Skip to content

feat: add bootstrap-state cmd#803

Closed
yihuang wants to merge 5 commits intocometbft:mainfrom
yihuang:bootstrap-state
Closed

feat: add bootstrap-state cmd#803
yihuang wants to merge 5 commits intocometbft:mainfrom
yihuang:bootstrap-state

Conversation

@yihuang
Copy link
Contributor

@yihuang yihuang commented May 8, 2023

Ref: #29

Add bootstrap-state height command to initialize consensus state to specific height using light client protocol, user can restore app state from local snapshot in a separate step, then the node should be able to run.
It's not intrusive to the handshaking process, compared with ADR-083


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments

@yihuang
Copy link
Contributor Author

yihuang commented May 9, 2023

it's ported to cosmos-sdk: cosmos/cosmos-sdk#16061, closing for now, I guess no need to merge the hacky solution here, cometbft can take the time for a better solution.

}

store.SaveBlockStoreState(&cmtstore.BlockStoreState{
// it breaks the invariant that blocks in range [Base, Height] must exists, but it do works in practice.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part is probably not ideal, but I don't have a better idea here, it's to initialize block store state, otherwise node can't start.

A related thing is, during normal state-sync, if the node is interrupted after switch to fast-sync but before download the first block, it's a similar situation, the node will end up in an invalid state.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I took a look at our 'online' state sync procedure and it seems that the blockstore heights are not actually updated there. Also, by definition the base and height refer to the block in store and technically we do not have a block at state.LastBlockHeight. My suspicion is this is not needed as long as the operator ensures the store is empty beforehand. I am writing a test to confirm though!

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale For use by stalebot label Jun 11, 2023
@jmalicevic jmalicevic added wip Work in progress and removed stale For use by stalebot labels Jun 11, 2023
@jmalicevic jmalicevic mentioned this pull request Jun 30, 2023
3 tasks
@jmalicevic
Copy link
Collaborator

Hi @yihuang, thank you so much for all this work and I am sorry we did not get back sooner. We decided to go with your solution but feel it is safer to provide this functionality within an API that users can call, rather then giving them a separate command line to do so. I thus took over your branch, but as I don't have permission to work directly on it, I cloned it and opened a new PR: #1057 . It preserves all your commits though.

The PR is a draft as I am writing tests to verify the code works and to verify we do not need the explicit setting of base and last height in blockstore (commented out atm)

Please let me know if you see any technical problems with the proposed solution or if it is not supporting the use case you envision for this command?

@tac0turtle does this API allow you to remove the code you have copied and bootstrap the stores just by calling it?

@jmalicevic
Copy link
Collaborator

Closing at it is superceeded by #1057

@jmalicevic jmalicevic closed this Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wip Work in progress

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Add Go API support to bootstrap node after it was state synced

3 participants