Skip to content

Commit 5441a8f

Browse files
authored
all: remove noop vm config flags (ethereum#23111)
* all: rm external interpreter and ewasm config * core/vm: rm Interpreter interface * cmd/geth: deprecate interpreter config fields
1 parent e13d14e commit 5441a8f

File tree

17 files changed

+32
-168
lines changed

17 files changed

+32
-168
lines changed

cmd/evm/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ var (
129129
Name: "noreturndata",
130130
Usage: "disable return data output",
131131
}
132-
EVMInterpreterFlag = cli.StringFlag{
133-
Name: "vm.evm",
134-
Usage: "External EVM configuration (default = built-in interpreter)",
135-
Value: "",
136-
}
137132
)
138133

139134
var stateTransitionCommand = cli.Command{
@@ -185,7 +180,6 @@ func init() {
185180
DisableStackFlag,
186181
DisableStorageFlag,
187182
DisableReturnDataFlag,
188-
EVMInterpreterFlag,
189183
}
190184
app.Commands = []cli.Command{
191185
compileCommand,

cmd/evm/runner.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,8 @@ func runCmd(ctx *cli.Context) error {
211211
Coinbase: genesisConfig.Coinbase,
212212
BlockNumber: new(big.Int).SetUint64(genesisConfig.Number),
213213
EVMConfig: vm.Config{
214-
Tracer: tracer,
215-
Debug: ctx.GlobalBool(DebugFlag.Name) || ctx.GlobalBool(MachineFlag.Name),
216-
EVMInterpreter: ctx.GlobalString(EVMInterpreterFlag.Name),
214+
Tracer: tracer,
215+
Debug: ctx.GlobalBool(DebugFlag.Name) || ctx.GlobalBool(MachineFlag.Name),
217216
},
218217
}
219218

cmd/geth/config.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,5 +236,12 @@ func applyMetricConfig(ctx *cli.Context, cfg *gethConfig) {
236236
}
237237

238238
func deprecated(field string) bool {
239-
return false
239+
switch field {
240+
case "ethconfig.Config.EVMInterpreter":
241+
return true
242+
case "ethconfig.Config.EWASMInterpreter":
243+
return true
244+
default:
245+
return false
246+
}
240247
}

cmd/geth/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ var (
148148
utils.GpoPercentileFlag,
149149
utils.GpoMaxGasPriceFlag,
150150
utils.GpoIgnoreGasPriceFlag,
151-
utils.EWASMInterpreterFlag,
152-
utils.EVMInterpreterFlag,
153151
utils.MinerNotifyFullFlag,
154152
configFileFlag,
155153
utils.CatalystFlag,

cmd/geth/usage.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ var AppHelpFlagGroups = []flags.FlagGroup{
203203
Name: "VIRTUAL MACHINE",
204204
Flags: []cli.Flag{
205205
utils.VMEnableDebugFlag,
206-
utils.EVMInterpreterFlag,
207-
utils.EWASMInterpreterFlag,
208206
},
209207
},
210208
{

cmd/utils/flags.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -760,16 +760,6 @@ var (
760760
Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements",
761761
Value: metrics.DefaultConfig.InfluxDBTags,
762762
}
763-
EWASMInterpreterFlag = cli.StringFlag{
764-
Name: "vm.ewasm",
765-
Usage: "External ewasm configuration (default = built-in interpreter)",
766-
Value: "",
767-
}
768-
EVMInterpreterFlag = cli.StringFlag{
769-
Name: "vm.evm",
770-
Usage: "External EVM configuration (default = built-in interpreter)",
771-
Value: "",
772-
}
773763

774764
CatalystFlag = cli.BoolFlag{
775765
Name: "catalyst",
@@ -1586,13 +1576,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
15861576
cfg.EnablePreimageRecording = ctx.GlobalBool(VMEnableDebugFlag.Name)
15871577
}
15881578

1589-
if ctx.GlobalIsSet(EWASMInterpreterFlag.Name) {
1590-
cfg.EWASMInterpreter = ctx.GlobalString(EWASMInterpreterFlag.Name)
1591-
}
1592-
1593-
if ctx.GlobalIsSet(EVMInterpreterFlag.Name) {
1594-
cfg.EVMInterpreter = ctx.GlobalString(EVMInterpreterFlag.Name)
1595-
}
15961579
if ctx.GlobalIsSet(RPCGlobalGasCapFlag.Name) {
15971580
cfg.RPCGasCap = ctx.GlobalUint64(RPCGlobalGasCapFlag.Name)
15981581
}

consensus/misc/eip1559_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ func copyConfig(original *params.ChainConfig) *params.ChainConfig {
4444
MuirGlacierBlock: original.MuirGlacierBlock,
4545
BerlinBlock: original.BerlinBlock,
4646
LondonBlock: original.LondonBlock,
47-
EWASMBlock: original.EWASMBlock,
4847
CatalystBlock: original.CatalystBlock,
4948
Ethash: original.Ethash,
5049
Clique: original.Clique,

core/vm/evm.go

Lines changed: 15 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package vm
1818

1919
import (
20-
"errors"
2120
"math/big"
2221
"sync/atomic"
2322
"time"
@@ -58,24 +57,6 @@ func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) {
5857
return p, ok
5958
}
6059

61-
// run runs the given contract and takes care of running precompiles with a fallback to the byte code interpreter.
62-
func run(evm *EVM, contract *Contract, input []byte, readOnly bool) ([]byte, error) {
63-
for _, interpreter := range evm.interpreters {
64-
if interpreter.CanRun(contract.Code) {
65-
if evm.interpreter != interpreter {
66-
// Ensure that the interpreter pointer is set back
67-
// to its current value upon return.
68-
defer func(i Interpreter) {
69-
evm.interpreter = i
70-
}(evm.interpreter)
71-
evm.interpreter = interpreter
72-
}
73-
return interpreter.Run(contract, input, readOnly)
74-
}
75-
}
76-
return nil, errors.New("no compatible interpreter")
77-
}
78-
7960
// BlockContext provides the EVM with auxiliary information. Once provided
8061
// it shouldn't be modified.
8162
type BlockContext struct {
@@ -131,8 +112,7 @@ type EVM struct {
131112
Config Config
132113
// global (to this context) ethereum virtual machine
133114
// used throughout the execution of the tx.
134-
interpreters []Interpreter
135-
interpreter Interpreter
115+
interpreter *EVMInterpreter
136116
// abort is used to abort the EVM calling operations
137117
// NOTE: must be set atomically
138118
abort int32
@@ -146,36 +126,14 @@ type EVM struct {
146126
// only ever be used *once*.
147127
func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig *params.ChainConfig, config Config) *EVM {
148128
evm := &EVM{
149-
Context: blockCtx,
150-
TxContext: txCtx,
151-
StateDB: statedb,
152-
Config: config,
153-
chainConfig: chainConfig,
154-
chainRules: chainConfig.Rules(blockCtx.BlockNumber),
155-
interpreters: make([]Interpreter, 0, 1),
156-
}
157-
158-
if chainConfig.IsEWASM(blockCtx.BlockNumber) {
159-
// to be implemented by EVM-C and Wagon PRs.
160-
// if vmConfig.EWASMInterpreter != "" {
161-
// extIntOpts := strings.Split(vmConfig.EWASMInterpreter, ":")
162-
// path := extIntOpts[0]
163-
// options := []string{}
164-
// if len(extIntOpts) > 1 {
165-
// options = extIntOpts[1..]
166-
// }
167-
// evm.interpreters = append(evm.interpreters, NewEVMVCInterpreter(evm, vmConfig, options))
168-
// } else {
169-
// evm.interpreters = append(evm.interpreters, NewEWASMInterpreter(evm, vmConfig))
170-
// }
171-
panic("No supported ewasm interpreter yet.")
172-
}
173-
174-
// vmConfig.EVMInterpreter will be used by EVM-C, it won't be checked here
175-
// as we always want to have the built-in EVM as the failover option.
176-
evm.interpreters = append(evm.interpreters, NewEVMInterpreter(evm, config))
177-
evm.interpreter = evm.interpreters[0]
178-
129+
Context: blockCtx,
130+
TxContext: txCtx,
131+
StateDB: statedb,
132+
Config: config,
133+
chainConfig: chainConfig,
134+
chainRules: chainConfig.Rules(blockCtx.BlockNumber),
135+
}
136+
evm.interpreter = NewEVMInterpreter(evm, config)
179137
return evm
180138
}
181139

@@ -198,7 +156,7 @@ func (evm *EVM) Cancelled() bool {
198156
}
199157

200158
// Interpreter returns the current interpreter
201-
func (evm *EVM) Interpreter() Interpreter {
159+
func (evm *EVM) Interpreter() *EVMInterpreter {
202160
return evm.interpreter
203161
}
204162

@@ -256,7 +214,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
256214
// The depth-check is already done, and precompiles handled above
257215
contract := NewContract(caller, AccountRef(addrCopy), value, gas)
258216
contract.SetCallCode(&addrCopy, evm.StateDB.GetCodeHash(addrCopy), code)
259-
ret, err = run(evm, contract, input, false)
217+
ret, err = evm.interpreter.Run(contract, input, false)
260218
gas = contract.Gas
261219
}
262220
}
@@ -308,7 +266,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
308266
// The contract is a scoped environment for this execution context only.
309267
contract := NewContract(caller, AccountRef(caller.Address()), value, gas)
310268
contract.SetCallCode(&addrCopy, evm.StateDB.GetCodeHash(addrCopy), evm.StateDB.GetCode(addrCopy))
311-
ret, err = run(evm, contract, input, false)
269+
ret, err = evm.interpreter.Run(contract, input, false)
312270
gas = contract.Gas
313271
}
314272
if err != nil {
@@ -343,7 +301,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
343301
// Initialise a new contract and make initialise the delegate values
344302
contract := NewContract(caller, AccountRef(caller.Address()), nil, gas).AsDelegate()
345303
contract.SetCallCode(&addrCopy, evm.StateDB.GetCodeHash(addrCopy), evm.StateDB.GetCode(addrCopy))
346-
ret, err = run(evm, contract, input, false)
304+
ret, err = evm.interpreter.Run(contract, input, false)
347305
gas = contract.Gas
348306
}
349307
if err != nil {
@@ -394,7 +352,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
394352
// When an error was returned by the EVM or when setting the creation code
395353
// above we revert to the snapshot and consume any gas remaining. Additionally
396354
// when we're in Homestead this also counts for code storage gas errors.
397-
ret, err = run(evm, contract, input, true)
355+
ret, err = evm.interpreter.Run(contract, input, true)
398356
gas = contract.Gas
399357
}
400358
if err != nil {
@@ -462,7 +420,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
462420
}
463421
start := time.Now()
464422

465-
ret, err := run(evm, contract, nil, false)
423+
ret, err := evm.interpreter.Run(contract, nil, false)
466424

467425
// Check whether the max code size has been exceeded, assign err if the case.
468426
if err == nil && evm.chainRules.IsEIP158 && len(ret) > params.MaxCodeSize {

core/vm/instructions_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func testTwoOperandOp(t *testing.T, tests []TwoOperandTestcase, opFn executionFu
9696
env = NewEVM(BlockContext{}, TxContext{}, nil, params.TestChainConfig, Config{})
9797
stack = newstack()
9898
pc = uint64(0)
99-
evmInterpreter = env.interpreter.(*EVMInterpreter)
99+
evmInterpreter = env.interpreter
100100
)
101101

102102
for i, test := range tests {
@@ -234,7 +234,7 @@ func getResult(args []*twoOperandParams, opFn executionFunc) []TwoOperandTestcas
234234
env = NewEVM(BlockContext{}, TxContext{}, nil, params.TestChainConfig, Config{})
235235
stack = newstack()
236236
pc = uint64(0)
237-
interpreter = env.interpreter.(*EVMInterpreter)
237+
interpreter = env.interpreter
238238
)
239239
result := make([]TwoOperandTestcase, len(args))
240240
for i, param := range args {

core/vm/interpreter.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,9 @@ type Config struct {
3535

3636
JumpTable [256]*operation // EVM instruction table, automatically populated if unset
3737

38-
EWASMInterpreter string // External EWASM interpreter options
39-
EVMInterpreter string // External EVM interpreter options
40-
4138
ExtraEips []int // Additional EIPS that are to be enabled
4239
}
4340

44-
// Interpreter is used to run Ethereum based contracts and will utilise the
45-
// passed environment to query external sources for state information.
46-
// The Interpreter will run the byte code VM based on the passed
47-
// configuration.
48-
type Interpreter interface {
49-
// Run loops and evaluates the contract's code with the given input data and returns
50-
// the return byte-slice and an error if one occurred.
51-
Run(contract *Contract, input []byte, static bool) ([]byte, error)
52-
// CanRun tells if the contract, passed as an argument, can be
53-
// run by the current interpreter. This is meant so that the
54-
// caller can do something like:
55-
//
56-
// ```golang
57-
// for _, interpreter := range interpreters {
58-
// if interpreter.CanRun(contract.code) {
59-
// interpreter.Run(contract.code, input)
60-
// }
61-
// }
62-
// ```
63-
CanRun([]byte) bool
64-
}
65-
6641
// ScopeContext contains the things that are per-call, such as stack and memory,
6742
// but not transients like pc and gas
6843
type ScopeContext struct {
@@ -303,9 +278,3 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
303278
}
304279
return nil, nil
305280
}
306-
307-
// CanRun tells if the contract, passed as an argument, can be
308-
// run by the current interpreter.
309-
func (in *EVMInterpreter) CanRun(code []byte) bool {
310-
return true
311-
}

0 commit comments

Comments
 (0)