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

core/vm: add switches to select evm+ewasm interpreters #17687

Merged
merged 1 commit into from
Sep 20, 2018

Conversation

gballet
Copy link
Member

@gballet gballet commented Sep 17, 2018

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 is evmc:path then the code should be something like:

params := strings.Split(, ":")
switch params[0] {
case "evmc":
  if len(params) != 2 {
  panic("Missing vm path in evmc:path argument to ewasm.interpreter")
  }
  vmPath := params[1]
  evm.interpreters = append(evm.interpreters, NewEVMC(evm, vmPath))
  break;
  ...
}

and the panic should be removed.

@gballet gballet mentioned this pull request Sep 17, 2018
@chfast
Copy link
Member

chfast commented Sep 17, 2018

Is there a way to run tests with an external EVMC VM? E.g. --evm.interpreter evmc:aleth-interpreter.so? Can go test ./tests/... accept custom flags?

@chfast
Copy link
Member

chfast commented Sep 17, 2018

EVMC supports also custom options. Can will add additional flag, e.g. --evmc.options option1=x;option2=y?

EWASMFlag = cli.BoolFlag{
Name: "ewasm",
Usage: "Enable eWASM capabilities on this chain",
}
Copy link
Member

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.

EVMInterpreterFlag = cli.StringFlag{
Name: "evm.interpreter",
Usage: "Path to the evm interpreter",
Value: "geth",
Copy link
Member

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.

Copy link
Member

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)

@@ -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
Copy link
Member

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.

EWASMEnabled bool
// Type of the EWASM interpreter ("wagon" or "evmc")
EWASMInterpreter string
// Type of the EVM interpreter ("geth" or "evmc")
Copy link
Member

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)}
Copy link
Member

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)}
Copy link
Member

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)}
Copy link
Member

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"`
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Constantinople" -> "EWASM"

@gballet
Copy link
Member Author

gballet commented Sep 17, 2018

Is there a way to run tests with an external EVMC VM? E.g. --evm.interpreter evmc:aleth-interpreter.so? Can go test ./tests/... accept custom flags?

you can write those tests

EVMC supports also custom options. Can will add additional flag, e.g. --evmc.options option1=x;option2=y?

I would say that's part of the EVMC pr: if you have --vm.evm=path:option1:option2 that should work .

Copy link

@ghost ghost left a 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 😂


// Type of the EWASM interpreter ("wagon" or "evmc")
EWASMInterpreter string
// Type of the EVM interpreter ("geth" or "evmc")
Copy link
Member

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"

Copy link
Member

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
Copy link
Member

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)


EWASMInterpreterFlag = cli.StringFlag{
Name: "vm.ewasm",
Usage: "Path to the ewasm interpreter",
Copy link
Member

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)

}
EVMInterpreterFlag = cli.StringFlag{
Name: "vm.evm",
Usage: "Path to the evm interpreter",
Copy link
Member

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:...")
Copy link
Member

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:.... ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anything can be passed

Copy link
Member

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).

@karalabe karalabe added this to the 1.8.16 milestone Sep 19, 2018
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)
Copy link
Member

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?

Copy link
Member Author

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? 😄

Copy link
Member

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.
@gballet gballet force-pushed the vm-selector-switches branch from 4e4c89b to 0c84df5 Compare September 19, 2018 13:10
Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@karalabe karalabe merged commit da29332 into ethereum:master Sep 20, 2018
nizsheanez referenced this pull request in nizsheanez/go-ethereum Sep 21, 2018
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{
Copy link
Member

@chfast chfast Sep 21, 2018

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.

Copy link
Member Author

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.

Copy link
Member

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.

@gballet gballet mentioned this pull request Sep 25, 2018
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants