* 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.
* Separate IBD to a new flow (so now invs are handled concurrently and no route capacity errors)
* Invs messages should be queued while waiting for BlockLocator msg
* Close IBD channel so that HandleIBDFlow exits too
* Apply flow separation to p2p protocol v4
* Manage the IBDRequestChannel through the Peer struct
* Some IBDs take a little longer
* 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
* Implement upgrade mechanism for p2p
* Remove dependencies from flowcontext to v3
* Add p2p v4
* Add Ready flow
* Remove copy paste code of v3
* Register SendAddresses flow at the top level
* Add option to set protocol version from CLI and add TestAddressExchangeV3V4
* Send ready message on minimal net adapter
* Rename defaultMaxProtocolVersion->maxAcceptableProtocolVersion
* 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>
* 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 <>
* 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
* Replace header finality point with pruning point
* Fix TestTransactionAcceptance
* Fix pruning candidate
* Store all past pruning points
* Pass pruning points on IBD
* Add blue score to block header
* Simplify ArePruningPointsInValidChain
* Fix static check errors
* Fix genesis
* Renames and text fixing
* Use ExpectedHeaderPruningPoint in block builder
* Fix TestCheckPruningPointViolation
* Implement GHOST.
* Implement TestGHOST.
* Make GHOST() take arbitrary subDAGs.
* Hold RootHashes in SubDAG rather than one GenesisHash.
* Select which root the GHOST chain starts with instead of passing a lowHash.
* If two child hashes have the same future size, decide which one is larger using the block hash.
* Extract blockHashWithLargestFutureSize to a separate function.
* Calculate future size for each block individually.
* Make TestGHOST deterministic.
* Increase the timeout for connecting 128 connections in TestRPCMaxInboundConnections.
* Implement BenchmarkGHOST.
* Fix an infinite loop.
* Use much larger benchmark data.
* Optimize `futureSizes` using reverse merge sets.
* Temporarily make the benchmark data smaller while GHOST is being optimized.
* Fix a bug in futureSizes.
* Fix a bug in populateReverseMergeSet.
* Choose a selectedChild at random instead of the one with the largest reverse merge set size.
* Rename populateReverseMergeSet to calculateReverseMergeSet.
* Use reachability to resolve isDescendantOf.
* Extract heightMaps to a separate object.
* Iterate using height maps in futureSizes.
* Don't store reverse merge sets in memory.
* Change calculateReverseMergeSet to calculateReverseMergeSetSize.
* Fix bad initial reverseMergeSetSize.
* Optimize calculateReverseMergeSetSize.
* Enlarge the benchmark data to 86k blocks.
* 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
* Update constants
* Add to transaction SigOpCount
* Update mass calculation, and move it from InContext to InIsolation
* Update block validation accordingly
* Add SigOpCount validation during TransactionInContext
* Remove checking of mass vs maxMassAcceptedByBlock from consensusStateManager
* Update mining manager with latest changes
* Add SigOpCount to MsgTx.Copy()
* Fix initTestTransactionAcceptanceDataForClone
* Fix all tests in transaction_equal_clone_test.go
* Fix TestBlockMass
* Fix tests in transactionvalidator package
* Add SigOpCount to sighash
* Fix TestPruningDepth
* Fix problems in libkaspawalelt
* Fix integration tests
* Fix CalculateSignatureHash tests
* Remove remaining places talking about block size
* Add sanity check to checkBlockMass to make sure all transactions have their mass filled
* always add own sigOpCount to sigHash
* Update protowire/rpc.md
* Start working on removing any remaining reference to block/tx size
* Update rpc transaction verbose data to include mass rather then size
* Convert verboseData and block size check to mass
* Remove remaining usages of tx size in mempool
* Move transactionEstimatedSerializedSize to transactionvalidator
* Add PopulateMass to fakeRelayInvsContext
* Move PopulateMass to beggining of ValidateAndInsertTransaction + fix in it
* Assign mass a new number for backward-compatibility
* Add notifyVirtualDaaScoreChanged to protowire.
* Add notifyVirtualDaaScoreChanged to the rest of kaspad.
* Add notifyVirtualDaaScoreChanged to the rest of kaspad.
* Test the DAA score notification in TestVirtualSelectedParentBlueScore.
* Rename TestVirtualSelectedParentBlueScore to TestVirtualSelectedParentBlueScoreAndVirtualDAAScore.
(cherry picked from commit 83e631548f206aaf2da5b2103681c715bc250c75)
* 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
* 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.
* Use BLAKE2B instead of HASH160, and get rid of any usage of RIPEMD160
* Change genesis coinbase payload script to OP_FALSE
* Fix tests after conflict
* Remove duplicate tests
* Change file name
* Change atomic swap to use proper hash size
* Move CalculateSignatureHash to consensushashing
* Added CalcSignatureHash_BIP143 with all parameters except the re-used hashes
* Add handling of outputHash
* Add sequencesHash to the mix
* Add previousOutputsHash to the mix
* Replace legacy CalculateSigHash with new one, and re-wire to all non-test code
* Add missing types to WriteElement
* Fix tests in txscript
* Fix tests in rest of code
* Add missing comments
* Add SubnetworkID and Gas to sigHash
* Add TestCalculateSignatureHash
* Invert condition in SigHashSingle getOutputsHash
* Explicitly define that payloadHash for native transactions is 0
* added benchmark to CalculateSignatureHash
* Reformat call for signAndCheck
* Change SigHashes to be true bit-fields
* Add check for transaction version
* Write length of byte array in WriteElement
* hashOutpoint should get outpoint, not txIn
* Use inputIndex instead of i to determine SigHashType
* Use correct transaction version + fix some typos
* Fix hashes in test
* Reformat an overly-long line
* Replace checkHashTypeEncoding with caalls to hashType.IsStandardSigHashType
* Convert hashType to uint8
* Add comment
* Replace blue score with DAA score in UTXO entries
* Use DAA score for coinbase maturity
* Use DAA score for sequence lock
* Fix calcBlockSubsidy to use DAA score
* Don't pay to blocks that are not included in the DAA added blocks, and bestow red blocks reward to the merging block
* Fix TestGetPruningPointUTXOs
* Fix TestTransactionAcceptance
* Fix TestChainedTransactions
* Fix TestVirtualDiff
* Fix TestBlockWindow
* Fix TestPruning
* Use NewFromSlice instead of manually creating the hash set
* Add assert
* Add comment
* Remove redundant call to UpdateDAADataAndReturnDifficultyBits
* Add RequiredDifficulty, rename UpdateDAADataAndReturnDifficultyBits to StageDAADataAndReturnRequiredDifficulty and add comments
* Make buildUTXOInvalidHeader get bits as an argument
* Fix comments
* Remove Subsystems map and replace with RegisterSubSystem
* Clean up the logger
* Fix LOGFLAGS and make LongFile work correctly
* Parallelize the logger backend
* More logger cleanup
* Initialize and close the logger backend wherever it's needed
* Move the location where the backend is closed, also print the log if it panics while writing
* Add TestMain to reachability manager tests to preserve the same log level
* Fix review comments
Co-authored-by: Svarog <feanorr@gmail.com>
* Send peers the hash of the virtual selected parent once connection is established.
* Add a log to SendVirtualSelectedParentInv.
* Fix TestIBDWithPruning.
* Fix TestIBDWithPruning better and signal from the IBD syncer to the IBD syncee that the DAG is split amongst them.
* Fix TestVirtualSelectedParentChain.
* Add comments.
* Make leveldb cache configurable
* Fix leveldb tests
* Add a preallocate option to all caches and disable in tests
Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>
* Add dummy go files for test only package, to mitigate golang/go#27333
* Stop ignoring errors when producing the coverage
* Add comments explaining the dummy go files
* Make the coverage output non-json
* Log the hashrate of each block
* Add a test for GetHashrateString
* Move difficulty related functions to its own package
* Convert the validated log in validateAndInsertBlock to a log function
* Add tests for max/min int
* ''
* ''
* ''
* Changes genesis block version to 0.
* a
* a
* All tests are done.
* All tests passed for changed block version from int32 to uint16
* Adds validation of rejecting blocks with unknown versions.
* Changes txn version from int32 to uint16.
* .
* Adds comments to exported functions.
* Change functions name from ConvertFromRpcScriptPubKeyToRPCScriptPubKey to ConvertFromAppMsgRPCScriptPubKeyToRPCScriptPubKey and from ConvertFromRPCScriptPubKeyToRpcScriptPubKey to ConvertFromRPCScriptPubKeyToAppMsgRPCScriptPubKey
* change comment to "ScriptPublicKey represents a Kaspad ScriptPublicKey"
* delete part (tx.Version < 0) that cannot be exist on the if statement.
* Revert protobuf version.
* Fix a comment.
* Fix a comment.
* Rename a variable.
* Rename a variable.
* Remove a const.
* Rename a type.
* Rename a field.
* Rename a field.
* Remove commented-out code.
* Remove dangerous nil case in DomainTransactionOutput.Clone().
* Remove a constant.
* Fix a string.
* Fix wrong totalScriptPubKeySize in transactionMassStandalonePart.
* Remove a constant.
* Remove an unused error.
* Fix a serialization error.
* Specify version types to be uint16 explicitly.
* Use constants.ScriptPublicKeyVersion.
* Fix a bad test.
* Remove some whitespace.
* Add a case to utxoEntry.Equal().
* Rename scriptPubKey to scriptPublicKey.
* Remove a TODO.
* Rename constants.
* Rename a variable.
* Add version to parseShortForm.
Co-authored-by: tal <tal@daglabs.com>
Co-authored-by: stasatdaglabs <stas@daglabs.com>
* Fix notifyVirtualSelectedParentBlueScoreChanged to show the selected tip blue score instead of the virtual's
* Fix ShouldMine() to fetch selected tip header
* Increase size of reachability cache
* Change DomainHash to struct with unexported hashArray
* Fixing compilation errors stemming from new DomainHash structure
* Remove obsolete Read/WriteElement methods in appmessage
* Fix all tests
* Fix all tests
* Add comments
* A few renamings
* go mod tidy
* [NOD-1575] Implement Clone and Equal for all model types
* [NOD-1575] Add assertion for transaction ID equality
* [NOD-1575] Use DomainTransaction.Equal to compare to expected coinbase transaction
* [NOD-1575] Add TestDomainBlockHeader_Clone
* [NOD-1575] Don't clone nil values
* [NOD-1575] Add type assertions
* [NOD-1575] Don't clone nil values
* [NOD-1575] Add missing Equals
* [NOD-1575] Add length checks
* [NOD-1575] Update comment
* [NOD-1575] Check length for TransactionAcceptanceData
* [NOD-1575] Explicitly clone nils where needed
* [NOD-1575] Clone tx id
* [NOD-1575] Flip condition
* Nod 1576 make coverage tests for equal clone inside model externalapi (#1177)
* [NOD-1576] Make coverage tests for equal and clone inside model and externalapi
* Some formatting and naming fixes
* Made transactionToCompare type exported
* Added some tests and made some changes to the tests code
* No changes made
* Some formatting and naming changes made
* Made better test coverage for externalapi clone and equal functions
* Changed expected result for two cases
* Added equal and clone functions tests for ghostdag and utxodiff
* Added tests
* [NOD-1576] Implement reachabilitydata equal/clone unit tests
* [NOD-1576] Full coverage of reachabilitydata equal/clone unit tests
* Made changes and handling panic to transaction_equal_clone_test.go and formating of utxodiff_equal_clone_test.go
* Added recoverForEqual2 for handling panic to transaction_equal_clone_test.go
* [NOD-1576] Full coverage of transaction equal unit test
* [NOD-1576] Add expects panic
* [NOD-1576] Allow composites in go vet
* [NOD-1576] Code review fixes (#1223)
* [NOD-1576] Code review fixes
* [NOD-1576] Code review fixes part 2
* [NOD-1576] Fix wrong name
Co-authored-by: karim1king <karimkaspersky@yahoo.com>
Co-authored-by: Ori Newman <orinewman1@gmail.com>
Co-authored-by: Karim <karim1king@users.noreply.github.com>
* Fix merge errors
* Use Equal where possible
* Use Equal where possible
* Use Equal where possible
Co-authored-by: andrey-hash <74914043+andrey-hash@users.noreply.github.com>
Co-authored-by: karim1king <karimkaspersky@yahoo.com>
Co-authored-by: Karim <karim1king@users.noreply.github.com>
* Expose CheckProofOfWork from model/pow
* Update blockvalidator to call the new CheckProofOfWork
* Update genesis blocks
* Update tools to use the new CheckProofOfWork
* Update tests with new PoW
* [NOD-1579] Remove selected tip hash messages.
* [NOD-1579] Start moving IBD stuff into blockrelay.
* [NOD-1579] Rename relaytransactions to transactionrelay.
* [NOD-1579] Move IBD files into blockrelay.
* [NOD-1579] Remove flow stuff from ibd.go.
* [NOD-1579] Bring back IsInIBD().
* [NOD-1579] Simplify block relay flow.
* [NOD-1579] Check orphan pool for missing parents to avoid unnecessary processing.
* [NOD-1579] Implement processOrphan.
* [NOD-1579] Implement addToOrphanSetAndRequestMissingParents.
* [NOD-1579] Fix TestIBD.
* [NOD-1579] Implement isBlockInOrphanResolutionRange.
* [NOD-1579] Implement limited block locators.
* [NOD-1579] Add some comments.
* [NOD-1579] Specifically check for StatusHeaderOnly in blockrelay.
* [NOD-1579] Simplify runIBDIfNotRunning.
* [NOD-1579] Don't run IBD if it is already running.
* [NOD-1579] Fix a comment.
* [NOD-1579] Rename mode to syncInfo.
* [NOD-1579] Simplify validateAndInsertBlock.
* [NOD-1579] Fix bad SyncStateSynced condition.
* [NOD-1579] Implement validateAgainstSyncStateAndResolveInsertMode.
* [NOD-1579] Use insertModeHeader.
* [NOD-1579] Add logs to TrySetIBDRunning and UnsetIBDRunning.
* [NOD-1579] Implement and use dequeueIncomingMessageAndSkipInvs.
* [NOD-1579] Fix a log.
* [NOD-1579] Fix a bug in createBlockLocator.
* [NOD-1579] Rename a variable.
* [NOD-1579] Fix a slew of bugs in missingBlockBodyHashes and selectedChildIterator.
* [NOD-1579] Fix bad chunk size in syncMissingBlockBodies.
* [NOD-1579] Remove maxOrphanBlueScoreDiff.
* [NOD-1579] Fix merge errors.
* [NOD-1579] Remove a debug log.
* [NOD-1579] Add logs.
* [NOD-1579] Make various go quality tools happy.
* [NOD-1579] Fix a typo in a variable name.
* [NOD-1579] Fix full blocks over header-only blocks not failing the missing-parents validation.
* [NOD-1579] Add an error log about a condition that should never happen.
* [NOD-1579] Check all antiPast hashes instead of just the lowHash's anticone to filter for header-only blocks.
* [NOD-1579] Remove the nil stuff from GetBlockLocator.
* [NOD-1579] Remove superfluous condition in handleRelayInvsFlow.start().
* [NOD-1579] Return a boolean from requestBlock instead of comparing to nil.
* [NOD-1579] Fix a bad log.Debugf.
* [NOD-1579] Remove a redundant check.
* [NOD-1579] Change an info log to a warning log.
* [NOD-1579] Move OnNewBlock out of relayBlock.
* [NOD-1579] Remove redundant exists check from runIBDIfNotRunning.
* [NOD-1579] Fix bad call to OnNewBlock.
* [NOD-1579] Remove an impossible check.
* [NOD-1579] Added a log.
* [NOD-1579] Rename insertModeBlockWithoutUpdatingVirtual to insertModeBlockBody.
* [NOD-1579] Add a check for duplicate headers.
* [NOD-1579] Added a comment.
* [NOD-1579] Tighten a stop condition.
* [NOD-1579] Simplify a log.
* [NOD-1579] Clarify a log.
* [NOD-1579] Move a log.
* Update go-secp256k1 to v0.0.3
* Update the txscript engine to support only 32 bytes pubkeys
* Update the txscript engine tests
* Update txscript/sign.go to use the new Schnorr KeyPair API
* Update txscript sign_test to use the new schnorr
* Update sigcache tests to use new schnorr pubkey
* Update integration tests to use the new txscript and new schnorr pubkey