mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-09-13 21:10:12 +00:00

* Calculate GHOSTDAG, reachability etc for each level * Don't preallocate cache for dag stores except level 0 and reduce the number of connections in the integration test to 32 * Reduce the number of connections in the integration test to 16 * Increase page file * BuildPruningPointProof * BuildPruningPointProof * Add PruningProofManager * Implement ApplyPruningPointProof * Add prefix and fix blockAtDepth and fill headersByLevel * Some bug fixes * Include all relevant blocks for each level in the proof * Fix syncAndValidatePruningPointProof to return the right block hash * Fix block window * Fix isAncestorOfPruningPoint * Ban for rule errors on pruning proof * Find common ancestor for blockAtDepthMAtNextLevel * Use pruning proof in TestValidateAndInsertImportedPruningPoint * stage status and finality point for proof blocks * Uncomment golint * Change test timeouts * Calculate merge set for ApplyPruningPointProof * Increase test timeout * Add better caching for daa window store * Return to default timeout * Add ErrPruningProofMissesBlocksBelowPruningPoint * Add errDAAWindowBlockNotFound * Force connection loop next iteration on connection manager stop * Revert to Test64IncomingConnections * Remove BlockAtDepth from DAGTraversalManager * numBullies->16 * Set page file size to 8gb * Increase p2p max message size * Test64IncomingConnections->Test16IncomingConnections * Add comment for PruningProofM * Add comment in `func (c *ConnectionManager) Stop()` * Rename isAncestorOfPruningPoint->isAncestorOfSelectedTip * Revert page file to 16gb * Improve ExpectedHeaderPruningPoint perf * Fix comment * Revert "Improve ExpectedHeaderPruningPoint perf" This reverts commit bca1080e7140c78d510f51bbea858ae280c2f38e. * Don't test windows
122 lines
4.4 KiB
Go
122 lines
4.4 KiB
Go
package blockvalidator
|
|
|
|
import (
|
|
"math/big"
|
|
"time"
|
|
|
|
"github.com/kaspanet/kaspad/domain/consensus/model"
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
"github.com/kaspanet/kaspad/util/difficulty"
|
|
)
|
|
|
|
// blockValidator exposes a set of validation classes, after which
|
|
// it's possible to determine whether either a block is valid
|
|
type blockValidator struct {
|
|
powMax *big.Int
|
|
skipPoW bool
|
|
genesisHash *externalapi.DomainHash
|
|
enableNonNativeSubnetworks bool
|
|
powMaxBits uint32
|
|
maxBlockMass uint64
|
|
mergeSetSizeLimit uint64
|
|
maxBlockParents externalapi.KType
|
|
timestampDeviationTolerance int
|
|
targetTimePerBlock time.Duration
|
|
|
|
databaseContext model.DBReader
|
|
difficultyManager model.DifficultyManager
|
|
pastMedianTimeManager model.PastMedianTimeManager
|
|
transactionValidator model.TransactionValidator
|
|
ghostdagManagers []model.GHOSTDAGManager
|
|
dagTopologyManagers []model.DAGTopologyManager
|
|
dagTraversalManager model.DAGTraversalManager
|
|
coinbaseManager model.CoinbaseManager
|
|
mergeDepthManager model.MergeDepthManager
|
|
pruningStore model.PruningStore
|
|
reachabilityManagers []model.ReachabilityManager
|
|
finalityManager model.FinalityManager
|
|
blockParentBuilder model.BlockParentBuilder
|
|
pruningManager model.PruningManager
|
|
|
|
blockStore model.BlockStore
|
|
ghostdagDataStores []model.GHOSTDAGDataStore
|
|
blockHeaderStore model.BlockHeaderStore
|
|
blockStatusStore model.BlockStatusStore
|
|
reachabilityStore model.ReachabilityDataStore
|
|
consensusStateStore model.ConsensusStateStore
|
|
daaBlocksStore model.DAABlocksStore
|
|
}
|
|
|
|
// New instantiates a new BlockValidator
|
|
func New(powMax *big.Int,
|
|
skipPoW bool,
|
|
genesisHash *externalapi.DomainHash,
|
|
enableNonNativeSubnetworks bool,
|
|
maxBlockMass uint64,
|
|
mergeSetSizeLimit uint64,
|
|
maxBlockParents externalapi.KType,
|
|
timestampDeviationTolerance int,
|
|
targetTimePerBlock time.Duration,
|
|
|
|
databaseContext model.DBReader,
|
|
|
|
difficultyManager model.DifficultyManager,
|
|
pastMedianTimeManager model.PastMedianTimeManager,
|
|
transactionValidator model.TransactionValidator,
|
|
ghostdagManagers []model.GHOSTDAGManager,
|
|
dagTopologyManagers []model.DAGTopologyManager,
|
|
dagTraversalManager model.DAGTraversalManager,
|
|
coinbaseManager model.CoinbaseManager,
|
|
mergeDepthManager model.MergeDepthManager,
|
|
reachabilityManagers []model.ReachabilityManager,
|
|
finalityManager model.FinalityManager,
|
|
blockParentBuilder model.BlockParentBuilder,
|
|
pruningManager model.PruningManager,
|
|
|
|
pruningStore model.PruningStore,
|
|
blockStore model.BlockStore,
|
|
ghostdagDataStores []model.GHOSTDAGDataStore,
|
|
blockHeaderStore model.BlockHeaderStore,
|
|
blockStatusStore model.BlockStatusStore,
|
|
reachabilityStore model.ReachabilityDataStore,
|
|
consensusStateStore model.ConsensusStateStore,
|
|
daaBlocksStore model.DAABlocksStore,
|
|
) model.BlockValidator {
|
|
|
|
return &blockValidator{
|
|
powMax: powMax,
|
|
skipPoW: skipPoW,
|
|
genesisHash: genesisHash,
|
|
enableNonNativeSubnetworks: enableNonNativeSubnetworks,
|
|
powMaxBits: difficulty.BigToCompact(powMax),
|
|
maxBlockMass: maxBlockMass,
|
|
mergeSetSizeLimit: mergeSetSizeLimit,
|
|
maxBlockParents: maxBlockParents,
|
|
|
|
timestampDeviationTolerance: timestampDeviationTolerance,
|
|
targetTimePerBlock: targetTimePerBlock,
|
|
databaseContext: databaseContext,
|
|
difficultyManager: difficultyManager,
|
|
pastMedianTimeManager: pastMedianTimeManager,
|
|
transactionValidator: transactionValidator,
|
|
ghostdagManagers: ghostdagManagers,
|
|
dagTopologyManagers: dagTopologyManagers,
|
|
dagTraversalManager: dagTraversalManager,
|
|
coinbaseManager: coinbaseManager,
|
|
mergeDepthManager: mergeDepthManager,
|
|
reachabilityManagers: reachabilityManagers,
|
|
finalityManager: finalityManager,
|
|
blockParentBuilder: blockParentBuilder,
|
|
pruningManager: pruningManager,
|
|
|
|
pruningStore: pruningStore,
|
|
blockStore: blockStore,
|
|
ghostdagDataStores: ghostdagDataStores,
|
|
blockHeaderStore: blockHeaderStore,
|
|
blockStatusStore: blockStatusStore,
|
|
reachabilityStore: reachabilityStore,
|
|
consensusStateStore: consensusStateStore,
|
|
daaBlocksStore: daaBlocksStore,
|
|
}
|
|
}
|