@@ -995,7 +995,7 @@ impl Batcher {
995995 ) {
996996 let replacement_max_fee = nonced_verification_data. max_fee ;
997997 let nonce = nonced_verification_data. nonce ;
998- let Some ( entry ) = batch_state_lock. get_entry ( addr, nonce) else {
998+ let Some ( replacement_entry ) = batch_state_lock. get_entry ( addr, nonce) else {
999999 std:: mem:: drop ( batch_state_lock) ;
10001000 warn ! ( "Invalid nonce for address {addr}. Queue entry with nonce {nonce} not found" ) ;
10011001 send_message (
@@ -1008,13 +1008,13 @@ impl Batcher {
10081008 } ;
10091009
10101010 // Validate that the max fee is at least higher or equal to the original fee + a [`min_bump_percentage`]
1011- let original_max_fee = entry . nonced_verification_data . max_fee ;
1011+ let original_max_fee = replacement_entry . nonced_verification_data . max_fee ;
10121012 let min_bump =
10131013 original_max_fee + ( original_max_fee * self . min_bump_percentage ) / U256 :: from ( 100 ) ;
10141014
10151015 if replacement_max_fee < min_bump {
10161016 std:: mem:: drop ( batch_state_lock) ;
1017- warn ! ( "Invalid replacement message for address {addr}, had max fee: {original_max_fee:?}, received fee: {replacement_max_fee:?}" ) ;
1017+ info ! ( "Invalid replacement message for address {addr}, had max fee: {original_max_fee:?}, received fee: {replacement_max_fee:?}" ) ;
10181018 send_message (
10191019 ws_conn_sink. clone ( ) ,
10201020 SubmitProofResponseMessage :: UnderpricedProof ,
@@ -1028,7 +1028,7 @@ impl Batcher {
10281028 info ! ( "Replacing message for address {addr} with nonce {nonce} and max fee {replacement_max_fee}" ) ;
10291029
10301030 // The replacement entry is built from the old entry and validated for then to be replaced
1031- let mut replacement_entry = entry . clone ( ) ;
1031+ let mut replacement_entry = replacement_entry . clone ( ) ;
10321032 replacement_entry. signature = signature;
10331033 replacement_entry. verification_data_commitment =
10341034 nonced_verification_data. verification_data . clone ( ) . into ( ) ;
@@ -1521,11 +1521,13 @@ impl Batcher {
15211521
15221522 let ( gas_price, disable_verifiers) =
15231523 tokio:: join!( gas_price_future, disabled_verifiers_future) ;
1524+
15241525 let gas_price = gas_price. map_err ( |_| BatcherError :: GasPriceError ) ?;
1526+ // Acquire a write lock to update the latest gas price.
1527+ // The lock is dropped immediately after this assignment completes.
1528+ * self . latest_block_gas_price . write ( ) . await = gas_price;
15251529
15261530 {
1527- * self . latest_block_gas_price . write ( ) . await = gas_price;
1528-
15291531 let new_disable_verifiers = disable_verifiers
15301532 . map_err ( |e| BatcherError :: DisabledVerifiersError ( e. to_string ( ) ) ) ?;
15311533 let mut disabled_verifiers_lock = self . disabled_verifiers . lock ( ) . await ;
0 commit comments