Skip to content

Commit

Permalink
ensure the furture ready transactions cannot be included in the bundl…
Browse files Browse the repository at this point in the history
…e within same consensus block
  • Loading branch information
vedhavyas committed Apr 30, 2024
1 parent e814569 commit 1bad28c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
9 changes: 2 additions & 7 deletions domains/runtime/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,16 +883,11 @@ fn pre_dispatch_evm_transaction(

let transaction_data: TransactionData = (&transaction).into();
let transaction_nonce = transaction_data.nonce;
// If this the first transaction from this sender for this bundle,
// then use the transaction nonce as first nonce.
// We do this to ensure all the ordered transactions coming from
// tx_pool is included in all the successive bundles within the same consensus block.
// Once the Domain block is imported, the nonce will be updated and as a result,
// if the current account nonce is greater than the tracked nonce, then
// If the current account nonce is greater than the tracked nonce, then
// pick the highest nonce
let account_nonce = {
let tracked_nonce =
EVMNoncetracker::account_nonce(account_id).unwrap_or(transaction_nonce);
EVMNoncetracker::account_nonce(account_id).unwrap_or(U256::zero());
let account_nonce = EVM::account_basic(&account_id).0.nonce;
max(tracked_nonce, account_nonce)
};
Expand Down
4 changes: 1 addition & 3 deletions domains/test/runtime/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,13 +851,11 @@ fn pre_dispatch_evm_transaction(

let transaction_data: TransactionData = (&transaction).into();
let transaction_nonce = transaction_data.nonce;
// if this the first transaction from this sender, then use the
// transaction nonce as first nonce.
// if the current account nonce is more the tracked nonce, then
// pick the highest nonce
let account_nonce = {
let tracked_nonce =
EVMNoncetracker::account_nonce(account_id).unwrap_or(transaction_nonce);
EVMNoncetracker::account_nonce(account_id).unwrap_or(U256::zero());
let account_nonce = EVM::account_basic(&account_id).0.nonce;
max(tracked_nonce, account_nonce)
};
Expand Down

0 comments on commit 1bad28c

Please sign in to comment.