From 4ed16abdb461f3e0d74ce579b7f815e819f320ab Mon Sep 17 00:00:00 2001 From: Alex Vlasov Date: Tue, 2 Jul 2024 00:30:30 +0400 Subject: [PATCH 1/7] added `viable_for_head_roots_and_weights` check description --- tests/formats/fork_choice/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/formats/fork_choice/README.md b/tests/formats/fork_choice/README.md index 066e4ceed5..f848fb60f0 100644 --- a/tests/formats/fork_choice/README.md +++ b/tests/formats/fork_choice/README.md @@ -177,6 +177,10 @@ finalized_checkpoint: { root: string, -- Encoded 32-byte value from store.finalized_checkpoint.root } proposer_boost_root: string -- Encoded 32-byte value from store.proposer_boost_root +viable_for_head_roots_and_weights: { + root: string, -- Encoded 32-byte value of filtered_block_tree leaf blocks + weight: int -- Integer value from get_weight(store, viable_block_root) +} ``` Additionally, these fields if `get_proposer_head` and `should_override_forkchoice_update` features are implemented: From fb3ff0fe3d632d8a4ed0ef0b2ca19b9266641d1b Mon Sep 17 00:00:00 2001 From: Alex Vlasov Date: Tue, 2 Jul 2024 03:26:17 +0400 Subject: [PATCH 2/7] fixed names (small -> tiny, smoke -> small) --- .../generate_test_instances.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/generators/fork_choice_generated/generate_test_instances.py b/tests/generators/fork_choice_generated/generate_test_instances.py index 0c997d8ce1..3846719cf5 100644 --- a/tests/generators/fork_choice_generated/generate_test_instances.py +++ b/tests/generators/fork_choice_generated/generate_test_instances.py @@ -115,26 +115,26 @@ def generate_block_cover(params): gen_params = { ################### - # small instances # + # tiny instances # ################### - 'block_tree_tree_small': { - 'out_path': 'small/block_tree_tree.yaml', + 'block_tree_tree_tiny': { + 'out_path': 'tiny/block_tree_tree.yaml', 'models': ['sm_link', 'block_tree'], 'params': [ ({'anchor_epoch': 0, 'number_of_epochs': 4, 'number_of_links': 3}, {'number_of_blocks': 8, 'max_children': 2, 'number_of_solutions': 3}), ([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 16, 'max_children': 2, 'number_of_solutions': 3}), ] }, - 'block_tree_other_small': { - 'out_path': 'small/block_tree_other.yaml', + 'block_tree_other_tiny': { + 'out_path': 'tiny/block_tree_other.yaml', 'models': ['sm_link', 'block_tree'], 'params': [ ([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 12, 'max_children': 2, 'number_of_solutions': 3}), ] }, - 'block_cover_small': { - 'out_path': 'small/block_cover.yaml', + 'block_cover_tiny': { + 'out_path': 'tiny/block_cover.yaml', 'models': ['block_cover'], 'params': [ ({'anchor_epoch': 0, 'number_of_solutions': 1},), @@ -143,11 +143,11 @@ def generate_block_cover(params): }, ################### - # smoke instances # + # small instances # ################### - 'block_tree_tree_smoke': { - 'out_path': 'smoke/block_tree_tree.yaml', + 'block_tree_tree_small': { + 'out_path': 'small/block_tree_tree.yaml', 'models': ['sm_link', 'block_tree'], 'params': [ ({'anchor_epoch': 0, 'number_of_epochs': 5, 'number_of_links': 3}, {'number_of_blocks': 16, 'max_children': 2, 'number_of_solutions': 2}), @@ -155,8 +155,8 @@ def generate_block_cover(params): ([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 12, 'max_children': 2, 'number_of_solutions': 73}), ] }, - 'block_tree_tree_smoke_2': { - 'out_path': 'smoke/block_tree_tree_2.yaml', + 'block_tree_tree_small_2': { + 'out_path': 'small/block_tree_tree_2.yaml', 'models': ['sm_link', 'block_tree'], 'params': [ ({'anchor_epoch': 0, 'number_of_epochs': 6, 'number_of_links': 4}, {'number_of_blocks': 16, 'max_children': 2, 'number_of_solutions': 2}), @@ -164,15 +164,15 @@ def generate_block_cover(params): ([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 12, 'max_children': 2, 'number_of_solutions': 283}), ] }, - 'block_tree_other_smoke': { - 'out_path': 'smoke/block_tree_other.yaml', + 'block_tree_other_small': { + 'out_path': 'small/block_tree_other.yaml', 'models': ['sm_link', 'block_tree'], 'params': [ ([{'sm_links': [[0, 1], [0, 2], [2, 3], [3, 4]]}], {'number_of_blocks': 12, 'max_children': 2, 'number_of_solutions': 4}), ] }, - 'block_cover_smoke': { - 'out_path': 'smoke/block_cover.yaml', + 'block_cover_small': { + 'out_path': 'small/block_cover.yaml', 'models': ['block_cover'], 'params': [ ({'anchor_epoch': 0, 'number_of_solutions': 2},), From c494a969edea69cd6213470cdff5b761c6ed6c1c Mon Sep 17 00:00:00 2001 From: Alex Vlasov Date: Tue, 2 Jul 2024 03:26:41 +0400 Subject: [PATCH 3/7] added instructions how to generate and run tests --- .../fork_choice_generated/README.md | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/generators/fork_choice_generated/README.md b/tests/generators/fork_choice_generated/README.md index c27645d5cc..1e182d9141 100644 --- a/tests/generators/fork_choice_generated/README.md +++ b/tests/generators/fork_choice_generated/README.md @@ -7,3 +7,45 @@ Implementation of the approach described in the [Fork Choice compliance testing Preliminary research has been also performed in this [repo](https://github.com/txrx-research/fork_choice_test_generation/tree/main). To simplfy adoption of the tests, we follow the test format described in the [fork choice test formats documentation](../../formats/fork_choice/README.md), with a minor exception (new check added). + +# Pre-requisites + +Install requirements (preferrably, in a dedicated Python environment) + +''' +> pip install -r requirements.txt +''' + +In order to run tests, instal tqdm additionally. +``` +> pip install tqdm +``` + +# Generating tests + +``` +> python test_gen.py -o ${test_dir} --fc-gen-config ${config_dir}/test_gen.yaml +``` + +There are three configurations in the repo: [tiny](tiny/), [small](small/) and [standard](standard/). + +# Running tests + +Install `tqdm` library (to show progress) +``` +> pip install tqdm +``` + +and then +``` +> python test_run.py -i ${test_dirt} +``` + +# Generating configurations + +Files in [tiny](tiny/), [small](small/) and [standard](standard/) are generated with [generate_test_instances.py](generate_test_instances.py), e.g. +``` +> python generate_test_instances.py +``` + +But one normally doesn't need to generate them. \ No newline at end of file From fb231debea289f89d48e464559276bd01e3ea2ac Mon Sep 17 00:00:00 2001 From: Alex Vlasov Date: Tue, 2 Jul 2024 03:28:39 +0400 Subject: [PATCH 4/7] Update README.md Fix typo --- tests/generators/fork_choice_generated/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/generators/fork_choice_generated/README.md b/tests/generators/fork_choice_generated/README.md index 1e182d9141..1d37aff1a1 100644 --- a/tests/generators/fork_choice_generated/README.md +++ b/tests/generators/fork_choice_generated/README.md @@ -12,9 +12,9 @@ To simplfy adoption of the tests, we follow the test format described in the [fo Install requirements (preferrably, in a dedicated Python environment) -''' +``` > pip install -r requirements.txt -''' +``` In order to run tests, instal tqdm additionally. ``` @@ -48,4 +48,4 @@ Files in [tiny](tiny/), [small](small/) and [standard](standard/) are generated > python generate_test_instances.py ``` -But one normally doesn't need to generate them. \ No newline at end of file +But one normally doesn't need to generate them. From eeafb1c7bfa21f23bdbcc7789f1d3c94d8b51c03 Mon Sep 17 00:00:00 2001 From: Alex Vlasov Date: Tue, 2 Jul 2024 03:30:14 +0400 Subject: [PATCH 5/7] Update README.md Fixed typos --- tests/generators/fork_choice_generated/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/generators/fork_choice_generated/README.md b/tests/generators/fork_choice_generated/README.md index 1d37aff1a1..e3a7d7b2f1 100644 --- a/tests/generators/fork_choice_generated/README.md +++ b/tests/generators/fork_choice_generated/README.md @@ -16,7 +16,7 @@ Install requirements (preferrably, in a dedicated Python environment) > pip install -r requirements.txt ``` -In order to run tests, instal tqdm additionally. +In order to run tests, install `tqdm` additionally. ``` > pip install tqdm ``` @@ -38,7 +38,7 @@ Install `tqdm` library (to show progress) and then ``` -> python test_run.py -i ${test_dirt} +> python test_run.py -i ${test_dir} ``` # Generating configurations From 959274fe07872814eeb263ab2f1f171c0d0b3e59 Mon Sep 17 00:00:00 2001 From: Alex Vlasov Date: Tue, 2 Jul 2024 17:17:51 +0400 Subject: [PATCH 6/7] Update tests/formats/fork_choice/README.md Co-authored-by: Mikhail Kalinin --- tests/formats/fork_choice/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/formats/fork_choice/README.md b/tests/formats/fork_choice/README.md index f848fb60f0..2d2a990429 100644 --- a/tests/formats/fork_choice/README.md +++ b/tests/formats/fork_choice/README.md @@ -177,10 +177,10 @@ finalized_checkpoint: { root: string, -- Encoded 32-byte value from store.finalized_checkpoint.root } proposer_boost_root: string -- Encoded 32-byte value from store.proposer_boost_root -viable_for_head_roots_and_weights: { +viable_for_head_roots_and_weights: [{ root: string, -- Encoded 32-byte value of filtered_block_tree leaf blocks weight: int -- Integer value from get_weight(store, viable_block_root) -} +}] ``` Additionally, these fields if `get_proposer_head` and `should_override_forkchoice_update` features are implemented: From ce897c86db8d6ee89842ff493cf2215b401877e0 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Tue, 2 Jul 2024 23:41:53 +0600 Subject: [PATCH 7/7] Fix viable_for_head_roots_and_weights in example --- tests/formats/fork_choice/README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/formats/fork_choice/README.md b/tests/formats/fork_choice/README.md index 2d2a990429..7a3aeab282 100644 --- a/tests/formats/fork_choice/README.md +++ b/tests/formats/fork_choice/README.md @@ -193,13 +193,6 @@ should_override_forkchoice_update: { -- [New in Bellatrix] } ``` -Additional check utilized by the generated fork choice tests: -```yaml -viable_for_head_roots_and_weights: { - : -- A map listing roots of all viable for head blocks and their fork choice weights -} -``` - For example: ```yaml - checks: @@ -210,8 +203,10 @@ For example: proposer_boost_root: '0xdaa1d49d57594ced0c35688a6da133abb086d191a2ebdfd736fad95299325aeb' get_proposer_head: '0xdaa1d49d57594ced0c35688a6da133abb086d191a2ebdfd736fad95299325aeb' should_override_forkchoice_update: {validator_is_connected: false, result: false} - viable_for_head_roots_and_weights: {'0x533290b6f44d31c925acd08dfc8448624979d48c40b877d4e6714648866c9ddb': 192000000000, - '0x5cfb9d9099cdf1d8ab68ce96cdae9f0fa6eef16914a01070580dfdc1d2d59ec3': 544000000000} + viable_for_head_roots_and_weights: [ + {root: '0x533290b6f44d31c925acd08dfc8448624979d48c40b877d4e6714648866c9ddb', weight: 192000000000}, + {root: '0x5cfb9d9099cdf1d8ab68ce96cdae9f0fa6eef16914a01070580dfdc1d2d59ec3', weight: 544000000000} + ] ``` *Note*: Each `checks` step may include one or multiple items. Each item has to be checked against the current store.