Change most Tracef to Debugf (#1302)

* Change most Tracef to Debugf

* Remove diff from log
This commit is contained in:
Ori Newman 2020-12-29 10:32:28 +02:00 committed by GitHub
parent 5f22632836
commit d91afbfe3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 140 additions and 141 deletions

View File

@ -42,11 +42,11 @@ func (f *FlowContext) OnNewBlock(block *externalapi.DomainBlock,
for i, newBlock := range newBlocks { for i, newBlock := range newBlocks {
blocklogger.LogBlock(block) blocklogger.LogBlock(block)
log.Tracef("OnNewBlock: passing block %s transactions to mining manager", hash) log.Debugf("OnNewBlock: passing block %s transactions to mining manager", hash)
_ = f.Domain().MiningManager().HandleNewBlockTransactions(newBlock.Transactions) _ = f.Domain().MiningManager().HandleNewBlockTransactions(newBlock.Transactions)
if f.onBlockAddedToDAGHandler != nil { if f.onBlockAddedToDAGHandler != nil {
log.Tracef("OnNewBlock: calling f.onBlockAddedToDAGHandler for block %s", hash) log.Debugf("OnNewBlock: calling f.onBlockAddedToDAGHandler for block %s", hash)
blockInsertionResult = newBlockInsertionResults[i] blockInsertionResult = newBlockInsertionResults[i]
err := f.onBlockAddedToDAGHandler(newBlock, blockInsertionResult) err := f.onBlockAddedToDAGHandler(newBlock, blockInsertionResult)
if err != nil { if err != nil {

View File

@ -70,7 +70,7 @@ func (f *FlowContext) UnorphanBlocks(rootBlock *externalapi.DomainBlock) ([]*Uno
orphanHash, processQueue = processQueue[0], processQueue[1:] orphanHash, processQueue = processQueue[0], processQueue[1:]
orphanBlock := f.orphans[orphanHash] orphanBlock := f.orphans[orphanHash]
log.Tracef("Considering to unorphan block %s with parents %s", log.Debugf("Considering to unorphan block %s with parents %s",
orphanHash, orphanBlock.Header.ParentHashes) orphanHash, orphanBlock.Header.ParentHashes)
canBeUnorphaned := true canBeUnorphaned := true
@ -80,7 +80,7 @@ func (f *FlowContext) UnorphanBlocks(rootBlock *externalapi.DomainBlock) ([]*Uno
return nil, err return nil, err
} }
if !orphanBlockParentInfo.Exists || orphanBlockParentInfo.BlockStatus == externalapi.StatusHeaderOnly { if !orphanBlockParentInfo.Exists || orphanBlockParentInfo.BlockStatus == externalapi.StatusHeaderOnly {
log.Tracef("Cannot unorphan block %s. It's missing at "+ log.Debugf("Cannot unorphan block %s. It's missing at "+
"least the following parent: %s", orphanHash, orphanBlockParentHash) "least the following parent: %s", orphanHash, orphanBlockParentHash)
canBeUnorphaned = false canBeUnorphaned = false

View File

@ -33,7 +33,7 @@ func (bp *blockProcessor) setBlockStatusAfterBlockValidation(block *externalapi.
return errors.Errorf("block %s that is not the pruning point is not expected to be valid "+ return errors.Errorf("block %s that is not the pruning point is not expected to be valid "+
"before adding to to the consensus state manager", blockHash) "before adding to to the consensus state manager", blockHash)
} }
log.Tracef("Block %s is the pruning point and has status %s, so leaving its status untouched", log.Debugf("Block %s is the pruning point and has status %s, so leaving its status untouched",
blockHash, status) blockHash, status)
return nil return nil
} }
@ -41,11 +41,11 @@ func (bp *blockProcessor) setBlockStatusAfterBlockValidation(block *externalapi.
isHeaderOnlyBlock := isHeaderOnlyBlock(block) isHeaderOnlyBlock := isHeaderOnlyBlock(block)
if isHeaderOnlyBlock { if isHeaderOnlyBlock {
log.Tracef("Block %s is a header-only block so setting its status as %s", log.Debugf("Block %s is a header-only block so setting its status as %s",
blockHash, externalapi.StatusHeaderOnly) blockHash, externalapi.StatusHeaderOnly)
bp.blockStatusStore.Stage(blockHash, externalapi.StatusHeaderOnly) bp.blockStatusStore.Stage(blockHash, externalapi.StatusHeaderOnly)
} else { } else {
log.Tracef("Block %s has body so setting its status as %s", log.Debugf("Block %s has body so setting its status as %s",
blockHash, externalapi.StatusUTXOPendingVerification) blockHash, externalapi.StatusUTXOPendingVerification)
bp.blockStatusStore.Stage(blockHash, externalapi.StatusUTXOPendingVerification) bp.blockStatusStore.Stage(blockHash, externalapi.StatusUTXOPendingVerification)
} }
@ -247,7 +247,7 @@ func (bp *blockProcessor) validatePostProofOfWork(block *externalapi.DomainBlock
return err return err
} }
} else { } else {
log.Tracef("Skipping ValidateBodyInContext for block %s because it's header only", blockHash) log.Debugf("Skipping ValidateBodyInContext for block %s because it's header only", blockHash)
} }
return nil return nil

View File

@ -27,10 +27,10 @@ func (bp *blockProcessor) validateBlock(block *externalapi.DomainBlock, isPrunin
} }
if !hasValidatedHeader { if !hasValidatedHeader {
log.Tracef("Staging block %s header", blockHash) log.Debugf("Staging block %s header", blockHash)
bp.blockHeaderStore.Stage(blockHash, block.Header) bp.blockHeaderStore.Stage(blockHash, block.Header)
} else { } else {
log.Tracef("Block %s header is already known, so no need to stage it", blockHash) log.Debugf("Block %s header is already known, so no need to stage it", blockHash)
} }
// If any validation until (included) proof-of-work fails, simply // If any validation until (included) proof-of-work fails, simply

View File

@ -9,10 +9,10 @@ import (
// current virtual. This process may result in a new virtual block // current virtual. This process may result in a new virtual block
// getting created // getting created
func (csm *consensusStateManager) AddBlock(blockHash *externalapi.DomainHash) (*externalapi.SelectedParentChainChanges, error) { func (csm *consensusStateManager) AddBlock(blockHash *externalapi.DomainHash) (*externalapi.SelectedParentChainChanges, error) {
log.Tracef("AddBlock start for block %s", blockHash) log.Debugf("AddBlock start for block %s", blockHash)
defer log.Tracef("AddBlock end for block %s", blockHash) defer log.Debugf("AddBlock end for block %s", blockHash)
log.Tracef("Resolving whether the block %s is the next virtual selected parent", blockHash) log.Debugf("Resolving whether the block %s is the next virtual selected parent", blockHash)
isCandidateToBeNextVirtualSelectedParent, err := csm.isCandidateToBeNextVirtualSelectedParent(blockHash) isCandidateToBeNextVirtualSelectedParent, err := csm.isCandidateToBeNextVirtualSelectedParent(blockHash)
if err != nil { if err != nil {
return nil, err return nil, err
@ -22,7 +22,7 @@ func (csm *consensusStateManager) AddBlock(blockHash *externalapi.DomainHash) (*
// It's important to check for finality violation before resolving the block status, because the status of // It's important to check for finality violation before resolving the block status, because the status of
// blocks with a selected chain that doesn't contain the pruning point cannot be resolved because they will // blocks with a selected chain that doesn't contain the pruning point cannot be resolved because they will
// eventually try to fetch UTXO diffs from the past of the pruning point. // eventually try to fetch UTXO diffs from the past of the pruning point.
log.Tracef("Block %s is candidate to be the next virtual selected parent. Resolving whether it violates "+ log.Debugf("Block %s is candidate to be the next virtual selected parent. Resolving whether it violates "+
"finality", blockHash) "finality", blockHash)
isViolatingFinality, shouldNotify, err := csm.isViolatingFinality(blockHash) isViolatingFinality, shouldNotify, err := csm.isViolatingFinality(blockHash)
if err != nil { if err != nil {
@ -35,7 +35,7 @@ func (csm *consensusStateManager) AddBlock(blockHash *externalapi.DomainHash) (*
} }
if !isViolatingFinality { if !isViolatingFinality {
log.Tracef("Block %s doesn't violate finality. Resolving its block status", blockHash) log.Debugf("Block %s doesn't violate finality. Resolving its block status", blockHash)
blockStatus, err := csm.resolveBlockStatus(blockHash) blockStatus, err := csm.resolveBlockStatus(blockHash)
if err != nil { if err != nil {
return nil, err return nil, err
@ -48,14 +48,14 @@ func (csm *consensusStateManager) AddBlock(blockHash *externalapi.DomainHash) (*
"therefore its status remains `%s`", blockHash, externalapi.StatusUTXOPendingVerification) "therefore its status remains `%s`", blockHash, externalapi.StatusUTXOPendingVerification)
} }
log.Tracef("Adding block %s to the DAG tips", blockHash) log.Debugf("Adding block %s to the DAG tips", blockHash)
newTips, err := csm.addTip(blockHash) newTips, err := csm.addTip(blockHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("After adding %s, the new tips are %s", blockHash, newTips) log.Debugf("After adding %s, the new tips are %s", blockHash, newTips)
log.Tracef("Updating the virtual with the new tips") log.Debugf("Updating the virtual with the new tips")
selectedParentChainChanges, err := csm.updateVirtual(blockHash, newTips) selectedParentChainChanges, err := csm.updateVirtual(blockHash, newTips)
if err != nil { if err != nil {
return nil, err return nil, err
@ -65,11 +65,11 @@ func (csm *consensusStateManager) AddBlock(blockHash *externalapi.DomainHash) (*
} }
func (csm *consensusStateManager) isCandidateToBeNextVirtualSelectedParent(blockHash *externalapi.DomainHash) (bool, error) { func (csm *consensusStateManager) isCandidateToBeNextVirtualSelectedParent(blockHash *externalapi.DomainHash) (bool, error) {
log.Tracef("isCandidateToBeNextVirtualSelectedParent start for block %s", blockHash) log.Debugf("isCandidateToBeNextVirtualSelectedParent start for block %s", blockHash)
defer log.Tracef("isCandidateToBeNextVirtualSelectedParent end for block %s", blockHash) defer log.Debugf("isCandidateToBeNextVirtualSelectedParent end for block %s", blockHash)
if blockHash.Equal(csm.genesisHash) { if blockHash.Equal(csm.genesisHash) {
log.Tracef("Block %s is the genesis block, therefore it is "+ log.Debugf("Block %s is the genesis block, therefore it is "+
"the selected parent by definition", blockHash) "the selected parent by definition", blockHash)
return true, nil return true, nil
} }
@ -79,40 +79,40 @@ func (csm *consensusStateManager) isCandidateToBeNextVirtualSelectedParent(block
return false, err return false, err
} }
log.Tracef("Selecting the next selected parent between "+ log.Debugf("Selecting the next selected parent between "+
"the block %s the current selected parent %s", blockHash, virtualGhostdagData.SelectedParent()) "the block %s the current selected parent %s", blockHash, virtualGhostdagData.SelectedParent())
nextVirtualSelectedParent, err := csm.ghostdagManager.ChooseSelectedParent(virtualGhostdagData.SelectedParent(), blockHash) nextVirtualSelectedParent, err := csm.ghostdagManager.ChooseSelectedParent(virtualGhostdagData.SelectedParent(), blockHash)
if err != nil { if err != nil {
return false, err return false, err
} }
log.Tracef("The next selected parent is: %s", nextVirtualSelectedParent) log.Debugf("The next selected parent is: %s", nextVirtualSelectedParent)
return blockHash.Equal(nextVirtualSelectedParent), nil return blockHash.Equal(nextVirtualSelectedParent), nil
} }
func (csm *consensusStateManager) addTip(newTipHash *externalapi.DomainHash) (newTips []*externalapi.DomainHash, err error) { func (csm *consensusStateManager) addTip(newTipHash *externalapi.DomainHash) (newTips []*externalapi.DomainHash, err error) {
log.Tracef("addTip start for new tip %s", newTipHash) log.Debugf("addTip start for new tip %s", newTipHash)
defer log.Tracef("addTip end for new tip %s", newTipHash) defer log.Debugf("addTip end for new tip %s", newTipHash)
log.Tracef("Calculating the new tips for new tip %s", newTipHash) log.Debugf("Calculating the new tips for new tip %s", newTipHash)
newTips, err = csm.calculateNewTips(newTipHash) newTips, err = csm.calculateNewTips(newTipHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("The new tips are: %s", newTips) log.Debugf("The new tips are: %s", newTips)
csm.consensusStateStore.StageTips(newTips) csm.consensusStateStore.StageTips(newTips)
log.Tracef("Staged the new tips %s", newTips) log.Debugf("Staged the new tips %s", newTips)
return newTips, nil return newTips, nil
} }
func (csm *consensusStateManager) calculateNewTips(newTipHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) { func (csm *consensusStateManager) calculateNewTips(newTipHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) {
log.Tracef("calculateNewTips start for new tip %s", newTipHash) log.Debugf("calculateNewTips start for new tip %s", newTipHash)
defer log.Tracef("calculateNewTips end for new tip %s", newTipHash) defer log.Debugf("calculateNewTips end for new tip %s", newTipHash)
if newTipHash.Equal(csm.genesisHash) { if newTipHash.Equal(csm.genesisHash) {
log.Tracef("The new tip is the genesis block, therefore it is the only tip by definition") log.Debugf("The new tip is the genesis block, therefore it is the only tip by definition")
return []*externalapi.DomainHash{newTipHash}, nil return []*externalapi.DomainHash{newTipHash}, nil
} }
@ -120,13 +120,13 @@ func (csm *consensusStateManager) calculateNewTips(newTipHash *externalapi.Domai
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("The current tips are: %s", currentTips) log.Debugf("The current tips are: %s", currentTips)
newTipParents, err := csm.dagTopologyManager.Parents(newTipHash) newTipParents, err := csm.dagTopologyManager.Parents(newTipHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("The parents of the new tip are: %s", newTipParents) log.Debugf("The parents of the new tip are: %s", newTipParents)
newTips := []*externalapi.DomainHash{newTipHash} newTips := []*externalapi.DomainHash{newTipHash}
@ -142,7 +142,7 @@ func (csm *consensusStateManager) calculateNewTips(newTipHash *externalapi.Domai
newTips = append(newTips, currentTip) newTips = append(newTips, currentTip)
} }
} }
log.Tracef("The calculated new tips are: %s", newTips) log.Debugf("The calculated new tips are: %s", newTips)
return newTips, nil return newTips, nil
} }

View File

@ -15,11 +15,11 @@ import (
func (csm *consensusStateManager) CalculatePastUTXOAndAcceptanceData(blockHash *externalapi.DomainHash) ( func (csm *consensusStateManager) CalculatePastUTXOAndAcceptanceData(blockHash *externalapi.DomainHash) (
model.UTXODiff, externalapi.AcceptanceData, model.Multiset, error) { model.UTXODiff, externalapi.AcceptanceData, model.Multiset, error) {
log.Tracef("CalculatePastUTXOAndAcceptanceData start for block %s", blockHash) log.Debugf("CalculatePastUTXOAndAcceptanceData start for block %s", blockHash)
defer log.Tracef("CalculatePastUTXOAndAcceptanceData end for block %s", blockHash) defer log.Debugf("CalculatePastUTXOAndAcceptanceData end for block %s", blockHash)
if blockHash.Equal(csm.genesisHash) { if blockHash.Equal(csm.genesisHash) {
log.Tracef("Block %s is the genesis. By definition, "+ log.Debugf("Block %s is the genesis. By definition, "+
"it has an empty UTXO diff, empty acceptance data, and a blank multiset", blockHash) "it has an empty UTXO diff, empty acceptance data, and a blank multiset", blockHash)
return utxo.NewUTXODiff(), externalapi.AcceptanceData{}, multiset.New(), nil return utxo.NewUTXODiff(), externalapi.AcceptanceData{}, multiset.New(), nil
} }
@ -29,53 +29,53 @@ func (csm *consensusStateManager) CalculatePastUTXOAndAcceptanceData(blockHash *
return nil, nil, nil, err return nil, nil, nil, err
} }
log.Tracef("Restoring the past UTXO of block %s with selectedParent %s", log.Debugf("Restoring the past UTXO of block %s with selectedParent %s",
blockHash, blockGHOSTDAGData.SelectedParent()) blockHash, blockGHOSTDAGData.SelectedParent())
selectedParentPastUTXO, err := csm.restorePastUTXO(blockGHOSTDAGData.SelectedParent()) selectedParentPastUTXO, err := csm.restorePastUTXO(blockGHOSTDAGData.SelectedParent())
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
log.Tracef("Applying blue blocks to the selected parent past UTXO of block %s", blockHash) log.Debugf("Applying blue blocks to the selected parent past UTXO of block %s", blockHash)
acceptanceData, utxoDiff, err := csm.applyMergeSetBlocks(blockHash, selectedParentPastUTXO, blockGHOSTDAGData) acceptanceData, utxoDiff, err := csm.applyMergeSetBlocks(blockHash, selectedParentPastUTXO, blockGHOSTDAGData)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
log.Tracef("Calculating the multiset of %s", blockHash) log.Debugf("Calculating the multiset of %s", blockHash)
multiset, err := csm.calculateMultiset(acceptanceData, blockGHOSTDAGData) multiset, err := csm.calculateMultiset(acceptanceData, blockGHOSTDAGData)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
log.Tracef("The multiset of block %s resolved to: %s", blockHash, multiset.Hash()) log.Debugf("The multiset of block %s resolved to: %s", blockHash, multiset.Hash())
return utxoDiff.ToImmutable(), acceptanceData, multiset, nil return utxoDiff.ToImmutable(), acceptanceData, multiset, nil
} }
func (csm *consensusStateManager) restorePastUTXO(blockHash *externalapi.DomainHash) (model.MutableUTXODiff, error) { func (csm *consensusStateManager) restorePastUTXO(blockHash *externalapi.DomainHash) (model.MutableUTXODiff, error) {
log.Tracef("restorePastUTXO start for block %s", blockHash) log.Debugf("restorePastUTXO start for block %s", blockHash)
defer log.Tracef("restorePastUTXO end for block %s", blockHash) defer log.Debugf("restorePastUTXO end for block %s", blockHash)
var err error var err error
log.Tracef("Collecting UTXO diffs for block %s", blockHash) log.Debugf("Collecting UTXO diffs for block %s", blockHash)
var utxoDiffs []model.UTXODiff var utxoDiffs []model.UTXODiff
nextBlockHash := blockHash nextBlockHash := blockHash
for { for {
log.Tracef("Collecting UTXO diff for block %s", nextBlockHash) log.Debugf("Collecting UTXO diff for block %s", nextBlockHash)
utxoDiff, err := csm.utxoDiffStore.UTXODiff(csm.databaseContext, nextBlockHash) utxoDiff, err := csm.utxoDiffStore.UTXODiff(csm.databaseContext, nextBlockHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
utxoDiffs = append(utxoDiffs, utxoDiff) utxoDiffs = append(utxoDiffs, utxoDiff)
log.Tracef("Collected UTXO diff for block %s: %s", nextBlockHash, utxoDiff) log.Debugf("Collected UTXO diff for block %s: %s", nextBlockHash, utxoDiff)
exists, err := csm.utxoDiffStore.HasUTXODiffChild(csm.databaseContext, nextBlockHash) exists, err := csm.utxoDiffStore.HasUTXODiffChild(csm.databaseContext, nextBlockHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !exists { if !exists {
log.Tracef("Block %s does not have a UTXO diff child, "+ log.Debugf("Block %s does not have a UTXO diff child, "+
"meaning we reached the virtual. Returning the collected "+ "meaning we reached the virtual. Returning the collected "+
"UTXO diffs: %s", nextBlockHash, utxoDiffs) "UTXO diffs: %s", nextBlockHash, utxoDiffs)
break break
@ -86,7 +86,7 @@ func (csm *consensusStateManager) restorePastUTXO(blockHash *externalapi.DomainH
return nil, err return nil, err
} }
if nextBlockHash == nil { if nextBlockHash == nil {
log.Tracef("Block %s does not have a UTXO diff child, "+ log.Debugf("Block %s does not have a UTXO diff child, "+
"meaning we reached the virtual. Returning the collected "+ "meaning we reached the virtual. Returning the collected "+
"UTXO diffs: %s", nextBlockHash, utxoDiffs) "UTXO diffs: %s", nextBlockHash, utxoDiffs)
break break
@ -94,7 +94,7 @@ func (csm *consensusStateManager) restorePastUTXO(blockHash *externalapi.DomainH
} }
// apply the diffs in reverse order // apply the diffs in reverse order
log.Tracef("Applying the collected UTXO diffs for block %s in reverse order", blockHash) log.Debugf("Applying the collected UTXO diffs for block %s in reverse order", blockHash)
accumulatedDiff := utxo.NewMutableUTXODiff() accumulatedDiff := utxo.NewMutableUTXODiff()
for i := len(utxoDiffs) - 1; i >= 0; i-- { for i := len(utxoDiffs) - 1; i >= 0; i-- {
err = accumulatedDiff.WithDiffInPlace(utxoDiffs[i]) err = accumulatedDiff.WithDiffInPlace(utxoDiffs[i])
@ -111,7 +111,7 @@ func (csm *consensusStateManager) applyMergeSetBlocks(blockHash *externalapi.Dom
selectedParentPastUTXODiff model.MutableUTXODiff, ghostdagData model.BlockGHOSTDAGData) ( selectedParentPastUTXODiff model.MutableUTXODiff, ghostdagData model.BlockGHOSTDAGData) (
externalapi.AcceptanceData, model.MutableUTXODiff, error) { externalapi.AcceptanceData, model.MutableUTXODiff, error) {
log.Tracef("applyMergeSetBlocks start for block %s", blockHash) log.Debugf("applyMergeSetBlocks start for block %s", blockHash)
defer log.Tracef("applyMergeSetBlocks end for block %s", blockHash) defer log.Tracef("applyMergeSetBlocks end for block %s", blockHash)
mergeSetBlocks, err := csm.blockStore.Blocks(csm.databaseContext, ghostdagData.MergeSet()) mergeSetBlocks, err := csm.blockStore.Blocks(csm.databaseContext, ghostdagData.MergeSet())

View File

@ -5,11 +5,11 @@ import "github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
func (csm *consensusStateManager) isViolatingFinality(blockHash *externalapi.DomainHash) (isViolatingFinality bool, func (csm *consensusStateManager) isViolatingFinality(blockHash *externalapi.DomainHash) (isViolatingFinality bool,
shouldSendNotification bool, err error) { shouldSendNotification bool, err error) {
log.Tracef("isViolatingFinality start for block %s", blockHash) log.Debugf("isViolatingFinality start for block %s", blockHash)
defer log.Tracef("isViolatingFinality end for block %s", blockHash) defer log.Debugf("isViolatingFinality end for block %s", blockHash)
if blockHash.Equal(csm.genesisHash) { if blockHash.Equal(csm.genesisHash) {
log.Tracef("Block %s is the genesis block, "+ log.Debugf("Block %s is the genesis block, "+
"and does not violate finality by definition", blockHash) "and does not violate finality by definition", blockHash)
return false, false, nil return false, false, nil
} }
@ -19,7 +19,7 @@ func (csm *consensusStateManager) isViolatingFinality(blockHash *externalapi.Dom
if err != nil { if err != nil {
return false, false, err return false, false, err
} }
log.Tracef("The virtual finality point is: %s", virtualFinalityPoint) log.Debugf("The virtual finality point is: %s", virtualFinalityPoint)
// There can be a situation where the virtual points close to the pruning point (or even in the past // There can be a situation where the virtual points close to the pruning point (or even in the past
// of the pruning point before calling validateAndInsertBlock for the pruning point block) and the // of the pruning point before calling validateAndInsertBlock for the pruning point block) and the
@ -30,7 +30,7 @@ func (csm *consensusStateManager) isViolatingFinality(blockHash *externalapi.Dom
if err != nil { if err != nil {
return false, false, err return false, false, err
} }
log.Tracef("The pruning point is: %s", pruningPoint) log.Debugf("The pruning point is: %s", pruningPoint)
isFinalityPointInPastOfPruningPoint, err := csm.dagTopologyManager.IsAncestorOf(virtualFinalityPoint, pruningPoint) isFinalityPointInPastOfPruningPoint, err := csm.dagTopologyManager.IsAncestorOf(virtualFinalityPoint, pruningPoint)
if err != nil { if err != nil {
@ -40,7 +40,7 @@ func (csm *consensusStateManager) isViolatingFinality(blockHash *externalapi.Dom
if !isFinalityPointInPastOfPruningPoint { if !isFinalityPointInPastOfPruningPoint {
finalityPoint = virtualFinalityPoint finalityPoint = virtualFinalityPoint
} else { } else {
log.Tracef("The virtual finality point is %s in the past of the pruning point, so finality is validated "+ log.Debugf("The virtual finality point is %s in the past of the pruning point, so finality is validated "+
"using the pruning point", virtualFinalityPoint) "using the pruning point", virtualFinalityPoint)
finalityPoint = pruningPoint finalityPoint = pruningPoint
} }
@ -60,7 +60,7 @@ func (csm *consensusStateManager) isViolatingFinality(blockHash *externalapi.Dom
// of the finality point. // of the finality point.
return true, false, nil return true, false, nil
} }
log.Tracef("Block %s does not violate finality", blockHash) log.Debugf("Block %s does not violate finality", blockHash)
return false, false, nil return false, false, nil
} }

View File

@ -12,11 +12,11 @@ import (
func (csm *consensusStateManager) calculateMultiset( func (csm *consensusStateManager) calculateMultiset(
acceptanceData externalapi.AcceptanceData, blockGHOSTDAGData model.BlockGHOSTDAGData) (model.Multiset, error) { acceptanceData externalapi.AcceptanceData, blockGHOSTDAGData model.BlockGHOSTDAGData) (model.Multiset, error) {
log.Tracef("calculateMultiset start for block with selected parent %s", blockGHOSTDAGData.SelectedParent()) log.Debugf("calculateMultiset start for block with selected parent %s", blockGHOSTDAGData.SelectedParent())
defer log.Tracef("calculateMultiset end for block with selected parent %s", blockGHOSTDAGData.SelectedParent()) defer log.Debugf("calculateMultiset end for block with selected parent %s", blockGHOSTDAGData.SelectedParent())
if blockGHOSTDAGData.SelectedParent() == nil { if blockGHOSTDAGData.SelectedParent() == nil {
log.Tracef("Selected parent is nil, which could only happen for the genesis. " + log.Debugf("Selected parent is nil, which could only happen for the genesis. " +
"The genesis, by definition, has an empty multiset") "The genesis, by definition, has an empty multiset")
return multiset.New(), nil return multiset.New(), nil
} }
@ -25,7 +25,7 @@ func (csm *consensusStateManager) calculateMultiset(
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("The multiset for the selected parent %s is: %s", blockGHOSTDAGData.SelectedParent(), ms.Hash()) log.Debugf("The multiset for the selected parent %s is: %s", blockGHOSTDAGData.SelectedParent(), ms.Hash())
for _, blockAcceptanceData := range acceptanceData { for _, blockAcceptanceData := range acceptanceData {
for i, transactionAcceptanceData := range blockAcceptanceData.TransactionAcceptanceData { for i, transactionAcceptanceData := range blockAcceptanceData.TransactionAcceptanceData {

View File

@ -9,10 +9,10 @@ import (
) )
func (csm *consensusStateManager) pickVirtualParents(tips []*externalapi.DomainHash) ([]*externalapi.DomainHash, error) { func (csm *consensusStateManager) pickVirtualParents(tips []*externalapi.DomainHash) ([]*externalapi.DomainHash, error) {
log.Tracef("pickVirtualParents start for tips: %s", tips) log.Debugf("pickVirtualParents start for tips: %s", tips)
defer log.Tracef("pickVirtualParents end for tips: %s", tips) defer log.Debugf("pickVirtualParents end for tips: %s", tips)
log.Tracef("Pushing all tips into a DownHeap") log.Debugf("Pushing all tips into a DownHeap")
candidatesHeap := csm.dagTraversalManager.NewDownHeap() candidatesHeap := csm.dagTraversalManager.NewDownHeap()
for _, tip := range tips { for _, tip := range tips {
err := candidatesHeap.Push(tip) err := candidatesHeap.Push(tip)
@ -29,7 +29,7 @@ func (csm *consensusStateManager) pickVirtualParents(tips []*externalapi.DomainH
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("The selected parent of the virtual is: %s", virtualSelectedParent) log.Debugf("The selected parent of the virtual is: %s", virtualSelectedParent)
selectedVirtualParents := hashset.NewFromSlice(virtualSelectedParent) selectedVirtualParents := hashset.NewFromSlice(virtualSelectedParent)
@ -38,17 +38,17 @@ func (csm *consensusStateManager) pickVirtualParents(tips []*externalapi.DomainH
for candidatesHeap.Len() > 0 && uint64(len(selectedVirtualParents)) < uint64(csm.maxBlockParents) { for candidatesHeap.Len() > 0 && uint64(len(selectedVirtualParents)) < uint64(csm.maxBlockParents) {
candidate := candidatesHeap.Pop() candidate := candidatesHeap.Pop()
log.Tracef("Attempting to add %s to the virtual parents", candidate) log.Debugf("Attempting to add %s to the virtual parents", candidate)
log.Tracef("The current merge set size is %d", mergeSetSize) log.Debugf("The current merge set size is %d", mergeSetSize)
mergeSetIncrease, err := csm.mergeSetIncrease(candidate, selectedVirtualParents) mergeSetIncrease, err := csm.mergeSetIncrease(candidate, selectedVirtualParents)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("The merge set would increase by %d with block %s", mergeSetIncrease, candidate) log.Debugf("The merge set would increase by %d with block %s", mergeSetIncrease, candidate)
if mergeSetSize+mergeSetIncrease > csm.mergeSetSizeLimit { if mergeSetSize+mergeSetIncrease > csm.mergeSetSizeLimit {
log.Tracef("Cannot add block %s since that would violate the merge set size limit", candidate) log.Debugf("Cannot add block %s since that would violate the merge set size limit", candidate)
continue continue
} }

View File

@ -8,39 +8,39 @@ import (
) )
func (csm *consensusStateManager) resolveBlockStatus(blockHash *externalapi.DomainHash) (externalapi.BlockStatus, error) { func (csm *consensusStateManager) resolveBlockStatus(blockHash *externalapi.DomainHash) (externalapi.BlockStatus, error) {
log.Tracef("resolveBlockStatus start for block %s", blockHash) log.Debugf("resolveBlockStatus start for block %s", blockHash)
defer log.Tracef("resolveBlockStatus end for block %s", blockHash) defer log.Debugf("resolveBlockStatus end for block %s", blockHash)
log.Tracef("Getting a list of all blocks in the selected "+ log.Debugf("Getting a list of all blocks in the selected "+
"parent chain of %s that have no yet resolved their status", blockHash) "parent chain of %s that have no yet resolved their status", blockHash)
unverifiedBlocks, err := csm.getUnverifiedChainBlocks(blockHash) unverifiedBlocks, err := csm.getUnverifiedChainBlocks(blockHash)
if err != nil { if err != nil {
return 0, err return 0, err
} }
log.Tracef("Got %d unverified blocks in the selected parent "+ log.Debugf("Got %d unverified blocks in the selected parent "+
"chain of %s: %s", len(unverifiedBlocks), blockHash, unverifiedBlocks) "chain of %s: %s", len(unverifiedBlocks), blockHash, unverifiedBlocks)
// If there's no unverified blocks in the given block's chain - this means the given block already has a // If there's no unverified blocks in the given block's chain - this means the given block already has a
// UTXO-verified status, and therefore it should be retrieved from the store and returned // UTXO-verified status, and therefore it should be retrieved from the store and returned
if len(unverifiedBlocks) == 0 { if len(unverifiedBlocks) == 0 {
log.Tracef("There are not unverified blocks in %s's selected parent chain. "+ log.Debugf("There are not unverified blocks in %s's selected parent chain. "+
"This means that the block already has a UTXO-verified status.", blockHash) "This means that the block already has a UTXO-verified status.", blockHash)
status, err := csm.blockStatusStore.Get(csm.databaseContext, blockHash) status, err := csm.blockStatusStore.Get(csm.databaseContext, blockHash)
if err != nil { if err != nil {
return 0, err return 0, err
} }
log.Tracef("Block %s's status resolved to: %s", blockHash, status) log.Debugf("Block %s's status resolved to: %s", blockHash, status)
return status, nil return status, nil
} }
log.Tracef("Finding the status of the selected parent of %s", blockHash) log.Debugf("Finding the status of the selected parent of %s", blockHash)
selectedParentStatus, err := csm.findSelectedParentStatus(unverifiedBlocks) selectedParentStatus, err := csm.findSelectedParentStatus(unverifiedBlocks)
if err != nil { if err != nil {
return 0, err return 0, err
} }
log.Tracef("The status of the selected parent of %s is: %s", blockHash, selectedParentStatus) log.Debugf("The status of the selected parent of %s is: %s", blockHash, selectedParentStatus)
log.Tracef("Resolving the unverified blocks' status in reverse order (past to present)") log.Debugf("Resolving the unverified blocks' status in reverse order (past to present)")
var blockStatus externalapi.BlockStatus var blockStatus externalapi.BlockStatus
for i := len(unverifiedBlocks) - 1; i >= 0; i-- { for i := len(unverifiedBlocks) - 1; i >= 0; i-- {
unverifiedBlockHash := unverifiedBlocks[i] unverifiedBlockHash := unverifiedBlocks[i]
@ -66,12 +66,12 @@ func (csm *consensusStateManager) resolveBlockStatus(blockHash *externalapi.Doma
func (csm *consensusStateManager) findSelectedParentStatus(unverifiedBlocks []*externalapi.DomainHash) ( func (csm *consensusStateManager) findSelectedParentStatus(unverifiedBlocks []*externalapi.DomainHash) (
externalapi.BlockStatus, error) { externalapi.BlockStatus, error) {
log.Tracef("findSelectedParentStatus start") log.Debugf("findSelectedParentStatus start")
defer log.Tracef("findSelectedParentStatus end") defer log.Debugf("findSelectedParentStatus end")
lastUnverifiedBlock := unverifiedBlocks[len(unverifiedBlocks)-1] lastUnverifiedBlock := unverifiedBlocks[len(unverifiedBlocks)-1]
if lastUnverifiedBlock.Equal(csm.genesisHash) { if lastUnverifiedBlock.Equal(csm.genesisHash) {
log.Tracef("the most recent unverified block is the genesis block, "+ log.Debugf("the most recent unverified block is the genesis block, "+
"which by definition has status: %s", externalapi.StatusUTXOValid) "which by definition has status: %s", externalapi.StatusUTXOValid)
return externalapi.StatusUTXOValid, nil return externalapi.StatusUTXOValid, nil
} }
@ -85,24 +85,24 @@ func (csm *consensusStateManager) findSelectedParentStatus(unverifiedBlocks []*e
func (csm *consensusStateManager) getUnverifiedChainBlocks( func (csm *consensusStateManager) getUnverifiedChainBlocks(
blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) { blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) {
log.Tracef("getUnverifiedChainBlocks start for block %s", blockHash) log.Debugf("getUnverifiedChainBlocks start for block %s", blockHash)
defer log.Tracef("getUnverifiedChainBlocks end for block %s", blockHash) defer log.Debugf("getUnverifiedChainBlocks end for block %s", blockHash)
var unverifiedBlocks []*externalapi.DomainHash var unverifiedBlocks []*externalapi.DomainHash
currentHash := blockHash currentHash := blockHash
for { for {
log.Tracef("Getting status for block %s", currentHash) log.Debugf("Getting status for block %s", currentHash)
currentBlockStatus, err := csm.blockStatusStore.Get(csm.databaseContext, currentHash) currentBlockStatus, err := csm.blockStatusStore.Get(csm.databaseContext, currentHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if currentBlockStatus != externalapi.StatusUTXOPendingVerification { if currentBlockStatus != externalapi.StatusUTXOPendingVerification {
log.Tracef("Block %s has status %s. Returning all the "+ log.Debugf("Block %s has status %s. Returning all the "+
"unverified blocks prior to it: %s", currentHash, currentBlockStatus, unverifiedBlocks) "unverified blocks prior to it: %s", currentHash, currentBlockStatus, unverifiedBlocks)
return unverifiedBlocks, nil return unverifiedBlocks, nil
} }
log.Tracef("Block %s is unverified. Adding it to the unverified block collection", currentHash) log.Debugf("Block %s is unverified. Adding it to the unverified block collection", currentHash)
unverifiedBlocks = append(unverifiedBlocks, currentHash) unverifiedBlocks = append(unverifiedBlocks, currentHash)
currentBlockGHOSTDAGData, err := csm.ghostdagDataStore.Get(csm.databaseContext, currentHash) currentBlockGHOSTDAGData, err := csm.ghostdagDataStore.Get(csm.databaseContext, currentHash)
@ -111,7 +111,7 @@ func (csm *consensusStateManager) getUnverifiedChainBlocks(
} }
if currentBlockGHOSTDAGData.SelectedParent() == nil { if currentBlockGHOSTDAGData.SelectedParent() == nil {
log.Tracef("Genesis block reached. Returning all the "+ log.Debugf("Genesis block reached. Returning all the "+
"unverified blocks prior to it: %s", unverifiedBlocks) "unverified blocks prior to it: %s", unverifiedBlocks)
return unverifiedBlocks, nil return unverifiedBlocks, nil
} }
@ -121,7 +121,7 @@ func (csm *consensusStateManager) getUnverifiedChainBlocks(
} }
func (csm *consensusStateManager) resolveSingleBlockStatus(blockHash *externalapi.DomainHash) (externalapi.BlockStatus, error) { func (csm *consensusStateManager) resolveSingleBlockStatus(blockHash *externalapi.DomainHash) (externalapi.BlockStatus, error) {
log.Tracef("resolveSingleBlockStatus start for block %s", blockHash) log.Debugf("resolveSingleBlockStatus start for block %s", blockHash)
defer log.Tracef("resolveSingleBlockStatus end for block %s", blockHash) defer log.Tracef("resolveSingleBlockStatus end for block %s", blockHash)
log.Tracef("Calculating pastUTXO and acceptance data and multiset for block %s", blockHash) log.Tracef("Calculating pastUTXO and acceptance data and multiset for block %s", blockHash)

View File

@ -27,8 +27,8 @@ func (csm *consensusStateManager) UpdatePruningPoint(newPruningPoint *externalap
} }
func (csm *consensusStateManager) updatePruningPoint(newPruningPoint *externalapi.DomainBlock, serializedUTXOSet []byte) error { func (csm *consensusStateManager) updatePruningPoint(newPruningPoint *externalapi.DomainBlock, serializedUTXOSet []byte) error {
log.Tracef("updatePruningPoint start") log.Debugf("updatePruningPoint start")
defer log.Tracef("updatePruningPoint end") defer log.Debugf("updatePruningPoint end")
newPruningPointHash := consensushashing.BlockHash(newPruningPoint) newPruningPointHash := consensushashing.BlockHash(newPruningPoint)

View File

@ -8,10 +8,10 @@ import (
func (csm *consensusStateManager) updateVirtual(newBlockHash *externalapi.DomainHash, func (csm *consensusStateManager) updateVirtual(newBlockHash *externalapi.DomainHash,
tips []*externalapi.DomainHash) (*externalapi.SelectedParentChainChanges, error) { tips []*externalapi.DomainHash) (*externalapi.SelectedParentChainChanges, error) {
log.Tracef("updateVirtual start for block %s", newBlockHash) log.Debugf("updateVirtual start for block %s", newBlockHash)
defer log.Tracef("updateVirtual end for block %s", newBlockHash) defer log.Debugf("updateVirtual end for block %s", newBlockHash)
log.Tracef("Saving a reference to the GHOSTDAG data of the old virtual") log.Debugf("Saving a reference to the GHOSTDAG data of the old virtual")
var oldVirtualSelectedParent *externalapi.DomainHash var oldVirtualSelectedParent *externalapi.DomainHash
if !newBlockHash.Equal(csm.genesisHash) { if !newBlockHash.Equal(csm.genesisHash) {
oldVirtualGHOSTDAGData, err := csm.ghostdagDataStore.Get(csm.databaseContext, model.VirtualBlockHash) oldVirtualGHOSTDAGData, err := csm.ghostdagDataStore.Get(csm.databaseContext, model.VirtualBlockHash)
@ -21,49 +21,49 @@ func (csm *consensusStateManager) updateVirtual(newBlockHash *externalapi.Domain
oldVirtualSelectedParent = oldVirtualGHOSTDAGData.SelectedParent() oldVirtualSelectedParent = oldVirtualGHOSTDAGData.SelectedParent()
} }
log.Tracef("Picking virtual parents from the tips: %s", tips) log.Debugf("Picking virtual parents from the tips: %s", tips)
virtualParents, err := csm.pickVirtualParents(tips) virtualParents, err := csm.pickVirtualParents(tips)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("Picked virtual parents: %s", virtualParents) log.Debugf("Picked virtual parents: %s", virtualParents)
err = csm.dagTopologyManager.SetParents(model.VirtualBlockHash, virtualParents) err = csm.dagTopologyManager.SetParents(model.VirtualBlockHash, virtualParents)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("Set new parents for the virtual block hash") log.Debugf("Set new parents for the virtual block hash")
err = csm.ghostdagManager.GHOSTDAG(model.VirtualBlockHash) err = csm.ghostdagManager.GHOSTDAG(model.VirtualBlockHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("Calculating past UTXO, acceptance data, and multiset for the new virtual block") log.Debugf("Calculating past UTXO, acceptance data, and multiset for the new virtual block")
virtualUTXODiff, virtualAcceptanceData, virtualMultiset, err := csm.CalculatePastUTXOAndAcceptanceData(model.VirtualBlockHash) virtualUTXODiff, virtualAcceptanceData, virtualMultiset, err := csm.CalculatePastUTXOAndAcceptanceData(model.VirtualBlockHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("Staging new acceptance data for the virtual block") log.Debugf("Staging new acceptance data for the virtual block")
csm.acceptanceDataStore.Stage(model.VirtualBlockHash, virtualAcceptanceData) csm.acceptanceDataStore.Stage(model.VirtualBlockHash, virtualAcceptanceData)
log.Tracef("Staging new multiset for the virtual block") log.Debugf("Staging new multiset for the virtual block")
csm.multisetStore.Stage(model.VirtualBlockHash, virtualMultiset) csm.multisetStore.Stage(model.VirtualBlockHash, virtualMultiset)
log.Tracef("Staging new UTXO diff for the virtual block") log.Debugf("Staging new UTXO diff for the virtual block")
err = csm.consensusStateStore.StageVirtualUTXODiff(virtualUTXODiff) err = csm.consensusStateStore.StageVirtualUTXODiff(virtualUTXODiff)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("Updating the virtual diff parents after adding %s to the DAG", newBlockHash) log.Debugf("Updating the virtual diff parents after adding %s to the DAG", newBlockHash)
err = csm.updateVirtualDiffParents(virtualUTXODiff) err = csm.updateVirtualDiffParents(virtualUTXODiff)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("Calculating selected parent chain changes") log.Debugf("Calculating selected parent chain changes")
var selectedParentChainChanges *externalapi.SelectedParentChainChanges var selectedParentChainChanges *externalapi.SelectedParentChainChanges
if !newBlockHash.Equal(csm.genesisHash) { if !newBlockHash.Equal(csm.genesisHash) {
newVirtualGHOSTDAGData, err := csm.ghostdagDataStore.Get(csm.databaseContext, model.VirtualBlockHash) newVirtualGHOSTDAGData, err := csm.ghostdagDataStore.Get(csm.databaseContext, model.VirtualBlockHash)
@ -81,8 +81,8 @@ func (csm *consensusStateManager) updateVirtual(newBlockHash *externalapi.Domain
} }
func (csm *consensusStateManager) updateVirtualDiffParents(virtualUTXODiff model.UTXODiff) error { func (csm *consensusStateManager) updateVirtualDiffParents(virtualUTXODiff model.UTXODiff) error {
log.Tracef("updateVirtualDiffParents start") log.Debugf("updateVirtualDiffParents start")
defer log.Tracef("updateVirtualDiffParents end") defer log.Debugf("updateVirtualDiffParents end")
virtualDiffParents, err := csm.consensusStateStore.VirtualDiffParents(csm.databaseContext) virtualDiffParents, err := csm.consensusStateStore.VirtualDiffParents(csm.databaseContext)
if err != nil { if err != nil {
@ -90,7 +90,7 @@ func (csm *consensusStateManager) updateVirtualDiffParents(virtualUTXODiff model
} }
for _, virtualDiffParent := range virtualDiffParents { for _, virtualDiffParent := range virtualDiffParents {
log.Tracef("Calculating new UTXO diff for virtual diff parent %s", virtualDiffParent) log.Debugf("Calculating new UTXO diff for virtual diff parent %s", virtualDiffParent)
virtualDiffParentUTXODiff, err := csm.utxoDiffStore.UTXODiff(csm.databaseContext, virtualDiffParent) virtualDiffParentUTXODiff, err := csm.utxoDiffStore.UTXODiff(csm.databaseContext, virtualDiffParent)
if err != nil { if err != nil {
return err return err
@ -100,7 +100,7 @@ func (csm *consensusStateManager) updateVirtualDiffParents(virtualUTXODiff model
return err return err
} }
log.Tracef("Staging new UTXO diff for virtual diff parent %s: %s", virtualDiffParent, newDiff) log.Debugf("Staging new UTXO diff for virtual diff parent %s", virtualDiffParent)
err = csm.stageDiff(virtualDiffParent, newDiff, nil) err = csm.stageDiff(virtualDiffParent, newDiff, nil)
if err != nil { if err != nil {
return err return err

View File

@ -9,24 +9,24 @@ import (
func (csm *consensusStateManager) stageDiff(blockHash *externalapi.DomainHash, func (csm *consensusStateManager) stageDiff(blockHash *externalapi.DomainHash,
utxoDiff model.UTXODiff, utxoDiffChild *externalapi.DomainHash) error { utxoDiff model.UTXODiff, utxoDiffChild *externalapi.DomainHash) error {
log.Tracef("stageDiff start for block %s", blockHash) log.Debugf("stageDiff start for block %s", blockHash)
defer log.Tracef("stageDiff end for block %s", blockHash) defer log.Debugf("stageDiff end for block %s", blockHash)
log.Tracef("Staging block %s as the diff child of %s", utxoDiffChild, blockHash) log.Debugf("Staging block %s as the diff child of %s", utxoDiffChild, blockHash)
csm.utxoDiffStore.Stage(blockHash, utxoDiff, utxoDiffChild) csm.utxoDiffStore.Stage(blockHash, utxoDiff, utxoDiffChild)
if utxoDiffChild == nil { if utxoDiffChild == nil {
log.Tracef("Adding block %s to the virtual diff parents", blockHash) log.Debugf("Adding block %s to the virtual diff parents", blockHash)
return csm.addToVirtualDiffParents(blockHash) return csm.addToVirtualDiffParents(blockHash)
} }
log.Tracef("Removing block %s from the virtual diff parents", blockHash) log.Debugf("Removing block %s from the virtual diff parents", blockHash)
return csm.removeFromVirtualDiffParents(blockHash) return csm.removeFromVirtualDiffParents(blockHash)
} }
func (csm *consensusStateManager) addToVirtualDiffParents(blockHash *externalapi.DomainHash) error { func (csm *consensusStateManager) addToVirtualDiffParents(blockHash *externalapi.DomainHash) error {
log.Tracef("addToVirtualDiffParents start for block %s", blockHash) log.Debugf("addToVirtualDiffParents start for block %s", blockHash)
defer log.Tracef("addToVirtualDiffParents end for block %s", blockHash) defer log.Debugf("addToVirtualDiffParents end for block %s", blockHash)
var oldVirtualDiffParents []*externalapi.DomainHash var oldVirtualDiffParents []*externalapi.DomainHash
if !blockHash.Equal(csm.genesisHash) { if !blockHash.Equal(csm.genesisHash) {
@ -46,19 +46,19 @@ func (csm *consensusStateManager) addToVirtualDiffParents(blockHash *externalapi
} }
if isInVirtualDiffParents { if isInVirtualDiffParents {
log.Tracef("Block %s is already a virtual diff parent, so there's no need to add it", blockHash) log.Debugf("Block %s is already a virtual diff parent, so there's no need to add it", blockHash)
return nil return nil
} }
newVirtualDiffParents := append([]*externalapi.DomainHash{blockHash}, oldVirtualDiffParents...) newVirtualDiffParents := append([]*externalapi.DomainHash{blockHash}, oldVirtualDiffParents...)
log.Tracef("Staging virtual diff parents after adding %s to it", blockHash) log.Debugf("Staging virtual diff parents after adding %s to it", blockHash)
csm.consensusStateStore.StageVirtualDiffParents(newVirtualDiffParents) csm.consensusStateStore.StageVirtualDiffParents(newVirtualDiffParents)
return nil return nil
} }
func (csm *consensusStateManager) removeFromVirtualDiffParents(blockHash *externalapi.DomainHash) error { func (csm *consensusStateManager) removeFromVirtualDiffParents(blockHash *externalapi.DomainHash) error {
log.Tracef("removeFromVirtualDiffParents start for block %s", blockHash) log.Debugf("removeFromVirtualDiffParents start for block %s", blockHash)
defer log.Tracef("removeFromVirtualDiffParents end for block %s", blockHash) defer log.Debugf("removeFromVirtualDiffParents end for block %s", blockHash)
oldVirtualDiffParents, err := csm.consensusStateStore.VirtualDiffParents(csm.databaseContext) oldVirtualDiffParents, err := csm.consensusStateStore.VirtualDiffParents(csm.databaseContext)
if err != nil { if err != nil {
@ -77,7 +77,7 @@ func (csm *consensusStateManager) removeFromVirtualDiffParents(blockHash *extern
"have a length of %d but got length of %d", len(oldVirtualDiffParents)-1, len(newVirtualDiffParents)) "have a length of %d but got length of %d", len(oldVirtualDiffParents)-1, len(newVirtualDiffParents))
} }
log.Tracef("Staging virtual diff parents after removing %s from it", blockHash) log.Debugf("Staging virtual diff parents after removing %s from it", blockHash)
csm.consensusStateStore.StageVirtualDiffParents(newVirtualDiffParents) csm.consensusStateStore.StageVirtualDiffParents(newVirtualDiffParents)
return nil return nil
} }

View File

@ -20,33 +20,33 @@ import (
func (csm *consensusStateManager) verifyUTXO(block *externalapi.DomainBlock, blockHash *externalapi.DomainHash, func (csm *consensusStateManager) verifyUTXO(block *externalapi.DomainBlock, blockHash *externalapi.DomainHash,
pastUTXODiff model.UTXODiff, acceptanceData externalapi.AcceptanceData, multiset model.Multiset) error { pastUTXODiff model.UTXODiff, acceptanceData externalapi.AcceptanceData, multiset model.Multiset) error {
log.Tracef("verifyUTXO start for block %s", blockHash) log.Debugf("verifyUTXO start for block %s", blockHash)
defer log.Tracef("verifyUTXO end for block %s", blockHash) defer log.Debugf("verifyUTXO end for block %s", blockHash)
log.Tracef("Validating UTXO commitment for block %s", blockHash) log.Debugf("Validating UTXO commitment for block %s", blockHash)
err := csm.validateUTXOCommitment(block, blockHash, multiset) err := csm.validateUTXOCommitment(block, blockHash, multiset)
if err != nil { if err != nil {
return err return err
} }
log.Tracef("UTXO commitment validation passed for block %s", blockHash) log.Debugf("UTXO commitment validation passed for block %s", blockHash)
log.Tracef("Validating acceptedIDMerkleRoot for block %s", blockHash) log.Debugf("Validating acceptedIDMerkleRoot for block %s", blockHash)
err = csm.validateAcceptedIDMerkleRoot(block, blockHash, acceptanceData) err = csm.validateAcceptedIDMerkleRoot(block, blockHash, acceptanceData)
if err != nil { if err != nil {
return err return err
} }
log.Tracef("AcceptedIDMerkleRoot validation passed for block %s", blockHash) log.Debugf("AcceptedIDMerkleRoot validation passed for block %s", blockHash)
coinbaseTransaction := block.Transactions[0] coinbaseTransaction := block.Transactions[0]
log.Tracef("Validating coinbase transaction %s for block %s", log.Debugf("Validating coinbase transaction %s for block %s",
consensushashing.TransactionID(coinbaseTransaction), blockHash) consensushashing.TransactionID(coinbaseTransaction), blockHash)
err = csm.validateCoinbaseTransaction(blockHash, coinbaseTransaction) err = csm.validateCoinbaseTransaction(blockHash, coinbaseTransaction)
if err != nil { if err != nil {
return err return err
} }
log.Tracef("Coinbase transaction validation passed for block %s", blockHash) log.Debugf("Coinbase transaction validation passed for block %s", blockHash)
log.Tracef("Validating transactions against past UTXO for block %s", blockHash) log.Debugf("Validating transactions against past UTXO for block %s", blockHash)
err = csm.validateBlockTransactionsAgainstPastUTXO(block, pastUTXODiff) err = csm.validateBlockTransactionsAgainstPastUTXO(block, pastUTXODiff)
if err != nil { if err != nil {
return err return err

View File

@ -36,27 +36,27 @@ func New(databaseContext model.DBReader,
} }
func (fm *finalityManager) VirtualFinalityPoint() (*externalapi.DomainHash, error) { func (fm *finalityManager) VirtualFinalityPoint() (*externalapi.DomainHash, error) {
log.Tracef("virtualFinalityPoint start") log.Debugf("virtualFinalityPoint start")
defer log.Tracef("virtualFinalityPoint end") defer log.Debugf("virtualFinalityPoint end")
virtualFinalityPoint, err := fm.calculateFinalityPoint(model.VirtualBlockHash) virtualFinalityPoint, err := fm.calculateFinalityPoint(model.VirtualBlockHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Tracef("The current virtual finality block is: %s", virtualFinalityPoint) log.Debugf("The current virtual finality block is: %s", virtualFinalityPoint)
return virtualFinalityPoint, nil return virtualFinalityPoint, nil
} }
func (fm *finalityManager) FinalityPoint(blockHash *externalapi.DomainHash) (*externalapi.DomainHash, error) { func (fm *finalityManager) FinalityPoint(blockHash *externalapi.DomainHash) (*externalapi.DomainHash, error) {
log.Tracef("FinalityPoint start") log.Debugf("FinalityPoint start")
defer log.Tracef("FinalityPoint end") defer log.Debugf("FinalityPoint end")
if blockHash.Equal(model.VirtualBlockHash) { if blockHash.Equal(model.VirtualBlockHash) {
return fm.VirtualFinalityPoint() return fm.VirtualFinalityPoint()
} }
finalityPoint, err := fm.finalityStore.FinalityPoint(fm.databaseContext, blockHash) finalityPoint, err := fm.finalityStore.FinalityPoint(fm.databaseContext, blockHash)
if err != nil { if err != nil {
log.Tracef("%s finality point not found in store - calculating", blockHash) log.Debugf("%s finality point not found in store - calculating", blockHash)
if errors.Is(err, database.ErrNotFound) { if errors.Is(err, database.ErrNotFound) {
return fm.calculateAndStageFinalityPoint(blockHash) return fm.calculateAndStageFinalityPoint(blockHash)
} }
@ -75,15 +75,15 @@ func (fm *finalityManager) calculateAndStageFinalityPoint(blockHash *externalapi
} }
func (fm *finalityManager) calculateFinalityPoint(blockHash *externalapi.DomainHash) (*externalapi.DomainHash, error) { func (fm *finalityManager) calculateFinalityPoint(blockHash *externalapi.DomainHash) (*externalapi.DomainHash, error) {
log.Tracef("calculateFinalityPoint start") log.Debugf("calculateFinalityPoint start")
defer log.Tracef("calculateFinalityPoint end") defer log.Debugf("calculateFinalityPoint end")
ghostdagData, err := fm.ghostdagDataStore.Get(fm.databaseContext, blockHash) ghostdagData, err := fm.ghostdagDataStore.Get(fm.databaseContext, blockHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if ghostdagData.BlueScore() < fm.finalityDepth { if ghostdagData.BlueScore() < fm.finalityDepth {
log.Tracef("%s blue score lower then finality depth - returning genesis as finality point", blockHash) log.Debugf("%s blue score lower then finality depth - returning genesis as finality point", blockHash)
return fm.genesisHash, nil return fm.genesisHash, nil
} }
@ -97,7 +97,7 @@ func (fm *finalityManager) calculateFinalityPoint(blockHash *externalapi.DomainH
return nil, err return nil, err
} }
requiredBlueScore := ghostdagData.BlueScore() - fm.finalityDepth requiredBlueScore := ghostdagData.BlueScore() - fm.finalityDepth
log.Tracef("%s's finality point is the one having the highest blue score lower then %d", blockHash, requiredBlueScore) log.Debugf("%s's finality point is the one having the highest blue score lower then %d", blockHash, requiredBlueScore)
var next *externalapi.DomainHash var next *externalapi.DomainHash
for { for {
@ -110,7 +110,7 @@ func (fm *finalityManager) calculateFinalityPoint(blockHash *externalapi.DomainH
return nil, err return nil, err
} }
if nextGHOSTDAGData.BlueScore() >= requiredBlueScore { if nextGHOSTDAGData.BlueScore() >= requiredBlueScore {
log.Tracef("%s's finality point is %s", blockHash, current) log.Debugf("%s's finality point is %s", blockHash, current)
return current, nil return current, nil
} }

View File

@ -1,15 +1,14 @@
package grpcserver package grpcserver
import ( import (
"github.com/davecgh/go-spew/spew"
"github.com/kaspanet/kaspad/infrastructure/logger"
"io" "io"
"time" "time"
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/davecgh/go-spew/spew"
"github.com/kaspanet/kaspad/infrastructure/logger"
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/server/grpcserver/protowire" "github.com/kaspanet/kaspad/infrastructure/network/netadapter/server/grpcserver/protowire"
) )