Skip to content

Commit 92e94c0

Browse files
committed
[WIP]Implement simple subroutine opcodes
1 parent 5c4db75 commit 92e94c0

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

eth/vm/forks/berlin/opcodes.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import copy
2+
3+
from eth_utils.toolz import merge
4+
5+
from eth import constants
6+
from eth.vm import (
7+
mnemonics,
8+
opcode_values,
9+
)
10+
from eth.vm.opcode import as_opcode
11+
from eth.vm.forks.istanbul.opcodes import ISTANBUL_OPCODES
12+
13+
14+
UPDATED_OPCODES = {
15+
opcode_values.BEGINSUB: as_opcode(
16+
logic_fn = ...,
17+
mnemonic = mnemonics.BEGINSUB,
18+
gas_cost = constants.GAS_BASE,
19+
),
20+
opcode_values.JUMPSUB: as_opcode(
21+
logic_fn = ...,
22+
mnemonic = mnemonics.JUMPSUB,
23+
gas_cost = constants.GAS_MID,
24+
),
25+
opcode_values.ENDSUB: as_opcode(
26+
logic_fn = ...,
27+
mnemonic = mnemonics.ENDSUB,
28+
gas_cost = constants.GAS_VERYLOW,
29+
),
30+
}
31+
32+
33+
BERLIN_OPCODES = merge(
34+
copy.deepcopy(ISTANBUL_OPCODES),
35+
UPDATED_OPCODES,
36+
)

eth/vm/mnemonics.py

+6
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@
162162
LOG3 = 'LOG3'
163163
LOG4 = 'LOG4'
164164
#
165+
# Subroutines
166+
#
167+
BEGINSUB = 'BEGINSUB'
168+
JUMPSUB = 'JUMPSUB'
169+
ENDSUB = 'ENDSUB'
170+
#
165171
# System
166172
#
167173
CREATE = 'CREATE'

eth/vm/opcode_values.py

+8
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@
182182
LOG4 = 0xa4
183183

184184

185+
#
186+
# Subroutines
187+
#
188+
BEGINSUB = 0xb2
189+
JUMPSUB = 0xb3
190+
ENDSUB = 0xb7
191+
192+
185193
#
186194
# System
187195
#

0 commit comments

Comments
 (0)