aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-08-22 18:41:55 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-08-22 18:41:55 +0800
commit060e33fb4c28a20f3e0ae0e95cd5b27e88c9ec7d (patch)
tree33d1642ca6c5fc05dbe70b86238f2ddaae32b402
parent46ec63b84932705219aad80174f8968357373b69 (diff)
downloadgo-tangerine-060e33fb4c28a20f3e0ae0e95cd5b27e88c9ec7d.tar
go-tangerine-060e33fb4c28a20f3e0ae0e95cd5b27e88c9ec7d.tar.gz
go-tangerine-060e33fb4c28a20f3e0ae0e95cd5b27e88c9ec7d.tar.bz2
go-tangerine-060e33fb4c28a20f3e0ae0e95cd5b27e88c9ec7d.tar.lz
go-tangerine-060e33fb4c28a20f3e0ae0e95cd5b27e88c9ec7d.tar.xz
go-tangerine-060e33fb4c28a20f3e0ae0e95cd5b27e88c9ec7d.tar.zst
go-tangerine-060e33fb4c28a20f3e0ae0e95cd5b27e88c9ec7d.zip
core/vm: enable istanbul EIPs in the jump table
-rw-r--r--core/vm/interpreter.go2
-rw-r--r--core/vm/jump_table.go23
2 files changed, 19 insertions, 6 deletions
diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go
index be6e00a6e..fe06492de 100644
--- a/core/vm/interpreter.go
+++ b/core/vm/interpreter.go
@@ -93,6 +93,8 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter {
if !cfg.JumpTable[STOP].valid {
var jt JumpTable
switch {
+ case evm.chainRules.IsIstanbul:
+ jt = istanbulInstructionSet
case evm.chainRules.IsConstantinople:
jt = constantinopleInstructionSet
case evm.chainRules.IsByzantium:
diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go
index da532541c..b26b55284 100644
--- a/core/vm/jump_table.go
+++ b/core/vm/jump_table.go
@@ -60,15 +60,27 @@ var (
spuriousDragonInstructionSet = newSpuriousDragonInstructionSet()
byzantiumInstructionSet = newByzantiumInstructionSet()
constantinopleInstructionSet = newConstantinopleInstructionSet()
+ istanbulInstructionSet = newIstanbulInstructionSet()
)
// JumpTable contains the EVM opcodes supported at a given fork.
type JumpTable [256]operation
-// NewConstantinopleInstructionSet returns the frontier, homestead
+// newIstanbulInstructionSet returns the frontier, homestead
+// byzantium, contantinople and petersburg instructions.
+func newIstanbulInstructionSet() JumpTable {
+ instructionSet := newConstantinopleInstructionSet()
+
+ enable1344(&instructionSet) // ChainID opcode - https://eips.ethereum.org/EIPS/eip-1344
+ enable1884(&instructionSet) // Reprice reader opcodes - https://eips.ethereum.org/EIPS/eip-1884
+ enable2200(&instructionSet) // Net metered SSTORE - https://eips.ethereum.org/EIPS/eip-2200
+
+ return instructionSet
+}
+
+// newConstantinopleInstructionSet returns the frontier, homestead
// byzantium and contantinople instructions.
func newConstantinopleInstructionSet() JumpTable {
- // instructions that can be executed during the byzantium phase.
instructionSet := newByzantiumInstructionSet()
instructionSet[SHL] = operation{
execute: opSHL,
@@ -112,10 +124,9 @@ func newConstantinopleInstructionSet() JumpTable {
return instructionSet
}
-// NewByzantiumInstructionSet returns the frontier, homestead and
+// newByzantiumInstructionSet returns the frontier, homestead and
// byzantium instructions.
func newByzantiumInstructionSet() JumpTable {
- // instructions that can be executed during the homestead phase.
instructionSet := newSpuriousDragonInstructionSet()
instructionSet[STATICCALL] = operation{
execute: opStaticCall,
@@ -177,7 +188,7 @@ func newTangerineWhistleInstructionSet() JumpTable {
return instructionSet
}
-// NewHomesteadInstructionSet returns the frontier and homestead
+// newHomesteadInstructionSet returns the frontier and homestead
// instructions that can be executed during the homestead phase.
func newHomesteadInstructionSet() JumpTable {
instructionSet := newFrontierInstructionSet()
@@ -194,7 +205,7 @@ func newHomesteadInstructionSet() JumpTable {
return instructionSet
}
-// NewFrontierInstructionSet returns the frontier instructions
+// newFrontierInstructionSet returns the frontier instructions
// that can be executed during the frontier phase.
func newFrontierInstructionSet() JumpTable {
return JumpTable{