implement PUSH0 (#273)

Co-authored-by: Péter Garamvölgyi <th307q@gmail.com>
This commit is contained in:
Nazarii Denha 2023-04-20 11:39:19 +02:00 committed by GitHub
parent 11ff7a0648
commit 09c69b6076
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -26,6 +26,7 @@ import (
)
var activators = map[int]func(*JumpTable){
3855: enable3855,
3529: enable3529,
3198: enable3198,
2929: enable2929,
@ -176,3 +177,20 @@ func opBaseFee(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]
scope.Stack.push(baseFee)
return nil, nil
}
// enable3855 applies EIP-3855 (PUSH0 opcode)
func enable3855(jt *JumpTable) {
// New opcode
jt[PUSH0] = &operation{
execute: opPush0,
constantGas: GasQuickStep,
minStack: minStack(0, 1),
maxStack: maxStack(0, 1),
}
}
// opPush0 implements the PUSH0 opcode
func opPush0(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
scope.Stack.push(new(uint256.Int))
return nil, nil
}

View file

@ -120,6 +120,7 @@ const (
MSIZE OpCode = 0x59
GAS OpCode = 0x5a
JUMPDEST OpCode = 0x5b
PUSH0 OpCode = 0x5f
)
// 0x60 range - pushes.
@ -308,6 +309,7 @@ var opCodeToString = map[OpCode]string{
MSIZE: "MSIZE",
GAS: "GAS",
JUMPDEST: "JUMPDEST",
PUSH0: "PUSH0",
// 0x60 range - push.
PUSH1: "PUSH1",
@ -475,6 +477,7 @@ var stringToOp = map[string]OpCode{
"MSIZE": MSIZE,
"GAS": GAS,
"JUMPDEST": JUMPDEST,
"PUSH0": PUSH0,
"PUSH1": PUSH1,
"PUSH2": PUSH2,
"PUSH3": PUSH3,