Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth/tracers: add optional includePrecompiles flag to callTracer - default true is preserved (#10986) #11022

Merged
Merged
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
51 changes: 24 additions & 27 deletions eth/tracers/internal/tracetest/calltrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/ledgerwatch/erigon-lib/common/dir"
"github.com/ledgerwatch/erigon-lib/common/hexutil"
"github.com/ledgerwatch/erigon-lib/common/hexutility"

"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/common/math"
"github.com/ledgerwatch/erigon/consensus"
Expand Down Expand Up @@ -137,41 +136,37 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) {
t.Fatalf("failed to parse testcase input: %v", err)
}
// Configure a blockchain with the given prestate
var (
signer = types.MakeSigner(test.Genesis.Config, uint64(test.Context.Number), uint64(test.Context.Time))
origin, _ = signer.Sender(tx)
txContext = evmtypes.TxContext{
Origin: origin,
GasPrice: tx.GetPrice(),
}
context = evmtypes.BlockContext{
CanTransfer: core.CanTransfer,
Transfer: consensus.Transfer,
Coinbase: test.Context.Miner,
BlockNumber: uint64(test.Context.Number),
Time: uint64(test.Context.Time),
Difficulty: (*big.Int)(test.Context.Difficulty),
GasLimit: uint64(test.Context.GasLimit),
}
rules = test.Genesis.Config.Rules(context.BlockNumber, context.Time)
)
signer := types.MakeSigner(test.Genesis.Config, uint64(test.Context.Number), uint64(test.Context.Time))
context := evmtypes.BlockContext{
CanTransfer: core.CanTransfer,
Transfer: consensus.Transfer,
Coinbase: test.Context.Miner,
BlockNumber: uint64(test.Context.Number),
Time: uint64(test.Context.Time),
Difficulty: (*big.Int)(test.Context.Difficulty),
GasLimit: uint64(test.Context.GasLimit),
}
if test.Context.BaseFee != nil {
context.BaseFee, _ = uint256.FromBig((*big.Int)(test.Context.BaseFee))
}
rules := test.Genesis.Config.Rules(context.BlockNumber, context.Time)

m := mock.Mock(t)
dbTx, err := m.DB.BeginRw(m.Ctx)
require.NoError(t, err)
defer dbTx.Rollback()
statedb, _ := tests.MakePreState(rules, dbTx, test.Genesis.Alloc, uint64(test.Context.Number), m.HistoryV3)
if test.Genesis.BaseFee != nil {
context.BaseFee, _ = uint256.FromBig(test.Genesis.BaseFee)
}
statedb, err := tests.MakePreState(rules, dbTx, test.Genesis.Alloc, uint64(test.Context.Number), m.HistoryV3)
require.NoError(t, err)
tracer, err := tracers.New(tracerName, new(tracers.Context), test.TracerConfig)
if err != nil {
t.Fatalf("failed to create call tracer: %v", err)
}
evm := vm.NewEVM(context, txContext, statedb, test.Genesis.Config, vm.Config{Debug: true, Tracer: tracer})
msg, err := tx.AsMessage(*signer, test.Genesis.BaseFee, rules)
msg, err := tx.AsMessage(*signer, (*big.Int)(test.Context.BaseFee), rules)
if err != nil {
t.Fatalf("failed to prepare transaction for tracing: %v", err)
}
txContext := core.NewEVMTxContext(msg)
evm := vm.NewEVM(context, txContext, statedb, test.Genesis.Config, vm.Config{Debug: true, Tracer: tracer})
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddBlobGas(tx.GetBlobGas()), true /* refunds */, false /* gasBailout */)
if err != nil {
t.Fatalf("failed to execute transaction: %v", err)
Expand All @@ -187,8 +182,10 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) {
// This is a tweak to make it deterministic. Can be removed when
// we remove the legacy tracer.
var x callTrace
json.Unmarshal(res, &x)
res, _ = json.Marshal(x)
err = json.Unmarshal(res, &x)
require.NoError(t, err)
res, err = json.Marshal(x)
require.NoError(t, err)
}
want, err := json.Marshal(test.Result)
if err != nil {
Expand Down
Loading
Loading