Skip to content

Commit

Permalink
Ignore user provided nonce when estimating gas (polkadot-evm#1550)
Browse files Browse the repository at this point in the history
* estimate gas: always ignore user provided nonce

* add: test estimateGas ignores nonce

---------

Co-authored-by: Éloïs <[email protected]>
  • Loading branch information
pLabarta and librelois authored Dec 13, 2024
1 parent 470fcad commit db4411c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 8 additions & 9 deletions client/rpc/src/eth/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,6 @@ where
gas,
value,
data,
nonce,
access_list,
..
} = request;
Expand All @@ -583,7 +582,7 @@ where
value.unwrap_or_default(),
gas_limit,
gas_price,
nonce,
None,
estimate_mode,
)
.map_err(|err| internal_err(format!("runtime error: {err}")))?
Expand All @@ -602,7 +601,7 @@ where
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
None,
estimate_mode,
)
.map_err(|err| internal_err(format!("runtime error: {err}")))?
Expand All @@ -622,7 +621,7 @@ where
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
None,
estimate_mode,
Some(
access_list
Expand All @@ -647,7 +646,7 @@ where
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
None,
estimate_mode,
Some(
access_list
Expand All @@ -673,7 +672,7 @@ where
value.unwrap_or_default(),
gas_limit,
gas_price,
nonce,
None,
estimate_mode,
)
.map_err(|err| internal_err(format!("runtime error: {err}")))?
Expand All @@ -691,7 +690,7 @@ where
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
None,
estimate_mode,
)
.map_err(|err| internal_err(format!("runtime error: {err}")))?
Expand All @@ -710,7 +709,7 @@ where
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
None,
estimate_mode,
Some(
access_list
Expand All @@ -734,7 +733,7 @@ where
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
None,
estimate_mode,
Some(
access_list
Expand Down
9 changes: 9 additions & 0 deletions ts-tests/tests/test-gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => {
expect(result).to.equal(197732);
});

it("eth_estimateGas should ignore nonce", async function () {
let result = await context.web3.eth.estimateGas({
from: GENESIS_ACCOUNT,
data: Test.bytecode,
nonce: 42, // Arbitrary nonce value
});
expect(result).to.equal(197732);
});

it("tx gas limit below ETH_BLOCK_GAS_LIMIT", async function () {
const tx = await context.web3.eth.accounts.signTransaction(
{
Expand Down

0 comments on commit db4411c

Please sign in to comment.