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

fix(f3): validate tipset before resetting the chain head #4931

Merged
merged 2 commits into from
Oct 28, 2024

Conversation

hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Oct 28, 2024

Summary of changes

This PR fixes a bug that Forest crashes when F3 resets the chain head. (We should merge this before releasing v0.21.1)

error:

2024-10-26T03:37:05.829Z        ERROR   f3      [email protected]/host.go:352        could not get timestamp of just finalized tipset: RPC error (-32603): Key for header not found
2024-10-26T03:37:06.382087Z  INFO forest_filecoin::chain::store::chain_store: New heaviest tipset! [bafy2bzacec4ebks2o4mt4itaq3ipf2zka23ctsz4j5dn4akw2mup2kz3ncrxm, bafy2bzacecdnlleq6q3vqn2rek5eqldercx2qe5min3arh2gn6mwuxfxgv4wi] (EPOCH = 2086246)
2024-10-26T03:37:06.382140Z  INFO forest_filecoin::rpc::methods::f3: F3 finalized tsk [bafy2bzacec4ebks2o4mt4itaq3ipf2zka23ctsz4j5dn4akw2mup2kz3ncrxm, bafy2bzaceczae4ft7az3boquqprikoegyhpqy44jxvnq456nljlbcoicigugu, bafy2bzacecati26vi2vpa5iltet24rkwhxd5zpra3f7vs3e5ijscho64geqj2, bafy2bzacebrksepzi7ttowme5q4c5j3zk3kyxassipg7tmqbhjywiozg5tftq, bafy2bzacecdnlleq6q3vqn2rek5eqldercx2qe5min3arh2gn6mwuxfxgv4wi] at epoch 2086246
2024-10-26T03:37:06.382689Z  INFO forest_filecoin::rpc::methods::f3: F3 reset chain head to tsk [bafy2bzacec4ebks2o4mt4itaq3ipf2zka23ctsz4j5dn4akw2mup2kz3ncrxm, bafy2bzaceczae4ft7az3boquqprikoegyhpqy44jxvnq456nljlbcoicigugu, bafy2bzacecati26vi2vpa5iltet24rkwhxd5zpra3f7vs3e5ijscho64geqj2, bafy2bzacebrksepzi7ttowme5q4c5j3zk3kyxassipg7tmqbhjywiozg5tftq, bafy2bzacecdnlleq6q3vqn2rek5eqldercx2qe5min3arh2gn6mwuxfxgv4wi] at epoch 2086246
2024-10-26T03:37:06.386650Z  INFO forest_filecoin::daemon::main: Shutting down tokio...
2024-10-26T03:37:06.391Z        ERROR   f3      [email protected]/host.go:252        error while finalizing decision at EC: RPC client error: sendRequest failed: Post "http://127.0.0.1:2345/rpc/v1": EOF
2024-10-26T03:37:06.887098Z  INFO forest_filecoin::daemon::main: Forest finish shutdown
Error: services failure

Caused by:
    0: Error changing head
    1: Invalid tipset: no msg root with cid bafy2bzacebflhrlxozfziy6sa6ke5rxhd2dqvhlzmtekswkgqghqzc6fyvo7w
➜  forest git:(main)

Manually verified the crash is fixed by this PR
After the fix:

2024-10-28T01:27:30.820816Z  INFO forest_filecoin::rpc::methods::f3: F3 finalized tsk [bafy2bzacebh3nd5ek7kav32lvcqeeruy5ynx3z2c3limjueiqw62m6kzc75mi, bafy2bzacealavtqyf6mas6wgq6ye6npbxk575lg2dtmparxltzmy55fbajgy6, bafy2bzacedjhzjk4vexcxcfmtuw525wv2mrmwkpwqersbzhj4vms6xkspsc7o, bafy2bzaceauj6jy7kvopm6nxkkv6eiodgpe73oppubrn3ujrpn67jh6egxhzk, bafy2bzacebccq3djw6kjjqsit7jgsx6avxfvnjs5bzqa6acyvwlja6ipqlyla] at epoch 2091748
2024-10-28T01:27:30.820947Z  INFO forest_filecoin::rpc::methods::f3: F3 reset chain head to tsk [bafy2bzacebh3nd5ek7kav32lvcqeeruy5ynx3z2c3limjueiqw62m6kzc75mi, bafy2bzacealavtqyf6mas6wgq6ye6npbxk575lg2dtmparxltzmy55fbajgy6, bafy2bzacedjhzjk4vexcxcfmtuw525wv2mrmwkpwqersbzhj4vms6xkspsc7o, bafy2bzaceauj6jy7kvopm6nxkkv6eiodgpe73oppubrn3ujrpn67jh6egxhzk, bafy2bzacebccq3djw6kjjqsit7jgsx6avxfvnjs5bzqa6acyvwlja6ipqlyla] at epoch 2091748
2024-10-28T01:27:31.604619Z  INFO forest_filecoin::chain_sync::tipset_syncer: Fork detected, searching for a common ancestor between the local chain and the network chain
2024-10-28T01:27:38.291058Z  INFO forest_filecoin::chain::store::chain_store: New heaviest tipset! [bafy2bzacebh3nd5ek7kav32lvcqeeruy5ynx3z2c3limjueiqw62m6kzc75mi, bafy2bzacealavtqyf6mas6wgq6ye6npbxk575lg2dtmparxltzmy55fbajgy6] (EPOCH = 2091748)
2024-10-28T01:27:40.060763Z  INFO forest_filecoin::chain_sync::tipset_syncer: Validating tipset: EPOCH = 2091747, N blocks = 3
2024-10-28T01:27:40.060891Z  INFO forest_filecoin::chain_sync::tipset_syncer: Validating tipset: EPOCH = 2091748, N blocks = 5
2024-10-28T01:27:40.073131Z  INFO forest_filecoin::chain_sync::tipset_syncer: Validating tipset: EPOCH = 2091749, N blocks = 1
2024-10-28T01:27:40.083961Z  INFO forest_filecoin::chain_sync::tipset_syncer: Successfully synced tipset range: [2091748, 2091749]

Changes introduced in this pull request:

  • save tipset messages to database and validate the tipset before resetting the chain head
  • refactor the code and remove some unnecessary Box and Arc wrappers

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@hanabi1224 hanabi1224 marked this pull request as ready for review October 28, 2024 01:37
@hanabi1224 hanabi1224 requested a review from a team as a code owner October 28, 2024 01:37
@hanabi1224 hanabi1224 requested review from LesnyRumcajs and elmattic and removed request for a team October 28, 2024 01:37
Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

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

Changelog entry?

@hanabi1224 hanabi1224 added this pull request to the merge queue Oct 28, 2024
@hanabi1224
Copy link
Contributor Author

Changelog entry?

@LesnyRumcajs the bug it fixes is in a feature that was not enabled in the last release.

Merged via the queue into main with commit 9d76a71 Oct 28, 2024
34 checks passed
@hanabi1224 hanabi1224 deleted the hm/f3-finalize-validate-full-tipset branch October 28, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants