Skip to content

Commit e0346a1

Browse files
committed
Revert "fix: initialize dummy state with correct nonce"
This reverts commit 0083d6f.
1 parent cc37783 commit e0346a1

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

crates/batcher/src/lib.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -852,26 +852,9 @@ impl Batcher {
852852
let is_user_in_state = self.user_states.read().await.contains_key(&addr);
853853

854854
if !is_user_in_state {
855-
// If the user state was not present,
856-
// we need to get the nonce from the Ethereum contract
857-
let ethereum_user_nonce = match self.get_user_nonce_from_ethereum(addr).await {
858-
Ok(ethereum_user_nonce) => ethereum_user_nonce,
859-
Err(e) => {
860-
error!(
861-
"Failed to get user nonce from Ethereum for address {addr:?}. Error: {e:?}"
862-
);
863-
send_message(
864-
ws_conn_sink.clone(),
865-
SubmitProofResponseMessage::EthRpcError,
866-
)
867-
.await;
868-
self.metrics.user_error(&["eth_rpc_error", ""]);
869-
return Ok(());
870-
}
871-
};
872855
debug!("User state for address {addr:?} not found, creating a new one");
873856
// We add a dummy user state to grab a lock on the user state
874-
let dummy_user_state = UserState::new(ethereum_user_nonce);
857+
let dummy_user_state = UserState::new(U256::zero());
875858
self.user_states
876859
.write()
877860
.await
@@ -899,6 +882,27 @@ impl Batcher {
899882
return Ok(());
900883
};
901884

885+
// If the user state was not present, we need to get the nonce from the Ethereum contract and update the dummy user state
886+
if !is_user_in_state {
887+
let ethereum_user_nonce = match self.get_user_nonce_from_ethereum(addr).await {
888+
Ok(ethereum_user_nonce) => ethereum_user_nonce,
889+
Err(e) => {
890+
error!(
891+
"Failed to get user nonce from Ethereum for address {addr:?}. Error: {e:?}"
892+
);
893+
send_message(
894+
ws_conn_sink.clone(),
895+
SubmitProofResponseMessage::EthRpcError,
896+
)
897+
.await;
898+
self.metrics.user_error(&["eth_rpc_error", ""]);
899+
return Ok(());
900+
}
901+
};
902+
// Update the dummy user state with the correct nonce
903+
user_state_guard.nonce = ethereum_user_nonce;
904+
}
905+
902906
// * ---------------------------------------------------*
903907
// * Perform validations over user state *
904908
// * ---------------------------------------------------*
@@ -992,10 +996,6 @@ impl Batcher {
992996
.try_batch_lock_with_timeout(self.batch_state.lock())
993997
.await
994998
else {
995-
if !is_user_in_state {
996-
// If the user state was not present before, we remove it since we couldn't process the message
997-
self.user_states.write().await.remove(&addr);
998-
}
999999
send_message(ws_conn_sink.clone(), SubmitProofResponseMessage::ServerBusy).await;
10001000
return Ok(());
10011001
};

0 commit comments

Comments
 (0)