Skip to content

Commit

Permalink
Merge pull request #60 from georgiypetrov/add-shanghai-support
Browse files Browse the repository at this point in the history
add shanghai support
  • Loading branch information
ESultanik authored Nov 9, 2023
2 parents 0ff2e0f + edde88b commit a6d6d7f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
11 changes: 10 additions & 1 deletion pyevmasm/evmasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from future.builtins import next, bytes # type: ignore
import copy

DEFAULT_FORK = "london"
DEFAULT_FORK = "shanghai"

"""
Example use::
Expand Down Expand Up @@ -1094,6 +1094,12 @@ def __repr__(self):
london_instruction_table, previous_fork=istanbul_instruction_table
)

shanghai_instruction_table = {0x5f: ("PUSH", 0, 0, 1, 2, "Place 0 constant byte item on stack.")}

shanghai_instruction_table = InstructionTable( # type: ignore
shanghai_instruction_table, previous_fork=london_instruction_table
)

accepted_forks = (
"frontier",
"homestead",
Expand All @@ -1105,6 +1111,7 @@ def __repr__(self):
"serenity",
"istanbul",
"london",
"shanghai"
)


Expand All @@ -1119,6 +1126,7 @@ def __repr__(self):
"serenity": serenity_instruction_table,
"istanbul": istanbul_instruction_table,
"london": london_instruction_table,
"shanghai": shanghai_instruction_table,
}


Expand Down Expand Up @@ -1153,6 +1161,7 @@ def block_to_fork(block_number):
7280000: "petersburg",
9069000: "istanbul",
12965000: "london",
17034870: "shanghai",
99999999: "serenity", # to be replaced after Serenity launch
}
fork_names = list(forks_by_block.values())
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='pyevmasm',
version='0.2.3',
version='0.2.4',
description='Ethereum Virtual Machine (EVM) assembler and disassembler',
author='Trail of Bits',
author_email='[email protected]',
Expand Down
8 changes: 8 additions & 0 deletions tests/test_EVMAssembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ def test_london_fork(self):
self.assertTrue(insn.pops == 0)
self.assertTrue(insn.pushes == 1)

def test_shanghai_fork(self):
insn = EVMAsm.disassemble_one(b"\x5f", fork="shanghai")
self.assertTrue(insn.mnemonic == "PUSH0")
self.assertTrue(insn.fee == 2)
self.assertTrue(insn.pops == 0)
self.assertTrue(insn.pushes == 1)
self.assertTrue(insn.operand_size == 0)

def test_assemble_DUP1_regression(self):
insn = EVMAsm.assemble_one("DUP1")
self.assertEqual(insn.mnemonic, "DUP1")
Expand Down

0 comments on commit a6d6d7f

Please sign in to comment.