File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
crates/anvil/src/eth/backend/mem Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -939,7 +939,6 @@ impl Backend {
939939 env. block . number = env. block . number . saturating_add ( U256 :: from ( 1 ) ) ;
940940 env. block . basefee = U256 :: from ( current_base_fee) ;
941941 env. block . blob_excess_gas_and_price = current_excess_blob_gas_and_price;
942- env. block . timestamp = U256 :: from ( self . time . next_timestamp ( ) ) ;
943942
944943 // pick a random value for prevrandao
945944 env. block . prevrandao = Some ( B256 :: random ( ) ) ;
@@ -954,6 +953,12 @@ impl Backend {
954953
955954 let ( executed_tx, block_hash) = {
956955 let mut db = self . db . write ( ) . await ;
956+
957+ // finally set the next block timestamp, this is done just before execution, because
958+ // there can be concurrent requests that can delay acquiring the db lock and we want
959+ // to ensure the timestamp is as close as possible to the actual execution.
960+ env. block . timestamp = U256 :: from ( self . time . next_timestamp ( ) ) ;
961+
957962 let executor = TransactionExecutor {
958963 db : & mut * db,
959964 validator : self ,
You can’t perform that action at this time.
0 commit comments