Skip to content

Commit 2b5718f

Browse files
authored
cmd/evm/internal/t8ntool: fix nil pointer dereference in Osaka blob gas calculation (ethereum#32714)
The parent header was missing the BaseFee field when calculating the reserve price for EIP-7918 in the Osaka fork, causing a nil pointer dereference. This fix ensures BaseFee is properly set from ParentBaseFee in the environment. Added regression test case 34 to verify Osaka fork blob gas calculation works correctly with parent base fee.
1 parent 2872242 commit 2b5718f

File tree

7 files changed

+63
-0
lines changed

7 files changed

+63
-0
lines changed

cmd/evm/internal/t8ntool/execution.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
191191
Time: pre.Env.ParentTimestamp,
192192
ExcessBlobGas: pre.Env.ParentExcessBlobGas,
193193
BlobGasUsed: pre.Env.ParentBlobGasUsed,
194+
BaseFee: pre.Env.ParentBaseFee,
194195
}
195196
header := &types.Header{
196197
Time: pre.Env.Timestamp,

cmd/evm/t8n_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ func TestT8n(t *testing.T) {
296296
output: t8nOutput{alloc: true, result: true},
297297
expOut: "exp.json",
298298
},
299+
{ // Osaka test, EIP-7918 blob gas with parent base fee
300+
base: "./testdata/34",
301+
input: t8nInput{
302+
"alloc.json", "txs.json", "env.json", "Osaka", "",
303+
},
304+
output: t8nOutput{alloc: true, result: true},
305+
expOut: "exp.json",
306+
},
299307
} {
300308
args := []string{"t8n"}
301309
args = append(args, tc.output.get()...)

cmd/evm/testdata/34/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This test verifies that Osaka fork blob gas calculation works correctly when
2+
parentBaseFee is provided. It tests the EIP-7918 reserve price calculation
3+
which requires parent.BaseFee to be properly set.
4+
5+
Regression test for: nil pointer dereference when parent.BaseFee was not
6+
included in the parent header during Osaka fork blob gas calculations.

cmd/evm/testdata/34/alloc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
3+
"balance": "0x1000000000000000000",
4+
"nonce": "0x0"
5+
}
6+
}

cmd/evm/testdata/34/env.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"currentCoinbase": "0x0000000000000000000000000000000000000000",
3+
"currentDifficulty": "0x0",
4+
"currentRandom": "0x0000000000000000000000000000000000000000000000000000000000000000",
5+
"currentGasLimit": "0x5f5e100",
6+
"currentNumber": "0x1",
7+
"currentTimestamp": "0x1000",
8+
"parentTimestamp": "0x0",
9+
"currentBaseFee": "0x10",
10+
"parentBaseFee": "0x0a",
11+
"parentGasUsed": "0x0",
12+
"parentGasLimit": "0x5f5e100",
13+
"currentExcessBlobGas": "0x0",
14+
"parentExcessBlobGas": "0x0",
15+
"parentBlobGasUsed": "0x20000",
16+
"parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
17+
"withdrawals": []
18+
}

cmd/evm/testdata/34/exp.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"alloc": {
3+
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
4+
"balance": "0x1000000000000000000"
5+
}
6+
},
7+
"result": {
8+
"stateRoot": "0x01c28492482a1a1f66224726ef1059a7036fce69d1d2c991b65cd013725d5742",
9+
"txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
10+
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
11+
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
12+
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
13+
"currentDifficulty": null,
14+
"receipts": [],
15+
"gasUsed": "0x0",
16+
"currentBaseFee": "0x10",
17+
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
18+
"currentExcessBlobGas": "0x0",
19+
"blobGasUsed": "0x0",
20+
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
21+
"requests": []
22+
}
23+
}

cmd/evm/testdata/34/txs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

0 commit comments

Comments
 (0)