diff --git a/chain/src/chain.rs b/chain/src/chain.rs index 1189ba3e2..9f6121b9b 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -544,9 +544,15 @@ impl Chain { let mut txhashset = txhashset::TxHashSet::open(self.db_root.clone(), self.store.clone(), Some(&header))?; + // validate against a read-only extension first (some of the validation + // runs additional rewinds) + txhashset::extending_readonly(&mut txhashset, |extension| { + extension.rewind(&header, &header)?; + extension.validate(&header, false, status) + })?; + // all good, prepare a new batch and update all the required records let mut batch = self.store.batch()?; - // Note: we are validating against a writeable extension. txhashset::extending(&mut txhashset, &mut batch, |extension| { // TODO do we need to rewind here? We have no blocks to rewind // (and we need them for the pos to unremove) diff --git a/chain/src/txhashset.rs b/chain/src/txhashset.rs index 4bc853dfa..cbe9166ee 100644 --- a/chain/src/txhashset.rs +++ b/chain/src/txhashset.rs @@ -911,8 +911,7 @@ impl<'a> Extension<'a> { // Verify kernel roots for all past headers, need to be last as it rewinds // a lot without resetting - // TODO broken in fast sync, fix - // self.verify_kernel_history(header)?; + self.verify_kernel_history(header)?; Ok((output_sum, kernel_sum)) } @@ -1047,7 +1046,6 @@ impl<'a> Extension<'a> { // header, rewind and check each root. This fixes a potential weakness in // fast sync where a reorg past the horizon could allow a whole rewrite of // the kernel set. - let header_head = header.clone(); let mut current = header.clone(); let empty_bitmap = Bitmap::create(); loop {