-
Notifications
You must be signed in to change notification settings - Fork 971
Don't create child lookup if parent is faulty #7118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mergify
merged 6 commits into
sigp:unstable
from
dapplion:fix-lookup-create-failed-parent
Jun 5, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a8a067c
Don't create child lookup if parent is faulty
dapplion 86bc221
Merge remote-tracking branch 'sigp/unstable' into fix-lookup-create-f…
dapplion 36d87dd
Merge branch 'unstable' into fix-lookup-create-failed-parent
jimmygchen fc47f0d
Add regression test for the fix.
jimmygchen 8863c9c
Ensure single penalty
dapplion 74da1fd
Assert penalty happens in the expected place
dapplion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1725,6 +1725,63 @@ fn test_parent_lookup_too_deep_grow_ancestor() { | |
| rig.assert_failed_chain(chain_hash); | ||
| } | ||
|
|
||
| // Regression test for https://github.com/sigp/lighthouse/pull/7118 | ||
| #[test] | ||
| fn test_child_lookup_not_created_for_failed_chain_parent_after_processing() { | ||
| // GIVEN: A parent chain longer than PARENT_DEPTH_TOLERANCE. | ||
| let mut rig = TestRig::test_setup(); | ||
| let mut blocks = rig.rand_blockchain(PARENT_DEPTH_TOLERANCE + 1); | ||
| let peer_id = rig.new_connected_peer(); | ||
|
|
||
| // The child of the trigger block to be used to extend the chain. | ||
| let trigger_block_child = blocks.pop().unwrap(); | ||
| // The trigger block that starts the lookup. | ||
| let trigger_block = blocks.pop().unwrap(); | ||
| let tip_root = trigger_block.canonical_root(); | ||
|
|
||
| // Trigger the initial unknown parent block for the tip. | ||
| rig.trigger_unknown_parent_block(peer_id, trigger_block.clone()); | ||
|
|
||
| // Simulate the lookup chain building up via `ParentUnknown` errors. | ||
| for block in blocks.into_iter().rev() { | ||
| let id = rig.expect_block_parent_request(block.canonical_root()); | ||
| rig.parent_lookup_block_response(id, peer_id, Some(block.clone())); | ||
| rig.parent_lookup_block_response(id, peer_id, None); | ||
| rig.expect_block_process(ResponseType::Block); | ||
| rig.parent_block_processed( | ||
| tip_root, | ||
| BlockProcessingResult::Err(BlockError::ParentUnknown { | ||
| parent_root: block.parent_root(), | ||
| }), | ||
| ); | ||
| } | ||
|
|
||
| // At this point, the chain should have been deemed too deep and pruned. | ||
| // The tip root should have been inserted into failed chains. | ||
| rig.assert_failed_chain(tip_root); | ||
| rig.expect_no_penalty_for(peer_id); | ||
|
|
||
| // WHEN: Trigger the extending block that points to the tip. | ||
| let trigger_block_child_root = trigger_block_child.canonical_root(); | ||
| rig.trigger_unknown_block_from_attestation(trigger_block_child_root, peer_id); | ||
| let id = rig.expect_block_lookup_request(trigger_block_child_root); | ||
| rig.single_lookup_block_response(id, peer_id, Some(trigger_block_child.clone())); | ||
| rig.single_lookup_block_response(id, peer_id, None); | ||
| rig.expect_block_process(ResponseType::Block); | ||
| rig.single_block_component_processed( | ||
| id.lookup_id, | ||
| BlockProcessingResult::Err(BlockError::ParentUnknown { | ||
| parent_root: tip_root, | ||
| }), | ||
| ); | ||
|
|
||
| // THEN: The extending block should not create a lookup because the tip was inserted into failed chains. | ||
| rig.expect_no_active_lookups(); | ||
| // AND: The peer should be penalized for extending a failed chain. | ||
| rig.expect_single_penalty(peer_id, "failed_chain"); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, we then penalize peers who do the same action. This is inconsistent and can lead to penalties for honest peers. We should not penalize peers who extend known long chains. We could have to hashsets
We should fix this in a future PR |
||
| rig.expect_empty_network(); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_parent_lookup_too_deep_grow_tip() { | ||
| let mut rig = TestRig::test_setup(); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test follows current behaviour where we do NOT penalize peers for sending us long chains that maybe be canonical (honest behaviour).