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

Expose CLI for explicit chain sync and head manipulation #3442

Closed
anorth opened this issue Sep 17, 2019 · 5 comments
Closed

Expose CLI for explicit chain sync and head manipulation #3442

anorth opened this issue Sep 17, 2019 · 5 comments
Assignees

Comments

@anorth
Copy link
Member

anorth commented Sep 17, 2019

Description

While debugging staging-0.5.0 I added some debug statements to the storage miner actor code. The only way to trigger these was to destroy my repo and then re-sync the chain, including re-fetching it from remote peers. Now that a new release has been deployed, I can't do that.

It would be more efficient and direct to instead support explicit rewinding of chain head back to the genesis, and then sync of the desired head tipset. This would cause the chain to be re-validated (fetching all the required data from the local store).

Chain import export #3443 could be another solution to the general problem.

Acceptance criteria

  • chain set-head <cid>.... command replaces the chain store's head with the provided tipset key cids (which must be present in the store)
  • chain sync <cid>... invokes HandleNewTipset with the provided tipset key, revalidating that part of the chain subsequent to wherever the new head diverges from the prior chain.

Risks + pitfalls

These commands allow an unwitting user to screw up their local chain state. I don't think this should be a dominating concern during the present stage of development.

FYI @ZenGround0 @frrist

@frrist
Copy link
Member

frrist commented Sep 17, 2019

The syncer uses the store's HasTipSetAndState method as a stopping point, it's the first call HandleNewTipSet makes, and is also used in the fetcher callback. Would we expect the set-head command to erase all state from the chain store's TipsIndex that is a child of the head state we are setting?

As the code read now, the syncer will not resync any head it already has state for.

@frrist
Copy link
Member

frrist commented Sep 17, 2019

These commands allow an unwitting user to screw up their local chain state. I don't think this should be a dominating concern during the present stage of development.

Given this I would feel comfortable with either (A) adding an option to the syncer that instructs it to ignore previous state while syncing or (B) Diffing the current state with the state of the head we are setting, and removing it from the TipIndex's state map when calling SetHead or (C) bouncing the node after a call to SetHead to trigger chain reprocessing.

@anorth
Copy link
Member Author

anorth commented Sep 17, 2019

For a first pass, (c) bouncing the node is ok. But otherwise yes I think we should expect something like (b) to remove all entries from the in-memory tip index that are not on the chain defined by the new head.

We could use this to make it safer too. A rewind rather than set-head could require that the provided tipset actually be on the chain from genesis (inclusive) to head, and the implementation could then walk back up the chain, dropping the in-memory state as it goes.

@ZenGround0
Copy link
Contributor

This mostly LGTM. The general idea is great. If we were designing a CLI that Did the Right Thing, then set-head would not do something drastically different from the internal set head (clear the internal tipindex). Instead it would just reset the head pointed to by the chain store. Then a separate command i.e. trim would remove all chain state not on the longest chain. The code for trim in this proposal would be somewhat related to #2634 but expanded in scope to garbage collect tipsets in memory too.

The above ideas might take more time to work out so I understand if throwing all functionality on set-head is the right choice to make now for quick turnaround of setting up debugging tools.

@frrist
Copy link
Member

frrist commented Sep 26, 2019

closed via #3444

@frrist frrist closed this as completed Sep 26, 2019
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

No branches or pull requests

3 participants