Commit Graph

109 Commits

Author SHA1 Message Date
PastaPastaPasta
087d98477b
Merge bitcoin#10387: Eventually connect to NODE_NETWORK_LIMITED peers (#3417)
* Merge #10387: Eventually connect to NODE_NETWORK_LIMITED peers

eb91835 Add setter for g_initial_block_download_completed (Jonas Schnelli)
3f56df5 [QA] add NODE_NETWORK_LIMITED address relay and sync test (Jonas Schnelli)
158e1a6 [QA] fix mininode CAddress ser/deser (Jonas Schnelli)
fa999af [QA] Allow addrman loopback tests (add debug option -addrmantest) (Jonas Schnelli)
6fe57bd Connect to peers signaling NODE_NETWORK_LIMITED when out-of-IBD (Jonas Schnelli)
31c45a9 Accept addresses with NODE_NETWORK_LIMITED flag (Jonas Schnelli)

Pull request description:

  Eventually connect to peers signalling NODE_NETWORK_LIMITED if we are out of IBD.
  Accept and relay NODE_NETWORK_LIMITED peers in addrman.

Tree-SHA512: 8a238fc97f767f81cae1866d6cc061390f23a72af4a711d2f7158c77f876017986abb371d213d1c84019eef7be4ca951e8e6f83fda36769c4e1a1d763f787037
Signed-off-by: Pasta <pasta@dashboost.org>

# Conflicts:
#	src/init.cpp
#	src/protocol.h
#	test/functional/node_network_limited.py

* remove witness

Signed-off-by: Pasta <pasta@dashboost.org>

* fix test expecting witness flag

Signed-off-by: Pasta <pasta@dashboost.org>

Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
2020-04-19 16:21:47 +03:00
Alexander Block
b212f21c15 Implement new way of concentrated signature recovery
Instead of propagating all sig shares to all LLMQ members, this will now
make all members send their individual sig share to a single member, which
is then responsible for the recovery and propagation of the recovered
signature. This process is repeated by all members every second for another
target/recovering member, until a recovered signature appears.
2020-03-31 19:58:07 +02:00
PastaPastaPasta
8a1ec935a0
Backport 11651 (#3358)
* scripted-diff: Replace #include "" with #include <> (ryanofsky)

-BEGIN VERIFY SCRIPT-
for f in \
  src/*.cpp \
  src/*.h \
  src/bench/*.cpp \
  src/bench/*.h \
  src/compat/*.cpp \
  src/compat/*.h \
  src/consensus/*.cpp \
  src/consensus/*.h \
  src/crypto/*.cpp \
  src/crypto/*.h \
  src/crypto/ctaes/*.h \
  src/policy/*.cpp \
  src/policy/*.h \
  src/primitives/*.cpp \
  src/primitives/*.h \
  src/qt/*.cpp \
  src/qt/*.h \
  src/qt/test/*.cpp \
  src/qt/test/*.h \
  src/rpc/*.cpp \
  src/rpc/*.h \
  src/script/*.cpp \
  src/script/*.h \
  src/support/*.cpp \
  src/support/*.h \
  src/support/allocators/*.h \
  src/test/*.cpp \
  src/test/*.h \
  src/wallet/*.cpp \
  src/wallet/*.h \
  src/wallet/test/*.cpp \
  src/wallet/test/*.h \
  src/zmq/*.cpp \
  src/zmq/*.h
do
  base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-

Signed-off-by: Pasta <pasta@dashboost.org>

* scripted-diff: Replace #include "" with #include <> (Dash Specific)

-BEGIN VERIFY SCRIPT-
for f in \
  src/bls/*.cpp \
  src/bls/*.h \
  src/evo/*.cpp \
  src/evo/*.h \
  src/governance/*.cpp \
  src/governance/*.h \
  src/llmq/*.cpp \
  src/llmq/*.h \
  src/masternode/*.cpp \
  src/masternode/*.h \
  src/privatesend/*.cpp \
  src/privatesend/*.h
do
  base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-

Signed-off-by: Pasta <pasta@dashboost.org>

* build: Remove -I for everything but project root

Remove -I from build system for everything but the project root,
and built-in dependencies.

Signed-off-by: Pasta <pasta@dashboost.org>

# Conflicts:
#	src/Makefile.test.include

* qt: refactor: Use absolute include paths in .ui files

* qt: refactor: Changes to make include paths absolute

This makes all include paths in the GUI absolute.

Many changes are involved as every single source file in
src/qt/ assumes to be able to use relative includes.

Signed-off-by: Pasta <pasta@dashboost.org>

# Conflicts:
#	src/qt/dash.cpp
#	src/qt/optionsmodel.cpp
#	src/qt/test/rpcnestedtests.cpp

* test: refactor: Use absolute include paths for test data files

* Recommend #include<> syntax in developer notes

* refactor: Include obj/build.h instead of build.h

* END BACKPORT #11651 Remove trailing whitespace causing travis failure

* fix backport 11651

Signed-off-by: Pasta <pasta@dashboost.org>

* More of 11651

* fix blockchain.cpp

Signed-off-by: pasta <pasta@dashboost.org>

* Add missing "qt/" in includes

* Add missing "test/" in includes

* Fix trailing whitespaces

Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
Co-authored-by: MeshCollider <dobsonsa68@gmail.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-03-20 01:46:56 +03:00
UdjinM6
0c3df75e62
More of 11740 2020-03-04 10:13:41 -06:00
Wladimir J. van der Laan
f175a2e351
Merge #11740: Implement BIP159 NODE_NETWORK_LIMITED (pruned peers) *signaling only*
de74c62 [Doc] Update bip.md, add support for BIP 159 (Jonas Schnelli)
e054d0e [QA] Add node_network_limited test (Jonas Schnelli)
bd09416 Avoid leaking the prune height through getdata (fingerprinting countermeasure) (Jonas Schnelli)
27df193 Always set NODE_NETWORK_LIMITED bit (Jonas Schnelli)
7caba38 Add NODE_NETWORK_LIMITED flags and min block amount constants (Jonas Schnelli)

Pull request description:

  Extracted from #10387.
  Does implement BIP159, but only the signalling part. No connections are made to NODE_NETWORK_LIMITED in this PR.

  The address relay and connection work (the more complicated part) can then be separated (probably in #10387).

Tree-SHA512: e3218eb4789a9320b0f42dc10f62d30c13c49bdef00443fbe653bee22933477adcfc1cf8f6a95269324560b5721203ed41f3c5e2dd8a98ec2791f6a9d8346b1a
2020-02-27 09:41:36 -06:00
UdjinM6
3bcf23fac7
Merge pull request #3305 from PastaPastaPasta/backport-11363
Backport P2P refactor
2020-01-31 13:54:16 +03:00
Wladimir J. van der Laan
94e99441c5
Merge #11512: Use GetDesireableServiceFlags in seeds, dnsseeds, fixing static seed adding
2b839ab Update chainparams comment for more info on service bits per dnsseed (Matt Corallo)
62e7642 Fall back to oneshot for DNS Seeds which don't support filtering. (Matt Corallo)
51ae766 Use GetDesireableServiceFlags in static seeds, document this. (Matt Corallo)
fb6f6b1 bluematt's testnet-seed now supports x9 (and is just a static list) (Matt Corallo)

Pull request description:

  4440710 broke inserting entries into addrman from dnsseeds which
  did not support service bits, as well as static seeds. Static seeds
  were already being filtered by UA for 0.13.1+ (ie NODE_WITNESS), so
  simply changing the default service bits to include NODE_WITNESS
  (and updating docs appropriately) is sufficient. For DNS Seeds, not
  supporting NODE_WITNESS is no longer useful, so instead use
  non-filtering seeds as oneshot hosts irrespective of named proxy.

  I've set my testnet-seed to also support x9, though because it is simply a static host, it may be useful to leave the support off so that it is used as a oneshot to get addresses from a live node instead. I'm fine with either.

Tree-SHA512: 3f17d4d2b0b84d876981c962d2b44cb0c8f95f52c56a48c6b35fd882f6d7a40805f320ec452985a1c0b34aebddb1922709156c3ceccd1b9f8363fd7cb537d21d
2020-01-26 01:15:36 -06:00
MarcoFalke
aeaf3c5ef9
Merge #10749: Use compile-time constants instead of unnamed enumerations (remove "enum hack")
1e65f0f33 Use compile-time constants instead of unnamed enumerations (remove "enum hack") (practicalswift)

Pull request description:

  Use compile-time constants instead of unnamed enumerations (remove "enum hack").

Tree-SHA512: 1b6ebb2755398c5ebab6cce125b1dfc39cbd1504d98d55136b32703fe935c4070360ab3b2f52b1da48ba9f3b01082d204f3d87c92ccb5c8c333731f7f972e128
2020-01-22 09:24:25 -06:00
Wladimir J. van der Laan
fdf3f25a0a
Merge #10969: Declare single-argument (non-converting) constructors "explicit"
64fb0ac Declare single-argument (non-converting) constructors "explicit" (practicalswift)

Pull request description:

  Declare single-argument (non-converting) constructors `explicit`.

  In order to avoid unintended implicit conversions.

  For a more thorough discussion, see ["C.46: By default, declare single-argument constructors explicit"](http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit) in the C++ Core Guidelines (Stroustrup & Sutter).

Tree-SHA512: e0c6922e56b11fa402621a38656d8b1122d16dd8f160e78626385373cf184ac7f26cb4c1851eca47e9b0dbd5e924e39a85c3cbdcb627a05ee3a655ecf5f7a0f1
2020-01-10 10:33:57 -06:00
Alexander Block
9a96c06057 Remove uses of NODE_WITNESS 2019-09-29 12:42:14 +02:00
Pieter Wuille
f8c310a974 Merge #11456: Replace relevant services logic with a function suite.
15f5d3b17 Switch DNSSeed-needed metric to any-automatic-nodes, not services (Matt Corallo)
5ee88b4bd Clarify docs for requirements/handling of addnode/connect nodes (Matt Corallo)
57edc0b0c Rename fAddnode to a more-descriptive "manual_connection" (Matt Corallo)
44407100f Replace relevant services logic with a function suite. (Matt Corallo)

Pull request description:

  This was mostly written as a way to clean things up so that the NETWORK_LIMITED PR (#10387) can be simplified a ton, but its also a nice standalone cleanup that will also require a bit of review because it tweaks a lot of stuff across net. The new functions are fine in protocol.h right now since they're straight-forward, but after NETWORK_LIMITED will really want to move elsewhere after @theuni moves the nServices-based selection to addrman from connman.

  Adds HasAllRelevantServices and GetRelevantServices, which check
  for NETWORK|WITNESS.

  This changes the following:
   * Removes nRelevantServices from CConnman, disconnecting it a bit
     more from protocol-level logic.
   * Replaces our sometimes-connect-to-!WITNESS-nodes logic with
     simply always requiring WITNESS|NETWORK for outbound non-feeler
     connections (feelers still only require NETWORK).
   * This has the added benefit of removing nServicesExpected from
     CNode - instead letting net_processing's VERSION message
     handling simply check HasAllRelevantServices.
   * This implies we believe WITNESS nodes to continue to be a
     significant majority of nodes on the network, but also because
     we cannot sync properly from !WITNESS nodes, it is strange to
     continue using our valuable outbound slots on them.
   * In order to prevent this change from preventing connection to
     -connect= nodes which have !WITNESS, -connect nodes are now
     given the "addnode" flag. This also allows outbound connections
     to !NODE_NETWORK nodes for -connect nodes (which was already true
     of addnodes).
   * Has the (somewhat unintended) consequence of changing one of the
     eviction metrics from the same
     sometimes-connect-to-!WITNESS-nodes metric to requiring
     HasRelevantServices.

  This should make NODE_NETWORK_LIMITED much simpler to implement.

Tree-SHA512: 90606896c86cc5da14c77843b16674a6a012065e7b583d76d1c47a18215358abefcbab44ff4fab3fadcd39aa9a42d4740c6dc8874a58033bdfc8ad3fb5c649fc
2019-09-29 12:42:14 +02:00
MarcoFalke
fc94fac752
Merge #10842: Fix incorrect Doxygen tag (@ince → @since). Doxygen parameter name matching.
2c2e90d Fix incorrect Doxygen tag (@ince → @since). Make Doxygen parameter names match actual parameter names. (practicalswift)

Pull request description:

  Doxygen fixes:
  * Fix incorrect Doxygen tag (`@ince` → `@since`).
  * Make Doxygen parameter names match actual parameter names.

Tree-SHA512: cb1d37a7d15a90d24affaf5c2bcf462663f0b0c13868bb25401e5d8cb303fcb41e53fdeee8012b2271a509112ef98fc0c070b4194f42cd55361f7e6bc7996342
2019-07-24 11:59:09 -05:00
Alexander Block
2f21e55514 Remove legacy InstantSend code (#3020)
* Remove ppszTypeName from protocol.cpp and reimplement GetCommand

This removes the need to carefully maintain ppszTypeName, which required
correct order and also did not allow to permanently remove old message
types.

To get the command name for an INV type, GetCommandInternal uses a switch
which needs to be maintained from now on.

The way this is implemented also resembles the way it is implemented in
Bitcoin today, but it's not identical. The original PR that introduced the
switch case in Bitcoin was part of the Segwit changes and thus never got
backported. I decided to implement it in a slightly different way that
avoids throwing exceptions when an unknown INV type is encountered.

IsKnownType will now also leverage GetCommandInternal() to figure out if
the INV type is known locally. This has the side effect of old/legacy
message types to return false from now on. We will depend on this side
effect in later commits when we remove legacy InstantSend code.

* Stop handling/relaying legacy IX messages

When we receive an IX message, we simply treat it as a regular TX and relay
it as such.

We'll however still request IX messages when they are announced to us. We
can't simply revert to requesting TX messages in this case as it might
result in the other peer not answering due to the TX not being in mapRelay
yet. We should at some point in the future completely drop handling of IX
messages instead.

* Remove IsNewInstantSendEnabled() and only use IsInstantSendEnabled()

* Remove legacy InstantSend from GUI

* Remove InstantSend from Bitcoin/Dash URIs

* Remove legacy InstantSend from RPC commands

* Remove legacy InstantSend from wallet

* Remove legacy instantsend.h include

* Remove legacy InstantSend from validation code

* Completely remove remaining legacy InstantSend code

* Remove now unused spork

* Fix InstantSend related test failures

* Remove now obsolete auto IS tests

* Make spork2 and spork3 disabled by default

This should have no influence on mainnet as these sporks are actually set
there. This will however affect regtest, which shouldn't have LLMQ based
InstantSend enabled by default.

* Remove instantsend tests from dip3-deterministicmns.py

These were only testing legacy InstantSend

* Fix .QCheckBox#checkUsePrivateSend styling a bit

* s/TXLEGACYLOCKREQUEST/LEGACYTXLOCKREQUEST/

* Revert "verified via InstantSend" back to "verified via LLMQ based InstantSend"

* Use cmd == nullptr instead of !cmd

* Remove last parameter from AvailableCoins call

This was for fUseInstantSend which is not present anymore since rebase
2019-07-09 17:50:08 +03:00
Wladimir J. van der Laan
a1770b0c25 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)

manual fixes

Signed-off-by: Pasta <pasta@dashboost.org>

remove sendalert.cpp

Signed-off-by: Pasta <pasta@dashboost.org>

CAlertNotify -> AlertNotify

Signed-off-by: Pasta <pasta@dashboost.org>

remove alert.h

Signed-off-by: Pasta <pasta@dashboost.org>

remove vAlertPubKey for DevNet

Signed-off-by: Pasta <pasta@dashboost.org>

remove src/main.cpp
2019-06-21 19:33:53 -05:00
Alexander Block
53827a3764 Remove code for QDEBUGSTATUS propagation (#2891)
* Remove code for QDEBUGSTATUS propagation

This turned out to be too expensive and could easily take the network
down by bringing all nodes to 100% CPU usage. Better to fully remove this
functionality.

* Apply suggestions from code review

Co-Authored-By: codablock <ablock84@gmail.com>

* Update src/rpc/rpcquorums.cpp

Co-Authored-By: codablock <ablock84@gmail.com>
2019-05-02 02:20:06 +03:00
Alexander Block
b18f8cb77c
Implement MNAUTH and allow unlimited inbound MN connections (#2790)
* Sort evo/* source files in Makefile.am

* Keep track of proRegTxHash in CConnman::masternodeQuorumNodes map

We will later need the proRegTxHash

* Fix serialization of std::tuple with const rvalue elements

Having serialization and deserialization in the same specialized template
results in compilation failures due to the "if(for_read)" branch.

* Implement MNAUTH message

This allows masternodes to authenticate themself.

* Protect fresh incoming connections for a second from eviction

Give fresh connections some time to do the VERSION/VERACK handshake and
an optional MNAUTH when it's a masternode. When an MNAUTH happened, the
incoming connection is then forever protected against eviction.

If a timeout of 1 second occurs or the first message after VERACK is not
MNAUTH, the node is not protected anymore and becomes eligable for
eviction.

* Avoid connecting to masternodes if an incoming connection is from the same one

Now that incoming connections from MNs authenticate them self, we can avoid
connecting to the same MNs through intra-quorum connections.

* Apply review suggestions
2019-03-22 11:52:37 +01:00
Alexander Block
9a1362abdf
Introduce SENDDSQUEUE to indicate that a node is interested in DSQ messages (#2785) 2019-03-21 09:33:41 +01:00
Alexander Block
12274e578a
Introduce "qsendrecsigs" to indicate that plain recovered sigs should be sent (#2783)
* Introduce "qsendrecsigs" to indicate that plain recovered sigs should be sent

Full nodes, including masternodes, will send this message automatically.
Other node implementations (e.g. SPV) are usually not interested and would
not send this message.

* Use std::atomic<bool> instead of std::atomic_bool

Not related to this PR, but a small enough change to include it here as
well.
2019-03-21 07:47:02 +01:00
Alexander Block
2299ee2836 Rename IXLOCK to ISLOCK and InstantX to InstantSend 2019-03-07 21:15:09 +01:00
Alexander Block
83dbcc483f Implement CInstantSendManager and related P2P messages 2019-03-07 21:14:31 +01:00
Alexander Block
55a6182b10 Introduce QSIGSESANN/CSigSesAnn P2P message 2019-02-27 17:33:40 +01:00
Alexander Block
29532ba196 Implement and enforce ChainLocks 2019-01-28 12:24:15 +01:00
Alexander Block
c38f889e77 Implement processing, verifcation and propagation of signature shares 2019-01-21 14:42:08 +01:00
Alexander Block
43fd1b352f Implement CSigningManager to process and propagage recovered signatures 2019-01-21 14:42:08 +01:00
Alexander Block
324406bfed Implement debugging messages and RPC for LLMQ DKGs 2019-01-09 12:16:12 +01:00
Alexander Block
6836f8c38b Implement LLMQ DKG 2019-01-09 12:16:12 +01:00
Alexander Block
0df3871d14 Remove dummy DKG 2019-01-09 12:16:11 +01:00
Alexander Block
f95aae2b30 Remove all legacy/compatibility MN code (#2600)
* Remove CActiveLegacyMasternodeManager

* Remove sentinelping RPC

* Remove unused P2P messages and inv types

There are still places where these are used in the code. The next commits
will clean these up.

* Remove MNB/MNP/MNVERIFY related code from masternode(man).h/cpp

* Remove all legacy code regarding block MN payee voting

* Remove MASTERNODE_SYNC_LIST and MASTERNODE_SYNC_MNW states

Also replace all uses of IsMasternodeListSynced and IsWinnersListSynced
with IsBlockchainSynced.

* Remove unsupported masternode RPCs

* Remove UpdateLastPaid methods

* Remove duplicate deterministicmns.h include

* Remove masternode.conf support

* Remove legacy MN lists support from masternode list GUI

* Remove unnecessary AskForMN call

* Remove compatibility code in CPrivateSendQueue::GetSignatureHash

* Don't add locally calculated MN payee in case GetBlockTxOuts failed

This is not valid in DIP3 mode

* Remove check for IsDeterministicMNsSporkActive in "masternode status"

* Move CMasternode::IsValidNetAddr to CActiveDeterministicMasternodeManager

* Remove use of CMasternode::CheckCollateral in governance code

* Remove uses of MASTERNODE_SENTINEL_PING_MAX_SECONDS/MASTERNODE_SENTINEL_PING_MAX_SECONDS

* Remove support for "-masternodeprivkey"

* Remove pre-DIP3 vote cleanup

* Remove compatibility code for quorumModifierHash/masternodeProTxHash

* Remove check for invalid nBlockHeight in CMasternodePayments::GetBlockTxOuts

...and let it crash instead. We expect this method to be called with the
correct height now (after DIP3 was fully deployed).

* Remove ECDSA based Sign/CheckSignature from CGovernanceObject

Only masternodes sign governance objects, so there is no need for ECDSA
support here anymore.

* Always add superblock and MN reward payments into new block

* Always check block payees (except if fLiteMode==true)

* Always allow superblock and MN payees in same block

* Remove/Fix a few references to masternode.conf and related stuff

Also delete guide-startmany.md and masternode_conf.md

* Implement NotifyMasternodeListChanged signal and call governance maintenance

* Remove non-DIP3 code path from CMasternodeMan::Find

* Remove remaining unused code from CMasternode/CMasternodeMan

* Always load governance.dat on startup

* Mine an empty block instead of incrementing nHeight from chain tip in miner tests

This test is crashing otherwise in GetBlockTxOuts as it tries to access a
previous block that is not existing.

* Skip MN payments verification on historical blocks (pre-DIP3 blocks)

Even though DIP3 was active on BIP9 level, the spork was not active yet at
that point meaning that payments were not enforced at that time.

* Remove unused state and CollateralStatus enums

* Unconditionally return false from IsBlockPayeeValid when IsTransactionValid returns false

IsTransactionValid already handles the case where IsDIP3Active() returns
false, making it return true.

* Add override keyword to CDSNotificationInterface::NotifyMasternodeListChanged

* Fix help for masternodelist status (POSE_BANNED and no OUTPOINT_SPENT)
2019-01-03 12:17:43 +03:00
Alexander Block
d9b28fe1ad
Introduce dummy (ping-like) contributions for the dummy DKG (#2542)
* Implement creation and propagation of dummy contributions

These act as a ping which is broadcast a few blocks before the dummy
commitments are created. They are meant to determine online/offline members.

* Use information about received dummy contributions to determine validMembers

* Fix PoSe tests

* Fix dummy DKG phase progress in PoSe tests and give tests more time

Mine one block at a time until we reach the mining phase.
2018-12-10 06:04:33 +01:00
Alexander Block
a4f5ba38b6
Implement CDummyDKG and CDummyCommitment until we have the real DKG merged (#2492)
* Add SPORK_17_QUORUM_DKG_ENABLED spork

* Implement CDummyDKG and CDummyCommitment until we have the real DKG merged

This is only used on testnet/devnet/regtest and will NEVER be used on
mainnet. It is NOT SECURE AT ALL!

See comment in quorums_dummydkg.h for more details.

* Test simple PoSe in DIP3 tests

* Generate 2 instead of 4 blocks per iteration in PoSe tests

4 was based on old chainparams where I used larger phases.

* Only sleep when necessary in PoSe tests

* Fix typo in comment

* Give PoSe tests more time and sync after fast-forward
2018-11-26 16:53:20 +01:00
Alexander Block
22b5952c5a
Implement and enforce DIP6 commitments (#2477)
* Add LLMQ parameters to consensus params

* Add DIP6 quorum commitment special TX

* Implement CQuorumBlockProcessor which validates and handles commitments

* Add quorum commitments to new blocks

* Propagate QFCOMMITMENT messages to all nodes

* Allow special transactions in blocks which have no inputs/outputs

But only for TRANSACTION_QUORUM_COMMITMENT for now.

* Add quorum commitments to self-crafted blocks in DIP3 tests

* Add simple fork logic for current testnet

This should avoid a fork on the current testnet. It only applies to the
current chain which activated DIP3 at height 264000 and block
00000048e6e71d4bd90e7c456dcb94683ae832fcad13e1760d8283f7e89f332f.

When we revert the chain to retest the DIP3 deployment, this fork logic
can be removed again.

* Use quorumVvecHash instead of quorumHash to make null commitments unique

Implementation of https://github.com/dashpay/dips/pull/31

* Re-add quorum commitments after pruning mempool selected blocks

* Refactor CQuorumBlockProcessor::ProcessBlock to have less nested if/else statements

Also add BEGIN/END markers for temporary code.

* Add comments/documentation to LLMQParams

* Move code which determines if a commitment is required into IsCommitmentRequired

This should make the code easier to read and also removes some duplication.

The also changes the error types that are possible from 3 to 2 now. Instead
of having "bad-qc-already-mined" and "bad-qc-not-mining-phase", there is
only "bad-qc-not-allowed" now.

* Use new parameter from consensus parames for the temporary fork
2018-11-23 15:42:09 +01:00
Alexander Block
d3ac86206c Implement GETMNLISTDIFF and MNLISTDIFF P2P messages
Also add "protx diff" RPC
2018-09-03 10:46:52 +02:00
Alexander Block
8b4c419ed6 Revert "Merge #7542: Implement "feefilter" P2P message" (#2025)
This reverts commit 11ac70af9e.
2018-04-11 18:16:43 +03:00
gladcow
bc45a2f87a Backport compact blocks functionality from bitcoin (#1966)
* 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)

* Merge #8408: Prevent fingerprinting, disk-DoS with compact blocks

1d06e49 Ignore CMPCTBLOCK messages for pruned blocks (Suhas Daftuar)
1de2a46 Ignore GETBLOCKTXN requests for unknown blocks (Suhas Daftuar)

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

* Merge #8505: Trivial: Fix typos in various files

1aacfc2 various typos (leijurv)

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

* Merge #8739: [qa] Fix broken sendcmpct test in p2p-compactblocks.py

157254a Fix broken sendcmpct test in p2p-compactblocks.py (Suhas Daftuar)

* Merge #8854: [qa] Fix race condition in p2p-compactblocks test

b5fd666 [qa] Fix race condition in p2p-compactblocks test (Suhas Daftuar)

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

* Merge #8882: [qa] Fix race conditions in p2p-compactblocks.py and sendheaders.py

b55d941 [qa] Fix race condition in sendheaders.py (Suhas Daftuar)
6976db2 [qa] Another attempt to fix race condition in p2p-compactblocks.py (Suhas Daftuar)

* Merge #8904: [qa] Fix compact block shortids for a test case

4cdece4 [qa] Fix compact block shortids for a test case (Dagur Valberg Johannsson)

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

* Merge #8975: Chainparams: Trivial: In AppInit2(), s/Params()/chainparams/

6f2f639 Chainparams: Trivial: In AppInit2(), s/Params()/chainparams/ (Jorge Timón)

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

* Merge #8995: Add missing cs_main lock to ::GETBLOCKTXN processing

dfe7906 Add missing cs_main lock to ::GETBLOCKTXN processing (Matt Corallo)

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

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

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

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

* Merge #9160: [trivial] Fix hungarian variable name

ec34648 [trivial] Fix hungarian variable name (Russell Yanofsky)

* Merge #9159: [qa] Wait for specific block announcement in p2p-compactblocks

dfa44d1 [qa] Wait for specific block announcement in p2p-compactblocks (Russell Yanofsky)

* Merge #9125: Make CBlock a vector of shared_ptr of CTransactions

b4e4ba4 Introduce convenience type CTransactionRef (Pieter Wuille)
1662b43 Make CBlock::vtx a vector of shared_ptr<CTransaction> (Pieter Wuille)
da60506 Add deserializing constructors to CTransaction and CMutableTransaction (Pieter Wuille)
0e85204 Add serialization for unique_ptr and shared_ptr (Pieter Wuille)

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

* Merge #9199: Always drop the least preferred HB peer when adding a new one.

ca8549d Always drop the least preferred HB peer when adding a new one. (Gregory Maxwell)

* Merge #9233: Fix some typos

15fa95d Fix some typos (fsb4000)

* Merge #9260: Mrs Peacock in The Library with The Candlestick (killed main.{h,cpp})

76faa3c Rename the remaining main.{h,cpp} to validation.{h,cpp} (Matt Corallo)
e736772 Move network-msg-processing code out of main to its own file (Matt Corallo)
87c35f5 Remove orphan state wipe from UnloadBlockIndex. (Matt Corallo)

* Merge #9014: Fix block-connection performance regression

dd0df81 Document ConnectBlock connectTrace postconditions (Matt Corallo)
2d6e561 Switch pblock in ProcessNewBlock to a shared_ptr (Matt Corallo)
2736c44 Make the optional pblock in ActivateBestChain a shared_ptr (Matt Corallo)
ae4db44 Create a shared_ptr for the block we're connecting in ActivateBCS (Matt Corallo)
fd9d890 Keep blocks as shared_ptrs, instead of copying txn in ConnectTip (Matt Corallo)
6fdd43b Add struct to track block-connect-time-generated info for callbacks (Matt Corallo)

* Merge #9240: Remove txConflicted

a874ab5 remove internal tracking of mempool conflicts for reporting to wallet (Alex Morcos)
bf663f8 remove external usage of mempool conflict tracking (Alex Morcos)

* Merge #9344: Do not run functions with necessary side-effects in assert()

da9cdd2 Do not run functions with necessary side-effects in assert() (Gregory Maxwell)

* Merge #9273: Remove unused CDiskBlockPos* argument from ProcessNewBlock

a13fa4c Remove unused CDiskBlockPos* argument from ProcessNewBlock (Matt Corallo)

* Merge #9352: Attempt reconstruction from all compact block announcements

813ede9 [qa] Update compactblocks test for multi-peer reconstruction (Suhas Daftuar)
7017298 Allow compactblock reconstruction when block is in flight (Suhas Daftuar)

* Merge #9252: Release cs_main before calling ProcessNewBlock, or processing headers (cmpctblock handling)

bd02bdd Release cs_main before processing cmpctblock as header (Suhas Daftuar)
680b0c0 Release cs_main before calling ProcessNewBlock (cmpctblock handling) (Suhas Daftuar)

* Merge #9283: A few more CTransactionRef optimizations

91335ba Remove unused MakeTransactionRef overloads (Pieter Wuille)
6713f0f Make FillBlock consume txn_available to avoid shared_ptr copies (Pieter Wuille)
62607d7 Convert COrphanTx to keep a CTransactionRef (Pieter Wuille)
c44e4c4 Make AcceptToMemoryPool take CTransactionRef (Pieter Wuille)

* Merge #9375: Relay compact block messages prior to full block connection

02ee4eb Make most_recent_compact_block a pointer to a const (Matt Corallo)
73666ad Add comment to describe callers to ActivateBestChain (Matt Corallo)
962f7f0 Call ActivateBestChain without cs_main/with most_recent_block (Matt Corallo)
0df777d Use a temp pindex to avoid a const_cast in ProcessNewBlockHeaders (Matt Corallo)
c1ae4fc Avoid holding cs_most_recent_block while calling ReadBlockFromDisk (Matt Corallo)
9eb67f5 Ensure we meet the BIP 152 old-relay-types response requirements (Matt Corallo)
5749a85 Cache most-recently-connected compact block (Matt Corallo)
9eaec08 Cache most-recently-announced block's shared_ptr (Matt Corallo)
c802092 Relay compact block messages prior to full block connection (Matt Corallo)
6987219 Add a CValidationInterface::NewPoWValidBlock callback (Matt Corallo)
180586f Call AcceptBlock with the block's shared_ptr instead of CBlock& (Matt Corallo)
8baaba6 [qa] Avoid race in preciousblock test. (Matt Corallo)
9a0b2f4 [qa] Make compact blocks test construction using fetch methods (Matt Corallo)
8017547 Make CBlockIndex*es in net_processing const (Matt Corallo)

* Merge #9486: Make peer=%d log prints consistent

e6111b2 Make peer id logging consistent ("peer=%d" instead of "peer %d") (Matt Corallo)

* Merge #9400: Set peers as HB peers upon full block validation

d4781ac Set peers as HB peers upon full block validation (Gregory Sanders)

* Merge #9499: Use recent-rejects, orphans, and recently-replaced txn for compact-block-reconstruction

c594580 Add braces around AddToCompactExtraTransactions (Matt Corallo)
1ccfe9b Clarify comment about mempool/extra conflicts (Matt Corallo)
fac4c78 Make PartiallyDownloadedBlock::InitData's second param const (Matt Corallo)
b55b416 Add extra_count lower bound to compact reconstruction debug print (Matt Corallo)
863edb4 Consider all (<100k memusage) txn for compact-block-extra-txn cache (Matt Corallo)
7f8c8ca Consider all orphan txn for compact-block-extra-txn cache (Matt Corallo)
93380c5 Use replaced transactions in compact block reconstruction (Matt Corallo)
1531652 Keep shared_ptrs to recently-replaced txn for compact blocks (Matt Corallo)
edded80 Make ATMP optionally return the CTransactionRefs it replaced (Matt Corallo)
c735540 Move ORPHAN constants from validation.h to net_processing.h (Matt Corallo)

* Merge #9587: Do not shadow local variable named `tx`.

44f2baa Do not shadow local variable named `tx`. (Pavel Janík)

* Merge #9510: [trivial] Fix typos in comments

cc16d99 [trivial] Fix typos in comments (practicalswift)

* Merge #9604: [Trivial] add comment about setting peer as HB peer.

dd5b011 [Trivial] add comment about setting peer as HB peer. (John Newbery)

* Fix using of AcceptToMemoryPool in PrivateSend code

* add `override`

* fSupportsDesiredCmpctVersion

* bring back tx ressurection in DisconnectTip

* Fix delayed headers

* Remove unused CConnman::FindNode overload

* Fix typos and comments

* Fix minor code differences

* Don't use rejection cache for corrupted transactions

Partly based on https://github.com/bitcoin/bitcoin/pull/8525

* Backport missed cs_main locking changes

Missed from 58a215ce8c

* Backport missed comments and mapBlockSource.emplace call

Missed from two commits:
88c35491ab
7c98ce584e

* Add CheckPeerHeaders() helper and check in (nCount == 0) too
2018-04-11 14:06:01 +03:00
UdjinM6
5b1c4d8a11
Few (mostly trivial) cleanups and fixes (#1940)
* Drop nBudgetProposalEstablishingTime

* Refactor: replace `== COutPoint()` with `.IsNull()`

* Refactor: add `operator bool()` to CMasternodePing

* Refactor: actually use `operator bool()` for CPendingDsaRequest

* Refactor: fixing code style in TrafficGraphData

* Fix some comments and whitespaces

* Drop CGovernanceVote::GetTypeHash()

* Drop legacy X11 code

No longer used... if it ever was used at all.

* Move `<boost/foreach.hpp>` out of coins.h

* Simplify CMasternodeBlockPayees::GetRequiredPaymentsString()

Also less of boost::lexical_cast

* Drop CTxDSIn::nSentTimes

* Fix few warnings

* fix warning (timer)

* fix nit
2018-02-21 19:32:08 +03:00
Wladimir J. van der Laan
19a2d668cf 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)
2018-01-15 06:14:15 +01:00
Wladimir J. van der Laan
0f021e55f6 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)
2018-01-12 09:58:14 +01:00
Alexander Block
005ae79cf3 Refactor MSG_XXX enum values to align with Bitcoin core
Needed as we skipped SegWit related backports
2018-01-12 09:58:14 +01:00
Wladimir J. van der Laan
b00f025dd8 Merge #8583: Show XTHIN in GUI
4c3e2cb Show XTHIN in GUI (R E Broadley)
2018-01-09 14:04:20 +01:00
Wladimir J. van der Laan
11ac70af9e Merge #7542: Implement "feefilter" P2P message
0371797 modify release-notes.md and bips.md (Alex Morcos)
b536a6f Add p2p test for feefilter (Alex Morcos)
5fa66e4 Create SingleNodeConnCB class for RPC tests (Alex Morcos)
9e072a6 Implement "feefilter" P2P message. (Alex Morcos)
2017-12-19 13:18:30 +01:00
Oleg Girko
b82b9787d2 Backport Bitcoin PR#8128: Net: Turn net structures into dumb storage classes (#1604)
* net: Split resolving out of CNetAddr

* net: Split resolving out of CService

* net: Split resolving out of CSubNet

* net: move CNetAddr/CService/CSubNet out of netbase

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

* net: Add direct tests for new CSubNet constructors

* 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

* net: fixup nits
2017-09-03 16:29:10 +03:00
Oleg Girko
bcf5455bfd Backport Bitcoin PR#8822: net: Consistent checksum handling (#1565)
* 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.

* net: Hardcode protocol sizes and use fixed-size types

The P2P network uses a fixed protocol, these sizes shouldn't change
based on what happens to be the architecture.
2017-08-08 20:57:36 +03:00
Oleg Girko
b39c518d5a Backport Bitcoin PR#7749: Enforce expected outbound services (#1508)
* Only store and connect to NODE_NETWORK nodes

* Keep addrman's nService bits consistent with outbound observations

* Verify that outbound connections have expected services

* Don't require services in -addnode

* Introduce enum ServiceFlags for service flags

* Introduce REQUIRED_SERVICES constant
2017-07-05 06:45:23 +03:00
UdjinM6
342bda5fdc new PoSe - MNVERIFY (#1066) 2016-10-21 01:11:30 +04:00
UdjinM6
ec239ffa36 Mostly winner -> payment vote (#1033)
Followup for the recent winner_block PR (#1028) and name confusion discovered during code review.

"Mostly" because also:

- CMasternodeBlockPayees::GetPayee -> CMasternodeBlockPayees::GetBestPayee which describes what this function is actually doing a bit better imo;
- fixing constructor CMasternodePaymentVote empty constructor
2016-09-21 18:45:29 +04:00
UdjinM6
1e2d61ad0d Implement a way to sync only needed winners (#1028)
* store vote hashes in CMasternodePayee and use them in CMasternodePayments::Sync

* Request low data payment blocks in batches directly from some node instead of/after preliminary Sync.

* remove nVotes
2016-09-19 02:23:52 +04:00
UdjinM6
9bf1e00f09 rename NetMsgType::IX -> NetMsgType::TXLOCKREQUEST, NetMsgType::IXLOCKVOTE -> NetMsgType::TXLOCKVOTE (#1021) 2016-09-16 00:07:01 +04:00
UdjinM6
625b5ebb09 Merge #936: Bump NO_BLOOM_VERSION and SENDHEADERS_VERSION to match PROTOCOL_VERSION
411ad29 Bump NO_BLOOM_VERSION and SENDHEADERS_VERSION to match PROTOCOL_VERSION
2016-08-12 07:41:23 +02:00
UdjinM6
b4cb1e2610 Merge #911: Fix sync process: (#911)
- mn hash compatibility with 70103
- ignore some requests while syncing
- fix locking/initializing in sync
- do not ban for old mnw
- split budget/governance messages/invs
2016-08-05 18:25:03 +02:00
Evan Duffield
95ba71570b Merge #864: govobj sync
487674f Governance object/vote syncing fixes
- disable fCached values
- use two maps for storing votes, by hash and parent-hash/type
- disable part of flatdb.dump (still overwriting)
- fixed govobj/votes relay and sync

15821fe various fixes
- Added const where possible
- Uncommented sync block
- Protocol min 70201
- Fixed bug which flags invalid votes incorrectly
- Formatting

aa8fdd7 fix curly braces

d8e39b1 Fix GetTypeHash bug
- Should not collide based on the outcome

732a8a3 fixed mismatched index for vote map
2016-06-08 08:57:16 +02:00