Skip to content

Commit 336a6e7

Browse files
committed
[antithesis] randomize max_tx_per_checkpoint in test
1 parent 28c2dc5 commit 336a6e7

12 files changed

+1801
-27
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/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,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
source: crates/sui-core/src/authority/execution_time_estimator.rs
3+
expression: snapshot_data
4+
---
5+
protocol_version: 112
6+
consensus_observations:
7+
- - MakeMoveVec
8+
- observations:
9+
- - 0
10+
- ~
11+
- - 4
12+
- secs: 0
13+
nanos: 28000000
14+
- - 5
15+
- secs: 0
16+
nanos: 19000000
17+
- - 9
18+
- secs: 0
19+
nanos: 19000000
20+
stake_weighted_median:
21+
secs: 0
22+
nanos: 19000000
23+
- - MergeCoins
24+
- observations:
25+
- - 6
26+
- secs: 0
27+
nanos: 63000000
28+
- - 9
29+
- secs: 0
30+
nanos: 26000000
31+
- - 2
32+
- secs: 0
33+
nanos: 32000000
34+
- - 7
35+
- secs: 0
36+
nanos: 0
37+
stake_weighted_median:
38+
secs: 0
39+
nanos: 32000000
40+
- - SplitCoins
41+
- observations:
42+
- - 7
43+
- secs: 0
44+
nanos: 21000000
45+
- - 0
46+
- ~
47+
- - 10
48+
- secs: 0
49+
nanos: 72000000
50+
- - 6
51+
- secs: 0
52+
nanos: 40000000
53+
stake_weighted_median:
54+
secs: 0
55+
nanos: 40000000
56+
- - TransferObjects
57+
- observations:
58+
- - 9
59+
- secs: 0
60+
nanos: 70000000
61+
- - 10
62+
- secs: 0
63+
nanos: 52000000
64+
- - 0
65+
- ~
66+
- - 9
67+
- secs: 0
68+
nanos: 91000000
69+
stake_weighted_median:
70+
secs: 0
71+
nanos: 70000000
72+
- - Upgrade
73+
- observations:
74+
- - 2
75+
- secs: 0
76+
nanos: 177000000
77+
- - 0
78+
- ~
79+
- - 6
80+
- secs: 0
81+
nanos: 981000000
82+
- - 4
83+
- secs: 0
84+
nanos: 587000000
85+
stake_weighted_median:
86+
secs: 0
87+
nanos: 587000000
88+
- - MoveEntryPoint:
89+
package: "0x0000000000000000000000000000000000000000000000000000000000000001"
90+
module: coin
91+
function: transfer
92+
type_arguments: []
93+
- observations:
94+
- - 8
95+
- secs: 0
96+
nanos: 337000000
97+
- - 6
98+
- secs: 0
99+
nanos: 162000000
100+
- - 9
101+
- secs: 0
102+
nanos: 268000000
103+
- - 5
104+
- secs: 0
105+
nanos: 262000000
106+
stake_weighted_median:
107+
secs: 0
108+
nanos: 268000000
109+
- - MoveEntryPoint:
110+
package: "0x0000000000000000000000000000000000000000000000000000000000000002"
111+
module: nft
112+
function: mint
113+
type_arguments: []
114+
- observations:
115+
- - 0
116+
- ~
117+
- - 7
118+
- secs: 0
119+
nanos: 70000000
120+
- - 10
121+
- secs: 0
122+
nanos: 224000000
123+
- - 8
124+
- secs: 0
125+
nanos: 499000000
126+
stake_weighted_median:
127+
secs: 0
128+
nanos: 224000000
129+
transaction_estimates:
130+
- - coin_transfer_call
131+
- secs: 0
132+
nanos: 268000000
133+
- - mixed_move_calls
134+
- secs: 0
135+
nanos: 492000000
136+
- - native_commands_with_observations
137+
- secs: 0
138+
nanos: 322000000
139+
- - transfer_objects_3_items
140+
- secs: 0
141+
nanos: 280000000
142+
- - split_coins_4_amounts
143+
- secs: 0
144+
nanos: 200000000
145+
- - merge_coins_3_sources
146+
- secs: 0
147+
nanos: 128000000
148+
- - make_move_vec_3_elements
149+
- secs: 0
150+
nanos: 76000000
151+
- - mixed_commands
152+
- secs: 0
153+
nanos: 291000000
154+
- - upgrade_package
155+
- secs: 0
156+
nanos: 587000000

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-open-rpc/tests/snapshots/generate_spec__openrpc.snap.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@
12941294
"name": "Result",
12951295
"value": {
12961296
"minSupportedProtocolVersion": "1",
1297-
"maxSupportedProtocolVersion": "111",
1297+
"maxSupportedProtocolVersion": "112",
12981298
"protocolVersion": "6",
12991299
"featureFlags": {
13001300
"abstract_size_in_object_runtime": false,
@@ -1405,6 +1405,7 @@
14051405
"prepend_prologue_tx_in_consensus_commit_in_checkpoints": false,
14061406
"private_generics_verifier_v2": false,
14071407
"random_beacon": false,
1408+
"randomize_checkpoint_tx_limit_in_tests": false,
14081409
"receive_objects": false,
14091410
"recompute_has_public_transfer_in_execution": false,
14101411
"record_additional_state_digest_in_prologue": false,

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: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use tracing::{info, warn};
2424

2525
/// The minimum and maximum protocol versions supported by this build.
2626
const MIN_PROTOCOL_VERSION: u64 = 1;
27-
const MAX_PROTOCOL_VERSION: u64 = 111;
27+
const MAX_PROTOCOL_VERSION: u64 = 112;
2828

2929
// Record history of protocol version allocations here:
3030
//
@@ -296,6 +296,7 @@ const MAX_PROTOCOL_VERSION: u64 = 111;
296296
// split_checkpoints_in_consensus_handler in devnet
297297
// Enable additional validation on zkLogin public identifier.
298298
// Version 111: Validator metadata
299+
// Version 112: Gate seeded test overrides for checkpoint tx limit behind feature flag.
299300

300301
#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
301302
pub struct ProtocolVersion(u64);
@@ -984,6 +985,9 @@ struct FeatureFlags {
984985
// If true perform consistent verification of metadata
985986
#[serde(skip_serializing_if = "is_false")]
986987
validator_metadata_verify_v2: bool,
988+
989+
#[serde(skip_serializing_if = "is_false")]
990+
randomize_checkpoint_tx_limit_in_tests: bool,
987991
}
988992

989993
fn is_false(b: &bool) -> bool {
@@ -2574,6 +2578,10 @@ impl ProtocolConfig {
25742578
self.feature_flags.split_checkpoints_in_consensus_handler
25752579
}
25762580

2581+
pub fn randomize_checkpoint_tx_limit_in_tests(&self) -> bool {
2582+
self.feature_flags.randomize_checkpoint_tx_limit_in_tests
2583+
}
2584+
25772585
pub fn consensus_always_accept_system_transactions(&self) -> bool {
25782586
self.feature_flags
25792587
.consensus_always_accept_system_transactions
@@ -4540,6 +4548,9 @@ impl ProtocolConfig {
45404548
111 => {
45414549
cfg.feature_flags.validator_metadata_verify_v2 = true;
45424550
}
4551+
112 => {
4552+
cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4553+
}
45434554
// Use this template when making changes:
45444555
//
45454556
// // modify an existing constant.
@@ -4554,15 +4565,28 @@ impl ProtocolConfig {
45544565
}
45554566
}
45564567

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.
4568+
cfg
4569+
}
4570+
4571+
pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4572+
if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests {
4573+
return;
45634574
}
45644575

4565-
cfg
4576+
let should_apply = if cfg!(msim) {
4577+
true
4578+
} else {
4579+
mysten_common::in_antithesis()
4580+
};
4581+
if !should_apply {
4582+
return;
4583+
}
4584+
4585+
use rand::{Rng, SeedableRng, rngs::StdRng};
4586+
let mut rng = StdRng::from_seed(*seed);
4587+
let max_txns = rng.gen_range(10..=100u64);
4588+
info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4589+
self.max_transactions_per_checkpoint = Some(max_txns);
45664590
}
45674591

45684592
// Extract the bytecode verifier config from this protocol config.
@@ -4876,6 +4900,7 @@ impl ProtocolConfig {
48764900
self.feature_flags.enable_authenticated_event_streams = true;
48774901
self.feature_flags
48784902
.include_checkpoint_artifacts_digest_in_summary = true;
4903+
self.feature_flags.split_checkpoints_in_consensus_handler = true;
48794904
}
48804905

48814906
pub fn disable_authenticated_event_streams_for_testing(&mut self) {

0 commit comments

Comments
 (0)