diff --git a/pyevmasm/evmasm.py b/pyevmasm/evmasm.py index 668b4ba..fbce7ab 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 = "shanghai" +DEFAULT_FORK = "dencun" """ Example use:: @@ -1095,12 +1095,33 @@ 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 = { + 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 ) +dencun_instruction_table = { + 0x5E: ("MCOPY", 0, 3, 0, 3, "Copy memory areas."), + 0x49: ("BLOBHASH", 0, 1, 1, 1, "Get versioned hashes."), + 0x4A: ( + "BLOBBASEFEE", + 0, + 0, + 1, + 2, + "Returns the value of the blob base-fee of the current block.", + ), + 0x5C: ("TLOAD", 0, 1, 1, 100, "Load word from transient storage."), + 0x5D: ("TSTORE", 0, 2, 0, 100, "Save word to transient storage."), +} + +dencun_instruction_table = InstructionTable( # type: ignore + dencun_instruction_table, previous_fork=shanghai_instruction_table +) + accepted_forks = ( "frontier", "homestead", @@ -1112,7 +1133,8 @@ def __repr__(self): "serenity", "istanbul", "london", - "shanghai" + "shanghai", + "dencun", ) @@ -1128,6 +1150,7 @@ def __repr__(self): "istanbul": istanbul_instruction_table, "london": london_instruction_table, "shanghai": shanghai_instruction_table, + "dencun": dencun_instruction_table, } diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_EVMAssembler.py b/tests/test_EVMAssembler.py index 1a44b68..caf832c 100644 --- a/tests/test_EVMAssembler.py +++ b/tests/test_EVMAssembler.py @@ -135,6 +135,26 @@ def test_shanghai_fork(self): self.assertTrue(insn.pops == 0) self.assertTrue(insn.pushes == 1) self.assertTrue(insn.operand_size == 0) + + def test_dencun_fork(self): + insn = EVMAsm.disassemble_one(b"\x5e", fork="dencun") + self.assertTrue(insn.mnemonic == "MCOPY") + self.assertTrue(insn.fee == 3) + self.assertTrue(insn.pops == 3) + self.assertTrue(insn.pushes == 0) + self.assertTrue(insn.operand_size == 0) + + insn = EVMAsm.disassemble_one(b"\x49", fork="dencun") + self.assertTrue(insn.mnemonic == "BLOBHASH") + + insn = EVMAsm.disassemble_one(b"\x4a", fork="dencun") + self.assertTrue(insn.mnemonic == "BLOBBASEFEE") + + insn = EVMAsm.disassemble_one(b"\x5c", fork="dencun") + self.assertTrue(insn.mnemonic=="TLOAD") + + insn = EVMAsm.disassemble_one(b"\x5d", fork="dencun") + self.assertTrue(insn.mnemonic=="TSTORE") def test_assemble_DUP1_regression(self): insn = EVMAsm.assemble_one("DUP1")