-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
core/vm: add switches to select evm+ewasm interpreters #17687
Conversation
Is there a way to run tests with an external EVMC VM? E.g. |
EVMC supports also custom options. Can will add additional flag, e.g. |
cmd/utils/flags.go
Outdated
EWASMFlag = cli.BoolFlag{ | ||
Name: "ewasm", | ||
Usage: "Enable eWASM capabilities on this chain", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be defined by a hard fork rule, not a CLI flag.
cmd/utils/flags.go
Outdated
EVMInterpreterFlag = cli.StringFlag{ | ||
Name: "evm.interpreter", | ||
Usage: "Path to the evm interpreter", | ||
Value: "geth", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please name these --vm.evm
and --vm.ewasm
. The defaults should be empty, which geth can interpret by running the built in VMs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add (default = built in implementation)
core/vm/interpreter.go
Outdated
@@ -39,6 +39,13 @@ type Config struct { | |||
// may be left uninitialised and will be set to the default | |||
// table. | |||
JumpTable [256]operation | |||
|
|||
// Enable support for EWASM contracts | |||
EWASMEnabled bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether ewasm is enabled or not is not a configuration value, it's a chain fork rule.
core/vm/interpreter.go
Outdated
EWASMEnabled bool | ||
// Type of the EWASM interpreter ("wagon" or "evmc") | ||
EWASMInterpreter string | ||
// Type of the EVM interpreter ("geth" or "evmc") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please get rid of geth
and wagon
. Empty means built in, non empty means use something else.
params/config.go
Outdated
@@ -84,16 +84,16 @@ var ( | |||
// | |||
// This configuration is intentionally not using keyed fields to force anyone | |||
// adding flags to the config to also have to set these fields. | |||
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil} | |||
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, big.NewInt(0)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use nil
. big.NewInt(0)
enables EWASM at block 0.
params/config.go
Outdated
|
||
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced | ||
// and accepted by the Ethereum core developers into the Clique consensus. | ||
// | ||
// This configuration is intentionally not using keyed fields to force anyone | ||
// adding flags to the config to also have to set these fields. | ||
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}} | ||
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, big.NewInt(0)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use nil
. big.NewInt(0)
enables EWASM at block 0.
params/config.go
Outdated
|
||
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil} | ||
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, big.NewInt(0)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use nil
. big.NewInt(0)
enables EWASM at block 0.
params/config.go
Outdated
@@ -123,6 +123,9 @@ type ChainConfig struct { | |||
// Various consensus engines | |||
Ethash *EthashConfig `json:"ethash,omitempty"` | |||
Clique *CliqueConfig `json:"clique,omitempty"` | |||
|
|||
// EWASM-related switches | |||
EWASMBlock *big.Int `json:"ewasmBlock,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this up after the rest of the fork definitions.
params/config.go
Outdated
@@ -269,6 +277,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi | |||
if isForkIncompatible(c.ConstantinopleBlock, newcfg.ConstantinopleBlock, head) { | |||
return newCompatError("Constantinople fork block", c.ConstantinopleBlock, newcfg.ConstantinopleBlock) | |||
} | |||
if isForkIncompatible(c.EWASMBlock, newcfg.EWASMBlock, head) { | |||
return newCompatError("Constantinople fork block", c.EWASMBlock, newcfg.EWASMBlock) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Constantinople" -> "EWASM"
you can write those tests
I would say that's part of the EVMC pr: if you have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't wait to implement eWASM on mainnet 😂
core/vm/interpreter.go
Outdated
|
||
// Type of the EWASM interpreter ("wagon" or "evmc") | ||
EWASMInterpreter string | ||
// Type of the EVM interpreter ("geth" or "evmc") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove "wagon" and "geth"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping
params/config.go
Outdated
@@ -119,6 +119,7 @@ type ChainConfig struct { | |||
|
|||
ByzantiumBlock *big.Int `json:"byzantiumBlock,omitempty"` // Byzantium switch block (nil = no fork, 0 = already on byzantium) | |||
ConstantinopleBlock *big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated) | |||
EWASMBlock *big.Int `json:"ewasmBlock,omitempty"` // EWASM-related switches |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets keep the comment consistent with the other ones.
// EWASM switch block (nil = no fork, 0 = already activated)
cmd/utils/flags.go
Outdated
|
||
EWASMInterpreterFlag = cli.StringFlag{ | ||
Name: "vm.ewasm", | ||
Usage: "Path to the ewasm interpreter", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
External EWASM configuration (default = built in interpreter)
cmd/utils/flags.go
Outdated
} | ||
EVMInterpreterFlag = cli.StringFlag{ | ||
Name: "vm.evm", | ||
Usage: "Path to the evm interpreter", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
External EVM configuration (default = built in interpreter)
eth/config.go
Outdated
@@ -121,6 +121,11 @@ type Config struct { | |||
|
|||
// Miscellaneous options | |||
DocRoot string `toml:"-"` | |||
|
|||
// Type of the EWASM interpreter ("" for detault, or e.g. "evmc:path:option1:...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this needs to be colon separated or can anything be passed after evmc:path:....
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anything can be passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the same comments as for the flag.
External eWASM configuration
and External EVM configuration
I wouldn't mention the config string here yet, since it's not even implemented, so we don't know what it will be. We do know it won't be the one you listed though (no evmc
).
params/config.go
Outdated
@@ -269,6 +275,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi | |||
if isForkIncompatible(c.ConstantinopleBlock, newcfg.ConstantinopleBlock, head) { | |||
return newCompatError("Constantinople fork block", c.ConstantinopleBlock, newcfg.ConstantinopleBlock) | |||
} | |||
if isForkIncompatible(c.EWASMBlock, newcfg.EWASMBlock, head) { | |||
return newCompatError("eWASM fork block", c.EWASMBlock, newcfg.EWASMBlock) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use ewasm
instead of eWASM
as that is the current naming style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@axic is this the current or the definitive naming style? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current, could change.
But there is agreement eWASM
is not the way to go :)
Interpreter initialization is left to the PRs implementing them. Options for external interpreters are passed after a colon in the `--vm.ewasm` and `--vm.evm` switches.
4e4c89b
to
0c84df5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Interpreter initialization is left to the PRs implementing them. Options for external interpreters are passed after a colon in the `--vm.ewasm` and `--vm.evm` switches.
@@ -149,7 +149,11 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { | |||
rawdb.WriteDatabaseVersion(chainDb, core.BlockChainVersion) | |||
} | |||
var ( | |||
vmConfig = vm.Config{EnablePreimageRecording: config.EnablePreimageRecording} | |||
vmConfig = vm.Config{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but you missed 64 other places where vm.Config{}
is created. I'm not even sure if the new incoming transactions are going to be executed with the selected VM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chfast those other location correspond to tests and simulations and we want to use the native interpreter in them. Incoming transactions will be executed by the VM, if you don't believe us check it for yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you. I just remember I had to change this in two places. Maybe it was about tests.
Interpreter initialization is left to the PRs implementing them.
There is a commented-out part that needs to be uncommented in order to initialize the proper interpreter when need be; for instance, in the case of ewasm and assuming that
--ewasm.interpreter
isevmc:path
then the code should be something like:and the
panic
should be removed.