aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
AgeCommit message (Collapse)Author
2016-11-28Fix some typosfsb4000
2016-11-25Merge #9128: net: Decouple CConnman and message serializationPieter Wuille
c7be56d net: push only raw data into CConnman (Cory Fields) 2ec935d net: add CVectorWriter and CNetMsgMaker (Cory Fields) b7695c2 net: No need to check individually for disconnection anymore (Cory Fields) fedea8a net: don't send any messages before handshake or after requested disconnect (Cory Fields) d74e352 net: Set feelers to disconnect at the end of the version message (Cory Fields)
2016-11-25net: push only raw data into CConnmanCory Fields
This fixes one of the last major layer violations in the networking stack. The network side is no longer in charge of message serialization, so it is now decoupled from Bitcoin structures. Only the header is serialized and attached to the payload.
2016-11-25net: No need to check individually for disconnection anymoreCory Fields
2016-11-25Merge #9189: Always add default_witness_commitment with GBT client supportWladimir J. van der Laan
95f4a03 [qa] Test getblocktemplate default_witness_commitment (Suhas Daftuar) ad04d1c Always add default_witness_commitment with GBT client support (Pieter Wuille)
2016-11-23net: don't send any messages before handshake or after requested disconnectCory Fields
Also, send reject messages earlier in SendMessages(), so that disconnections are processed earlier. These changes combined should ensure that no message is ever sent after fDisconnect is set.
2016-11-23net: Set feelers to disconnect at the end of the version messageCory Fields
This way we're not relying on messages going out after fDisconnect has been set. This should not cause any real behavioral changes, though feelers should arguably disconnect earlier in the process. That can be addressed in a later functional change.
2016-11-23Merge #8930: Move orphan processing to ActivateBestChainPieter Wuille
d2b88f9 Move orphan-conflict removal from main logic into a callback (Matt Corallo) 97e2802 Erase orphans per-transaction instead of per-block (Matt Corallo) ec4525c Move orphan processing to ActivateBestChain (Matt Corallo)
2016-11-23Merge #9199: Always drop the least preferred HB peer when adding a new one.Pieter Wuille
ca8549d Always drop the least preferred HB peer when adding a new one. (Gregory Maxwell)
2016-11-23Move orphan-conflict removal from main logic into a callbackMatt Corallo
This makes the orphan map a part of net-processing logic instead of main logic.
2016-11-23Merge #9196: Send tip change notification from invalidateblockWladimir J. van der Laan
67c6326 Send tip change notification from invalidateblock (Russell Yanofsky)
2016-11-23Merge #8690: Do not fully sort all nodes for addr relayWladimir J. van der Laan
a33b169 Do not fully sort all nodes for addr relay (Pieter Wuille)
2016-11-22Always drop the least preferred HB peer when adding a new one.Gregory Maxwell
When a BIP152 HB-mode peer is in the least preferred position and disconnects, they will not be by ForNode on the next loop. They will continue to sit in that position and prevent deactivating HB mode for peers that are still connected. There is no reason for them to stay in the list if already gone, so drop the first element unconditionally if there are too many. Fixes issue #9163.
2016-11-21Always add default_witness_commitment with GBT client supportPieter Wuille
2016-11-21Merge #8872: Remove block-request logic from INV message processingWladimir J. van der Laan
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-21Merge #9117: net: don't send feefilter messages before the version handshake ↵Wladimir J. van der Laan
is complete 4662553 net: don't send feefilter messages before the version handshake is complete (Cory Fields)
2016-11-19Introduce convenience type CTransactionRefPieter Wuille
2016-11-19Make CBlock::vtx a vector of shared_ptr<CTransaction>Pieter Wuille
2016-11-17Erase orphans per-transaction instead of per-blockMatt Corallo
2016-11-17Move orphan processing to ActivateBestChainMatt Corallo
This further decouples "main" and "net" processing logic by moving orphan processing out of the chain-connecting cs_main lock and into its own cs_main lock, beside all of the other chain callbacks. Once further decoupling of net and main processing logic occurs, orphan handing should move to its own lock, out of cs_main. Note that this will introduce a race if there are any cases where we assume the orphan map to be consistent with the current chain tip, however I am confident there is no such case (ATMP will fail without DoS score in all such cases).
2016-11-17Merge #9075: Decouple peer-processing-logic from block-connection-logic (#3)Pieter Wuille
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-14[trivial] Fix hungarian variable nameRussell Yanofsky
Follow up to comment https://github.com/bitcoin/bitcoin/pull/9058#discussion_r87676593
2016-11-11Merge #9058: Fixes for p2p-compactblocks.py test timeouts on travis (#8842)Wladimir J. van der Laan
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-10Merge #9049: Remove duplicatable duplicate-input check from CheckTransactionWladimir J. van der Laan
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-09Optimize vInOutPoints insertion a bitMatt Corallo
2016-11-09Remove redundant duplicate-input check from CheckTransactionMatt Corallo
2016-11-09Replace CValidationState param in ProcessNewBlock with BlockCheckedMatt Corallo
2016-11-09Remove pfrom parameter from ProcessNewBlockMatt Corallo
This further decouples ProcessNewBlock from networking/peer logic.
2016-11-09net: don't send feefilter messages before the version handshake is completeCory Fields
2016-11-09Merge #9039: Various serialization simplifcations and optimizationsWladimir J. van der Laan
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-07Merge #9026: Fix handling of invalid compact blocksPieter Wuille
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-07Remove block-request logic from INV message processingMatt Corallo
2016-11-07Merge #9045: Hash P2P messages as they are received instead of at process-timePieter Wuille
fe1dc62 Hash P2P messages as they are received instead of at process-time (Matt Corallo)
2016-11-07Make GetSerializeSize a wrapper on top of CSizeComputerPieter Wuille
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-07Modify getblocktxn handler not to drop requests for old blocksRussell Yanofsky
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-07Merge #8709: Allow filterclear messages for enabling TX relay only.Wladimir J. van der Laan
1f951c6 Allow filterclear messages for enabling TX relay only. (R E Broadley)
2016-11-03net: handle version push in InitializeNodeCory Fields
2016-11-03net: construct CNodeStates in placeCory Fields
2016-11-03net: switch all callers to connman for pushing messagesCory Fields
Drop all of the old stuff.
2016-11-03connman is in charge of pushing messagesCory Fields
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-03Fix compact block handling to not ban if block is invalidSuhas Daftuar
2016-11-03Merge #8969: Decouple peer-processing-logic from block-connection-logic (#2)Wladimir J. van der Laan
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-03Do not fully sort all nodes for addr relayPieter Wuille
As we only need 1 or 2, explicitly keep track of the best ones.
2016-11-03Merge #9053: IBD using chainwork instead of height and not using header ↵Pieter Wuille
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-02Merge #9013: Trivial: Explicitly pass const CChainParams& to LoadBlockIndexDB()Wladimir J. van der Laan
d0b01f3 Explicitly pass const CChainParams& to LoadBlockIndexDB() (Geoffrey Tsui)
2016-11-02IsInitialBlockDownload no longer uses header-only timestamps.Gregory Maxwell
This avoids a corner case (mostly visible on testnet) where bogus headers can keep nodes in IsInitialBlockDownload.
2016-11-02IBD check uses minimumchain work instead of checkpoints.Gregory Maxwell
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-10-31Move nTimeBestReceived updating into net processing codeMatt Corallo
2016-10-31Move all calls to CheckBlockIndex out of net-processing logicMatt Corallo
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-31Remove network state wipe from UnloadBlockIndex.Matt Corallo
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.