Skip to content

Commit

Permalink
Support for setting committee size and number of shared objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mystenmark committed Nov 15, 2022
1 parent 4687dda commit 4465503
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
13 changes: 11 additions & 2 deletions crates/sui-benchmark/tests/simtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ mod test {

#[sim_test(config = "test_config()")]
async fn test_simulated_load() {
let test_cluster = init_cluster_builder_env_aware().build().await.unwrap();
let test_cluster = init_cluster_builder_env_aware()
.with_num_validators(get_var("SIM_STRESS_TEST_NUM_VALIDATORS", 4))
.build()
.await
.unwrap();
let swarm = &test_cluster.swarm;
let context = &test_cluster.wallet;
let sender = test_cluster.get_address_0();
Expand Down Expand Up @@ -85,7 +89,12 @@ mod test {
);

for w in workloads.iter_mut() {
w.workload.init(5, proxy.clone()).await;
w.workload
.init(
get_var("SIM_STRESS_TEST_NUM_SHARED_OBJECTS", 5),
proxy.clone(),
)
.await;
}

let driver = BenchDriver::new(5);
Expand Down
12 changes: 10 additions & 2 deletions crates/sui-storage/src/lock_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use typed_store::traits::Map;
use typed_store::traits::TypedStoreDebug;
use typed_store_derive::DBMapUtils;

use sui_types::base_types::{ObjectRef, TransactionDigest};
use sui_types::base_types::{ObjectID, ObjectRef, TransactionDigest};
use sui_types::batch::TxSequenceNumber;
use sui_types::committee::EpochId;
use sui_types::error::{SuiError, SuiResult};
Expand Down Expand Up @@ -340,7 +340,15 @@ impl LockServiceImpl {

let write_batch = write_batch.insert_batch(
&self.transaction_lock,
objects.iter().map(|obj_ref| (obj_ref, None)),
objects.iter().map(|obj_ref| {
if obj_ref.0
== ObjectID::from_hex_literal("0x1a1096087b3df46667da611b10b760bfc3ce8088")
.unwrap()
{
error!(object = ?obj_ref, "creating lock");
}
(obj_ref, None)
}),
)?;

Ok(write_batch)
Expand Down
24 changes: 16 additions & 8 deletions crates/test-utils/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub struct TestClusterBuilder {
fullnode_rpc_port: Option<u16>,
fullnode_ws_port: Option<u16>,
do_not_build_fullnode: bool,
num_validators: Option<usize>,
}

impl TestClusterBuilder {
Expand All @@ -106,6 +107,7 @@ impl TestClusterBuilder {
fullnode_rpc_port: None,
fullnode_ws_port: None,
do_not_build_fullnode: false,
num_validators: None,
}
}

Expand All @@ -129,6 +131,11 @@ impl TestClusterBuilder {
self
}

pub fn with_num_validators(mut self, num: usize) -> Self {
self.num_validators = Some(num);
self
}

pub async fn build(self) -> anyhow::Result<TestCluster> {
let cluster = self.start_test_network_with_customized_ports().await?;
#[cfg(msim)]
Expand All @@ -141,7 +148,9 @@ impl TestClusterBuilder {
Ok(cluster)
}

async fn start_test_network_with_customized_ports(self) -> Result<TestCluster, anyhow::Error> {
async fn start_test_network_with_customized_ports(
mut self,
) -> Result<TestCluster, anyhow::Error> {
// Where does wallet client connect to?
// 1. `start_test_swarm_with_fullnodes` init the wallet to use an embedded
// Gateway. If `use_embedded_gateway` is true, the config remains intact.
Expand All @@ -150,7 +159,7 @@ impl TestClusterBuilder {
// 3. Otherwise, the wallet connects to Fullnode rpc server, unless
// `do_not_build_fullnode` is false, in which case the wallet is connected
// with the initial embedded Gateway.
let swarm = Self::start_test_swarm_with_fullnodes(self.genesis_config).await?;
let swarm = self.start_test_swarm_with_fullnodes().await?;
let working_dir = swarm.dir();

let mut wallet_conf: SuiClientConfig =
Expand Down Expand Up @@ -195,13 +204,12 @@ impl TestClusterBuilder {
}

/// Start a Swarm and set up WalletConfig with an embedded Gateway
async fn start_test_swarm_with_fullnodes(
genesis_config: Option<GenesisConfig>,
) -> Result<Swarm, anyhow::Error> {
let mut builder: SwarmBuilder =
Swarm::builder().committee_size(NonZeroUsize::new(NUM_VALIDAOTR).unwrap());
async fn start_test_swarm_with_fullnodes(&mut self) -> Result<Swarm, anyhow::Error> {
let mut builder: SwarmBuilder = Swarm::builder().committee_size(
NonZeroUsize::new(self.num_validators.unwrap_or(NUM_VALIDAOTR)).unwrap(),
);

if let Some(genesis_config) = genesis_config {
if let Some(genesis_config) = self.genesis_config.take() {
builder = builder.initial_accounts_config(genesis_config);
}

Expand Down

0 comments on commit 4465503

Please sign in to comment.