Only return viable payload-status variants from get_head - #5509
Only return viable payload-status variants from get_head#55090xsamalt wants to merge 25 commits into
get_head#5509Conversation
|
What do you think about renaming |
|
Thanks for the suggestion. I like the direction, since the function is now FFG-testing payload-status variants rather than blocks, so One thing to flag: pysetup merges same-named functions across forks but has no rename detection, so renaming in Happy to make this change if you think it's worth it, wanted to confirm the approach and the |
|
I think we can alter the spec by introducing |
|
Good call, that also sidesteps the deprecation issue since Gloas redefines these functions rather than inheriting phase0's, so a phase0-origin rename should merge cleanly. I'll rework the PR: rename |
|
Pushed the rename. |
|
I was thinking about a little bit different design:
What are your thoughts on this? |
|
Implemented as described: |
…block-tree-payload-variants
Builtin hash is no longer shadowed in the compiled spec namespace after ethereum#5555, so the dataclass-generated hash can be used.
filter_block_treeget_head returning unviable Gloas payload-status variants
get_head returning unviable Gloas payload-status variantsget_head
|
Also, please take a moment to mark resolved comment as "resolved". |
| @with_gloas_and_later | ||
| @with_presets([MINIMAL], reason="too slow") | ||
| @spec_state_test | ||
| def test_get_head_prunes_childless_unviable_full_variant(spec, state): |
There was a problem hiding this comment.
Can you add a test that's the mirror of this case?
ie. childless EMPTY variant of a block that fails FFG test and K builds on FULL(B)?
There was a problem hiding this comment.
Also add one more:
both FULL(B) and EMPTY(B) pass FFG test, both childless, see if get_filtered_node_tree contains both
|
It would be great if @potuz could take a look at this PR as he was opposing to making this change into the spec |
potuz
left a comment
There was a problem hiding this comment.
This change looks correct to me, it is equivalent to what we already implement in Prysm anyway so it is zero changes for us.
| #### `get_node_children` | ||
|
|
||
| ```python | ||
| def get_node_children( |
There was a problem hiding this comment.
This is a deeper semantics change that probably should be commented, previous to this change get_node_children gets a prefiltered list of blocks that are descendant of the justified checkpoint, while now it takes nodes from the store and gives all children.
| node: ForkChoiceNode, | ||
| ) -> Sequence[ForkChoiceNode]: | ||
| return [ForkChoiceNode(root=root) for root in blocks if blocks[root].parent_root == node.root] | ||
| base = ForkChoiceNode(root=store.justified_checkpoint.root) |
There was a problem hiding this comment.
It's weird to think in nodes in phase 0 as now we have this bad situation in which we pass a ForkChoiceNode without any PayloadStatus.
| while True: | ||
| children = get_node_children(store, blocks, head) | ||
| children = [ | ||
| child for child in get_node_children(store, head) if child in filtered_node_tree |
There was a problem hiding this comment.
This is the semantic change consumer which requires a check in the caller instead of just a single filtering as we did before.
In Gloas,
get_node_childrenexpands aPENDINGnode into itsEMPTYandFULLpayload-status variants without consulting the filtered block tree or any FFG test (introduced in #5249). As a result, a childless variant of a block that fails the FFG test is never pruned: it can become a leaf of the LMD-GHOST walk and be returned byget_head, even though it is not viable (#5496).This PR makes
filter_block_treeoperate on payload-status variants, keyed by(root, payload_status), so that every variant is FFG-tested independently. The FFG test itself is unchanged and still computed per block root.get_node_childrennow only returns children present in the filtered block tree, so the head walk can never stop at a non-viable variant, andget_filtered_block_treeseeds the recursion from a pending node atstore.justified_checkpoint.root.Fixes #5496