Commit graph

1174 commits

Author SHA1 Message Date
Wladimir J. van der Laan 05998da5a7
Merge #8865: Decouple peer-processing-logic from block-connection-logic
a9aec5c Use BlockChecked signal to send reject messages from mapBlockSource (Matt Corallo)
7565e03 Remove SyncWithWallets wrapper function (Matt Corallo)
12ee1fe Always call UpdatedBlockTip, even if blocks were only disconnected (Matt Corallo)
f5efa28 Remove CConnman parameter from ProcessNewBlock/ActivateBestChain (Matt Corallo)
fef1010 Use CValidationInterface from chain logic to notify peer logic (Matt Corallo)
aefcb7b Move net-processing logic definitions together in main.h (Matt Corallo)
0278fb5 Remove duplicate nBlocksEstimate cmp (we already checked IsIBD()) (Matt Corallo)
87e7d72 Make validationinterface.UpdatedBlockTip more verbose (Matt Corallo)
2016-10-18 22:48:51 +02:00
Wladimir J. van der Laan 744d2652dd
Merge #8223: [c++11] Use std::unique_ptr for block creation.
9fce062 [c++11] Use std::unique_ptr for block creation. (Daniel Kraft)
2016-10-18 21:16:08 +02:00
Wladimir J. van der Laan cdfb7755a6
Merge #8914: Kill insecure_random and associated global state
5eaaa83 Kill insecure_random and associated global state (Wladimir J. van der Laan)
2016-10-18 15:44:57 +02:00
Wladimir J. van der Laan 5eaaa83ac1 Kill insecure_random and associated global state
There are only a few uses of `insecure_random` outside the tests.
This PR replaces uses of insecure_random (and its accompanying global
state) in the core code with an FastRandomContext that is automatically
seeded on creation.

This is meant to be used for inner loops. The FastRandomContext
can be in the outer scope, or the class itself, then rand32() is used
inside the loop. Useful e.g. for pushing addresses in CNode or the fee
rounding, or randomization for coin selection.

As a context is created per purpose, thus it gets rid of
cross-thread unprotected shared usage of a single set of globals, this
should also get rid of the potential race conditions.

- I'd say TxMempool::check is not called enough to warrant using a special
  fast random context, this is switched to GetRand() (open for
  discussion...)

- The use of `insecure_rand` in ConnectThroughProxy has been replaced by
  an atomic integer counter. The only goal here is to have a different
  credentials pair for each connection to go on a different Tor circuit,
  it does not need to be random nor unpredictable.

- To avoid having a FastRandomContext on every CNode, the context is
  passed into PushAddress as appropriate.

There remains an insecure_random for test usage in `test_random.h`.
2016-10-17 13:08:35 +02:00
Johnson Lau 9260085377 test segwit uncompressed key fixes 2016-10-17 00:34:37 +08:00
Johnson Lau 4c0c25a604 Require compressed keys in segwit as policy and disable signing with uncompressed keys for segwit scripts 2016-10-16 23:53:35 +08:00
Johnson Lau acf853df91 Add script tests for FindAndDelete in pre-segwit and segwit scripts 2016-10-16 00:30:50 +08:00
Wladimir J. van der Laan e2b8c394d6
Merge #8817: update bitcoin-tx to output witness data
4408558 Update bitcoin-tx to output witness data. (jonnynewbs)
2016-10-13 18:56:43 +02:00
Pieter Wuille 6429cfa8a7
Merge #8393: Support for compact blocks together with segwit
27acfc1 [qa] Update p2p-compactblocks.py for compactblocks v2 (Suhas Daftuar)
422fac6 [qa] Add support for compactblocks v2 to mininode (Suhas Daftuar)
f5b9b8f [qa] Fix bug in mininode witness deserialization (Suhas Daftuar)
6aa28ab Use cmpctblock type 2 for segwit-enabled transfer (Pieter Wuille)
be7555f Fix overly-prescriptive p2p-segwit test for new fetch logic (Matt Corallo)
06128da Make GetFetchFlags always request witness objects from witness peers (Matt Corallo)
2016-10-10 13:16:40 +02:00
jnewbery 621441a7a7 add verbose mode to bitcoin-util-test.py 2016-10-05 09:16:08 -04:00
jonnynewbs 4408558843 Update bitcoin-tx to output witness data. 2016-10-05 09:00:34 -04:00
Matt Corallo f5efa28393 Remove CConnman parameter from ProcessNewBlock/ActivateBestChain 2016-10-04 13:51:32 -04:00
Pieter Wuille 6aa28abf53 Use cmpctblock type 2 for segwit-enabled transfer
Contains version negotiation logic by Matt Corallo and bugfixes by
Suhas Daftuar.
2016-10-04 19:10:41 +02:00
Wladimir J. van der Laan ef0801bd13
Merge #8830: [test] Add option to run bitcoin-util-test.py manually
b82f493 Add option to run bitcoin-util-test.py manually (jnewbery)
2016-09-30 17:03:21 +02:00
jnewbery da94697708 bitcoin-util-test.py should fail if the output file is empty 2016-09-29 10:16:56 -04:00
jnewbery b82f493938 Add option to run bitcoin-util-test.py manually 2016-09-29 08:54:56 -04:00
MarcoFalke 8ca69a2a88
Merge #8829: Add bitcoin-tx JSON tests
54e5d7c Add bitcoin-tx JSON tests (jnewbery)
2016-09-29 10:50:05 +02:00
jnewbery 54e5d7c1b8 Add bitcoin-tx JSON tests 2016-09-28 13:38:42 -04:00
Johnson Lau e41bd449ab Add policy: null signature for failed CHECK(MULTI)SIG 2016-09-27 23:40:59 +08:00
Wladimir J. van der Laan 5a4f6d72e6
Merge #8526: Make non-minimal OP_IF/NOTIF argument non-standard for P2WSH
c72c5b1 Make non-minimal OP_IF/NOTIF argument non-standard for P2WSH (Johnson Lau)
2016-09-27 17:10:15 +02:00
Pavel Janík 4731cab8fb Do not shadow variables 2016-09-27 09:25:15 +02:00
Johnson Lau c72c5b1e3b Make non-minimal OP_IF/NOTIF argument non-standard for P2WSH 2016-09-23 13:07:38 +08:00
MarcoFalke 3333bd2d15 [test] Remove redundant print in addrman_tests 2016-09-22 12:50:39 +02:00
Pieter Wuille d9ff591d42 Move static global randomizer seeds into CConnman 2016-09-19 15:53:47 +02:00
Cory Fields f60b9059e4 net: Pass best block known height into CConnman
CConnman then passes the current best height into CNode at creation time.

This way CConnman/CNode have no dependency on main for height, and the signals
only move in one direction.

This also helps to prevent identity leakage a tiny bit. Before this change, an
attacker could theoretically make 2 connections on different interfaces. They
would connect fully on one, and only establish the initial connection on the
other. Once they receive a new block, they would relay it to your first
connection, and immediately commence the version handshake on the second. Since
the new block height is reflected immediately, they could attempt to learn
whether the two connections were correlated.

This is, of course, incredibly unlikely to work due to the small timings
involved and receipt from other senders. But it doesn't hurt to lock-in
nBestHeight at the time of connection, rather than letting the remote choose
the time.
2016-09-08 12:24:06 -04:00
Cory Fields bd72937dc4 net: move nLocalServices/nRelevantServices to CConnman
These are in-turn passed to CNode at connection time. This allows us to offer
different services to different peers (or test the effects of doing so).
2016-09-08 12:24:06 -04:00
Cory Fields 551e0887db net: move nLastNodeId to CConnman 2016-09-08 12:24:06 -04:00
Cory Fields a0f3d3cdad net: move ban and addrman functions into CConnman 2016-09-08 12:12:57 -04:00
Cory Fields aaf018e3b7 net: handle nodesignals in CConnman 2016-09-08 12:06:24 -04:00
Cory Fields 8d58c4d81f net: Pass CConnman around as needed 2016-09-08 12:04:35 -04:00
Cory Fields cd16f48028 net: Create CConnman to encapsulate p2p connections 2016-09-08 12:04:35 -04:00
MarcoFalke ddc308068d
Merge #8671: Minimal fix to slow prevector tests as stopgap measure
f71d4a3 Minimal fix to slow prevector tests as stopgap measure (Jeremy Rubin)
2016-09-08 11:12:50 +02:00
Jeremy Rubin 426e7bce0e Fix obvious assignment/equality error in test 2016-09-06 16:22:13 -04:00
Jeremy Rubin f71d4a3786 Minimal fix to slow prevector tests as stopgap measure 2016-09-06 16:19:25 -04:00
Wladimir J. van der Laan 381d0ddc8a
Merge #8449: [Trivial] Do not shadow local variable, cleanup
a159f25 Remove redundand (and shadowing) declaration (Pavel Janík)
cce3024 Do not shadow local variable, cleanup (Pavel Janík)
2016-09-02 12:25:59 +02:00
Wladimir J. van der Laan 6f939c9080
Merge #8629: C++11: s/boost::scoped_ptr/std::unique_ptr/
cdd79eb C++11: s/boost::scoped_ptr/std::unique_ptr/ (Jorge Timón)
2016-09-02 09:56:33 +02:00
Jorge Timón cdd79eb70f C++11: s/boost::scoped_ptr/std::unique_ptr/ 2016-09-01 19:05:07 +02:00
Pieter Wuille 19b0f33de0
Merge #8524: Precompute sighashes
35fe039 Rename to PrecomputedTransactionData (Pieter Wuille)
ab48c5e Unit test for sighash caching (Nicolas DORIER)
d2c5d04 Precompute sighashes (Pieter Wuille)
2016-09-01 12:20:43 +02:00
Pieter Wuille 35fe0393f2 Rename to PrecomputedTransactionData 2016-08-26 18:44:10 +02:00
MarcoFalke 95a983d56d
Merge #8578: [test] Remove unused code
fa1cf9e [test] Remove unused code (MarcoFalke)
2016-08-25 11:00:21 +02:00
MarcoFalke fa1cf9e7b8 [test] Remove unused code 2016-08-24 20:21:31 +02:00
Ethan Heilman dbb1f640e6 Added feeler connections increasing good addrs in the tried table.
Tests if addresses are online or offline by briefly connecting to them. These short lived connections are referred to as feeler connections. Feeler connections are designed to increase the number of fresh online addresses in tried by selecting and connecting to addresses in new. One feeler connection is attempted on average once every two minutes.

This change was suggested as Countermeasure 4 in
Eclipse Attacks on Bitcoin’s Peer-to-Peer Network, Ethan Heilman,
Alison Kendler, Aviv Zohar, Sharon Goldberg. ePrint Archive Report
2015/263. March 2015.
2016-08-23 16:26:42 -04:00
Nicolas DORIER ab48c5e721 Unit test for sighash caching 2016-08-16 15:37:56 +02:00
Pieter Wuille d2c5d044d0 Precompute sighashes
Original version by Nicolas Dorier. Precomputing version by Pieter Wuille.
2016-08-16 15:35:45 +02:00
MarcoFalke 6e5e5abba6
Merge #8270: Tests: Use portable #! in python scripts (/usr/bin/env)
7b01ce2 Favour python over python2 as per PR #7723 (Matthew King)
873e81f Use portable #! in python scripts (/usr/bin/env) (Matthew King)
2016-08-15 15:45:20 +02:00
Wladimir J. van der Laan 1030fa718c
Merge #8128: Net: Turn net structures into dumb storage classes
9e9d644 net: fixup nits (Cory Fields)
8945384 net: Have LookupNumeric return a CService directly (Cory Fields)
21ba407 net: narrow include scope after moving to netaddress (Cory Fields)
21e5b96 net: move CNetAddr/CService/CSubNet out of netbase (Cory Fields)
1017b8a net: Add direct tests for new CSubNet constructors (Cory Fields)
b6c3ff3 net: Split resolving out of CSubNet (Cory Fields)
f96c7c4 net: Split resolving out of CService (Cory Fields)
31d6b1d net: Split resolving out of CNetAddr (Cory Fields)
2016-08-15 13:35:27 +02:00
Pavel Janík a159f25e19 Remove redundand (and shadowing) declaration 2016-08-05 20:03:01 +02:00
Cory Fields 8945384bca net: Have LookupNumeric return a CService directly
Also fix up a few small issues:
- Lookup with "badip:port" now sets the port to 0
- Don't allow assert to have side-effects
2016-08-04 16:41:39 -04:00
Wladimir J. van der Laan f97d335942
Merge #8392: Fix several node initialization issues
9d4eb9a Do diskspace check before import thread is started (Pieter Wuille)
aa59f2e Add extra message to avoid a long 'Loading banlist' (Pieter Wuille)
0fd2a33 Use a signal to continue init after genesis activation (Pieter Wuille)
2016-08-04 12:33:21 +02:00
Wladimir J. van der Laan fc93486d2a
Merge #8428: Update README.md inside of src/test/
b8db185 Update README.md (Chris Stewart)
2016-08-03 11:00:30 +02:00
Wladimir J. van der Laan 63c03dd41c
Merge #8418: Add tests for compact blocks
45c7ddd Add p2p test for BIP 152 (compact blocks) (Suhas Daftuar)
9a22a6c Add support for compactblocks to mininode (Suhas Daftuar)
a8689fd Tests: refactor compact size serialization in mininode (Suhas Daftuar)
9c8593d Implement SipHash in Python (Pieter Wuille)
56c87e9 Allow changing BIP9 parameters on regtest (Suhas Daftuar)
2016-08-02 08:26:57 +02:00
Cory Fields 21ba407a73 net: narrow include scope after moving to netaddress
Net functionality is no longer needed for CAddress/CAddrman/etc. now that
CNetAddr/CService/CSubNet are dumb storage classes.
2016-07-31 14:01:44 -04:00
Cory Fields 1017b8a960 net: Add direct tests for new CSubNet constructors 2016-07-31 14:01:43 -04:00
Cory Fields b6c3ff3dae net: Split resolving out of CSubNet 2016-07-31 14:01:43 -04:00
Chris Stewart b8db185952 Update README.md
Updating documentation for adding new unit test files

Removing unneeded sentence from README

Removing uint160_tests.cpp as it DNE

Formatting command line instructions to use ``

fixing 80 char formatting issue in README

fixing more nits
2016-07-31 12:43:45 -05:00
Cory Fields f96c7c4d91 net: Split resolving out of CService 2016-07-31 13:24:07 -04:00
Cory Fields 31d6b1d5f0 net: Split resolving out of CNetAddr 2016-07-31 13:24:07 -04:00
Pieter Wuille 0fd2a33648 Use a signal to continue init after genesis activation 2016-07-30 02:17:47 +02:00
Pieter Wuille 9c8593d2b4 Implement SipHash in Python 2016-07-29 09:41:58 -04:00
Suhas Daftuar 8bfd70817b Enable size accounting in mining unit tests 2016-07-28 14:27:19 -04:00
Wladimir J. van der Laan 4324bd237c
Merge #8311: Rename CTxinWitness -> CTxInWitness
36ae37a Rename CTxinWitness -> CTxInWitness (Bob McElrath)
2016-07-14 08:18:38 +02:00
Wladimir J. van der Laan ff46dd4a34
Merge #7540: Rename OP_NOP3 to OP_CHECKSEQUENCEVERIFY
18c975c Rename NOP3 to CHECSEQUENCEVERIFY in rpc tests (BtcDrak)
14d0130 Rename OP_NOP3 to OP_CHECKSEQUENCEVERIFY (BtcDrak)
2016-07-08 11:39:10 +02:00
Bob McElrath 36ae37a9f9 Rename CTxinWitness -> CTxInWitness 2016-07-06 19:46:46 -04:00
Wladimir J. van der Laan 042c323922
Merge #8275: Remove bad chain alert partition check
ab8be98 Remove bad chain alert partition check (BtcDrak)
2016-07-06 07:35:54 +02:00
BtcDrak 14d01309be Rename OP_NOP3 to OP_CHECKSEQUENCEVERIFY 2016-06-28 17:17:36 +01:00
Matthew King 873e81f89b Use portable #! in python scripts (/usr/bin/env) 2016-06-26 16:47:03 +03:00
Jonas Nick fdb43df23e [qa] Add GetTransactionSigOpCost unit tests 2016-06-22 15:43:02 +02:00
Suhas Daftuar d846e02372 [qa] script_tests: witness tests can specify tx amount
Add tests that witness signatures cover value
2016-06-22 15:43:02 +02:00
Suhas Daftuar 330b0f31ee [qa] p2p segwit tests
mininode now supports witness transactions/blocks, blocktools
has a helper for adding witness commitments to blocks, and script
has a function to calculate hashes for signature under sigversion
1, used by segwit.

Py3 conversion by Marco Falke

Test to make sure upgraded nodes don't ask for non-wit blocks by
Gregory Sanders.
2016-06-22 15:43:02 +02:00
Pieter Wuille 66cca79130 [qa] Autogeneration support for witness in script_tests 2016-06-22 15:43:01 +02:00
Pieter Wuille 06d3805c1a [qa] Add segwit support to script_tests
Contains fix by Johnson Lau.
2016-06-22 15:43:01 +02:00
NicolasDorier 00f46cbcd9 [qa] Add transaction tests for segwit
Including BIP143 P2WSH examples by jl2012.
2016-06-22 15:43:01 +02:00
Pieter Wuille 0aa9207451 [qa] Witness version 0 signing unit tests 2016-06-22 15:43:01 +02:00
Pieter Wuille 605e8473a7 BIP143: Signing logic 2016-06-22 15:43:01 +02:00
Thomas Kerin b7dbeb24eb [libconsensus] Script verification API with amounts
script_tests: always test bitcoinconsensus_verify_script_with_amount if VERIFY_WITNESS isn't set

Rename internal method + make it static

trim bitcoinconsensus_ prefix

Add SERIALIZE_TRANSACTION_WITNESS flag
2016-06-22 15:43:00 +02:00
Pieter Wuille 2b1f6f9ccf BIP141: Other consensus critical limits, and BIP145
Includes changes by Suhas Daftuar, Luke-jr, and mruddy.
2016-06-22 15:43:00 +02:00
Pieter Wuille 3dd410294d BIP143: Verification logic
Includes simplifications by Eric Lombrozo.
2016-06-22 15:43:00 +02:00
Pieter Wuille 0ef1dd3e11 Refactor script validation to observe amounts
This is a preparation for BIP143 support.
2016-06-22 15:43:00 +02:00
Pieter Wuille 449f9b8deb BIP141: Witness program 2016-06-22 15:42:59 +02:00
Pieter Wuille 7030d9eb47 BIP144: Serialization, hashes, relay (sender side)
Contains refactorings by Eric Lombrozo.
Contains fixup by Nicolas Dorier.
Contains cleanup of CInv::GetCommand by Alex Morcos
2016-06-22 15:42:59 +02:00
Wladimir J. van der Laan e9d76a161d
Merge #8068: Compact Blocks
48efec8 Fix some minor compact block issues that came up in review (Matt Corallo)
ccd06b9 Elaborate bucket size math (Pieter Wuille)
0d4cb48 Use vTxHashes to optimize InitData significantly (Matt Corallo)
8119026 Provide a flat list of txid/terators to txn in CTxMemPool (Matt Corallo)
678ee97 Add BIP 152 to implemented BIPs list (Matt Corallo)
56ba516 Add reconstruction debug logging (Matt Corallo)
2f34a2e Get our "best three" peers to announce blocks using cmpctblocks (Matt Corallo)
927f8ee Add ability to fetch CNode by NodeId (Matt Corallo)
d25cd3e Add receiver-side protocol implementation for CMPCTBLOCK stuff (Matt Corallo)
9c837d5 Add sender-side protocol implementation for CMPCTBLOCK stuff (Matt Corallo)
00c4078 Add protocol messages for short-ids blocks (Matt Corallo)
e3b2222 Add some blockencodings tests (Matt Corallo)
f4f8f14 Add TestMemPoolEntryHelper::FromTx version for CTransaction (Matt Corallo)
85ad31e Add partial-block block encodings API (Matt Corallo)
5249dac Add COMPACTSIZE wrapper similar to VARINT for serialization (Matt Corallo)
cbda71c Move context-required checks from CheckBlockHeader to Contextual... (Matt Corallo)
7c29ec9 If AcceptBlockHeader returns true, pindex will be set. (Matt Corallo)
96806c3 Stop trimming when mapTx is empty (Pieter Wuille)
2016-06-22 14:30:38 +02:00
Wladimir J. van der Laan 961893f26e
Merge #8222: Enable mempool consistency checks in unit tests
3775ff9 Enable mempool consistency checks in unit tests (Pieter Wuille)
2016-06-22 08:48:37 +02:00
Wladimir J. van der Laan 94ab58b5cc
Merge #8179: Evict orphans which are included or precluded by accepted blocks.
54326a6 Increase maximum orphan size to 100,000 bytes. (Gregory Maxwell)
8c99d1b Treat orphans as implicit inv for parents, discard when parents rejected. (Gregory Maxwell)
11cc143 Adds an expiration time for orphan tx. (Gregory Maxwell)
db0ffe8 This eliminates the primary leak that causes the orphan map to  always grow to its maximum size. (Gregory Maxwell)
1b0bcc5 Track orphan by prev COutPoint rather than prev hash (Pieter Wuille)
2016-06-20 14:53:33 +02:00
Matt Corallo e3b2222144 Add some blockencodings tests 2016-06-19 01:34:57 -07:00
Matt Corallo f4f8f14adc Add TestMemPoolEntryHelper::FromTx version for CTransaction 2016-06-19 01:34:57 -07:00
Daniel Kraft 9fce0629b4 [c++11] Use std::unique_ptr for block creation.
CreateNewBlock returns a pointer for which the caller takes ownership.
Use std::unique_ptr to make this explicit and simplify handling of these
objects in getblocktemplate.
2016-06-18 19:38:28 +02:00
Pieter Wuille 3775ff9ea7 Enable mempool consistency checks in unit tests 2016-06-18 19:15:03 +02:00
Pieter Wuille 66db2d62d5
Merge #7600: Mining: Select transactions using feerate-with-ancestors
29fac19 Add unit tests for ancestor feerate mining (Suhas Daftuar)
c82a4e9 Use ancestor-feerate based transaction selection for mining (Suhas Daftuar)
2016-06-16 19:20:13 +02:00
Suhas Daftuar 29fac19c93 Add unit tests for ancestor feerate mining 2016-06-16 12:35:37 -04:00
Gregory Maxwell 54326a6808 Increase maximum orphan size to 100,000 bytes.
Although this increases node memory usage in the worst case by perhaps
 30MB, the current behavior causes severe issues with dependent tx relay.
2016-06-15 09:56:42 +00:00
BtcDrak ab8be98fdb Remove bad chain alert partition check
As per meeting 2016-03-31
https://bitcoincore.org/en/meetings/2016/03/31/#bad-chain-alerts

The partition checker was producing huge number of false-positives
and was disabled in 0.12.1 on the understanding it would either be
fixed in 0.13 or removed entirely from master if not.
2016-06-14 12:26:59 +01:00
Pieter Wuille ee06e04369 Introduce enum ServiceFlags for service flags 2016-06-13 17:40:16 +02:00
Pieter Wuille 15bf863219 Don't require services in -addnode 2016-06-13 17:40:16 +02:00
Wladimir J. van der Laan e1486eb95c
Merge #7598: Refactor CreateNewBlock to be a method of the BlockAssembler class
c2dd5a3 FIX: correctly measure size of priority block (Alex Morcos)
a278764 FIX: Account for txs already added to block in addPriorityTxs (Alex Morcos)
4dc94d1 Refactor CreateNewBlock to be a method of the BlockAssembler class (Alex Morcos)
2016-06-13 11:35:55 +02:00
Wladimir J. van der Laan 0b5279f89c
Merge #8166: src/test: Do not shadow local variables
c2715d3 Do not shadow local variables (Pavel Janík)
2016-06-09 08:25:25 +02:00
Wladimir J. van der Laan d36618585d
Merge #8168: util: Add ParseUInt32 and ParseUInt64
e012f3c util: Add ParseUInt32 and ParseUInt64 (Wladimir J. van der Laan)
2016-06-09 07:37:07 +02:00
Pieter Wuille 4286f43025
Merge #8173: Use SipHash for node eviction (cont'd)
eebc232 test: Add more test vectors for siphash (Wladimir J. van der Laan)
8884830 Use C++11 thread-safe static initializers (Pieter Wuille)
c31b24f Use 64-bit SipHash of netgroups in eviction (Pieter Wuille)
9bf156b Support SipHash with arbitrary byte writes (Pieter Wuille)
053930f Avoid recalculating vchKeyedNetGroup in eviction logic. (Patrick Strateman)
2016-06-08 18:32:34 +02:00
Wladimir J. van der Laan eebc232187 test: Add more test vectors for siphash
Add full test vectors from spec, test per byte and per 8 bytes.

Builds on #8086.
2016-06-08 15:50:55 +02:00
Wladimir J. van der Laan a7c41f2de0
Merge #8126: std::shared_ptr based CTransaction storage in mempool
288d85d Get rid of CTxMempool::lookup() entirely (Pieter Wuille)
c2a4724 Optimization: use usec in expiration and reuse nNow (Pieter Wuille)
e9b4780 Optimization: don't check the mempool at all if no mempool req ever (Pieter Wuille)
dbfb426 Optimize the relay map to use shared_ptr's (Pieter Wuille)
8d39d7a Switch CTransaction storage in mempool to std::shared_ptr (Pieter Wuille)
1b9e6d3 Add support for unique_ptr and shared_ptr to memusage (Pieter Wuille)
2016-06-08 14:01:18 +02:00
Wladimir J. van der Laan e012f3cea0 util: Add ParseUInt32 and ParseUInt64
Add error and range-checking parsers for unsigned 32 and 64 bit numbers.
The 32-bit variant is required for parsing sequence numbers from the
command line in `bitcoin-tx` (see #8164 for discussion). I've thrown in
the 64-bit variant as a bonus, as I'm sure it will be needed at some
point.

Also adds tests, and updates `developer-notes.md`.
2016-06-08 10:28:51 +02:00
Pavel Janík c2715d3ab8 Do not shadow local variables 2016-06-07 21:22:48 +02:00
Wladimir J. van der Laan 79004d4ae6
Merge #7957: [RPC][Bitcoin-TX] Add support for sequence number
ae357d5 [Bitcoin-Tx] Add tests for sequence number support (Jonas Schnelli)
e59336f [bitcoin-tx] allow to set nSequence number over the in= command (Jonas Schnelli)
a946bb6 [RPC] createrawtransaction: add option to set the sequence number per input (Jonas Schnelli)
2016-06-07 18:25:13 +02:00
Jonas Schnelli ae357d5ab9
[Bitcoin-Tx] Add tests for sequence number support 2016-06-07 17:37:35 +02:00
Pieter Wuille 9bf156bb9e Support SipHash with arbitrary byte writes 2016-06-07 16:20:40 +02:00
Pieter Wuille 288d85ddf2 Get rid of CTxMempool::lookup() entirely 2016-06-07 13:44:56 +02:00
Pieter Wuille ec45cc5e27
Merge #7992: Extend #7956 with one more test.
269a440 Add test for dbwrapper iterators with same-prefix keys. (Matt Corallo)
6030625 test: Add more thorough test for dbwrapper iterators (Wladimir J. van der Laan)
84c13e7 chain: Add assertion in case of missing records in index db (Wladimir J. van der Laan)
2016-06-02 19:14:34 +02:00
Pieter Wuille b89ef13114
Merge #7689: Replace OpenSSL AES with ctaes-based version
723779c build: Enumerate ctaes rather than globbing (Cory Fields)
34ed64a crypter: add tests for crypter (Cory Fields)
0a36b9a crypter: shuffle Makefile so that crypto can be used by the wallet (Cory Fields)
976f9ec crypter: add a BytesToKey clone to replace the use of openssl (Cory Fields)
9049cde crypter: hook up the new aes cbc classes (Cory Fields)
fb96831 crypter: constify encrypt/decrypt (Cory Fields)
1c391a5 crypter: fix the stored initialization vector size (Cory Fields)
daa3841 crypto: add aes cbc tests (Cory Fields)
27a212d crypto: add AES 128/256 CBC classes (Cory Fields)
6bec172 Add ctaes-based constant time AES implementation (Pieter Wuille)
a545127 Squashed 'src/crypto/ctaes/' content from commit cd3c3ac (Pieter Wuille)
2016-06-01 18:22:34 +02:00
Wladimir J. van der Laan a2df115249
Merge #8090: Adding P2SH(p2pkh) script test case
b682960 Adding P2SH(p2pkh) script test case (Chris Stewart)
2016-05-31 15:27:14 +02:00
Chris Stewart b682960a28 Adding P2SH(p2pkh) script test case
Fixing formatting

Adding test case into automatically generated test case set

Clean up commits

removing extra whitespace from eol

Removing extra whitespace on macro line
2016-05-30 08:51:37 -05:00
MarcoFalke a80de15113
Merge #8108: Trivial: Remove unused local variable shadowing upper local
13c4558 Remove unused local variable shadowing upper local (Pavel Janík)
2016-05-27 08:49:00 +02:00
Pavel Janík 13c455823f Remove unused local variable shadowing upper local 2016-05-27 07:46:36 +02:00
Ethan Heilman 2a8b3589b5 Fix typo adddrman to addrman as requested in #8070 2016-05-18 20:14:26 -04:00
Alex Morcos 4dc94d1036 Refactor CreateNewBlock to be a method of the BlockAssembler class 2016-05-18 14:11:12 -04:00
EthanHeilman f4119c6c98 Remove non-determinism which is breaking net_tests #8069 2016-05-18 12:26:41 -04:00
Wladimir J. van der Laan 5e374f7306
Merge #8020: Use SipHash-2-4 for various non-cryptographic hashes
a68ec21 Use SipHash-2-4 for address relay selection (Pieter Wuille)
8cc9cfe Switch CTxMempool::mapTx to use a hash index for txids (Pieter Wuille)
382c871 Use SipHash-2-4 for CCoinsCache index (Pieter Wuille)
0b1295b Add SipHash-2-4 primitives to hash (Pieter Wuille)
2016-05-18 11:01:42 +02:00
Matt Corallo 269a4402a8 Add test for dbwrapper iterators with same-prefix keys. 2016-05-17 19:44:58 -07:00
Pieter Wuille 0b1295b066 Add SipHash-2-4 primitives to hash 2016-05-17 20:04:42 +02:00
Pieter Wuille 5c3f8ddcaa
Merge #7696: Fix de-serialization bug where AddrMan is left corrupted
1475ecf Fix de-serialization bug where AddrMan is corrupted after exception * CAddrDB modified so that when de-serialization code throws an exception Addrman is reset to a clean state * CAddrDB modified to make unit tests possible * Regression test created to ensure bug is fixed * StartNode modifed to clear adrman if CAddrDB::Read returns an error code. (EthanHeilman)
2016-05-17 10:53:00 +02:00
Pieter Wuille 1f01443567
Merge #7994: Add op csv tests to script_tests.json
10e83d7 Adding basic tests for OP_CSV inside of script_tests.json (Chris Stewart)
2016-05-17 01:32:35 +02:00
Gregory Maxwell d87b198b73 Remove unneeded feerate param from RelayTransaction/AcceptToMemoryPool. 2016-05-16 04:10:06 +00:00
Cory Fields daa384120a crypto: add aes cbc tests 2016-05-13 10:23:03 +02:00
Pieter Wuille 6bec172eb9 Add ctaes-based constant time AES implementation 2016-05-13 10:22:54 +02:00
Chris Stewart 10e83d7956 Adding basic tests for OP_CSV inside of script_tests.json
Changing NOP3 op name to OP_CHECKSEQUENCEVERIFY, renaming instances of OP_NOP3 in script_tests.json to CHECKSEQUENCEVERIFY

Cleaning up NOP3 comment

Re-adding test cases that were accidentally deleted, removing dupicated test case, fixing formatting

Removing re-labeling of OP_NOP3 to OP_CSV

Fixing whitespace issues
2016-05-11 08:00:48 -05:00
Wladimir J. van der Laan 5767e80dda
Merge #8016: Fix multithread CScheduler and reenable test
166e4b0 Notify other serviceQueue thread we are finished to prevent deadlocks. (Pavel Janík)
db18ab2 Reenable multithread scheduler test. (Pavel Janík)
2016-05-10 12:08:08 +02:00
Wladimir J. van der Laan e29cfc48fc
Merge #7976: Remove obsolete reference to CValidationState from UpdateCoins.
c8b9248 Remove obsolete reference to CValidationState from UpdateCoins. (21E14)
2016-05-09 11:59:03 +02:00
Wladimir J. van der Laan f17032f703
Merge #7934: Improve rolling bloom filter performance and benchmark
1953c40 More efficient bitsliced rolling Bloom filter (Pieter Wuille)
aa62b68 Benchmark rolling bloom filter (Pieter Wuille)
2016-05-09 08:52:31 +02:00
Pavel Janík db18ab28c7 Reenable multithread scheduler test. 2016-05-06 20:44:39 +02:00
Wladimir J. van der Laan 006cdf64dc
Merge #7907: Optimize and Cleanup CScript::FindAndDelete
d1d7775 Improve worst-case behavior of CScript::FindAndDelete (Patrick Strateman)
e2a30bc Unit test for CScript::FindAndDelete (Gavin Andresen)
c0f660c Replace c-style cast with c++ style static_cast. (Patrick Strateman)
ec9ad5f Replace memcmp with std::equal in CScript::FindAndDelete (Patrick Strateman)
2016-05-05 19:01:32 +02:00
EthanHeilman 1475ecf611 Fix de-serialization bug where AddrMan is corrupted after exception
* CAddrDB modified so that when de-serialization code throws an exception Addrman is reset to a clean state
* CAddrDB modified to make unit tests possible
* Regression test created to ensure bug is fixed
* StartNode modifed to clear adrman if CAddrDB::Read returns an error code.
2016-05-04 18:55:01 -04:00
21E14 c8b92486c4 Remove obsolete reference to CValidationState from UpdateCoins. 2016-04-30 15:14:22 -04:00
MarcoFalke 0ad1041904
Merge #7807: Fixed miner test values, gave constants for less error-prone values.
f8536a6 Corrected values (instagibbs)
617deeb Gave miner test values constants for less error-prone values. (instagibbs)
2016-04-29 22:02:59 +02:00
Pieter Wuille 1953c40aa9 More efficient bitsliced rolling Bloom filter
This patch changes the implementation from one that stores 16 2-bit integers
in one uint32_t's, to one that stores the first bit of 64 2-bit integers in
one uint64_t and the second bit in another. This allows for 450x faster
refreshing and 2.2x faster average speed.
2016-04-28 14:56:32 +02:00
Wladimir J. van der Laan 6030625631 test: Add more thorough test for dbwrapper iterators
I made a silly mistake in a database wrapper where keys
were sorted by char instead of uint8_t. As x86 char is signed
the sorting for the block index database was messed up, resulting
in a segfault due to missing records.

Add a test to catch:
- Wrong sorting
- Seeking errors
- Iteration result not complete
2016-04-27 11:11:36 +02:00
Wladimir J. van der Laan e26b62093a
Merge #7933: Fix OOM when deserializing UTXO entries with invalid length
1e44169 Add tests for CCoins deserialization (Pieter Wuille)
5d0434d Fix OOM bug: UTXO entries with invalid script length (Pieter Wuille)
4bf631e CDataStream::ignore Throw exception instead of assert on negative nSize. (Patrick Strateman)
4f87af6 Treat overly long scriptPubKeys as unspendable (Pieter Wuille)
f8e6fb1 Introduce constant for maximum CScript length (Pieter Wuille)
2016-04-26 13:23:05 +02:00
Chris Stewart 62a9abd12b Fixing comment in script_test.json test case 2016-04-25 11:08:10 -05:00
Pieter Wuille 1e44169f0e Add tests for CCoins deserialization 2016-04-25 14:42:07 +02:00
Wladimir J. van der Laan b69836d6ff dbwrapper: Pass parent CDBWrapper into CDBBatch and CDBIterator
Pass parent wrapper directly instead of obfuscation key. This
makes it possible for other databases which re-use this code
to use other properties from the database.

Add a namespace dbwrapper_private for private functions to be used
only in dbwrapper.h/cpp and dbwrapper_tests.
2016-04-23 09:32:25 +02:00
Gavin Andresen e2a30bc9a9 Unit test for CScript::FindAndDelete 2016-04-19 13:22:45 -07:00
Wladimir J. van der Laan 04a2937357
Merge #7787: [Moveonly] Create ui_interface.cpp
fa10ce6 Move ui_interface.cpp to libbitcoin_server_a_SOURCES (MarcoFalke)
fabbf80 [ui] Move InitError, InitWarning, AmountErrMsg (MarcoFalke)
2016-04-19 16:10:57 +02:00
Wladimir J. van der Laan a25a4f5b04 wallet_ismine.h → script/ismine.h
Removes conditional dependency of `src/test` on wallet.

Makes multisig and P2SH tests complete without wallet built-in.
2016-04-18 15:14:36 +02:00
Wladimir J. van der Laan f4eae2d910 test: Create test fixture for wallet
Removes all the `#ifdef ENABLE_WALLET` from `test_bitcoin` by
making the wallet tests use their own fixture.
2016-04-18 14:57:42 +02:00
Wladimir J. van der Laan de39c95c24 test: move accounting_tests and rpc_wallet_tests to wallet/test
Move the two other wallet tests to where they belong.
2016-04-18 14:04:40 +02:00
Kaz Wesley 4ed41a2b61 test prevector::swap
- add a swap operation to prevector tests (fails due to broken prevector::swap)
- fix 2 prevector test operation conditions that were impossible
2016-04-16 08:05:11 -07:00
Wladimir J. van der Laan 9e47fcec17
Merge #7756: Add cursor to iterate over utxo set, use this in gettxoutsetinfo
509cb00 txdb: Add Cursor() method to CCoinsView to iterate over UTXO set (Wladimir J. van der Laan)
2016-04-15 16:43:21 +02:00
Wladimir J. van der Laan 509cb006d5 txdb: Add Cursor() method to CCoinsView to iterate over UTXO set
Add a method Cursor() to CCoinsView that returns a cursor which can be
used to iterate over the whole UTXO set.

- rpc: Change gettxoutsetinfo to use new Cursor method

- txdb: Remove GetStats method - Now that GetStats is implemented in
  terms of Cursor, remove it.
2016-04-15 16:33:05 +02:00
Wladimir J. van der Laan 48c5adfbce
Merge #6215: add bip32 pub key serialization
90604f1 add bip32 pubkey serialization (Jonas Schnelli)
2016-04-15 07:59:38 +02:00
Jonas Schnelli 90604f16af
add bip32 pubkey serialization
CExtPubKey should be serializable like CPubKey
2016-04-14 20:56:33 +02:00
MarcoFalke fa7abe0a00 [test] bctest.py: Revert faa41ee 2016-04-14 19:39:53 +02:00
Wladimir J. van der Laan 6ef5e000a2
Merge #7853: [qa] py2: Unfiddle strings into bytes explicitly
faa41ee [qa] py2: Unfiddle strings into bytes explicitly (MarcoFalke)
2016-04-14 17:40:31 +02:00
Wladimir J. van der Laan ab8586e667
Merge #7849: tests: add varints_bitpatterns test
4521f00 tests: add varints_bitpatterns test (Wladimir J. van der Laan)
2016-04-14 14:46:13 +02:00
Wladimir J. van der Laan 3911a0a1b7
Merge #7818: Refactor script tests
dde46d3 Merge script_valid and script_invalid tests (Pieter Wuille)
009b503 Get rid of expect in script_tests as it's implied by scripterror (Pieter Wuille)
76da761 Make script_error a mandatory 4th field for script_tests (Pieter Wuille)
269281b Fix some misconstructed tests (Pieter Wuille)
d03e466 Fix formatting of NOPs for generated script tests (Pieter Wuille)
c7c6641 Fix JSON pretty printing in script_tests (Pieter Wuille)
2016-04-14 13:27:41 +02:00
Wladimir J. van der Laan 536b75e946
Merge #7796: [amount] Add support for negative fee rates
facf5a4 [amount] tests: Fix off-by-one mistake (MarcoFalke)
fa2da2c [amount] Add support for negative fee rates (MarcoFalke)
11114a6 [amount] test negative fee rates and full constructor (MarcoFalke)
2016-04-14 12:07:52 +02:00
MarcoFalke faa41ee204 [qa] py2: Unfiddle strings into bytes explicitly 2016-04-10 20:35:57 +02:00
MarcoFalke facf5a4947 [amount] tests: Fix off-by-one mistake 2016-04-09 15:28:22 +02:00
Wladimir J. van der Laan 4521f005a1 tests: add varints_bitpatterns test
The current tests for varint only check that
serialization-deserialization is a roundtrip. That is a useful test, but
it is also good to check for some exact bit patterns, to prevent a code
change that changes the serialization format from going undetected.

As the varint functions are templated, also check with different types.
2016-04-09 09:17:51 +02:00
MarcoFalke 11114a69c8 [amount] test negative fee rates and full constructor 2016-04-08 19:59:44 +02:00
instagibbs f8536a62c3 Corrected values 2016-04-07 10:14:49 -04:00
instagibbs 617deeb06e Gave miner test values constants for less error-prone values. 2016-04-07 10:14:44 -04:00
Pieter Wuille dde46d3ae1 Merge script_valid and script_invalid tests 2016-04-05 16:11:47 +02:00
Pieter Wuille 009b503792 Get rid of expect in script_tests as it's implied by scripterror 2016-04-05 15:50:17 +02:00
Pieter Wuille 76da761351 Make script_error a mandatory 4th field for script_tests 2016-04-05 15:46:16 +02:00
Pieter Wuille 269281b7cc Fix some misconstructed tests
They claimed to be testing P2SH scripts with non-push scriptSigs, but
1) they were not enabling P2SH
2) they have push-only scriptSigs

Fix this, and add a few more related cases.
2016-04-05 14:54:37 +02:00
Pieter Wuille c7c664191f Fix JSON pretty printing in script_tests 2016-04-05 14:54:33 +02:00
mruddy 60361ca481 RPC: fix generatetoaddress failing to parse address and add unit test 2016-04-03 14:30:00 +00:00
MarcoFalke fabbf80f2f [ui] Move InitError, InitWarning, AmountErrMsg 2016-04-02 15:26:21 +02:00
Wladimir J. van der Laan 30c2dd8d05
Merge #7691: [Wallet] refactor wallet/init interaction
25340b7 [Wallet] refactor wallet/init interaction (Jonas Schnelli)
2016-04-02 11:07:39 +02:00
Wladimir J. van der Laan fb8a8cf2e6 rpc: Register calls where they are defined
Split out methods to every module, apart from 'help' and 'stop' which
are implemented in rpcserver.cpp itself.

- This makes it easier to add or remove RPC commands - no longer everything that includes
    rpcserver.h has to be rebuilt when there's a change there.
- Cleans up `rpc/server.h` by getting rid of the huge cluttered list of function definitions.
- Removes most of the bitcoin-specific code from rpcserver.cpp and .h.

Continues #7307 for the non-wallet.
2016-03-31 10:48:32 +02:00
Wladimir J. van der Laan 5131005e5b
Merge #7723: build: python 3 compatibility
18f05c7 build: python 3 compatibility (Wladimir J. van der Laan)
2016-03-29 17:22:46 +02:00
Wladimir J. van der Laan 18f05c765c build: python 3 compatibility
Ubuntu 16.04 "xenial xerus" does not come with Python 2.x by default.
It is possible to install a python-2.7 package, but this has its own
problem: no `python` or `python2` symlink (see #7717).

This fixes the following scripts to work with python 3:
- `make check` (bctest,py, bitcoin-util-test.py)
- `make translate` (extract_strings_qt.py)
- `make symbols-check` (symbol-check.py)
- `make security-check` (security-check.py)

Explicitly call the python commands using $(PYTHON) instead
of relying on the interpreter line at the top of the scripts.
2016-03-29 17:20:16 +02:00
instagibbs 7eb702954e Add importprunedfunds rpc call 2016-03-23 10:40:38 -04:00
Jonas Schnelli 25340b7cd5
[Wallet] refactor wallet/init interaction 2016-03-22 08:20:59 +01:00
Alex Morcos 9e072a6e66 Implement "feefilter" P2P message.
The "feefilter" p2p message is used to inform other nodes of your mempool min fee which is the feerate that any new transaction must meet to be accepted to your mempool.  This will allow them to filter invs to you according to this feerate.
2016-03-21 10:46:25 -04:00
Wladimir J. van der Laan 29b2be6ad7
Merge #7692: Remove p2p alert system
cfd519e Add release note documentation (BtcDrak)
6601ce5 protocol.h/cpp: Removes NetMsgType::ALERT (Thomas Kerin)
ad72104 Formatting (BtcDrak)
1b77471 Remove alert keys (BtcDrak)
01fdfef Remove `-alerts` option (BtcDrak)
9206634 Update alert notification and GUI (BtcDrak)
bbb9d1d Remove p2p alert handling (BtcDrak)
2016-03-21 13:41:05 +01:00
Wladimir J. van der Laan ddfd79659e
Merge #7705: [amount] Add tests and make GetFee() monotonic
fad13b1 [amount] Preempt issues with negative fee rates (MarcoFalke)
faf756a [amount] Make GetFee() monotonic (MarcoFalke)
fab6880 [qa] Add amount tests (MarcoFalke)
2016-03-21 12:40:31 +01:00
BtcDrak ad7210408c Formatting 2016-03-18 19:55:16 +00:00
BtcDrak bbb9d1d123 Remove p2p alert handling 2016-03-18 19:33:59 +00:00
Wladimir J. van der Laan 73b7eb501e
Merge #7575: Minimal BIP9 implementation
8c74ced RPC test for BIP9 warning logic (Suhas Daftuar)
7870deb Test versionbits deployments (Suhas Daftuar)
532cbb2 Add testing of ComputeBlockVersion (Suhas Daftuar)
d23f6c6 Softfork status report in RPC (Pieter Wuille)
732e774 Versionbits tests (Pieter Wuille)
6851107 BIP9 Implementation (Pieter Wuille)
2016-03-18 08:50:43 +01:00
MarcoFalke fab6880494 [qa] Add amount tests 2016-03-17 16:59:37 +01:00
Wladimir J. van der Laan 01f4267623
Merge #7594: Mempool: Add tracking of ancestor packages
ce019bf Check all ancestor state in CTxMemPool::check() (Suhas Daftuar)
e2eeb5d Add ancestor feerate index to mempool (Suhas Daftuar)
72abd2c Add ancestor tracking to mempool (Suhas Daftuar)
76a7632 Remove work limit in UpdateForDescendants() (Suhas Daftuar)
5de2baa Rename CTxMemPool::remove -> removeRecursive (Suhas Daftuar)
7659438 CTxMemPool::removeForBlock now uses RemoveStaged (Suhas Daftuar)
2016-03-17 13:33:54 +01:00
Wladimir J. van der Laan 14d6324a24
Merge #7187: Keep reorgs fast for SequenceLocks checks
982670c Add LockPoints (Alex Morcos)
2016-03-16 21:20:04 +01:00
Alex Morcos 982670c333 Add LockPoints
Obtain LockPoints to store in CTxMemPoolEntry and during a reorg, evaluate whether they are still valid and if not, recalculate them.
2016-03-16 16:11:46 -04:00
Wladimir J. van der Laan 3d0dfdbf9f
Merge #7684: [qa] Extend tests
fad8cfb [qa] mininode: Add and use CONSTs (MarcoFalke)
fa8cd46 [qa] Move create_tx() to util.py (MarcoFalke)
fad7dc8 [qa] wallet: speed up tests (MarcoFalke)
fa3a81a [tests] Extend util_ParseMoney test case (MarcoFalke)
2016-03-16 17:32:05 +01:00
Suhas Daftuar 7870debceb Test versionbits deployments 2016-03-15 16:54:39 +01:00
Suhas Daftuar 532cbb22b5 Add testing of ComputeBlockVersion 2016-03-15 16:54:39 +01:00
Pieter Wuille 732e774c06 Versionbits tests 2016-03-15 16:54:38 +01:00
Pieter Wuille 6851107b3a BIP9 Implementation
Inspired by former implementations by Eric Lombrozo and Rusty Russell, and
based on code by Jorge Timon.
2016-03-15 16:54:38 +01:00
Suhas Daftuar e2eeb5dda7 Add ancestor feerate index to mempool 2016-03-14 12:13:34 -04:00
Suhas Daftuar 5de2baa138 Rename CTxMemPool::remove -> removeRecursive
remove is no longer called non-recursively, so simplify the logic
and eliminate an unnecessary parameter
2016-03-14 12:11:09 -04:00
MarcoFalke fa3a81af18 [tests] Extend util_ParseMoney test case 2016-03-14 15:49:33 +01:00
Wladimir J. van der Laan f1ca8915bb
Merge #7517: test: script_error checking in script_invalid tests
0ecb340 test: Script_error checking in script_invalid tests (Wladimir J. van der Laan)
2317ad7 test: Re-introduce JSON pretty printing in test builder (Wladimir J. van der Laan)
b0ff857 test: Move non-generated script_invalid test to the correct place (Wladimir J. van der Laan)
2016-03-14 11:30:06 +01:00
Mustafa 2fdaa25529 Move GetTempPath() to testutil. 2016-03-11 15:04:05 +00:00
Mustafa 393b22eacb Add a source file for unit test utils. 2016-03-11 12:03:45 +00:00
Suhas Daftuar 086da92ea7 Add tags to mempool's mapTx indices 2016-02-16 12:35:16 -05:00
Wladimir J. van der Laan 93c85d458a
Merge #7524: BIP-112: Mempool-only CHECKSEQUENCEVERIFY
a381076 Code style fix. (BtcDrak)
c3c3752 Separate CheckLockTime() and CheckSequence() logic (BtcDrak)
53e53a3 BIP112: Implement CHECKSEQUENCEVERIFY (Mark Friedenbach)
2016-02-16 10:46:34 +01:00
Wladimir J. van der Laan f31b6b8995 test: test leading space for ParseHex
BerkeleyDB dump files have key and value lines indented.
The salvage code passes these to ParseHex as-is.
Check this in the tests (should just pass with current code).
2016-02-15 17:14:30 +01:00
Mark Friedenbach 53e53a33c9 BIP112: Implement CHECKSEQUENCEVERIFY
- Replace NOP3 with CHECKSEQUENCEVERIFY (BIP112)
  <nSequence> CHECKSEQUENCEVERIFY -> <nSequence>
- Fails if txin.nSequence < nSequence, allowing funds of a txout to be locked for a number of blocks or a duration of time after its inclusion in a block.
- Pull most of CheckLockTime() out into VerifyLockTime(), a local function that will be reused for CheckSequence()
- Add bitwise AND operator to CScriptNum
- Enable CHECKSEQUENCEVERIFY as a standard script verify flag
- Transactions that fail CSV verification will be rejected from the mempool, making it easy to test the feature. However blocks containing "invalid" CSV-using transactions will still be accepted; this is *not* the soft-fork required to actually enable CSV for production use.
2016-02-14 11:29:38 +00:00
Wladimir J. van der Laan 80d1f2e483
Merge #7184: Implement SequenceLocks functions for BIP 68
b043c4b fix sdaftuar's nits again (Alex Morcos)
a51c79b Bug fix to RPC test (Alex Morcos)
da6ad5f Add RPC test exercising BIP68 (mempool only) (Suhas Daftuar)
c6c2f0f Implement SequenceLocks functions (Alex Morcos)
2016-02-12 17:03:46 +01:00
Wladimir J. van der Laan 0ecb3401fe test: Script_error checking in script_invalid tests
Check the returned script_error. Add expected script_error
for generated as well as custom tests.

The specific error is not part of consensus, however
it could avoid unclear reporting issues such as #6862 in the future.

Fixes #7513.
2016-02-11 17:33:28 +01:00
Wladimir J. van der Laan 2317ad7c56 test: Re-introduce JSON pretty printing in test builder 2016-02-11 17:33:28 +01:00
Wladimir J. van der Laan b0ff8572ae test: Move non-generated script_invalid test to the correct place
This test was introduced in 9fadf1c874,
but accidentally added in the autogenerated area.
2016-02-11 16:16:40 +01:00
Alex Morcos c6c2f0fd78 Implement SequenceLocks functions
SequenceLocks functions are used to evaluate sequence lock times or heights per BIP 68.

The majority of this code is copied from maaku in #6312
Further credit: btcdrak, sipa, NicolasDorier
2016-02-10 15:35:33 -05:00
Wladimir J. van der Laan acf5983502 tests: Remove May15 test
This test is no longer relevant.

It was introduced in 8c222dca4f to check
the switch to 1MB blocks after the BDB too-many-locks issue back in
2013. The switching code has been long since removed.

It also needs a specific data file that is hard to find. I've verified
in #6320 that it still passes, however I think there is zero reason to
keep it.

Closes #6320.
2016-02-09 16:23:52 +01:00
Wladimir J. van der Laan 4f4dc5ef72
Merge #7070: Move maxTxFee out of mempool
fad6244 ATMP: make nAbsurdFee const (MarcoFalke)
fa762d0 [wallet.h] Remove main.h include (MarcoFalke)
fa79db2 Move maxTxFee out of mempool (MarcoFalke)
2016-02-04 14:54:23 +01:00
Luke Dashjr a68bb9f5e7 Merge branch 'master' into single_prodname 2016-02-03 05:41:13 +00:00
Luke Dashjr cc2095ecae Rewrite FormatParagraph to handle newlines within input strings correctly 2016-02-03 05:38:43 +00:00
MarcoFalke fa79db2641 Move maxTxFee out of mempool
Also, remove default values in CMerkleTx::AcceptToMemoryPool()
2016-02-02 20:08:51 +01:00
Pieter Wuille 5d743099b5 Get rid of inaccurate ScriptSigArgsExpected
(cherry picked from commit 52b29dca7670c3f6d2ab918c0fff1d17c4e494ad)
2016-02-01 15:28:25 +01:00
Wladimir J. van der Laan 326ffed09b
Merge #7212: Adds unittests for CAddrMan and CAddrinfo, removes source of non-determinism.
40c87b6 Increase test coverage for addrman and addrinfo (Ethan Heilman)
2016-01-28 13:14:07 +01:00
Wladimir J. van der Laan 62f2d769e4
Merge #7348: MOVE ONLY: move rpc* to rpc/
d13f65e rpc: update inline comments to refer to new file paths (Daniel Cousens)
a0eaff8 move rpc* to rpc/ (Daniel Cousens)
2016-01-28 11:28:24 +01:00
Ethan Heilman 40c87b6e69 Increase test coverage for addrman and addrinfo
Adds several unittests for CAddrMan and CAddrInfo.
Increases the accuracy of addrman tests.
Removes non-determinism in tests by overriding the random number generator.
Extracts testing code from addrman class to test class.
2016-01-27 10:50:58 -05:00
Wladimir J. van der Laan 9189e30b12
Merge #7300: [trivial] Add missing copyright headers
fabcee1 Remove copyright header from autogenerated chainparamsseeds.h (MarcoFalke)
fa60d05 Add missing copyright headers (MarcoFalke)
fa7e4c0 Bump copyright headers to 2014 (MarcoFalke)
2016-01-27 12:06:31 +01:00
Daniel Cousens a0eaff8a1d move rpc* to rpc/ 2016-01-21 08:36:55 +11:00
Wladimir J. van der Laan 9982710e88
Merge #7307: [RPC, Wallet] Move RPC dispatch table registration to wallet/ code
dd2dc40 [RPC, Wallet] Move RPC dispatch table registration to wallet/ code (Jonas Schnelli)
2016-01-20 15:15:51 +01:00
Jonas Schnelli dd2dc400ee
[RPC, Wallet] Move RPC dispatch table registration to wallet/ code
Allow extending the rpc dispatch table by appending commands when server is not running.
2016-01-20 15:03:25 +01:00
Chris Wheeler 9d263bd17c Typo fixes in comments 2016-01-17 11:03:56 +00:00
Cory Fields 89f71c68c0 c++11: don't throw from the reverselock destructor
noexcept is default for destructors as of c++11. By throwing in reverselock's
destructor if it's lock has been tampered with, the likely result is
std::terminate being called. Indeed that happened before this change.

Once reverselock has taken another lock (its ctor didn't throw), it makes no
sense to try to grab or lock the parent lock. That is be broken/undefined
behavior depending on the parent lock's implementation, but it shouldn't cause
the reverselock to fail to re-lock when destroyed.

To avoid those problems, simply swap the parent lock's contents with a dummy
for the duration of the lock. That will ensure that any undefined behavior is
caught at the call-site rather than the reverse lock's destruction.

Barring a failed mutex unlock which would be indicative of a larger problem,
the destructor should now never throw.
2016-01-05 17:17:29 -05:00
MarcoFalke fa60d05a4e Add missing copyright headers 2016-01-05 21:34:15 +01:00
MarcoFalke fa7e4c0919 Bump copyright headers to 2014 2016-01-05 21:01:39 +01:00
Wladimir J. van der Laan 605c17844e
Merge pull request #7205
fa71669 [devtools] Use git pretty-format for year parsing (MarcoFalke)
fa24439 Bump copyright headers to 2015 (MarcoFalke)
fa6ad85 [devtools] Rewrite fix-copyright-headers.py (MarcoFalke)
2016-01-05 14:11:40 +01:00
21E14 a5a0831458 Double semicolon cleanup. 2015-12-30 12:23:07 -05:00
mb300sd 37d271d7cc Rename OP_NOP2 to OP_CHECKLOCKTIMEVERIFY. 2015-12-15 02:01:45 -05:00
MarcoFalke fa24439ff3 Bump copyright headers to 2015 2015-12-13 18:08:39 +01:00
Pieter Wuille 5400ef6bcb Replace trickle nodes with per-node/message Poisson delays
We used to have a trickle node, a node which was chosen in each iteration of
the send loop that was privileged and allowed to send out queued up non-time
critical messages. Since the removal of the fixed sleeps in the network code,
this resulted in fast and attackable treatment of such broadcasts.

This pull request changes the 3 remaining trickle use cases by random delays:
* Local address broadcast (while also removing the the wiping of the seen filter)
* Address relay
* Inv relay (for transactions; blocks are always relayed immediately)

The code is based on older commits by Patrick Strateman.
2015-12-11 22:20:38 +01:00
Wladimir J. van der Laan 8843676621
Merge pull request #7133
aa4b0c2 When not filtering blocks, getdata sends more in one test (Pieter Wuille)
d41e44c Actually only use filterInventoryKnown with MSG_TX inventory messages. (Gregory Maxwell)
b6a0da4 Only use filterInventoryKnown with MSG_TX inventory messages. (Patick Strateman)
6b84935 Rename setInventoryKnown filterInventoryKnown (Patick Strateman)
e206724 Remove mruset as it is no longer used. (Gregory Maxwell)
ec73ef3 Replace setInventoryKnown with a rolling bloom filter. (Gregory Maxwell)
2015-12-03 13:16:46 +01:00
Wladimir J. van der Laan 1b0241fcec
Merge pull request #7144
8f0d79e test: Disable scheduler test manythreads (Wladimir J. van der Laan)
2015-12-02 10:18:20 +01:00
Alex Morcos 553cad94e2 Rewrite CreateNewBlock
Use the score index on the mempool to only add sorted txs in order.  Remove much of the validation while building the block, relying on mempool to be consistent and only contain txs that can be mined.
The mempool is assumed to be consistent as far as not containing txs which spend non-existent outputs or double spends, and scripts are valid.  Finality of txs is still checked (except not coinbase maturity, assumed in mempool).
Still TestBlockValidity in case mempool consistency breaks and return error state if an invalid block was created.
Unit tests are modified to realize that invalid blocks can now be constructed if the mempool breaks its consistency assumptions and also updated to have the right fees, since the cached value is now used for block construction.

Conflicts:
	src/miner.cpp
2015-12-01 12:09:37 -05:00
Alex Morcos f3fe83673e Add a score index to the mempool.
The score index is meant to represent the order of priority for being included in a block for miners.  Initially this is set to the transactions modified (by any feeDelta) fee rate.  Index improvements and unit tests by sdaftuar.
2015-12-01 10:10:25 -05:00
Alex Morcos c49d5bc9e6 Store the total sig op count of a tx.
Store sum of legacy and P2SH sig op counts.  This is calculated in AcceptToMemory pool and storing it saves redoing the expensive calculation in block template creation.
2015-12-01 10:10:25 -05:00
Wladimir J. van der Laan 8f0d79e3c8 test: Disable scheduler test manythreads
It causes occasional deadlocks, resulting in false negatives in Travis.

Disable the test for now.
Works around #6540.
2015-12-01 14:43:38 +01:00
Wladimir J. van der Laan 2ef5ffa59a
Merge pull request #6915
2d8860e Fix removeForReorg to use MedianTimePast (Suhas Daftuar)
b7fa4aa Don't call removeForReorg if DisconnectTip fails (Suhas Daftuar)
7e49f5f Track coinbase spends in CTxMemPoolEntry (Suhas Daftuar)
bb8ea1f removeForReorg calls once-per-disconnect-> once-per-reorg (Matt Corallo)
474b84a Make indentation in ActivateBestChainStep readable (Matt Corallo)
b0a064c Fix comment in removeForReorg (Matt Corallo)
9b060e5 Fix removal of time-locked transactions during reorg (Matt Corallo)
0c9959a Add failing test checking timelocked-txn removal during reorg (Matt Corallo)
2015-12-01 13:17:34 +01:00
Wladimir J. van der Laan 327291af02
Merge pull request #6914
114b581 Prevector type (Pieter Wuille)
2015-12-01 10:22:14 +01:00
Gregory Maxwell c143c499c8
Merge pull request #7072
996d311 [RPC] Add transaction size to JSON output (Nick)
2015-11-30 22:58:43 -08:00
Suhas Daftuar 7e49f5f8b4 Track coinbase spends in CTxMemPoolEntry
This allows us to optimize CTxMemPool::removeForReorg.
2015-11-30 13:12:53 -05:00
Gregory Maxwell e20672479e Remove mruset as it is no longer used. 2015-11-30 12:53:48 +01:00
Nick 996d3117c7 [RPC] Add transaction size to JSON output
This may be useful for blockchain explorers.
2015-11-28 17:06:56 +03:00
Pieter Wuille eece63fa72 Switch blocks to a constant-space Merkle root/branch algorithm.
This switches the Merkle tree logic for blocks to one that runs in constant (small) space.
The old code is moved to tests, and a new test is added that for various combinations of
block sizes, transaction positions to compute a branch for, and mutations:
 * Verifies that the old code and new code agree for the Merkle root.
 * Verifies that the old code and new code agree for the Merkle branch.
 * Verifies that the computed Merkle branch is valid.
 * Verifies that mutations don't change the Merkle root.
 * Verifies that mutations are correctly detected.
2015-11-27 15:36:52 +01:00
Wladimir J. van der Laan d8368a07ba
Merge pull request #7095
4ec3561 Replace scriptnum_test's normative ScriptNum implementation (Wladimir J. van der Laan)
2015-11-27 14:16:55 +01:00
Wladimir J. van der Laan 5ca149a3db
Merge pull request #7053
2e29e7e Globals: Remove a bunch of Params() calls from main.cpp: (Jorge Timón)
2015-11-27 13:29:54 +01:00
Wladimir J. van der Laan e92377fa7f
Merge pull request #6134
e304432 Pass reference to estimateSmartFee and cleanup whitespace (Suhas Daftuar)
56106a3 Expose RPC calls for estimatesmart functions (Alex Morcos)
e93a236 add estimateSmartFee to the unit test (Alex Morcos)
6303051 EstimateSmart functions consider mempool min fee (Alex Morcos)
f22ac4a Increase success threshold for fee estimation to 95% (Alex Morcos)
4fe2823 Change wallet and GUI code to use new smart fee estimation calls. (Alex Morcos)
22eca7d Add smart fee estimation functions (Alex Morcos)
2015-11-27 12:59:37 +01:00
Wladimir J. van der Laan 05d591839f
Merge pull request #5967
072e2f8 Alter assumptions in CCoinsViewCache::BatchWrite (Alex Morcos)
2015-11-27 12:44:00 +01:00
Wladimir J. van der Laan 4ec3561eb3 Replace scriptnum_test's normative ScriptNum implementation
Compare against the scriptnum from Bitcoin Core 0.10 instead of OpenSSL.
Closes #7086.
2015-11-25 13:59:49 +01:00
Jorge Timón 2e29e7e247 Globals: Remove a bunch of Params() calls from main.cpp:
1) Chainparams: Explicit CChainParams arg for main:

-AcceptBlock
-AcceptBlockHeader
-ActivateBestChain
-ConnectTip
-InitBlockIndex
-LoadExternalBlockFile
-VerifyDB parametric constructor

2) Also pickup more Params()\. in main.cpp

3) Pass nPruneAfterHeight explicitly to new FindFilesToPrune() in main.cpp
2015-11-23 12:14:40 +01:00
Gregory Maxwell 616d61b20d
Merge pull request #6851
3e7c891 Optimisation: Store transaction list order in memory rather than compute it every need (Luke Dashjr)
2015-11-20 18:52:44 -08:00
Luke Dashjr 3e7c89196c Optimisation: Store transaction list order in memory rather than compute it every need
Huge performance improvement (450%) for zapwallettxes
2015-11-21 01:48:25 +00:00
Alex Morcos c0353064dd Change GetPriority calculation.
Compute the value of inputs that already are in the chain at time of mempool entry and only increase priority due to aging for those inputs.  This effectively changes the CTxMemPoolEntry's GetPriority calculation from an upper bound to a lower bound.
2015-11-19 21:44:35 -05:00
Alex Morcos 072e2f8644 Alter assumptions in CCoinsViewCache::BatchWrite
Previously it would break if you flushed a parent cache while there was a child cache referring to it.  This change will allow the flushing of parent caches.
2015-11-18 12:03:50 -05:00
Wladimir J. van der Laan 73fa5e6043
Merge pull request #6932
1cf3dd8 Add unit test for UpdateCoins (Alex Morcos)
03c8282 Make CCoinsViewTest behave like CCoinsViewDB (Alex Morcos)
14470f9 ModifyNewCoins saves database lookups (Alex Morcos)
2015-11-18 17:37:58 +01:00
Alex Morcos e587bc3fd9 Implement helper class for CTxMemPoolEntry constructor
This is only for unit tests.
2015-11-16 20:41:32 -05:00
Gregory Maxwell 87ee0e2dbc
Merge pull request #6986
6bc9e40 Chainparams: Explicit CChainParams arg for miner: (Jorge Timón)
598e494 Chainparams: Explicit CChainParams arg for main (pre miner): (Jorge Timón)
2015-11-16 17:00:11 -08:00
Alex Morcos e93a236d7a add estimateSmartFee to the unit test 2015-11-16 15:33:06 -05:00