From db4411c686bc9aeef62c5c8dbf5ab665e0a835fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?pablito=20=E3=83=86?= Date: Thu, 12 Dec 2024 23:15:35 -0300 Subject: [PATCH] Ignore user provided nonce when estimating gas (#1550) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * estimate gas: always ignore user provided nonce * add: test estimateGas ignores nonce --------- Co-authored-by: Éloïs --- client/rpc/src/eth/execute.rs | 17 ++++++++--------- ts-tests/tests/test-gas.ts | 9 +++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/client/rpc/src/eth/execute.rs b/client/rpc/src/eth/execute.rs index 628b7c4cc6..9f673fd7c5 100644 --- a/client/rpc/src/eth/execute.rs +++ b/client/rpc/src/eth/execute.rs @@ -560,7 +560,6 @@ where gas, value, data, - nonce, access_list, .. } = request; @@ -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}")))? @@ -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}")))? @@ -622,7 +621,7 @@ where gas_limit, max_fee_per_gas, max_priority_fee_per_gas, - nonce, + None, estimate_mode, Some( access_list @@ -647,7 +646,7 @@ where gas_limit, max_fee_per_gas, max_priority_fee_per_gas, - nonce, + None, estimate_mode, Some( access_list @@ -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}")))? @@ -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}")))? @@ -710,7 +709,7 @@ where gas_limit, max_fee_per_gas, max_priority_fee_per_gas, - nonce, + None, estimate_mode, Some( access_list @@ -734,7 +733,7 @@ where gas_limit, max_fee_per_gas, max_priority_fee_per_gas, - nonce, + None, estimate_mode, Some( access_list diff --git a/ts-tests/tests/test-gas.ts b/ts-tests/tests/test-gas.ts index ff72ae5d8b..7da474b7da 100644 --- a/ts-tests/tests/test-gas.ts +++ b/ts-tests/tests/test-gas.ts @@ -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( {