Skip to content
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

feat(chain): rework checkpoint logic to better handle finality #12650

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

Stebalien
Copy link
Member

Related Issues

fixes filecoin-project/go-f3#717

Proposed Changes

  1. Optimize finding ancestors.
  2. Allow setting checkpoints arbitrarily far in the past.
  3. Forbid setting checkpoints, even future/current checkpoints, that would revert more than 900
    epochs of the current chain.

Checklist

Before you mark the PR ready for review, please make sure that:

That way we efficiently accept old and checkpoint finality certificates.
1. Allow setting checkpoints more than 900 epochs ago as long as said
checkpoint doesn't cause us to _revert_ more than 900 epochs.

2. Verify that we don't end up reverting more than 900 epochs
when switching to a chain at or beyond the current head.

3. Optimize all of this such that, e.g., setting checkpoints in the
distant past can use the chain index instead of having to walk back the
chain manually. We may still need to walk up to 900 epochs to make sure
we're not forking beyond finality, but that's it.
It's unused, inefficient, and a potential DoS vector if someone decides
to use it.
Copy link
Contributor

@Kubuxu Kubuxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGWM, having better tests would make me more confident from a thorough look, I think it is correct.

@Kubuxu Kubuxu added release/backport skip/changelog This change does not require CHANGELOG.md update labels Oct 28, 2024
@Kubuxu Kubuxu merged commit 33577db into master Oct 28, 2024
84 of 85 checks passed
@Kubuxu Kubuxu deleted the steb/f3-fork branch October 28, 2024 17:11
@Stebalien
Copy link
Member Author

I'm working on the test, just running into some issues with the lotus "chain gen" logic.

Kubuxu pushed a commit that referenced this pull request Oct 28, 2024
* feat(chain): use the index when determining if A is an ancestor of B

That way we efficiently accept old and checkpoint finality certificates.

* feat(chain): allow checkpoints beyond finality but prevent forks

1. Allow setting checkpoints more than 900 epochs ago as long as said
checkpoint doesn't cause us to _revert_ more than 900 epochs.

2. Verify that we don't end up reverting more than 900 epochs
when switching to a chain at or beyond the current head.

3. Optimize all of this such that, e.g., setting checkpoints in the
distant past can use the chain index instead of having to walk back the
chain manually. We may still need to walk up to 900 epochs to make sure
we're not forking beyond finality, but that's it.

* chore(chain): remove ChainStore.NearestCommonAncestor

It's unused, inefficient, and a potential DoS vector if someone decides
to use it.
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
rjan90 pushed a commit that referenced this pull request Oct 28, 2024
* feat(chain): use the index when determining if A is an ancestor of B

That way we efficiently accept old and checkpoint finality certificates.

* feat(chain): allow checkpoints beyond finality but prevent forks

1. Allow setting checkpoints more than 900 epochs ago as long as said
checkpoint doesn't cause us to _revert_ more than 900 epochs.

2. Verify that we don't end up reverting more than 900 epochs
when switching to a chain at or beyond the current head.

3. Optimize all of this such that, e.g., setting checkpoints in the
distant past can use the chain index instead of having to walk back the
chain manually. We may still need to walk up to 900 epochs to make sure
we're not forking beyond finality, but that's it.

* chore(chain): remove ChainStore.NearestCommonAncestor

It's unused, inefficient, and a potential DoS vector if someone decides
to use it.
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip/changelog This change does not require CHANGELOG.md update
Projects
Status: ☑️ Done (Archive)
Development

Successfully merging this pull request may close these issues.

Prevent very large reverts based on finality certificates
4 participants