Skip to content

Commit

Permalink
fix rebase (MystenLabs#3191)
Browse files Browse the repository at this point in the history
  • Loading branch information
punwai authored Jul 28, 2022
1 parent bc03727 commit 79417b4
Show file tree
Hide file tree
Showing 82 changed files with 1,133 additions and 678 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/sui-benchmark/src/benchmark/bench_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::default::Default;
use std::path::PathBuf;
use strum_macros::EnumString;
use sui_types::base_types::ObjectID;
use sui_types::crypto::{KeyPair, PublicKeyBytes};
use sui_types::crypto::{AccountKeyPair, AuthorityKeyPair, AuthorityPublicKeyBytes};

#[derive(Debug, Clone, Parser)]
#[clap(
Expand Down Expand Up @@ -205,9 +205,9 @@ impl std::fmt::Display for MicroBenchmarkResult {
pub struct RemoteLoadGenConfig {
/// Keypairs of all the validators
/// Ideally we wouldnt need this, but sometime we pre-sign certs
pub validator_keypairs: BTreeMap<PublicKeyBytes, KeyPair>,
pub validator_keypairs: BTreeMap<AuthorityPublicKeyBytes, AuthorityKeyPair>,
/// Account keypair to use for transactions
pub account_keypair: KeyPair,
pub account_keypair: AccountKeyPair,
/// ObjectID offset for transaction objects
pub object_id_offset: ObjectID,
/// Network config for accessing validators
Expand Down
16 changes: 8 additions & 8 deletions crates/sui-benchmark/src/benchmark/transaction_creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use sui_config::NetworkConfig;
use sui_types::{
base_types::*,
crypto::{
get_key_pair, AuthoritySignature, KeyPair, KeypairTraits, PublicKeyBytes, Signature,
SuiAuthoritySignature,
get_key_pair, AccountKeyPair, AuthorityPublicKeyBytes, AuthoritySignature, KeypairTraits,
Signature, SuiAuthoritySignature,
},
messages::*,
object::Object,
Expand Down Expand Up @@ -68,7 +68,7 @@ fn make_cert(network_config: &NetworkConfig, tx: &Transaction) -> CertifiedTrans
.get(i as usize)
.unwrap()
.key_pair();
let pubx: PublicKeyBytes = secx.public().into();
let pubx: AuthorityPublicKeyBytes = secx.public().into();
let sig = AuthoritySignature::new(&tx.data, secx);
sigs.push((pubx, sig));
}
Expand All @@ -81,7 +81,7 @@ fn make_cert(network_config: &NetworkConfig, tx: &Transaction) -> CertifiedTrans

fn make_transactions(
address: SuiAddress,
keypair: KeyPair,
keypair: AccountKeyPair,
network_config: &NetworkConfig,
account_gas_objects: &[(Vec<Object>, Object)],
batch_size: usize,
Expand All @@ -92,7 +92,7 @@ fn make_transactions(
account_gas_objects
.par_iter()
.map(|(objects, gas_obj)| {
let next_recipient: SuiAddress = get_key_pair().0;
let next_recipient: SuiAddress = get_key_pair::<AccountKeyPair>().0;
let mut single_kinds = vec![];
for object in objects {
single_kinds.push(make_transfer_transaction(
Expand Down Expand Up @@ -154,10 +154,10 @@ impl TransactionCreator {
use_move: bool,
chunk_size: usize,
num_chunks: usize,
sender: Option<&KeyPair>,
sender: Option<&AccountKeyPair>,
validator_preparer: &mut ValidatorPreparer,
) -> Vec<(Transaction, CertifiedTransaction)> {
let (address, keypair) = if let Some(a) = sender {
let (address, keypair): (_, AccountKeyPair) = if let Some(a) = sender {
(a.public().into(), a.copy())
} else {
get_key_pair()
Expand Down Expand Up @@ -222,7 +222,7 @@ impl TransactionCreator {
fn make_transactions(
&mut self,
address: SuiAddress,
key_pair: KeyPair,
key_pair: AccountKeyPair,
chunk_size: usize,
num_chunks: usize,
conn: usize,
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-benchmark/src/benchmark/validator_preparer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use sui_core::authority::*;
use sui_types::{
base_types::{SuiAddress, *},
committee::*,
crypto::{KeyPair, KeypairTraits, PublicKeyBytes},
crypto::{AuthorityKeyPair, AuthorityPublicKeyBytes, KeypairTraits},
gas_coin::GasCoin,
object::Object,
};
Expand Down Expand Up @@ -260,8 +260,8 @@ fn make_authority_state(
store_path: &Path,
db_cpus: i32,
committee: &Committee,
pubx: &PublicKeyBytes,
secx: KeyPair,
pubx: &AuthorityPublicKeyBytes,
secx: AuthorityKeyPair,
) -> (AuthorityState, Arc<AuthorityStore>) {
fs::create_dir(&store_path).unwrap();
info!("Open database on path: {:?}", store_path.as_os_str());
Expand Down
3 changes: 2 additions & 1 deletion crates/sui-benchmark/src/bin/bench_configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use clap::*;
use std::path::Path;
use sui_config::genesis_config::{AccountConfig, GenesisConfig, ObjectConfigRange};
use sui_config::Config;
use sui_types::crypto::AccountKeyPair;

use sui_types::{base_types::ObjectID, crypto::get_key_pair};

Expand Down Expand Up @@ -35,7 +36,7 @@ fn main() {
// For each load gen, create an account
for _ in 0..bch.number_of_generators {
// Create a keypair for this account
let (account_address, account_keypair) = get_key_pair();
let (account_address, account_keypair): (_, AccountKeyPair) = get_key_pair();

// Populate the range configs
let range_cfg = ObjectConfigRange {
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-benchmark/src/bin/remote_load_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use clap::*;
use futures::join;
use sui_benchmark::benchmark::bench_types::{MicroBenchmarkResult, RemoteLoadGenConfig};
use sui_benchmark::benchmark::load_generator::MultiFixedRateLoadGenerator;
use sui_types::crypto::AccountKeyPair;

use std::panic;
use std::path::PathBuf;
use sui_benchmark::benchmark::transaction_creator::TransactionCreator;
use sui_benchmark::benchmark::validator_preparer::ValidatorPreparer;
use sui_config::{NetworkConfig, PersistedConfig};
use sui_types::base_types::ObjectID;
use sui_types::crypto::KeyPair;
use tokio::runtime::Builder;

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -93,7 +93,7 @@ fn run_latency_microbench(
period_us: u64,

object_id_offset: ObjectID,
sender: &KeyPair,
sender: &AccountKeyPair,

network_config: NetworkConfig,

Expand Down
8 changes: 4 additions & 4 deletions crates/sui-benchmark/src/stress/transfer_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rand::seq::IteratorRandom;
use sui_config::NetworkConfig;
use sui_types::{
base_types::{ObjectID, ObjectRef, SuiAddress},
crypto::{get_key_pair, EmptySignInfo, KeyPair},
crypto::{get_key_pair, AccountKeyPair, EmptySignInfo},
messages::TransactionEnvelope,
object::{Object, Owner},
};
Expand All @@ -24,7 +24,7 @@ pub struct TransferObjectTestPayload {
transfer_from: SuiAddress,
transfer_to: SuiAddress,
gas: Vec<Gas>,
keypairs: Arc<HashMap<SuiAddress, KeyPair>>,
keypairs: Arc<HashMap<SuiAddress, AccountKeyPair>>,
}

impl Payload for TransferObjectTestPayload {
Expand Down Expand Up @@ -76,7 +76,7 @@ pub struct TransferObjectTestCtx {
transfer_gas: Vec<Vec<Object>>,
transfer_objects: Vec<Object>,
transfer_objects_owner: SuiAddress,
keypairs: Arc<HashMap<SuiAddress, KeyPair>>,
keypairs: Arc<HashMap<SuiAddress, AccountKeyPair>>,
}

impl TransferObjectTestCtx {
Expand All @@ -86,7 +86,7 @@ impl TransferObjectTestCtx {
_configs: &NetworkConfig,
) -> Box<dyn StressTestCtx<dyn Payload>> {
// create several accounts to transfer object between
let keypairs: Arc<HashMap<SuiAddress, KeyPair>> =
let keypairs: Arc<HashMap<SuiAddress, AccountKeyPair>> =
Arc::new((0..num_accounts).map(|_| get_key_pair()).collect());
// create enough gas to do those transfers
let gas: Vec<Vec<Object>> = (0..count)
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-cluster-test/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use sui_config::genesis_config::GenesisConfig;
use sui_swarm::memory::Node;
use sui_swarm::memory::Swarm;
use sui_types::crypto::KeypairTraits;
use sui_types::crypto::{get_key_pair, KeyPair};
use sui_types::crypto::{get_key_pair, AccountKeyPair};
use test_utils::network::{start_rpc_test_network_with_fullnode, TestNetwork};

const DEVNET_FAUCET_ADDR: &str = "https://faucet.devnet.sui.io:443";
Expand Down Expand Up @@ -43,7 +43,7 @@ pub trait Cluster {
fn rpc_url(&self) -> &str;
fn faucet_url(&self) -> Option<&str>;
fn fullnode_url(&self) -> &str;
fn user_key(&self) -> KeyPair;
fn user_key(&self) -> AccountKeyPair;
}

/// Represents an up and running cluster deployed remotely.
Expand Down Expand Up @@ -106,7 +106,7 @@ impl Cluster for RemoteRunningCluster {
fn faucet_url(&self) -> Option<&str> {
Some(&self.faucet_url)
}
fn user_key(&self) -> KeyPair {
fn user_key(&self) -> AccountKeyPair {
get_key_pair().1
}
}
Expand Down Expand Up @@ -161,7 +161,7 @@ impl Cluster for LocalNewCluster {
None
}

fn user_key(&self) -> KeyPair {
fn user_key(&self) -> AccountKeyPair {
self.swarm().config().account_keys[0].copy()
}
}
7 changes: 5 additions & 2 deletions crates/sui-cluster-test/src/test_case/native_transfer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use anyhow::bail;
use async_trait::async_trait;
use sui_json_rpc_types::SuiExecutionStatus;
use sui_types::{
crypto::get_key_pair, event::TransferType, object::Owner, SUI_FRAMEWORK_OBJECT_ID,
crypto::{get_key_pair, AccountKeyPair},
event::TransferType,
object::Owner,
SUI_FRAMEWORK_OBJECT_ID,
};
use tracing::info;
pub struct NativeTransferTest;
Expand All @@ -30,7 +33,7 @@ impl TestCaseImpl for NativeTransferTest {
let gas_obj = sui_objs.swap_remove(0);
let obj_to_transfer = sui_objs.swap_remove(0);
let signer = ctx.get_wallet_address();
let (recipient_addr, _) = get_key_pair();
let (recipient_addr, _): (_, AccountKeyPair) = get_key_pair();
let data = ctx
.get_gateway()
.public_transfer_object(
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-config/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{
};
use sui_types::{
base_types::encode_bytes_hex,
crypto::{get_key_pair_from_rng, KeypairTraits, PublicKeyBytes},
crypto::{get_key_pair_from_rng, AuthorityKeyPair, AuthorityPublicKeyBytes, KeypairTraits},
};

pub struct ConfigBuilder<R = OsRng> {
Expand Down Expand Up @@ -70,7 +70,7 @@ impl<R: ::rand::RngCore + ::rand::CryptoRng> ConfigBuilder<R> {
pub fn build(mut self) -> NetworkConfig {
let validators = (0..self.committee_size.get())
.map(|_| get_key_pair_from_rng(&mut self.rng).1)
.map(|key_pair| ValidatorGenesisInfo {
.map(|key_pair: AuthorityKeyPair| ValidatorGenesisInfo {
key_pair,
network_address: utils::new_network_address(),
stake: DEFAULT_STAKE,
Expand All @@ -91,7 +91,7 @@ impl<R: ::rand::RngCore + ::rand::CryptoRng> ConfigBuilder<R> {
.enumerate()
.map(|(i, validator)| {
let name = format!("validator-{i}");
let public_key: PublicKeyBytes = validator.key_pair.public().into();
let public_key: AuthorityPublicKeyBytes = validator.key_pair.public().into();
let stake = validator.stake;
let network_address = validator.network_address.clone();

Expand Down Expand Up @@ -130,7 +130,7 @@ impl<R: ::rand::RngCore + ::rand::CryptoRng> ConfigBuilder<R> {
let validator_configs = validators
.into_iter()
.map(|validator| {
let public_key: PublicKeyBytes = validator.key_pair.public().into();
let public_key: AuthorityPublicKeyBytes = validator.key_pair.public().into();
let db_path = self
.config_directory
.join(AUTHORITIES_DB_NAME)
Expand Down
11 changes: 5 additions & 6 deletions crates/sui-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ use sui_adapter::in_memory_storage::InMemoryStorage;
use sui_adapter::temporary_store::TemporaryStore;
use sui_types::base_types::ObjectID;
use sui_types::base_types::TransactionDigest;
use sui_types::crypto::PublicKey;
use sui_types::crypto::PublicKeyBytes;
use sui_types::crypto::{AuthorityPublicKey, AuthorityPublicKeyBytes};
use sui_types::gas::SuiGasStatus;
use sui_types::messages::CallArg;
use sui_types::messages::InputObjects;
Expand Down Expand Up @@ -61,7 +60,7 @@ impl Genesis {
)
}

pub fn narwhal_committee(&self) -> narwhal_config::SharedCommittee<PublicKey> {
pub fn narwhal_committee(&self) -> narwhal_config::SharedCommittee<AuthorityPublicKey> {
let narwhal_committee = self
.validator_set
.iter()
Expand Down Expand Up @@ -202,7 +201,7 @@ impl<'de> Deserialize<'de> for Genesis {

pub struct Builder {
objects: BTreeMap<ObjectID, Object>,
validators: BTreeMap<PublicKeyBytes, ValidatorInfo>,
validators: BTreeMap<AuthorityPublicKeyBytes, ValidatorInfo>,
}

impl Default for Builder {
Expand Down Expand Up @@ -515,7 +514,7 @@ mod test {
use super::Builder;
use crate::{genesis_config::GenesisConfig, utils, ValidatorInfo};
use narwhal_crypto::traits::KeyPair;
use sui_types::crypto::get_key_pair_from_rng;
use sui_types::crypto::{get_key_pair_from_rng, AuthorityKeyPair};

#[test]
fn roundtrip() {
Expand All @@ -535,7 +534,7 @@ mod test {
.generate_accounts(&mut rand::rngs::OsRng)
.unwrap();

let key = get_key_pair_from_rng(&mut rand::rngs::OsRng).1;
let key: AuthorityKeyPair = get_key_pair_from_rng(&mut rand::rngs::OsRng).1;
let validator = ValidatorInfo {
name: "0".into(),
public_key: key.public().into(),
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-config/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde_with::serde_as;
use std::collections::{BTreeMap, BTreeSet};
use sui_types::base_types::{ObjectID, SuiAddress};
use sui_types::committee::StakeUnit;
use sui_types::crypto::{get_key_pair_from_rng, KeyPair};
use sui_types::crypto::{get_key_pair_from_rng, AccountKeyPair, AuthorityKeyPair};
use sui_types::object::Object;
use sui_types::sui_serde::KeyPairBase64;
use tracing::info;
Expand All @@ -28,7 +28,7 @@ impl GenesisConfig {
pub fn generate_accounts<R: ::rand::RngCore + ::rand::CryptoRng>(
&self,
mut rng: R,
) -> Result<(Vec<KeyPair>, Vec<Object>)> {
) -> Result<(Vec<AccountKeyPair>, Vec<Object>)> {
let mut addresses = Vec::new();
let mut preload_objects = Vec::new();
let mut all_preload_objects_set = BTreeSet::new();
Expand Down Expand Up @@ -85,7 +85,7 @@ impl GenesisConfig {
#[derive(Serialize, Deserialize, Debug)]
pub struct ValidatorGenesisInfo {
#[serde_as(as = "KeyPairBase64")]
pub key_pair: KeyPair,
pub key_pair: AuthorityKeyPair,
pub network_address: Multiaddr,
pub stake: StakeUnit,
pub narwhal_primary_to_primary: Multiaddr,
Expand Down
Loading

0 comments on commit 79417b4

Please sign in to comment.