Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 12 additions & 1 deletion eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,18 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
}
defer release()

vmctx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
h := *block.Header()
Comment thread
lightclient marked this conversation as resolved.
Outdated

if config != nil && config.BlockOverrides != nil {
h = *config.BlockOverrides.MakeHeader(block.Header())
if h.Number.Uint64() == block.NumberU64()+1 {
h.ParentHash = block.Hash()
} else if h.Number.Uint64() > block.NumberU64()+1 {
h.ParentHash = common.Hash{}
}
Comment thread
lightclient marked this conversation as resolved.
Outdated
}

vmctx := core.NewEVMBlockContext(&h, api.chainContext(ctx), nil)
// Apply the customization rules if required.
if config != nil {
if overrideErr := config.BlockOverrides.Apply(&vmctx); overrideErr != nil {
Expand Down
23 changes: 23 additions & 0 deletions eth/tracers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,10 @@ func TestTracingWithOverrides(t *testing.T) {
Failed bool
ReturnValue string
}
overrideBlockNumber := genBlocks + 1
parentHash := backend.chain.GetHeaderByNumber(uint64(genBlocks)).Hash().Hex()[2:]
expectParent := fmt.Sprintf("0x%064s", parentHash)
Comment thread
lightclient marked this conversation as resolved.
Outdated

var testSuite = []struct {
blockNumber rpc.BlockNumber
call ethapi.TransactionArgs
Expand Down Expand Up @@ -788,6 +792,25 @@ func TestTracingWithOverrides(t *testing.T) {
},
want: `{"gas":72666,"failed":false,"returnValue":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}`,
},
{ // Override blocknumber, and query a blockhash
blockNumber: rpc.LatestBlockNumber,
call: ethapi.TransactionArgs{
From: &accounts[0].addr,
Input: newRPCBytes([]byte{
byte(vm.PUSH1), byte(genBlocks),
byte(vm.BLOCKHASH),
byte(vm.PUSH1), 0x00,
byte(vm.MSTORE),
byte(vm.PUSH1), 0x20,
byte(vm.PUSH1), 0x00,
byte(vm.RETURN),
}), // blocknumber
},
config: &TraceCallConfig{
BlockOverrides: &override.BlockOverrides{Number: (*hexutil.Big)(big.NewInt(int64(overrideBlockNumber)))},
},
want: fmt.Sprintf(`{"gas":59590,"failed":false,"returnValue":"%s"}`, expectParent),
},
/*
pragma solidity =0.8.12;

Expand Down