Commit graph

1521 commits

Author SHA1 Message Date
Wladimir J. van der Laan 9bdf5269f8
Merge #8515: A few mempool removal optimizations
0334430 Add some missing includes (Pieter Wuille)
4100499 Return shared_ptr<CTransaction> from mempool removes (Pieter Wuille)
51f2783 Make removed and conflicted arguments optional to remove (Pieter Wuille)
f48211b Bypass removeRecursive in removeForReorg (Pieter Wuille)
2016-10-25 14:21:57 +02:00
Wladimir J. van der Laan ced22d035a
Merge #8995: Add missing cs_main lock to ::GETBLOCKTXN processing
dfe7906 Add missing cs_main lock to ::GETBLOCKTXN processing (Matt Corallo)
2016-10-24 11:17:07 +02:00
Pieter Wuille 4100499db4 Return shared_ptr<CTransaction> from mempool removes 2016-10-21 19:22:43 -07:00
Pieter Wuille 51f278329d Make removed and conflicted arguments optional to remove 2016-10-21 19:22:43 -07:00
Pavel Janík 1d8e12ba48 Fix doxygen comment: the transaction is returned in txOut 2016-10-21 23:42:37 +02:00
Matt Corallo dfe79060a6 Add missing cs_main lock to ::GETBLOCKTXN processing
Note that this is not a major issue as, in order for the missing
lock to cause issues, you have to receive a GETBLOCKTXN message
while reindexing, adding a block header via RPC, etc, which results
in either a table rehash or an insert into the bucket which you are
currently looking at.
2016-10-21 12:15:19 -04:00
Wladimir J. van der Laan 3cf496d102
Merge #8968: Don't hold cs_main when calling ProcessNewBlock from a cmpctblock
72ca7d9 Don't hold cs_main when calling ProcessNewBlock from a cmpctblock (Matt Corallo)
2016-10-21 16:58:44 +02:00
Jonas Schnelli 0a261b63fd
Use pindexBestHeader instead of setBlockIndexCandidates for NotifyHeaderTip() 2016-10-20 19:02:48 +02:00
mruddy fc146095d2 RPC: augment getblockchaininfo bip9_softforks data 2016-10-19 09:08:39 -04:00
Wladimir J. van der Laan 1230890a6d
Merge #8936: Report NodeId in misbehaving debug
a1919ad Report NodeId in misbehaving debug (R E Broadley)
2016-10-19 10:35:44 +02:00
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 7f71a3c591
Merge #6996: Add preciousblock RPC
5805ac8 Add preciousblock tests (Pieter Wuille)
5127c4f Add preciousblock RPC (Pieter Wuille)
2016-10-18 21:36:38 +02:00
Matt Corallo 72ca7d924e Don't hold cs_main when calling ProcessNewBlock from a cmpctblock 2016-10-18 15:24:59 -04:00
Wladimir J. van der Laan 0b5a997acf
Merge #8637: Compact Block Tweaks (rebase of #8235)
3ac6de0 Align constant names for maximum compact block / blocktxn depth (Pieter Wuille)
b2e93a3 Add cmpctblock to debug help list (instagibbs)
fe998e9 More agressively filter compact block requests (Matt Corallo)
02a337d Dont remove a "preferred" cmpctblock peer if they provide a block (Matt Corallo)
2016-10-18 21:19:54 +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
R E Broadley a1919adab0 Report NodeId in misbehaving debug 2016-10-18 07:17:09 +07:00
Pieter Wuille 3ac6de0a04 Align constant names for maximum compact block / blocktxn depth 2016-10-17 16:46:30 +02:00
Matt Corallo fe998e962d More agressively filter compact block requests
Unit test adaptations by Pieter Wuille.
2016-10-17 16:44:57 +02:00
Matt Corallo 02a337defd Dont remove a "preferred" cmpctblock peer if they provide a block 2016-10-17 16:44:57 +02:00
Wladimir J. van der Laan 53133c1c04
Merge #8499: Add several policy limits and disable uncompressed keys for segwit scripts
67d6ee1 remove redundant tests in p2p-segwit.py (Johnson Lau)
9260085 test segwit uncompressed key fixes (Johnson Lau)
248f3a7 Fix ismine and addwitnessaddress: no uncompressed keys in segwit (Pieter Wuille)
b811124 [qa] Add tests for uncompressed pubkeys in segwit (Suhas Daftuar)
9f0397a Make test framework produce lowS signatures (Johnson Lau)
4c0c25a Require compressed keys in segwit as policy and disable signing with uncompressed keys for segwit scripts (Johnson Lau)
3ade2f6 Add standard limits for P2WSH with tests (Johnson Lau)
2016-10-17 13:27:05 +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 3ade2f64cf Add standard limits for P2WSH with tests 2016-10-16 23:53:35 +08:00
Wladimir J. van der Laan 49c5910372
Merge #8880: protocol.h: Move MESSAGE_START_SIZE into CMessageHeader
1df3111 protocol.h: Make enums in GetDataMsg concrete values (Wladimir J. van der Laan)
2c09a52 protocol.h: Move MESSAGE_START_SIZE into CMessageHeader (Wladimir J. van der Laan)
f9bd92d version.h: s/shord/short/ in comment (Wladimir J. van der Laan)
2016-10-15 10:27:46 +02:00
Matt Corallo a9aec5c24d Use BlockChecked signal to send reject messages from mapBlockSource 2016-10-04 13:54:29 -04:00
Matt Corallo 7565e03b96 Remove SyncWithWallets wrapper function 2016-10-04 13:53:04 -04:00
Matt Corallo 12ee1fe018 Always call UpdatedBlockTip, even if blocks were only disconnected 2016-10-04 13:52:57 -04:00
Matt Corallo f5efa28393 Remove CConnman parameter from ProcessNewBlock/ActivateBestChain 2016-10-04 13:51:32 -04:00
Matt Corallo fef1010199 Use CValidationInterface from chain logic to notify peer logic
This adds a new CValidationInterface subclass, defined in main.h,
to receive notifications of UpdatedBlockTip and use that to push
blocks to peers, instead of doing it directly from
ActivateBestChain.
2016-10-04 13:49:44 -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
Matt Corallo 0278fb5f48 Remove duplicate nBlocksEstimate cmp (we already checked IsIBD()) 2016-10-04 12:35:07 -04:00
Matt Corallo 87e7d72807 Make validationinterface.UpdatedBlockTip more verbose
In anticipation of making all the callbacks out of block processing
flow through it. Note that vHashes will always have something in it
since pindexFork != pindexNewTip.
2016-10-04 12:35:07 -04:00
Matt Corallo 06128da751 Make GetFetchFlags always request witness objects from witness peers
This fixes a bug where we might (in exceedingly rare circumstances)
accidentally ban a node for sending us the first (potentially few)
segwit blocks in non-segwit mode.
2016-10-04 18:24:10 +02:00
Wladimir J. van der Laan 2c09a5209a protocol.h: Move MESSAGE_START_SIZE into CMessageHeader
Also move the enum to the top, and remove a deceptive TODO
comment.
2016-10-04 11:12:55 +00:00
Cory Fields 905bc68d05 net: fix a few cases where messages were sent rather than dropped upon disconnection
75ead758 turned these into crashes in the event of a handshake failure, most
notably when a peer does not offer the expected services.

There are likely other cases that these assertions will find as well.
2016-10-01 19:13:10 -04:00
Wladimir J. van der Laan 41e58faf04 net: Consistent checksum handling
In principle, the checksums of P2P packets are simply 4-byte blobs which
are the first four bytes of SHA256(SHA256(payload)).

Currently they are handled as little-endian 32-bit integers half of the
time, as blobs the other half, sometimes copying the one to the other,
resulting in somewhat confused code.

This PR changes the handling to be consistent both at packet creation
and receiving, making it (I think) easier to understand.
2016-09-28 12:44:13 +02:00
Pavel Janík 4731cab8fb Do not shadow variables 2016-09-27 09:25:15 +02:00
Wladimir J. van der Laan 26b370a937
Merge #8636: Implement NULLDUMMY softfork (BIP147)
482f852 Implement NULLDUMMY softfork (Johnson Lau)
2016-09-22 10:58:00 +02:00
Wladimir J. van der Laan 047ded0b12
Merge #8688: Move static global randomizer seeds into CConnman
d9ff591 Move static global randomizer seeds into CConnman (Pieter Wuille)
2016-09-19 18:02:01 +02:00
Pieter Wuille d9ff591d42 Move static global randomizer seeds into CConnman 2016-09-19 15:53:47 +02:00
Pavel Janík b4fb512719 UndoReadFromDisk works on undo files (rev), not on block files. 2016-09-15 12:40:09 +02:00
rodasmith 1d635ae61b fix op order to append first alert 2016-09-10 11:41:01 -07:00
Pieter Wuille 6898213409
Merge #8681: Performance Regression Fix: Pre-Allocate txChanged vector
ec81881 Performance Regression Fix: Pre-Allocate txChanged vector (Jeremy Rubin)
2016-09-09 13:41:15 +02:00
Wladimir J. van der Laan 6423116741
Merge #8085: p2p: Begin encapsulation
0103c5b net: move MAX_FEELER_CONNECTIONS into connman (Cory Fields)
e700cd0 Convert ForEachNode* functions to take a templated function argument rather than a std::function to eliminate std::function overhead (Jeremy Rubin)
d1a2295 Made the ForEachNode* functions in src/net.cpp more pragmatic and self documenting (Jeremy Rubin)
98591c5 net: move vNodesDisconnected into CConnman (Cory Fields)
fa2f8bc net: add nSendBufferMaxSize/nReceiveFloodSize to CConnection::Options (Cory Fields)
a19553b net: Introduce CConnection::Options to avoid passing so many params (Cory Fields)
bafa5fc net: Drop StartNode/StopNode and use CConnman directly (Cory Fields)
e81a602 net: pass CClientUIInterface into CConnman (Cory Fields)
f60b905 net: Pass best block known height into CConnman (Cory Fields)
fdf69ff net: move max/max-outbound to CConnman (Cory Fields)
8a59369 net: move semOutbound to CConnman (Cory Fields)
bd72937 net: move nLocalServices/nRelevantServices to CConnman (Cory Fields)
be9c796 net: move SendBufferSize/ReceiveFloodSize to CConnman (Cory Fields)
63cafa6 net: move send/recv statistics to CConnman (Cory Fields)
adf5d4c net: SocketSendData returns written size (Cory Fields)
ee44fa9 net: move messageHandlerCondition to CConnman (Cory Fields)
960cf2e net: move nLocalHostNonce to CConnman (Cory Fields)
551e088 net: move nLastNodeId to CConnman (Cory Fields)
6c19d92 net: move whitelist functions into CConnman (Cory Fields)
53347f0 net: create generic functor accessors and move vNodes to CConnman (Cory Fields)
c0569c7 net: Add most functions needed for vNodes to CConnman (Cory Fields)
8ae2dac net: move added node functions to CConnman (Cory Fields)
502dd3a net: Add oneshot functions to CConnman (Cory Fields)
a0f3d3c net: move ban and addrman functions into CConnman (Cory Fields)
aaf018e net: handle nodesignals in CConnman (Cory Fields)
b1a5f43 net: move OpenNetworkConnection into CConnman (Cory Fields)
02137f1 net: Move socket binding into CConnman (Cory Fields)
5b446dd net: Pass CConnection to wallet rather than using the global (Cory Fields)
8d58c4d net: Pass CConnman around as needed (Cory Fields)
d7349ca net: Add rpc error for missing/disabled p2p functionality (Cory Fields)
cd16f48 net: Create CConnman to encapsulate p2p connections (Cory Fields)
d93b14d net: move CBanDB and CAddrDB out of net.h/cpp (Cory Fields)
531214f gui: add NodeID to the peer table (Cory Fields)
2016-09-09 11:52:22 +02:00
Wladimir J. van der Laan 4daf02a03f
Merge #8677: Do not shadow upper local variable 'send', prevent -Wshadow compiler warning.
125b946 Do not shadow upper local variable 'send', prevent -Wshadow compiler warning. (Pavel Janík)
2016-09-09 10:25:39 +02:00
Wladimir J. van der Laan 80a4f21d37
Merge #8525: Do not store witness txn in rejection cache
ca10a03 Add basic test for IsStandard witness transaction blinding (instagibbs)
34521e4 Do not store witness txn in rejection cache (Pieter Wuille)
2016-09-09 07:47:48 +02:00
Jeremy Rubin d1a2295f0d Made the ForEachNode* functions in src/net.cpp more pragmatic and self documenting 2016-09-08 13:06:05 -04: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 be9c796dc5 net: move SendBufferSize/ReceiveFloodSize to CConnman 2016-09-08 12:24:06 -04:00
Cory Fields 63cafa6329 net: move send/recv statistics to CConnman 2016-09-08 12:24:06 -04:00