core/vm: EIP-2315, JUMPSUB for the EVM (#20619)
* core/vm: implement EIP 2315, subroutines for the EVM * core/vm: eip 2315 - lintfix + check jump dest validity + check ret stack size constraints logger: markdown-friendly traces, validate jumpdest, more testcase, correct opcodes * core/vm: update subroutines acc to eip: disallow walk-into * core/vm/eips: gas cost changes for subroutines * core/vm: update opcodes for EIP-2315 * core/vm: define RETURNSUB as a 'jumping' operation + review concerns Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
@ -33,6 +33,8 @@ func EnableEIP(eipNum int, jt *JumpTable) error {
|
||||
enable1884(jt)
|
||||
case 1344:
|
||||
enable1344(jt)
|
||||
case 2315:
|
||||
enable2315(jt)
|
||||
default:
|
||||
return fmt.Errorf("undefined eip %d", eipNum)
|
||||
}
|
||||
@ -91,3 +93,34 @@ func enable2200(jt *JumpTable) {
|
||||
jt[SLOAD].constantGas = params.SloadGasEIP2200
|
||||
jt[SSTORE].dynamicGas = gasSStoreEIP2200
|
||||
}
|
||||
|
||||
// enable2315 applies EIP-2315 (Simple Subroutines)
|
||||
// - Adds opcodes that jump to and return from subroutines
|
||||
func enable2315(jt *JumpTable) {
|
||||
// New opcode
|
||||
jt[BEGINSUB] = operation{
|
||||
execute: opBeginSub,
|
||||
constantGas: GasQuickStep,
|
||||
minStack: minStack(0, 0),
|
||||
maxStack: maxStack(0, 0),
|
||||
valid: true,
|
||||
}
|
||||
// New opcode
|
||||
jt[JUMPSUB] = operation{
|
||||
execute: opJumpSub,
|
||||
constantGas: GasSlowStep,
|
||||
minStack: minStack(1, 0),
|
||||
maxStack: maxStack(1, 0),
|
||||
jumps: true,
|
||||
valid: true,
|
||||
}
|
||||
// New opcode
|
||||
jt[RETURNSUB] = operation{
|
||||
execute: opReturnSub,
|
||||
constantGas: GasFastStep,
|
||||
minStack: minStack(0, 0),
|
||||
maxStack: maxStack(0, 0),
|
||||
valid: true,
|
||||
jumps: true,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user