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

add custom interpreter to t8n evm config #505

Merged
merged 4 commits into from
Jan 23, 2023
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
11 changes: 9 additions & 2 deletions cmd/evm/internal/t8ntool/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"path"
"strings"

"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/state"
Expand Down Expand Up @@ -178,9 +179,15 @@ func Transition(ctx *cli.Context) error {
prestate.Env = *inputData.Env

vmConfig := vm.Config{
Tracer: tracer,
Debug: (tracer != nil),
Tracer: tracer,
Debug: (tracer != nil),
EVMInterpreter: ctx.String(utils.EVMInterpreterFlag.Name),
}

if vmConfig.EVMInterpreter != "" {
vm.InitEVMCEVM(vmConfig.EVMInterpreter)
}

// Construct the chainconfig
var chainConfig ctypes.ChainConfigurator
if cConf, extraEips, err := tests.GetChainConfig(ctx.String(ForknameFlag.Name)); err != nil {
Expand Down
9 changes: 3 additions & 6 deletions cmd/evm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"os"

"github.com/ethereum/go-ethereum/cmd/evm/internal/t8ntool"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -132,11 +133,6 @@ var (
Value: true,
Usage: "enable return data output",
}
EVMInterpreterFlag = &cli.StringFlag{
Name: "vm.evm",
Usage: "External EVM configuration (default = built-in interpreter)",
Value: "",
}
)

var stateTransitionCommand = &cli.Command{
Expand All @@ -162,6 +158,7 @@ var stateTransitionCommand = &cli.Command{
t8ntool.ChainIDFlag,
t8ntool.RewardFlag,
t8ntool.VerbosityFlag,
utils.EVMInterpreterFlag,
},
}

Expand Down Expand Up @@ -222,7 +219,7 @@ func init() {
DisableStackFlag,
DisableStorageFlag,
DisableReturnDataFlag,
EVMInterpreterFlag,
utils.EVMInterpreterFlag,
}
app.Commands = []*cli.Command{
compileCommand,
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func runCmd(ctx *cli.Context) error {
EVMConfig: vm.Config{
Tracer: tracer,
Debug: ctx.Bool(DebugFlag.Name) || ctx.Bool(MachineFlag.Name),
EVMInterpreter: ctx.String(EVMInterpreterFlag.Name),
EVMInterpreter: ctx.String(utils.EVMInterpreterFlag.Name),
},
}

Expand Down
14 changes: 12 additions & 2 deletions cmd/evm/staterunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"os"

"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth/tracers/logger"
Expand All @@ -37,8 +38,11 @@ var stateTestCommand = &cli.Command{
Name: "statetest",
Usage: "executes the given state tests",
ArgsUsage: "<file>",
Flags: []cli.Flag{stateTestEVMCEWASMFlag},
Category: flags.DevCategory,
Flags: []cli.Flag{
stateTestEVMCEWASMFlag,
utils.EVMInterpreterFlag,
},
Category: flags.DevCategory,
}

var stateTestEVMCEWASMFlag = &cli.StringFlag{
Expand Down Expand Up @@ -107,7 +111,13 @@ func stateTestCmd(ctx *cli.Context) error {
Tracer: tracer,
Debug: ctx.Bool(DebugFlag.Name) || ctx.Bool(MachineFlag.Name),
EWASMInterpreter: ctx.String(stateTestEVMCEWASMFlag.Name),
EVMInterpreter: ctx.String(utils.EVMInterpreterFlag.Name),
}

if cfg.EVMInterpreter != "" {
vm.InitEVMCEVM(cfg.EVMInterpreter)
}

results := make([]StatetestResult, 0, len(tests))
for key, test := range tests {
for _, st := range test.Subtests(nil) {
Expand Down
2 changes: 2 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2021,10 +2021,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {

if ctx.IsSet(EWASMInterpreterFlag.Name) {
cfg.EWASMInterpreter = ctx.String(EWASMInterpreterFlag.Name)
vm.InitEVMCEwasm(cfg.EWASMInterpreter)
}

if ctx.IsSet(EVMInterpreterFlag.Name) {
cfg.EVMInterpreter = ctx.String(EVMInterpreterFlag.Name)
vm.InitEVMCEVM(cfg.EVMInterpreter)
}
if ctx.IsSet(RPCGlobalGasCapFlag.Name) {
cfg.RPCGasCap = ctx.Uint64(RPCGlobalGasCapFlag.Name)
Expand Down