20 Commits

Author SHA1 Message Date
stasatdaglabs
f46dec449d [NOD-510] Change all references to Bitcoin to Kaspa (#531)
* [NOD-510] Change coinbase flags to kaspad.

* [NOD-510] Removed superfluous spaces after periods in comments.

* [NOD-510] Rename btcd -> kaspad in the root folder.

* [NOD-510] Rename BtcEncode -> KaspaEncode and BtcDecode -> KaspaDecode.

* [NOD-510] Rename BtcEncode -> KaspaEncode and BtcDecode -> KaspaDecode.

* [NOD-510] Continue renaming btcd -> kaspad.

* [NOD-510] Rename btcjson -> kaspajson.

* [NOD-510] Rename file names inside kaspajson.

* [NOD-510] Rename kaspajson -> jsonrpc.

* [NOD-510] Finish renaming in addrmgr.

* [NOD-510] Rename package btcec to ecc.

* [NOD-510] Finish renaming stuff in blockdag.

* [NOD-510] Rename stuff in cmd.

* [NOD-510] Rename stuff in config.

* [NOD-510] Rename stuff in connmgr.

* [NOD-510] Rename stuff in dagconfig.

* [NOD-510] Rename stuff in database.

* [NOD-510] Rename stuff in docker.

* [NOD-510] Rename stuff in integration.

* [NOD-510] Rename jsonrpc to rpcmodel.

* [NOD-510] Rename stuff in limits.

* [NOD-510] Rename stuff in logger.

* [NOD-510] Rename stuff in mempool.

* [NOD-510] Rename stuff in mining.

* [NOD-510] Rename stuff in netsync.

* [NOD-510] Rename stuff in peer.

* [NOD-510] Rename stuff in release.

* [NOD-510] Rename stuff in rpcclient.

* [NOD-510] Rename stuff in server.

* [NOD-510] Rename stuff in signal.

* [NOD-510] Rename stuff in txscript.

* [NOD-510] Rename stuff in util.

* [NOD-510] Rename stuff in wire.

* [NOD-510] Fix failing tests.

* [NOD-510] Fix merge errors.

* [NOD-510] Fix go vet errors.

* [NOD-510] Remove merged file that's no longer relevant.

* [NOD-510] Add a comment above Op0.

* [NOD-510] Fix some comments referencing Bitcoin Core.

* [NOD-510] Fix some more comments referencing Bitcoin Core.

* [NOD-510] Fix bitcoin -> kaspa.

* [NOD-510] Fix more bitcoin -> kaspa.

* [NOD-510] Fix comments, remove DisconnectBlock in addrindex.

* [NOD-510] Rename KSPD to KASD.

* [NOD-510] Fix comments and user agent.
2019-12-12 15:21:41 +02:00
Svarog
369ec449a8 [NOD-509] Change organization name to kaspanet (#524)
* [NOD-509] Change organization name to kaspanet

* [NOD-509] Reorganize imports
2019-12-08 17:33:42 +02:00
Svarog
f4c6859e51 [NOD-509] Updated repository and imports to github.com/daglabs/kaspad (#521) 2019-12-08 16:28:53 +02:00
stasatdaglabs
1a569c7bd7 [NOD-270] Implement NotifyChainUpdates api call (#368)
* [NOD-270] Added notifyChainChanges and related commands.

* [NOD-270] Added NTChainChanged to blockdag.

* [NOD-270] Implemented collection and sending of ChainChanged notifications.

* [NOD-270] Fixed an improperly named test.

* [NOD-270] Added a test: TestChainChangedNotification.

* [NOD-270] Fixed a couple copy+paste errors.

* [NOD-270] Added a couple of comments for TestChainChangedNotification.

* [NOD-270] Fixed formatting error.

* [NOD-270] Fixed a comment.

* [NOD-270] Uncoupled chain updates inside blockdag from the concept of a notification.

* [NOD-270] Removed intermediary ChainUpdates object from ChainChangedNotificationData.
2019-08-21 12:58:32 +03:00
stasatdaglabs
5f49115cac [NOD-269] Implement GetChainFromBlock api-call (#364)
* [NOD-269] Added a skeleton for getChainFromBlock.

* [NOD-269] Made startHash and includeBlocks optional.

* [NOD-269] Implemented chainBlock collection.

* [NOD-269] Extracted GetBlockVerboseResult building to its own method.

* [NOD-269] Implemented the IncludeBlocks part of GetChainFromBlock.

* [NOD-269] Added a comment for NewGetChainFromBlockCmd.

* [NOD-269] Made IsInSelectedPathChain return an error.

* [NOD-269] Fixed a very wrong comment.

* [NOD-269] Made SelectedPathChain allocate only the required amount of space.

* [NOD-269] Renamed pathChain to parentChain.

* [NOD-269] Split handleGetChainFromBlock to separate functions.

* [NOD-269] Fixed some grammar.
2019-08-18 13:31:54 +03:00
stasatdaglabs
da7c9c7dfb [NOD-191] Added .acceptingBlock and .confirmations methods to blockNode (#305)
* [NOD-191] Added selectedPathChainSlice to virtualBlock.

* [NOD-191] Implemented acceptingBlock().

* [NOD-191] Implemented confirmations().

* [NOD-191] Added selectedPathChainSlice tests to TestSelectedPath.

* [NOD-191] Fixed a bug in acceptingBlock(). Written tests for confirmations().

* [NOD-191] Written tests for acceptingBlock().

* [NOD-191] Added test to make sure that acceptingBlock(tip) returns the virtual block.

* [NOD-191] Added a panic if we somehow feed a childless block that isn't the virtual to acceptingBlock.

* [NOD-191] Fixed comments.

* [NOD-191] Fixed a bug in acceptingBlock. Added red block tests for acceptingBlock.

* [NOD-191] Added red block tests for confirmations.

* [NOD-191] Fixed misleading comment and error message.
2019-05-23 10:57:03 +03:00
Ori Newman
254eab96cd [NOD-55] Change daghash hash to pointer in most places (#239)
* [NOD-55] Change daghash.Hash to pointer in most places

* [NOD-55] Fixed format error

* [NOD-55] Fixed merge error

* [NOD-55] Cancel copying hash in blockSet.hashes()
2019-04-02 13:49:47 +03:00
Svarog
122520b9a5 Nod 42 restructure block acceptance logic (#217)
* [NOD-42] Split checkFinalityRules and newFinalityPoint

* [NOD-42] Rename connectToDAG -> addBlock + move anything that is not actually connecting block to DAG out of connectBlock

* [NOD-42] Extract methods from PastUTXO

* [NOD-42] Give names to outputs in verifyAndBuildUTXO and propagate name
changes up the call tree

* [NOD-42] Split loop that creates UTXODiff and updates acceptance data into 2 separate methods

* [NOD-42] Removed from applyUTXOChanges any validation logic, moved in any logic related to updating the DAG and renamed to applyDAGChanges

* [NOD-42] Rename: CheckTransactionInputs -> CheckTransactionInputsAndCalculateFee

* [NOD-42] Revise some comments

* [NOD-42] Removed finalityErr constant - it's not needed

* Multiple chain -> dag corrections in comments

* [NOD-42] Removed redundant declaration of feeData

* [NOD-42] Reworded some comments

* [NOD-42] Rename MultiblockTxsAcceptanceData -> MultiBlockTxsAcceptanceData
2019-03-19 11:21:27 +02:00
Ori Newman
7093155c3a [DEV-234] Add to txindex method to return the block in which tx was accepted (or indication it was not accepted) (#116)
* [DEV-234] add TxAcceptedInBlock and TxBlocks

* [DEV-234] test TxAcceptedInBlock and TxBlocks

* [DEV-234] test TxAcceptedInBlock and TxFirstBlockRegion

* [DEV-234] rename selectedPathSet to selectedPathChain

* [DEV-234] set indexers db as part of index manager initialization

* [DEV-234] remove redudant dag instance in txindex

* [DEV-234] fix TestTxIndexConnectBlock and add DAGParams as part of config in DAGSetup

* [DEV-234] TestTxIndexConnectBlock make K=1 to make calculations easier

* [DEV-234] rename TxAcceptingBlock to BlockThatAcceptedTx

* [DEV-234] update block fields names in txindex_test.go

* [DEV-234] rename selectedPathChain -> selectedPathChainSet
2018-11-05 16:11:54 +02:00
Ori Newman
c4a541d093 [DEV-91] Increase mempool test coverage part 2 (#107)
* [DEV-91] add TestAddrIndex

* [DEV-91] add TestFeeEstimator

* [DEV-91] rename TestFeeEstimator -> TestFeeEstimatorCfg

* [DEV-91] added TestCount

* [DEV-91] add TestExtractRejectCode in mempool_test.go

* [DEV-91] get rid of fakeErr type and defer unpatching monkey patch

* [DEV-91] use the result of monkey.patch to unpatch
2018-10-25 18:13:02 +03:00
Ori Newman
9ea9098fbc [DEV-204] Unexport VirtualBlock (#93)
* [DEV-201] In handleGetBlockDAGInfo calculate difficulty by the tip with the lowest bits

* [DEV-202] Move VirtualBlock.GetUTXOEntry to BlockDAG

* [DEV-203] Move VirtualBlock.SelectedTip() to BlockDAG

* [DEV-203] Move VirtualBlock.SelectedTip() to BlockDAG

* [DEV-204] Unexport VirtualBlock() and add CalcMedianTime method for DAG

* [DEV-204] add explanation about difficulty in CurrentBits() comment

* [DEV-204] unexport VirtualBlock type
2018-10-16 15:21:18 +03:00
Ori Newman
c3316715ae
[DEV-225] Always maintain a block set of selected parents chain. (#99)
* [DEV-225] Always maintain a block set of selected parents chain.

* [DEV-225] Add comments

* [DEV-225] remove oldSelectedParent != nil condition

* [DEV-225] move updating selected path logic to updateSelectedPathSet

* [DEV-225] fix typo in comment
2018-10-16 12:12:24 +03:00
Ori Newman
3c88184b38 [DEV-169] add to BlockDAG TipHashes() and HighestTipHash() and remove Tiphashes() and SelectedTipHash from VirtualBlock (#82)
* [DEV-169] add to BlockDAG TipHashes() and HighestTipHash() and remove Tiphashes() and SelectedTipHash from VirtualBlock

* [DEV-169] move highest node logic to separate method of blockset
2018-10-07 13:07:30 +03:00
Ori Newman
2f3e0a609c [DEV-150] Created separate lock for UTXOSet, and write lock it only when calling meldToBase() (#76)
* [DEV-150] refactor utxo set locks

* [DEV-150] meldToBase inside new function updateVirtualUTXO
2018-10-04 17:48:50 +03:00
Ori Newman
ca7df552a6 [DEV-168] use dag.Height instead of VirtualBlock.Height() and VirtualBlock().SelectedTipHeight() (#75) 2018-10-04 15:22:29 +03:00
Svarog
c8461dfcba [DEV-137] Calculate height correctly in blockdag and mining packages (#67) 2018-09-27 14:24:04 +03:00
Ori Newman
5fb220c38a Dev 105 get rid of utxoview (#58)
* [DEV-105] use utxodiff in mempool instead of utxoview

* [DEV-105] get rid of utxoview

* [DEV-105] fix tests to use utxoset

* [DEV-105] remove utxoview type

* [DEV-105] move DagSetup to test_utils.go

* [DEV-105] add comments and add blockdag/test_utils_test.go

* [DEV-105] add restoreInputs arg to removeTransaction

* [DEV-105] give more descriptive names to vars

* [DEV-115] close txChan outside of HandleNewBlock

* [DEV-105] rename DagSetup -> DAGSetup
2018-09-17 11:47:35 +03:00
Ori Newman
86feb42cc4 [DEV-104] Disable chained txs (#57)
* [DEV-104] Disable chained transactions

* [DEV-104] add TestApplyUTXOChanges

* [DEV-104] remove isCompatible

* [DEV-104] add TestDiffFromTx

* [DEV-104] reorder variables in TestApplyUTXOChanges

* [DEV-104] rename node -> containgNode in diffFromTx
2018-09-03 16:57:23 +03:00
stasatdaglabs
37cd482db3 [DEV-75] Update UTXO model to work with Diffs (#53)
* [DEV-75] Removed fetchEntryByHash, which was no longer used.

* [DEV-75] Removed a few functions in manager.go that weren't used by anything.

* [DEV-75] checkConnectBlock will soon not accept a utxoViewpoint, so removed the call to view.Tip() so that it could be deleted.

* [DEV-75] Got rid of tips in UtxoViewpoint.

* [DEV-75] Added the full UTXO set to the virtual block.

* [DEV-75] Implemented UTXO-wrangling when adding a new block.

* [DEV-75] Added isCoinbase to utxoEntry creation.

* [DEV-75] Added blockHeight to utxoEntry creation.

* Implemented fetching the fullUTXOSet from the database.

* [DEV-75] Simplified DAGState because almost all of the state in it was unnecessary. Also got rid of dbDAGState.

* [DEV-75] Made the process around adding a new block, UTXO-wise, much safer.

* [DEV-75] Implemented melding the virtual UTXO diff to the database.

* [DEV-75] Fixed utxoSet loading from the wrong bucket.

* [DEV-75] Began pruning utxoviewpoint.go. Replaced FetchUtxoEntry with a fullUTXOSet-based GetUTXOEntry.

* [DEV-75] Removed fetchUtxos.

* [DEV-75] Moved GetUTXOEntry into the virtual block.

* [DEV-75] Updated IndexManager to not use utxoViewpoints.

* [DEV-75] Fixed some bad login in restoreUTXO involving nodeDiffs.

* [DEV-75] Got rid of the UTXO spend journal, which wasn't used anywhere.

* [DEV-75] Moved some STXO-related validation logic out of connectToDAG and into checkConnectBlock.

* [DEV-75] Renamed UtxoXxx to UTXOXxx. Removed a bunch of methods that were no longer used by anything.

* [DEV-75] Another Utxo -> UTXO rename.

* [DEV-75] Removed IsModified from UTXOView, which was not used anywhere.

* [DEV-75] Renamed nodeDiff to provisionalNode. Added a bunch of comments.

* [DEV-75] Removed the test for genesis in pastUTXO, since it can never happen.

* [DEV-75] Wrote tests for errors in pastUTXO.

* [DEV-75] Wrote tests for errors in restoreUTXO.

* [DEV-75] Improved testErrorThroughPatching.

* [DEV-75] Wrote tests for errors in verifyAndBuildUTXO.

* [DEV-75] Used TipHashes instead of tips().hashes(), fixed comments in a few places, and brought back an error return that I erroneously removed.

* [DEV-75] Removed UTXO set logs.

* [DEV-75] Recreated add/remove/contains functions for utxoCollection.

* [DEV-75] Changed newUTXOEntry to use an object initializer.

* [DEV-75] Changed the UTXO bucket version to 1.

* Added a comment that clarifies that the index is not initialized before initDAGState is called.

* [DEV-75] Renamed GetVirtualBlock to VirtualBlock.

* [DEV-75] Removed superfluous variables.

* [DEV-75] Combined connectBlockToParents with updateParentsDiffs.

* [DEV-75] Removed another superfluous variable.

* [DEV-75] In pastUTXO, first fetch transactions from the database and only then add them.

* [DEV-75] Reworded the comment for commit().

* [DEV-75] Made all the connectUTXO subfunctions not BlockDAG methods.

* [DEV-75] Updated the comment for connectUTXO.

* [DEV-75] Updated the comment explaining why we're creating provisionalNodes.

* [DEV-75] Removed a couple of unnecessary calls to toProvisionalNode.

* [DEV-75] Renamed connectUTXO to applyUTXOChanges.

* [DEV-75] Replaced allProvisionalNodes with provisionalNodeSet, an object that holds provisionalNodes for this particular call to applyUTXOChanges.

* [DEV-75] Changed createProvisionalNode to accept a boolean "withParents" instead of relying on the caller to supply the node's parents or an empty set.

* [DEV-75] Made most applyUTXOChanges subfunctions be methods on provisionalNode.

* [DEV-75] Fixed a couple of bad comments.

* [DEV-75] Added descriptive error messages to callers of applyUTXOChanges.

* [DEV-75] Fixed weird English.

* [DEV-75] Replaced DAGState with a slice of DAG tip hashes.

* [DEV-75] In createProvisionalNode, changed withParents to withRelatives to avoid certain kinds of attacks.

* [DEV-75] Renamed createdProvisionalNode to newProvisionalNode.

* [DEV-75] Added precalculating the amount of transactions inside a new block's blue set.

* [DEV-75] Pruned unnecessary variable.
2018-08-30 16:00:03 +03:00
stasatdaglabs
460216be65 [DEV-89] Convert DAGView into VirtualBlock (#41)
* [DEV-74] Implemented and written tests for utxoIterator.

* [DEV-74] Improved utxoIterator tests.

* [DEV-74] Implemented utxoCollection tests.

* [DEV-74] Implemented utxoDiff and its tests.

* [DEV-74] Implemented utxoSet.

* [DEV -74] Added tests for fullUTXOSet.

* [DEV-74] Added some tests for diffUTXOSet.

* [DEV-74] Wrote tests for diffUTXOSet iterator.

* [DEV-74] Added a negative test for diffUTXOSet.withDiff.

* [DEV-74] Wrote tests for addTx.

* [DEV-74] Wrote a toRemove test for addTx.

* [DEV-74] Changed blockNode.utxoDiff to be of type utxoDiff.

* [DEV-74] Removed superfluous whitespace.

* [DEV-74] Renamed confusing "previousHash" to "hash".

* [DEV-74] Fixed bad test and corrected failing test.

* [DEV-74] Moved confusing "negatives" test to be part of the general utxoCollection test.

* [DEV-74] Removed utxoDiff.inverted.

* [DEV-74] Renamed blockNode.utxoDiff to blockNode.diff.

* [DEV-74] Renamed diff to diffFrom for clarity's sake.

* [DEV-74] Converted the type of utxoCollection from map[daghash.Hash]map[uint32]*wire.TxOut to map[wire.OutPoint]*UtxoEntry.

* [DEV-74] Corrected test names in utxoCollection_test.

* [DEV-74] Removed superfluous utxoCollection iterator and moved utxoIterator into utxoset.go.

* [DEV-74] Renamed variables in utxoset.go.

* [DEV-74] Renamed verifyTx to areInputsInUTXO and removed a superfulous test.

* [DEV-74] Fixed bad test logic in TestDiffUTXOSet_addTx.

* [DEV-74] Added a few comments. Added reference-equals checks to clone functions.

* [DEV-74] Moved utxoCollection and utxoDiff into utxoset.go.

* [DEV-74] Wrote explanations for utxoCollection and utxoDiff tests.

* [DEV-74] Wrote explanations for all utxoSet tests besides addTx.

* [DEV-74] Wrote explanations for TestDiffUTXOSet_addTx.

* [DEV-74] Moved the documentation for utxoDiff into utxoset.go.

* [DEV-74] Wrote an explanation on utxoSet.

* [DEV-75] Found a typo.

* [DEV-75] Renamed dag -> virtual, dagView -> virtualBlock.

* [DEV-75] Renamed newDAGView to newVirtualBlock.

* [DEV-75] Moved queries for the genesis block from virtualBlock to BlockDAG.

* [DEV-75] Got rid of chainView height and findFork.

* [DEV-75] Renamed receivers from c to v.

* [DEV-75] Updated initBlockNode to allow for virtual (headerless) nodes, updated dbDAGState to contain multiple tip hashes, implemented virtualBlock.setTips.

* [DEV-75] Got rid of virtualBlock.equals, which was not used anywhere.

* [DEV-75] Got rid of virtualBlock.tip().

* [DEV-75] Got rid of SetTip everywhere except for tests.

* [DEV-75] Got rid of Next().

* [DEV-75] Got rid of Contains().

* [DEV-75] Got rid of HeightRange(), as no one was using it.

* [DEV-75] Made verifyDAG in rpcserver.go not use block height for iteration.

* [DEV-75] Got rid of the part of Manager.Init() that handled "catching up" for side chains, which allowed me to get rid of BlockDAG.BlockByHeight().

* [DEV-75] Dropped support for the RPC command getblockhash since it was getting blocks by their height.

* [DEV-75] Dropped getnetworkhashps since it was reliant on height, fixed another couple of RPC commands to return nextHashes instead of a nextHash, and got rid of nodeByHeight in virtualBlock.

* [DEV-75] Got rid of setTip().

* [DEV-75] Moved blockLocator() out of virtualBlock and into BlockDAG. Also removed TestLocateInventory().

* [DEV-75] Implemented addTip().

* [DEV-75] Cleaned up virtualblock.go a bit.

* [DEV-75] Erased irrelevant tests in virtualblock_test.go. Moved dag-related tests into dag_test.go.

* [DEV-75] Removed unnecessary nil check.

* [DEV-75] Wrote tests for virtualBlock.

* [DEV-75] Fixed bad test, added explanations to tests.

* [DEV-89] Fixed a comment.

* [DEV-89] Fixed another comment.

* [DEV-89] Removed the section in Manager::Init that handled rolling back indexes to the main chain if their tip is an orphaned fork. This could only happen during reorg, which no longer exists. Also removed BlockDAG::MainChainHasBlock, which was no longer used by anyone.

* [DEV-89] Removed the nil check inside initBlockNode() and amended the one place that called it with nil.

* [DEV-89] Renamed the receiver param for BlockDAG from b to dag.

* [DEV-89] Moved fastLog2Floor from dag.go to btcutil/btcmath.go.

* [DEV-89] Renamed tstTip to testTip.

* [DEV-89] Renamed phanom_test.go to phantom_test.go.

* [DEV-89] Fixed comments, renamed mainChainHeight to dagHeight.

* [DEV-89] Rewrote virtualBlock.addTip().

* [DEV-89] Fixed a comment. (chain -> DAG)

* [DEV-89] Fixed another chain -> DAG comment.
2018-08-09 18:21:03 +03:00