eth/tracers: use header by reference when overriding

This commit is contained in:
lightclient 2025-07-15 06:41:00 -06:00
parent 829774feda
commit 0553f3ba86
No known key found for this signature in database
GPG key ID: 657913021EF45A6A
2 changed files with 7 additions and 7 deletions

View file

@ -953,13 +953,15 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
}
defer release()
hdr := *block.Header()
// Apply block override to header to ensure GetHashFn works correctly with
// blocks in the future (#32175).
h := block.Header()
if config != nil {
hdr = *config.BlockOverrides.MakeHeader(block.Header())
h = config.BlockOverrides.MakeHeader(h)
}
vmctx := core.NewEVMBlockContext(&hdr, api.chainContext(ctx), nil)
// Apply the customization rules if required.
// Apply block overrides to block context, if applicable.
vmctx := core.NewEVMBlockContext(h, api.chainContext(ctx), nil)
if config != nil {
if overrideErr := config.BlockOverrides.Apply(&vmctx); overrideErr != nil {
return nil, overrideErr

View file

@ -689,8 +689,6 @@ func TestTracingWithOverrides(t *testing.T) {
Failed bool
ReturnValue string
}
parentHashHex := backend.chain.GetHeaderByNumber(uint64(genBlocks - 1)).Hash().Hex()[2:]
return96 := fmt.Sprintf("0x%064s%s%064s", "", parentHashHex, "")
var testSuite = []struct {
blockNumber rpc.BlockNumber
@ -789,7 +787,7 @@ func TestTracingWithOverrides(t *testing.T) {
config: &TraceCallConfig{
BlockOverrides: &override.BlockOverrides{Number: (*hexutil.Big)(big.NewInt(0x1337))},
},
want: fmt.Sprintf(`{"gas":72666,"failed":false,"returnValue":"%s"}`, return96),
want: `{"gas":72666,"failed":false,"returnValue":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}`,
},
/*
pragma solidity =0.8.12;