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

Targeting specific EVM instruction sets #2

Open
fjl opened this issue Sep 13, 2023 · 0 comments
Open

Targeting specific EVM instruction sets #2

fjl opened this issue Sep 13, 2023 · 0 comments

Comments

@fjl
Copy link
Owner

fjl commented Sep 13, 2023

Would be nice if there was a way of setting the target instruction set (Ethereum fork version). It could look like this in the code:

#pragma target "cancun"

The pragma needs to apply to the whole program, so it should be an error if multiple targets are declared in a single program.

To implement this, opcode metadata in package internal/evm needs to be extended to track named instruction sets. I anticipate there will be a couple of these, and there could be support for more EVM versions than the Ethereum mainnet forks. So the best way of tracking these is probably as a tree, i.e.

type InstructionSet struct{
    Name string
    Parent string
    NewOpcodes []string
    RemovedOpcodes []string
}

var allInstructionSets map[string]*InstructionSet

When the user requests a named instruction set, the set of valid opcodes can be created by following the Parent references until the base Frontier instruction set is reached.

@fjl fjl changed the title Targeting instruction sets Targeting specific EVM instruction sets Sep 13, 2023
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

No branches or pull requests

1 participant