Skip to content

Commit

Permalink
Enable more fulu test generators (#4108)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia authored Jan 30, 2025
1 parent 8ee551c commit dd97ae7
Show file tree
Hide file tree
Showing 18 changed files with 519 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ PYSPEC_DIR = $(TEST_LIBS_DIR)/pyspec
# Create the pyspec for all phases.
pyspec: $(VENV) setup.py pyproject.toml
@echo "Building eth2spec"
@$(PYTHON_VENV) -m uv pip install .[docs,lint,test,generator]
@$(PYTHON_VENV) -m uv pip install --reinstall-package=eth2spec .[docs,lint,test,generator]
@echo "Building all pyspecs"
@$(PYTHON_VENV) setup.py pyspecdev

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO: add new data availability tests.
Empty file.
438 changes: 438 additions & 0 deletions tests/core/pyspec/eth2spec/test/fulu/random/test_random.py

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions tests/core/pyspec/eth2spec/test/utils/randomized_block_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ def randomize_state_electra(spec, state, stats, exit_fraction=0.1, slash_fractio
return scenario_state


def randomize_state_fulu(spec, state, stats, exit_fraction=0.1, slash_fraction=0.1):
scenario_state = randomize_state_electra(
spec,
state,
stats,
exit_fraction=exit_fraction,
slash_fraction=slash_fraction,
)
return scenario_state


# epochs

def epochs_until_leak(spec):
Expand Down Expand Up @@ -269,6 +280,12 @@ def random_block_electra(spec, state, signed_blocks, scenario_state, rng=Random(
return block


def random_block_fulu(spec, state, signed_blocks, scenario_state, rng=Random(3456)):
block = random_block_electra(spec, state, signed_blocks, scenario_state, rng=rng)

return block


# validations

def no_op_validation(_spec, _state):
Expand Down
6 changes: 5 additions & 1 deletion tests/generators/epoch_processing/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, combine_mods, check_mods
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU


if __name__ == "__main__":
Expand Down Expand Up @@ -49,6 +49,9 @@
_new_electra_mods = {**_new_electra_mods_1, **_new_electra_mods_2}
electra_mods = combine_mods(_new_electra_mods, deneb_mods)

# No additional Fulu specific epoch processing tests
fulu_mods = electra_mods

# TODO Custody Game testgen is disabled for now
# custody_game_mods = {**{key: 'eth2spec.test.custody_game.epoch_processing.test_process_' + key for key in [
# 'reveal_deadlines',
Expand All @@ -63,6 +66,7 @@
CAPELLA: capella_mods,
DENEB: deneb_mods,
ELECTRA: electra_mods,
FULU: fulu_mods,
}
check_mods(all_mods, "epoch_processing")

Expand Down
4 changes: 3 additions & 1 deletion tests/generators/finality/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, check_mods
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU


if __name__ == "__main__":
Expand All @@ -9,6 +9,7 @@
capella_mods = bellatrix_mods # No additional Capella specific finality tests
deneb_mods = capella_mods # No additional Deneb specific finality tests
electra_mods = deneb_mods # No additional Electra specific finality tests
fulu_mods = electra_mods # No additional Fulu specific finality tests

all_mods = {
PHASE0: phase_0_mods,
Expand All @@ -17,6 +18,7 @@
CAPELLA: capella_mods,
DENEB: deneb_mods,
ELECTRA: electra_mods,
FULU: fulu_mods,
}
check_mods(all_mods, "finality")

Expand Down
9 changes: 8 additions & 1 deletion tests/generators/fork_choice/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, combine_mods, check_mods
from eth2spec.test.helpers.constants import ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA
from eth2spec.test.helpers.constants import ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU


if __name__ == "__main__":
Expand Down Expand Up @@ -30,12 +30,19 @@

electra_mods = deneb_mods # No additional Electra specific fork choice tests

# Fulu adds new `is_data_available` tests
_new_fulu_mods = {key: 'eth2spec.test.fulu.fork_choice.test_' + key for key in [
'on_block',
]}
fulu_mods = combine_mods(_new_fulu_mods, electra_mods)

all_mods = {
ALTAIR: altair_mods,
BELLATRIX: bellatrix_mods,
CAPELLA: capella_mods,
DENEB: deneb_mods,
ELECTRA: electra_mods,
FULU: fulu_mods,
}
check_mods(all_mods, "fork_choice")

Expand Down
5 changes: 4 additions & 1 deletion tests/generators/forks/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Iterable

from eth2spec.test.helpers.constants import (
PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA,
PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU,
MINIMAL, MAINNET,
)
from eth2spec.test.helpers.typing import SpecForkName, PresetBaseName
Expand All @@ -10,6 +10,7 @@
from eth2spec.test.capella.fork import test_capella_fork_basic, test_capella_fork_random
from eth2spec.test.deneb.fork import test_deneb_fork_basic, test_deneb_fork_random
from eth2spec.test.electra.fork import test_electra_fork_basic, test_electra_fork_random
from eth2spec.test.fulu.fork import test_fulu_fork_basic, test_fulu_fork_random
from eth2spec.gen_helpers.gen_base import gen_runner, gen_typing
from eth2spec.gen_helpers.gen_from_tests.gen import generate_from_tests

Expand Down Expand Up @@ -45,6 +46,8 @@ def _get_fork_tests_providers():
yield create_provider(test_deneb_fork_random, preset, CAPELLA, DENEB)
yield create_provider(test_electra_fork_basic, preset, DENEB, ELECTRA)
yield create_provider(test_electra_fork_random, preset, DENEB, ELECTRA)
yield create_provider(test_fulu_fork_basic, preset, ELECTRA, FULU)
yield create_provider(test_fulu_fork_random, preset, ELECTRA, FULU)


if __name__ == "__main__":
Expand Down
5 changes: 4 additions & 1 deletion tests/generators/genesis/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, check_mods
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU


if __name__ == "__main__":
Expand All @@ -13,13 +13,16 @@
capella_mods = bellatrix_mods # No additional Capella specific genesis tests
deneb_mods = capella_mods # No additional Deneb specific genesis tests
electra_mods = deneb_mods # No additional Electra specific genesis tests
fulu_mods = electra_mods # No additional Fulu specific genesis tests

all_mods = {
PHASE0: phase_0_mods,
ALTAIR: altair_mods,
BELLATRIX: bellatrix_mods,
CAPELLA: capella_mods,
DENEB: deneb_mods,
ELECTRA: electra_mods,
FULU: fulu_mods,
}
check_mods(all_mods, "genesis")

Expand Down
8 changes: 7 additions & 1 deletion tests/generators/light_client/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from eth2spec.test.helpers.constants import ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA
from eth2spec.test.helpers.constants import ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU
from eth2spec.gen_helpers.gen_from_tests.gen import combine_mods, run_state_test_generators, check_mods


Expand Down Expand Up @@ -27,14 +27,20 @@
'sync',
]}
deneb_mods = combine_mods(_new_deneb_mods, capella_mods)

# No additional Electra specific light client tests
electra_mods = deneb_mods

# No additional Electra specific light client tests
fulu_mods = electra_mods

all_mods = {
ALTAIR: altair_mods,
BELLATRIX: bellatrix_mods,
CAPELLA: capella_mods,
DENEB: deneb_mods,
ELECTRA: electra_mods,
FULU: fulu_mods,
}
check_mods(all_mods, "light_client")

Expand Down
6 changes: 5 additions & 1 deletion tests/generators/operations/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, combine_mods, check_mods
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU


if __name__ == "__main__":
Expand Down Expand Up @@ -53,13 +53,17 @@
]}
electra_mods = combine_mods(_new_electra_mods, deneb_mods)

# No additional Fulu specific block processing tests
fulu_mods = electra_mods

all_mods = {
PHASE0: phase_0_mods,
ALTAIR: altair_mods,
BELLATRIX: bellatrix_mods,
CAPELLA: capella_mods,
DENEB: deneb_mods,
ELECTRA: electra_mods,
FULU: fulu_mods,
}
check_mods(all_mods, "block_processing")

Expand Down
11 changes: 10 additions & 1 deletion tests/generators/random/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
randomize_state_capella,
randomize_state_deneb,
randomize_state_electra,
randomize_state_fulu,
random_block,
random_block_altair_with_cycling_sync_committee_participation,
random_block_bellatrix,
random_block_capella,
random_block_deneb,
random_block_electra,
random_block_fulu,
last_slot_in_epoch,
random_slot_in_epoch,
penultimate_slot_in_epoch,
Expand All @@ -38,7 +40,7 @@
transition_to_leaking,
transition_without_leak,
)
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU


# Ensure this many blocks are present in *each* randomized scenario
Expand Down Expand Up @@ -290,5 +292,12 @@ def run_generate_tests_to_std_out(phase, state_randomizer, block_randomizer):
state_randomizer=randomize_state_electra,
block_randomizer=random_block_electra,
)
if FULU in sys.argv:
did_generate = True
run_generate_tests_to_std_out(
FULU,
state_randomizer=randomize_state_fulu,
block_randomizer=random_block_fulu,
)
if not did_generate:
warnings.warn("no phase given for test generation")
6 changes: 5 additions & 1 deletion tests/generators/random/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from eth2spec.test.helpers.constants import (
PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA,
PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU
)
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, check_mods

Expand All @@ -23,6 +23,9 @@
electra_mods = {key: 'eth2spec.test.electra.random.test_' + key for key in [
'random',
]}
fulu_mods = {key: 'eth2spec.test.fulu.random.test_' + key for key in [
'random',
]}

all_mods = {
PHASE0: phase_0_mods,
Expand All @@ -31,6 +34,7 @@
CAPELLA: capella_mods,
DENEB: deneb_mods,
ELECTRA: electra_mods,
FULU: fulu_mods,
}
check_mods(all_mods, "random")

Expand Down
4 changes: 3 additions & 1 deletion tests/generators/rewards/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, check_mods
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU


if __name__ == "__main__":
Expand All @@ -18,6 +18,7 @@
capella_mods = bellatrix_mods
deneb_mods = capella_mods
electra_mods = deneb_mods
fulu_mods = electra_mods

all_mods = {
PHASE0: phase_0_mods,
Expand All @@ -26,6 +27,7 @@
CAPELLA: capella_mods,
DENEB: deneb_mods,
ELECTRA: electra_mods,
FULU: fulu_mods,
}
check_mods(all_mods, "rewards")

Expand Down
6 changes: 5 additions & 1 deletion tests/generators/sanity/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, combine_mods, check_mods


Expand Down Expand Up @@ -40,13 +40,17 @@
_new_electra_mods = {**_new_electra_mods_1, **_new_electra_mods_2}
electra_mods = combine_mods(_new_electra_mods, deneb_mods)

# No additional Fulu specific sanity tests
fulu_mods = electra_mods

all_mods = {
PHASE0: phase_0_mods,
ALTAIR: altair_mods,
BELLATRIX: bellatrix_mods,
CAPELLA: capella_mods,
DENEB: deneb_mods,
ELECTRA: electra_mods,
FULU: fulu_mods,
}
check_mods(all_mods, "sanity")

Expand Down
4 changes: 3 additions & 1 deletion tests/generators/sync/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, check_mods
from eth2spec.test.helpers.constants import BELLATRIX, CAPELLA, DENEB, ELECTRA
from eth2spec.test.helpers.constants import BELLATRIX, CAPELLA, DENEB, ELECTRA, FULU


if __name__ == "__main__":
Expand All @@ -9,12 +9,14 @@
capella_mods = bellatrix_mods
deneb_mods = capella_mods
electra_mods = deneb_mods
fulu_mods = electra_mods

all_mods = {
BELLATRIX: bellatrix_mods,
CAPELLA: capella_mods,
DENEB: deneb_mods,
ELECTRA: electra_mods,
FULU: fulu_mods,
}
check_mods(all_mods, "sync")

Expand Down

0 comments on commit dd97ae7

Please sign in to comment.