Commit Graph

17602 Commits

Author SHA1 Message Date
Greg Pfeil d0522df5c0
Many z_mergetoaddress updates
- add ZIP 317 support
- address review comments
- restructure `AsyncRPCOperation_mergetoaddress` (removing the just-added
  `prepare`)
2023-04-20 01:24:39 -06:00
Greg Pfeil 94f5bfc595
Update z_mergetoaddress to use WalletTxBuilder
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
Co-authored-by: Jack Grigg <jack@z.cash>
2023-04-19 22:26:42 -06:00
str4d 250a3f049b
Merge pull request #6403 from daira/zip317-blocktemplate
Implement ZIP 317 block construction algorithm
2023-04-20 02:23:59 +01:00
Kris Nuttycombe f0e0c281ad
Merge pull request #6585 from str4d/update-deps-5.5.0 2023-04-19 18:18:43 -06:00
Daira Emma Hopwood 11dc0d7277 Add a `-blockunpaidactionlimit` config option to configure the per-block
limit on unpaid actions for ZIP 317 block template construction.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-20 00:48:38 +01:00
Daira Emma Hopwood c1930170d2 Remove the implementation of score-based block template construction
and the `-blockminsize` option.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-19 22:48:46 +01:00
Daira Emma Hopwood 783bd52556 mergetoaddress_helper.py: use Decimal for amounts and integers otherwise.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-19 22:48:46 +01:00
Daira Emma Hopwood 7c956ffab6 mergetoaddress_helper.py: Use `generate_and_check` helper to mine a block
and make sure that it contains the expected number of transactions.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-19 22:48:46 +01:00
Daira Emma Hopwood eb74c8e8b0 Repair some RPC tests.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-19 22:48:46 +01:00
Daira Emma Hopwood 3b255b8941 Repair `miner_tests.py` btest.
The previous code did not mine enough blocks to have sufficient matured
funds for the tests it needed to perform, taking into account the slow
start. So, we now mine 200 instead of 110 blocks.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-19 22:48:46 +01:00
Daira Emma Hopwood 9af901e1a9 Add assertions that `GetRandInt*` functions are called with `nMax >= 0`.
All existing uses have been checked to ensure they are consistent with
this assertion.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-19 22:48:46 +01:00
Daira Emma Hopwood 75030610f2 ZIP 317 block construction algorithm.
This breaks tests which are repaired in subsequent commits.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-19 22:48:46 +01:00
Jack Grigg 8f848e8ef3 cargo update 2023-04-19 20:06:12 +00:00
Daira Emma Hopwood c111bff3d7 Implement `GetUnpaidActionCount` and `GetWeightRatio` for ZIP 317.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-19 20:04:51 +01:00
Jack Grigg fde211c7f6 qa: Postpone Clang 16.0.2 2023-04-19 18:50:01 +00:00
Jack Grigg 787d840841 depends: Boost 1.82.0 2023-04-19 18:44:53 +00:00
str4d 6cb4c9e144
Merge pull request #6576 from sellout/wallet_tx_builder-net-payments
WalletTxBuilder support for net payments
2023-04-19 10:24:00 +01:00
Greg Pfeil e3b1802637
Don’t test “Insufficient funds” for `z_shieldcoinbase`
I don’t think it’s possible for this error condition to be tested for `z_shieldcoinbase` any more

1. to hit this failure, we need a fee higher than the amount available in coinbase UTXOs;
2. if there are no UTXOs to shield, we fail before reaching an “insufficient funds” check;
3. coinbase UTXOs are >1 ZEC, which is the highest we can set `-maxtxfee` to without emitting a
   warning;
4. emitting a warning causes the test to fail.
2023-04-18 19:39:47 -06:00
str4d 63b644b20f
Merge pull request #6578 from sellout/maxtxfee-bounds
Restore previous `-maxtxfee` bound
2023-04-19 00:12:08 +01:00
Greg Pfeil 1100829d99
fixup! WalletTxBuilder support for net payments
This just rearranges functions so they’re defined before they’re called.
2023-04-18 15:57:13 -06:00
Greg Pfeil f655f482ab
WalletTxBuilder support for net payments
Previously, `WalletTxBuilder` expected a vector of payments with known amounts.
This meant that operations like `z_shieldcoinbase` and `z_mergetoaddress` needed
to pre-calculate the amount to be sent to the target address.

With ZIP 317 fees, this became harder to do. Now `WalletTxBuilder` accepts
either a vector of payments or a single address (and optional memo) for the net
amount to be paid to.

This also converts `z_shieldcoinbase` to use this approach. `z_mergetoaddress`
conversion is blocked by #6569.
2023-04-18 15:55:21 -06:00
Greg Pfeil 9820a6399b
Correct -maxtxfee lower bound diagnostic messages
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
Co-authored-by: str4d <thestr4d@gmail.com>
2023-04-18 15:00:27 -06:00
Greg Pfeil 23a680a05f
Restore previous `-maxtxfee` bound
And warn on the new bound.

Fixes #6577.
2023-04-18 13:55:35 -06:00
str4d f512291ff2
Merge pull request #6555 from sellout/zip-317-legacy-wallet
Support ZIP 317 fees for legacy wallet operations
2023-04-18 20:44:46 +01:00
Kris Nuttycombe 65e90a7964
Merge pull request #6574 from str4d/fix-mempool_packages-nondeterminism
Fix `mempool_packages` nondeterminism
2023-04-18 13:24:57 -06:00
Kris Nuttycombe 0a47f1c148 Use the conventional fee for prioritisation in prioritisetransactions.py
Co-authored-by: Greg Pfeil <greg@technomadic.org>
2023-04-18 12:37:04 -06:00
Jack Grigg b3e40d8548 test: Sync blocks before invalidating them in `mempool_packages` RPC test
This avoids a race condition where node 1 attempts to fetch the block
while it is considered invalid by node 0, which eventually leads to the
nodes becoming disconnected, preventing the test from advancing.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-04-18 18:24:15 +00:00
Jack Grigg 8342e350b1 test: Avoid generating a chain fork in `mempool_packages` RPC test
There was a race condition here between the block generated by node 0
being broadcast to node 1, and being invalidated by node 0. Due to the
changes we made to the difficulty adjustment algorithm, the invalidated
block and the block replacing it generated by node 0 would have the same
chain work; thus if node 1 observed the invalidated block, it would
never reorg to the replacement block.

We fix this by having node 0 reconsider the invalidated block before
generating its next block. This avoids the chain fork, and also clears
the mempool to provide better separation between test stages.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-04-18 17:00:54 +00:00
Kris Nuttycombe f177deaa37 Fix formating of money strings. 2023-04-18 07:51:17 -06:00
Kris Nuttycombe e566955acb Calculate convential fee in `CreateTransaction` before stripping sigs. 2023-04-18 07:51:17 -06:00
Greg Pfeil bf68d69439 Remove `-txconfirmtarget` config option 2023-04-18 07:51:17 -06:00
Greg Pfeil 3f9714aa9d Address review comments re: legacy wallet ZIP 317 2023-04-18 07:51:17 -06:00
Greg Pfeil 59b98d8290 Remove `-mintxfee` config option 2023-04-18 07:51:16 -06:00
Greg Pfeil b67c5852a4 Support ZIP 317 fees for legacy wallet operations
This also handles fee bounds (minRelayFee, maxTxFee) in WalletTxBuilder.

Fixes #6553.
2023-04-18 07:51:16 -06:00
Kris Nuttycombe 786d8e32e1
Merge pull request #6572 from sellout/wallet_tx_builder-z_shieldcoinbase
Minor improvements to z_shieldcoinbase
2023-04-17 21:28:07 -06:00
Greg Pfeil 0ce621a8e6
Minor improvements to z_shieldcoinbase
Some formatting, and use of a constant that didn’t make it into #6568.
2023-04-17 15:11:10 -06:00
Kris Nuttycombe facb4856ee
Merge pull request #6568 from sellout/wallet_tx_builder-z_shieldcoinbase
Have z_shieldcoinbase use WalletTxBuilder
2023-04-17 15:08:55 -06:00
Kris Nuttycombe 35953b5cee
Merge pull request #6542 from daira/remove-priority-and-free-txns
Remove priority and "free" transactions
2023-04-17 14:37:48 -06:00
Greg Pfeil 1ba0843845
Fix an incorrect error message in a test 2023-04-17 13:51:43 -06:00
Luke Dashjr dd4fdf77d0 RPC/Mining: Restore API compatibility for prioritisetransaction
Breaking API serves no purpose other than to be incompatible with older versions and other implementations that do support priority

(cherry picked from commit bitcoin/bitcoin@870824e919)

Zcash:
* Update the release notes.
* Update the `prioritisetransaction.py` RPC test.
* We don't have BIP 68 or replace-by-fee.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00
Daira Emma Hopwood 54fe279ef8 Fix mempool_packages and prioritisetransaction RPC tests.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00
Daira Emma Hopwood 0acbbfe609 Fix miner_tests btest.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00
Daira Emma Hopwood ea9fa3f06e Fix tests that failed due to the minimum relay fee being enforced.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00
Daira Emma Hopwood d20a52faaa Fix some messages, comments, and documentation that:
* used "fee" to mean "fee rate", "kB" to mean 1000 bytes, "satoshis"
  to mean zatoshis, or that incorrectly used "BTC" in place of "ZEC";
* used obsolete concepts such as "zero fee" or "free transaction"; or
* did not accurately document their applicability.

Uses of "satoshis" as a JSON key are not altered.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00
Alex Morcos 59d809cf53 Update example zcash.conf
(cherry picked from commit bitcoin/bitcoin@b421e6ddcf)

Zcash: DEFAULT_TX_CONFIRM_TARGET is 2.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00
Daira Emma Hopwood e2f99f5133 Fix the dust threshold rate to three times 100 zats/1000 bytes.
(We express it that way rather than 300 zats/1000 bytes, because the
threshold is always rounded to an integer and then multiplied by 3.)

Bitcoin Core added the concept of "dust" in bitcoin/bitcoin#2577.
At that point the dust threshold was tied to three times the
minRelayTxFee rate, with the motivation that if you'd pay more than
a third of the minimum relay fee to spend something, it should be
considered dust. This was implemented as a standard rule rejecting
dust outputs.

This motivation will not apply after ZIP 317 block construction
is implemented: at that point the ZIP 317 marginal fee will be
5000 zats per logical action, but the dust threshold rate will
still be three times 100 zats per 1000 bytes. Those costs would
only coincide if the marginal size per logical action were
5000/300 * 1000 ~= 16667 bytes, and in practice the marginal size
for any kind of input is much smaller than that.

However, to avoid interoperability problems (older wallets creating
transactions that newer nodes will reject because they view the
outputs as dust), we will have to coordinate any increase in the
dust threshold carefully.

More history: in Zcash the minRelayTxFee rate was 5000 zats/1000 bytes
at launch, changed to 1000 zats/1000 bytes in zcashd v1.0.3 and to
100 zats/1000 bytes in zcashd v1.0.7-1 (#2141). The relaying problem
for shielded transactions (#1969) that prompted the latter change was
fixed more thoroughly by the addition of `CFeeRate::GetFeeForRelay`
in #4916, ensuring that a transaction paying `DEFAULT_FEE` can always
be relayed. At the same time the default fee was set to 1000 zats,
per ZIP 313.

An earlier commit in this PR changed relaying policy to be more strict
about enforcing minRelayTxFee. The commit just before this one also
allowed `-minrelaytxfee=0`, which we are going to use to avoid some test
breakage. But if the dust threshold rate were still set to three times
the minRelayTxFee rate, then setting `-minrelaytxfee=0` would have the
side effect of setting the dust threshold to zero, which is not intended.

Bitcoin Core took a different approach to disentangling the dust
threshold from the relay threshold, adding a `-dustrelayfee` option
(bitcoin/bitcoin#9380). We don't want to do that because it is likely
that we will change the dust policy again, and adding a user-visible
config option might conflict with that. Also, it isn't a good idea for
the dust threshold rate to be configurable per node; it's a standard
rule parameter and should only be changed with network-wide coordination
(if it is increased then wallets have to change before nodes, and vice
versa if it is decreased). So for now we set it to a constant that
matches the behaviour before this PR.

Since we can no longer modify the dust threshold, we remove a check
from transaction_tests.cpp that relied on doing so.

This change also indirectly fixes a false-positive assertion error that
would occur in `SpendableInputs::LimitToAmount` if we allowed the dust
threshold to be zero.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00
Alex Morcos 5e87cb480f Allow setting minrelaytxfee to 0
Setting minrelaytxfee to 0 will allow all transactions regardless of fee to enter your mempool until it reaches its size limit.

(cherry picked from commit bitcoin/bitcoin@7d4e9509ad)

Zcash: Removed the following misleading sentence from the upstream
commit message:

> However now that mempool limiting is governed by a separate
> incrementalrelay fee, it is an unnecessary restriction to prevent
> a minrelaytxfee of 0.

We do not have `-incrementalrelayfee`, which was added upstream in
bitcoin/bitcoin#9380 . Still, it was pointless to prevent
`-minrelaytxfee=0`, because we did not prevent `-minrelaytxfee=1`
or other low values, which would be similarly ineffective.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00
Alex Morcos 1d866c85d8 [cleanup] Remove coin age priority completely.
Remove GetPriority and ComputePriority.  Remove internal machinery for tracking priority in CTxMemPoolEntry.

(cherry picked from commit bitcoin/bitcoin@359e8a03d1)

Zcash:
* We don't have `src/bench/mempool_eviction.cpp`.
* We don't have `-walletrejectlongchains`.
* Now we can remove `MAX_PRIORITY`.
* Fix a comment in `coins.h` while we're changing code next to it.
* Update the `Mempool/PriorityStatsDoNotCrash` regression test.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00
Alex Morcos c42be7ca10 [rpc] Remove priorityDelta from prioritisetransaction
This a breaking API change to the prioritisetransaction RPC call which previously required exactly three arguments and now requires exactly two (hash and feeDelta).  The function prioritiseTransaction is also updated.

(cherry picked from commit bitcoin/bitcoin@f9b9371c60)

Zcash: We don't have `LoadMempool` or `DumpMempool`.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00
Alex Morcos 1cf62dbcc6 [rpc] Remove priority information from mempool RPC calls
"startingpriority" and "currentpriority" are no longer returned in the JSON information about a mempool entry.  This affects getmempoolancestors, getmempooldescendants, getmempooolentry, and getrawmempool.

(cherry picked from commit bitcoin/bitcoin@49be7e1bef)

Zcash:
* Adjusted because we don't have bitcoin/bitcoin@5ec0cde371
* Update Zcash-specific tests.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00