Targeting specific EVM instruction sets
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.