I use latest master branch and if I quit during a sync (for example the txhashset downloading stage), next time when run it again, it will always start from the Header sync, exactly from 0 height.
Looks like a regression bug.
The root cause is the change of https://github.com/mimblewimble/grin/pull/1624/files
chain/src/chain.rs
- batch.init_sync_head(&head)?;
+ batch.reset_head()?;
batch.commit()?;
chain/src/store.rs
- pub fn init_sync_head(&self, t: &Tip) -> Result<(), Error> {
- let header_tip = match self.store.get_header_head() {
- Ok(hh) => hh,
- Err(store::Error::NotFoundErr(_)) => {
- self.save_header_head(t)?;
- t.clone()
- }
- Err(e) => return Err(e),
- };
- self.save_sync_head(&header_tip)
- }
...
// Reset both header_head and sync_head to the current head of the body chain
pub fn reset_head(&self) -> Result<(), Error> {
init_sync_head() behavior is get_header_head() and use it for save_sync_head().reset_head() behavior is Reset both header_head and sync_head to the current head of the body chain, that's why fast sync step 1/2/3 will be discarded if exit.Question to @antiochp , can we revert setup_head() function to the old behavior "get_header_head() and use it for save_sync_head()" ? It's only used for Chain::init().
I think we can, but not 100% sure.
I think we can simply change batch.reset_head()?; to batch.reset_sync_head()? in setup_head() and this will do what you want.
Let me test it out locally.
Most helpful comment
I think we can, but not 100% sure.
I think we can simply change
batch.reset_head()?;tobatch.reset_sync_head()?insetup_head()and this will do what you want.Let me test it out locally.