@@ -33,7 +33,7 @@ type Config struct {
33
33
NoBaseFee bool // Forces the EIP-1559 baseFee to 0 (needed for 0 price calls)
34
34
EnablePreimageRecording bool // Enables recording of SHA3/keccak preimages
35
35
36
- JumpTable JumpTable // EVM instruction table, automatically populated if unset
36
+ JumpTable * JumpTable // EVM instruction table, automatically populated if unset
37
37
38
38
ExtraEips []int // Additional EIPS that are to be enabled
39
39
}
@@ -68,39 +68,37 @@ type EVMInterpreter struct {
68
68
69
69
// NewEVMInterpreter returns a new instance of the Interpreter.
70
70
func NewEVMInterpreter (evm * EVM , cfg Config ) * EVMInterpreter {
71
- // We use the STOP instruction whether to see
72
- // the jump table was initialised. If it was not
73
- // we'll set the default jump table.
74
- if cfg .JumpTable [STOP ] == nil {
75
- var jt JumpTable
71
+ // If jump table was not initialised we set the default one.
72
+ if cfg .JumpTable == nil {
76
73
switch {
77
74
case evm .chainRules .IsLondon :
78
- jt = londonInstructionSet
75
+ cfg . JumpTable = & londonInstructionSet
79
76
case evm .chainRules .IsBerlin :
80
- jt = berlinInstructionSet
77
+ cfg . JumpTable = & berlinInstructionSet
81
78
case evm .chainRules .IsIstanbul :
82
- jt = istanbulInstructionSet
79
+ cfg . JumpTable = & istanbulInstructionSet
83
80
case evm .chainRules .IsConstantinople :
84
- jt = constantinopleInstructionSet
81
+ cfg . JumpTable = & constantinopleInstructionSet
85
82
case evm .chainRules .IsByzantium :
86
- jt = byzantiumInstructionSet
83
+ cfg . JumpTable = & byzantiumInstructionSet
87
84
case evm .chainRules .IsEIP158 :
88
- jt = spuriousDragonInstructionSet
85
+ cfg . JumpTable = & spuriousDragonInstructionSet
89
86
case evm .chainRules .IsEIP150 :
90
- jt = tangerineWhistleInstructionSet
87
+ cfg . JumpTable = & tangerineWhistleInstructionSet
91
88
case evm .chainRules .IsHomestead :
92
- jt = homesteadInstructionSet
89
+ cfg . JumpTable = & homesteadInstructionSet
93
90
default :
94
- jt = frontierInstructionSet
91
+ cfg . JumpTable = & frontierInstructionSet
95
92
}
96
93
for i , eip := range cfg .ExtraEips {
97
- if err := EnableEIP (eip , & jt ); err != nil {
94
+ copy := * cfg .JumpTable
95
+ if err := EnableEIP (eip , & copy ); err != nil {
98
96
// Disable it, so caller can check if it's activated or not
99
97
cfg .ExtraEips = append (cfg .ExtraEips [:i ], cfg .ExtraEips [i + 1 :]... )
100
98
log .Error ("EIP activation failed" , "eip" , eip , "error" , err )
101
99
}
100
+ cfg .JumpTable = & copy
102
101
}
103
- cfg .JumpTable = jt
104
102
}
105
103
106
104
return & EVMInterpreter {
0 commit comments