Skip to content

Commit

Permalink
[WIP]Implement simple subroutine opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Peppece committed May 28, 2020
1 parent a876368 commit 8e8703a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
36 changes: 36 additions & 0 deletions eth/vm/forks/berlin/opcodes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import copy

from eth_utils.toolz import merge

from eth import constants
from eth.vm import (
mnemonics,
opcode_values,
)
from eth.vm.opcode import as_opcode
from eth.vm.forks.istanbul.opcodes import ISTANBUL_OPCODES


UPDATED_OPCODES = {
opcode_values.BEGINSUB: as_opcode(
logic_fn = ...,
mnemonic = mnemonics.BEGINSUB,
gas_cost = constants.GAS_BASE,
),
opcode_values.JUMPSUB: as_opcode(
logic_fn = ...,
mnemonic = mnemonics.JUMPSUB,
gas_cost = constants.GAS_MID,
),
opcode_values.ENDSUB: as_opcode(
logic_fn = ...,
mnemonic = mnemonics.ENDSUB,
gas_cost = constants.GAS_VERYLOW,
),
}


BERLIN_OPCODES = merge(
copy.deepcopy(ISTANBUL_OPCODES),
UPDATED_OPCODES,
)
6 changes: 6 additions & 0 deletions eth/vm/mnemonics.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@
LOG3 = 'LOG3'
LOG4 = 'LOG4'
#
# Subroutines
#
BEGINSUB = 'BEGINSUB'
JUMPSUB = 'JUMPSUB'
ENDSUB = 'ENDSUB'
#
# System
#
CREATE = 'CREATE'
Expand Down
8 changes: 8 additions & 0 deletions eth/vm/opcode_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@
LOG4 = 0xa4


#
# Subroutines
#
BEGINSUB = 0xb2
JUMPSUB = 0xb3
ENDSUB = 0xb7


#
# System
#
Expand Down

0 comments on commit 8e8703a

Please sign in to comment.