Skip to content

Commit 79c4de3

Browse files
crypto-facsfedekunze
authored andcommitted
cherry-pick (tharsis#746)
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Federico Kunze Küllmer <federico.kunze94@gmail.com>
1 parent e520c6d commit 79c4de3

8 files changed

Lines changed: 62 additions & 33 deletions

File tree

app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func NewEthermintApp(
341341
app.EvmKeeper = evmkeeper.NewKeeper(
342342
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], app.GetSubspace(evmtypes.ModuleName),
343343
app.AccountKeeper, app.BankKeeper, app.StakingKeeper,
344-
tracer, bApp.Trace(), // debug EVM based on Baseapp options
344+
tracer,
345345
)
346346

347347
app.FeeMarketKeeper = feemarketkeeper.NewKeeper(

init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ if [[ $1 == "pending" ]]; then
8787
fi
8888

8989
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
90-
ethermintd start --pruning=nothing $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner
90+
ethermintd start --pruning=nothing --evm.tracer=json $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner

server/config/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const (
2525
DefaultJSONRPCWsAddress = "0.0.0.0:8546"
2626

2727
// DefaultEVMTracer is the default vm.Tracer type
28-
DefaultEVMTracer = "json"
28+
DefaultEVMTracer = ""
2929

3030
DefaultGasCap uint64 = 25000000
3131

3232
DefaultFilterCap int32 = 200
3333
)
3434

35-
var evmTracers = []string{DefaultEVMTracer, "markdown", "struct", "access_list"}
35+
var evmTracers = []string{"json", "markdown", "struct", "access_list"}
3636

3737
// Config defines the server's top level configuration. It includes the default app config
3838
// from the SDK as well as the EVM configuration to enable the JSON-RPC APIs.
@@ -129,7 +129,7 @@ func DefaultEVMConfig() *EVMConfig {
129129

130130
// Validate returns an error if the tracer type is invalid.
131131
func (c EVMConfig) Validate() error {
132-
if !strings.StringInSlice(c.Tracer, evmTracers) {
132+
if c.Tracer != "" && !strings.StringInSlice(c.Tracer, evmTracers) {
133133
return fmt.Errorf("invalid tracer type %s, available types: %v", c.Tracer, evmTracers)
134134
}
135135

x/evm/keeper/grpc_query.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (*types.Ms
231231
return nil, status.Error(codes.Internal, err.Error())
232232
}
233233

234-
tracer := types.NewTracer(k.tracer, msg, ethCfg, k.Ctx().BlockHeight(), k.debug)
234+
tracer := types.NewTracer(k.tracer, msg, ethCfg, k.Ctx().BlockHeight())
235235
evm := k.NewEVM(msg, ethCfg, params, coinbase, tracer)
236236

237237
// pass true means execute in query mode, which don't do actual gas refund.
@@ -308,7 +308,7 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type
308308

309309
msg := args.ToMessage(req.GasCap)
310310

311-
tracer := types.NewTracer(k.tracer, msg, ethCfg, k.Ctx().BlockHeight(), k.debug)
311+
tracer := types.NewTracer(k.tracer, msg, ethCfg, k.Ctx().BlockHeight())
312312
evm := k.NewEVM(msg, ethCfg, params, coinbase, tracer)
313313
// pass true means execute in query mode, which don't do actual gas refund.
314314
rsp, err := k.ApplyMessage(evm, msg, ethCfg, true)
@@ -519,7 +519,7 @@ func (k *Keeper) traceTx(
519519
}
520520
tracer = vm.NewStructLogger(&logConfig)
521521
default:
522-
tracer = types.NewTracer(types.TracerStruct, msg, ethCfg, ctx.BlockHeight(), true)
522+
tracer = types.NewTracer(types.TracerStruct, msg, ethCfg, ctx.BlockHeight())
523523
}
524524

525525
evm := k.NewEVM(msg, ethCfg, params, coinbase, tracer)

x/evm/keeper/grpc_query_test.go

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,6 @@ func (suite *KeeperTestSuite) TestEstimateGas() {
556556
}
557557

558558
func (suite *KeeperTestSuite) TestTraceTx() {
559-
ctx := sdk.WrapSDKContext(suite.ctx)
560559
// TODO deploy contract that triggers internal transactions
561560
var (
562561
txMsg *types.MsgEthereumTx
@@ -579,7 +578,20 @@ func (suite *KeeperTestSuite) TestTraceTx() {
579578
predecessors = []*types.MsgEthereumTx{}
580579
},
581580
expPass: true,
582-
traceResponse: []byte{0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d},
581+
traceResponse: []byte{0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a, 0x22, 0x50, 0x55, 0x53, 0x48, 0x31, 0x22, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x30, 0x32, 0x39, 0x36, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x43, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x33, 0x2c, 0x22, 0x64, 0x65, 0x70, 0x74, 0x68, 0x22, 0x3a, 0x31, 0x2c, 0x22, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x22, 0x3a, 0x5b, 0x5d, 0x2c, 0x22, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x22, 0x3a, 0x5b, 0x5d, 0x2c, 0x22, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x22, 0x3a, 0x7b, 0x7d, 0x7d},
582+
},
583+
{
584+
msg: "default trace with filtered response",
585+
malleate: func() {
586+
txIndex = 0
587+
traceConfig = &types.TraceConfig{
588+
DisableStack: true,
589+
DisableStorage: true,
590+
}
591+
predecessors = []*types.MsgEthereumTx{}
592+
},
593+
expPass: true,
594+
traceResponse: []byte{0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a, 0x22, 0x50, 0x55, 0x53, 0x48, 0x31, 0x22, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x30, 0x32, 0x39, 0x36, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x43, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x33, 0x2c, 0x22, 0x64, 0x65, 0x70, 0x74, 0x68, 0x22, 0x3a, 0x31, 0x2c, 0x22, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0x2c, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x32, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a, 0x22, 0x50, 0x55, 0x53, 0x48, 0x31, 0x22, 0x2c, 0x22, 0x67},
583595
}, {
584596
msg: "javascript tracer",
585597
malleate: func() {
@@ -596,11 +608,14 @@ func (suite *KeeperTestSuite) TestTraceTx() {
596608
msg: "default trace with dynamicTxFee",
597609
malleate: func() {
598610
txIndex = 0
599-
traceConfig = nil
611+
traceConfig = &types.TraceConfig{
612+
DisableStack: true,
613+
DisableStorage: true,
614+
}
600615
predecessors = []*types.MsgEthereumTx{}
601616
},
602617
expPass: true,
603-
traceResponse: []byte{0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d},
618+
traceResponse: []byte{0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a, 0x22, 0x50, 0x55, 0x53, 0x48, 0x31, 0x22, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x30, 0x32, 0x39, 0x36, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x43, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x33, 0x2c, 0x22, 0x64, 0x65, 0x70, 0x74, 0x68, 0x22, 0x3a, 0x31, 0x2c, 0x22, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0x2c, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x32, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a, 0x22, 0x50, 0x55, 0x53, 0x48, 0x31, 0x22, 0x2c, 0x22, 0x67},
604619
}, {
605620
msg: "javascript tracer with dynamicTxFee",
606621
malleate: func() {
@@ -629,7 +644,7 @@ func (suite *KeeperTestSuite) TestTraceTx() {
629644
predecessors = append(predecessors, firstTx)
630645
},
631646
expPass: true,
632-
traceResponse: []byte{0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x32, 0x35, 0x32, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d},
647+
traceResponse: []byte{0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x32, 0x35, 0x32, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a, 0x22, 0x50, 0x55, 0x53, 0x48, 0x31, 0x22, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x39, 0x31, 0x39, 0x36, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x43, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x33, 0x2c, 0x22, 0x64, 0x65, 0x70, 0x74, 0x68, 0x22, 0x3a, 0x31, 0x2c, 0x22, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x22, 0x3a, 0x5b, 0x5d, 0x2c, 0x22, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x22, 0x3a, 0x5b, 0x5d, 0x2c, 0x22, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x22, 0x3a, 0x7b, 0x7d, 0x7d, 0x2c},
633648
},
634649
}
635650

@@ -650,11 +665,17 @@ func (suite *KeeperTestSuite) TestTraceTx() {
650665
TxIndex: txIndex,
651666
Predecessors: predecessors,
652667
}
653-
res, err := suite.queryClient.TraceTx(ctx, &traceReq)
668+
res, err := suite.queryClient.TraceTx(sdk.WrapSDKContext(suite.ctx), &traceReq)
669+
suite.Require().NoError(err)
654670

655671
if tc.expPass {
656672
suite.Require().NoError(err)
657-
suite.Require().Equal(tc.traceResponse, res.Data)
673+
// if data is to big, slice the result
674+
if len(res.Data) > 150 {
675+
suite.Require().Equal(tc.traceResponse, res.Data[:150])
676+
} else {
677+
suite.Require().Equal(tc.traceResponse, res.Data)
678+
}
658679
} else {
659680
suite.Require().Error(err)
660681
}
@@ -663,7 +684,6 @@ func (suite *KeeperTestSuite) TestTraceTx() {
663684
}
664685

665686
func (suite *KeeperTestSuite) TestTraceBlock() {
666-
ctx := sdk.WrapSDKContext(suite.ctx)
667687
var (
668688
txs []*types.MsgEthereumTx
669689
traceConfig *types.TraceConfig
@@ -681,7 +701,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
681701
traceConfig = nil
682702
},
683703
expPass: true,
684-
traceResponse: []byte{0x5b, 0x7b, 0x22, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0x7d, 0x5d},
704+
traceResponse: []byte{0x5b, 0x7b, 0x22, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a, 0x22, 0x50, 0x55, 0x53, 0x48, 0x31, 0x22, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x30, 0x32, 0x39, 0x36, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x43, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x33, 0x2c, 0x22, 0x64, 0x65, 0x70, 0x74, 0x68, 0x22, 0x3a, 0x31, 0x2c, 0x22, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x22, 0x3a, 0x5b, 0x5d, 0x2c, 0x22, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x22, 0x3a, 0x5b, 0x5d, 0x2c, 0x22, 0x73},
685705
},
686706
{
687707
msg: "filtered trace",
@@ -692,7 +712,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
692712
}
693713
},
694714
expPass: true,
695-
traceResponse: []byte{0x5b, 0x7b, 0x22, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0x7d, 0x5d},
715+
traceResponse: []byte{0x5b, 0x7b, 0x22, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a, 0x22, 0x50, 0x55, 0x53, 0x48, 0x31, 0x22, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x30, 0x32, 0x39, 0x36, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x43, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x33, 0x2c, 0x22, 0x64, 0x65, 0x70, 0x74, 0x68, 0x22, 0x3a, 0x31, 0x2c, 0x22, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0x2c, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x32, 0x2c, 0x22, 0x6f, 0x70, 0x22},
696716
}, {
697717
msg: "javascript tracer",
698718
malleate: func() {
@@ -712,7 +732,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
712732
}
713733
},
714734
expPass: true,
715-
traceResponse: []byte{0x5b, 0x7b, 0x22, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0x7d, 0x5d},
735+
traceResponse: []byte{0x5b, 0x7b, 0x22, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a, 0x22, 0x50, 0x55, 0x53, 0x48, 0x31, 0x22, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x30, 0x32, 0x39, 0x36, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x43, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x33, 0x2c, 0x22, 0x64, 0x65, 0x70, 0x74, 0x68, 0x22, 0x3a, 0x31, 0x2c, 0x22, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0x2c, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x32, 0x2c, 0x22, 0x6f, 0x70, 0x22},
716736
}, {
717737
msg: "javascript tracer with dynamicTxFee",
718738
malleate: func() {
@@ -737,7 +757,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
737757
txs = append([]*types.MsgEthereumTx{}, firstTx, secondTx)
738758
},
739759
expPass: true,
740-
traceResponse: []byte{0x5b, 0x7b, 0x22, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0x7d, 0x2c, 0x7b, 0x22, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x32, 0x35, 0x32, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0x7d, 0x5d},
760+
traceResponse: []byte{0x5b, 0x7b, 0x22, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x34, 0x38, 0x32, 0x38, 0x2c, 0x22, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x3a, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a, 0x22, 0x50, 0x55, 0x53, 0x48, 0x31, 0x22, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x30, 0x32, 0x39, 0x36, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x43, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x33, 0x2c, 0x22, 0x64, 0x65, 0x70, 0x74, 0x68, 0x22, 0x3a, 0x31, 0x2c, 0x22, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x22, 0x3a, 0x5b, 0x5d, 0x2c, 0x22, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x22, 0x3a, 0x5b, 0x5d, 0x2c, 0x22, 0x73},
741761
},
742762
}
743763

@@ -759,11 +779,16 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
759779
Txs: txs,
760780
TraceConfig: traceConfig,
761781
}
762-
res, err := suite.queryClient.TraceBlock(ctx, &traceReq)
782+
res, err := suite.queryClient.TraceBlock(sdk.WrapSDKContext(suite.ctx), &traceReq)
763783

764784
if tc.expPass {
765785
suite.Require().NoError(err)
766-
suite.Require().Equal(tc.traceResponse, res.Data)
786+
// if data is to big, slice the result
787+
if len(res.Data) > 150 {
788+
suite.Require().Equal(tc.traceResponse, res.Data[:150])
789+
} else {
790+
suite.Require().Equal(tc.traceResponse, res.Data)
791+
}
767792
} else {
768793
suite.Require().Error(err)
769794
}

x/evm/keeper/keeper.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ type Keeper struct {
5151

5252
// Tracer used to collect execution traces from the EVM transaction execution
5353
tracer string
54-
// trace EVM state transition execution. This value is obtained from the `--trace` flag.
55-
// For more info check https://geth.ethereum.org/docs/dapp/tracing
56-
debug bool
5754

5855
// EVM Hooks for tx post-processing
5956
hooks types.EvmHooks
@@ -67,7 +64,7 @@ func NewKeeper(
6764
cdc codec.BinaryCodec,
6865
storeKey, transientKey sdk.StoreKey, paramSpace paramtypes.Subspace,
6966
ak types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper,
70-
tracer string, debug bool,
67+
tracer string,
7168
) *Keeper {
7269
// ensure evm module account is set
7370
if addr := ak.GetModuleAddress(types.ModuleName); addr == nil {
@@ -89,7 +86,6 @@ func NewKeeper(
8986
storeKey: storeKey,
9087
transientKey: transientKey,
9188
tracer: tracer,
92-
debug: debug,
9389
stateErr: nil,
9490
}
9591
}

x/evm/keeper/state_transition.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,21 @@ func (k *Keeper) NewEVM(
4444
}
4545

4646
txCtx := core.NewEVMTxContext(msg)
47-
vmConfig := k.VMConfig(msg, params, tracer)
47+
vmConfig := k.VMConfig(params, tracer)
4848

4949
return vm.NewEVM(blockCtx, txCtx, k, config, vmConfig)
5050
}
5151

5252
// VMConfig creates an EVM configuration from the debug setting and the extra EIPs enabled on the
5353
// module parameters. The config generated uses the default JumpTable from the EVM.
54-
func (k Keeper) VMConfig(msg core.Message, params types.Params, tracer vm.Tracer) vm.Config {
54+
func (k Keeper) VMConfig(params types.Params, tracer vm.Tracer) vm.Config {
55+
var debug bool
56+
if _, ok := tracer.(types.NoOpTracer); !ok {
57+
debug = true
58+
}
59+
5560
return vm.Config{
56-
Debug: k.debug,
61+
Debug: debug,
5762
Tracer: tracer,
5863
NoRecursion: false, // TODO: consider disabling recursion though params
5964
ExtraEips: params.EIPs(),
@@ -166,7 +171,7 @@ func (k *Keeper) ApplyTransaction(tx *ethtypes.Transaction) (*types.MsgEthereumT
166171
}
167172

168173
// create an ethereum EVM instance and run the message
169-
tracer := types.NewTracer(k.tracer, msg, ethCfg, ctx.BlockHeight(), k.debug)
174+
tracer := types.NewTracer(k.tracer, msg, ethCfg, ctx.BlockHeight())
170175
evm := k.NewEVM(msg, ethCfg, params, coinbase, tracer)
171176

172177
txHash := tx.Hash()

0 commit comments

Comments
 (0)