Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dencun upgrade instrs #64

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions 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 = "shanghai"
DEFAULT_FORK = "dencun"

"""
Example use::
Expand Down Expand Up @@ -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",
Expand All @@ -1112,7 +1133,8 @@ def __repr__(self):
"serenity",
"istanbul",
"london",
"shanghai"
"shanghai",
"dencun",
)


Expand All @@ -1128,6 +1150,7 @@ def __repr__(self):
"istanbul": istanbul_instruction_table,
"london": london_instruction_table,
"shanghai": shanghai_instruction_table,
"dencun": dencun_instruction_table,
}


Expand Down
Empty file added tests/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions tests/test_EVMAssembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down