core/vm: implement EIP-3855: PUSH0 instruction (#24039)
* core/vm: Implement PUSH0 * Move PUSH0 to enable3855 * Add method doc
This commit is contained in:
parent
1941c5e6c9
commit
3b967d16ca
|
@ -25,6 +25,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var activators = map[int]func(*JumpTable){
|
var activators = map[int]func(*JumpTable){
|
||||||
|
3855: enable3855,
|
||||||
3529: enable3529,
|
3529: enable3529,
|
||||||
3198: enable3198,
|
3198: enable3198,
|
||||||
2929: enable2929,
|
2929: enable2929,
|
||||||
|
@ -174,3 +175,20 @@ func opBaseFee(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]
|
||||||
scope.Stack.push(baseFee)
|
scope.Stack.push(baseFee)
|
||||||
return nil, nil
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -116,6 +116,7 @@ const (
|
||||||
MSIZE OpCode = 0x59
|
MSIZE OpCode = 0x59
|
||||||
GAS OpCode = 0x5a
|
GAS OpCode = 0x5a
|
||||||
JUMPDEST OpCode = 0x5b
|
JUMPDEST OpCode = 0x5b
|
||||||
|
PUSH0 OpCode = 0x5f
|
||||||
)
|
)
|
||||||
|
|
||||||
// 0x60 range - pushes.
|
// 0x60 range - pushes.
|
||||||
|
@ -297,6 +298,7 @@ var opCodeToString = map[OpCode]string{
|
||||||
MSIZE: "MSIZE",
|
MSIZE: "MSIZE",
|
||||||
GAS: "GAS",
|
GAS: "GAS",
|
||||||
JUMPDEST: "JUMPDEST",
|
JUMPDEST: "JUMPDEST",
|
||||||
|
PUSH0: "PUSH0",
|
||||||
|
|
||||||
// 0x60 range - push.
|
// 0x60 range - push.
|
||||||
PUSH1: "PUSH1",
|
PUSH1: "PUSH1",
|
||||||
|
@ -460,6 +462,7 @@ var stringToOp = map[string]OpCode{
|
||||||
"MSIZE": MSIZE,
|
"MSIZE": MSIZE,
|
||||||
"GAS": GAS,
|
"GAS": GAS,
|
||||||
"JUMPDEST": JUMPDEST,
|
"JUMPDEST": JUMPDEST,
|
||||||
|
"PUSH0": PUSH0,
|
||||||
"PUSH1": PUSH1,
|
"PUSH1": PUSH1,
|
||||||
"PUSH2": PUSH2,
|
"PUSH2": PUSH2,
|
||||||
"PUSH3": PUSH3,
|
"PUSH3": PUSH3,
|
||||||
|
|
Loading…
Reference in New Issue