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
This commit is contained in:
Ori Newman 2021-12-19 08:56:18 +02:00 committed by GitHub
parent 011871cda2
commit 1d740e1eab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 15 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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:

View File

@ -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
}

View File

@ -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