Grin: fast sync always start from 0 if quit in the middle

Created on 9 Oct 2018  路  2Comments  路  Source: mimblewimble/grin

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.

bug

Most helpful comment

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.

All 2 comments

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> {
  • The old init_sync_head() behavior is get_header_head() and use it for save_sync_head().
  • The new 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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lehnberg picture lehnberg  路  4Comments

lehnberg picture lehnberg  路  5Comments

garyyu picture garyyu  路  6Comments

antiochp picture antiochp  路  3Comments

alden-alvins picture alden-alvins  路  5Comments