3205 Commits

Author SHA1 Message Date
Ori Newman
d70e2be641 [DEV-236] add counter to blockdag that will increment for each valid … (#115)
* [DEV-236] add counter to blockdag that will increment for each valid block that is connected to the dag

* [DEV-236] increment dag.blockCount while building block index in initDagState

* [DEV-236] changed dag.BlockCount to return an unsigned value
2018-11-05 12:58:37 +02:00
Svarog
35546b62d0
[DEV-240] Style fixes to satisfy golint (#112)
* [DEV-240] Unexport BlockDAG/SelectedTip, since it returns unexported *blockNode

* [DEV-240] Fix blockdag package comment to satisfy golint

* [DEV-240] Add comment explaining blank import of ffldb in blockdag/test_utils.go

* [DEV-240] Add comment to FullUTXOSet.Get

* [DEV-240] Unexported config.DefaultHomeDir

* [DEV-240] Remove blank import of ffldb from config/config.go

* [DEV-240] Added comment to daghash.Strings()

* [DEV-240] Added missing comments in hdkeychain/extendedkey.go

* [DEV-240] Re-activate goline in CI Dockerfile

* [DEV-240] Fixed some typos in comments

* [DEV-240] Typo fix in comment
2018-11-05 12:58:17 +02:00
Ori Newman
78e8c6084c [DEV-238] Remove addrlocal from getPeerInfo RPC call (#117) 2018-11-04 10:09:39 +02:00
Svarog
8721f0d03f [DEV-253] Remove dependancy on github.com/pkg/errors (#113) 2018-11-01 14:45:59 +02:00
Ori Newman
4951c0bee0 [DEV-260] Don't update parents on initBlockNode (#114)
* [DEV-260] Don't update parents on initBlockNode

* [DEV-260] move addNodeAsChildToParents to blockdag/common_test.go

* [DEV-260] update newProvisionalNode comment
2018-11-01 14:43:38 +02:00
Ori Newman
3ebded9ae7 [DEV-255] create checkConnectToPastUTXO and move the required functionalities to it from checkConnectBlock1)
* [DEV-255] create checkConnectToPastUTXO and move the required functionalities to it from checkConnectBlock

* [DEV-255] get rid of checkConnectBlock

* [DEV-255] rename pNode -> node

* [DEV-255] add comment to describe ErrWithDiff
2018-10-29 17:58:09 +02:00
Ori Newman
3ff2ef19e4 [DEV-254] Defer any monkey unpatching (#109) 2018-10-29 12:16:58 +02:00
stasatdaglabs
3ace16ad23 [DEV-134] Implement Continuous Integration (#105)
* [DEV-134] Implement Continuous Integration

Squashed commit:

[5e41d830] Dev 223 fix txindex (#100)

* [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

* [DEV-223] make applyUTXOChanges return pastUTXOResults

* [DEV-223] add bluestxdata for current block as well

* [DEV-223] re-design tx index

* [DEV-223] edit txindex comments

* [DEV-223] rename BluesTxData -> AcceptedTxData, and return from applyUTXOChanges only transactions that got accepted

* [DEV-223] add unit test for txindex

* [DEV-223] fix comments and unite blueTransaction and AcceptedTxData to one type

* [DEV-223] use bucket cursor for dbFetchFirstTxRegion

* [DEV-223] use the same cursor instance for dbFetchFirstTxRegion

* [DEV-223] write in dbFetchFirstTxRegion's comment that it returns the first block region

* [DEV-223] rename type BlueBlockTransaction to TxWithBlockHash

* [DEV-223] add named returned value for applyUTXOChanges

[4c95e293] [DEV-134] Made golint ignore the vendor directory.

[21736dbc] [DEV-134] Renamed ExampleBlockChain_ProcessBlock to ExampleBlockDAG_ProcessBlock to satisfy go vet.

[beea6486] [DEV-134] Removed pushing the built docker to a remove repository. That's unnecessary at this stage.

[bee911ed] [DEV-134] Made all precompilation checks run on everything instead of only the root dir.

[585f92ae] [DEV-134] Added "github.com/pkg/errors" to dep.

[5f02f570] [DEV-134] -vendor-only is written with only one hyphen.

[3eee7f95] [DEV-134] go vet instead of go tool vet.

[0c2d4343] [DEV-134] Split all the pre-compile checks to separate lines to be able to tell which of them is failing.

[780519c8] [DEV-134] Ran gofmt on everything.

[8247146b] Dev 223 fix txindex (#100)

* [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

* [DEV-223] make applyUTXOChanges return pastUTXOResults

* [DEV-223] add bluestxdata for current block as well

* [DEV-223] re-design tx index

* [DEV-223] edit txindex comments

* [DEV-223] rename BluesTxData -> AcceptedTxData, and return from applyUTXOChanges only transactions that got accepted

* [DEV-223] add unit test for txindex

* [DEV-223] fix comments and unite blueTransaction and AcceptedTxData to one type

* [DEV-223] use bucket cursor for dbFetchFirstTxRegion

* [DEV-223] use the same cursor instance for dbFetchFirstTxRegion

* [DEV-223] write in dbFetchFirstTxRegion's comment that it returns the first block region

* [DEV-223] rename type BlueBlockTransaction to TxWithBlockHash

* [DEV-223] add named returned value for applyUTXOChanges

[bff68aa3] [DEV-134] Gave executable permission to deploy.sh

[638a99d9] [DEV-134] Added jenkinsfile and deploy script.

* [DEV-134] Added a robust testing script.

* [DEV-134] Fixed a bash-ism.

* [DEV-134] Disabled testing with coverage for now.

* [DEV-134] Disabled golint and removed removing debug symbols.

* [DEV-134] Disabled aligncheck.

* [DEV-134] Disabled structcheck and varcheck.

* [DEV-134] Added "don't inline functions" to compiler flags for testing.

* [DEV-134] Made build fail if gofmt prints out anything.

* [DEV-134] Fixed misleading comment.

* [DEV-134] Added comments to test.sh.

* [DEV-134] Renamed tm to measure_runtime and removed do_ prefixes from functions.

* [DEV-134] Fixed gofmt line in build script.

* [DEV-134] Fixed gofmt some more.

* [DEV-134]  Fixed gofmt not actually failing due to logical or.
2018-10-25 18:58:41 +03: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
Evgeny Khirin
499adbf046 DEV-222: Changed type of TxOut.Value and util.Amount to uin64 (#108)
* [DEV-222] Changed type of TxOut.Value and util.Amount to uin64

* [DEV-222] Replaced math.MaxUint64 with 0

* [DEV-222] Fixed comment to reflect uint64 instead of int64

* [DEV-222] Fixed overflow comment
2018-10-24 16:29:50 +03:00
stasatdaglabs
ac01babfb1 [DEV-213] Converted all RPC commands to lowercaseCamelCase. (#106) 2018-10-23 12:24:57 +03:00
Ori Newman
5e41d83015
Dev 223 fix txindex (#100)
* [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

* [DEV-223] make applyUTXOChanges return pastUTXOResults

* [DEV-223] add bluestxdata for current block as well

* [DEV-223] re-design tx index

* [DEV-223] edit txindex comments

* [DEV-223] rename BluesTxData -> AcceptedTxData, and return from applyUTXOChanges only transactions that got accepted

* [DEV-223] add unit test for txindex

* [DEV-223] fix comments and unite blueTransaction and AcceptedTxData to one type

* [DEV-223] use bucket cursor for dbFetchFirstTxRegion

* [DEV-223] use the same cursor instance for dbFetchFirstTxRegion

* [DEV-223] write in dbFetchFirstTxRegion's comment that it returns the first block region

* [DEV-223] rename type BlueBlockTransaction to TxWithBlockHash

* [DEV-223] add named returned value for applyUTXOChanges
2018-10-21 16:01:22 +03:00
stasatdaglabs
d5787954ee
[DEV-167] Create full docker-based environment for client team testing (#78)
* [DEV-167] Created Dockerfile, dockerignore, and docker-compose.

* [DEV-167] Updated docker-compose to use remote image.

* [DEV-167] Added --addrindex to docker-compose.

* [DEV-167] Switched to testnet and plugged in the correct address.

* [DEV-167] Removed the third and fourth nodes from docker-compose.

* [DEV-167] Exposed RPC port, added rpcuser and rpcpass.

* [DEV-167] Wrangled RPC stuff into shape. Moved docker stuff into btcd/docker.

* [DEV-167] Moved dockerignore back to root. Corrected path for rpc.cert and rpc.key.

* [DEV-167] Added Jenkins job stuff.

* [DEV-167] Added deploy.sh.

* [DEV-167] Removed .travis.yaml and a couple of files that shouldn't be in this branch.
2018-10-18 11:49:11 +03:00
Ori Newman
201d7e0207 [DEV-226] Fix sorting of hashes in blockset.hashes() (#98)
* [DEV-226] Fix sorting of hashes in blockset.hashes()

* [DEV-226] add TestHashes
2018-10-17 15:35:56 +03:00
Ori Newman
3deaea6c15 [DEV-224] Fix getblockcount RPC command to show real data (#97)
* [DEV-224] Fix getblockcount RPC command to show real data

* [DEV-227] provisionalNode.commit() should not update the original parents if the provisionalNode was created with withRelatives=false

* [DEV-224] remove debug info from TestBlockCount and BlockDAG.BlockCount()
2018-10-17 15:34:10 +03:00
Ori Newman
85d221f322 [DEV-227] provisionalNode.commit() should not update the original parents if the provisionalNode was created with withRelatives=false (#96) 2018-10-17 11:41:36 +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
29a7d66d81 [DEV-219] Remove testnet and mainnet checkpoints (#94)
* [DEV-219] remove testnet checkpoints

* [DEV-219] remove mainnet checkpoints
2018-10-15 17:00:40 +03:00
Ori Newman
0bb2030200 [DEV-220] Fix NTBlockAccepted bug (#95) 2018-10-15 16:52:19 +03:00
Ori Newman
65788d4dc0 [DEV-200] convert nonce to uint64 (#90) 2018-10-15 15:17:41 +03:00
Ori Newman
695c0e5a68 [DEV-206] allow block timestamp to be equal to past median time (#89)
* [DEV-206] allow block timestamp to be equal to past median time

* [DEV-206] make more specific error messages

* [DEV-206] make independent nodes in TestPastMedianTime
2018-10-14 15:33:36 +03:00
Ori Newman
b0aaa79ad0 [DEV-195] Implement addmanualnode, getallmanualnodesinfo, getmanualnodeinfo and removemanualnode RPC-API calls (#87)
* [DEV-195] Implement addmanualnode, getallmanualnodesinfo, getmanualnodeinfo and removemanualnode RPC-API calls

* [DEV-195] fix wrong types for handleRemoveManualNode and handleGetManualNodeInfo

* [DEV-195] fix addednode terminology to manualnode

* [DEV-195] add default values to details and onetry

* [DEV-195] fix comments
2018-10-11 12:38:54 +03:00
Ori Newman
bb10f8484c [DEV-199] Apply the minimum-if-policy for all transactions (#88)
* [DEV-199] apply minimum if

* [DEV-199] refactor popIfBool

* [DEV-199] use popIfBool in OP_NOTIF
2018-10-11 11:21:14 +03:00
Ori Newman
030469f035 [DEV-149] Add test case for CVE-2018-17144 (Bitcoin DoS/Double Spend bug) (#77)
* [DEV-149] Add test case for CVE-2018-17144 (Bitcoin DoS/Double Spend bug)

* [DEV-149] change t.Errorf + return to t.Fatalf

* [DEV-149] fix malformed blocks

* [DEV-149] change test blocks to use simnet genesis
2018-10-09 15:40:00 +03:00
Svarog
45e0e6707b
[DEV-192] write 0 into indexesBucket when creating indexers to make mark indexer as initialized (#86) 2018-10-08 18:13:33 +03:00
Mike Zak
faf5efa455 [DEV-189] Fixed blockSet.highest() case when highest==nil 2018-10-08 18:03:58 +03:00
Ori Newman
ab7d9f2fa7 [DEV-170] Get rid of utxo collection functions (#79) 2018-10-08 15:51:20 +03:00
stasatdaglabs
6b302dad7c
[DEV-92] Ensure 100% coverage in blockdag package (#71)
* [DEV-92] Covered lookupPreviousNodes in tests.

* [DEV-92] Covered accept.go in tests.

* [DEV-92] Fixed a typo.

* [DEV-92] Covered blockindex.go in tests.

* [DEV-92] Replaced Errorf + return with Errorf. Added the test case to the error messages.

* [DEV-92] Fixed grammar in a comment.

* [DEV-92] Split casting error checking and ErrorCode checking into separate tests.

* [DEV-92] Improved errors.

* [DEV-92] Made errors a tiny bit more descriptive.
2018-10-08 13:02:15 +03:00
Ori Newman
d414ce5522 [DEV-165] Implement pastMedianTimeCalculation (#81) 2018-10-08 12:24:30 +03:00
Ori Newman
d9a81b2a84 [DEV-193] Invert previous blocks order to be from low hash to high hash (#84)
* [DEV-189] invert arguments order or daghash.Less

* [DEV-189] invert arguments order of daghash.Less in blockset.highest

* [DEV-189] change to equivalent condition in Hash.Less to make it prettier

* [DEV-194] change prevblocks order to be from low hash to high hash
2018-10-08 12:14:18 +03:00
Ori Newman
0643b0d920 [DEV-189] invert arguments order of daghash.Less (#83)
* [DEV-189] invert arguments order or daghash.Less

* [DEV-189] invert arguments order of daghash.Less in blockset.highest

* [DEV-189] change to equivalent condition in Hash.Less to make it prettier
2018-10-07 16:44:29 +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
Ori Newman
df23d87503 [DEV-164] add bluest parent (#74)
* [DEV-164] use bluestParent from time calculations

* [DEV-164] use bluestParent next difficulty calculations

* [DEV-164] get rid of blockset.first()
2018-10-04 10:35:22 +03:00
Yuri
29b9f6a9b2 Change glide to dep in README.md (#80) 2018-10-04 10:13:22 +03:00
Ori Newman
c9dadfef1b [DEV-166] fix endless loop in validate parents (#73)
* [DEV-66] fix endless loop in validateParents

* [DEV-166] add TestValidateParents

* [DEV-166] use generateNode in TestValidateParents to avoid repetition

* [DEV-166] use blockDAG.genesis instead of blockDAG.virtual.SelectedTip()
2018-09-30 13:30:55 +03:00
Ori Newman
b2648cf1fd [DEV-132] change TargetTimePerBlock to 10 seconds (#66)
* [DEV-132] change TargetTimePerBlock to 10 seconds

* [DEV-132] change pow limits to regtest limits in all networks, enable cpu mining in testnet, and get rid of dns seeds in testnet
2018-09-30 12:34:08 +03:00
Ori Newman
18f54d13a4 [DEV-126] Get rid of tfSpent in txoFlags (#69) 2018-09-30 12:30:40 +03:00
Svarog
fae411706e [DEV-137] calculate height correctly in blockdag and mining packages (#72)
* [DEV-137] calculate height correctly in blockdag and mining packages

* [DEV-137] Fix tests that didn't set block height
2018-09-30 11:16:51 +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
b348449f01 [DEV-91] Ensure 100% coverage in mempool package (#70)
* [DEV-91] add tests for RemoveOrphansByTag

* [DEV-91] Add tests for orphan tx expiration

* [DEV-91] add TestDoubleSpends

* [DEV-91] add TestFetchTransaction

* [DEV-91] added a test for MinHighPriority

* [DEV-91] test unparsable scripts

* [DEV-91] test MaxOrphanTxs=0

* [DEV-91] add TestRemoveTransaction

* [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] change checkPoolDoubleSpend to check utxodiff

* [DEV-105] add restoreInputs arg to removeTransaction

* [DEV-91] add restoreInputs arg to removeTransaction in unit tests

* [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

* [DEV-91] remove IsSpentInDiff

* [DEV-91] fix comment

* [DEV-91] Make IsPushOnlyScript return an error if the script cannot be parsed

* [DEV-91] add more tests for IsPushOnlyScript

* [DEV-91] fix comments

* [DEV-91] fix NewAddressPubKeyHash
2018-09-27 14:11:26 +03:00
Ori Newman
1cd82fcd3b [DEV-91] Ensure 100% coverage in mempool package (#60)
* [DEV-91] add tests for RemoveOrphansByTag

* [DEV-91] Add tests for orphan tx expiration

* [DEV-91] add TestDoubleSpends

* [DEV-91] add TestFetchTransaction

* [DEV-91] added a test for MinHighPriority

* [DEV-91] test unparsable scripts

* [DEV-91] test MaxOrphanTxs=0

* [DEV-91] add TestRemoveTransaction

* [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] change checkPoolDoubleSpend to check utxodiff

* [DEV-105] add restoreInputs arg to removeTransaction

* [DEV-91] add restoreInputs arg to removeTransaction in unit tests

* [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

* [DEV-91] remove IsSpentInDiff

* [DEV-91] fix comment

* [DEV-91] Make IsPushOnlyScript return an error if the script cannot be parsed

* [DEV-91] add more tests for IsPushOnlyScript

* [DEV-91] fix comments
2018-09-27 12:09:19 +03:00
Ori Newman
81453b221d [DEV-128] Fix BTCD sync (#65)
* [DEV-115] fix mistype mainCfg -> cfg in config/config.go

* [DEV-115] add config log

* [DEV-115] always handle block announcments

* [DEV-128] delete indexer tips bucket

* [DEV-128] disable cfilters by default

* [DEV-128] get rid of dbIndexDisconnectBlock and dbIndexConnectBlock

* [DEV-128] fix NTBlockConnected to send a block instead of TipHashes
2018-09-25 12:06:22 +03:00
stasatdaglabs
6dd3b815c1 [DEV-17] Move Bech32Prefix-related code from btcd/chaincfg/params.go to btcdutil (#62)
* [DEV-17] Moved Bech32 stuff from params.go to address.go.

* [DEV-17] Removed dagconfig dependency from address_test.go.

* [DEV-17] Removed dagconfig dependency from builder_test.go.

* [DEV-17] Removed dagconfig dependency from internal_test.go.

* [DEV-17] Removed dagconfig dependency from wif.go.

* [DEV-17] Removed dagconfig dependency from externdedkey.go.

* [DEV-17] Fixed compilation errors outside of hdkeychain.

* [DEV-17] Resolved circular dependencies.

* [DEV-17] Fixed failing tests.

* [DEV-17] Renamed DagXxx to Bech32PrefixDAGXxx

* [DEV-17] Fixed register_test.go.

* [DEV-17] Renamed HDKeyIDPairXxxNet to XxxNetHDKeyPair.

* [DEV-17] Renamed IsForNet to IsForPrefix.
2018-09-23 15:49:50 +03:00
Mike Zak
9b5aa66e5b Merge branch 'master' of github.com:daglabs/btcd 2018-09-23 15:44:58 +03:00
Ori Newman
e5545e2ee6 [DEV-130] convert searchrawtransaction ints to bools (#61) 2018-09-23 11:30:47 +03:00
Ori Newman
d739bf5034 [DEV-129] switch the locations in json between reqsigs and type (#63) 2018-09-23 11:27:38 +03:00
Ori Newman
21e9fde74d [DEV-127] remove getwork rpc command 2018-09-23 11:23:56 +03:00