Skip to content

Commit fac24ec

Browse files
committed
randomize tx limits in test per epoch
1 parent 00db2e4 commit fac24ec

File tree

6 files changed

+40
-14
lines changed

6 files changed

+40
-14
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/mysten-common/src/random.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
// Copyright (c) Mysten Labs, Inc.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
use rand::SeedableRng;
5+
use rand::rngs::StdRng;
6+
47
use crate::in_antithesis;
58

9+
pub fn seeded_rng(seed: &[u8; 32]) -> StdRng {
10+
StdRng::from_seed(*seed)
11+
}
12+
613
/// Get a random number generator.
714
///
815
/// If we are running in antithesis mode, use the antithesis RNG.

crates/sui-core/src/authority/authority_per_epoch_store.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,9 @@ impl AuthorityPerEpochStore {
11111111
chain_from_id, chain.1
11121112
);
11131113

1114-
let protocol_config = ProtocolConfig::get_for_version(protocol_version, chain.1);
1114+
let mut protocol_config = ProtocolConfig::get_for_version(protocol_version, chain.1);
1115+
protocol_config
1116+
.apply_seeded_test_overrides(epoch_start_configuration.epoch_digest().inner());
11151117

11161118
let execution_component = ExecutionComponents::new(
11171119
&protocol_config,

crates/sui-core/src/consensus_handler.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,9 @@ impl CheckpointQueue {
644644
let next_tx_count = queued.roots.tx_roots.len();
645645

646646
if current_tx_count + next_tx_count > max_tx && !current_roots.is_empty() {
647-
assert_reachable!("checkpoint split due to transaction limit");
647+
assert_reachable!(
648+
"checkpoint flush split due to batched roots exceeding transaction limit"
649+
);
648650
let details = current_details.unwrap();
649651
pending_checkpoints.push(PendingCheckpointV2 {
650652
roots: std::mem::take(&mut current_roots),
@@ -1710,7 +1712,17 @@ impl<C: CheckpointServiceNotify + Send + Sync> ConsensusHandler<C> {
17101712
.collect()
17111713
};
17121714

1715+
let num_schedulables = schedulables.len();
17131716
let chunked_schedulables = build_chunks(schedulables, &mut checkpoint_queue);
1717+
if chunked_schedulables.len() > 1 {
1718+
info!(
1719+
"Splitting transactions into {} checkpoint chunks (num_schedulables={}, max_tx={})",
1720+
chunked_schedulables.len(),
1721+
num_schedulables,
1722+
max_transactions_per_checkpoint
1723+
);
1724+
assert_reachable!("checkpoint split due to transaction limit");
1725+
}
17141726
let chunked_randomness_schedulables = if should_write_random_checkpoint {
17151727
build_chunks(randomness_schedulables, &mut checkpoint_queue)
17161728
} else {

crates/sui-protocol-config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ fastcrypto = { workspace = true }
2222
move-core-types.workspace = true
2323
move-binary-format.workspace = true
2424
mysten-common.workspace = true
25+
rand.workspace = true
2526

2627
[dev-dependencies]
2728
insta.workspace = true

crates/sui-protocol-config/src/lib.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4554,21 +4554,24 @@ impl ProtocolConfig {
45544554
}
45554555
}
45564556

4557-
// Simtest specific overrides.
4558-
if cfg!(msim) {
4559-
// Trigger checkpoint splitting more often.
4560-
// cfg.max_transactions_per_checkpoint = Some(10);
4561-
// FIXME: Re-introduce this once we resolve the checkpoint splitting issue
4562-
// in the quarantine output.
4563-
}
4557+
cfg
4558+
}
45644559

4565-
// Antithesis specific overrides.
4566-
#[cfg(not(msim))]
4567-
if mysten_common::in_antithesis() {
4568-
cfg.max_transactions_per_checkpoint = Some(100);
4560+
pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4561+
let should_apply = if cfg!(msim) {
4562+
true
4563+
} else {
4564+
mysten_common::in_antithesis()
4565+
};
4566+
if !should_apply {
4567+
return;
45694568
}
45704569

4571-
cfg
4570+
use rand::Rng;
4571+
let mut rng = mysten_common::random::seeded_rng(seed);
4572+
let max_txns = rng.gen_range(10..=100u64);
4573+
info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4574+
self.max_transactions_per_checkpoint = Some(max_txns);
45724575
}
45734576

45744577
// Extract the bytecode verifier config from this protocol config.

0 commit comments

Comments
 (0)