Skip to content

Commit 486ac44

Browse files
committed
apollo_integration_tests: add proposal margins to end to end flow args
1 parent bf7af36 commit 486ac44

File tree

5 files changed

+66
-16
lines changed

5 files changed

+66
-16
lines changed

crates/apollo_integration_tests/src/flow_test_setup.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ use crate::utils::{
6565
spawn_local_eth_to_strk_oracle,
6666
spawn_local_success_recorder,
6767
AccumulatedTransactions,
68+
ProposalMarginMillis,
6869
};
6970

7071
pub const NUM_OF_SEQUENCERS: usize = 2;
@@ -95,6 +96,7 @@ impl FlowTestSetup {
9596
test_unique_index: u16,
9697
block_max_capacity_gas: GasAmount,
9798
allow_bootstrap_txs: bool,
99+
proposal_margin_millis: Option<ProposalMarginMillis>,
98100
) -> Self {
99101
let chain_info = ChainInfo::create_for_testing();
100102
let mut available_ports = AvailablePorts::new(test_unique_index, 0);
@@ -104,6 +106,7 @@ impl FlowTestSetup {
104106
create_consensus_manager_configs_and_channels(
105107
available_ports.get_next_ports(NUM_OF_SEQUENCERS + 1),
106108
&chain_info.chain_id,
109+
proposal_margin_millis,
107110
);
108111
let [sequencer_0_consensus_manager_config, sequencer_1_consensus_manager_config] =
109112
consensus_manager_configs.try_into().unwrap();
@@ -322,6 +325,7 @@ impl FlowSequencerSetup {
322325
pub fn create_consensus_manager_configs_and_channels(
323326
ports: Vec<u16>,
324327
chain_id: &ChainId,
328+
proposal_margin_millis: Option<ProposalMarginMillis>,
325329
) -> (
326330
Vec<ConsensusManagerConfig>,
327331
BroadcastTopicChannels<StreamMessage<ProposalPart, HeightAndRound>>,
@@ -335,6 +339,7 @@ pub fn create_consensus_manager_configs_and_channels(
335339
network_configs,
336340
n_network_configs,
337341
chain_id,
342+
proposal_margin_millis,
338343
);
339344

340345
for (i, config) in consensus_manager_configs.iter_mut().enumerate() {

crates/apollo_integration_tests/src/integration_test_manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ async fn get_sequencer_setup_configs(
11111111
),
11121112
component_configs_len,
11131113
&chain_info.chain_id,
1114+
None,
11141115
);
11151116

11161117
let node_indices: HashSet<usize> = (0..component_configs_len).collect();

crates/apollo_integration_tests/src/utils.rs

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ pub type CreateL1ToL2MessagesArgsFn =
101101
fn(&mut MultiAccountTransactionGenerator) -> Vec<L1HandlerTransaction>;
102102
pub type TestTxHashesFn = fn(&[TransactionHash]) -> Vec<TransactionHash>;
103103

104+
#[derive(Clone, Copy, Debug)]
105+
pub struct ProposalMarginMillis {
106+
pub build_proposal_margin_millis: Duration,
107+
pub validate_proposal_margin_millis: Duration,
108+
}
109+
110+
impl ProposalMarginMillis {
111+
pub fn new(build_proposal_margin_millis: u64, validate_proposal_margin_millis: u64) -> Self {
112+
Self {
113+
build_proposal_margin_millis: Duration::from_millis(build_proposal_margin_millis),
114+
validate_proposal_margin_millis: Duration::from_millis(validate_proposal_margin_millis),
115+
}
116+
}
117+
}
118+
104119
pub trait TestScenario {
105120
fn create_txs(
106121
&self,
@@ -339,6 +354,7 @@ pub(crate) fn create_consensus_manager_configs_from_network_configs(
339354
network_configs: Vec<NetworkConfig>,
340355
n_composed_nodes: usize,
341356
chain_id: &ChainId,
357+
proposal_margin_millis: Option<ProposalMarginMillis>,
342358
) -> Vec<ConsensusManagerConfig> {
343359
let num_validators = u64::try_from(n_composed_nodes).unwrap();
344360
let mut timeouts = TimeoutsConfig::default();
@@ -347,7 +363,21 @@ pub(crate) fn create_consensus_manager_configs_from_network_configs(
347363
network_configs
348364
.into_iter()
349365
// TODO(Matan): Get config from default config file.
350-
.map(|network_config| ConsensusManagerConfig {
366+
.map(|network_config| {
367+
let mut context_config = ContextConfig {
368+
static_config: ContextStaticConfig {
369+
num_validators,
370+
chain_id: chain_id.clone(),
371+
builder_address: ContractAddress::from(4_u128),
372+
..Default::default()
373+
},
374+
..Default::default()
375+
};
376+
if let Some(build_margin_millis) = proposal_margin_millis {
377+
context_config.static_config.build_proposal_margin_millis = build_margin_millis.build_proposal_margin_millis;
378+
context_config.static_config.validate_proposal_margin_millis = build_margin_millis.validate_proposal_margin_millis;
379+
}
380+
ConsensusManagerConfig {
351381
network_config,
352382
consensus_manager_config: ConsensusConfig {
353383
dynamic_config: ConsensusDynamicConfig {
@@ -365,21 +395,13 @@ pub(crate) fn create_consensus_manager_configs_from_network_configs(
365395
startup_delay: Duration::from_secs(15),
366396
},
367397
},
368-
context_config: ContextConfig {
369-
static_config: ContextStaticConfig {
370-
num_validators,
371-
chain_id: chain_id.clone(),
372-
builder_address: ContractAddress::from(4_u128),
373-
..Default::default()
374-
},
375-
..Default::default()
376-
},
398+
context_config,
377399
cende_config: CendeConfig {
378400
..Default::default()
379401
},
380402
assume_no_malicious_validators: true,
381403
..Default::default()
382-
})
404+
}})
383405
.collect()
384406
}
385407

crates/apollo_integration_tests/tests/common/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use apollo_integration_tests::utils::{
1919
run_test_scenario,
2020
CreateL1ToL2MessagesArgsFn,
2121
CreateRpcTxsFn,
22+
ProposalMarginMillis,
2223
TestTxHashesFn,
2324
};
2425
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
@@ -34,6 +35,7 @@ pub struct EndToEndFlowArgs {
3435
pub expecting_full_blocks: bool,
3536
pub expecting_reverted_transactions: bool,
3637
pub allow_bootstrap_txs: bool,
38+
pub proposal_margin_millis: Option<ProposalMarginMillis>,
3739
}
3840

3941
impl EndToEndFlowArgs {
@@ -49,6 +51,7 @@ impl EndToEndFlowArgs {
4951
expecting_full_blocks: false,
5052
expecting_reverted_transactions: false,
5153
allow_bootstrap_txs: false,
54+
proposal_margin_millis: None,
5255
}
5356
}
5457

@@ -63,6 +66,20 @@ impl EndToEndFlowArgs {
6366
pub fn allow_bootstrap_txs(self) -> Self {
6467
Self { allow_bootstrap_txs: true, ..self }
6568
}
69+
70+
pub fn proposal_margin_millis(
71+
self,
72+
build_proposal_margin_millis: u64,
73+
validate_proposal_margin_millis: u64,
74+
) -> Self {
75+
Self {
76+
proposal_margin_millis: Some(ProposalMarginMillis::new(
77+
build_proposal_margin_millis,
78+
validate_proposal_margin_millis,
79+
)),
80+
..self
81+
}
82+
}
6683
}
6784

6885
// Note: run integration/flow tests from separate files in `tests/`, which helps cargo ensure
@@ -76,6 +93,7 @@ pub async fn end_to_end_flow(args: EndToEndFlowArgs) {
7693
expecting_full_blocks,
7794
expecting_reverted_transactions,
7895
allow_bootstrap_txs,
96+
proposal_margin_millis,
7997
} = args;
8098
configure_tracing().await;
8199

@@ -91,6 +109,7 @@ pub async fn end_to_end_flow(args: EndToEndFlowArgs) {
91109
test_identifier.into(),
92110
block_max_capacity_gas,
93111
allow_bootstrap_txs,
112+
proposal_margin_millis,
94113
)
95114
.await;
96115

crates/apollo_integration_tests/tests/end_to_end_flow_test.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ mod common;
2525
/// Number of threads is 3 = Num of sequencer + 1 for the test thread.
2626
#[tokio::test(flavor = "multi_thread", worker_threads = 3)]
2727
async fn test_end_to_end_flow() {
28-
end_to_end_flow(EndToEndFlowArgs::new(
29-
TestIdentifier::EndToEndFlowTest,
30-
create_test_scenarios(),
31-
BouncerWeights::default().proving_gas,
32-
))
28+
end_to_end_flow(
29+
EndToEndFlowArgs::new(
30+
TestIdentifier::EndToEndFlowTest,
31+
create_test_scenarios(),
32+
BouncerWeights::default().proving_gas,
33+
)
34+
.proposal_margin_millis(100, 1000),
35+
)
3336
.await
3437
}
3538

0 commit comments

Comments
 (0)