Skip to content

Commit eed3b8b

Browse files
committed
[WIP] Implement subroutine opcodes
1 parent c0a13b5 commit eed3b8b

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

eth/vm/forks/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@
2525
from .muir_glacier import ( # noqa: F401
2626
MuirGlacierVM,
2727
)
28+
from .berlin import (
29+
BerlinVM,
30+
)

eth/vm/forks/berlin/opcodes.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
copy.deepcopy(MUIR_GLACIER_OPCODES),
1717
UPDATED_OPCODES,
1818
)
19-
||||||| parent of eb1aad086... [WIP]Implement simple subroutine opcodes
20-
=======
2119
import copy
2220

2321
from eth_utils.toolz import merge
@@ -54,4 +52,3 @@
5452
copy.deepcopy(ISTANBUL_OPCODES),
5553
UPDATED_OPCODES,
5654
)
57-
>>>>>>> eb1aad086... [WIP]Implement simple subroutine opcodes

tests/core/opcodes/test_opcodes.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
)
3838
from eth.vm.chain_context import ChainContext
3939
from eth.vm.forks import (
40+
BerlinVM,
4041
IstanbulVM,
4142
PetersburgVM,
4243
ConstantinopleVM,
@@ -1125,3 +1126,49 @@ def test_blake2b_f_compression(vm_class, input_hex, output_hex, expect_exception
11251126
comp.raise_if_error()
11261127
result = comp.output
11271128
assert result.hex() == output_hex
1129+
1130+
1131+
@pytest.mark.parametrize(
1132+
'vm_class, code, expect_gas_used',
1133+
(
1134+
(
1135+
BerlinVM,
1136+
'0x60045e005c5d',
1137+
18,
1138+
),
1139+
(
1140+
BerlinVM,
1141+
'0x6800000000000000000c5e005c60115e5d5c5d',
1142+
36,
1143+
),
1144+
(
1145+
BerlinVM,
1146+
'0x6801000000000000000c5e005c60115e5d5c5d',
1147+
0,
1148+
),
1149+
(
1150+
BerlinVM,
1151+
'0x5d5858',
1152+
0,
1153+
),
1154+
(
1155+
BerlinVM,
1156+
'0x6005565c5d5b60035e',
1157+
30,
1158+
),
1159+
(
1160+
BerlinVM,
1161+
'0x5c5d00',
1162+
0,
1163+
),
1164+
)
1165+
)
1166+
def test_jumpsub(vm_class, code, expect_gas_used):
1167+
computation = setup_computation(vm_class, CANONICAL_ADDRESS_B, decode_hex(code))
1168+
comp = computation.apply_message(
1169+
computation.state,
1170+
computation.msg,
1171+
computation.transaction_context,
1172+
)
1173+
assert comp.is_success
1174+
assert comp.get_gas_used() == expect_gas_used

0 commit comments

Comments
 (0)