Skip to content

Commit 202dcec

Browse files
committed
[WIP]Implement simple subroutine opcodes
1 parent 0b2d2e3 commit 202dcec

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

eth/vm/forks/berlin/opcodes.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,42 @@
1616
copy.deepcopy(MUIR_GLACIER_OPCODES),
1717
UPDATED_OPCODES,
1818
)
19+
||||||| parent of eb1aad086... [WIP]Implement simple subroutine opcodes
20+
=======
21+
import copy
22+
23+
from eth_utils.toolz import merge
24+
25+
from eth import constants
26+
from eth.vm import (
27+
mnemonics,
28+
opcode_values,
29+
)
30+
from eth.vm.opcode import as_opcode
31+
from eth.vm.forks.istanbul.opcodes import ISTANBUL_OPCODES
32+
33+
34+
UPDATED_OPCODES = {
35+
opcode_values.BEGINSUB: as_opcode(
36+
logic_fn = ...,
37+
mnemonic = mnemonics.BEGINSUB,
38+
gas_cost = constants.GAS_BASE,
39+
),
40+
opcode_values.JUMPSUB: as_opcode(
41+
logic_fn = ...,
42+
mnemonic = mnemonics.JUMPSUB,
43+
gas_cost = constants.GAS_MID,
44+
),
45+
opcode_values.ENDSUB: as_opcode(
46+
logic_fn = ...,
47+
mnemonic = mnemonics.ENDSUB,
48+
gas_cost = constants.GAS_VERYLOW,
49+
),
50+
}
51+
52+
53+
BERLIN_OPCODES = merge(
54+
copy.deepcopy(ISTANBUL_OPCODES),
55+
UPDATED_OPCODES,
56+
)
57+
>>>>>>> eb1aad086... [WIP]Implement simple subroutine opcodes

eth/vm/mnemonics.py

Lines changed: 6 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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)