fix: set EVM debug based on tracer config (#746)
* set debug based on tracer * fix tests * set default tracer * remove debug from keeper * remove unnecesary param * remove unnecesary param * Update x/evm/keeper/state_transition.go * changelog Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Federico Kunze Küllmer <federico.kunze94@gmail.com>
This commit is contained in:
parent
f42f339d05
commit
d4621f3e82
@ -56,6 +56,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
* (evm) [tharsis#746](https://github.com/tharsis/ethermint/pull/746) Set EVM debugging based on tracer configuration.
|
||||||
* (app,cli) [tharsis#725](https://github.com/tharsis/ethermint/pull/725) Fix cli-config for `keys` command.
|
* (app,cli) [tharsis#725](https://github.com/tharsis/ethermint/pull/725) Fix cli-config for `keys` command.
|
||||||
* (rpc) [tharsis#727](https://github.com/tharsis/ethermint/pull/727) Decode raw transaction using RLP.
|
* (rpc) [tharsis#727](https://github.com/tharsis/ethermint/pull/727) Decode raw transaction using RLP.
|
||||||
* (rpc) [tharsis#661](https://github.com/tharsis/ethermint/pull/661) Fix OOM bug when creating too many filters using JSON-RPC.
|
* (rpc) [tharsis#661](https://github.com/tharsis/ethermint/pull/661) Fix OOM bug when creating too many filters using JSON-RPC.
|
||||||
|
@ -345,7 +345,7 @@ func NewEthermintApp(
|
|||||||
app.EvmKeeper = evmkeeper.NewKeeper(
|
app.EvmKeeper = evmkeeper.NewKeeper(
|
||||||
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], app.GetSubspace(evmtypes.ModuleName),
|
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], app.GetSubspace(evmtypes.ModuleName),
|
||||||
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
|
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
|
||||||
tracer, bApp.Trace(), // debug EVM based on Baseapp options
|
tracer,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create IBC Keeper
|
// Create IBC Keeper
|
||||||
|
2
init.sh
2
init.sh
@ -87,4 +87,4 @@ if [[ $1 == "pending" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
||||||
ethermintd start --pruning=nothing $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner
|
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
|
||||||
|
@ -26,7 +26,7 @@ const (
|
|||||||
DefaultJSONRPCWsAddress = "0.0.0.0:8546"
|
DefaultJSONRPCWsAddress = "0.0.0.0:8546"
|
||||||
|
|
||||||
// DefaultEVMTracer is the default vm.Tracer type
|
// DefaultEVMTracer is the default vm.Tracer type
|
||||||
DefaultEVMTracer = "json"
|
DefaultEVMTracer = ""
|
||||||
|
|
||||||
DefaultGasCap uint64 = 25000000
|
DefaultGasCap uint64 = 25000000
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ const (
|
|||||||
DefaultTxFeeCap float64 = 1.0
|
DefaultTxFeeCap float64 = 1.0
|
||||||
)
|
)
|
||||||
|
|
||||||
var evmTracers = []string{DefaultEVMTracer, "markdown", "struct", "access_list"}
|
var evmTracers = []string{"json", "markdown", "struct", "access_list"}
|
||||||
|
|
||||||
// Config defines the server's top level configuration. It includes the default app config
|
// Config defines the server's top level configuration. It includes the default app config
|
||||||
// from the SDK as well as the EVM configuration to enable the JSON-RPC APIs.
|
// from the SDK as well as the EVM configuration to enable the JSON-RPC APIs.
|
||||||
@ -138,7 +138,7 @@ func DefaultEVMConfig() *EVMConfig {
|
|||||||
|
|
||||||
// Validate returns an error if the tracer type is invalid.
|
// Validate returns an error if the tracer type is invalid.
|
||||||
func (c EVMConfig) Validate() error {
|
func (c EVMConfig) Validate() error {
|
||||||
if !strings.StringInSlice(c.Tracer, evmTracers) {
|
if c.Tracer != "" && !strings.StringInSlice(c.Tracer, evmTracers) {
|
||||||
return fmt.Errorf("invalid tracer type %s, available types: %v", c.Tracer, evmTracers)
|
return fmt.Errorf("invalid tracer type %s, available types: %v", c.Tracer, evmTracers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,4 +58,4 @@ ethermintd collect-gentxs
|
|||||||
ethermintd validate-genesis
|
ethermintd validate-genesis
|
||||||
|
|
||||||
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
||||||
ethermintd start --pruning=nothing --rpc.unsafe --keyring-backend test --trace --log_level info --json-rpc.api eth,txpool,personal,net,debug,web3
|
ethermintd start --pruning=nothing --rpc.unsafe --keyring-backend test --log_level info --json-rpc.api eth,txpool,personal,net,debug,web3
|
||||||
|
@ -523,7 +523,7 @@ func (k *Keeper) traceTx(
|
|||||||
}
|
}
|
||||||
tracer = vm.NewStructLogger(&logConfig)
|
tracer = vm.NewStructLogger(&logConfig)
|
||||||
default:
|
default:
|
||||||
tracer = types.NewTracer(types.TracerStruct, msg, ethCfg, ctx.BlockHeight(), true)
|
tracer = types.NewTracer(types.TracerStruct, msg, ethCfg, ctx.BlockHeight())
|
||||||
}
|
}
|
||||||
|
|
||||||
k.SetTxHashTransient(txHash)
|
k.SetTxHashTransient(txHash)
|
||||||
|
@ -593,7 +593,6 @@ func (suite *KeeperTestSuite) TestEstimateGas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *KeeperTestSuite) TestTraceTx() {
|
func (suite *KeeperTestSuite) TestTraceTx() {
|
||||||
ctx := sdk.WrapSDKContext(suite.ctx)
|
|
||||||
// TODO deploy contract that triggers internal transactions
|
// TODO deploy contract that triggers internal transactions
|
||||||
var (
|
var (
|
||||||
txMsg *types.MsgEthereumTx
|
txMsg *types.MsgEthereumTx
|
||||||
@ -617,7 +616,22 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
|||||||
predecessors = []*types.MsgEthereumTx{}
|
predecessors = []*types.MsgEthereumTx{}
|
||||||
},
|
},
|
||||||
expPass: true,
|
expPass: true,
|
||||||
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},
|
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, 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, 0x61},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
msg: "default trace with filtered response",
|
||||||
|
malleate: func() {
|
||||||
|
txIndex = 0
|
||||||
|
traceConfig = &types.TraceConfig{
|
||||||
|
DisableStack: true,
|
||||||
|
DisableStorage: true,
|
||||||
|
EnableMemory: false,
|
||||||
|
}
|
||||||
|
predecessors = []*types.MsgEthereumTx{}
|
||||||
|
},
|
||||||
|
expPass: true,
|
||||||
|
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, 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, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x30, 0x32, 0x39, 0x33, 0x2c, 0x22, 0x67},
|
||||||
|
dynamicTxFee: false,
|
||||||
}, {
|
}, {
|
||||||
msg: "javascript tracer",
|
msg: "javascript tracer",
|
||||||
malleate: func() {
|
malleate: func() {
|
||||||
@ -634,11 +648,15 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
|||||||
msg: "default trace with dynamicTxFee",
|
msg: "default trace with dynamicTxFee",
|
||||||
malleate: func() {
|
malleate: func() {
|
||||||
txIndex = 0
|
txIndex = 0
|
||||||
traceConfig = nil
|
traceConfig = &types.TraceConfig{
|
||||||
|
DisableStack: true,
|
||||||
|
DisableStorage: true,
|
||||||
|
EnableMemory: false,
|
||||||
|
}
|
||||||
predecessors = []*types.MsgEthereumTx{}
|
predecessors = []*types.MsgEthereumTx{}
|
||||||
},
|
},
|
||||||
expPass: true,
|
expPass: true,
|
||||||
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},
|
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, 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, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x30, 0x32, 0x39, 0x33, 0x2c, 0x22, 0x67},
|
||||||
dynamicTxFee: true,
|
dynamicTxFee: true,
|
||||||
}, {
|
}, {
|
||||||
msg: "javascript tracer with dynamicTxFee",
|
msg: "javascript tracer with dynamicTxFee",
|
||||||
@ -669,7 +687,7 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
|||||||
predecessors = append(predecessors, firstTx)
|
predecessors = append(predecessors, firstTx)
|
||||||
},
|
},
|
||||||
expPass: true,
|
expPass: true,
|
||||||
traceResponse: []byte{0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x30, 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},
|
traceResponse: []byte{0x7b, 0x22, 0x67, 0x61, 0x73, 0x22, 0x3a, 0x33, 0x30, 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, 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, 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, 0x61, 0x73},
|
||||||
dynamicTxFee: false,
|
dynamicTxFee: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -692,11 +710,17 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
|||||||
TxIndex: txIndex,
|
TxIndex: txIndex,
|
||||||
Predecessors: predecessors,
|
Predecessors: predecessors,
|
||||||
}
|
}
|
||||||
res, err := suite.queryClient.TraceTx(ctx, &traceReq)
|
res, err := suite.queryClient.TraceTx(sdk.WrapSDKContext(suite.ctx), &traceReq)
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
if tc.expPass {
|
if tc.expPass {
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
// if data is to big, slice the result
|
||||||
|
if len(res.Data) > 150 {
|
||||||
|
suite.Require().Equal(tc.traceResponse, res.Data[:150])
|
||||||
|
} else {
|
||||||
suite.Require().Equal(tc.traceResponse, res.Data)
|
suite.Require().Equal(tc.traceResponse, res.Data)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
suite.Require().Error(err)
|
suite.Require().Error(err)
|
||||||
}
|
}
|
||||||
@ -707,7 +731,6 @@ func (suite *KeeperTestSuite) TestTraceTx() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *KeeperTestSuite) TestTraceBlock() {
|
func (suite *KeeperTestSuite) TestTraceBlock() {
|
||||||
ctx := sdk.WrapSDKContext(suite.ctx)
|
|
||||||
var (
|
var (
|
||||||
txs []*types.MsgEthereumTx
|
txs []*types.MsgEthereumTx
|
||||||
traceConfig *types.TraceConfig
|
traceConfig *types.TraceConfig
|
||||||
@ -726,7 +749,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
|
|||||||
traceConfig = nil
|
traceConfig = nil
|
||||||
},
|
},
|
||||||
expPass: true,
|
expPass: true,
|
||||||
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},
|
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, 0x7d, 0x2c, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x32, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
msg: "filtered trace",
|
msg: "filtered trace",
|
||||||
@ -738,7 +761,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
expPass: true,
|
expPass: true,
|
||||||
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},
|
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, 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, 0x61},
|
||||||
}, {
|
}, {
|
||||||
msg: "javascript tracer",
|
msg: "javascript tracer",
|
||||||
malleate: func() {
|
malleate: func() {
|
||||||
@ -759,7 +782,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
expPass: true,
|
expPass: true,
|
||||||
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},
|
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, 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, 0x61},
|
||||||
dynamicTxFee: true,
|
dynamicTxFee: true,
|
||||||
}, {
|
}, {
|
||||||
msg: "javascript tracer with dynamicTxFee",
|
msg: "javascript tracer with dynamicTxFee",
|
||||||
@ -786,7 +809,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
|
|||||||
txs = append([]*types.MsgEthereumTx{}, firstTx, secondTx)
|
txs = append([]*types.MsgEthereumTx{}, firstTx, secondTx)
|
||||||
},
|
},
|
||||||
expPass: true,
|
expPass: true,
|
||||||
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, 0x33, 0x30, 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},
|
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, 0x7d, 0x2c, 0x7b, 0x22, 0x70, 0x63, 0x22, 0x3a, 0x32, 0x2c, 0x22, 0x6f, 0x70, 0x22, 0x3a},
|
||||||
dynamicTxFee: false,
|
dynamicTxFee: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -810,11 +833,16 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
|
|||||||
Txs: txs,
|
Txs: txs,
|
||||||
TraceConfig: traceConfig,
|
TraceConfig: traceConfig,
|
||||||
}
|
}
|
||||||
res, err := suite.queryClient.TraceBlock(ctx, &traceReq)
|
res, err := suite.queryClient.TraceBlock(sdk.WrapSDKContext(suite.ctx), &traceReq)
|
||||||
|
|
||||||
if tc.expPass {
|
if tc.expPass {
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
// if data is to big, slice the result
|
||||||
|
if len(res.Data) > 150 {
|
||||||
|
suite.Require().Equal(tc.traceResponse, res.Data[:150])
|
||||||
|
} else {
|
||||||
suite.Require().Equal(tc.traceResponse, res.Data)
|
suite.Require().Equal(tc.traceResponse, res.Data)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
suite.Require().Error(err)
|
suite.Require().Error(err)
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,6 @@ type Keeper struct {
|
|||||||
|
|
||||||
// Tracer used to collect execution traces from the EVM transaction execution
|
// Tracer used to collect execution traces from the EVM transaction execution
|
||||||
tracer string
|
tracer string
|
||||||
// trace EVM state transition execution. This value is obtained from the `--trace` flag.
|
|
||||||
// For more info check https://geth.ethereum.org/docs/dapp/tracing
|
|
||||||
debug bool
|
|
||||||
|
|
||||||
// EVM Hooks for tx post-processing
|
// EVM Hooks for tx post-processing
|
||||||
hooks types.EvmHooks
|
hooks types.EvmHooks
|
||||||
@ -73,7 +70,7 @@ func NewKeeper(
|
|||||||
storeKey, transientKey sdk.StoreKey, paramSpace paramtypes.Subspace,
|
storeKey, transientKey sdk.StoreKey, paramSpace paramtypes.Subspace,
|
||||||
ak types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper,
|
ak types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper,
|
||||||
fmk types.FeeMarketKeeper,
|
fmk types.FeeMarketKeeper,
|
||||||
tracer string, debug bool,
|
tracer string,
|
||||||
) *Keeper {
|
) *Keeper {
|
||||||
// ensure evm module account is set
|
// ensure evm module account is set
|
||||||
if addr := ak.GetModuleAddress(types.ModuleName); addr == nil {
|
if addr := ak.GetModuleAddress(types.ModuleName); addr == nil {
|
||||||
@ -96,7 +93,6 @@ func NewKeeper(
|
|||||||
storeKey: storeKey,
|
storeKey: storeKey,
|
||||||
transientKey: transientKey,
|
transientKey: transientKey,
|
||||||
tracer: tracer,
|
tracer: tracer,
|
||||||
debug: debug,
|
|
||||||
stateErr: nil,
|
stateErr: nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,5 +379,5 @@ func (k *Keeper) PostTxProcessing(txHash common.Hash, logs []*ethtypes.Log) erro
|
|||||||
|
|
||||||
// Tracer return a default vm.Tracer based on current keeper state
|
// Tracer return a default vm.Tracer based on current keeper state
|
||||||
func (k Keeper) Tracer(msg core.Message, ethCfg *params.ChainConfig) vm.Tracer {
|
func (k Keeper) Tracer(msg core.Message, ethCfg *params.ChainConfig) vm.Tracer {
|
||||||
return types.NewTracer(k.tracer, msg, ethCfg, k.Ctx().BlockHeight(), k.debug)
|
return types.NewTracer(k.tracer, msg, ethCfg, k.Ctx().BlockHeight())
|
||||||
}
|
}
|
||||||
|
@ -70,17 +70,22 @@ func (k *Keeper) NewEVM(
|
|||||||
if tracer == nil {
|
if tracer == nil {
|
||||||
tracer = k.Tracer(msg, cfg.ChainConfig)
|
tracer = k.Tracer(msg, cfg.ChainConfig)
|
||||||
}
|
}
|
||||||
vmConfig := k.VMConfig(msg, cfg.Params, tracer)
|
vmConfig := k.VMConfig(cfg.Params, tracer)
|
||||||
return vm.NewEVM(blockCtx, txCtx, k, cfg.ChainConfig, vmConfig)
|
return vm.NewEVM(blockCtx, txCtx, k, cfg.ChainConfig, vmConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VMConfig creates an EVM configuration from the debug setting and the extra EIPs enabled on the
|
// VMConfig creates an EVM configuration from the debug setting and the extra EIPs enabled on the
|
||||||
// module parameters. The config generated uses the default JumpTable from the EVM.
|
// module parameters. The config generated uses the default JumpTable from the EVM.
|
||||||
func (k Keeper) VMConfig(msg core.Message, params types.Params, tracer vm.Tracer) vm.Config {
|
func (k Keeper) VMConfig(params types.Params, tracer vm.Tracer) vm.Config {
|
||||||
fmParams := k.feeMarketKeeper.GetParams(k.Ctx())
|
fmParams := k.feeMarketKeeper.GetParams(k.Ctx())
|
||||||
|
|
||||||
|
var debug bool
|
||||||
|
if _, ok := tracer.(types.NoOpTracer); !ok {
|
||||||
|
debug = true
|
||||||
|
}
|
||||||
|
|
||||||
return vm.Config{
|
return vm.Config{
|
||||||
Debug: k.debug,
|
Debug: debug,
|
||||||
Tracer: tracer,
|
Tracer: tracer,
|
||||||
NoRecursion: false, // TODO: consider disabling recursion though params
|
NoRecursion: false, // TODO: consider disabling recursion though params
|
||||||
NoBaseFee: fmParams.NoBaseFee,
|
NoBaseFee: fmParams.NoBaseFee,
|
||||||
|
@ -21,10 +21,10 @@ const (
|
|||||||
|
|
||||||
// NewTracer creates a new Logger tracer to collect execution traces from an
|
// NewTracer creates a new Logger tracer to collect execution traces from an
|
||||||
// EVM transaction.
|
// EVM transaction.
|
||||||
func NewTracer(tracer string, msg core.Message, cfg *params.ChainConfig, height int64, debug bool) vm.Tracer {
|
func NewTracer(tracer string, msg core.Message, cfg *params.ChainConfig, height int64) vm.Tracer {
|
||||||
// TODO: enable additional log configuration
|
// TODO: enable additional log configuration
|
||||||
logCfg := &vm.LogConfig{
|
logCfg := &vm.LogConfig{
|
||||||
Debug: debug,
|
Debug: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch tracer {
|
switch tracer {
|
||||||
@ -90,6 +90,7 @@ func FormatLogs(logs []vm.StructLog) []StructLogRes {
|
|||||||
Depth: trace.Depth,
|
Depth: trace.Depth,
|
||||||
Error: trace.ErrorString(),
|
Error: trace.ErrorString(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if trace.Stack != nil {
|
if trace.Stack != nil {
|
||||||
stack := make([]string, len(trace.Stack))
|
stack := make([]string, len(trace.Stack))
|
||||||
for i, stackValue := range trace.Stack {
|
for i, stackValue := range trace.Stack {
|
||||||
@ -97,6 +98,7 @@ func FormatLogs(logs []vm.StructLog) []StructLogRes {
|
|||||||
}
|
}
|
||||||
formatted[index].Stack = &stack
|
formatted[index].Stack = &stack
|
||||||
}
|
}
|
||||||
|
|
||||||
if trace.Memory != nil {
|
if trace.Memory != nil {
|
||||||
memory := make([]string, 0, (len(trace.Memory)+31)/32)
|
memory := make([]string, 0, (len(trace.Memory)+31)/32)
|
||||||
for i := 0; i+32 <= len(trace.Memory); i += 32 {
|
for i := 0; i+32 <= len(trace.Memory); i += 32 {
|
||||||
@ -104,6 +106,7 @@ func FormatLogs(logs []vm.StructLog) []StructLogRes {
|
|||||||
}
|
}
|
||||||
formatted[index].Memory = &memory
|
formatted[index].Memory = &memory
|
||||||
}
|
}
|
||||||
|
|
||||||
if trace.Storage != nil {
|
if trace.Storage != nil {
|
||||||
storage := make(map[string]string)
|
storage := make(map[string]string)
|
||||||
for i, storageValue := range trace.Storage {
|
for i, storageValue := range trace.Storage {
|
||||||
|
Loading…
Reference in New Issue
Block a user