Decrement estimatedHeaderUpperBound from mempool's MaxBlockMass (#2009)

This commit is contained in:
Ori Newman 2022-04-06 21:53:00 +03:00 committed by GitHub
parent a4669f3fb5
commit 99bb21c512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -567,7 +567,7 @@ func (flow *handleIBDFlow) receiveAndInsertPruningPointUTXOSet(
receivedChunkCount++
if receivedChunkCount%ibdBatchSize == 0 {
log.Debugf("Received %d UTXO set chunks so far, totaling in %d UTXOs",
log.Infof("Received %d UTXO set chunks so far, totaling in %d UTXOs",
receivedChunkCount, receivedUTXOCount)
requestNextPruningPointUTXOSetChunkMessage := appmessage.NewMsgRequestNextPruningPointUTXOSetChunk()

View File

@ -5,6 +5,7 @@ import (
"github.com/kaspanet/kaspad/domain/dagconfig"
"github.com/kaspanet/kaspad/domain/miningmanager/blocktemplatebuilder"
mempoolpkg "github.com/kaspanet/kaspad/domain/miningmanager/mempool"
"github.com/pkg/errors"
"sync"
"time"
)
@ -21,7 +22,15 @@ func (f *factory) NewMiningManager(consensusReference consensusreference.Consens
mempoolConfig *mempoolpkg.Config) MiningManager {
mempool := mempoolpkg.New(mempoolConfig, consensusReference)
blockTemplateBuilder := blocktemplatebuilder.New(consensusReference, mempool, params.MaxBlockMass, params.CoinbasePayloadScriptPublicKeyMaxLength)
// In the current pruning window (according to 06/04/2022) the header with the most mass weighted 5294 grams.
// We take a 10x factor for safety.
// TODO: Remove this behaviour once `ignoreHeaderMass` is set to true in all networks.
const estimatedHeaderUpperBound = 60000
if estimatedHeaderUpperBound > params.MaxBlockMass {
panic(errors.Errorf("Estimated header mass upper bound is higher than the max block mass allowed"))
}
maxBlockMass := params.MaxBlockMass - estimatedHeaderUpperBound
blockTemplateBuilder := blocktemplatebuilder.New(consensusReference, mempool, maxBlockMass, params.CoinbasePayloadScriptPublicKeyMaxLength)
return &miningManager{
consensusReference: consensusReference,