mirror of
https://github.com/kaspanet/kaspad.git
synced 2026-02-25 21:01:44 +00:00
Compare commits
1 Commits
hf-test-2
...
v1sectimeo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5993f26b04 |
2
.github/workflows/race.yaml
vendored
2
.github/workflows/race.yaml
vendored
@@ -46,4 +46,4 @@ jobs:
|
||||
run: |
|
||||
git checkout "${{ env.run_on }}"
|
||||
git status
|
||||
go test -timeout 20m -race ./...
|
||||
go test -race ./...
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
// DefaultTimeout is the default duration to wait for enqueuing/dequeuing
|
||||
// to/from routes.
|
||||
const DefaultTimeout = 120 * time.Second
|
||||
const DefaultTimeout = 30 * time.Second
|
||||
|
||||
// ErrPeerWithSameIDExists signifies that a peer with the same ID already exist.
|
||||
var ErrPeerWithSameIDExists = errors.New("ready peer with the same ID already exists")
|
||||
|
||||
@@ -130,7 +130,7 @@ func (flow *handleRelayInvsFlow) downloadHeadersAndPruningUTXOSet(highHash *exte
|
||||
return err
|
||||
}
|
||||
|
||||
log.Infof("Headers downloaded from peer %s", flow.peer)
|
||||
log.Debugf("Headers downloaded from peer %s", flow.peer)
|
||||
|
||||
highHashInfo, err := flow.Domain().StagingConsensus().GetBlockInfo(highHash)
|
||||
if err != nil {
|
||||
|
||||
@@ -14,14 +14,9 @@ import (
|
||||
func HandleSubmitBlock(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) {
|
||||
submitBlockRequest := request.(*appmessage.SubmitBlockRequestMessage)
|
||||
|
||||
isSynced, err := context.ProtocolManager.ShouldMine()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !context.Config.AllowSubmitBlockWhenNotSynced && !isSynced {
|
||||
if context.ProtocolManager.IsIBDRunning() {
|
||||
return &appmessage.SubmitBlockResponseMessage{
|
||||
Error: appmessage.RPCErrorf("Block not submitted - node is not synced"),
|
||||
Error: appmessage.RPCErrorf("Block not submitted - IBD is running"),
|
||||
RejectReason: appmessage.RejectReasonIsInIBD,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ golint -set_exit_status ./...
|
||||
|
||||
staticcheck -checks SA4006,SA4008,SA4009,SA4010,SA5003,SA1004,SA1014,SA1021,SA1023,SA1024,SA1025,SA1026,SA1027,SA1028,SA2000,SA2001,SA2003,SA4000,SA4001,SA4003,SA4004,SA4011,SA4012,SA4013,SA4014,SA4015,SA4016,SA4017,SA4018,SA4019,SA4020,SA4021,SA4022,SA4023,SA5000,SA5002,SA5004,SA5005,SA5007,SA5008,SA5009,SA5010,SA5011,SA5012,SA6001,SA6002,SA9001,SA9002,SA9003,SA9004,SA9005,SA9006,ST1019 ./...
|
||||
|
||||
#go vet -composites=false $FLAGS ./...
|
||||
go vet -composites=false $FLAGS ./...
|
||||
|
||||
go build $FLAGS -o kaspad .
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ func create(conf *createConfig) error {
|
||||
}
|
||||
|
||||
file := keys.File{
|
||||
Version: keys.LastVersion,
|
||||
EncryptedMnemonics: encryptedMnemonics,
|
||||
ExtendedPublicKeys: extendedPublicKeys,
|
||||
MinimumSignatures: conf.MinimumSignatures,
|
||||
|
||||
@@ -97,7 +97,7 @@ func encryptMnemonic(mnemonic string, password []byte) (*EncryptedMnemonic, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
aead, err := getAEAD(defaultNumThreads, password, salt)
|
||||
aead, err := getAEAD(password, salt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/kaspanet/kaspad/domain/dagconfig"
|
||||
"github.com/kaspanet/kaspad/util"
|
||||
@@ -23,9 +22,6 @@ var (
|
||||
defaultAppDir = util.AppDir("kaspawallet", false)
|
||||
)
|
||||
|
||||
// LastVersion is the most up to date file format version
|
||||
const LastVersion = 1
|
||||
|
||||
func defaultKeysFile(netParams *dagconfig.Params) string {
|
||||
return filepath.Join(defaultAppDir, netParams.Name, "keys.json")
|
||||
}
|
||||
@@ -36,8 +32,6 @@ type encryptedPrivateKeyJSON struct {
|
||||
}
|
||||
|
||||
type keysFileJSON struct {
|
||||
Version uint32 `json:"version"`
|
||||
NumThreads uint8 `json:"numThreads,omitempty"` // This field is ignored for versions different than 0
|
||||
EncryptedPrivateKeys []*encryptedPrivateKeyJSON `json:"encryptedMnemonics"`
|
||||
ExtendedPublicKeys []string `json:"publicKeys"`
|
||||
MinimumSignatures uint32 `json:"minimumSignatures"`
|
||||
@@ -55,8 +49,6 @@ type EncryptedMnemonic struct {
|
||||
|
||||
// File holds all the data related to the wallet keys
|
||||
type File struct {
|
||||
Version uint32
|
||||
NumThreads uint8 // This field is ignored for versions different than 0
|
||||
EncryptedMnemonics []*EncryptedMnemonic
|
||||
ExtendedPublicKeys []string
|
||||
MinimumSignatures uint32
|
||||
@@ -77,8 +69,6 @@ func (d *File) toJSON() *keysFileJSON {
|
||||
}
|
||||
|
||||
return &keysFileJSON{
|
||||
Version: d.Version,
|
||||
NumThreads: d.NumThreads,
|
||||
EncryptedPrivateKeys: encryptedPrivateKeysJSON,
|
||||
ExtendedPublicKeys: d.ExtendedPublicKeys,
|
||||
MinimumSignatures: d.MinimumSignatures,
|
||||
@@ -90,8 +80,6 @@ func (d *File) toJSON() *keysFileJSON {
|
||||
}
|
||||
|
||||
func (d *File) fromJSON(fileJSON *keysFileJSON) error {
|
||||
d.Version = fileJSON.Version
|
||||
d.NumThreads = fileJSON.NumThreads
|
||||
d.MinimumSignatures = fileJSON.MinimumSignatures
|
||||
d.ECDSA = fileJSON.ECDSA
|
||||
d.ExtendedPublicKeys = fileJSON.ExtendedPublicKeys
|
||||
@@ -193,20 +181,10 @@ func (d *File) DecryptMnemonics(cmdLinePassword string) ([]string, error) {
|
||||
if len(password) == 0 {
|
||||
password = getPassword("Password:")
|
||||
}
|
||||
|
||||
var numThreads uint8
|
||||
if len(d.EncryptedMnemonics) > 0 {
|
||||
var err error
|
||||
numThreads, err = d.numThreads(password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
privateKeys := make([]string, len(d.EncryptedMnemonics))
|
||||
for i, encryptedPrivateKey := range d.EncryptedMnemonics {
|
||||
var err error
|
||||
privateKeys[i], err = decryptMnemonic(numThreads, encryptedPrivateKey, password)
|
||||
privateKeys[i], err = decryptMnemonic(encryptedPrivateKey, password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -300,66 +278,13 @@ func (d *File) Save() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
const defaultNumThreads = 8
|
||||
|
||||
func (d *File) numThreads(password []byte) (uint8, error) {
|
||||
if d.Version != 0 {
|
||||
return defaultNumThreads, nil
|
||||
}
|
||||
|
||||
if d.NumThreads != 0 {
|
||||
return d.NumThreads, nil
|
||||
}
|
||||
|
||||
numThreads, err := d.detectNumThreads(password, d.EncryptedMnemonics[0].salt)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
d.NumThreads = numThreads
|
||||
err = d.Save()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return numThreads, nil
|
||||
}
|
||||
|
||||
func (d *File) detectNumThreads(password, salt []byte) (uint8, error) {
|
||||
numCPU := uint8(runtime.NumCPU())
|
||||
_, err := getAEAD(numCPU, password, salt)
|
||||
if err != nil {
|
||||
if !strings.Contains(err.Error(), "message authentication failed") {
|
||||
return 0, err
|
||||
}
|
||||
} else {
|
||||
return numCPU, nil
|
||||
}
|
||||
|
||||
for i := uint8(1); ; i++ {
|
||||
if i == numCPU {
|
||||
continue
|
||||
}
|
||||
|
||||
_, err := getAEAD(i, password, salt)
|
||||
if err != nil {
|
||||
const maxTries = 32
|
||||
if i == maxTries || !strings.Contains(err.Error(), "message authentication failed") {
|
||||
return 0, err
|
||||
}
|
||||
} else {
|
||||
return i, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getAEAD(threads uint8, password, salt []byte) (cipher.AEAD, error) {
|
||||
key := argon2.IDKey(password, salt, 1, 64*1024, threads, 32)
|
||||
func getAEAD(password, salt []byte) (cipher.AEAD, error) {
|
||||
key := argon2.IDKey(password, salt, 1, 64*1024, uint8(runtime.NumCPU()), 32)
|
||||
return chacha20poly1305.NewX(key)
|
||||
}
|
||||
|
||||
func decryptMnemonic(numThreads uint8, encryptedPrivateKey *EncryptedMnemonic, password []byte) (string, error) {
|
||||
aead, err := getAEAD(numThreads, password, encryptedPrivateKey.salt)
|
||||
func decryptMnemonic(encryptedPrivateKey *EncryptedMnemonic, password []byte) (string, error) {
|
||||
aead, err := getAEAD(password, encryptedPrivateKey.salt)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -716,10 +716,7 @@ func (s *consensus) PopulateMass(transaction *externalapi.DomainTransaction) {
|
||||
func (s *consensus) ResolveVirtual() error {
|
||||
// In order to prevent a situation that the consensus lock is held for too much time, we
|
||||
// release the lock each time resolve 100 blocks.
|
||||
for i := 0; ; i++ {
|
||||
if i%10 == 0 {
|
||||
log.Infof("Resolving virtual. This may take some time...")
|
||||
}
|
||||
for {
|
||||
var isCompletelyResolved bool
|
||||
var err error
|
||||
func() {
|
||||
@@ -733,7 +730,6 @@ func (s *consensus) ResolveVirtual() error {
|
||||
}
|
||||
|
||||
if isCompletelyResolved {
|
||||
log.Infof("Resolved virtual")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ import (
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/lrucache"
|
||||
"github.com/kaspanet/kaspad/infrastructure/db/database"
|
||||
"github.com/kaspanet/kaspad/util/staging"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var reachabilityDataBucketName = []byte("reachability-data")
|
||||
@@ -52,8 +50,6 @@ func (rds *reachabilityDataStore) IsStaged(stagingArea *model.StagingArea) bool
|
||||
return rds.stagingShard(stagingArea).isStaged()
|
||||
}
|
||||
|
||||
var errNotFound = errors.Wrap(database.ErrNotFound, "reachability data not found")
|
||||
|
||||
// ReachabilityData returns the reachabilityData associated with the given blockHash
|
||||
func (rds *reachabilityDataStore) ReachabilityData(dbContext model.DBReader, stagingArea *model.StagingArea, blockHash *externalapi.DomainHash) (model.ReachabilityData, error) {
|
||||
stagingShard := rds.stagingShard(stagingArea)
|
||||
@@ -63,16 +59,10 @@ func (rds *reachabilityDataStore) ReachabilityData(dbContext model.DBReader, sta
|
||||
}
|
||||
|
||||
if reachabilityData, ok := rds.reachabilityDataCache.Get(blockHash); ok {
|
||||
if reachabilityData == nil {
|
||||
return nil, errNotFound
|
||||
}
|
||||
return reachabilityData.(model.ReachabilityData), nil
|
||||
}
|
||||
|
||||
reachabilityDataBytes, err := dbContext.Get(rds.reachabilityDataBlockHashAsKey(blockHash))
|
||||
if database.IsNotFoundError(err) {
|
||||
rds.reachabilityDataCache.Add(blockHash, nil)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -86,15 +76,17 @@ func (rds *reachabilityDataStore) ReachabilityData(dbContext model.DBReader, sta
|
||||
}
|
||||
|
||||
func (rds *reachabilityDataStore) HasReachabilityData(dbContext model.DBReader, stagingArea *model.StagingArea, blockHash *externalapi.DomainHash) (bool, error) {
|
||||
_, err := rds.ReachabilityData(dbContext, stagingArea, blockHash)
|
||||
if database.IsNotFoundError(err) {
|
||||
return false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, err
|
||||
stagingShard := rds.stagingShard(stagingArea)
|
||||
|
||||
if _, ok := stagingShard.reachabilityData[*blockHash]; ok {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return true, nil
|
||||
if rds.reachabilityDataCache.Has(blockHash) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return dbContext.Has(rds.reachabilityDataBlockHashAsKey(blockHash))
|
||||
}
|
||||
|
||||
// ReachabilityReindexRoot returns the current reachability reindex root
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"github.com/kaspanet/kaspad/domain/consensus/datastructures/daawindowstore"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/processes/blockparentbuilder"
|
||||
parentssanager "github.com/kaspanet/kaspad/domain/consensus/processes/parentsmanager"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/processes/pruningproofmanager"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/constants"
|
||||
"io/ioutil"
|
||||
@@ -159,17 +158,12 @@ func (f *factory) NewConsensus(config *Config, db infrastructuredatabase.Databas
|
||||
dagTraversalManager := dagTraversalManagers[0]
|
||||
|
||||
// Processes
|
||||
parentsManager := parentssanager.New(config.GenesisHash, config.HardForkOmitGenesisFromParentsDAAScore)
|
||||
blockParentBuilder := blockparentbuilder.New(
|
||||
dbManager,
|
||||
blockHeaderStore,
|
||||
dagTopologyManager,
|
||||
parentsManager,
|
||||
reachabilityDataStore,
|
||||
pruningStore,
|
||||
|
||||
config.HardForkOmitGenesisFromParentsDAAScore,
|
||||
config.GenesisHash,
|
||||
)
|
||||
pastMedianTimeManager := f.pastMedianTimeConsructor(
|
||||
config.TimestampDeviationTolerance,
|
||||
@@ -322,7 +316,6 @@ func (f *factory) NewConsensus(config *Config, db infrastructuredatabase.Databas
|
||||
finalityManager,
|
||||
blockParentBuilder,
|
||||
pruningManager,
|
||||
parentsManager,
|
||||
|
||||
pruningStore,
|
||||
blockStore,
|
||||
@@ -410,7 +403,6 @@ func (f *factory) NewConsensus(config *Config, db infrastructuredatabase.Databas
|
||||
ghostdagManagers,
|
||||
reachabilityManagers,
|
||||
dagTraversalManagers,
|
||||
parentsManager,
|
||||
|
||||
ghostdagDataStores,
|
||||
pruningStore,
|
||||
@@ -589,7 +581,7 @@ func dagStores(config *Config,
|
||||
ghostdagDataStores[i] = ghostdagdatastore.New(prefixBucket, ghostdagDataCacheSize, preallocateCaches)
|
||||
} else {
|
||||
blockRelationStores[i] = blockrelationstore.New(prefixBucket, 200, false)
|
||||
reachabilityDataStores[i] = reachabilitydatastore.New(prefixBucket, 86400, false)
|
||||
reachabilityDataStores[i] = reachabilitydatastore.New(prefixBucket, 200, false)
|
||||
ghostdagDataStores[i] = ghostdagdatastore.New(prefixBucket, 200, false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ type BlockHeader interface {
|
||||
type BaseBlockHeader interface {
|
||||
Version() uint16
|
||||
Parents() []BlockLevelParents
|
||||
ParentsAtLevel(level int) BlockLevelParents
|
||||
DirectParents() BlockLevelParents
|
||||
HashMerkleRoot() *DomainHash
|
||||
AcceptedIDMerkleRoot() *DomainHash
|
||||
@@ -69,7 +70,6 @@ type BaseBlockHeader interface {
|
||||
BlueScore() uint64
|
||||
BlueWork() *big.Int
|
||||
PruningPoint() *DomainHash
|
||||
BlockLevel() int
|
||||
Equal(other BaseBlockHeader) bool
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,5 @@ import "github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||
// BlockParentBuilder exposes a method to build super-block parents for
|
||||
// a given set of direct parents
|
||||
type BlockParentBuilder interface {
|
||||
BuildParents(stagingArea *StagingArea,
|
||||
daaScore uint64,
|
||||
directParentHashes []*externalapi.DomainHash) ([]externalapi.BlockLevelParents, error)
|
||||
BuildParents(stagingArea *StagingArea, directParentHashes []*externalapi.DomainHash) ([]externalapi.BlockLevelParents, error)
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package model
|
||||
|
||||
import "github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||
|
||||
// ParentsManager lets is a wrapper above header parents that replaces empty parents with genesis when needed.
|
||||
type ParentsManager interface {
|
||||
ParentsAtLevel(blockHeader externalapi.BlockHeader, level int) externalapi.BlockLevelParents
|
||||
Parents(blockHeader externalapi.BlockHeader) []externalapi.BlockLevelParents
|
||||
}
|
||||
@@ -183,16 +183,10 @@ func (bb *blockBuilder) newBlockCoinbaseTransaction(stagingArea *model.StagingAr
|
||||
func (bb *blockBuilder) buildHeader(stagingArea *model.StagingArea, transactions []*externalapi.DomainTransaction,
|
||||
newBlockPruningPoint *externalapi.DomainHash) (externalapi.BlockHeader, error) {
|
||||
|
||||
daaScore, err := bb.newBlockDAAScore(stagingArea)
|
||||
parents, err := bb.newBlockParents(stagingArea)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
parents, err := bb.newBlockParents(stagingArea, daaScore)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
timeInMilliseconds, err := bb.newBlockTime(stagingArea)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -210,6 +204,10 @@ func (bb *blockBuilder) buildHeader(stagingArea *model.StagingArea, transactions
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
daaScore, err := bb.newBlockDAAScore(stagingArea)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
blueWork, err := bb.newBlockBlueWork(stagingArea)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -235,12 +233,12 @@ func (bb *blockBuilder) buildHeader(stagingArea *model.StagingArea, transactions
|
||||
), nil
|
||||
}
|
||||
|
||||
func (bb *blockBuilder) newBlockParents(stagingArea *model.StagingArea, daaScore uint64) ([]externalapi.BlockLevelParents, error) {
|
||||
func (bb *blockBuilder) newBlockParents(stagingArea *model.StagingArea) ([]externalapi.BlockLevelParents, error) {
|
||||
virtualBlockRelations, err := bb.blockRelationStore.BlockRelation(bb.databaseContext, stagingArea, model.VirtualBlockHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bb.blockParentBuilder.BuildParents(stagingArea, daaScore, virtualBlockRelations.Parents)
|
||||
return bb.blockParentBuilder.BuildParents(stagingArea, virtualBlockRelations.Parents)
|
||||
}
|
||||
|
||||
func (bb *blockBuilder) newBlockTime(stagingArea *model.StagingArea) (int64, error) {
|
||||
|
||||
@@ -83,7 +83,7 @@ func (bb *testBlockBuilder) buildUTXOInvalidHeader(stagingArea *model.StagingAre
|
||||
return nil, err
|
||||
}
|
||||
|
||||
parents, err := bb.blockParentBuilder.BuildParents(stagingArea, daaScore, parentHashes)
|
||||
parents, err := bb.blockParentBuilder.BuildParents(stagingArea, parentHashes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/hashset"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/pow"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -12,12 +13,8 @@ type blockParentBuilder struct {
|
||||
databaseContext model.DBManager
|
||||
blockHeaderStore model.BlockHeaderStore
|
||||
dagTopologyManager model.DAGTopologyManager
|
||||
parentsManager model.ParentsManager
|
||||
reachabilityDataStore model.ReachabilityDataStore
|
||||
pruningStore model.PruningStore
|
||||
|
||||
hardForkOmitGenesisFromParentsDAAScore uint64
|
||||
genesisHash *externalapi.DomainHash
|
||||
}
|
||||
|
||||
// New creates a new instance of a BlockParentBuilder
|
||||
@@ -25,29 +22,20 @@ func New(
|
||||
databaseContext model.DBManager,
|
||||
blockHeaderStore model.BlockHeaderStore,
|
||||
dagTopologyManager model.DAGTopologyManager,
|
||||
parentsManager model.ParentsManager,
|
||||
|
||||
reachabilityDataStore model.ReachabilityDataStore,
|
||||
pruningStore model.PruningStore,
|
||||
|
||||
hardForkOmitGenesisFromParentsDAAScore uint64,
|
||||
genesisHash *externalapi.DomainHash,
|
||||
) model.BlockParentBuilder {
|
||||
return &blockParentBuilder{
|
||||
databaseContext: databaseContext,
|
||||
blockHeaderStore: blockHeaderStore,
|
||||
dagTopologyManager: dagTopologyManager,
|
||||
parentsManager: parentsManager,
|
||||
|
||||
reachabilityDataStore: reachabilityDataStore,
|
||||
pruningStore: pruningStore,
|
||||
hardForkOmitGenesisFromParentsDAAScore: hardForkOmitGenesisFromParentsDAAScore,
|
||||
genesisHash: genesisHash,
|
||||
databaseContext: databaseContext,
|
||||
blockHeaderStore: blockHeaderStore,
|
||||
dagTopologyManager: dagTopologyManager,
|
||||
reachabilityDataStore: reachabilityDataStore,
|
||||
pruningStore: pruningStore,
|
||||
}
|
||||
}
|
||||
|
||||
func (bpb *blockParentBuilder) BuildParents(stagingArea *model.StagingArea,
|
||||
daaScore uint64, directParentHashes []*externalapi.DomainHash) ([]externalapi.BlockLevelParents, error) {
|
||||
directParentHashes []*externalapi.DomainHash) ([]externalapi.BlockLevelParents, error) {
|
||||
|
||||
// Late on we'll mutate direct parent hashes, so we first clone it.
|
||||
directParentHashesCopy := make([]*externalapi.DomainHash, len(directParentHashes))
|
||||
@@ -105,7 +93,7 @@ func (bpb *blockParentBuilder) BuildParents(stagingArea *model.StagingArea,
|
||||
// all the block levels they occupy
|
||||
for _, directParentHeader := range directParentHeaders {
|
||||
directParentHash := consensushashing.HeaderHash(directParentHeader)
|
||||
blockLevel := directParentHeader.BlockLevel()
|
||||
blockLevel := pow.BlockLevel(directParentHeader)
|
||||
for i := 0; i <= blockLevel; i++ {
|
||||
if _, exists := candidatesByLevelToReferenceBlocksMap[i]; !exists {
|
||||
candidatesByLevelToReferenceBlocksMap[i] = make(map[externalapi.DomainHash][]*externalapi.DomainHash)
|
||||
@@ -128,7 +116,7 @@ func (bpb *blockParentBuilder) BuildParents(stagingArea *model.StagingArea,
|
||||
}
|
||||
|
||||
for _, directParentHeader := range directParentHeaders {
|
||||
for blockLevel, blockLevelParentsInHeader := range bpb.parentsManager.Parents(directParentHeader) {
|
||||
for blockLevel, blockLevelParentsInHeader := range directParentHeader.Parents() {
|
||||
isEmptyLevel := false
|
||||
if _, exists := candidatesByLevelToReferenceBlocksMap[blockLevel]; !exists {
|
||||
candidatesByLevelToReferenceBlocksMap[blockLevel] = make(map[externalapi.DomainHash][]*externalapi.DomainHash)
|
||||
@@ -157,7 +145,7 @@ func (bpb *blockParentBuilder) BuildParents(stagingArea *model.StagingArea,
|
||||
} else {
|
||||
for childHash, childHeader := range virtualGenesisChildrenHeaders {
|
||||
childHash := childHash // Assign to a new pointer to avoid `range` pointer reuse
|
||||
if bpb.parentsManager.ParentsAtLevel(childHeader, blockLevel).Contains(parent) {
|
||||
if childHeader.ParentsAtLevel(blockLevel).Contains(parent) {
|
||||
referenceBlocks = append(referenceBlocks, &childHash)
|
||||
}
|
||||
}
|
||||
@@ -217,16 +205,11 @@ func (bpb *blockParentBuilder) BuildParents(stagingArea *model.StagingArea,
|
||||
|
||||
parents := make([]externalapi.BlockLevelParents, len(candidatesByLevelToReferenceBlocksMap))
|
||||
for blockLevel := 0; blockLevel < len(candidatesByLevelToReferenceBlocksMap); blockLevel++ {
|
||||
if _, ok := candidatesByLevelToReferenceBlocksMap[blockLevel][*bpb.genesisHash]; daaScore >= bpb.hardForkOmitGenesisFromParentsDAAScore && ok && len(candidatesByLevelToReferenceBlocksMap[blockLevel]) == 1 {
|
||||
break
|
||||
}
|
||||
|
||||
levelBlocks := make(externalapi.BlockLevelParents, 0, len(candidatesByLevelToReferenceBlocksMap[blockLevel]))
|
||||
for block := range candidatesByLevelToReferenceBlocksMap[blockLevel] {
|
||||
block := block // Assign to a new pointer to avoid `range` pointer reuse
|
||||
levelBlocks = append(levelBlocks, &block)
|
||||
}
|
||||
|
||||
parents[blockLevel] = levelBlocks
|
||||
}
|
||||
return parents, nil
|
||||
|
||||
@@ -102,30 +102,9 @@ func (bp *blockProcessor) validateAndInsertBlock(stagingArea *model.StagingArea,
|
||||
}
|
||||
}
|
||||
|
||||
shouldAddHeaderSelectedTip := false
|
||||
if !hasHeaderSelectedTip {
|
||||
shouldAddHeaderSelectedTip = true
|
||||
} else {
|
||||
pruningPoint, err := bp.pruningStore.PruningPoint(bp.databaseContext, stagingArea)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
isInSelectedChainOfPruningPoint, err := bp.dagTopologyManager.IsInSelectedParentChainOf(stagingArea, pruningPoint, blockHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Don't set blocks in the anticone of the pruning point as header selected tip.
|
||||
shouldAddHeaderSelectedTip = isInSelectedChainOfPruningPoint
|
||||
}
|
||||
|
||||
if shouldAddHeaderSelectedTip {
|
||||
// Don't set blocks in the anticone of the pruning point as header selected tip.
|
||||
err = bp.headerTipsManager.AddHeaderTip(stagingArea, blockHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = bp.headerTipsManager.AddHeaderTip(stagingArea, blockHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var selectedParentChainChanges *externalapi.SelectedChainPath
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/ruleerrors"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/pow"
|
||||
"github.com/kaspanet/kaspad/infrastructure/logger"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -62,7 +63,7 @@ func (v *blockValidator) ValidateHeaderInContext(stagingArea *model.StagingArea,
|
||||
return err
|
||||
}
|
||||
if !hasReachabilityData {
|
||||
blockLevel := header.BlockLevel()
|
||||
blockLevel := pow.BlockLevel(header)
|
||||
for i := 0; i <= blockLevel; i++ {
|
||||
err = v.reachabilityManagers[i].AddBlock(stagingArea, blockHash)
|
||||
if err != nil {
|
||||
@@ -194,7 +195,7 @@ func (v *blockValidator) checkMergeSizeLimit(stagingArea *model.StagingArea, has
|
||||
}
|
||||
|
||||
func (v *blockValidator) checkIndirectParents(stagingArea *model.StagingArea, header externalapi.BlockHeader) error {
|
||||
expectedParents, err := v.blockParentBuilder.BuildParents(stagingArea, header.DAAScore(), header.DirectParents())
|
||||
expectedParents, err := v.blockParentBuilder.BuildParents(stagingArea, header.DirectParents())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ type blockValidator struct {
|
||||
finalityManager model.FinalityManager
|
||||
blockParentBuilder model.BlockParentBuilder
|
||||
pruningManager model.PruningManager
|
||||
parentsManager model.ParentsManager
|
||||
|
||||
blockStore model.BlockStore
|
||||
ghostdagDataStores []model.GHOSTDAGDataStore
|
||||
@@ -73,7 +72,6 @@ func New(powMax *big.Int,
|
||||
finalityManager model.FinalityManager,
|
||||
blockParentBuilder model.BlockParentBuilder,
|
||||
pruningManager model.PruningManager,
|
||||
parentsManager model.ParentsManager,
|
||||
|
||||
pruningStore model.PruningStore,
|
||||
blockStore model.BlockStore,
|
||||
@@ -110,7 +108,6 @@ func New(powMax *big.Int,
|
||||
finalityManager: finalityManager,
|
||||
blockParentBuilder: blockParentBuilder,
|
||||
pruningManager: pruningManager,
|
||||
parentsManager: parentsManager,
|
||||
|
||||
pruningStore: pruningStore,
|
||||
blockStore: blockStore,
|
||||
|
||||
@@ -67,9 +67,9 @@ func (v *blockValidator) setParents(stagingArea *model.StagingArea,
|
||||
header externalapi.BlockHeader,
|
||||
isBlockWithTrustedData bool) error {
|
||||
|
||||
for level := 0; level <= header.BlockLevel(); level++ {
|
||||
for level := 0; level <= pow.BlockLevel(header); level++ {
|
||||
var parents []*externalapi.DomainHash
|
||||
for _, parent := range v.parentsManager.ParentsAtLevel(header, level) {
|
||||
for _, parent := range header.ParentsAtLevel(level) {
|
||||
_, err := v.ghostdagDataStores[level].Get(v.databaseContext, stagingArea, parent, false)
|
||||
isNotFoundError := database.IsNotFoundError(err)
|
||||
if !isNotFoundError && err != nil {
|
||||
@@ -116,7 +116,7 @@ func (v *blockValidator) validateDifficulty(stagingArea *model.StagingArea,
|
||||
return err
|
||||
}
|
||||
|
||||
blockLevel := header.BlockLevel()
|
||||
blockLevel := pow.BlockLevel(header)
|
||||
for i := 1; i <= blockLevel; i++ {
|
||||
err = v.ghostdagManagers[i].GHOSTDAG(stagingArea, blockHash)
|
||||
if err != nil {
|
||||
|
||||
@@ -35,7 +35,7 @@ func (csm *consensusStateManager) ResolveVirtual(maxBlocksToResolve uint64) (boo
|
||||
var selectedTip *externalapi.DomainHash
|
||||
isCompletelyResolved := true
|
||||
for _, tip := range tips {
|
||||
log.Debugf("Resolving tip %s", tip)
|
||||
log.Infof("Resolving tip %s", tip)
|
||||
resolveStagingArea := model.NewStagingArea()
|
||||
unverifiedBlocks, err := csm.getUnverifiedChainBlocks(resolveStagingArea, tip)
|
||||
if err != nil {
|
||||
@@ -46,7 +46,7 @@ func (csm *consensusStateManager) ResolveVirtual(maxBlocksToResolve uint64) (boo
|
||||
hasMoreUnverifiedThanMax := maxBlocksToResolve != 0 && uint64(len(unverifiedBlocks)) > maxBlocksToResolve
|
||||
if hasMoreUnverifiedThanMax {
|
||||
resolveTip = unverifiedBlocks[uint64(len(unverifiedBlocks))-maxBlocksToResolve]
|
||||
log.Debugf("Has more than %d blocks to resolve. Changing the resolve tip to %s", maxBlocksToResolve, resolveTip)
|
||||
log.Infof("Has more than %d blocks to resolve. Changing the resolve tip to %s", maxBlocksToResolve, resolveTip)
|
||||
}
|
||||
|
||||
blockStatus, reversalData, err := csm.resolveBlockStatus(resolveStagingArea, resolveTip, true)
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package parentssanager
|
||||
|
||||
import (
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/constants"
|
||||
)
|
||||
|
||||
type parentsManager struct {
|
||||
hardForkOmitGenesisFromParentsDAAScore uint64
|
||||
genesisHash *externalapi.DomainHash
|
||||
}
|
||||
|
||||
// New instantiates a new HeadersSelectedTipManager
|
||||
func New(genesisHash *externalapi.DomainHash, hardForkOmitGenesisFromParentsDAAScore uint64) model.ParentsManager {
|
||||
return &parentsManager{
|
||||
genesisHash: genesisHash,
|
||||
hardForkOmitGenesisFromParentsDAAScore: hardForkOmitGenesisFromParentsDAAScore,
|
||||
}
|
||||
}
|
||||
|
||||
func (pm *parentsManager) ParentsAtLevel(blockHeader externalapi.BlockHeader, level int) externalapi.BlockLevelParents {
|
||||
if len(blockHeader.Parents()) <= level {
|
||||
if blockHeader.DAAScore() >= pm.hardForkOmitGenesisFromParentsDAAScore {
|
||||
return externalapi.BlockLevelParents{pm.genesisHash}
|
||||
}
|
||||
return externalapi.BlockLevelParents{}
|
||||
}
|
||||
|
||||
return blockHeader.Parents()[level]
|
||||
}
|
||||
|
||||
func (pm *parentsManager) Parents(blockHeader externalapi.BlockHeader) []externalapi.BlockLevelParents {
|
||||
numParents := len(blockHeader.Parents())
|
||||
if blockHeader.DAAScore() >= pm.hardForkOmitGenesisFromParentsDAAScore {
|
||||
numParents = constants.MaxBlockLevel + 1
|
||||
}
|
||||
|
||||
parents := make([]externalapi.BlockLevelParents, numParents)
|
||||
for i := 0; i < numParents; i++ {
|
||||
parents[i] = pm.ParentsAtLevel(blockHeader, i)
|
||||
}
|
||||
|
||||
return parents
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package pruningproofmanager
|
||||
|
||||
import "github.com/kaspanet/kaspad/infrastructure/logger"
|
||||
|
||||
var log = logger.RegisterSubSystem("PPMN")
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/constants"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/hashset"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/pow"
|
||||
"github.com/kaspanet/kaspad/infrastructure/db/database"
|
||||
"github.com/kaspanet/kaspad/infrastructure/logger"
|
||||
"github.com/pkg/errors"
|
||||
"math/big"
|
||||
)
|
||||
@@ -28,7 +28,6 @@ type pruningProofManager struct {
|
||||
ghostdagManagers []model.GHOSTDAGManager
|
||||
reachabilityManagers []model.ReachabilityManager
|
||||
dagTraversalManagers []model.DAGTraversalManager
|
||||
parentsManager model.ParentsManager
|
||||
|
||||
ghostdagDataStores []model.GHOSTDAGDataStore
|
||||
pruningStore model.PruningStore
|
||||
@@ -40,9 +39,6 @@ type pruningProofManager struct {
|
||||
genesisHash *externalapi.DomainHash
|
||||
k externalapi.KType
|
||||
pruningProofM uint64
|
||||
|
||||
cachedPruningPoint *externalapi.DomainHash
|
||||
cachedProof *externalapi.PruningPointProof
|
||||
}
|
||||
|
||||
// New instantiates a new PruningManager
|
||||
@@ -53,7 +49,6 @@ func New(
|
||||
ghostdagManagers []model.GHOSTDAGManager,
|
||||
reachabilityManagers []model.ReachabilityManager,
|
||||
dagTraversalManagers []model.DAGTraversalManager,
|
||||
parentsManager model.ParentsManager,
|
||||
|
||||
ghostdagDataStores []model.GHOSTDAGDataStore,
|
||||
pruningStore model.PruningStore,
|
||||
@@ -73,7 +68,6 @@ func New(
|
||||
ghostdagManagers: ghostdagManagers,
|
||||
reachabilityManagers: reachabilityManagers,
|
||||
dagTraversalManagers: dagTraversalManagers,
|
||||
parentsManager: parentsManager,
|
||||
|
||||
ghostdagDataStores: ghostdagDataStores,
|
||||
pruningStore: pruningStore,
|
||||
@@ -89,33 +83,6 @@ func New(
|
||||
}
|
||||
|
||||
func (ppm *pruningProofManager) BuildPruningPointProof(stagingArea *model.StagingArea) (*externalapi.PruningPointProof, error) {
|
||||
onEnd := logger.LogAndMeasureExecutionTime(log, "BuildPruningPointProof")
|
||||
defer onEnd()
|
||||
|
||||
pruningPoint, err := ppm.pruningStore.PruningPoint(ppm.databaseContext, stagingArea)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if ppm.cachedPruningPoint != nil && ppm.cachedPruningPoint.Equal(pruningPoint) {
|
||||
return ppm.cachedProof, nil
|
||||
}
|
||||
|
||||
proof, err := ppm.buildPruningPointProof(stagingArea)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ppm.cachedProof = proof
|
||||
ppm.cachedPruningPoint = pruningPoint
|
||||
|
||||
return proof, nil
|
||||
}
|
||||
|
||||
func (ppm *pruningProofManager) buildPruningPointProof(stagingArea *model.StagingArea) (*externalapi.PruningPointProof, error) {
|
||||
onEnd := logger.LogAndMeasureExecutionTime(log, "buildPruningPointProof")
|
||||
defer onEnd()
|
||||
|
||||
pruningPoint, err := ppm.pruningStore.PruningPoint(ppm.databaseContext, stagingArea)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -130,33 +97,17 @@ func (ppm *pruningProofManager) buildPruningPointProof(stagingArea *model.Stagin
|
||||
return nil, err
|
||||
}
|
||||
|
||||
maxLevel := len(ppm.parentsManager.Parents(pruningPointHeader)) - 1
|
||||
maxLevel := len(pruningPointHeader.Parents()) - 1
|
||||
headersByLevel := make(map[int][]externalapi.BlockHeader)
|
||||
selectedTipByLevel := make([]*externalapi.DomainHash, maxLevel+1)
|
||||
pruningPointLevel := pruningPointHeader.BlockLevel()
|
||||
pruningPointLevel := pow.BlockLevel(pruningPointHeader)
|
||||
for blockLevel := maxLevel; blockLevel >= 0; blockLevel-- {
|
||||
var selectedTip *externalapi.DomainHash
|
||||
if blockLevel <= pruningPointLevel {
|
||||
selectedTip = pruningPoint
|
||||
} else {
|
||||
blockLevelParents := ppm.parentsManager.ParentsAtLevel(pruningPointHeader, blockLevel)
|
||||
selectedTipCandidates := make([]*externalapi.DomainHash, 0, len(blockLevelParents))
|
||||
|
||||
// In a pruned node, some pruning point parents might be missing, but we're guaranteed that its
|
||||
// selected parent is not missing.
|
||||
for _, parent := range blockLevelParents {
|
||||
_, err := ppm.ghostdagDataStores[blockLevel].Get(ppm.databaseContext, stagingArea, parent, false)
|
||||
if database.IsNotFoundError(err) {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
selectedTipCandidates = append(selectedTipCandidates, parent)
|
||||
}
|
||||
|
||||
selectedTip, err = ppm.ghostdagManagers[blockLevel].ChooseSelectedParent(stagingArea, selectedTipCandidates...)
|
||||
blockLevelParents := pruningPointHeader.ParentsAtLevel(blockLevel)
|
||||
selectedTip, err = ppm.ghostdagManagers[blockLevel].ChooseSelectedParent(stagingArea, []*externalapi.DomainHash(blockLevelParents)...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -297,9 +248,6 @@ func (ppm *pruningProofManager) blockAtDepth(stagingArea *model.StagingArea, gho
|
||||
}
|
||||
|
||||
func (ppm *pruningProofManager) ValidatePruningPointProof(pruningPointProof *externalapi.PruningPointProof) error {
|
||||
onEnd := logger.LogAndMeasureExecutionTime(log, "ValidatePruningPointProof")
|
||||
defer onEnd()
|
||||
|
||||
stagingArea := model.NewStagingArea()
|
||||
|
||||
if len(pruningPointProof.Headers) == 0 {
|
||||
@@ -309,8 +257,8 @@ func (ppm *pruningProofManager) ValidatePruningPointProof(pruningPointProof *ext
|
||||
level0Headers := pruningPointProof.Headers[0]
|
||||
pruningPointHeader := level0Headers[len(level0Headers)-1]
|
||||
pruningPoint := consensushashing.HeaderHash(pruningPointHeader)
|
||||
pruningPointBlockLevel := pruningPointHeader.BlockLevel()
|
||||
maxLevel := len(ppm.parentsManager.Parents(pruningPointHeader)) - 1
|
||||
pruningPointBlockLevel := pow.BlockLevel(pruningPointHeader)
|
||||
maxLevel := len(pruningPointHeader.Parents()) - 1
|
||||
if maxLevel >= len(pruningPointProof.Headers) {
|
||||
return errors.Wrapf(ruleerrors.ErrPruningProofEmpty, "proof has only %d levels while pruning point "+
|
||||
"has parents from %d levels", len(pruningPointProof.Headers), maxLevel+1)
|
||||
@@ -352,15 +300,15 @@ func (ppm *pruningProofManager) ValidatePruningPointProof(pruningPointProof *ext
|
||||
var selectedTip *externalapi.DomainHash
|
||||
for i, header := range headers {
|
||||
blockHash := consensushashing.HeaderHash(header)
|
||||
if header.BlockLevel() < blockLevel {
|
||||
if pow.BlockLevel(header) < blockLevel {
|
||||
return errors.Wrapf(ruleerrors.ErrPruningProofWrongBlockLevel, "block %s level is %d when it's "+
|
||||
"expected to be at least %d", blockHash, header.BlockLevel(), blockLevel)
|
||||
"expected to be at least %d", blockHash, pow.BlockLevel(header), blockLevel)
|
||||
}
|
||||
|
||||
blockHeaderStore.Stage(stagingArea, blockHash, header)
|
||||
|
||||
var parents []*externalapi.DomainHash
|
||||
for _, parent := range ppm.parentsManager.ParentsAtLevel(header, blockLevel) {
|
||||
for _, parent := range header.ParentsAtLevel(blockLevel) {
|
||||
_, err := ghostdagDataStores[blockLevel].Get(ppm.databaseContext, stagingArea, parent, false)
|
||||
if database.IsNotFoundError(err) {
|
||||
continue
|
||||
@@ -429,7 +377,7 @@ func (ppm *pruningProofManager) ValidatePruningPointProof(pruningPointProof *ext
|
||||
}
|
||||
}
|
||||
|
||||
if !selectedTip.Equal(pruningPoint) && !ppm.parentsManager.ParentsAtLevel(pruningPointHeader, blockLevel).Contains(selectedTip) {
|
||||
if !selectedTip.Equal(pruningPoint) && !pruningPointHeader.ParentsAtLevel(blockLevel).Contains(selectedTip) {
|
||||
return errors.Wrapf(ruleerrors.ErrPruningProofMissesBlocksBelowPruningPoint, "the selected tip %s at "+
|
||||
"level %d is not a parent of the pruning point", selectedTip, blockLevel)
|
||||
}
|
||||
@@ -447,7 +395,7 @@ func (ppm *pruningProofManager) ValidatePruningPointProof(pruningPointProof *ext
|
||||
return errors.Wrapf(ruleerrors.ErrPruningProofSelectedTipIsNotThePruningPoint, "the pruning "+
|
||||
"proof selected tip %s at level %d is not the pruning point", selectedTip, blockLevel)
|
||||
}
|
||||
} else if !ppm.parentsManager.ParentsAtLevel(pruningPointHeader, blockLevel).Contains(selectedTip) {
|
||||
} else if !pruningPointHeader.ParentsAtLevel(blockLevel).Contains(selectedTip) {
|
||||
return errors.Wrapf(ruleerrors.ErrPruningProofSelectedTipNotParentOfPruningPoint, "the pruning "+
|
||||
"proof selected tip %s at level %d is not a parent of the of the pruning point on the same "+
|
||||
"level", selectedTip, blockLevel)
|
||||
@@ -606,22 +554,19 @@ func (ppm *pruningProofManager) dagProcesses(
|
||||
}
|
||||
|
||||
func (ppm *pruningProofManager) ApplyPruningPointProof(stagingArea *model.StagingArea, pruningPointProof *externalapi.PruningPointProof) error {
|
||||
onEnd := logger.LogAndMeasureExecutionTime(log, "ApplyPruningPointProof")
|
||||
defer onEnd()
|
||||
|
||||
for blockLevel, headers := range pruningPointProof.Headers {
|
||||
var selectedTip *externalapi.DomainHash
|
||||
for i, header := range headers {
|
||||
blockHash := consensushashing.HeaderHash(header)
|
||||
if header.BlockLevel() < blockLevel {
|
||||
if pow.BlockLevel(header) < blockLevel {
|
||||
return errors.Wrapf(ruleerrors.ErrPruningProofWrongBlockLevel, "block %s level is %d when it's "+
|
||||
"expected to be at least %d", blockHash, header.BlockLevel(), blockLevel)
|
||||
"expected to be at least %d", blockHash, pow.BlockLevel(header), blockLevel)
|
||||
}
|
||||
|
||||
ppm.blockHeaderStore.Stage(stagingArea, blockHash, header)
|
||||
|
||||
var parents []*externalapi.DomainHash
|
||||
for _, parent := range ppm.parentsManager.ParentsAtLevel(header, blockLevel) {
|
||||
for _, parent := range header.ParentsAtLevel(blockLevel) {
|
||||
_, err := ppm.ghostdagDataStores[blockLevel].Get(ppm.databaseContext, stagingArea, parent, false)
|
||||
if database.IsNotFoundError(err) {
|
||||
continue
|
||||
|
||||
@@ -2,7 +2,6 @@ package blockheader
|
||||
|
||||
import (
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/pow"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
@@ -19,9 +18,6 @@ type blockHeader struct {
|
||||
blueScore uint64
|
||||
blueWork *big.Int
|
||||
pruningPoint *externalapi.DomainHash
|
||||
|
||||
isBlockLevelCached bool
|
||||
blockLevel int
|
||||
}
|
||||
|
||||
func (bh *blockHeader) BlueScore() uint64 {
|
||||
@@ -45,12 +41,10 @@ func (bh *blockHeader) ToImmutable() externalapi.BlockHeader {
|
||||
}
|
||||
|
||||
func (bh *blockHeader) SetNonce(nonce uint64) {
|
||||
bh.isBlockLevelCached = false
|
||||
bh.nonce = nonce
|
||||
}
|
||||
|
||||
func (bh *blockHeader) SetTimeInMilliseconds(timeInMilliseconds int64) {
|
||||
bh.isBlockLevelCached = false
|
||||
bh.timeInMilliseconds = timeInMilliseconds
|
||||
}
|
||||
|
||||
@@ -62,12 +56,16 @@ func (bh *blockHeader) Parents() []externalapi.BlockLevelParents {
|
||||
return bh.parents
|
||||
}
|
||||
|
||||
func (bh *blockHeader) DirectParents() externalapi.BlockLevelParents {
|
||||
if len(bh.parents) == 0 {
|
||||
func (bh *blockHeader) ParentsAtLevel(level int) externalapi.BlockLevelParents {
|
||||
if len(bh.parents) <= level {
|
||||
return externalapi.BlockLevelParents{}
|
||||
}
|
||||
|
||||
return bh.parents[0]
|
||||
return bh.parents[level]
|
||||
}
|
||||
|
||||
func (bh *blockHeader) DirectParents() externalapi.BlockLevelParents {
|
||||
return bh.ParentsAtLevel(0)
|
||||
}
|
||||
|
||||
func (bh *blockHeader) HashMerkleRoot() *externalapi.DomainHash {
|
||||
@@ -179,15 +177,6 @@ func (bh *blockHeader) ToMutable() externalapi.MutableBlockHeader {
|
||||
return bh.clone()
|
||||
}
|
||||
|
||||
func (bh *blockHeader) BlockLevel() int {
|
||||
if !bh.isBlockLevelCached {
|
||||
bh.blockLevel = pow.BlockLevel(bh)
|
||||
bh.isBlockLevelCached = true
|
||||
}
|
||||
|
||||
return bh.blockLevel
|
||||
}
|
||||
|
||||
// NewImmutableBlockHeader returns a new immutable header
|
||||
func NewImmutableBlockHeader(
|
||||
version uint16,
|
||||
|
||||
@@ -36,8 +36,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
8,
|
||||
big.NewInt(9),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{10}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -57,8 +55,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
headersToCompareTo: []headerToCompare{
|
||||
{
|
||||
@@ -79,8 +75,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: true,
|
||||
},
|
||||
@@ -98,8 +92,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -119,8 +111,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -138,8 +128,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -157,8 +145,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -176,8 +162,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -195,8 +179,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -214,8 +196,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -233,8 +213,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -252,8 +230,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -271,8 +247,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -290,8 +264,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
100,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -309,8 +281,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(100),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{11}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
@@ -328,8 +298,6 @@ func TestDomainBlockHeader_Equal(t *testing.T) {
|
||||
9,
|
||||
big.NewInt(10),
|
||||
externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{100}),
|
||||
false,
|
||||
0,
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
|
||||
@@ -39,7 +39,7 @@ func (mat *matrix) computeRank() int {
|
||||
var rowSelected [64]bool
|
||||
for i := 0; i < 64; i++ {
|
||||
var j int
|
||||
for j = 0; j < 64; j++ {
|
||||
for j := 0; j < 64; j++ {
|
||||
if !rowSelected[j] && math.Abs(B[j][i]) > eps {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@ package pow
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/hashes"
|
||||
"math/rand"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -20,135 +18,6 @@ func BenchmarkMatrix_HeavyHash(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkMatrix_Generate(b *testing.B) {
|
||||
r := rand.New(rand.NewSource(0))
|
||||
h := [32]byte{}
|
||||
r.Read(h[:])
|
||||
hash := externalapi.NewDomainHashFromByteArray(&h)
|
||||
for i := 0; i < b.N; i++ {
|
||||
generateMatrix(hash)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkMatrix_Rank(b *testing.B) {
|
||||
r := rand.New(rand.NewSource(0))
|
||||
h := [32]byte{}
|
||||
r.Read(h[:])
|
||||
hash := externalapi.NewDomainHashFromByteArray(&h)
|
||||
matrix := generateMatrix(hash)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
matrix.computeRank()
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatrix_Rank(t *testing.T) {
|
||||
var mat matrix
|
||||
if mat.computeRank() != 0 {
|
||||
t.Fatalf("The zero matrix should have rank 0, instead got: %d", mat.computeRank())
|
||||
}
|
||||
|
||||
r := rand.New(rand.NewSource(0))
|
||||
h := [32]byte{}
|
||||
r.Read(h[:])
|
||||
hash := externalapi.NewDomainHashFromByteArray(&h)
|
||||
mat = *generateMatrix(hash)
|
||||
|
||||
if mat.computeRank() != 64 {
|
||||
t.Fatalf("generateMatrix() should always return full rank matrix, instead got: %d", mat.computeRank())
|
||||
}
|
||||
|
||||
for i := range mat {
|
||||
mat[0][i] = mat[1][i] * 2
|
||||
}
|
||||
if mat.computeRank() != 63 {
|
||||
t.Fatalf("Made a linear depenency between 2 rows, rank should be 63, instead got: %d", mat.computeRank())
|
||||
}
|
||||
|
||||
for i := range mat {
|
||||
mat[33][i] = mat[32][i] * 3
|
||||
}
|
||||
if mat.computeRank() != 62 {
|
||||
t.Fatalf("Made anoter linear depenency between 2 rows, rank should be 62, instead got: %d", mat.computeRank())
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateMatrix(t *testing.T) {
|
||||
hashBytes := [32]byte{42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42}
|
||||
hash := externalapi.NewDomainHashFromByteArray(&hashBytes)
|
||||
expectedMatrix := matrix{
|
||||
{4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 2, 10, 2, 10, 2, 10, 2, 10, 2, 10, 2, 10, 2, 10, 2, 10, 14, 1, 2, 2, 14, 10, 4, 12, 4, 12, 10, 10, 10, 10, 10, 10},
|
||||
{9, 11, 1, 11, 1, 11, 9, 11, 9, 11, 9, 3, 12, 13, 11, 5, 15, 15, 5, 0, 6, 8, 1, 8, 6, 11, 15, 5, 3, 6, 7, 3, 2, 15, 14, 3, 7, 11, 14, 7, 3, 6, 14, 12, 3, 9, 5, 1, 1, 0, 8, 4, 10, 15, 9, 10, 6, 13, 1, 1, 7, 4, 4, 6},
|
||||
{2, 6, 0, 8, 11, 15, 4, 0, 5, 2, 7, 13, 15, 3, 11, 12, 6, 2, 1, 8, 13, 4, 11, 4, 10, 14, 13, 2, 6, 15, 10, 6, 6, 5, 6, 9, 3, 3, 3, 1, 9, 12, 12, 15, 6, 0, 1, 5, 7, 13, 14, 1, 10, 10, 5, 14, 4, 0, 12, 13, 2, 15, 8, 4},
|
||||
{8, 6, 5, 1, 0, 6, 4, 8, 13, 0, 8, 12, 7, 2, 4, 3, 10, 5, 9, 3, 12, 13, 2, 4, 13, 14, 7, 7, 9, 12, 10, 8, 11, 6, 14, 3, 12, 8, 8, 0, 2, 10, 0, 9, 1, 9, 7, 8, 5, 2, 9, 13, 15, 6, 13, 10, 1, 9, 1, 10, 6, 2, 10, 9},
|
||||
{4, 2, 6, 14, 4, 2, 5, 7, 15, 6, 0, 4, 11, 9, 12, 0, 3, 2, 0, 4, 10, 5, 12, 3, 3, 4, 10, 1, 0, 13, 3, 12, 15, 0, 7, 10, 2, 2, 15, 0, 2, 15, 8, 2, 15, 12, 10, 6, 6, 2, 13, 3, 8, 14, 3, 13, 10, 5, 4, 5, 1, 6, 5, 10},
|
||||
{0, 3, 13, 12, 11, 4, 11, 13, 1, 12, 4, 11, 15, 14, 13, 4, 7, 1, 3, 0, 10, 3, 8, 8, 1, 2, 5, 14, 4, 5, 14, 1, 1, 3, 3, 1, 5, 15, 7, 5, 11, 8, 8, 12, 10, 5, 7, 9, 2, 10, 13, 11, 4, 2, 12, 15, 10, 6, 6, 0, 6, 6, 3, 12},
|
||||
{9, 12, 3, 3, 5, 8, 12, 13, 7, 4, 5, 11, 4, 0, 7, 2, 2, 15, 12, 14, 12, 5, 4, 2, 8, 8, 8, 13, 6, 1, 1, 5, 0, 15, 12, 13, 8, 5, 0, 4, 13, 1, 6, 1, 12, 14, 1, 0, 13, 12, 10, 10, 1, 4, 13, 13, 8, 4, 15, 13, 6, 6, 14, 10},
|
||||
{14, 15, 8, 0, 7, 2, 5, 10, 5, 3, 12, 0, 11, 3, 4, 2, 8, 11, 6, 14, 14, 3, 3, 12, 3, 7, 6, 2, 6, 12, 15, 1, 1, 13, 0, 6, 9, 9, 7, 7, 13, 4, 4, 2, 15, 5, 2, 15, 13, 13, 10, 6, 9, 15, 2, 9, 6, 10, 6, 14, 14, 3, 5, 11},
|
||||
{6, 4, 7, 8, 11, 0, 13, 11, 0, 7, 0, 0, 13, 6, 3, 11, 15, 14, 10, 2, 7, 8, 13, 14, 8, 15, 10, 8, 14, 6, 10, 14, 3, 11, 5, 11, 13, 5, 3, 12, 3, 0, 2, 0, 6, 14, 4, 12, 4, 4, 8, 15, 7, 8, 12, 11, 3, 9, 5, 13, 10, 14, 13, 4},
|
||||
{10, 0, 0, 15, 1, 4, 13, 3, 15, 10, 2, 5, 11, 2, 9, 14, 7, 3, 2, 8, 6, 15, 0, 12, 1, 4, 1, 9, 3, 0, 15, 8, 9, 13, 0, 7, 9, 10, 6, 14, 3, 7, 9, 7, 4, 0, 11, 8, 4, 6, 5, 8, 8, 0, 5, 14, 7, 12, 12, 2, 5, 6, 5, 6},
|
||||
{12, 0, 0, 14, 8, 3, 0, 3, 13, 10, 5, 13, 5, 7, 2, 4, 13, 11, 3, 1, 11, 2, 14, 5, 10, 5, 5, 9, 12, 15, 12, 8, 1, 0, 11, 13, 8, 1, 1, 11, 10, 0, 11, 15, 13, 9, 12, 14, 5, 4, 5, 14, 2, 7, 2, 1, 4, 12, 11, 11, 9, 12, 11, 15},
|
||||
{3, 15, 9, 8, 13, 12, 15, 7, 8, 7, 14, 6, 10, 3, 0, 5, 2, 2, 6, 6, 3, 2, 5, 12, 11, 2, 10, 11, 13, 3, 9, 7, 7, 6, 8, 15, 14, 14, 11, 11, 9, 7, 1, 3, 8, 5, 11, 11, 1, 2, 15, 8, 13, 8, 11, 4, 1, 5, 3, 12, 5, 3, 7, 7},
|
||||
{13, 13, 2, 14, 4, 3, 15, 2, 0, 15, 1, 5, 4, 1, 5, 1, 4, 14, 5, 1, 11, 13, 15, 1, 3, 3, 5, 13, 14, 1, 0, 4, 6, 1, 15, 7, 7, 0, 15, 8, 15, 3, 14, 7, 7, 8, 12, 10, 2, 14, 9, 2, 11, 11, 7, 10, 4, 3, 12, 13, 4, 13, 0, 14},
|
||||
{12, 14, 15, 15, 2, 0, 0, 13, 4, 6, 4, 2, 14, 11, 5, 6, 14, 8, 14, 7, 13, 15, 6, 15, 7, 9, 1, 0, 11, 9, 9, 0, 2, 12, 8, 8, 14, 11, 7, 5, 3, 0, 11, 12, 9, 2, 8, 9, 0, 0, 9, 8, 9, 8, 2, 14, 12, 2, 0, 14, 13, 8, 4, 10},
|
||||
{7, 10, 1, 15, 12, 14, 7, 4, 7, 13, 4, 8, 13, 12, 1, 7, 10, 6, 5, 14, 14, 3, 14, 4, 11, 14, 6, 12, 15, 12, 15, 12, 4, 5, 9, 8, 7, 7, 3, 0, 5, 7, 3, 8, 4, 4, 7, 5, 6, 12, 13, 0, 12, 10, 2, 5, 14, 9, 6, 4, 13, 13, 14, 5},
|
||||
{14, 5, 8, 3, 4, 15, 13, 14, 14, 10, 7, 14, 15, 2, 11, 14, 13, 13, 12, 10, 6, 9, 5, 5, 6, 13, 15, 13, 7, 0, 15, 11, 4, 12, 15, 7, 7, 4, 3, 11, 8, 14, 5, 10, 2, 4, 4, 12, 3, 6, 1, 9, 15, 1, 1, 13, 7, 5, 0, 14, 15, 7, 8, 6},
|
||||
{1, 2, 10, 5, 2, 13, 1, 11, 15, 10, 4, 9, 9, 12, 14, 13, 3, 5, 0, 3, 7, 11, 10, 3, 12, 5, 10, 2, 13, 7, 1, 7, 13, 8, 2, 8, 3, 14, 10, 3, 5, 12, 0, 9, 3, 9, 11, 2, 10, 9, 0, 6, 4, 0, 1, 14, 11, 0, 8, 6, 1, 15, 3, 10},
|
||||
{13, 9, 0, 5, 8, 7, 12, 15, 10, 10, 5, 1, 1, 7, 6, 1, 14, 5, 15, 2, 3, 5, 3, 5, 7, 3, 7, 7, 1, 4, 3, 14, 5, 0, 12, 0, 12, 10, 10, 6, 12, 6, 3, 5, 5, 11, 10, 1, 11, 3, 13, 3, 9, 11, 1, 7, 14, 14, 0, 8, 15, 5, 2, 7},
|
||||
{8, 5, 11, 6, 15, 0, 1, 13, 1, 6, 7, 15, 4, 3, 14, 12, 9, 3, 11, 6, 4, 12, 1, 11, 6, 12, 5, 11, 1, 12, 2, 3, 1, 2, 11, 12, 0, 5, 11, 5, 3, 13, 11, 3, 11, 14, 10, 8, 3, 9, 4, 8, 13, 11, 9, 11, 2, 4, 12, 3, 0, 14, 7, 11},
|
||||
{10, 11, 4, 10, 7, 8, 3, 14, 15, 8, 15, 6, 9, 8, 5, 6, 12, 1, 15, 6, 5, 5, 14, 13, 2, 12, 14, 6, 5, 5, 14, 9, 1, 10, 11, 14, 8, 6, 14, 11, 1, 15, 6, 11, 11, 8, 1, 2, 8, 5, 4, 15, 6, 8, 0, 8, 0, 11, 0, 1, 0, 7, 8, 15},
|
||||
{0, 15, 5, 0, 11, 4, 4, 2, 0, 4, 8, 12, 2, 2, 0, 8, 1, 2, 6, 5, 6, 12, 3, 1, 12, 1, 6, 10, 2, 5, 0, 2, 0, 11, 8, 6, 13, 4, 14, 4, 15, 5, 8, 11, 9, 6, 2, 6, 9, 1, 4, 2, 14, 10, 4, 4, 1, 1, 11, 8, 6, 11, 11, 9},
|
||||
{7, 3, 6, 5, 9, 1, 11, 0, 15, 13, 13, 13, 4, 14, 14, 12, 3, 7, 9, 3, 1, 6, 5, 9, 7, 6, 2, 11, 10, 4, 11, 14, 10, 13, 11, 8, 11, 8, 1, 15, 5, 0, 10, 5, 6, 0, 5, 15, 11, 6, 6, 4, 10, 11, 8, 12, 0, 10, 11, 11, 11, 1, 13, 6},
|
||||
{7, 15, 0, 0, 11, 5, 7, 13, 3, 7, 3, 2, 5, 12, 6, 11, 14, 4, 9, 8, 9, 9, 13, 0, 15, 2, 13, 2, 15, 6, 15, 1, 1, 7, 4, 0, 10, 1, 8, 14, 0, 10, 12, 4, 5, 13, 9, 0, 7, 12, 13, 11, 11, 8, 8, 15, 2, 15, 4, 4, 9, 3, 10, 7},
|
||||
{0, 9, 3, 5, 14, 6, 7, 14, 7, 2, 13, 7, 3, 15, 9, 15, 2, 8, 0, 4, 6, 0, 15, 6, 2, 1, 14, 8, 5, 8, 2, 4, 2, 11, 9, 2, 15, 13, 11, 12, 8, 15, 3, 13, 2, 2, 10, 13, 1, 8, 7, 15, 13, 6, 7, 7, 4, 3, 14, 7, 0, 9, 15, 11},
|
||||
{8, 13, 7, 7, 8, 8, 7, 8, 1, 4, 10, 1, 12, 4, 14, 11, 7, 12, 15, 0, 10, 15, 9, 2, 14, 2, 14, 2, 4, 5, 13, 3, 2, 10, 0, 15, 7, 6, 8, 11, 7, 6, 10, 10, 4, 7, 10, 6, 6, 14, 10, 4, 14, 6, 12, 2, 8, 1, 9, 13, 3, 4, 3, 14},
|
||||
{10, 10, 6, 3, 8, 5, 10, 7, 11, 10, 9, 4, 8, 14, 9, 10, 0, 9, 8, 14, 11, 15, 8, 13, 13, 7, 13, 13, 13, 9, 12, 11, 6, 3, 9, 6, 0, 0, 6, 6, 11, 6, 4, 8, 1, 5, 1, 7, 9, 6, 13, 4, 3, 8, 8, 11, 9, 10, 6, 11, 12, 13, 14, 14},
|
||||
{14, 10, 0, 15, 14, 4, 3, 0, 12, 4, 0, 14, 11, 9, 0, 6, 4, 6, 0, 9, 8, 14, 4, 4, 6, 8, 2, 8, 10, 3, 8, 0, 1, 1, 15, 4, 2, 4, 13, 9, 9, 4, 0, 5, 5, 1, 2, 5, 11, 6, 2, 1, 7, 8, 10, 10, 1, 5, 8, 6, 7, 0, 4, 14},
|
||||
{0, 15, 10, 11, 13, 12, 7, 7, 4, 0, 9, 5, 2, 8, 0, 10, 6, 6, 7, 5, 6, 7, 9, 0, 1, 4, 8, 14, 10, 3, 5, 5, 11, 5, 1, 10, 6, 10, 0, 14, 1, 15, 11, 12, 8, 2, 7, 8, 4, 0, 3, 11, 9, 15, 3, 5, 15, 15, 14, 15, 3, 4, 5, 14},
|
||||
{5, 12, 12, 8, 0, 0, 14, 1, 4, 15, 3, 2, 2, 6, 1, 10, 7, 10, 14, 5, 14, 0, 8, 5, 9, 0, 12, 8, 9, 10, 3, 12, 3, 2, 0, 0, 12, 12, 7, 13, 2, 6, 4, 7, 10, 10, 14, 1, 11, 6, 10, 3, 12, 2, 1, 10, 7, 13, 10, 12, 14, 11, 14, 8},
|
||||
{9, 5, 3, 12, 4, 3, 10, 14, 7, 5, 11, 12, 2, 13, 9, 8, 5, 2, 6, 2, 4, 9, 10, 10, 4, 3, 4, 0, 11, 1, 10, 9, 4, 10, 4, 5, 8, 11, 1, 7, 13, 7, 6, 6, 3, 12, 0, 0, 15, 6, 12, 12, 13, 7, 14, 14, 11, 15, 7, 14, 12, 6, 15, 2},
|
||||
{15, 2, 0, 12, 15, 14, 8, 14, 7, 14, 0, 3, 3, 11, 12, 2, 3, 14, 13, 5, 12, 9, 6, 11, 7, 4, 5, 1, 7, 12, 0, 11, 1, 5, 6, 6, 8, 6, 12, 2, 12, 3, 10, 3, 4, 10, 3, 3, 3, 10, 10, 14, 3, 13, 15, 0, 7, 6, 15, 6, 13, 7, 4, 11},
|
||||
{11, 15, 5, 14, 0, 1, 1, 14, 2, 3, 15, 14, 4, 3, 11, 1, 6, 6, 0, 12, 3, 5, 15, 6, 3, 11, 13, 11, 7, 7, 8, 11, 5, 9, 10, 10, 9, 14, 7, 1, 7, 2, 8, 6, 6, 5, 1, 9, 6, 5, 8, 14, 2, 14, 2, 9, 3, 3, 4, 15, 13, 5, 2, 7},
|
||||
{7, 8, 13, 9, 15, 8, 11, 7, 1, 9, 15, 12, 6, 9, 3, 1, 10, 10, 11, 0, 0, 8, 14, 5, 11, 12, 14, 4, 3, 9, 12, 9, 14, 0, 0, 9, 12, 4, 1, 13, 3, 6, 3, 4, 13, 10, 2, 9, 3, 7, 7, 10, 7, 10, 10, 3, 5, 15, 8, 9, 11, 7, 1, 14},
|
||||
{5, 5, 9, 1, 15, 3, 3, 11, 6, 11, 13, 13, 4, 12, 7, 12, 4, 8, 14, 13, 7, 12, 13, 8, 10, 2, 1, 12, 11, 7, 0, 8, 10, 9, 15, 1, 3, 9, 10, 0, 9, 1, 14, 1, 1, 9, 2, 2, 8, 9, 5, 6, 3, 2, 15, 9, 15, 6, 3, 11, 14, 4, 0, 4},
|
||||
{9, 2, 10, 2, 0, 9, 6, 13, 13, 0, 13, 14, 3, 12, 1, 15, 9, 3, 12, 2, 5, 15, 6, 6, 15, 11, 7, 11, 0, 4, 0, 11, 10, 12, 7, 9, 3, 0, 2, 2, 13, 13, 9, 6, 9, 2, 6, 4, 3, 6, 5, 10, 10, 9, 7, 2, 4, 9, 13, 11, 2, 13, 6, 8},
|
||||
{13, 15, 9, 8, 6, 2, 3, 2, 2, 12, 5, 3, 8, 6, 11, 6, 15, 7, 10, 3, 15, 8, 7, 5, 3, 8, 4, 2, 11, 1, 0, 4, 1, 1, 6, 1, 13, 6, 5, 1, 2, 6, 7, 10, 4, 3, 10, 6, 2, 0, 7, 13, 15, 1, 13, 0, 12, 10, 15, 6, 2, 4, 14, 3},
|
||||
{5, 11, 14, 4, 0, 7, 12, 4, 4, 14, 12, 3, 4, 10, 7, 14, 6, 4, 14, 7, 0, 12, 5, 9, 15, 6, 15, 6, 3, 12, 0, 10, 11, 7, 1, 14, 13, 5, 1, 14, 5, 15, 12, 1, 9, 13, 9, 13, 14, 5, 10, 11, 12, 10, 15, 11, 9, 13, 2, 14, 9, 12, 2, 11},
|
||||
{2, 12, 5, 7, 1, 5, 2, 11, 8, 4, 15, 6, 9, 14, 5, 1, 15, 4, 3, 1, 11, 4, 2, 1, 4, 5, 4, 4, 7, 3, 3, 12, 4, 3, 2, 15, 13, 1, 14, 15, 1, 4, 6, 11, 13, 15, 6, 12, 12, 13, 6, 8, 10, 0, 10, 12, 1, 10, 3, 2, 9, 8, 2, 8},
|
||||
{10, 12, 12, 6, 8, 5, 4, 4, 5, 3, 6, 7, 15, 5, 10, 3, 8, 15, 14, 5, 6, 2, 14, 4, 1, 7, 1, 3, 12, 3, 12, 4, 10, 15, 6, 6, 0, 6, 6, 8, 6, 9, 5, 7, 5, 1, 9, 2, 4, 9, 0, 8, 1, 1, 14, 3, 7, 14, 8, 9, 0, 4, 11, 7},
|
||||
{13, 11, 14, 7, 0, 4, 0, 10, 12, 11, 10, 8, 6, 12, 13, 15, 9, 2, 14, 9, 3, 0, 12, 14, 11, 15, 4, 7, 15, 14, 4, 8, 15, 12, 9, 14, 7, 7, 9, 13, 14, 14, 4, 9, 13, 8, 1, 13, 6, 3, 12, 7, 0, 15, 6, 15, 7, 2, 3, 0, 9, 5, 13, 0},
|
||||
{3, 8, 12, 11, 5, 9, 9, 14, 8, 14, 14, 5, 9, 9, 12, 10, 3, 12, 13, 0, 0, 0, 6, 7, 12, 4, 2, 3, 8, 8, 9, 15, 11, 1, 12, 13, 10, 15, 11, 1, 2, 13, 10, 1, 7, 2, 7, 11, 8, 15, 7, 6, 4, 6, 5, 11, 11, 15, 2, 1, 11, 1, 1, 8},
|
||||
{10, 7, 7, 1, 4, 13, 9, 10, 2, 2, 3, 7, 12, 8, 5, 5, 5, 5, 3, 1, 5, 6, 8, 2, 8, 11, 5, 0, 4, 12, 12, 6, 7, 9, 14, 10, 11, 8, 0, 9, 11, 4, 14, 7, 7, 8, 2, 15, 12, 7, 4, 4, 13, 2, 0, 3, 14, 0, 1, 5, 2, 15, 7, 11},
|
||||
{3, 8, 10, 4, 1, 7, 3, 13, 5, 14, 0, 9, 3, 1, 0, 11, 2, 15, 4, 9, 6, 5, 14, 0, 2, 8, 1, 14, 7, 6, 1, 5, 5, 7, 2, 0, 5, 3, 4, 15, 13, 10, 9, 13, 13, 12, 5, 11, 11, 14, 13, 10, 8, 14, 0, 8, 1, 7, 2, 10, 12, 12, 1, 11},
|
||||
{11, 14, 4, 13, 3, 11, 10, 6, 15, 2, 5, 10, 14, 4, 13, 3, 12, 7, 12, 10, 4, 0, 0, 1, 14, 6, 1, 2, 2, 12, 9, 2, 3, 11, 1, 4, 10, 4, 4, 7, 7, 12, 4, 3, 12, 11, 9, 3, 15, 13, 6, 13, 7, 11, 5, 12, 5, 13, 15, 12, 0, 13, 12, 9},
|
||||
{8, 7, 2, 2, 5, 3, 10, 15, 10, 8, 1, 0, 4, 5, 7, 6, 15, 13, 2, 14, 6, 2, 9, 5, 9, 0, 5, 12, 8, 6, 4, 12, 6, 8, 14, 15, 7, 15, 11, 2, 2, 12, 7, 9, 7, 11, 15, 7, 0, 4, 5, 13, 7, 2, 5, 9, 0, 5, 7, 6, 7, 12, 4, 1},
|
||||
{11, 4, 2, 13, 6, 10, 9, 4, 12, 9, 9, 6, 4, 2, 14, 14, 9, 5, 5, 15, 15, 9, 8, 11, 4, 2, 8, 11, 14, 3, 8, 10, 14, 9, 6, 6, 4, 7, 11, 2, 3, 7, 5, 1, 14, 2, 9, 4, 0, 1, 10, 7, 6, 7, 1, 3, 13, 7, 3, 2, 12, 3, 6, 6},
|
||||
{11, 1, 14, 3, 14, 3, 9, 9, 0, 11, 14, 6, 14, 7, 14, 8, 4, 2, 5, 6, 13, 3, 4, 10, 8, 8, 10, 11, 5, 1, 15, 15, 7, 0, 4, 14, 15, 13, 14, 13, 3, 2, 1, 6, 0, 6, 6, 4, 15, 6, 0, 12, 5, 11, 1, 7, 3, 3, 13, 12, 12, 6, 3, 2},
|
||||
{7, 2, 10, 14, 14, 13, 4, 14, 10, 6, 0, 2, 7, 7, 2, 5, 14, 1, 5, 14, 15, 1, 2, 9, 2, 13, 1, 3, 6, 1, 3, 13, 10, 6, 11, 13, 1, 7, 13, 15, 2, 11, 9, 6, 13, 7, 9, 2, 3, 13, 10, 10, 6, 2, 5, 9, 1, 3, 0, 3, 1, 5, 3, 12},
|
||||
{11, 14, 4, 2, 10, 11, 15, 5, 9, 7, 8, 11, 10, 9, 5, 7, 14, 3, 12, 2, 7, 15, 12, 15, 4, 15, 12, 9, 2, 6, 6, 6, 8, 5, 0, 7, 14, 15, 14, 14, 3, 12, 7, 12, 2, 4, 1, 7, 1, 3, 4, 7, 1, 9, 11, 15, 15, 3, 7, 1, 10, 9, 14, 14},
|
||||
{4, 13, 11, 1, 9, 6, 5, 1, 11, 6, 6, 8, 3, 9, 8, 15, 13, 12, 3, 13, 5, 9, 10, 5, 12, 1, 15, 14, 12, 1, 10, 11, 5, 7, 3, 12, 9, 12, 0, 2, 2, 3, 14, 4, 2, 13, 1, 15, 11, 8, 3, 13, 0, 10, 5, 4, 6, 0, 14, 8, 1, 0, 6, 15},
|
||||
{15, 2, 0, 5, 2, 14, 9, 0, 10, 5, 12, 8, 5, 6, 0, 1, 9, 4, 4, 1, 4, 6, 14, 5, 3, 0, 2, 2, 14, 9, 7, 0, 2, 15, 12, 0, 10, 12, 9, 12, 15, 1, 9, 4, 15, 3, 0, 13, 0, 6, 5, 0, 2, 6, 11, 9, 13, 15, 6, 3, 5, 4, 0, 8},
|
||||
{4, 14, 8, 14, 13, 4, 4, 10, 6, 12, 15, 11, 7, 2, 15, 6, 9, 9, 1, 11, 13, 2, 7, 10, 4, 4, 5, 12, 14, 15, 8, 5, 6, 1, 11, 15, 4, 11, 5, 2, 5, 7, 3, 4, 5, 7, 3, 8, 10, 13, 7, 5, 6, 5, 10, 1, 12, 13, 3, 6, 2, 8, 7, 15},
|
||||
{3, 15, 4, 9, 14, 12, 6, 1, 7, 0, 7, 15, 10, 6, 5, 5, 15, 5, 9, 4, 7, 6, 14, 2, 1, 4, 10, 3, 12, 1, 7, 1, 0, 10, 2, 11, 14, 13, 7, 10, 5, 11, 5, 11, 15, 5, 0, 3, 15, 1, 2, 14, 13, 13, 10, 9, 15, 12, 10, 5, 2, 10, 0, 6},
|
||||
{4, 6, 5, 13, 11, 10, 15, 4, 2, 15, 13, 6, 7, 7, 4, 0, 4, 6, 7, 4, 9, 1, 6, 7, 6, 1, 4, 2, 0, 11, 6, 3, 14, 5, 9, 2, 2, 10, 1, 2, 13, 14, 4, 11, 4, 7, 12, 9, 8, 2, 2, 9, 5, 7, 9, 12, 8, 15, 0, 9, 12, 11, 1, 12},
|
||||
{11, 12, 11, 9, 8, 15, 4, 12, 13, 10, 6, 6, 6, 12, 3, 0, 6, 15, 15, 10, 6, 12, 5, 7, 10, 2, 7, 1, 6, 12, 9, 11, 11, 14, 1, 12, 15, 0, 6, 2, 12, 15, 4, 15, 14, 8, 3, 4, 15, 4, 13, 3, 14, 1, 3, 7, 6, 13, 9, 1, 0, 12, 4, 14},
|
||||
{12, 11, 13, 10, 10, 10, 3, 7, 12, 3, 13, 9, 6, 0, 12, 10, 4, 11, 5, 4, 11, 5, 7, 14, 6, 10, 12, 12, 13, 15, 12, 1, 13, 15, 15, 7, 1, 2, 8, 6, 1, 12, 12, 0, 4, 3, 3, 3, 7, 8, 9, 10, 7, 7, 0, 0, 11, 13, 15, 4, 9, 5, 10, 9},
|
||||
{6, 12, 3, 0, 9, 11, 6, 4, 9, 9, 1, 5, 9, 14, 3, 7, 15, 3, 5, 0, 5, 11, 7, 6, 13, 5, 10, 2, 12, 10, 2, 6, 0, 1, 1, 13, 9, 3, 11, 7, 8, 2, 10, 9, 13, 6, 6, 4, 12, 0, 3, 10, 9, 4, 15, 11, 14, 1, 9, 3, 0, 14, 6, 1},
|
||||
{11, 14, 10, 10, 11, 6, 4, 7, 10, 0, 7, 9, 3, 2, 13, 13, 9, 9, 2, 3, 3, 14, 10, 4, 14, 1, 10, 7, 14, 4, 9, 15, 3, 11, 5, 10, 7, 8, 3, 0, 1, 2, 2, 3, 12, 9, 6, 2, 11, 15, 3, 9, 3, 6, 8, 0, 4, 5, 7, 3, 0, 14, 7, 9},
|
||||
{4, 11, 13, 12, 6, 2, 3, 15, 15, 3, 5, 1, 0, 5, 10, 2, 5, 3, 7, 10, 15, 0, 5, 3, 2, 10, 12, 10, 8, 3, 9, 15, 5, 3, 7, 13, 5, 7, 13, 12, 5, 10, 2, 9, 10, 1, 9, 4, 14, 1, 10, 13, 1, 2, 2, 12, 5, 3, 14, 7, 7, 8, 13, 13},
|
||||
{10, 12, 11, 10, 0, 15, 4, 3, 0, 8, 3, 0, 15, 0, 3, 10, 10, 9, 15, 3, 13, 3, 8, 3, 8, 2, 14, 7, 1, 6, 13, 8, 2, 2, 12, 3, 3, 0, 10, 12, 0, 1, 1, 7, 5, 0, 13, 10, 7, 13, 9, 9, 13, 7, 0, 1, 0, 2, 14, 2, 13, 0, 8, 3},
|
||||
{11, 3, 11, 10, 12, 15, 11, 6, 14, 8, 8, 5, 7, 11, 3, 1, 13, 7, 13, 4, 15, 7, 2, 3, 8, 7, 3, 8, 9, 15, 10, 15, 9, 0, 5, 4, 1, 7, 13, 8, 2, 7, 1, 10, 1, 12, 12, 1, 7, 12, 13, 5, 14, 10, 9, 15, 12, 2, 10, 3, 10, 3, 9, 12},
|
||||
{9, 8, 11, 0, 5, 6, 1, 5, 9, 1, 0, 12, 12, 0, 12, 11, 2, 8, 4, 0, 1, 7, 7, 5, 1, 14, 1, 9, 13, 7, 2, 12, 8, 9, 12, 13, 1, 11, 5, 3, 12, 14, 15, 4, 9, 8, 12, 7, 11, 1, 3, 9, 11, 5, 7, 14, 4, 6, 12, 3, 4, 12, 7, 9},
|
||||
{10, 12, 2, 14, 14, 1, 11, 8, 3, 7, 13, 7, 2, 1, 14, 13, 7, 6, 15, 8, 15, 12, 13, 10, 11, 15, 4, 2, 6, 13, 12, 3, 2, 10, 15, 14, 10, 11, 8, 14, 9, 3, 12, 9, 15, 2, 14, 14, 5, 13, 7, 6, 2, 1, 1, 4, 1, 0, 13, 10, 1, 0, 2, 9},
|
||||
{10, 5, 11, 14, 12, 1, 12, 7, 12, 8, 10, 5, 6, 10, 0, 7, 5, 6, 11, 11, 13, 12, 0, 13, 0, 6, 11, 0, 14, 4, 2, 1, 12, 7, 1, 10, 7, 15, 5, 3, 14, 15, 1, 3, 1, 2, 10, 4, 11, 8, 2, 11, 2, 5, 5, 4, 15, 5, 10, 3, 1, 7, 2, 14},
|
||||
}
|
||||
mat := generateMatrix(hash)
|
||||
|
||||
if *mat != expectedMatrix {
|
||||
t.Fatal("The generated matrix doesn't match the test vector")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatrix_HeavyHash(t *testing.T) {
|
||||
expected, err := hex.DecodeString("87689f379943eaf9b7475ca95325687772bfcc68fc7899caeb4409ec4590c325")
|
||||
if err != nil {
|
||||
|
||||
@@ -186,8 +186,6 @@ type Params struct {
|
||||
FixedSubsidySwitchPruningPointInterval uint64
|
||||
|
||||
FixedSubsidySwitchHashRateThreshold *big.Int
|
||||
|
||||
HardForkOmitGenesisFromParentsDAAScore uint64
|
||||
}
|
||||
|
||||
// NormalizeRPCServerAddress returns addr with the current network default
|
||||
@@ -266,7 +264,6 @@ var MainnetParams = Params{
|
||||
PruningProofM: defaultPruningProofM,
|
||||
FixedSubsidySwitchPruningPointInterval: defaultFixedSubsidySwitchPruningPointInterval,
|
||||
FixedSubsidySwitchHashRateThreshold: big.NewInt(150_000_000_000),
|
||||
HardForkOmitGenesisFromParentsDAAScore: 2e6,
|
||||
}
|
||||
|
||||
// TestnetParams defines the network parameters for the test Kaspa network.
|
||||
@@ -329,7 +326,6 @@ var TestnetParams = Params{
|
||||
PruningProofM: defaultPruningProofM,
|
||||
FixedSubsidySwitchPruningPointInterval: defaultFixedSubsidySwitchPruningPointInterval,
|
||||
FixedSubsidySwitchHashRateThreshold: big.NewInt(150_000_000_000),
|
||||
HardForkOmitGenesisFromParentsDAAScore: 2e6,
|
||||
}
|
||||
|
||||
// SimnetParams defines the network parameters for the simulation test Kaspa
|
||||
@@ -396,7 +392,6 @@ var SimnetParams = Params{
|
||||
PruningProofM: defaultPruningProofM,
|
||||
FixedSubsidySwitchPruningPointInterval: defaultFixedSubsidySwitchPruningPointInterval,
|
||||
FixedSubsidySwitchHashRateThreshold: big.NewInt(150_000_000_000),
|
||||
HardForkOmitGenesisFromParentsDAAScore: 5,
|
||||
}
|
||||
|
||||
// DevnetParams defines the network parameters for the development Kaspa network.
|
||||
@@ -459,7 +454,6 @@ var DevnetParams = Params{
|
||||
PruningProofM: defaultPruningProofM,
|
||||
FixedSubsidySwitchPruningPointInterval: defaultFixedSubsidySwitchPruningPointInterval,
|
||||
FixedSubsidySwitchHashRateThreshold: big.NewInt(150_000_000_000),
|
||||
HardForkOmitGenesisFromParentsDAAScore: 3000,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -121,7 +121,6 @@ type Flags struct {
|
||||
MaxUTXOCacheSize uint64 `long:"maxutxocachesize" description:"Max size of loaded UTXO into ram from the disk in bytes"`
|
||||
UTXOIndex bool `long:"utxoindex" description:"Enable the UTXO index"`
|
||||
IsArchivalNode bool `long:"archival" description:"Run as an archival node: don't delete old block data when moving the pruning point (Warning: heavy disk usage)'"`
|
||||
AllowSubmitBlockWhenNotSynced bool `long:"allow-submit-block-when-not-synced" hidden:"true" description:"Allow the node to accept blocks from RPC while not synced (this flag is mainly used for testing)"`
|
||||
EnableSanityCheckPruningUTXOSet bool `long:"enable-sanity-check-pruning-utxo" hidden:"true" description:"When moving the pruning point - check that the utxo set matches the utxo commitment"`
|
||||
NetworkFlags
|
||||
ServiceOptions *ServiceOptions
|
||||
|
||||
@@ -66,7 +66,7 @@ func (c *ConnectionManager) checkRequestedConnections(connSet connectionSet) {
|
||||
log.Debugf("Connecting to connection request %s", connReq.address)
|
||||
err := c.initiateConnection(connReq.address)
|
||||
if err != nil {
|
||||
log.Infof("Couldn't connect to requested connection %s: %s", address, err)
|
||||
log.Infof("Couldn't connect to %s: %s", address, err)
|
||||
// if connection request is one try - remove from pending and ignore failure
|
||||
if !connReq.isPermanent {
|
||||
delete(c.pendingRequested, address)
|
||||
|
||||
@@ -41,7 +41,7 @@ func (c *ConnectionManager) checkOutgoingConnections(connSet connectionSet) {
|
||||
|
||||
err := c.initiateConnection(addressString)
|
||||
if err != nil {
|
||||
log.Debugf("Couldn't connect to %s: %s", addressString, err)
|
||||
log.Infof("Couldn't connect to %s: %s", addressString, err)
|
||||
c.addressManager.MarkConnectionFailure(netAddress)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !windows && !plan9
|
||||
// +build !windows,!plan9
|
||||
|
||||
package limits
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package signal
|
||||
|
||||
@@ -36,7 +36,6 @@ func setConfig(t *testing.T, harness *appHarness) {
|
||||
harness.config.Listeners = []string{harness.p2pAddress}
|
||||
harness.config.RPCListeners = []string{harness.rpcAddress}
|
||||
harness.config.UTXOIndex = harness.utxoIndex
|
||||
harness.config.AllowSubmitBlockWhenNotSynced = true
|
||||
|
||||
if harness.overrideDAGParams != nil {
|
||||
harness.config.ActiveNetParams = harness.overrideDAGParams
|
||||
|
||||
@@ -11,7 +11,7 @@ const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs
|
||||
const (
|
||||
appMajor uint = 0
|
||||
appMinor uint = 11
|
||||
appPatch uint = 3
|
||||
appPatch uint = 2
|
||||
)
|
||||
|
||||
// appBuild is defined as a variable so it can be overridden during the build
|
||||
|
||||
Reference in New Issue
Block a user