Svarog 369a3bac09
Limit block mass instead of merge set limit + Introduce SigOpCount to TransactionInput (#1790)
* Update constants

* Add to transaction SigOpCount

* Update mass calculation, and move it from InContext to InIsolation

* Update block validation accordingly

* Add SigOpCount validation during TransactionInContext

* Remove checking of mass vs maxMassAcceptedByBlock from consensusStateManager

* Update mining manager with latest changes

* Add SigOpCount to MsgTx.Copy()

* Fix initTestTransactionAcceptanceDataForClone

* Fix all tests in transaction_equal_clone_test.go

* Fix TestBlockMass

* Fix tests in transactionvalidator package

* Add SigOpCount to sighash

* Fix TestPruningDepth

* Fix problems in libkaspawalelt

* Fix integration tests

* Fix CalculateSignatureHash tests

* Remove remaining places talking about block size

* Add sanity check to checkBlockMass to make sure all transactions have their mass filled

* always add own sigOpCount to sigHash

* Update protowire/rpc.md

* Start working on removing any remaining reference to block/tx size

* Update rpc transaction verbose data to include mass rather then size

* Convert verboseData and block size check to mass

* Remove remaining usages of tx size in mempool

* Move transactionEstimatedSerializedSize to transactionvalidator

* Add PopulateMass to fakeRelayInvsContext

* Move PopulateMass to beggining of ValidateAndInsertTransaction + fix in it

* Assign mass a new number for backward-compatibility
2021-07-14 14:21:57 +03:00

127 lines
4.2 KiB
Go

package consensusstatemanager
import (
"github.com/kaspanet/kaspad/domain/consensus/model"
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
)
// consensusStateManager manages the node's consensus state
type consensusStateManager struct {
pruningDepth uint64
maxBlockParents model.KType
mergeSetSizeLimit uint64
genesisHash *externalapi.DomainHash
databaseContext model.DBManager
ghostdagManager model.GHOSTDAGManager
dagTopologyManager model.DAGTopologyManager
dagTraversalManager model.DAGTraversalManager
pastMedianTimeManager model.PastMedianTimeManager
transactionValidator model.TransactionValidator
blockValidator model.BlockValidator
reachabilityManager model.ReachabilityManager
coinbaseManager model.CoinbaseManager
mergeDepthManager model.MergeDepthManager
finalityManager model.FinalityManager
difficultyManager model.DifficultyManager
headersSelectedTipStore model.HeaderSelectedTipStore
blockStatusStore model.BlockStatusStore
ghostdagDataStore model.GHOSTDAGDataStore
consensusStateStore model.ConsensusStateStore
multisetStore model.MultisetStore
blockStore model.BlockStore
utxoDiffStore model.UTXODiffStore
blockRelationStore model.BlockRelationStore
acceptanceDataStore model.AcceptanceDataStore
blockHeaderStore model.BlockHeaderStore
pruningStore model.PruningStore
daaBlocksStore model.DAABlocksStore
stores []model.Store
}
// New instantiates a new ConsensusStateManager
func New(
databaseContext model.DBManager,
pruningDepth uint64,
maxBlockParents model.KType,
mergeSetSizeLimit uint64,
genesisHash *externalapi.DomainHash,
ghostdagManager model.GHOSTDAGManager,
dagTopologyManager model.DAGTopologyManager,
dagTraversalManager model.DAGTraversalManager,
pastMedianTimeManager model.PastMedianTimeManager,
transactionValidator model.TransactionValidator,
blockValidator model.BlockValidator,
reachabilityManager model.ReachabilityManager,
coinbaseManager model.CoinbaseManager,
mergeDepthManager model.MergeDepthManager,
finalityManager model.FinalityManager,
difficultyManager model.DifficultyManager,
blockStatusStore model.BlockStatusStore,
ghostdagDataStore model.GHOSTDAGDataStore,
consensusStateStore model.ConsensusStateStore,
multisetStore model.MultisetStore,
blockStore model.BlockStore,
utxoDiffStore model.UTXODiffStore,
blockRelationStore model.BlockRelationStore,
acceptanceDataStore model.AcceptanceDataStore,
blockHeaderStore model.BlockHeaderStore,
headersSelectedTipStore model.HeaderSelectedTipStore,
pruningStore model.PruningStore,
daaBlocksStore model.DAABlocksStore) (model.ConsensusStateManager, error) {
csm := &consensusStateManager{
pruningDepth: pruningDepth,
maxBlockParents: maxBlockParents,
mergeSetSizeLimit: mergeSetSizeLimit,
genesisHash: genesisHash,
databaseContext: databaseContext,
ghostdagManager: ghostdagManager,
dagTopologyManager: dagTopologyManager,
dagTraversalManager: dagTraversalManager,
pastMedianTimeManager: pastMedianTimeManager,
transactionValidator: transactionValidator,
blockValidator: blockValidator,
reachabilityManager: reachabilityManager,
coinbaseManager: coinbaseManager,
mergeDepthManager: mergeDepthManager,
finalityManager: finalityManager,
difficultyManager: difficultyManager,
multisetStore: multisetStore,
blockStore: blockStore,
blockStatusStore: blockStatusStore,
ghostdagDataStore: ghostdagDataStore,
consensusStateStore: consensusStateStore,
utxoDiffStore: utxoDiffStore,
blockRelationStore: blockRelationStore,
acceptanceDataStore: acceptanceDataStore,
blockHeaderStore: blockHeaderStore,
headersSelectedTipStore: headersSelectedTipStore,
pruningStore: pruningStore,
daaBlocksStore: daaBlocksStore,
stores: []model.Store{
consensusStateStore,
acceptanceDataStore,
blockStore,
blockStatusStore,
blockRelationStore,
multisetStore,
ghostdagDataStore,
consensusStateStore,
utxoDiffStore,
blockHeaderStore,
headersSelectedTipStore,
pruningStore,
},
}
return csm, nil
}