|
@@ -47,13 +47,36 @@ type operation struct {
|
|
|
// jumps indicates whether operation made a jump. This prevents the program
|
|
// jumps indicates whether operation made a jump. This prevents the program
|
|
|
// counter from further incrementing.
|
|
// counter from further incrementing.
|
|
|
jumps bool
|
|
jumps bool
|
|
|
|
|
+ // writes determines whether this a state modifying operation
|
|
|
|
|
+ writes bool
|
|
|
// valid is used to check whether the retrieved operation is valid and known
|
|
// valid is used to check whether the retrieved operation is valid and known
|
|
|
valid bool
|
|
valid bool
|
|
|
|
|
+ // reverts determined whether the operation reverts state
|
|
|
|
|
+ reverts bool
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-var defaultJumpTable = NewJumpTable()
|
|
|
|
|
|
|
+var (
|
|
|
|
|
+ frontierInstructionSet = NewFrontierInstructionSet()
|
|
|
|
|
+ homesteadInstructionSet = NewHomesteadInstructionSet()
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+// NewHomesteadInstructionSet returns the frontier and homestead
|
|
|
|
|
+// instructions that can be executed during the homestead phase.
|
|
|
|
|
+func NewHomesteadInstructionSet() [256]operation {
|
|
|
|
|
+ instructionSet := NewFrontierInstructionSet()
|
|
|
|
|
+ instructionSet[DELEGATECALL] = operation{
|
|
|
|
|
+ execute: opDelegateCall,
|
|
|
|
|
+ gasCost: gasDelegateCall,
|
|
|
|
|
+ validateStack: makeStackFunc(6, 1),
|
|
|
|
|
+ memorySize: memoryDelegateCall,
|
|
|
|
|
+ valid: true,
|
|
|
|
|
+ }
|
|
|
|
|
+ return instructionSet
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
-func NewJumpTable() [256]operation {
|
|
|
|
|
|
|
+// NewFrontierInstructionSet returns the frontier instructions
|
|
|
|
|
+// that can be executed during the frontier phase.
|
|
|
|
|
+func NewFrontierInstructionSet() [256]operation {
|
|
|
return [256]operation{
|
|
return [256]operation{
|
|
|
STOP: {
|
|
STOP: {
|
|
|
execute: opStop,
|
|
execute: opStop,
|
|
@@ -357,6 +380,7 @@ func NewJumpTable() [256]operation {
|
|
|
gasCost: gasSStore,
|
|
gasCost: gasSStore,
|
|
|
validateStack: makeStackFunc(2, 0),
|
|
validateStack: makeStackFunc(2, 0),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
|
|
+ writes: true,
|
|
|
},
|
|
},
|
|
|
JUMP: {
|
|
JUMP: {
|
|
|
execute: opJump,
|
|
execute: opJump,
|
|
@@ -397,193 +421,193 @@ func NewJumpTable() [256]operation {
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH1: {
|
|
PUSH1: {
|
|
|
- execute: makePush(1, big.NewInt(1)),
|
|
|
|
|
|
|
+ execute: makePush(1, 1),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH2: {
|
|
PUSH2: {
|
|
|
- execute: makePush(2, big.NewInt(2)),
|
|
|
|
|
|
|
+ execute: makePush(2, 2),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH3: {
|
|
PUSH3: {
|
|
|
- execute: makePush(3, big.NewInt(3)),
|
|
|
|
|
|
|
+ execute: makePush(3, 3),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH4: {
|
|
PUSH4: {
|
|
|
- execute: makePush(4, big.NewInt(4)),
|
|
|
|
|
|
|
+ execute: makePush(4, 4),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH5: {
|
|
PUSH5: {
|
|
|
- execute: makePush(5, big.NewInt(5)),
|
|
|
|
|
|
|
+ execute: makePush(5, 5),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH6: {
|
|
PUSH6: {
|
|
|
- execute: makePush(6, big.NewInt(6)),
|
|
|
|
|
|
|
+ execute: makePush(6, 6),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH7: {
|
|
PUSH7: {
|
|
|
- execute: makePush(7, big.NewInt(7)),
|
|
|
|
|
|
|
+ execute: makePush(7, 7),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH8: {
|
|
PUSH8: {
|
|
|
- execute: makePush(8, big.NewInt(8)),
|
|
|
|
|
|
|
+ execute: makePush(8, 8),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH9: {
|
|
PUSH9: {
|
|
|
- execute: makePush(9, big.NewInt(9)),
|
|
|
|
|
|
|
+ execute: makePush(9, 9),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH10: {
|
|
PUSH10: {
|
|
|
- execute: makePush(10, big.NewInt(10)),
|
|
|
|
|
|
|
+ execute: makePush(10, 10),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH11: {
|
|
PUSH11: {
|
|
|
- execute: makePush(11, big.NewInt(11)),
|
|
|
|
|
|
|
+ execute: makePush(11, 11),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH12: {
|
|
PUSH12: {
|
|
|
- execute: makePush(12, big.NewInt(12)),
|
|
|
|
|
|
|
+ execute: makePush(12, 12),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH13: {
|
|
PUSH13: {
|
|
|
- execute: makePush(13, big.NewInt(13)),
|
|
|
|
|
|
|
+ execute: makePush(13, 13),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH14: {
|
|
PUSH14: {
|
|
|
- execute: makePush(14, big.NewInt(14)),
|
|
|
|
|
|
|
+ execute: makePush(14, 14),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH15: {
|
|
PUSH15: {
|
|
|
- execute: makePush(15, big.NewInt(15)),
|
|
|
|
|
|
|
+ execute: makePush(15, 15),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH16: {
|
|
PUSH16: {
|
|
|
- execute: makePush(16, big.NewInt(16)),
|
|
|
|
|
|
|
+ execute: makePush(16, 16),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH17: {
|
|
PUSH17: {
|
|
|
- execute: makePush(17, big.NewInt(17)),
|
|
|
|
|
|
|
+ execute: makePush(17, 17),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH18: {
|
|
PUSH18: {
|
|
|
- execute: makePush(18, big.NewInt(18)),
|
|
|
|
|
|
|
+ execute: makePush(18, 18),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH19: {
|
|
PUSH19: {
|
|
|
- execute: makePush(19, big.NewInt(19)),
|
|
|
|
|
|
|
+ execute: makePush(19, 19),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH20: {
|
|
PUSH20: {
|
|
|
- execute: makePush(20, big.NewInt(20)),
|
|
|
|
|
|
|
+ execute: makePush(20, 20),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH21: {
|
|
PUSH21: {
|
|
|
- execute: makePush(21, big.NewInt(21)),
|
|
|
|
|
|
|
+ execute: makePush(21, 21),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH22: {
|
|
PUSH22: {
|
|
|
- execute: makePush(22, big.NewInt(22)),
|
|
|
|
|
|
|
+ execute: makePush(22, 22),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH23: {
|
|
PUSH23: {
|
|
|
- execute: makePush(23, big.NewInt(23)),
|
|
|
|
|
|
|
+ execute: makePush(23, 23),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH24: {
|
|
PUSH24: {
|
|
|
- execute: makePush(24, big.NewInt(24)),
|
|
|
|
|
|
|
+ execute: makePush(24, 24),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH25: {
|
|
PUSH25: {
|
|
|
- execute: makePush(25, big.NewInt(25)),
|
|
|
|
|
|
|
+ execute: makePush(25, 25),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH26: {
|
|
PUSH26: {
|
|
|
- execute: makePush(26, big.NewInt(26)),
|
|
|
|
|
|
|
+ execute: makePush(26, 26),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH27: {
|
|
PUSH27: {
|
|
|
- execute: makePush(27, big.NewInt(27)),
|
|
|
|
|
|
|
+ execute: makePush(27, 27),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH28: {
|
|
PUSH28: {
|
|
|
- execute: makePush(28, big.NewInt(28)),
|
|
|
|
|
|
|
+ execute: makePush(28, 28),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH29: {
|
|
PUSH29: {
|
|
|
- execute: makePush(29, big.NewInt(29)),
|
|
|
|
|
|
|
+ execute: makePush(29, 29),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH30: {
|
|
PUSH30: {
|
|
|
- execute: makePush(30, big.NewInt(30)),
|
|
|
|
|
|
|
+ execute: makePush(30, 30),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH31: {
|
|
PUSH31: {
|
|
|
- execute: makePush(31, big.NewInt(31)),
|
|
|
|
|
|
|
+ execute: makePush(31, 31),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
PUSH32: {
|
|
PUSH32: {
|
|
|
- execute: makePush(32, big.NewInt(32)),
|
|
|
|
|
|
|
+ execute: makePush(32, 32),
|
|
|
gasCost: gasPush,
|
|
gasCost: gasPush,
|
|
|
validateStack: makeStackFunc(0, 1),
|
|
validateStack: makeStackFunc(0, 1),
|
|
|
valid: true,
|
|
valid: true,
|
|
@@ -821,6 +845,7 @@ func NewJumpTable() [256]operation {
|
|
|
validateStack: makeStackFunc(3, 1),
|
|
validateStack: makeStackFunc(3, 1),
|
|
|
memorySize: memoryCreate,
|
|
memorySize: memoryCreate,
|
|
|
valid: true,
|
|
valid: true,
|
|
|
|
|
+ writes: true,
|
|
|
},
|
|
},
|
|
|
CALL: {
|
|
CALL: {
|
|
|
execute: opCall,
|
|
execute: opCall,
|
|
@@ -844,19 +869,13 @@ func NewJumpTable() [256]operation {
|
|
|
halts: true,
|
|
halts: true,
|
|
|
valid: true,
|
|
valid: true,
|
|
|
},
|
|
},
|
|
|
- DELEGATECALL: {
|
|
|
|
|
- execute: opDelegateCall,
|
|
|
|
|
- gasCost: gasDelegateCall,
|
|
|
|
|
- validateStack: makeStackFunc(6, 1),
|
|
|
|
|
- memorySize: memoryDelegateCall,
|
|
|
|
|
- valid: true,
|
|
|
|
|
- },
|
|
|
|
|
SELFDESTRUCT: {
|
|
SELFDESTRUCT: {
|
|
|
execute: opSuicide,
|
|
execute: opSuicide,
|
|
|
gasCost: gasSuicide,
|
|
gasCost: gasSuicide,
|
|
|
validateStack: makeStackFunc(1, 0),
|
|
validateStack: makeStackFunc(1, 0),
|
|
|
halts: true,
|
|
halts: true,
|
|
|
valid: true,
|
|
valid: true,
|
|
|
|
|
+ writes: true,
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|