Commit Graph

71 Commits

Author SHA1 Message Date
UdjinM6
8178b297ee
spork: Introduce SPORK_23_QUORUM_POSE (#3907)
This splits SPORK_21_QUORUM_ALL_CONNECTED into two which should let us control node connectivity and quorum PoSe individually.
2021-01-10 21:23:01 -06:00
UdjinM6
f13852e662
PrivateSend: Harden SPORK_22_PS_MORE_PARTICIPANTS (#3860) 2020-12-09 20:00:08 +00:00
UdjinM6
757c99eb20
evo/llmq/spork: Fix various (potential) locking issues (#3829)
* Fix potential deadlock in `CSporkManager::UpdateSpork()`

* Protect `inputRequestIds` with cs lock

* Protect `curDBTransaction` in `CEvoDB::CommitRootTransaction()`

* Check for `AssertLockNotHeld` in `EnforceBestChainLock()` instead of just having a comment in code

* Protect spork maps on (de)serialization
2020-11-28 19:06:51 +00:00
PastaPastaPasta
8baf69d448
Harden spork6 logic then remove spork6 (#3662)
* Harden Spork6

Spork6 was previously activated on testnet, but we then developed an alternative fix for the issue and never activated spork6 on mainnet. At this point, Spork6 will not be activated on mainnet.
As such, it makes sense to harden Spork6 and ensure that spork6 will never be activated on mainnet. So, we just change from checking Spork6 to checking if we are on testnet. If we are on testnet, use spork6 logic, else don't.

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

* remove now unused SPORK_6_NEW_SIGS

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

* force fSporkSixActive to be correct, otherwise return

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

* Harden spork6 even more

* Add TODO in chainparams as a reminder to drop all spork6 related code on next testnet reset

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-08-30 17:22:21 +03:00
MarcoFalke
db747ea384 Merge #12757: Clarify include guard naming convention
3bcc0059b8 Add lint-include-guards.sh which checks include guard consistency (practicalswift)
8fd6af89a0 Fix missing or inconsistent include guards (practicalswift)
8af65d96f4 Document include guard convention (practicalswift)

Pull request description:

  * **Documentation**: Document include guard convention
  * **Fix**: Fix missing or inconsistent include guards
  * **Regression test**: Add `lint-include-guards.sh` which checks include guard consistency

Tree-SHA512: 8171878f60fd08ccbea943a11e835195750592abb9d7ab74eaa4265ae7fac523b1da9d31ca13d6ab73dd596e49986bfb7593c696e5f39567c93e610165bc2acc
Signed-off-by: pasta <pasta@dashboost.org>

# Conflicts:
#	src/bech32.h
#	src/consensus/merkle.h
#	src/key_io.h
#	src/policy/fees.h
#	src/rpc/server.h
#	src/script/bitcoinconsensus.h
#	src/wallet/coinselection.h
2020-07-19 00:42:54 -05:00
PastaPastaPasta
1d94d914c5
privatesend: Increase max participants to 20 (#3610)
* Add spork to change max mixing participants to 20

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

* Also change min participants on devnet/testnet

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

* adjust formatting

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

* add nPoolNewMinParticipants under regtest

Signed-off-by: pasta <pasta@dashboost.org>
2020-07-17 13:19:29 +03:00
PastaPastaPasta
8fcda67a54
Remove spork 15, 16, 20 (#3493)
Signed-off-by: pasta <pasta@dashboost.org>
2020-05-20 12:24:35 +03:00
Alexander Block
486463d622 Add SPORK_21_QUORUM_ALL_CONNECTED 2020-03-27 15:12:20 +01: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
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
PastaPastaPasta
2756cb7954 remove spork 12 (#2754)
Signed-off-by: Pasta <Pasta@dash.org>
2019-06-18 14:32:11 +03:00
UdjinM6
2c5e2bc6c8
Inject custom specialization of std::hash for SporkId enum into std (#2960)
This should fix compilation on gcc5
2019-06-08 14:16:20 +03:00
Alexander Block
fc73b4d6e6 Refactor sporks to get rid of repeated if/else blocks (#2946)
* Use enum to define spork IDs

* Introduce CSporkDef and remove if/else blocks in GetSporkIDByName/GetSporkNameByID

* Deduplicate code in IsSporkActive

* Fix spork RPC to use new spork defs

This also removes the need for SPORK_START/SPORK_END

* Move sporkManager global variable below sporkDefs

This ensures correct order of initialization.
2019-05-29 21:18:31 +03: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
241f76f9bf Collection of minor performance optimizations (#2855)
* Merge #13176: Improve CRollingBloomFilter performance: replace modulus with FastMod

9aac9f90d5e56752cc6cbfac48063ad29a01143c replace modulus with FastMod (Martin Ankerl)

Pull request description:

  Not sure if this is optimization is necessary, but anyway I have some spare time so here it is. This replaces the slow modulo operation with a much faster 64bit multiplication & shift. This works when the hash is uniformly distributed between 0 and 2^32-1. This speeds up the benchmark by a factor of about 1.3:

  ```
  RollingBloom, 5, 1500000, 3.73733, 4.97569e-07, 4.99002e-07, 4.98372e-07 # before
  RollingBloom, 5, 1500000, 2.86842, 3.81630e-07, 3.83730e-07, 3.82473e-07 # FastMod
  ```

  Be aware that this changes the internal data of the filter, so this should probably
  not be used for CBloomFilter because of interoperability problems.

Tree-SHA512: 04104f3fb09f56c9d14458a6aad919aeb0a5af944e8ee6a31f00e93c753e22004648c1cd65bf36752b6addec528d19fb665c27b955ce1666a85a928e17afa47a

* Use unordered_map in CSporkManager

In one of my profiling sessions with many InstantSend transactions
happening, calls into CSporkManager added up to about 1% of total CPU time.
This is easily avoidable by using unordered maps.

* Use std::unordered_map instead of std::map in limitedmap

* Use unordered_set for CNode::setAskFor

* Add serialization support for unordered maps and sets

* Use unordered_map for mapArgs and mapMultiArgs

* Let limitedmap prune in batches and use unordered_multimap

Due to the batched pruning, there is no need to maintain an ordered map
of values anymore. Only when nPruneAfterSize, there is a need to create
a temporary ordered vector of values to figure out what can be removed.

* Instead of using a multimap for mapAskFor, use a vector which we sort on demand

CNode::AskFor will now push entries into an initially unordered vector
instead of an ordered multimap. Only when we later want to use vecAskFor in
SendMessages, we sort the vector.

The vector will actually be mostly sorted in most cases as insertion order
usually mimics the desired ordering. Only the last few entries might need
some shuffling around. Doing the sort on-demand should be less wasteful
then trying to maintain correct order all the time.

* Fix compilation of tests

* Fix limitedmap tests

* Rename limitedmap to unordered_limitedmap to ensure backports conflict

This ensures that future backports that depends on limitedmap's ordering
conflict so that we are made aware of needed action.

* Fix compilation error on Travis
2019-04-11 15:42:14 +03:00
Alexander Block
f5dcb00acf Introduce spork SPORK_20_INSTANTSEND_LLMQ_BASED to switch between new/old system 2019-03-07 21:15:09 +01:00
Alexander Block
3bbc75fc48 Reintroduce spork15 so that it's relayed by 0.14 nodes (#2701) 2019-02-14 21:24:06 +03:00
Alexander Block
f6828b19b6
Merge pull request #2643 from codablock/pr_llmq_chainlocks
Implement LLMQ based ChainLocks
2019-01-29 15:59:05 +01:00
PastaPastaPasta
f123248f1c update copyright (#2648)
* update copyright

* Update copyright in configure.ac and COPYING
2019-01-29 15:53:14 +01:00
Alexander Block
135829dc49 Add SPORK_19_CHAINLOCKS_ENABLED 2019-01-28 12:24:15 +01:00
Alexander Block
352edbd33e Introduce SPORK_18_QUORUM_DEBUG_ENABLED to enable/disable LLMQ debug messages 2019-01-09 12:16:12 +01:00
Alexander Block
7d58d87f43 Remove a few sporks which are not used anymore (#2607)
* Remove SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT

And always enforce payments.

* Remove SPORK_10_MASTERNODE_PAY_UPDATED_NODES and SPORK_10_MASTERNODE_PAY_UPDATED_NODES
2019-01-03 23:08:51 +03:00
Alexander Block
0c9fb69687 Harden spork15 on testnet (#2586)
* Replace IsDeterministicMNsSporkActive with IsDIP3Active

IsDIP3Active will now use a fixed parameter from consensus params.
Values for DIP0003Height/DIP0003Hash need to be updated when spork15
activates on mainnet.

Also enforce correct block hash on testnet/mainnet for DIP3 activation
block.

* Remove SPORK_15_DETERMINISTIC_MNS_ENABLED

* Replace all uses of IsDeterministicMNsSporkActive with IsDIP3Active

* Remove DIP3 upgrade-path tests and directly start with DIP3 enabled tests

* Make -masternodeprivkey non-mandatory

This code will vanish later.
2018-12-28 19:13:44 +03: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
Nathan Marley
07208a4ae2 document spork system with doxygen comments (#2301)
This is an initial shot at an on-going WIP, which will add documentation via
Doxygen comments to (especially) Dash-specific features in the codebase.
2018-10-02 12:02:27 +03:00
gladcow
f7ab6c469c M-of-N-like sporks (#2288)
* support set of keys to sign spork

* several addresses support in -sporkkey

* tests for multykey sporks

* command line option -minsporkkeys

* make spork active only after given number of signers

* use signature in spork hash calculation

* test for new and old spork messages interaction

* add multikeyspork.py to integration tests

* change test to have ability to distinguish default spork value

* require min spork keys number to be more than the half of the common spork keys number

* calc current spork value with majority of signers

* set test nodes time in integration test

* extract keyid from signed spork message directly

* change -sporkaddr option syntax to process several addresses

* codestyle fixes

* fix test comments

* codestyle fixes

* simplify CSporkManager::SporkValueIsActive

* Calc signature hash without signature field

* do not restore pubkey ids from cach

* Calc different keyids to check signature because not all sporks can be synced at moment

* codestyle fixes

* Fix CSporkManager::CheckAndRemove to use several keys

* codestyle fixes

* Correct processing of not actual spork6 value with GetSignerKeyID
2018-09-30 20:01:33 +03:00
gladcow
5454bea377 Automatic InstantSend locks for "simple" transactions (#2140)
* add locktransaction rpc call

* Remove special instantsend fee for simple transactions

* Function to check if trx is simple enough to be autolocked

* Automatic lock for all received from peers simple trxes

If we get a new transaction with CInv message and it is "simple" and
is accepted in mempool, we initiate its lock. We don't lock orphan trxes
that accepted in mempool after this trx because they are locked by other
peers.

* Automatically lock simple trxes in wallet

* protocol bump for InstantSend without special fee

* Add function to detect used mempool share

* Mempool threshold for auto IX locks

* Add SPORK_16_INSTANTSEND_AUTOLOCKS spork

* Make autolocks active only when spork SPORK_16_INSTANTSEND_AUTOLOCKS is active

* BIP9 autolocks activation

* revert increasing min peer protocol version for mn rank

* move IsTrxSimple check to CTxLockRequest class

* make MAX_INPUTS_FOR_AUTO_IX private member of CTxLockRequest class

* make AUTO_IX_MEMPOOL_THRESHOLD private member of CInstantSend class

* remove locktransaction RPC call

* tests for automatic IS locks

* fix mempool threshod calculation

* bump mocktime in activate_autoix_bip9

* set node times

* no need to spam the node with gettransaction rpc requests that often

* use `spork active` instead of leaking spork logic into tests

* codestyle fixes

* add test description in comments

* fix typo

* sync test nodes more often during BIP9 activation

* Use 4th bit in BIP9 activation

* Fix comments according codestyle guide

* Call AcceptLockRequest and Vote at the first node creating autoix lock

* fix mempool used memory calculation

* rallback not necessary change in CWallet::CreateTransaction

* test for stopping autolocks for full mempool

* Inject "simple autolockable" txes into txlockrequest logic
2018-09-26 17:17:47 +03:00
UdjinM6
8c0dca2826
Add versioning to spork cache (#2312) 2018-09-26 17:15:02 +03:00
Alexander Block
5461e92bf4 Add spork to control deterministic MN lists activation 2018-08-30 19:47:48 +02:00
Nathan Marley
73c2ddde7a extract sporkmanager from sporkmessage (#2234)
The SporkMessage is a lower-level construct which shouldn't be aware of
SporkManager. This commit moves the `sporkManager.IsSporkActive()` calls
outside the SporkMessage functions. This follows the dependency injection
pattern and makes it easier to test SporkMessage as well.
2018-08-22 17:46:27 +03:00
gladcow
1767e3457e Save/load spork cache (#2206)
* CSporkManager class serialization

* Read/write sporks.dat file

* Move mapSporks into CSporkManager and serialize it

* fix GetSporkByHash

* spork tests

* add missed cs lock

* clear mapSporksByHash in CSporkManager::Clear

* use spork active rpc call to hide spork inner logic

* set small pause between rpc calls in cycles
2018-08-13 23:21:21 +03:00
Alexander Block
075ca0903f Protect CSporkManager with critical section (#2213) 2018-08-11 01:34:28 +03:00
UdjinM6
b07503f013
Some cleanup (mostly trivial) (#2038)
* Drop CInstantSend::IsEnoughOrphanVotesForTxAndOutPoint

* small cleanup in rpc tests

* move some pieces from .h to .cpp

* fix few log outputs

* fix some comments

* some trivial fixes + readability
2018-04-20 13:53:23 +03:00
Nathan Marley
f8e5c5d56e Simplify spork defaults by using a map (#2037) 2018-04-18 14:50:26 +03:00
Alexander Block
611879aa6d Use spork addresses instead of raw keys and allow changing them on startup (#1969)
* Support passing CKeyID to CMessageSigner/CHashSigner

* Use Dash addresses instead of raw public keys for sporks

The spork addresses are identical to the previously used public keys.

Also use CKeyID/CKey directly inside CSporkManager instead of parsing the
addresses/keys over and over. The default spork key (from chainparams) is
initialized with InitDefaultSporkAddress(). SetPrivKey parses the private
key now and stores it in sporkPrivKey instead of parsing it in
CSporkMessage::Sign().

* Allow setting of spork address via command line

* Remove unused strMasternodePaymentsPubKey chainparam

Traces from the past...

* Review fixes

1. Remove the need for InitDefaultSporkAddress
2. Remove bogus checks for hex private keys
3. Alphabetical order for new include
4. Add . to help string

* Add regtest spork key

As this key is not meant to be private, the private key is also added in
the form of a comment (for later use in regtests)

* Review fixes
2018-03-02 16:15:04 +03:00
UdjinM6
99273f63aa
Use SPORK_6_NEW_SIGS to switch from signing string messages to hashes (#1937)
* Use SPORK_6_NEW_SIGS to switch from signing string messages to hashes (gobject)

* Use SPORK_6_NEW_SIGS to switch from signing string messages to hashes (gobjvote)

* Use SPORK_6_NEW_SIGS to switch from signing string messages to hashes (mnw)

* Use SPORK_6_NEW_SIGS to switch from signing string messages to hashes (txlvote)

* Use SPORK_6_NEW_SIGS to switch from signing string messages to hashes (dsq)

* Use SPORK_6_NEW_SIGS to switch from signing string messages to hashes (dstx)

* Use SPORK_6_NEW_SIGS to switch from signing string messages to hashes (spork)

* Use SPORK_6_NEW_SIGS to switch from signing string messages to hashes (mnb)

* Actually care about old signature format in mnp, otherwise we can start banning peers rather quickly

* Use SPORK_6_NEW_SIGS to switch from signing string messages to hashes (mnv)

* Unify sign/verify code a bit by using GetSignatureHash() (even when it matches GetHash())

* fix docs

* address review comments

* fix log output (copy/paste error)

* Replace custom GetSignatureHash/GetHash with serialization (where applicable)

* Convert from/to old format in SerializationOp only for p2p

* fix
2018-02-16 17:54:53 +03:00
UdjinM6
451f7f0710
Fix issues with mnp, mnw and dsq signatures via new spork (SPORK_6_NEW_SIGS) (#1936)
* Use new spork SPORK_6_NEW_SIGS to fix masternode payment vote signature format

* Use SPORK_6_NEW_SIGS to also fix masternode ping signature format

* Use SPORK_6_NEW_SIGS to also fix privatesend queue signature format

* adjust spork6 description in docs

* mnp hashing/signing changed - hash everything and use SignHash/VerifyHash directly instead of constructing a string to sign (both activate via SPORK_6_NEW_SIGS)

* fix

* cleanup
2018-02-15 17:44:22 +03:00
UdjinM6
d5ef77ba99
Refactor: use constant refs and Ret suffix (#1928)
* Refactor function params from `std::string` to `const std::string&`

* Refactor more function params to use const references
2018-02-12 15:49:00 +03:00
UdjinM6
8a387ee09c
Drop SPORK_13_OLD_SUPERBLOCK_FLAG and check superblock start hash (#1872) 2018-02-01 15:42:21 +03:00
Wladimir J. van der Laan
3f1929fb0d Merge #9659: Net: Turn some methods and params/variables const
0729102 Net: pass interruptMsgProc as const where possible (Jorge Timón)
fc7f2ff Net: Make CNetMsgMaker more const (Jorge Timón)
d45955f Net: CConnman: Make some methods const (Jorge Timón)
2018-01-23 09:24:27 +01:00
Alexander Block
7765c87e79 Remove nType and nVersion from Dash related serialization code
Also remove bogus "nVersion = this->nVersion" assignments. These were
leftovers from old times.
2018-01-15 06:14:15 +01:00
Oleg Girko
8da26da713 Eliminate g_connman use in spork module. (#1613)
Pass reference to CConnman instance to methods of CSporkManager and
CSporkMessage instead of using g_connman global variable.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
2017-09-07 18:58:38 +03:00
Holger Schinzel
e1702cd4ec bump copyright notice to 2017 (#1207) 2016-12-20 17:26:45 +04:00
UdjinM6
072b0fd708 fix annoying compiler warnings (#1204) 2016-12-14 17:33:46 +04:00
Tim Flynn
3e8c0062a0 Implement SPORK_14_REQUIRE_SENTINEL (#1163) 2016-11-23 19:30:36 +04:00
UdjinM6
0597900c16 Changes for sporks: (#981)
- rename all 3 instantsend sporks
- remove SPORK_7_MASTERNODE_SCANNING (not used anymore)
- change `_DEFAULT` for spork 2 and 3, adjust comments for for them
- fix GetSporkNameByID() (should not return smth_DEFAULT)
2016-09-01 18:55:25 +04:00
UdjinM6
0cf75d0ef7 Merge #974: Slightly refactor sporks
6648716 Slightly refactor sporks, rename spork9 to SPORK_9_SUPERBLOCKS_ENABLED, remove SPORK_11_RESET_BUDGET (not used anymore)
2016-08-29 21:16:02 +02:00
Tim Flynn
de7b2b6c51 Merge #944: V0.12.1.x governance pr - part 1 - base functionality
068c178 Added DBG macro in util.h to facilitate debugging

    - This macro allows debugging statements (typically printf's or cout's) to
      be activated or deactivated with a single comment.  Uncomment the line:
      //#define ENABLE_DASH_DEBUG
      in util.h to enable debugging statements.

    - When commented any code wrapped with the DBG() macro will simply be removed
      by the preprocessor.  When not commented all such wrapped statements will
      be present.

    - For maximum effectiveness it is best that util.h be the first effective include
      in all source files.  It is also possible to enable the macro for a single file
      by temporarily adding #define ENABLE_DASH_DEBUG to the top of the file.

    - Code committed to non-development branches should always have the define
      commented.

d125d9b V0.12.1.x -- merging trigger/generic object/superblock changes for testnet phase II

    - This commit contains the core governance system changes for 0.12.1.  Any unrelated
      changes have either been removed or moved to separate commits.

120724c File mode fixes

    - Changed mode 0755->0644 on several source files.

c7f9e11 Updated todo reminders

    - Added reminder to revert temporary reduction of number of votes
      required to trigger superblock to 1 for testing

92adc98 Made CSuperblockManager::IsValidSuperblockHeight an inline function

    - This is for efficiency since this function is called often and is
      only 1 line of code.

c050ed7 Added comment explaining rationale for no LOCK(cs) in CSuperblock::IsValid

dc933fe Removed unused CSuperblockManager::IsBlockValid function

decec88 Moved calls to SuperblockManager::IsValidSuperblockHeight into IsSuperblockTriggered.

    - Since calls to the later function are always protected by the former there's
      no reason to keep these separate and this simplifies the code in
      masternode-payments.cpp.

8672885 Reestablished expected value check for non-superblocks in IsBlockValueValid

b01cbe0 Changes to IsBlockValueValid to fix rpc test failure

a937c76 Changed include order to allow per file activation of the DBG macro

d116aa5 Fixed IsValidSuperblockHeight logic

    - Note this has an effect on testing because we can now only create
      1 superblock per day.  Devs may need to temporarily change testnet params
      for easier testing.

2d0c2de Convert superblock payments to CAmount

    - We assume that payment values in JSON are in units of DASH
      for consistency with other RPC functions, such as
      createrawtransaction.

376b833 Revert temporary testing value for nAbsVoteReq

    - Also ensure that number of votes required is never smaller than 1

8c89f4b Cleaned up CSuperblock error handling

    - Exceptions are now thrown consistently rather than using a mix of
      exceptions and return code checking.  Exceptions are now caught only
      in AddNewTrigger when the CSuperblock constructor is called.  Unnecessary object
      status members have been removed.

d7c8a6b Removed utilstrencodings header

    - This appears to help with travis tests, for unknown reasons.

c4dfc7a Fixed some minor code review issues

63c3580 Reverted locking change in miner.

    - This should have been done in the original PR but was overlooked.

4ab72de Fixed variable name to match common practice and bracket formatting

886a678 Improvements to vote conversion code

    - Replaced redundantly defined function with inclusion of governance-vote.h

    - Replaced magic numbers with their corresponding constant symbols

0a37966 Reordered governance message handling
2016-08-17 09:08:25 +02:00
Tim Flynn
9a8a1ace9e Merge #943: Fixed non-deterministic CSporkMessage hash function
5bb8dca Fixed non-deterministic CSporkMessage hash function

CSporkMessage::GetHash() was including random data
in the hash due to 4 bytes of structure padding between the 32 bit
nSporkID and the following 64 bit nValue members.

This has been fixed by using CHashWriter which serializes the structure
data properly before hashing rather than relying on compiler defined behavior
such as structure alignment.  The underlying hash function is CHash256 which is
bitcoin's double SHA-256 hash.  HashX11 is not necessary here
because the hash is only used to identify distinct spork messages.
2016-08-15 16:46:46 +02:00
UdjinM6
d514ee7f9a Merge #922: Refactor/fix spork
42bdf42 Refactor/fix spork:
- move ProcessSpork, GetSporkValue, IsSporkActive, ExecuteSpork and mapSporksActive to CSporkManager
- move Sign, CheckSignature, Relay to CSporkMessage
- move ReprocessBlocks out of sporks to main.cpp / rename DisconnectBlocksAndReprocess to DisconnectBlocks
- rename SporkKey to SporkPubKey
- bugfix: only set strMasterPrivKey if spork signature produced by that key was verified successfully
- few log format changes, cleaned up includes
2016-07-30 13:04:27 +02:00