Skip to content

Commit 2a1688a

Browse files
committed
[antithesis] randomize max_tx_per_checkpoint in test
1 parent 2ff7011 commit 2a1688a

12 files changed

+1829
-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,157 @@
1+
---
2+
source: crates/sui-core/src/authority/execution_time_estimator.rs
3+
expression: snapshot_data
4+
---
5+
protocol_version: 113
6+
consensus_observations:
7+
- - MakeMoveVec
8+
- observations:
9+
- - 2
10+
- secs: 0
11+
nanos: 27000000
12+
- - 7
13+
- secs: 0
14+
nanos: 18000000
15+
- - 10
16+
- secs: 0
17+
nanos: 20000000
18+
- - 1
19+
- secs: 0
20+
nanos: 25000000
21+
stake_weighted_median:
22+
secs: 0
23+
nanos: 25000000
24+
- - MergeCoins
25+
- observations:
26+
- - 9
27+
- secs: 0
28+
nanos: 64000000
29+
- - 2
30+
- secs: 0
31+
nanos: 62000000
32+
- - 2
33+
- secs: 0
34+
nanos: 32000000
35+
- - 7
36+
- secs: 0
37+
nanos: 0
38+
stake_weighted_median:
39+
secs: 0
40+
nanos: 62000000
41+
- - SplitCoins
42+
- observations:
43+
- - 6
44+
- secs: 0
45+
nanos: 42000000
46+
- - 3
47+
- secs: 0
48+
nanos: 25000000
49+
- - 8
50+
- secs: 0
51+
nanos: 67000000
52+
- - 3
53+
- secs: 0
54+
nanos: 61000000
55+
stake_weighted_median:
56+
secs: 0
57+
nanos: 61000000
58+
- - TransferObjects
59+
- observations:
60+
- - 1
61+
- secs: 0
62+
nanos: 13000000
63+
- - 10
64+
- secs: 0
65+
nanos: 80000000
66+
- - 0
67+
- ~
68+
- - 9
69+
- secs: 0
70+
nanos: 39000000
71+
stake_weighted_median:
72+
secs: 0
73+
nanos: 39000000
74+
- - Upgrade
75+
- observations:
76+
- - 0
77+
- ~
78+
- - 8
79+
- secs: 0
80+
nanos: 389000000
81+
- - 10
82+
- secs: 0
83+
nanos: 274000000
84+
- - 4
85+
- secs: 0
86+
nanos: 587000000
87+
stake_weighted_median:
88+
secs: 0
89+
nanos: 389000000
90+
- - MoveEntryPoint:
91+
package: "0x0000000000000000000000000000000000000000000000000000000000000001"
92+
module: coin
93+
function: transfer
94+
type_arguments: []
95+
- observations:
96+
- - 7
97+
- secs: 0
98+
nanos: 404000000
99+
- - 6
100+
- secs: 0
101+
nanos: 162000000
102+
- - 9
103+
- secs: 0
104+
nanos: 268000000
105+
- - 3
106+
- secs: 0
107+
nanos: 254000000
108+
stake_weighted_median:
109+
secs: 0
110+
nanos: 268000000
111+
- - MoveEntryPoint:
112+
package: "0x0000000000000000000000000000000000000000000000000000000000000002"
113+
module: nft
114+
function: mint
115+
type_arguments: []
116+
- observations:
117+
- - 0
118+
- ~
119+
- - 0
120+
- ~
121+
- - 2
122+
- secs: 0
123+
nanos: 142000000
124+
- - 8
125+
- secs: 0
126+
nanos: 499000000
127+
stake_weighted_median:
128+
secs: 0
129+
nanos: 499000000
130+
transaction_estimates:
131+
- - coin_transfer_call
132+
- secs: 0
133+
nanos: 268000000
134+
- - mixed_move_calls
135+
- secs: 0
136+
nanos: 767000000
137+
- - native_commands_with_observations
138+
- secs: 0
139+
nanos: 374000000
140+
- - transfer_objects_2_items
141+
- secs: 0
142+
nanos: 117000000
143+
- - split_coins_3_amounts
144+
- secs: 0
145+
nanos: 244000000
146+
- - merge_coins_3_sources
147+
- secs: 0
148+
nanos: 248000000
149+
- - make_move_vec_4_elements
150+
- secs: 0
151+
nanos: 125000000
152+
- - mixed_commands
153+
- secs: 0
154+
nanos: 240000000
155+
- - upgrade_package
156+
- secs: 0
157+
nanos: 389000000

crates/sui-core/src/consensus_handler.rs

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

661661
if current_tx_count + next_tx_count > max_tx && !current_roots.is_empty() {
662-
assert_reachable!("checkpoint split due to transaction limit");
662+
assert_reachable!(
663+
"checkpoint flush split due to batched roots exceeding transaction limit"
664+
);
663665
let details = current_details.unwrap();
664666
pending_checkpoints.push(PendingCheckpointV2 {
665667
roots: std::mem::take(&mut current_roots),
@@ -1739,7 +1741,17 @@ impl<C: CheckpointServiceNotify + Send + Sync> ConsensusHandler<C> {
17391741
.collect()
17401742
};
17411743

1744+
let num_schedulables = schedulables.len();
17421745
let chunked_schedulables = build_chunks(schedulables, &mut checkpoint_queue);
1746+
if chunked_schedulables.len() > 1 {
1747+
info!(
1748+
"Splitting transactions into {} checkpoint chunks (num_schedulables={}, max_tx={})",
1749+
chunked_schedulables.len(),
1750+
num_schedulables,
1751+
max_transactions_per_checkpoint
1752+
);
1753+
assert_reachable!("checkpoint split due to transaction limit");
1754+
}
17431755
let chunked_randomness_schedulables = if should_write_random_checkpoint {
17441756
build_chunks(randomness_schedulables, &mut checkpoint_queue)
17451757
} 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": "112",
1297+
"maxSupportedProtocolVersion": "113",
12981298
"protocolVersion": "6",
12991299
"featureFlags": {
13001300
"abstract_size_in_object_runtime": false,
@@ -1406,6 +1406,7 @@
14061406
"prepend_prologue_tx_in_consensus_commit_in_checkpoints": false,
14071407
"private_generics_verifier_v2": false,
14081408
"random_beacon": false,
1409+
"randomize_checkpoint_tx_limit_in_tests": false,
14091410
"receive_objects": false,
14101411
"recompute_has_public_transfer_in_execution": false,
14111412
"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: 29 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 = 112;
27+
const MAX_PROTOCOL_VERSION: u64 = 113;
2828

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

301302
#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
302303
pub struct ProtocolVersion(u64);
@@ -989,6 +990,9 @@ struct FeatureFlags {
989990
// If true perform consistent verification of metadata
990991
#[serde(skip_serializing_if = "is_false")]
991992
validator_metadata_verify_v2: bool,
993+
994+
#[serde(skip_serializing_if = "is_false")]
995+
randomize_checkpoint_tx_limit_in_tests: bool,
992996
}
993997

994998
fn is_false(b: &bool) -> bool {
@@ -4588,6 +4592,9 @@ impl ProtocolConfig {
45884592
cfg.feature_flags.enable_ristretto255_group_ops = true;
45894593
}
45904594
}
4595+
113 => {
4596+
cfg.feature_flags.randomize_checkpoint_tx_limit_in_tests = true;
4597+
}
45914598
// Use this template when making changes:
45924599
//
45934600
// // modify an existing constant.
@@ -4602,15 +4609,28 @@ impl ProtocolConfig {
46024609
}
46034610
}
46044611

4605-
// Simtest specific overrides.
4606-
if cfg!(msim) {
4607-
// Trigger checkpoint splitting more often.
4608-
// cfg.max_transactions_per_checkpoint = Some(10);
4609-
// FIXME: Re-introduce this once we resolve the checkpoint splitting issue
4610-
// in the quarantine output.
4612+
cfg
4613+
}
4614+
4615+
pub fn apply_seeded_test_overrides(&mut self, seed: &[u8; 32]) {
4616+
if !self.feature_flags.randomize_checkpoint_tx_limit_in_tests {
4617+
return;
46114618
}
46124619

4613-
cfg
4620+
let should_apply = if cfg!(msim) {
4621+
true
4622+
} else {
4623+
mysten_common::in_antithesis()
4624+
};
4625+
if !should_apply {
4626+
return;
4627+
}
4628+
4629+
use rand::{Rng, SeedableRng, rngs::StdRng};
4630+
let mut rng = StdRng::from_seed(*seed);
4631+
let max_txns = rng.gen_range(10..=100u64);
4632+
info!("seeded test override: max_transactions_per_checkpoint = {max_txns}");
4633+
self.max_transactions_per_checkpoint = Some(max_txns);
46144634
}
46154635

46164636
// Extract the bytecode verifier config from this protocol config.
@@ -4924,6 +4944,7 @@ impl ProtocolConfig {
49244944
self.feature_flags.enable_authenticated_event_streams = true;
49254945
self.feature_flags
49264946
.include_checkpoint_artifacts_digest_in_summary = true;
4947+
self.feature_flags.split_checkpoints_in_consensus_handler = true;
49274948
}
49284949

49294950
pub fn disable_authenticated_event_streams_for_testing(&mut self) {

0 commit comments

Comments
 (0)