Skip to content

Commit db4411c

Browse files
pLabartalibrelois
andauthored
Ignore user provided nonce when estimating gas (#1550)
* estimate gas: always ignore user provided nonce * add: test estimateGas ignores nonce --------- Co-authored-by: Éloïs <c@elo.tf>
1 parent 470fcad commit db4411c

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

client/rpc/src/eth/execute.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ where
560560
gas,
561561
value,
562562
data,
563-
nonce,
564563
access_list,
565564
..
566565
} = request;
@@ -583,7 +582,7 @@ where
583582
value.unwrap_or_default(),
584583
gas_limit,
585584
gas_price,
586-
nonce,
585+
None,
587586
estimate_mode,
588587
)
589588
.map_err(|err| internal_err(format!("runtime error: {err}")))?
@@ -602,7 +601,7 @@ where
602601
gas_limit,
603602
max_fee_per_gas,
604603
max_priority_fee_per_gas,
605-
nonce,
604+
None,
606605
estimate_mode,
607606
)
608607
.map_err(|err| internal_err(format!("runtime error: {err}")))?
@@ -622,7 +621,7 @@ where
622621
gas_limit,
623622
max_fee_per_gas,
624623
max_priority_fee_per_gas,
625-
nonce,
624+
None,
626625
estimate_mode,
627626
Some(
628627
access_list
@@ -647,7 +646,7 @@ where
647646
gas_limit,
648647
max_fee_per_gas,
649648
max_priority_fee_per_gas,
650-
nonce,
649+
None,
651650
estimate_mode,
652651
Some(
653652
access_list
@@ -673,7 +672,7 @@ where
673672
value.unwrap_or_default(),
674673
gas_limit,
675674
gas_price,
676-
nonce,
675+
None,
677676
estimate_mode,
678677
)
679678
.map_err(|err| internal_err(format!("runtime error: {err}")))?
@@ -691,7 +690,7 @@ where
691690
gas_limit,
692691
max_fee_per_gas,
693692
max_priority_fee_per_gas,
694-
nonce,
693+
None,
695694
estimate_mode,
696695
)
697696
.map_err(|err| internal_err(format!("runtime error: {err}")))?
@@ -710,7 +709,7 @@ where
710709
gas_limit,
711710
max_fee_per_gas,
712711
max_priority_fee_per_gas,
713-
nonce,
712+
None,
714713
estimate_mode,
715714
Some(
716715
access_list
@@ -734,7 +733,7 @@ where
734733
gas_limit,
735734
max_fee_per_gas,
736735
max_priority_fee_per_gas,
737-
nonce,
736+
None,
738737
estimate_mode,
739738
Some(
740739
access_list

ts-tests/tests/test-gas.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => {
132132
expect(result).to.equal(197732);
133133
});
134134

135+
it("eth_estimateGas should ignore nonce", async function () {
136+
let result = await context.web3.eth.estimateGas({
137+
from: GENESIS_ACCOUNT,
138+
data: Test.bytecode,
139+
nonce: 42, // Arbitrary nonce value
140+
});
141+
expect(result).to.equal(197732);
142+
});
143+
135144
it("tx gas limit below ETH_BLOCK_GAS_LIMIT", async function () {
136145
const tx = await context.web3.eth.accounts.signTransaction(
137146
{

0 commit comments

Comments
 (0)