11use std:: future:: ready;
2- use std:: sync:: Arc ;
2+ use std:: sync:: { Arc , LazyLock } ;
33use std:: time:: Duration ;
44
55use apollo_batcher_types:: batcher_types:: {
@@ -67,6 +67,7 @@ use crate::sequencer_consensus_context::{
6767 SequencerConsensusContext ,
6868 SequencerConsensusContextDeps ,
6969} ;
70+ use crate :: snip35:: proposal_commitment_from;
7071use crate :: test_utils:: {
7172 create_test_and_network_deps,
7273 proposal_init,
@@ -90,7 +91,14 @@ fn expected_l2_gas_info_for_build_proposal_defaults() -> L2GasInfo {
9091}
9192use crate :: utils:: { apply_fee_transformations, make_gas_price_params} ;
9293
93- const TEST_PROPOSAL_COMMITMENT : ProposalCommitment = ProposalCommitment ( PARTIAL_BLOCK_HASH . 0 ) ;
94+ static TEST_PROPOSAL_COMMITMENT : LazyLock < ProposalCommitment > = LazyLock :: new ( || {
95+ // Default test setup: empty fee_proposals_window → `compute_fee_actual` returns `None` →
96+ // `compute_snip35_fee_proposal` falls back to `self.l2_gas_price` (default
97+ // `min_gas_price` = 8 gwei = 8_000_000_000 FRI). The orchestrator chains this value into
98+ // the proposal commitment via `proposal_commitment_from`. The `proposal_init` test helper
99+ // produces an init with `fee_proposal_fri = Some(8 gwei)` to match what the proposer emits.
100+ proposal_commitment_from ( PARTIAL_BLOCK_HASH , Some ( GasPrice ( 8_000_000_000 ) ) )
101+ } ) ;
94102const HEIGHT_0 : BlockNumber = BlockNumber ( 0 ) ;
95103const HEIGHT_1 : BlockNumber = BlockNumber ( 1 ) ;
96104
@@ -130,7 +138,7 @@ async fn validate_proposal_success() {
130138 let fin_receiver = context
131139 . validate_proposal ( proposal_init ( HEIGHT_0 , ROUND_0 ) , TIMEOUT , content_receiver)
132140 . await ;
133- assert_eq ! ( fin_receiver. await . unwrap( ) , TEST_PROPOSAL_COMMITMENT ) ;
141+ assert_eq ! ( fin_receiver. await . unwrap( ) , * TEST_PROPOSAL_COMMITMENT ) ;
134142}
135143
136144#[ rstest]
@@ -176,7 +184,7 @@ async fn validate_then_repropose(#[case] execute_all_txs: bool) {
176184 ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) ;
177185 content_sender. send ( transactions. clone ( ) ) . await . unwrap ( ) ;
178186 let fin = ProposalPart :: Fin ( ProposalFin {
179- proposal_commitment : TEST_PROPOSAL_COMMITMENT ,
187+ proposal_commitment : * TEST_PROPOSAL_COMMITMENT ,
180188 executed_transaction_count : n_executed_txs_count. try_into ( ) . unwrap ( ) ,
181189 fin_payload : Some ( ProposalFinPayload {
182190 commitment_parts : CommitmentParts :: default ( ) ,
@@ -186,11 +194,11 @@ async fn validate_then_repropose(#[case] execute_all_txs: bool) {
186194 content_sender. send ( fin. clone ( ) ) . await . unwrap ( ) ;
187195 let fin_receiver = context. validate_proposal ( init. clone ( ) , TIMEOUT , content_receiver) . await ;
188196 content_sender. close_channel ( ) ;
189- assert_eq ! ( fin_receiver. await . unwrap( ) , TEST_PROPOSAL_COMMITMENT ) ;
197+ assert_eq ! ( fin_receiver. await . unwrap( ) , * TEST_PROPOSAL_COMMITMENT ) ;
190198
191199 let build_param =
192200 BuildParam { round : ROUND_1 , valid_round : Some ( ROUND_0 ) , ..Default :: default ( ) } ;
193- context. repropose ( TEST_PROPOSAL_COMMITMENT , build_param) . await ;
201+ context. repropose ( * TEST_PROPOSAL_COMMITMENT , build_param) . await ;
194202 let ( _, mut receiver) = network. outbound_proposal_receiver . next ( ) . await . unwrap ( ) ;
195203 // Reproposal sends init with updated round, proposer, valid_round.
196204 let mut expected_init = init;
@@ -206,7 +214,7 @@ async fn validate_then_repropose(#[case] execute_all_txs: bool) {
206214 assert ! ( receiver. next( ) . await . is_none( ) ) ;
207215
208216 // Verify decision_reached uses the updated init (from reproposal round) for finalize.
209- context. decision_reached ( HEIGHT_0 , ROUND_1 , TEST_PROPOSAL_COMMITMENT , false ) . await . unwrap ( ) ;
217+ context. decision_reached ( HEIGHT_0 , ROUND_1 , * TEST_PROPOSAL_COMMITMENT , false ) . await . unwrap ( ) ;
210218}
211219
212220#[ tokio:: test]
@@ -254,14 +262,14 @@ async fn validate_then_build_then_decision_reached_round_0_uses_round_0_init() {
254262 ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) ;
255263 content_sender. send ( transactions. clone ( ) ) . await . unwrap ( ) ;
256264 let fin = ProposalPart :: Fin ( ProposalFin {
257- proposal_commitment : TEST_PROPOSAL_COMMITMENT ,
265+ proposal_commitment : * TEST_PROPOSAL_COMMITMENT ,
258266 executed_transaction_count : TX_BATCH . len ( ) . try_into ( ) . unwrap ( ) ,
259267 fin_payload : None ,
260268 } ) ;
261269 content_sender. send ( fin. clone ( ) ) . await . unwrap ( ) ;
262270 let fin_receiver = context. validate_proposal ( init, TIMEOUT , content_receiver) . await ;
263271 content_sender. close_channel ( ) ;
264- assert_eq ! ( fin_receiver. await . unwrap( ) , TEST_PROPOSAL_COMMITMENT ) ;
272+ assert_eq ! ( fin_receiver. await . unwrap( ) , * TEST_PROPOSAL_COMMITMENT ) ;
265273
266274 // Round 1: build - clock returns TIMESTAMP_ROUND_1 (different from TIMESTAMP_ROUND_0)
267275 let build_param = BuildParam { round : ROUND_1 , ..Default :: default ( ) } ;
@@ -276,10 +284,10 @@ async fn validate_then_build_then_decision_reached_round_0_uses_round_0_init() {
276284 assert_eq ! ( build_init. timestamp, TIMESTAMP_ROUND_1 ) ;
277285 let _txs = receiver. next ( ) . await . unwrap ( ) ;
278286 let _fin = receiver. next ( ) . await . unwrap ( ) ;
279- assert_eq ! ( fin_receiver. await . unwrap( ) , TEST_PROPOSAL_COMMITMENT ) ;
287+ assert_eq ! ( fin_receiver. await . unwrap( ) , * TEST_PROPOSAL_COMMITMENT ) ;
280288
281289 // Decision reached for round 0 - state_sync should receive TIMESTAMP_ROUND_0
282- context. decision_reached ( HEIGHT_0 , ROUND_0 , TEST_PROPOSAL_COMMITMENT , false ) . await . unwrap ( ) ;
290+ context. decision_reached ( HEIGHT_0 , ROUND_0 , * TEST_PROPOSAL_COMMITMENT , false ) . await . unwrap ( ) ;
283291}
284292
285293#[ tokio:: test]
@@ -295,7 +303,7 @@ async fn proposals_from_different_rounds() {
295303 let prop_part_txs =
296304 ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) ;
297305 let prop_part_fin = ProposalPart :: Fin ( ProposalFin {
298- proposal_commitment : TEST_PROPOSAL_COMMITMENT ,
306+ proposal_commitment : * TEST_PROPOSAL_COMMITMENT ,
299307 executed_transaction_count : INTERNAL_TX_BATCH . len ( ) . try_into ( ) . unwrap ( ) ,
300308 fin_payload : Some ( ProposalFinPayload :: default ( ) ) ,
301309 } ) ;
@@ -319,7 +327,7 @@ async fn proposals_from_different_rounds() {
319327 let fin_receiver_curr_round = context
320328 . validate_proposal ( proposal_init ( HEIGHT_0 , ROUND_1 ) , TIMEOUT , content_receiver)
321329 . await ;
322- assert_eq ! ( fin_receiver_curr_round. await . unwrap( ) , TEST_PROPOSAL_COMMITMENT ) ;
330+ assert_eq ! ( fin_receiver_curr_round. await . unwrap( ) , * TEST_PROPOSAL_COMMITMENT ) ;
323331
324332 // The proposal from the future round should not be processed.
325333 let ( mut content_sender, content_receiver) =
@@ -388,7 +396,7 @@ async fn interrupt_active_proposal() {
388396
389397 // Interrupt active proposal.
390398 assert ! ( fin_receiver_0. await . is_err( ) ) ;
391- assert_eq ! ( fin_receiver_1. await . unwrap( ) , TEST_PROPOSAL_COMMITMENT ) ;
399+ assert_eq ! ( fin_receiver_1. await . unwrap( ) , * TEST_PROPOSAL_COMMITMENT ) ;
392400}
393401
394402#[ tokio:: test]
@@ -408,14 +416,16 @@ async fn build_proposal() {
408416 panic ! ( "Expected ProposalPart::Init" ) ;
409417 } ;
410418 assert ! ( info. timestamp >= before && info. timestamp <= after) ;
419+ let expected_proposal_commitment =
420+ proposal_commitment_from ( PARTIAL_BLOCK_HASH , info. fee_proposal_fri ) ;
411421 assert_eq ! (
412422 receiver. next( ) . await . unwrap( ) ,
413423 ProposalPart :: Transactions ( TransactionBatch { transactions: TX_BATCH . to_vec( ) } )
414424 ) ;
415425 assert_eq ! (
416426 receiver. next( ) . await . unwrap( ) ,
417427 ProposalPart :: Fin ( ProposalFin {
418- proposal_commitment: TEST_PROPOSAL_COMMITMENT ,
428+ proposal_commitment: expected_proposal_commitment ,
419429 executed_transaction_count: INTERNAL_TX_BATCH . len( ) . try_into( ) . unwrap( ) ,
420430 fin_payload: Some ( ProposalFinPayload {
421431 commitment_parts: CommitmentParts :: default ( ) ,
@@ -424,7 +434,7 @@ async fn build_proposal() {
424434 } )
425435 ) ;
426436 assert ! ( receiver. next( ) . await . is_none( ) ) ;
427- assert_eq ! ( fin_receiver. await . unwrap( ) , TEST_PROPOSAL_COMMITMENT ) ;
437+ assert_eq ! ( fin_receiver. await . unwrap( ) , expected_proposal_commitment ) ;
428438}
429439
430440#[ tokio:: test]
@@ -558,12 +568,12 @@ async fn propose_then_repropose(#[case] execute_all_txs: bool) {
558568 } ;
559569 let _txs = receiver. next ( ) . await . unwrap ( ) ;
560570 let fin = receiver. next ( ) . await . unwrap ( ) ;
561- assert_eq ! ( fin_receiver. await . unwrap( ) , TEST_PROPOSAL_COMMITMENT ) ;
571+ assert_eq ! ( fin_receiver. await . unwrap( ) , * TEST_PROPOSAL_COMMITMENT ) ;
562572
563573 // Re-propose.
564574 let build_param =
565575 BuildParam { round : ROUND_1 , valid_round : Some ( ROUND_0 ) , ..Default :: default ( ) } ;
566- context. repropose ( TEST_PROPOSAL_COMMITMENT , build_param) . await ;
576+ context. repropose ( * TEST_PROPOSAL_COMMITMENT , build_param) . await ;
567577 // Re-propose sends the same proposal content but with updated init (round, proposer,
568578 // valid_round).
569579 let ( _, mut receiver) = network. outbound_proposal_receiver . next ( ) . await . unwrap ( ) ;
@@ -580,7 +590,7 @@ async fn propose_then_repropose(#[case] execute_all_txs: bool) {
580590 assert ! ( receiver. next( ) . await . is_none( ) ) ;
581591
582592 // Verify decision_reached uses the updated init (from reproposal round) for finalize.
583- context. decision_reached ( HEIGHT_0 , ROUND_1 , TEST_PROPOSAL_COMMITMENT , false ) . await . unwrap ( ) ;
593+ context. decision_reached ( HEIGHT_0 , ROUND_1 , * TEST_PROPOSAL_COMMITMENT , false ) . await . unwrap ( ) ;
584594}
585595
586596#[ tokio:: test]
@@ -679,7 +689,7 @@ async fn gas_price_limits(#[case] maximum: bool) {
679689 // Even though we used the minimum/maximum gas price, not the values we gave the provider,
680690 // the proposal should be still be valid due to the clamping of limit prices.
681691 let fin_receiver = context. validate_proposal ( init, TIMEOUT , content_receiver) . await ;
682- assert_eq ! ( fin_receiver. await , Ok ( TEST_PROPOSAL_COMMITMENT ) ) ;
692+ assert_eq ! ( fin_receiver. await , Ok ( * TEST_PROPOSAL_COMMITMENT ) ) ;
683693}
684694
685695#[ tokio:: test]
@@ -725,7 +735,7 @@ async fn decision_reached_sends_correct_values() {
725735 let _fin = context. build_proposal ( BuildParam :: default ( ) , TIMEOUT ) . await . unwrap ( ) . await ;
726736 // At this point we should have a valid proposal in the context which contains the timestamp.
727737
728- context. decision_reached ( HEIGHT_0 , ROUND_0 , TEST_PROPOSAL_COMMITMENT , false ) . await . unwrap ( ) ;
738+ context. decision_reached ( HEIGHT_0 , ROUND_0 , * TEST_PROPOSAL_COMMITMENT , false ) . await . unwrap ( ) ;
729739
730740 let metrics = recorder. handle ( ) . render ( ) ;
731741 CONSENSUS_L2_GAS_PRICE
@@ -885,7 +895,7 @@ async fn oracle_fails_on_startup(#[case] l1_oracle_failure: bool) {
885895 assert_eq ! (
886896 receiver. next( ) . await . unwrap( ) ,
887897 ProposalPart :: Fin ( ProposalFin {
888- proposal_commitment: TEST_PROPOSAL_COMMITMENT ,
898+ proposal_commitment: * TEST_PROPOSAL_COMMITMENT ,
889899 executed_transaction_count: INTERNAL_TX_BATCH . len( ) . try_into( ) . unwrap( ) ,
890900 fin_payload: Some ( ProposalFinPayload {
891901 commitment_parts: CommitmentParts :: default ( ) ,
@@ -894,7 +904,7 @@ async fn oracle_fails_on_startup(#[case] l1_oracle_failure: bool) {
894904 } )
895905 ) ;
896906 assert ! ( receiver. next( ) . await . is_none( ) ) ;
897- assert_eq ! ( fin_receiver. await . unwrap( ) , TEST_PROPOSAL_COMMITMENT ) ;
907+ assert_eq ! ( fin_receiver. await . unwrap( ) , * TEST_PROPOSAL_COMMITMENT ) ;
898908}
899909
900910#[ rstest]
@@ -967,7 +977,7 @@ async fn oracle_fails_on_second_block(#[case] l1_oracle_failure: bool) {
967977 . validate_proposal ( proposal_init ( HEIGHT_0 , ROUND_0 ) , TIMEOUT , content_receiver)
968978 . await ;
969979 let proposal_commitment = fin_receiver. await . unwrap ( ) ;
970- assert_eq ! ( proposal_commitment, TEST_PROPOSAL_COMMITMENT ) ;
980+ assert_eq ! ( proposal_commitment, * TEST_PROPOSAL_COMMITMENT ) ;
971981
972982 // Decision reached
973983
@@ -1000,7 +1010,7 @@ async fn oracle_fails_on_second_block(#[case] l1_oracle_failure: bool) {
10001010 assert_eq ! (
10011011 receiver. next( ) . await . unwrap( ) ,
10021012 ProposalPart :: Fin ( ProposalFin {
1003- proposal_commitment: TEST_PROPOSAL_COMMITMENT ,
1013+ proposal_commitment: * TEST_PROPOSAL_COMMITMENT ,
10041014 executed_transaction_count: INTERNAL_TX_BATCH . len( ) . try_into( ) . unwrap( ) ,
10051015 fin_payload: Some ( ProposalFinPayload {
10061016 commitment_parts: CommitmentParts :: default ( ) ,
@@ -1009,7 +1019,7 @@ async fn oracle_fails_on_second_block(#[case] l1_oracle_failure: bool) {
10091019 } )
10101020 ) ;
10111021 assert ! ( receiver. next( ) . await . is_none( ) ) ;
1012- assert_eq ! ( fin_receiver. await . unwrap( ) , TEST_PROPOSAL_COMMITMENT ) ;
1022+ assert_eq ! ( fin_receiver. await . unwrap( ) , * TEST_PROPOSAL_COMMITMENT ) ;
10131023}
10141024
10151025// L2 gas is a bit above the minimum gas price.
@@ -1136,7 +1146,7 @@ async fn override_prices_behavior(
11361146 return ;
11371147 }
11381148
1139- context. decision_reached ( HEIGHT_0 , ROUND_0 , TEST_PROPOSAL_COMMITMENT , false ) . await . unwrap ( ) ;
1149+ context. decision_reached ( HEIGHT_0 , ROUND_0 , * TEST_PROPOSAL_COMMITMENT , false ) . await . unwrap ( ) ;
11401150
11411151 let actual_l2_gas_price = context. l2_gas_price . 0 ;
11421152
@@ -1262,7 +1272,7 @@ async fn change_gas_price_overrides() {
12621272 . await ;
12631273
12641274 let proposal_commitment = fin_receiver. await . unwrap ( ) ;
1265- assert_eq ! ( proposal_commitment, TEST_PROPOSAL_COMMITMENT ) ;
1275+ assert_eq ! ( proposal_commitment, * TEST_PROPOSAL_COMMITMENT ) ;
12661276
12671277 context. decision_reached ( HEIGHT_0 , ROUND_0 , proposal_commitment, false ) . await . unwrap ( ) ;
12681278
@@ -1291,7 +1301,7 @@ async fn change_gas_price_overrides() {
12911301 let content_receiver = send_proposal_to_validator_context ( & mut context) . await ;
12921302 let fin_receiver = context. validate_proposal ( modified_init, TIMEOUT , content_receiver) . await ;
12931303 let proposal_commitment = fin_receiver. await . unwrap ( ) ;
1294- assert_eq ! ( proposal_commitment, TEST_PROPOSAL_COMMITMENT ) ;
1304+ assert_eq ! ( proposal_commitment, * TEST_PROPOSAL_COMMITMENT ) ;
12951305
12961306 // Validate block number 1, round 1.
12971307 let new_dynamic_config = ContextDynamicConfig {
@@ -1321,7 +1331,7 @@ async fn change_gas_price_overrides() {
13211331 let content_receiver = send_proposal_to_validator_context ( & mut context) . await ;
13221332 let fin_receiver = context. validate_proposal ( modified_init, TIMEOUT , content_receiver) . await ;
13231333 let proposal_commitment = fin_receiver. await . unwrap ( ) ;
1324- assert_eq ! ( proposal_commitment, TEST_PROPOSAL_COMMITMENT ) ;
1334+ assert_eq ! ( proposal_commitment, * TEST_PROPOSAL_COMMITMENT ) ;
13251335
13261336 context. decision_reached ( HEIGHT_1 , ROUND_1 , proposal_commitment, false ) . await . unwrap ( ) ;
13271337
@@ -1340,7 +1350,7 @@ async fn change_gas_price_overrides() {
13401350 . await
13411351 . unwrap ( ) ;
13421352
1343- assert_eq ! ( fin_receiver, TEST_PROPOSAL_COMMITMENT ) ;
1353+ assert_eq ! ( fin_receiver, * TEST_PROPOSAL_COMMITMENT ) ;
13441354 let ( _, mut receiver) = network. outbound_proposal_receiver . next ( ) . await . unwrap ( ) ;
13451355
13461356 let part = receiver. next ( ) . await . unwrap ( ) ;
0 commit comments