* add p2p v5 which is currently identical to v4
* set all internal imports to v5
* set default version to 5
* Send pruning point and its anticone in batches
* go lint
* Fix jsom format
* Use DequeueWithTimeout
* Assert that batch size < route capacity
* oops, this is a flow handler, by definition it needs to be w/o a timeout
* here however, a timeout is required
* Keep IDs of prev messages unmodified
* previous merge operation accidentally erased an important part of this pr
* Extend timeout of simple sync
Co-authored-by: Ori Newman <orinewman1@gmail.com>
* Split ApplyPruningPointProof to multiple small database transactions.
* Increase the timeout duration in TestIBDWithPruning.
* Increase the timeout duration in simple-sync.
* Explain that if ApplyPruningPointProof fails, the database must be discarded.
* Copy blockrelay flows to v4
* Remove duplicate sending of the same DAA blocks
* Advance testnet version
* Renames and add comments
* Add IBD test between v3 and v4
* Fix syncee v4 p2p version
* Check if netsync finished with selected tip
* Fix stability test mining (allow submission of non DAA blocks too)
* Comments for go fmt
* Use SubmitBlockAlsoIfNonDAA for all tests
Co-authored-by: Elichai Turkel <elichai.turkel@gmail.com>
* Get rid of genesis's UTXO dump
* Allow known orphans when AllowSubmitBlockWhenNotSynced=true
* gofmt
* Avoid IBD without changing the pruning point when only genesis is available
* Add DisallowDirectBlocksOnTopOfGenesis=true for mainnet
* Remove any mention to nobanning to let stability tests run
* Rename ifGenesisSetUtxoSet to loadUTXODataForGenesis
Co-authored-by: Ori Newman <>
* Modify DefaultTimeout to 120 seconds
A temporary workaround for nodes having trouble to sync (currently the download of pruning point related data during IBD takes more than 30 seconds)
* Cache existence in reachability store
* Cache block level in the header
* Fix IBD indication on submit block
* Add hardForkOmitGenesisFromParentsDAAScore logic
* Fix NumThreads bug in the wallet
* Get rid of ParentsAtLevel header method
* Fix a bug in BuildPruningPointProof
* Increase race detector timeout
* Add cache to BuildPruningPointProof
* Add comments and temp comment out go vet
* Fix ParentsAtLevel
* Dont fill empty parents
* Change HardForkOmitGenesisFromParentsDAAScore in fast netsync test
* Add --allow-submit-block-when-not-synced in stability tests
* Fix TestPruning
* Return fast tests
* Fix off by one error on kaspawallet
* Fetch only one block with trusted data at a time
* Update fork DAA score
* Don't ban for unexpected message type
* Fix tests
Co-authored-by: Michael Sutton <mikisiton2@gmail.com>
Co-authored-by: Ori Newman <>
* Implement a MinerState to cache the matrix and friends
* Modify the miner and related code to use the new MinerCache
* Change MinerState to State
* Make go lint happy
Co-authored-by: Ori Newman <orinewman1@gmail.com>
Co-authored-by: Kaspa Profiler <>
* Send pruning point anticone in topological order
Fix a UTXO pagination bug
Lengthen the stabilization time for the last DAA test
* Extend "sudden hash rate drop" test length to 45 minutes
Co-authored-by: Kaspa Profiler <>
* Check blue score before requesting a pruning proof
* BuildPruningPointProof should return empty proof if the pruning point is genesis
* Don't fail many-tips if kaspad exits ungracefully
* Replace the old blockSubsidy parameters with the new ones.
* Return subsidyGenesisReward if blockHash is the genesis hash.
* Traverse a block's past for the subsidy calculation.
* Partially implement SubsidyStore.
* Refer to SubsidyStore from CoinbaseManager.
* Wrap calcBlockSubsidy in getBlockSubsidy, which first checks the database.
* Fix finalityStore not calling GenerateShardingID.
* Implement calculateAveragePastSubsidy.
* Implement calculateMergeSetSubsidySum.
* Implement calculateSubsidyRandomVariable.
* Implement calcBlockSubsidy.
* Add a TODO about floats.
* Update the calcBlockSubsidy TODO.
* Use binary.LittleEndian in calculateSubsidyRandomVariable.
* Fix bad range in calculateSubsidyRandomVariable.
* Replace float64 with big.Rat everywhere except for subsidyRandomVariable.
* Fix a nil dereference.
* Use a random walk to approximate the normal distribution.
* In order to avoid unsupported fractional results from powInt64, flip the numerator and the denominator manually.
* Set standardDeviation to 0.25, MaxSompi to 10_000_000_000 * SompiPerKaspa and defaultSubsidyGenesisReward to 1_000.
* Set the standard deviation to 0.2.
* Use a binomial distribution instead of trying to estimate the normal distribution.
* Change some values around.
* Clamp the block subsidy.
* Remove the fake duplicate constants in the util package.
* Reduce MaxSompi to only 100m Kaspa to avoid hitting the uint64 ceiling.
* Lower MaxSompi further to avoid new and exciting ways for the uint64 ceiling to be hit.
* Remove debug logs.
* Fix a couple of failing tests.
* Fix TestBlockWindow.
* Fix limitTransactionCount sometimes crashing on index-out-of-bounds.
* In TrustedDataDataDAABlock, replace BlockHeader with DomainBlock
* In calculateAveragePastSubsidy, use blockWindow instead of doing a BFS manually.
* Remove the reference to DAGTopologyManager in coinbaseManager.
* Add subsidy to the coinbase payload.
* Get rid of the subsidy store and extract subsidies out of coinbase transactions.
* Keep a blockWindow amount of blocks under the virtual for IBD purposes.
* Manually remove the virtual genesis from the merge set.
* Fix simnet genesis.
* Fix TestPruning.
* Fix TestCheckBlockIsNotPruned.
* Fix TestBlockWindow.
* Fix TestCalculateSignatureHashSchnorr.
* Fix TestCalculateSignatureHashECDSA.
* Fix serializing the wrong value into the coinbase payload.
* Rename coinbaseOutputForBlueBlock to coinbaseOutputAndSubsidyForBlueBlock.
* Add a TODO about optimizing trusted data DAA window blocks.
* Expand on a comment in TestCheckBlockIsNotPruned.
* In calcBlockSubsidy, divide the big.Int numerator by the big.Int denominator instead of converting to float64.
* Clarify a comment.
* Rename SubsidyMinGenesisReward to MinSubsidy.
* Properly handle trusted data blocks in calculateMergeSetSubsidySum.
* Use the first two bytes of the selected parent's hash for randomness instead of math/rand.
* Restore maxSompi to what it used to be.
* Fix TestPruning.
* Fix TestAmountCreation.
* Fix TestBlockWindow.
* Fix TestAmountUnitConversions.
* Increase the timeout in many-tips to 30 minutes.
* Check coinbase subsidy for every block
* Re-rename functions
* Use shift instead of powInt64 to determine subsidyRandom
Co-authored-by: Ori Newman <orinewman1@gmail.com>
* Replace the old parents in the block header with BlockLevelParents.
* Begin fixing compilation errors.
* Implement database serialization for block level parents.
* Implement p2p serialization for block level parents.
* Implement rpc serialization for block level parents.
* Add DirectParents() to the block header interface.
* Use DirectParents() instead of Parents() in some places.
* Revert test_block_builder.go.
* Add block level parents to hash serialization.
* Use the zero hash for genesis finality points.
* Fix failing tests.
* Fix a variable name.
* Update headerEstimatedSerializedSize.
* Add comments in blocklevelparents.go.
* Fix the rpc-stability stability test.
* Change the field number for `parents` fields in p2p.proto and rpc.proto.
* Remove MsgBlockHeader::NumParentBlocks.
* Limit the amount of inbound RPC connections.
* Increment/decrement the right variable.
* Implement TestRPCMaxInboundConnections.
* Make go vet happy.
* Increase RPCMaxInboundConnections to 128.
* Set NUM_CLIENTS=128 in the rpc-idle-clients stability test.
* Explain why the P2P server has unlimited inbound connections.
* Pruning headers p2p basic structure
* Remove headers-first
* Fix consensus tests except TestValidateAndInsertPruningPointWithSideBlocks and TestValidateAndInsertImportedPruningPoint
* Add virtual genesis
* Implement PruningPointAndItsAnticoneWithMetaData
* Start fixing TestValidateAndInsertImportedPruningPoint
* Fix TestValidateAndInsertImportedPruningPoint
* Fix BlockWindow
* Update p2p and gRPC
* Fix all tests except TestHandleRelayInvs
* Delete TestHandleRelayInvs parts that cover the old IBD flow
* Fix lint errors
* Add p2p_request_ibd_blocks.go
* Clean code
* Make MsgBlockWithMetaData implement its own representation
* Remove redundant check if highest share block is below the pruning point
* Fix TestCheckLockTimeVerifyConditionedByAbsoluteTimeWithWrongLockTime
* Fix comments, errors ane names
* Fix window size to the real value
* Check reindex root after each block at TestUpdateReindexRoot
* Remove irrelevant check
* Renames and comments
* Remove redundant argument from sendGetBlockLocator
* Don't delete staging on non-recoverable errors
* Renames and comments
* Remove redundant code
* Commit changes inside ResolveVirtual
* Add comment to IsRecoverableError
* Remove blocksWithMetaDataGHOSTDAGDataStore
* Increase windows pagefile
* Move DeleteStagingConsensus outside of defer
* Get rid of mustAccepted in receiveBlockWithMetaData
* Ban on invalid pruning point
* Rename interface_datastructures_daawindowstore.go to interface_datastructures_blocks_with_meta_data_daa_window_store.go
* * Change GetVirtualSelectedParentChainFromBlockResponseMessage and VirtualSelectedParentChainChangedNotificationMessage to show only added block hashes
* Remove ResolveVirtual
* Use externalapi.ConsensusWrapper inside MiningManager
* Fix pruningmanager.blockwithmetadata
* Set pruning point selected child when importing the pruning point UTXO set
* Change virtual genesis hash
* replace the selected parent with virtual genesis on removePrunedBlocksFromGHOSTDAGData
* Get rid of low hash in block locators
* Remove +1 from everywhere we use difficultyAdjustmentWindowSize and increase the default value by one
* Add comments about consensus wrapper
* Don't use separate staging area when resolving resolveBlockStatus
* Fix netsync stability test
* Fix checkResolveVirtual
* Rename ConsensusWrapper->ConsensusReference
* Get rid of blockHeapNode
* Add comment to defaultDifficultyAdjustmentWindowSize
* Add SelectedChild to DAGTraversalManager
* Remove redundant copy
* Rename blockWindowHeap->calculateBlockWindowHeap
* Move isVirtualGenesisOnlyParent to utils
* Change BlockWithMetaData->BlockWithTrustedData
* Get rid of maxReasonLength
* Split IBD to 100 blocks each time
* Fix a bug in calculateBlockWindowHeap
* Switch to trusted data when encountering virtual genesis in blockWithTrustedData
* Move ConsensusReference to domain
* Update ConsensusReference comment
* Add comment
* Rename shouldNotAddGenesis->skipAddingGenesis
* Copy over boilerplate and begin implementing TestDAA.
* Implement a fairly reliable method of hashing at a certain hashrate.
* Convert the DAA test to an application.
* Start kaspad and make sure that hashrate throttling works with that as well.
* Finish implementing testConstantHashRate.
* Tidied up a bit.
* Convert TestDAA back into a go test.
* Reorganize TestDAA to be more like a traditional test.
* Add sudden hashrate drop/jump tests.
* Simplify targetHashNanosecondsFunction.
* Improve progress logs.
* Add more tests.
* Remove the no-longer relevant `hashes` part of targetHashNanosecondsFunction.
* Implement a constant hashrate increase test.
* Implement a constant hashrate decrease test.
* Give the correct run duration to the constant hashrate decrease test.
* Add cooldowns to exponential functions.
* Add run.sh to the DAA test.
* Add a README.
* Add `daa` to run-slow.sh.
* Make go lint happy.
* Fix the README's title.
* Keep running tests even if one of them failed on high block rate deviation.
* Fix hashrate peak/valley tests.
* Preallocate arrays for hash and mining durations.
* Add more statistics to the "mined block" log.
* Make sure runDAATest stops when it's suppposed to.
* Add a newline after "5 minute cooldown."
* Fix variable names.
* Rename totalElapsedTime to tatalElapsedDuration.
* In measureMachineHashNanoseconds, generate a random nonce only once.
* In runDAATest, add "DAA" to the start/finish log.
* Remove --logdir from kaspadRunCommand.
* In runDAATest, enlarge the nonce range to the entirety of uint64.
* Explain what targetHashNanosecondsFunction is.
* Move RunKaspadForTesting into common.
* Rename runForDuration to loopForDuration.
* Make go lint happy.
* Extract fetchBlockForMining to a separate function.
* Extract waitUntilTargetHashDurationHadElapsed to a separate function.
* Extract pushHashDuration and pushMiningDuration to separate functions.
* Extract logMinedBlockStatsAndUpdateStatFields to a separate function.
* Extract submitMinedBlock to a separate function.
* Extract tryNonceForMiningAndIncrementNonce to a separate function.
* Add comments.
* Use a rolling average instead of appending to an array for performance/accuracy.
* Change a word in a comment.
* Explain why we wait for five minutes at the end of the exponential increase/decrease tests.
Co-authored-by: Svarog <feanorr@gmail.com>
* First limit the candidates size to 3*csm.maxBlockParents before taking the bottom csm.maxBlockParents/2
* Change log level of printing all tips to Tracef
* Add many-tips to run-fast.sh and run-slow.sh
* Fix preallocation size
* Assign intermediate variables
* Unfinished code.
* Update the testnet version to testnet-5. (#1683)
* Generalize stability-tests/docker/Dockerfile. (#1685)
* Committed for rebasing.
* Adds stability-test many-tips, which tests kaspad handling with many tips in the DAG.
* Delete manytips_test.go.
* Add timeout to the test and create only one RPC client.
* Place the spawn before the for loop and remove a redundant condition.
Co-authored-by: tal <tal@daglabs.com>
Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>
* Add -v to the `go test` command.
* Generate a new keypair for mempool-limits.
* Set mempool-limits to time out only after 24 hours.
(cherry picked from commit eb1703b948c740170334a333b0b0b29bcb208fdf)
* Use selectedParent instead of selectedTip for non-selectedTip blocks in restoreSingleBlockStatus
* Cache the selectedParent for re-use in a resolveSingleBlockStatus chain
* Implement and use reverseUTXOSet
* Reverse blocks in correct order
* Support resolveBlockStatus without separate stagingAreas for usage of testConsensus
* Handle the case where the tip of the resolved block is not the next selectedTip
* Unify isResolveTip
* Some minor fixes and cleanup
* Add full finality window re-org test to stability-slow
* rename: useSeparateStagingAreasPerBlock -> useSeparateStagingAreaPerBlock
* Better logs in resolveSingleBlockStatus
* A few retouches to reverseUTXODiffs
* TEMPORARY COMMIT: EXTRAT ALL DIFFFROMS TO SEPARATE METHODS
* TEMPORARY COMMIT: REMOVE DIFFICULTY CHECKS IN DEVNET
* Don't pre-allocate in utxo-algebra, since the numbers are not known ahead-of-time
* Add some logs to reverseUTXODiffs
* Revert "TEMPORARY COMMIT: REMOVE DIFFICULTY CHECKS IN DEVNET"
This reverts commit c0af9dc6ade78a914c970e11bc63c34605565f57.
* Revert "TEMPORARY COMMIT: EXTRAT ALL DIFFFROMS TO SEPARATE METHODS"
This reverts commit 4fcca1b48c3a1183598833a355b9bfaf169edba1.
* Remove redundant paranthesis
* Revise some logs messages
* Rename:oneBlockBeforeCurrentUTXOSet -> lastResolvedBlockUTXOSet
* Don't break if the block was resolved as invalid
* rename unverifiedBlocks to recentlyVerifiedBlcks in reverseUTXODiffs
* Add errors.New to the panic, for a stack trace
* Reverse the UTXODiffs after the main block has been commited
* Use the correct value for previousUTXODiff
* Add test for ReverseUTXODiff
* Fix some names and comments
* Update TestReverseUTXODiffs to use consensus.Config
* Fix comments mentioning 'oneBlockBeforeTip'
* Add windows to the CI
* Cast syscall.Stdin into an integer
* DataDir -> AppDir in service_windows.go
* Rename mempool-limits package to something non-main
* Close database after re-assigining to it
* Up rpcTimout to 10 seconds
* Copy some boilerplate from the other stability tests.
* Fix a copy+paste error in run.sh.
* Copy over some stability test boilerplate go code.
* Run kaspad in the background.
* Catch panics and initialize the RPC client.
* Mine enough blocks to fund filling up the mempool.
* Extract coinbase transactions out of the generated blocks.
* Tidy up a bit.
* Implement submitting transactions.
* Lower the amount of outputs in each transaction.
* Verify that the mempool size has the expected amount of transactions.
* Pregenerate enough funds before submitting the first transaction so that block creation doesn't interfere with the test.
* Empty mempool out by continuously adding blocks to the DAG.
* Handle orphan transactions when overfilling the mempool.
* Increase mempoolSizeLimit to 1m.
* Fix a comment.
* Fix a comment.
* Add mempool-limits to run-slow.sh.
* Rename generateTransactionsWithLotsOfOutputs to generateTransactionsWithMultipleOutputs.
* Rename generateCoinbaseTransaction to mineBlockAndGetCoinbaseTransaction.
* Make generateFundingCoinbaseTransactions return an object instead of store a global variable.
* Convert mempool-limits into a Go test.
* Convert panics to t.Fatalfs.
* Fix a comment.
* Increase mempoolSizeLimit to 1m.
* Run TestMempoolLimits only if RUN_STABILITY_TESTS is set.
* Move the run of mempool-limits in run-slow.sh.
* Add a comment above fundingCoinbaseTransactions.
* Make a couple of stylistic changes.
* Use transactionhelper.CoinbaseTransactionIndex instead of hardcoding 0.
* Make uninteresting errors print %+v instead of %s.
Co-authored-by: Svarog <feanorr@gmail.com>
* Replace BlockMessage with RpcBlock in rpc.proto.
* Convert everything in kaspad to use RPCBlocks and fix tests.
* Fix compilation errors in stability tests and the miner.
* Update TransactionVerboseData in rpc.proto.
* Update TransactionVerboseData in the rest of kaspad.
* Make golint happy.
* Include RpcTransactionVerboseData in RpcTransaction instead of the other way around.
* Regenerate rpc.pb.go after merge.
* Update appmessage types.
* Update appmessage request and response types.
* Reimplement conversion functions between appmessage.RPCTransaction and protowire.RpcTransaction.
* Extract RpcBlockHeader toAppMessage/fromAppMessage out of RpcBlock.
* Fix compilation errors in getBlock, getBlocks, and submitBlock.
* Fix compilation errors in getMempoolEntry.
* Fix compilation errors in notifyBlockAdded.
* Update verbosedata.go.
* Fix compilation errors in getBlock and getBlocks.
* Fix compilation errors in getBlocks tests.
* Fix conversions between getBlocks message types.
* Fix integration tests.
* Fix a comment.
* Add selectedParent to the verbose block response.
* Add StagingArea struct
* Implemented staging areas in blockStore
* Move blockStagingShard to separate folder
* Apply staging shard to acceptanceDataStore
* Update blockHeaderStore with StagingArea
* Add StagingArea to BlockRelationStore
* Add StagingArea to blockStatusStore
* Add StagingArea to consensusStateStore
* Add StagingArea to daaBlocksStore
* Add StagingArea to finalityStore
* Add StagingArea to ghostdagDataStore
* Add StagingArea to headersSelectedChainStore and headersSelectedTipStore
* Add StagingArea to multisetStore
* Add StagingArea to pruningStore
* Add StagingArea to reachabilityDataStore
* Add StagingArea to utxoDiffStore
* Fix forgotten compilation error
* Update reachability manager and some more things with StagingArea
* Add StagingArea to dagTopologyManager, and some more
* Add StagingArea to GHOSTDAGManager, and some more
* Add StagingArea to difficultyManager, and some more
* Add StagingArea to dagTraversalManager, and some more
* Add StagingArea to headerTipsManager, and some more
* Add StagingArea to constnsusStateManager, pastMedianTimeManager
* Add StagingArea to transactionValidator
* Add StagingArea to finalityManager
* Add StagingArea to mergeDepthManager
* Add StagingArea to pruningManager
* Add StagingArea to rest of ValidateAndInsertBlock
* Add StagingArea to blockValidator
* Add StagingArea to coinbaseManager
* Add StagingArea to syncManager
* Add StagingArea to blockBuilder
* Update consensus with StagingArea
* Add StagingArea to ghostdag2
* Fix remaining compilation errors
* Update names of stagingShards
* Fix forgotten stagingArea passing
* Mark stagingShard.isCommited = true once commited
* Move isStaged to stagingShard, so that it's available without going through store
* Make blockHeaderStore count be avilable from stagingShard
* Fix remaining forgotten stagingArea passing
* commitAllChanges should call dbTx.Commit in the end
* Fix all tests tests in blockValidator
* Fix all tests in consensusStateManager and some more
* Fix all tests in pruningManager
* Add many missing stagingAreas in tests
* Fix many tests
* Fix most of all other tests
* Fix ghostdag_test.go
* Add comment to StagingArea
* Make list of StagingShards an array
* Add comment to StagingShardID
* Make sure all staging shards are pointer-receiver
* Undo bucket rename in block_store
* Typo: isCommited -> isCommitted
* Add comment explaining why stagingArea.shards is an array