This updates the minimum known chain work values for the main and test
networks as follows:
mainnet: 0x00000000000000000000000000000000000000000013e6909b5a73128d52fc6f
testnet: 0x000000000000000000000000000000000000000000000000e41955f181d00f59
This adds checkpoints at the following heights:
mainnet:
- 237310
- 277940
- 318020
- 340120
- 362120
- 404170
- 424170
- 444170
- 464170
- 483600
testnet:
- 148320
- 213120
- 347140
- 411940
- 476740
- 515730
Note that this also includes some historical checkpoints to limit the
size of the gaps between each checkpoint to be around 3 months max.
This is being done because recent optimizations have sped up processing
to the point that larger gaps can trigger peers to get banned during IBD
in some cases.
This adds functionality to proactively evict SigCache entries when they
are nearly guaranteed to no longer be useful. It accomplishes this by
evicting entries related to transactions in the block that is 2 levels
deep from a newly processed block.
Proactively evicting entries reduces the likelihood of the SigCache
reaching maximum capacity quickly and then relying on random eviction,
which may randomly evict entries that are still useful.
This adds a uint64 short transaction hash to sigcache entries. This can
be used to proactively evict entries from the sigcache based on the
transaction that they are associated with.
This defines a shortTxHash method that generates a short 64-bit hash
from the standard 128-bit hash. It accomplishes this by using the
SipHash-2-4 hash function.
This is being introduced to track the transaction associated with a
signature cache entry at a reduced memory overhead.
This adds assertions to the existing treasury rpctest to verify that
treasury base transactions have the correct value even when the block
containing them has less than the maximum allowed of vote (SSGen)
transactions.
This adds the ability for the voting wallet to limit the total number of
votes issued, which is useful for some testing scenarios involving
blocks with less than the maximum number of votes.
Due to how the rpctest VotingWallet is currently structured
(specifically, the fact that it only tracks the absolute minimum amount
of tickets to advance the chain) it can't keep advancing the chain
indefinitely after limiting the number of votes for some blocks.
This is less than ideal, but sufficient for the tests that will be
introduced in future commits.
This adds assertions in the TestTreasury rpctest that verify the correct
behavior of the recently introduced gettreasuryspendvotes rpc command.
It also serves to ensure vote tallying of the underlying blockchain
corresponds to the expected ones.
The new gettreasuryspendvotes rpc command is useful to keep track of the
voting progress of treasury spend transactions as well as to query for
the status of old tspends.
When invoked without any parameters, the command tallies the vote counts
for all tspends currently in the node's mempool up to the current tip
block.
The first parameter ("Blocks") can be used to limit the block up to
which the tallies are performed, which is useful for historical queries.
The second parameter ("TSpends") can be used to narrow down the list of
tspends that should be queried. It can be used to query for tspends that
have already been mined.
A set of unit tests ensures proper behavior for the new command.
This allows external callers to tally the number of votes a given
treasury spend transaction has received.
This will be used in a future commit to allow the rpc server to offer
tspend vote counts via a new gettreasuryspendvotes command.
This changes the server to support the most recent protocol version (v8
or InitStateVersion).
On this version, instead of using the getminingstate/miningstate pair of
messages, peers use getinitstate/initstate messages which allow for
finer grained control over what information is sent upon startup.
The older protocol versions are still supported so that the node may
continue to both request and serve initial mining state to older nodes
of the network.
This modifies the peer package to handle GetInitState/InitState
messages by adding the appropriate listeners. It also bumps the max
supported protocol version to version 8, which is needed to be able to
decode the messages.
Note this modifies the peer package's go.mod to use the local copy of
the wire module in order to have access to the new messages.
This adds the GetInitState and InitState messages along with appropriate
tests. It also adds a new protocol version (version 8) and bumps the
current wire version to it.
This set of messages will be used to allow peers to exchange ephemeral
startup information in a more general manner than the current existing
GetMiningState/MiningState pair.
In particular, peers will be able to selectively request only the
specific startup info they're insterested in so that different types of
nodes (such as SPV clients) may only request relevant startup
information.
Compared to the existing MiningState message, the InitState message
already offers a new type of data: tspend hashes, that nodes may use to
fetch tspend transactions for inspecting, generating templates and
voting on their approval.
This improves handling of tspend expiries within the mempool and adds
relevant tests.
TSpends are tested for a correct expiry and are limited to enter the
mempool only when their voting starts less than two full voting
intervals in the future.
We add tests to ensure expired tspends can't enter the mempool and that
the tspend _can_ enter up to the last allowable height where it can be
included in a block.
TSpends have non-standard input signature scripts. Specifically, they
are not push-only, due to the presence of OP_TSPEND.
This commit special-cases tspends so that the mempool will accept them
even when configured to reject non-standard transactions.
We also add a set of tests to ensure tspends can enter the mempool
correctly.
This allows easier discovery of the current treasury spend transactions
in the mempool.
This will be needed in order to provide tspends to remote peers upon a
getinitstate message.
This should fix consumers requiring the blockchain module at dcrd
master. Previously, this would fail, due to an invalid require on the
released v2.0.0 version of standalone/v2, which has not yet been
released.
This adds code to migrate the database to the new schema required by the
decentralized treasury implementation.
It involves updating the utxo set and spend journal entries to account
for the change of the position of the fully spent bit within the flags
from bit 4 to bit 6. The process can be interrupted at any point and
future invocations will resume from the point it was interrupted.
This is based on https://proposals.decred.org/proposals/c96290a but was
modified in order to deal with realities that were unknown at the time
of the specification draft.
It is large and could not really be broken apart due to the pervasive
use of the isTreasuryEnabled flag. It was primarily authored by
* Marco Peereboom <marco@peereboom.us>
* Dave Collins <davec@conformal.com>
* Matheus Degiovani <opensource@matheusd.com>
With additional contributions from
* Donald Adu-Poku <donald.adu@gmail.com>
* Jamie Holdstock <jholdstock@decred.org>
Major changes:
* Add decentralized treasury agenda, as specified in DCP0006, to all supported
nets.
* Add functions to determine if the decentralized treasury agenda is active at
given block.
* Add new opcode OP_TADD that is a nop in txscript but is used to tag scripts
that credit the treasury account. This opcode is overloaded for treasurybase
and for normal transactions.
* Add new opcode OP_TSPEND that is a nop in txscript but is used to tag scripts
that debit the treasury account.
* Add new opcode OP_TGEN that is a nop in txscript but is used to tag P2PKH and
P2SH outputs in a TSpend transaction.
* Add functions that detect if a transaction is a valid TAdd, TSpend
or treasurybase transaction.
* Add error codes that return specific treasurybase/TAdd/TSpend consensus
violations.
* Modify countSpentOutputs to deal with treasury opcodes accordingly.
* Modify indexBlock to skip treasury transactions that do not have inputs.
* Add IsTreasuryEnabled call to ChainQueryer interface.
* Add treasury logger for debugging and logging the decentralized treasury
subsystem.
* Add IsTreasuryActive flag to BlockConnectedNtfnsData and
BlockDisconnectedNtfnsData.
* Modify OP_SSGEN to allow an optional output that contains votes for a TSpend
transaction hash.
* Add function that returns TSpend votes from an SSGen transaction.
* Modify CalcStakeVoteSubsidy so that treasurybase, unlike coinbase, is always
awarded the full percentage of the assigned block reward.
* Add helper functions to do all TSpend math so that callers don't roll their
own.
* Modify IsCoinBaseTx to not mistake a TSpend transaction as a coinbase.
* Add checkTreasuryBase function that verifies that a treasurybase is properly
constructed and pays the right amount to the treasury account.
* Add functions to calculate treasury balance for the provided block hash/node.
* Add function that verifies if a TSpend has a valid signature.
* Add functions to determine if a TSpend is not overspending.
* Add function to determine if a TSpend has been mined on the provided chain.
* Add functions that count and verifies treasury spend votes.
* Modify connectTransaction and disconnectTransactions to deal with the various
treasury transactions.
* Split CheckTransactionSanity in two functions
checkTransactionSanityContextFree and checkTransactionSanityContextual. This
is done in order to keep the decentralized treasury, which is always
contextual, from infecting the context free checks.
* Modify checkTransactionSanityContextual to recognize and verify treasury
transactions.
* Modify CheckTransactionSanity to deal with treasury transactions.
* Split checkBlockSanity in two functions checkBlockSanityContextFree and
checkBlockSanityContextual. This is done in order to keep the decentralized
treasury, which is always contextual, from infecting the context free checks.
* Modify checkBlockSanityContextual to enforce treasurybase and TAdd consensus
checks.
* Modify checkBlockPositional by unindenting it and adding TSpend consensus
enforcement.
* Modify checkCoinbaseUniqueHeightWithAddress to deal with the removal of the
project subsidy from output 0.
* Add checkCoinbaseUniqueHeightWithTreasuryBase that verifies coinbase and
treasurybase in the provided block.
* Unindent checkBlockContext.
* Modify checkTicketRedeemerCommitments and checkVoteInputs to deal with
potential tspend votes.
* Modify CheckTransactionInputs to skip treasurybase transactions.
* Modify CheckTransactionInputs to deal with TSpend transactions. Ensure the
provided Pi key is valid and that the signature is valid for the transaction.
Ensure that treasury TAdd and TSpend transaction utxo can only be spent after
coinbase maturity.
* Modify CountSigOps to deal with treasury transactions.
* Modify CountP2SHSigOps to deal with treasury transactions.
* Modify getStakeTreeFees to skip treasury transactions. Modify
totalOutputs to subtract ValueIn 0 for TSpend and treasurybase transactions.
* Modify checkTransactionsAndConnect to deal with modified amounts.
* Add tspendChecks function that verifies an entire TSpend transaction
validity at the point of the provided block. It ensures a TSpend is on a TVI.
It ensures the TSpend is in the valid window. It verifies that a TSpend In
and Out amounts match. It ensures a TSpend has the ValueIn amount encoded in
the OP_RETURN in Out 0. It ensures a TSpend has not been mined before on this
chain. It ensures a TSpend has the requisite votes. It ensures a TSpend is
not overspending.
* Modify checkConnectBlock to call checkTreasuryBase and tspendChecks when
treasury agenda is active.
* Add two tables to the database. Table "treasury" records the balance as of
this block and balance changes that occurred in this block which will become
active in CoinbaseMaturity blocks. Table "tspend" records all block hashes
where a TSpend has been mined this is to detect forks and prevent a Tspend
from being mined more than once.
* Modify handleBlockchainNotification to communicate if the treasury agenda is
active and skip treasurybase transaction when needed.
* Add various Treasury parameters to chaincfg params.
* Add hardcoded Tspend signatures in dcr_tmux_simnet_setup.sh.
* Add notifytspend and stoptspend calls to the RPC server. notifytspend
notifies the mempool when a TSpend transaction arrives.
* Modify commit filters V2 to recognize TAdd and TSpend transactions. It was
possible to modify V2 instead of introducing V3 because nothing changes from
the viewpoint of the wallet and treasury opcodes are disallowed prior to
agenda activation.
* Modify AddMemPoolTransaction to skip TSpend transactions that would throw the
fee estimator off.
* Add IsTreasuryAgendaActive, OnTSpendReceived and TSpendMinedOnAncestor to
mempool.Config in order to reject/accept TSpends in the mempool.
* Modify checkPoolDoubleSpend to ignore treasurybase.
* Modify mempool.maybeAcceptTransaction to enforce treasury standardness rules.
Don't allow TSpend transactions prior to stake validation height. Skip
treasurybase and tspend transactions in the orphan test. Ensure a tspend is
in a valid window. Ensure not more than 7 TSpends are active in the mempool.
Ensure TSpend has a well-known Pi key. Ensure The provided Pi key was used to
sign the transaction. Ensure TSpend was not mined in an ancestor block.
Notify subscribers that a valid TSpend was received.
* Add standardCoinbaseOpReturn and standardTreasurybaseOpReturn to create an
OP_RETURN followed by a data push that little endian encodes the height of
the block. Then there are a number of random bytes to ensure that the
transaction hash is always random.
* Modify createCoinbaseTx to create a coinbase that is valid when treasury is
enabled or not. Additionally, alter the transaction version if treasury is
enabled.
* Add createTreasuryBaseTx that creates a standard treasurybase.
* Modify maybeInsertStakeTx to recognize treasurybase and TSpend transactions.
* Modify handleTooFewVoters to call createTreasuryBaseTx when the treasury
agenda is active. Skip copying treasurybase.
* Modify NewBlockTemplate to recognize and deal with treasury transactions.
Skip TSpend transaction if block is not a TVI. Skip TSpend transaction if it
is not in the proper window. Skip TSpend transaction if a TSpend does not
have enough yes votes. Skip TSpend transaction if it overspends the treasury
account. Skip TAdd if there are more than 20 TAdds in the block. Create
treasurybase if required. Insert valid TAdd/TSpend transactions into stake
tree.
* Add TreasuryBalance and IsTreasuryAgendaActive to rpcserver Chain interface.
* Add gettreasurybalance, sendfromtreasury and sendtotreasury calls to RPC
server.
* Add notifytspend and stopnotifytspend to RPC websocket commands.
* Add simnet miner to generate large number of blocks during rpctests without
triggering PoW difficulty increases. This is used to verify various treasury
and tspend conditions during CI/CT.
* Modify RPC voting wallet to also vote on TSpends.
* Add json tests to verify all new opcodes and corner cases in the script
engine.
* Modify isStakeOpcode to recognize treasury opcodes.
* Modify countSigOpsV0 to count TSpends.
* Modify handleStakeOutSign to deal with TSpends.
* Modify SignTxOutput to recognize TSpends.
* Add TSpendSignatureScript that signs a TSpend transaction.
* Add TreasuryAddTy and TreasurySpendTy types to the standard scripts.
* Add isTreasuryAddScript and isTreasurySpendScript functions that recognize
a form of TAdd and TSpend transactions.
* Modify ExtractPkScriptAddrs to deal with TAdd and TSpend outputs.
* Add TxVersionSeqLock = 2 and TxVersionTreasury = 3 to wire. This is
used to discriminate between treasury and non-treasury scripts.
* Rig up all functions that need the isTreasuryEnabledflag directly or
indirectly.
* Shuffle various functions around and export them when they were needed to be
called from other packages.
* Added and modified numerous tests to verify (hopefully) all corner cases that
the decentralized treasury agenda has added.
This consolidates the logic for handling the disable banning flag as
well as whitelisted peers into the BanPeer function on the server and
updates all of the direct banning from the callbacks accordingly.
This consolidation will help prevent the possibility of banning without
properly checking those flags.
This modifies the code that was fairly recently added to ban peers
sending messages that do not conform to the wire protocol to only apply
when they are not whitelisted.
This updates the rebroadcastmissed and rebroadcastwinners entries to be
properly categorized under the Websocket Methods section and updates
them to properly call out the associated notifications they generate.
This moves the rebroadcastmissed and rebroadcastwinners commands from
the regular chain server file to the websocket chain server file so they
are only registered as available to websocket clients.
This allows simnet nodes to run with --rejectnonstd and still receive
votes and advance the network past SVH.
Previously the simnet used a non-push-only signature script, so this
conflicted with the --rejectnonstd mempool policy.
This modifies the error return from generate command when mining is
already in progress to properly differentiate between the discrete mining
and CPU mining cases.
This modifies the sampleconfig package to contain a single function
named FileContents instead of a constant.
This is being done because changing a constant is technically a major
semver breaking change while changing the contents returned by a
function is not and the goal is to ultimately make the root module
semver compliant.
This ensures that all code in the main package of root module is not
exported since none of it should be accessed outside of the main package
itself.
While here, it also updates the NAT discover func to avoid using named
variables which ensures error are not shadowed and eaten.
This removes a few rpcadaptors that are unnecessary since the underlying
types that server provides satisfies those interfaces themselves. It
also restructures how nil interfaces are passed to rpcserver.Config to
be more straightforward and a bit less code.
This adds a TxIndexer interface to rpcserver, which decouples rpcserver
from the implementation of the transaction index and allows a mocked
version to be provided for testing.
This adds an AddrIndexer interface to rpcserver, which decouples
rpcserver from the implementation of the address index and allows a
mocked version to be provided for testing.
This adds a function to the common test infrastructure to remove
deployments for a given vote ID from parameters for use in testing cases
where it is useful to ensure behavior is correct on networks for which
an agenda is already active before heights that are not possible to hit
when the agenda has to be voted in.
Note that it is intentionally unused at this point, but future commits
will make use of it.
This imposes a limit on the response size from the http seeder such that
each returned entry is allowed to have max size of 256 bytes. Since
there is also a limit of 16 entries per response, it amounts to a max
overall response size of 4KiB.