diff --git a/pyevmasm/evmasm.py b/pyevmasm/evmasm.py index e49f739..c514cb8 100644 --- a/pyevmasm/evmasm.py +++ b/pyevmasm/evmasm.py @@ -5,7 +5,7 @@ from future.builtins import next, bytes # type: ignore import copy -DEFAULT_FORK = "london" +DEFAULT_FORK = "shanghai" """ Example use:: @@ -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", @@ -1105,6 +1111,7 @@ def __repr__(self): "serenity", "istanbul", "london", + "shanghai" ) @@ -1119,6 +1126,7 @@ def __repr__(self): "serenity": serenity_instruction_table, "istanbul": istanbul_instruction_table, "london": london_instruction_table, + "shanghai": shanghai_instruction_table, } @@ -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()) diff --git a/setup.py b/setup.py index d93c082..5624c27 100644 --- a/setup.py +++ b/setup.py @@ -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='evmasm@trailofbits.com', diff --git a/tests/test_EVMAssembler.py b/tests/test_EVMAssembler.py index d226b6e..1a44b68 100644 --- a/tests/test_EVMAssembler.py +++ b/tests/test_EVMAssembler.py @@ -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")