mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
cmd/evm: fix nil pointer dereference in Osaka fork blob gas calculation
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.
This commit is contained in:
parent
2872242045
commit
0b2bf1d026
7 changed files with 63 additions and 0 deletions
|
|
@ -191,6 +191,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
||||||
Time: pre.Env.ParentTimestamp,
|
Time: pre.Env.ParentTimestamp,
|
||||||
ExcessBlobGas: pre.Env.ParentExcessBlobGas,
|
ExcessBlobGas: pre.Env.ParentExcessBlobGas,
|
||||||
BlobGasUsed: pre.Env.ParentBlobGasUsed,
|
BlobGasUsed: pre.Env.ParentBlobGasUsed,
|
||||||
|
BaseFee: pre.Env.ParentBaseFee,
|
||||||
}
|
}
|
||||||
header := &types.Header{
|
header := &types.Header{
|
||||||
Time: pre.Env.Timestamp,
|
Time: pre.Env.Timestamp,
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,14 @@ func TestT8n(t *testing.T) {
|
||||||
output: t8nOutput{alloc: true, result: true},
|
output: t8nOutput{alloc: true, result: true},
|
||||||
expOut: "exp.json",
|
expOut: "exp.json",
|
||||||
},
|
},
|
||||||
|
{ // Osaka test, EIP-7918 blob gas with parent base fee
|
||||||
|
base: "./testdata/34",
|
||||||
|
input: t8nInput{
|
||||||
|
"alloc.json", "txs.json", "env.json", "Osaka", "",
|
||||||
|
},
|
||||||
|
output: t8nOutput{alloc: true, result: true},
|
||||||
|
expOut: "exp.json",
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
args := []string{"t8n"}
|
args := []string{"t8n"}
|
||||||
args = append(args, tc.output.get()...)
|
args = append(args, tc.output.get()...)
|
||||||
|
|
|
||||||
6
cmd/evm/testdata/34/README.md
vendored
Normal file
6
cmd/evm/testdata/34/README.md
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
This test verifies that Osaka fork blob gas calculation works correctly when
|
||||||
|
parentBaseFee is provided. It tests the EIP-7918 reserve price calculation
|
||||||
|
which requires parent.BaseFee to be properly set.
|
||||||
|
|
||||||
|
Regression test for: nil pointer dereference when parent.BaseFee was not
|
||||||
|
included in the parent header during Osaka fork blob gas calculations.
|
||||||
6
cmd/evm/testdata/34/alloc.json
vendored
Normal file
6
cmd/evm/testdata/34/alloc.json
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
|
||||||
|
"balance": "0x1000000000000000000",
|
||||||
|
"nonce": "0x0"
|
||||||
|
}
|
||||||
|
}
|
||||||
18
cmd/evm/testdata/34/env.json
vendored
Normal file
18
cmd/evm/testdata/34/env.json
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"currentCoinbase": "0x0000000000000000000000000000000000000000",
|
||||||
|
"currentDifficulty": "0x0",
|
||||||
|
"currentRandom": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"currentGasLimit": "0x5f5e100",
|
||||||
|
"currentNumber": "0x1",
|
||||||
|
"currentTimestamp": "0x1000",
|
||||||
|
"parentTimestamp": "0x0",
|
||||||
|
"currentBaseFee": "0x10",
|
||||||
|
"parentBaseFee": "0x0a",
|
||||||
|
"parentGasUsed": "0x0",
|
||||||
|
"parentGasLimit": "0x5f5e100",
|
||||||
|
"currentExcessBlobGas": "0x0",
|
||||||
|
"parentExcessBlobGas": "0x0",
|
||||||
|
"parentBlobGasUsed": "0x20000",
|
||||||
|
"parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"withdrawals": []
|
||||||
|
}
|
||||||
23
cmd/evm/testdata/34/exp.json
vendored
Normal file
23
cmd/evm/testdata/34/exp.json
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"alloc": {
|
||||||
|
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
|
||||||
|
"balance": "0x1000000000000000000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"stateRoot": "0x01c28492482a1a1f66224726ef1059a7036fce69d1d2c991b65cd013725d5742",
|
||||||
|
"txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||||
|
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||||
|
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
||||||
|
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"currentDifficulty": null,
|
||||||
|
"receipts": [],
|
||||||
|
"gasUsed": "0x0",
|
||||||
|
"currentBaseFee": "0x10",
|
||||||
|
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||||
|
"currentExcessBlobGas": "0x0",
|
||||||
|
"blobGasUsed": "0x0",
|
||||||
|
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||||
|
"requests": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
cmd/evm/testdata/34/txs.json
vendored
Normal file
1
cmd/evm/testdata/34/txs.json
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
Loading…
Reference in a new issue