* Make use of maxBlocks instead of maxBlueScoreDifference in antiPastHashesBetween
* Make use of maxBlocks instead of maxBlueScoreDifference in antiPastHashesBetween
* Make use of maxBlocks instead of maxBlueScoreDifference in antiPastHashesBetween
* Make use of maxBlocks instead of maxBlueScoreDifference in antiPastHashesBetween
* Make use of maxBlocks instead of maxBlueScoreDifference in antiPastHashesBetween
Co-authored-by: Ori Newman <orinewman1@gmail.com>
* Change SequenceLockTimeDisabled to 1 << 63
* Move LockTimeThreshold to constants
* Update locktime constants according to new proposal
* Fix opcodeCheckSequenceVerify and failed tests
* Disallow numbers above 8 bytes in makeScriptNum
* Use littleEndian.Uint64 for sequence instead of ScriptNum
* Update comments on constants
* Update some more comments
* Added model and stubs for all main methods
* Add constructors to all main objects
* Implement BlockCandidateTransactions
* implement expireOldTransactions and expireOrphanTransactions
* Rename isHighPriority to neverExpires
* Add stub for checkDoubleSpends
* Revert "Rename isHighPriority to neverExpires"
This reverts commit b2da9a4a00c02fb380d2518cf54fa16257bd8423.
* Imeplement transactionsOrderedByFeeRate
* Orphan maps should be idToOrphan
* Add error.go to mempool
* Invert the condition for banning when mempool rejects a transaction
* Move all model objects to model package
* Implement getParentsInPool
* Implemented mempoolUTXOSet.addTransaction
* Implement removeTransaction, remove sanity checks
* Implemented mempoolUTXOSet.checkDoubleSpends
* Implemented removeOrphan
* Implement removeOrphan
* Implement maybeAddOrphan and AddOrphan
* Implemented processOrphansAfterAcceptedTransaction
* Implement transactionsPool.addTransaction
* Implement RemoveTransaction
* If a transaction was removed from the mempool - update it's redeemers in orphan pool as well
* Use maximumOrphanTransactionCount
* Add allowOrphans to ValidateAndInsertTransaction stub
* Implement validateTransaction functions
* Implement fillInputs
* Implement ValidateAndInsertTransaction
* Implement HandleNewBlockTransactions
* Implement missing mempool interface methods
* Add comments to exported functions
* Call ValidateTransactionInIsolation where needed
* Implement RevalidateHighPriorityTransactions
* Rewire kaspad to use new mempool, and fix compilation errors
* Update rebroadcast logic to use new structure
* Handle non-standard transaction errors properly
* Add mutex to mempool
* bugfix: GetTransaction panics when ok is false
* properly calculate targetBlocksPerSecond in config.go
* Fix various lint errors and tests
* Fix expected text in test for duplicate transactions
* Skip the coinbase transaction in HandleNewBlockTransactions
* Unorphan the correct transactions
* Call ValidateTransactionAndPopulateWithConsensusData on unorphanTransaction
* Re-apply policy_test as check_transactions_standard_test
* removeTransaction: Remove redeemers in orphan pool as well
* Remove redundant check for uint64 < 0
* Export and rename isDust -> IsTransactionOutputDust to allow usage by rothschild
* Add allowOrphan to SubmitTransaction RPC request
* Remove all implementation from mempool.go
* tidy go mod
* Don't pass acceptedOrphans to handleNewBlockTransactions
* Use t.Errorf in stead of t.Fatalf
* Remove minimum relay fee from TestDust, as it's no longer configurable
* Add separate VirtualDAASCore method for faster retrieval where it's repeated multiple times
* Broadcast all transactions that were accepted
* Don't re-use GetVirtualDAAScore in GetVirtualInfo - this causes a deadlock
* Use real transaction count, and not Orphan
* Get mempool config from outside, incorporating values received from cli
* Use MinRelayFee and MaxOrphanTxs from global kaspad config
* Add explanation for the seemingly redundant check for transaction version in checkTransactionStandard
* Update some comment
* Convert creation of acceptedTransactions to a single line
* Move mempoolUTXOSet out of checkDoubleSpends
* Add test for attempt to insert double spend into mempool
* fillInputs: Skip check for coinbase - it's always false in mempool
* Clarify comment about removeRedeemers when removing random orphan
* Don't remove high-priority transactions in limitTransactionCount
* Use mempool.removeTransaction in limitTransactionCount
* Add mutex comment to handleNewBlockTransactions
* Return error from limitTransactionCount
* Pluralize the map types
* mempoolUTXOSet.removeTransaction: Don't restore utxo if it was not created in mempool
* Don't evacuate from orphanPool high-priority transactions
* Disallow double-spends in orphan pool
* Don't use exported (and locking) methods from inside mempool
* Check for double spends in mempool during revalidateTransaction
* Add checkOrphanDuplicate
* Add orphan to acceptedOrphans, not current
* Add TestHighPriorityTransactions
* Fix off-by-one error in limitTransactionCount
* Add TestRevalidateHighPriorityTransactions
* Remove checkDoubleSpends from revalidateTransaction
* Fix TestRevalidateHighPriorityTransactions
* Move check for MaximumOrphanCount to beggining of maybeAddOrphan
* Rename all map type to singulateToSingularMap
* limitOrphanPool only after the orphan was added
* TestDoubleSpendInMempool: use createChildTxWhenParentTxWasAddedByConsensus instead of createTransactionWithUTXOEntry
* Fix some comments
* Have separate min/max transaction versions for mempool
* Add comment on defaultMaximumOrphanTransactionCount to keep it small as long as we have recursion
* Fix comment
* Rename: createChildTxWhenParentTxWasAddedByConsensus -> createChildTxWhereParentTxWasAddedByConsensus
* Handle error from createChildTxWhereParentTxWasAddedByConsensus
* Rename createChildTxWhereParentTxWasAddedByConsensus -> createChildAndParentTxsAndAddParentToConsensus
* Convert all MaximumXXX constants to uint64
* Add comment
* remove mutex comments
* Add prefix to stores
* Add prefix to forgotten stores
* Add a special type for prefix
* Rename transaction->dbTx
* Change error message
* Use countKeyName
* Rename Temporary Consesnsus to Staging
* Add DeleteStagingConsensus to Domain interface
* Add lock to staging consensus
* Make prefix type-safer
* Use ioutil.TempDir instead of t.TempDir
* Add BlockHash optional parameter to EstimateNetworkBlockHashesPerSecond
* Allow to pass '-' for optional values in kaspactl
* Solve a division-by-zero in estimateNetworkHashesPerSecond
* Add BlockHash to toAppMessage/fromAppMessage functions
* Rename: topHash -> StartHash
* Return proper error message if provided startHash doesn't deserialize into a hash
* 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
* Change mergeSet to be ordered topologically.
* Add special condition for genesis.
* Add check that the coinbase is validated.
* Change names of variables(old: chainHash, blueHash).
* Fix the DAG diagram in the comment above the function.
* Fix variables names.
Co-authored-by: tal <tal@daglabs.com>
Co-authored-by: Ori Newman <orinewman1@gmail.com>
* Fix overflow when checking coinbase maturity and don't ban peers that send transactions with immature spend
* Fix tests
Co-authored-by: Svarog <feanorr@gmail.com>
(cherry picked from commit a18f2f8802d52261c691ba1051d7b3134ddf8a78)
* Fix getBlock RPC command to return transactions
* Fix getBlocks RPC command to return transactions and blocks
* Add GetBlockEvenIfHeaderOnly and use it for getBlock and getBlocks
* Implement GetBlockEvenIfHeaderOnly for fakeRelayInvsContext
* Use less nested code
(cherry picked from commit 50fd86e2878a6dcf1399610d8edc146466a5b492)
* 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 a flag for sanity check pruning point utxo set and do the sanity check only if it's enabled
* add description to EnableSanityCheckPruningUTXOSet
* review fix
Co-authored-by: Svarog <feanorr@gmail.com>
* Add version file to database
* Remove redundant code
* Check for version before opening the database, create version file after
* Create version file before opening the database
* Add oldPruningPoint to pruningStore
* Make the pruning store work with utxo diff and return an iterator over pruning point utxoset
* Redesign pruning point utxo storage by creating a diff and modifying the old pruning utxo set
* Fix review comments
* Rename updatePruningPointUTXOSet
* Add ECDSA support
* Add domain separation to ECDSA sighash
* Use InfallibleWrite instead of Write
* Rename funcs
* Fix wrong use if vm.sigCache
* Add TestCalculateSignatureHashECDSA
* Add consts
* Fix comment and test name
* Move consts to the top
* Fix comment
* 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.
* [NOD-1429] add mining manager unit tests
* [NOD-1429] Add additional test
* found a bug, so stopped working on this test until the bug will be fix.
* Update miningmanager_test.go test.
* Delete payloadHash field - not used anymore in the current version.
* Change the condition for comparing slices instead of pointers.
* Fix due to review notes - change names, use testutils.CreateTransaction function and adds comments.
* Changes after fetch&merge to v0.10.0-dev
* Create a new function createChildTxWhenParentTxWasAddedByConsensus and add a comment
* Add an argument to create_transaction function and fix review notes
* Optimization
* Change to blockID(instead of the all transaction) in the error messages and fix review notes
* Change to blockID(instead of the all transaction) in the error messages and fix review notes
* Change format of error messages.
* Change name ofa variable
* Use go:embed to embed sample-kaspad.conf (only on go1.16)
* Revert "Use go:embed to embed sample-kaspad.conf (only on go1.16)"
This reverts commit bd28052b92b5a36f2ea826188d6876fddaf1802d.
Co-authored-by: karim1king <karimkaspersky@yahoo.com>
Co-authored-by: tal <tal@daglabs.com>
Co-authored-by: Ori Newman <orinewman1@gmail.com>
* 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
* 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
* [NOD-1424] Write general unit-tests for Reachability
* Update the tests of reachabilityManager.
* Add a diagram for the created DAG in the test.
* Change tabs to spaces in the diagram.
Co-authored-by: karim1king <karimkaspersky@yahoo.com>
Co-authored-by: tal <tal@daglabs.com>
Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>
* Save DAA score and DAA added blocks for each block
* Add test
* Add pruning support
* Replace 8 with uint64Length
* Separate DAABlocksStore cache size to DAA score and daaAddedBlocks
* Move timesorter to its own package and remove unused functions
* Remove padding+genesis from BlockWindow
* Adjust the difficulty even when there's less than difficultyAdjustmentWindowSize blocks
* Remove unnecessary check from checkBlockTransactionsFinalized
* Update tests with new pastMedianTime and Difficulty
* Review nit
* Write better tests for red blocks and DAA
* Fix comments
* Fix blue chain size
* Remove high timestamps from blue chain
Co-authored-by: Svarog <feanorr@gmail.com>
* Refactor mergeSetIncrease to return the current BFS block to allow easier merging
* Remove unneeded Heap/HashSet usages
* Add new IsAnyAncestorOf to DagTopolyManager
* Check if the new candidate is in the future of any existing candidate
* Add comments and fix off-by-one in the mergeSetIncrease queue
* Fixed DAGToplogy test mock
* Fix review 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>