Skip to content

Commit

Permalink
Merge pull request #47 from crytic/feat/base-fee
Browse files Browse the repository at this point in the history
make london hard fork default, add EIP1559 basefee opcode
  • Loading branch information
0xalpharush authored Jan 20, 2022
2 parents 2184d6b + cae3e75 commit 59499d6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyevmasm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def main():
"--fork",
default=DEFAULT_FORK,
type=str,
help="Fork, default: byzantium. "
"Possible: frontier, homestead, tangerine_whistle, spurious_dragon, byzantium, constantinople, serenity. "
help="Fork, default: london. "
"Possible: frontier, homestead, tangerine_whistle, spurious_dragon, byzantium, constantinople, istanbul, london, serenity. "
"Also an unsigned block number is accepted to select the fork.",
)

Expand Down
16 changes: 14 additions & 2 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 = "istanbul"
DEFAULT_FORK = "london"

"""
Example use::
Expand Down Expand Up @@ -976,6 +976,14 @@ def __repr__(self):
istanbul_instruction_table, previous_fork=serenity_instruction_table
)

london_instruction_table = {
0x48: ("BASEFEE", 0, 0, 1, 2, "Base fee in wei")
}

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

accepted_forks = (
"frontier",
"homestead",
Expand All @@ -986,6 +994,7 @@ def __repr__(self):
"petersburg",
"serenity",
"istanbul",
"london"
)


Expand All @@ -999,6 +1008,7 @@ def __repr__(self):
"petersburg": constantinople_instruction_table, # constantinople table is intentional here: those two are aliases
"serenity": serenity_instruction_table,
"istanbul": istanbul_instruction_table,
"london": london_instruction_table
}


Expand Down Expand Up @@ -1031,7 +1041,9 @@ def block_to_fork(block_number):
4370000: "byzantium",
# 7280000: "constantinople", # Same Block as petersburg, commented to avoid conflicts
7280000: "petersburg",
9999999: "serenity", # to be replaced after Serenity launch
9069000: "istanbul",
12965000: "london",
99999999: "serenity" # to be replaced after Serenity launch
}
fork_names = list(forks_by_block.values())
fork_blocks = list(forks_by_block.keys())
Expand Down
7 changes: 7 additions & 0 deletions tests/test_EVMAssembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ def test_istanbul_fork(self):
self.assertTrue(insn.fee == 800)
self.assertTrue(insn.pops == 1)
self.assertTrue(insn.pushes == 1)

def test_london_fork(self):
insn = EVMAsm.disassemble_one(b"\x48", fork="london")
self.assertTrue(insn.mnemonic == "BASEFEE")
self.assertTrue(insn.fee == 2)
self.assertTrue(insn.pops == 0)
self.assertTrue(insn.pushes == 1)

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

0 comments on commit 59499d6

Please sign in to comment.