Commit graph

1563 commits

Author SHA1 Message Date
Wladimir J. van der Laan 791b58d148
Merge #8690: Do not fully sort all nodes for addr relay
a33b169 Do not fully sort all nodes for addr relay (Pieter Wuille)
2016-11-23 08:19:57 +01:00
Wladimir J. van der Laan 0c577f2638
Merge #8872: Remove block-request logic from INV message processing
037159c Remove block-request logic from INV message processing (Matt Corallo)
3451203 [qa] Respond to getheaders and do not assume a getdata on inv (Matt Corallo)
d768f15 [qa] Make comptool push blocks instead of relying on inv-fetch (mrbandrews)
2016-11-21 15:41:32 +01:00
Wladimir J. van der Laan c3906403c8
Merge #9117: net: don't send feefilter messages before the version handshake is complete
4662553 net: don't send feefilter messages before the version handshake is complete (Cory Fields)
2016-11-21 11:51:03 +01:00
Pieter Wuille b4e4ba475a Introduce convenience type CTransactionRef 2016-11-19 17:53:23 -08:00
Pieter Wuille 1662b437b3 Make CBlock::vtx a vector of shared_ptr<CTransaction> 2016-11-19 17:51:09 -08:00
Pieter Wuille 9346f84299
Merge #9075: Decouple peer-processing-logic from block-connection-logic (#3)
ae22357 Replace CValidationState param in ProcessNewBlock with BlockChecked (Matt Corallo)
7c98ce5 Remove pfrom parameter from ProcessNewBlock (Matt Corallo)
e2e069d Revert "RPC: Give more details when "generate" fails" (Matt Corallo)
2016-11-17 13:23:50 -08:00
Russell Yanofsky ec34648766 [trivial] Fix hungarian variable name
Follow up to comment https://github.com/bitcoin/bitcoin/pull/9058#discussion_r87676593
2016-11-14 14:02:24 -05:00
Wladimir J. van der Laan 7977a1157a
Merge #9058: Fixes for p2p-compactblocks.py test timeouts on travis (#8842)
dac53b5 Modify getblocktxn handler not to drop requests for old blocks (Russell Yanofsky)
55bfddc [qa] Fix stale data bug in test_compactblocks_not_at_tip (Russell Yanofsky)
47e9659 [qa] Fix bug in compactblocks v2 merge (Russell Yanofsky)
2016-11-11 11:02:44 +01:00
Wladimir J. van der Laan 71bc39eb74
Merge #9049: Remove duplicatable duplicate-input check from CheckTransaction
e2b3fb3 Optimize vInOutPoints insertion a bit (Matt Corallo)
eecffe5 Remove redundant duplicate-input check from CheckTransaction (Matt Corallo)
b2e178a Add deserialize + CheckBlock benchmarks, and a full block hex (Matt Corallo)
2016-11-10 16:02:55 +01:00
Matt Corallo e2b3fb349e Optimize vInOutPoints insertion a bit 2016-11-09 11:28:41 -08:00
Matt Corallo eecffe50ef Remove redundant duplicate-input check from CheckTransaction 2016-11-09 11:28:00 -08:00
Matt Corallo ae22357607 Replace CValidationState param in ProcessNewBlock with BlockChecked 2016-11-09 11:21:55 -08:00
Matt Corallo 7c98ce584e Remove pfrom parameter from ProcessNewBlock
This further decouples ProcessNewBlock from networking/peer logic.
2016-11-09 11:21:45 -08:00
Cory Fields 46625538d6 net: don't send feefilter messages before the version handshake is complete 2016-11-09 12:45:13 -05:00
Wladimir J. van der Laan e81df49644
Merge #9039: Various serialization simplifcations and optimizations
d59a518 Use fixed preallocation instead of costly GetSerializeSize (Pieter Wuille)
25a211a Add optimized CSizeComputer serializers (Pieter Wuille)
a2929a2 Make CSerAction's ForRead() constexpr (Pieter Wuille)
a603925 Avoid -Wshadow errors (Pieter Wuille)
5284721 Get rid of nType and nVersion (Pieter Wuille)
657e05a Make GetSerializeSize a wrapper on top of CSizeComputer (Pieter Wuille)
fad9b66 Make nType and nVersion private and sometimes const (Pieter Wuille)
c2c5d42 Make streams' read and write return void (Pieter Wuille)
50e8a9c Remove unused ReadVersion and WriteVersion (Pieter Wuille)
2016-11-09 13:52:04 +01:00
Pieter Wuille dc6b9406bd
Merge #9026: Fix handling of invalid compact blocks
d4833ff Bump the protocol version to distinguish new banning behavior. (Suhas Daftuar)
88c3549 Fix compact block handling to not ban if block is invalid (Suhas Daftuar)
c93beac [qa] Test that invalid compactblocks don't result in ban (Suhas Daftuar)
2016-11-07 18:11:18 -08:00
Matt Corallo 037159cebf Remove block-request logic from INV message processing 2016-11-07 17:41:00 -05:00
Pieter Wuille 9f554e03eb
Merge #9045: Hash P2P messages as they are received instead of at process-time
fe1dc62 Hash P2P messages as they are received instead of at process-time (Matt Corallo)
2016-11-07 14:19:44 -08:00
Pieter Wuille 657e05ab2e Make GetSerializeSize a wrapper on top of CSizeComputer
Given that in default GetSerializeSize implementations created by
ADD_SERIALIZE_METHODS we're already using CSizeComputer(), get rid
of the specialized GetSerializeSize methods everywhere, and just use
CSizeComputer. This removes a lot of code which isn't actually used
anywhere.

For CCompactSize and CVarInt this actually removes a more efficient
size computing algorithm, which is brought back in a later commit.
2016-11-07 13:56:22 -08:00
Russell Yanofsky dac53b58b5 Modify getblocktxn handler not to drop requests for old blocks
The current getblocktxn implementation drops and ignores requests for old
blocks, which causes occasional sync_block timeouts during the
p2p-compactblocks.py test as reported in
https://github.com/bitcoin/bitcoin/issues/8842.

The p2p-compactblocks.py test setup creates many new blocks in a short
period of time, which can lead to getblocktxn requests for blocks below the
hardcoded depth limit of 10 blocks. This commit changes the getblocktxn
handler not to ignore these requests, so the peer nodes in the test setup
will reliably be able to sync.

The protocol change is documented in BIP-152 update "Allow block responses
to getblocktxn requests" at https://github.com/bitcoin/bips/pull/469.

The protocol change is not expected to affect nodes running outside the test
environment, because there shouldn't normally be lots of new blocks being
rapidly added that need to be synced.
2016-11-07 14:35:11 -05:00
Wladimir J. van der Laan 1e50d22ed2
Merge #8709: Allow filterclear messages for enabling TX relay only.
1f951c6 Allow filterclear messages for enabling TX relay only. (R E Broadley)
2016-11-07 13:19:42 +01:00
Cory Fields 902768099c net: handle version push in InitializeNode 2016-11-03 13:35:54 -07:00
Cory Fields 7588b85cd2 net: construct CNodeStates in place 2016-11-03 13:35:54 -07:00
Cory Fields ea3326891d net: switch all callers to connman for pushing messages
Drop all of the old stuff.
2016-11-03 13:35:53 -07:00
Cory Fields 3e32cd09f6 connman is in charge of pushing messages
The changes here are dense and subtle, but hopefully all is more explicit
than before.

- CConnman is now in charge of sending data rather than the nodes themselves.
  This is necessary because many decisions need to be made with all nodes in
  mind, and a model that requires the nodes calling up to their manager quickly
  turns to spaghetti.

- The per-node-serializer (ssSend) has been replaced with a (quasi-)const
  send-version. Since the send version for serialization can only change once
  per connection, we now explicitly tag messages with INIT_PROTO_VERSION if
  they are sent before the handshake. With this done, there's no need to lock
  for access to nSendVersion.

  Also, a new stream is used for each message, so there's no need to lock
  during the serialization process.

- This takes care of accounting for optimistic sends, so the
  nOptimisticBytesWritten hack can be removed.

- -dropmessagestest and -fuzzmessagestest have not been preserved, as I suspect
  they haven't been used in years.
2016-11-03 13:32:09 -07:00
Suhas Daftuar 88c35491ab Fix compact block handling to not ban if block is invalid 2016-11-03 13:07:12 -04:00
Wladimir J. van der Laan 3665483be7
Merge #8969: Decouple peer-processing-logic from block-connection-logic (#2)
f5b960b Move nTimeBestReceived updating into net processing code (Matt Corallo)
d8670fb Move all calls to CheckBlockIndex out of net-processing logic (Matt Corallo)
d6ea737 Remove network state wipe from UnloadBlockIndex. (Matt Corallo)
fc0c24f Move MarkBlockAsReceived out of ProcessNewMessage (Matt Corallo)
65f35eb Move FlushStateToDisk call out of ProcessMessages::TX into ATMP (Matt Corallo)
2016-11-03 16:31:32 +01:00
Pieter Wuille a33b1691f1 Do not fully sort all nodes for addr relay
As we only need 1 or 2, explicitly keep track of the best ones.
2016-11-03 00:20:04 -07:00
Pieter Wuille 508404de98
Merge #9053: IBD using chainwork instead of height and not using header timestamps
e141beb IsInitialBlockDownload no longer uses header-only timestamps. (Gregory Maxwell)
2082b55 Remove GetTotalBlocksEstimate and checkpoint tests that test nothing. (Gregory Maxwell)
fd46136 IBD check uses minimumchain work instead of checkpoints. (Gregory Maxwell)
2016-11-03 00:08:59 -07:00
Wladimir J. van der Laan c05db83488
Merge #9013: Trivial: Explicitly pass const CChainParams& to LoadBlockIndexDB()
d0b01f3 Explicitly pass const CChainParams& to LoadBlockIndexDB() (Geoffrey Tsui)
2016-11-02 21:09:27 +01:00
Gregory Maxwell e141beb6a9 IsInitialBlockDownload no longer uses header-only timestamps.
This avoids a corner case (mostly visible on testnet) where bogus
 headers can keep nodes in IsInitialBlockDownload.
2016-11-02 01:51:53 +00:00
Gregory Maxwell fd46136dfa IBD check uses minimumchain work instead of checkpoints.
This introduces a 'minimum chain work' chainparam which is intended
 to be the known amount of work in the chain for the network at the
 time of software release.  If you don't have this much work, you're
 not yet caught up.

This is used instead of the count of blocks test from checkpoints.

This criteria is trivial to keep updated as there is no element of
subjectivity, trust, or position dependence to it. It is also a more
reliable metric of sync status than a block count.
2016-11-02 01:47:02 +00:00
Matt Corallo f5b960be4e Move nTimeBestReceived updating into net processing code 2016-10-31 10:08:11 -04:00
Matt Corallo d8670fb103 Move all calls to CheckBlockIndex out of net-processing logic
This will result in many more calls to CheckBlockIndex when
connecting a list of headers (eg in ::HEADERS messages processing)
but its only enabled in debug mode, and that should mostly just be
during IBD, so it should be OK.
2016-10-31 10:08:11 -04:00
Matt Corallo d6ea737be1 Remove network state wipe from UnloadBlockIndex.
UnloadBlockIndex is only used during init if we end up reindexing
to clear our block state so that we can start over. However, at
that time no connections have been brought up as CConnman hasn't
been started yet, so all of the network processing state logic is
empty when its called.

Additionally, the initialization of the recentRejects set is moved
to InitPeerLogic.
2016-10-31 10:08:11 -04:00
Matt Corallo fc0c24f67b Move MarkBlockAsReceived out of ProcessNewMessage 2016-10-31 10:08:11 -04:00
Matt Corallo 65f35eb91b Move FlushStateToDisk call out of ProcessMessages::TX into ATMP 2016-10-31 10:08:11 -04:00
Pieter Wuille 3f78562df5 Add DumpMempool and LoadMempool 2016-10-31 00:10:36 -07:00
Pieter Wuille ced7c949e8 Add AcceptToMemoryPoolWithTime function 2016-10-30 23:24:41 -07:00
Matt Corallo fe1dc62cef Hash P2P messages as they are received instead of at process-time 2016-10-30 18:04:57 -04:00
Geoffrey Tsui d0b01f3a85 Explicitly pass const CChainParams& to LoadBlockIndexDB() 2016-10-25 22:35:26 +08:00
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