Skip to content

Commit

Permalink
feat: include fee vault address in trace api result (ethereum#208)
Browse files Browse the repository at this point in the history
* include fee vault address in trace api result

* use fee vault instead of coinbase if exists

* retrigger checks

* Update api_blocktrace_test.go

---------

Co-authored-by: maskpp <maskpp266@gmail.com>
Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 10, 2023
1 parent 7c3657b commit aae2ea5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
12 changes: 9 additions & 3 deletions eth/tracers/api_blocktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ func (api *API) createTraceEnv(ctx context.Context, config *TraceConfig, block *
}

// get coinbase
coinbase, err := api.backend.Engine().Author(block.Header())
if err != nil {
return nil, err
var coinbase common.Address
if api.backend.ChainConfig().FeeVaultAddress != nil {
coinbase = *api.backend.ChainConfig().FeeVaultAddress
} else {
coinbase, err = api.backend.Engine().Author(block.Header())
if err != nil {
return nil, err
}
}

env := &traceEnv{
Expand Down Expand Up @@ -127,6 +132,7 @@ func (api *API) createTraceEnv(ctx context.Context, config *TraceConfig, block *
}
env.Proofs[key] = wrappedProof
}

return env, nil
}

Expand Down
13 changes: 9 additions & 4 deletions eth/tracers/api_blocktrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,15 @@ func checkStructLogs(t *testing.T, expect []*txTraceResult, actual []*types.Exec
}

func checkCoinbase(t *testing.T, b *testBackend, wrapper *types.AccountWrapper) {
header, err := b.HeaderByNumber(context.Background(), 1)
assert.NoError(t, err)
coinbase, err := b.engine.Author(header)
assert.NoError(t, err)
var coinbase common.Address
if b.chainConfig.FeeVaultAddress != nil {
coinbase = *b.chainConfig.FeeVaultAddress
} else {
header, err := b.HeaderByNumber(context.Background(), 1)
assert.NoError(t, err)
coinbase, err = b.engine.Author(header)
assert.NoError(t, err)
}
assert.Equal(t, true, coinbase.String() == wrapper.Address.String())
}

Expand Down

0 comments on commit aae2ea5

Please sign in to comment.