From 1d740e1eabe4ca1584003819cb939939416ff7ce Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Sun, 19 Dec 2021 08:56:18 +0200 Subject: [PATCH] UTXO index fix (#1891) * Update to version v0.11.8 * Call OnPruningPointUTXOSetOverride after committing the staging consensus * use domain.Consensus() in utxo index so it'll always check the right consensus --- app/component_manager.go | 2 +- .../flows/blockrelay/ibd_with_headers_proof.go | 10 +++++----- changelog.txt | 9 +++++++++ domain/utxoindex/utxoindex.go | 17 +++++++++-------- version/version.go | 2 +- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/component_manager.go b/app/component_manager.go index 20de1f530..b288bd487 100644 --- a/app/component_manager.go +++ b/app/component_manager.go @@ -102,7 +102,7 @@ func NewComponentManager(cfg *config.Config, db infrastructuredatabase.Database, var utxoIndex *utxoindex.UTXOIndex if cfg.UTXOIndex { - utxoIndex, err = utxoindex.New(domain.Consensus(), db) + utxoIndex, err = utxoindex.New(domain, db) if err != nil { return nil, err } diff --git a/app/protocol/flows/blockrelay/ibd_with_headers_proof.go b/app/protocol/flows/blockrelay/ibd_with_headers_proof.go index 732ce2b2c..97a1a1d9e 100644 --- a/app/protocol/flows/blockrelay/ibd_with_headers_proof.go +++ b/app/protocol/flows/blockrelay/ibd_with_headers_proof.go @@ -36,6 +36,11 @@ func (flow *handleRelayInvsFlow) ibdWithHeadersProof(highHash *externalapi.Domai return err } + err = flow.OnPruningPointUTXOSetOverride() + if err != nil { + return err + } + return nil } @@ -355,10 +360,5 @@ func (flow *handleRelayInvsFlow) fetchMissingUTXOSet(consensus externalapi.Conse return false, protocolerrors.ConvertToBanningProtocolErrorIfRuleError(err, "error with pruning point UTXO set") } - err = flow.OnPruningPointUTXOSetOverride() - if err != nil { - return false, err - } - return true, nil } diff --git a/changelog.txt b/changelog.txt index fca0e105f..cbc3d1bda 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,12 @@ +Kaspad v0.11.8 - 2021-12-13 +=========================== +Bug fixes: +* Update reindex root for each block level (#1881) + +Non-breaking changes: +* Update readme (#1848) +* Lower devnet's initial difficulty (#1869) + Kaspad v0.11.7 - 2021-12-11 =========================== Breaking changes: diff --git a/domain/utxoindex/utxoindex.go b/domain/utxoindex/utxoindex.go index 605cd7f1b..13e4d3b3d 100644 --- a/domain/utxoindex/utxoindex.go +++ b/domain/utxoindex/utxoindex.go @@ -1,6 +1,7 @@ package utxoindex import ( + "github.com/kaspanet/kaspad/domain" "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" "github.com/kaspanet/kaspad/infrastructure/db/database" "github.com/kaspanet/kaspad/infrastructure/logger" @@ -10,8 +11,8 @@ import ( // UTXOIndex maintains an index between transaction scriptPublicKeys // and UTXOs type UTXOIndex struct { - consensus externalapi.Consensus - store *utxoIndexStore + domain domain.Domain + store *utxoIndexStore mutex sync.Mutex } @@ -19,10 +20,10 @@ type UTXOIndex struct { // New creates a new UTXO index. // // NOTE: While this is called no new blocks can be added to the consensus. -func New(consensus externalapi.Consensus, database database.Database) (*UTXOIndex, error) { +func New(domain domain.Domain, database database.Database) (*UTXOIndex, error) { utxoIndex := &UTXOIndex{ - consensus: consensus, - store: newUTXOIndexStore(database), + domain: domain, + store: newUTXOIndexStore(database), } isSynced, err := utxoIndex.isSynced() @@ -47,7 +48,7 @@ func (ui *UTXOIndex) Reset() error { return err } - virtualInfo, err := ui.consensus.GetVirtualInfo() + virtualInfo, err := ui.domain.Consensus().GetVirtualInfo() if err != nil { return err } @@ -55,7 +56,7 @@ func (ui *UTXOIndex) Reset() error { var fromOutpoint *externalapi.DomainOutpoint for { const step = 1000 - virtualUTXOs, err := ui.consensus.GetVirtualUTXOs(virtualInfo.ParentHashes, fromOutpoint, step) + virtualUTXOs, err := ui.domain.Consensus().GetVirtualUTXOs(virtualInfo.ParentHashes, fromOutpoint, step) if err != nil { return err } @@ -85,7 +86,7 @@ func (ui *UTXOIndex) isSynced() (bool, error) { return false, err } - virtualInfo, err := ui.consensus.GetVirtualInfo() + virtualInfo, err := ui.domain.Consensus().GetVirtualInfo() if err != nil { return false, err } diff --git a/version/version.go b/version/version.go index a946afaee..97bc4e3b5 100644 --- a/version/version.go +++ b/version/version.go @@ -11,7 +11,7 @@ const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs const ( appMajor uint = 0 appMinor uint = 11 - appPatch uint = 7 + appPatch uint = 8 ) // appBuild is defined as a variable so it can be overridden during the build