Skip to content

Commit c54c1cf

Browse files
LouisTsai-CsieCarsons-Eels
authored andcommitted
feat(forks): add stack limit in fork configuration (ethereum#1768)
* feat: add max_stack_height method to BaseFork and Frontier classes * refactor: replace hardcode stack limit to fork configuration
1 parent a7c7353 commit c54c1cf

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/ethereum_test_forks/base_fork.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,12 @@ def max_code_size(cls) -> int:
480480
"""Return the maximum code size allowed to be deployed in a contract creation."""
481481
pass
482482

483+
@classmethod
484+
@abstractmethod
485+
def max_stack_height(cls) -> int:
486+
"""Return the maximum stack height allowed in the EVM stack."""
487+
pass
488+
483489
@classmethod
484490
@abstractmethod
485491
def max_initcode_size(cls) -> int:

src/ethereum_test_forks/forks/forks.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ def max_code_size(cls) -> int:
380380
"""However, the default is set to the limit of EIP-170 (Spurious Dragon)"""
381381
return 0x6000
382382

383+
@classmethod
384+
def max_stack_height(cls) -> int:
385+
"""At genesis, the maximum stack height is 1024."""
386+
return 1024
387+
383388
@classmethod
384389
def max_initcode_size(cls) -> int:
385390
"""At genesis, there is no upper bound for initcode size."""

tests/zkevm/test_worst_compute.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
REFERENCE_SPEC_GIT_PATH = "TODO"
4242
REFERENCE_SPEC_VERSION = "TODO"
4343

44-
MAX_STACK_HEIGHT = 1024
4544
KECCAK_RATE = 136
4645

4746

@@ -90,7 +89,7 @@ def test_worst_zero_param(
9089
"""Test running a block with as many zero-parameter opcodes as possible."""
9190
env = Environment()
9291

93-
opcode_sequence = opcode * MAX_STACK_HEIGHT
92+
opcode_sequence = opcode * fork.max_stack_height()
9493
target_contract_address = pre.deploy_contract(code=opcode_sequence)
9594

9695
calldata = Bytecode()

0 commit comments

Comments
 (0)