diff --git a/app/protocol/flows/v5/blockrelay/ibd.go b/app/protocol/flows/v5/blockrelay/ibd.go index fd5fcdcca..f8130f33b 100644 --- a/app/protocol/flows/v5/blockrelay/ibd.go +++ b/app/protocol/flows/v5/blockrelay/ibd.go @@ -618,6 +618,12 @@ func (flow *handleIBDFlow) syncMissingBlockBodies(highHash *externalapi.DomainHa progressReporter := newIBDProgressReporter(lowBlockHeader.DAAScore(), highBlockHeader.DAAScore(), "blocks") highestProcessedDAAScore := lowBlockHeader.DAAScore() + // If the IBD is small, we want to update the virtual after each block in order to avoid complications and possible bugs. + updateVirtual, err := flow.Domain().Consensus().IsNearlySynced() + if err != nil { + return err + } + for offset := 0; offset < len(hashes); offset += ibdBatchSize { var hashesToRequest []*externalapi.DomainHash if offset+ibdBatchSize < len(hashes) { @@ -654,7 +660,7 @@ func (flow *handleIBDFlow) syncMissingBlockBodies(highHash *externalapi.DomainHa return err } - err = flow.Domain().Consensus().ValidateAndInsertBlock(block, false) + err = flow.Domain().Consensus().ValidateAndInsertBlock(block, updateVirtual) if err != nil { if errors.Is(err, ruleerrors.ErrDuplicateBlock) { log.Debugf("Skipping IBD Block %s as it has already been added to the DAG", blockHash) @@ -673,7 +679,15 @@ func (flow *handleIBDFlow) syncMissingBlockBodies(highHash *externalapi.DomainHa progressReporter.reportProgress(len(hashesToRequest), highestProcessedDAAScore) } - return flow.resolveVirtual(highestProcessedDAAScore) + // We need to resolve virtual only if it wasn't updated while syncing block bodies + if !updateVirtual { + err := flow.resolveVirtual(highestProcessedDAAScore) + if err != nil { + return err + } + } + + return flow.OnNewBlockTemplate() } func (flow *handleIBDFlow) banIfBlockIsHeaderOnly(block *externalapi.DomainBlock) error { @@ -705,9 +719,5 @@ func (flow *handleIBDFlow) resolveVirtual(estimatedVirtualDAAScoreTarget uint64) } log.Infof("Resolved virtual") - err = flow.OnNewBlockTemplate() - if err != nil { - return err - } return nil } diff --git a/version/version.go b/version/version.go index 16ad2c592..cd27ef67d 100644 --- a/version/version.go +++ b/version/version.go @@ -11,7 +11,7 @@ const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs const ( appMajor uint = 0 appMinor uint = 12 - appPatch uint = 5 + appPatch uint = 6 ) // appBuild is defined as a variable so it can be overridden during the build