Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(eth/tracers): fix crash in TraceCall with BlockOverrides
  • Loading branch information
dmkulazhenko committed Dec 4, 2025
commit e9cd4bf0b635e806df8747e546d853f7fe0390d0
2 changes: 1 addition & 1 deletion graft/coreth/eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc

// Apply the customization rules if required.
if config != nil {
if config.BlockOverrides != nil && config.BlockOverrides.Number.ToInt().Uint64() == h.Number.Uint64()+1 {
if config.BlockOverrides != nil && config.BlockOverrides.Number != nil && config.BlockOverrides.Number.ToInt().Uint64() == h.Number.Uint64()+1 {
// Overriding the block number to n+1 is a common way for wallets to
// simulate transactions, however without the following fix, a contract
// can assert it is being simulated by checking if blockhash(n) == 0x0 and
Expand Down
14 changes: 14 additions & 0 deletions graft/coreth/eth/tracers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,20 @@ func testTraceCall(t *testing.T, scheme string) {
{"pc":0,"op":"NUMBER","gas":24946982,"gasCost":2,"depth":1,"stack":[]},
{"pc":1,"op":"STOP","gas":24946980,"gasCost":0,"depth":1,"stack":["0x1337"]}]}`,
},
// Regression test of bug: accessing nil block number override panics
{
blockNumber: rpc.BlockNumber(0),
call: ethapi.TransactionArgs{
From: &accounts[0].addr,
To: &accounts[1].addr,
Value: (*hexutil.Big)(big.NewInt(1000)),
},
config: &TraceCallConfig{
BlockOverrides: &ethapi.BlockOverrides{},
},
expectErr: nil,
expect: `{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}`,
},
}
for i, testspec := range testSuite {
result, err := api.TraceCall(context.Background(), testspec.call, rpc.BlockNumberOrHash{BlockNumber: &testspec.blockNumber}, testspec.config)
Expand Down
Loading