Commit Graph

8482 Commits

Author SHA1 Message Date
Jorge Timón a68c8114e1
Globals: Explicitly pass const CChainParams& to UpdateTip() 2019-05-23 17:48:21 +01:00
MarcoFalke 98f3010026
[doc] Fix doxygen comments for members 2019-05-23 17:48:20 +01:00
Peter Todd 9b0f61af2d
Improve block validity/ConnectBlock() comments
Previously didn't make clear that the ContextualCheckBlock* functions
meant the block headers as context - not the UTXO set itself - and that
ConnectBlock() also did UTXO-related validity checks (in the future we
may split that functionality into a separate UTXO-specific contextual
check block function).

Also, reordered to put validity checks first for better readability.
2019-05-23 17:48:19 +01:00
Jorge Timón 44b2d060ef
Globals: Remove a bunch of Params() calls from main.cpp:
1) Chainparams: Explicit CChainParams arg for main:

-AcceptBlock
-AcceptBlockHeader
-ActivateBestChain
-ConnectTip
-InitBlockIndex
-LoadExternalBlockFile
-VerifyDB parametric constructor

2) Also pickup more Params()\. in main.cpp

3) Pass nPruneAfterHeight explicitly to new FindFilesToPrune() in main.cpp
2019-05-23 17:48:18 +01:00
Jorge Timón 793a72e31f
Chainparams: Explicit CChainParams arg for miner:
-BitcoinMiner
-CreateNewBlock
-GenerateBitcoins
-ProcessBlockFound
2019-05-23 17:48:17 +01:00
Jorge Timón 8e5d8ca52a
Chainparams: Explicit CChainParams arg for main (pre miner):
-ProcessNewBlock
-TestBlockValidity
2019-05-23 17:48:16 +01:00
Jorge Timón 94debefbcf
Globals: Make AcceptBlockHeader static (Fix #6163)
..and at the same time prevent AcceptBlockHeader() from calling global function Params()
2019-05-23 17:48:15 +01:00
Jorge Timón 71cf6ba98b
Globals: Explicit Consensus::Params arg for main:
-CheckBlockIndex
-DisconnectTip
-GetTransaction
-InvalidateBlock
-ProcessGetData
-ReadBlockFromDisk
2019-05-23 17:48:14 +01:00
Jack Grigg cea06a4fd3
Move Equihash parameters into consensus params 2019-05-23 17:48:13 +01:00
Daniel Kraft 9a529fd217
Add some const declarations where they are appropriate.
Declare some arguments of functions as "const" pointers where they are
not meant to be modified.
2019-05-23 17:48:04 +01:00
Eirik0 a630f50349 Replace CSproutNotePlaintextEntry with SproutNoteEntry to match Sapling 2019-05-23 09:24:46 -06:00
Homu de68430af6 Auto merge of #4008 - Eirik0:3971-fix-comment, r=Eirik0
Fix tree depth in comment

Closes #3971
2019-05-16 14:00:33 -07:00
Simon 831611edd3 Fix typo and clean up help message for RPC z_getmigrationstatus. 2019-05-15 11:06:37 -07:00
Eirik0 c34d253fa6 make-release.py: Versioning changes for 2.0.5-2. 2019-05-15 09:49:44 -06:00
Eirik0 23d9826ef9 Fix LogPrint statements 2019-05-10 17:25:30 -06:00
Eirik0 58348c79b3 Add logging for Sprout to Sapling migration transaction generation 2019-05-10 17:22:08 -06:00
Eirik0 7470ae8885 Do not automatically remove async migration operations and return txids 2019-05-10 17:19:56 -06:00
Eirik0 a84125aacd Fix tree depth in comment 2019-05-10 12:58:11 -06:00
Eirik0 0e06801e12 Move reused sign and send logic 2019-05-10 12:45:14 -06:00
Eirik0 a7a52d2424 Move reused async rpc send logic to separate file 2019-05-10 12:20:52 -06:00
Eirik0 3220d99360 Use CommitTransaction() rather than sendrawtransaction() 2019-05-10 11:44:40 -06:00
Daira Hopwood 9615caa8f9 Fix cosmetic spacing issue in z_setmigration help.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2019-05-10 16:08:03 +01:00
Daira Hopwood 14c0be6f27 Change expiry delta for migration transactions to 450 blocks.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2019-05-10 13:48:43 +01:00
Daira Hopwood 9cd34fc10a Repair calls to TransactionBuilder from tests.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2019-05-10 13:48:43 +01:00
Daira Hopwood 5eb7129d95 Generalize TransactionBuilder and CreateNewContextualCMutableTransaction to allow choosing the expiry delta.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2019-05-10 13:48:43 +01:00
Homu e97621acf7 Auto merge of #3995 - bitcartel:no_migration_during_block_download_phase, r=Eirik0
Don't allow Sprout-to-Sapling migration when syncing during IBD or after wake from sleep.

Prevent migration transactions from being created in response to incoming blocks when a node launches and syncs (the initial block download phase) and when a node wakes from sleep/hibernation and starts syncing old blocks rapidly.
2019-05-09 13:51:49 -07:00
Simon 6921c81b9d Don't allow migration when node is syncing at launch or after waking up. 2019-05-09 09:32:09 -07:00
Simon bda85eb06a Remove unused specifier from format string.
The extra specifier meant that a runtime error would be thrown
during Sprout to Sapling migration if `zrpcunsafe` logging
was enabled:
"tinyformat: Too many conversion specifiers in format string"
2019-05-08 20:51:13 -07:00
Eirik0 f809ff997f make-release.py: Versioning changes for 2.0.5-1. 2019-05-08 06:50:57 -06:00
Eirik0 ea8823ce51 coinsView is required when using TransactionBuilder if there may be Sprout change 2019-05-07 18:41:35 -06:00
Eirik0 5fd7af5f85 Add the amount migrated to the operation's result 2019-05-07 08:58:23 -06:00
Eirik0 f0f7b3f012 Fix summing available funds 2019-05-07 08:55:26 -06:00
Eirik0 94e419f95d Rename variable and add comment 2019-05-06 11:46:16 -06:00
Eirik0 d48c3efca7 Store the migration operation id rather than the operation iteslf 2019-05-06 09:57:40 -06:00
Eirik0 7cf4749d0d Correctly account for migration transactions in the mempool
Co-authored-by: LarryRuane <larry@z.cash>
2019-05-05 12:59:43 -06:00
Eirik0 c1daa11d7b make-release.py: Versioning changes for 2.0.5. 2019-05-03 16:30:13 -06:00
Simon 68c17ffec8 Update chain work and checkpoint using block 525000. 2019-05-02 14:53:35 -07:00
Eirik0 6c47e6fe7b make-release.py: Versioning changes for 2.0.5-rc1. 2019-05-01 14:15:14 -06:00
Homu d894f7b3b2 Auto merge of #3977 - LarryRuane:3873-setmigration-cli, r=bitcartel
3873 z_setmigration cli bool enable arg conversion

Addresses #3873.
2019-05-01 09:26:20 -07:00
Larry Ruane 4cbe0a9d02 3873 z_setmigration cli bool enable arg conversion 2019-05-01 10:03:24 -06:00
Eirik0 3cad5f454f Do not throw an exception if HD Seed is not found when exporting wallet 2019-04-30 15:47:03 -06:00
Eirik0 e14cf96642 Calculate the number of confimations in the canonical way 2019-04-30 11:06:08 -06:00
Eirik0 345177cfc1 Do not look at vin/vout when determining migration txs and other cleanup 2019-04-30 09:52:53 -06:00
Eirik0 e9530f40f2 use -valueBalance rather than vpub_new to calculate migrated amount 2019-04-29 17:00:26 -06:00
Eirik0 108e587c14 Fix typos and update documentation 2019-04-29 15:29:29 -06:00
Eirik0 5969bd8f55 Fix help message 2019-04-29 15:29:27 -06:00
Eirik0 6e82d72852 Add rpc to get Sprout to Sapling migration status 2019-04-29 15:28:35 -06:00
Eirik0 52cfa9c1ee Create method for getting HD seed in RPCs 2019-04-29 15:28:35 -06:00
Homu f283f2460e Auto merge of #3967 - Eirik0:3961-migration-address, r=Eirik0
3961 migration address

Closes #3961
2019-04-29 11:41:47 -07:00
Homu 63fff636d7 Auto merge of #3968 - bitcartel:3768_enable_mainnet_turnstile, r=bitcartel
Activate turnstile on mainnet

This PR enables [ZIP209](https://github.com/zcash/zips/blob/master/zip-0209.rst) support on mainnet, to mark blocks as invalid if they would lead to a turnstile violation in the Sprout or Sapling value pools.

To test this PR, I performed the following manual tests:

1. Used RPC call `getblock` to verify the fallback Sprout value.
2. Individually changed the fallback Sprout block hash, block height and chain value, recompiling and relaunching the node, verifying that each individual change resulted in an error.  When the block hash and block height are incorrect, an error is logged to debug.log `FallbackSproutValuePoolBalance(): fallback block hash is incorrect`.  An incorrect chain value results in node termination with error: `void FallbackSproutValuePoolBalance(CBlockIndex*, const CChainParams&): Assertion '*pindex->nChainSproutValue == chainparams.SproutValuePoolCheckpointBalance()' failed.`
3. Ran the `Smoke Testing` described in PR #3885, on mainnet.
4. Launched zcashd with experimental feature `-developersetpoolsizezero` to manually trigger a turnstile violation in both Sprout and Sapling shielded pools.  The Sprout turnstile violation occurred after launch, due to chance, when the next incoming block 520786 contained a Sprout unshielding transaction. The Sapling turnstile violation was triggered after creating a Sapling unshielding transaction.
2019-04-29 09:08:46 -07:00
str4d b9c7f274a4
remove extra hyphen
Co-Authored-By: Eirik0 <eirik@z.cash>
2019-04-29 09:55:07 -06:00
Eirik0 8ffd63af2d Add migration options to conf file
Co-authored-by: Simon <simon@bitcartel.com>
2019-04-29 09:36:26 -06:00
Homu 20821614a8 Auto merge of #3888 - Eirik0:3873-sapling-migration, r=Eirik0
Sapling migration RPC

Closes #3873
2019-04-27 12:29:29 -07:00
Larry Ruane 7fb8088288 add -timestampindex for bitcore insight block explorer 2019-04-26 08:44:56 -06:00
Homu 1b24243392 Auto merge of #3849 - LarryRuane:3708-spentindex, r=daira
add SpentIndex changes needed for bitcore block explorer

Addresses #3708, follow-on to #3837, note there are no tests yet (will come later with RPC interfaces).
2019-04-25 16:32:22 -07:00
Homu 1fefed9eb5 Auto merge of #3940 - str4d:3607-init-encrypted-wallet-without-hd-seed, r=bitcartel
init: Fix new HD seed generation for previously-encrypted wallets

Closes #3607.

How to verify (with `zcashd` flags `-testnet -wallet=wallet.3607.dat -experimentalfeatures -developerencryptwallet`):
- Start `zcashd` 2.0.0, encrypt the wallet, and stop the node.
- Start `zcashd` 2.0.1+ (before this branch), and see that it crashes during startup.
- Start `zcashd` built from this branch, and see that it does not crash during startup. Unlock the wallet, then stop.
- Start `zcashd` 2.0.1+ (before this branch), and see that it no longer crashes during startup.
2019-04-25 13:15:51 -07:00
Eirik0 5519d16997 Set min depth when selecting notes to migrate 2019-04-25 13:43:23 -06:00
Eirik0 7c4ad6e298 Additional locking and race condition prevention 2019-04-24 11:31:14 -06:00
Eirik0 699288b4b4 Documentation cleanup 2019-04-24 11:31:14 -06:00
Eirik0 162bfc3a1e Move migration logic to ChainTip 2019-04-24 11:31:14 -06:00
Eirik0 81a45d6984 Add rpc to enable and disable Sprout to Sapling migration 2019-04-24 11:31:14 -06:00
Simon 867786d777 Enable experimental feature -developersetpoolsizezero on mainnet. 2019-04-24 08:40:17 -07:00
Simon fc79a848fb Enable ZIP209 on mainnet and set fallback Sprout pool balance. 2019-04-23 22:57:30 -07:00
Homu e1c922de5b Auto merge of #3964 - bitcartel:test_turnstile_violation, r=bitcartel
Test turnstile violation

Adds experimental feature -developersetpoolsizezero to enable developers to test Sprout and Sapling turnstile violations on testnet and in regtest mode.
2019-04-23 15:07:43 -07:00
Larry Ruane 3d018ab556 add -spentindex changes for bitcore insight block explorer 2019-04-23 11:06:23 -06:00
Homu ab856294d9 Auto merge of #3505 - str4d:rust-targets, r=str4d
depends: Support additional cross-compilation targets in Rust

This will make it easier for third parties to cross-compile `zcashd` for other platforms. The third commit in this PR shows how to add a new target to the Rust dependency builder.

The default Rust target during cross-compilation is the canonical host, which is derived from `HOST` using `depends/config.sub`. If the canonical host differs from the required Rust target, add the necessary mapping in addition to the target itself.

Also includes fixes for cross-compiling aarch64 targets.
2019-04-23 08:33:40 -07:00
Simon 4c1a8884f4 Add testnet and regtest experimental feature: -developersetpoolsizezero 2019-04-22 14:24:40 -07:00
Gareth Davies 82848efb0e Adding addressindex.h to Makefile.am
Co-authored by: Daira Hopwood <daira@jacaranda.org>
2019-04-21 07:44:18 -07:00
Homu 8752c7aef5 Auto merge of #3935 - str4d:blossom-activation-logic, r=str4d
Add Blossom to upgrade list
2019-04-09 10:39:07 -07:00
Homu 33548140d9 Auto merge of #3907 - LarryRuane:3860-enable-debug-build, r=daira
fix enable-debug build DB_COINS undefined

Fixes #3860. The way `DB_COINS` is defined in this PR is the same as in `src/txdb.cpp` (static "global" instead of class member).
2019-04-09 03:45:07 -07:00
Homu e73326eed0 Auto merge of #3837 - LarryRuane:3708-addressindex, r=bitcartel
add AddressIndex changes needed for bitcore block explorer

Addresses #3708, note there are no tests yet (will come later with RPC interfaces).
2019-04-04 17:36:56 -07:00
Jack Grigg 1f561f323f
init: Fix new HD seed generation for previously-encrypted wallets
Closes #3607.
2019-04-04 18:27:46 +01:00
Homu 926fd0ce28 Auto merge of #3848 - str4d:transaction-builder-sprout, r=Eirik0
Add Sprout support to TransactionBuilder

The logic in `TransactionBuilder::CreateJSDescriptions()` is a combination of the logic used by `z_sendmany`, `z_mergetoaddress` and `z_shieldcoinbase`, in order to support arbitrary numbers of Sprout inputs or outputs.
2019-04-04 10:19:46 -07:00
Jack Grigg 885fce070a
Add Blossom to upgrade list 2019-04-02 07:39:36 +01:00
Braydon Fuller ec81c70964 tests: adds unit test for IsPayToPublicKeyHash method 2019-03-28 12:04:02 -06:00
Larry Ruane 6cf0e50b56 add -addressindex changes for bitcore insight block explorer 2019-03-28 12:03:48 -06:00
Simon 108dc2df95 make-release.py: Versioning changes for 2.0.4. 2019-03-26 11:25:19 -07:00
Larry Ruane e1df250a0d fix enable-debug build DB_COINS undefined 2019-03-20 16:29:06 -06:00
Simon b95cb71653 make-release.py: Versioning changes for 2.0.4-rc1. 2019-03-20 09:29:06 -07:00
Homu 3c5062aa90 Auto merge of #3898 - sandakersmann:patch-1, r=bitcartel
Update COPYRIGHT_YEAR in clientversion.h to 2019

Update COPYRIGHT_YEAR in clientversion.h to 2019
2019-03-20 07:36:25 -07:00
Homu 6158f0a4fa Auto merge of #3897 - ebfull:wallet-sprout-check-commitment, r=ebfull
Check consistency of note commitment and ciphertext in wallet

Fixes #3896.
2019-03-19 21:21:54 -07:00
Sean Bowe c1009374b1 (wallet) Check that the commitment matches the note plaintext provided by the sender. 2019-03-19 13:12:26 -06:00
Homu 008705d7c1 Auto merge of #3885 - ebfull:turnstile, r=bitcartel
Reject blocks that violate turnstile

This is an implementation of a consensus rule which marks blocks as invalid if they would lead to a turnstile violation in the Sprout or Shielded value pools. The motivations and deployment details can be found in the [accompanying ZIP draft](https://github.com/zcash/zips/pull/210).

**This PR only introduces the rule for testnet at the moment.**

We achieve the institution of this rule in three ways:

1. Nodes prior to #2795 did not record the "delta" in the Sprout value pool balance as part of the on-disk block index. This was a long time ago, though, and all nodes that are consensus-compatible with the network today have been recording this value for newer blocks. However, the value is absent from older block indexes unless the node has reindexed or synchronized from scratch in the time since. We shouldn't need to require nodes to reindex in order to enforce this consensus rule. We avoid this problem by falling back on a hardcoded Sprout shielded value pool balance in a very recent block.
2. If during `ConnectBlock` we observe that the resulting shielded value pool balance of Sprout or Sapling is negative, we reject the block.
3. During the miner's block assembly process the miner will skip over transactions if adding them to the assembled block might violate the turnstile, since the resulting block would be invalid. This means that theoretical transactions violating the turnstile would still be relayed in the network (and made available in users' memory pools) and so a turnstile violation would have some visibility outside of block relay.

## Smoke Testing

It's really tricky to test the behavior that automatically falls back to hardcoded shielded value pool balances in our architecture because it's very testnet-specific and node-version-specific. However, we can do some smoke tests to see that everything is working.

I modified the serialization of `CDiskBlockIndex` to serialize `boost::none` for `nSproutValue`

```
if ((s.GetType() & SER_DISK) && (nVersion >= SPROUT_VALUE_VERSION)) {
    boost::optional<CAmount> nSproutValueFake = boost::none;
    READWRITE(nSproutValueFake);
}
```

and then began a reindex of my node which I interruped around height 130k on testnet. I then restored the original serialization and resumed the reindex; I have thus _roughly_ simulated a older node "upgrading" to a newer node that records the deltas when processing new blocks. My node showed pool monitoring was disabled, as expected, for Sprout. I confirmed that some blocks following the reindex had nonzero Sprout `valueDelta` from `getblock`, as expected. I finished the reindex, restarted the node, and confirmed that the serialization worked for newer blocks but not older blocks by querying `getblock`, simply as a reassurance.

Finally, I introduced the code in this PR and reloaded the node. The desired behavior (that the chain began to be "monitored" again) worked, and the values were consistent with the hardcoded constant. I then made a payment to a Sprout z-addr from the transparent pool and the pool value increased as expected, as reported by `getblockchaininfo`. I reindexed the node again to exercise the remaining logic and check for turnstile violations throughout the history of testnet; there were none.
2019-03-19 12:10:17 -07:00
Eirik0 ee9ff2ce74 Rename and update comment 2019-03-19 12:55:55 -06:00
Sean Bowe 8d0e2befe7 (minor) Remove added newline. 2019-03-19 12:45:21 -06:00
Sean Bowe 4e3dca978b Do not enable ZIP209 on regtest right now. 2019-03-19 12:44:53 -06:00
Marius Kjærstad 3f8e662a89
Update COPYRIGHT_YEAR in clientversion.h to 2019
Update COPYRIGHT_YEAR in clientversion.h to 2019
2019-03-19 17:42:52 +01:00
Sean Bowe 30a5d6f520 Only enforce Sapling turnstile if balance values have been populated. 2019-03-18 14:09:32 -06:00
Sean Bowe b5c7e63bcd Change SproutValuePoolCheckpointEnabled to ZIP209Activated 2019-03-18 11:32:26 -06:00
Sean Bowe 6482b661ab Check blockhash of fallback block for Sprout value pool balance 2019-03-14 15:39:11 -06:00
Sean Bowe ebe2edce9a Add newlines to turntile log messages for miner 2019-03-14 15:25:31 -06:00
Sean Bowe 831725a671 Use existing chainparams variable 2019-03-14 15:25:10 -06:00
Sean Bowe 2b1252af80 Consolidate logic to enable turnstile auditing for testnet/regtest/mainnet. 2019-03-14 14:29:04 -06:00
Sean Bowe cb6df4b0cc Fix tallying for Sprout/Sapling value pools. 2019-03-14 14:08:12 -06:00
Simon ea5f00aa5d Add checkpoint for block 497000. 2019-03-13 17:31:49 -07:00
Simon 16385486b8 Update nMinimumChainWork using block 497000. 2019-03-13 17:24:43 -07:00
Sean Bowe bf4de896e7 (testnet/regtest) Avoid mining transactions that would violate the turnstile. 2019-03-13 01:38:34 -06:00
Jack Grigg 98cfe4228c
configure: Guess -march for libsnark OPTFLAGS instead of hard-coding
When cross-compiling, this will remove the -march flag entirely unless
the user specifies CONFIGURE_FLAGS="--with-gcc-arch=<arch>".
2019-03-13 07:37:56 +00:00
Sean Bowe 8a990a7d64 (testnet) Reject blocks that result in turnstile violations 2019-03-13 00:54:29 -06:00
Sean Bowe 24db3297df (testnet) Fall back to hardcoded shielded pool balance to avoid reorgs. 2019-03-13 00:43:54 -06:00
Jack Grigg 1fee15028f
Move payment disclosure code and tests into wallet
The code was already compiled as part of the wallet, but the tests were
not, meaning that the tests would fail to compile when the wallet was
disabled.
2019-03-06 10:04:23 +13:00
Jack Grigg c7fc78987a
Move utiltest.cpp from wallet to common
This ensures it is accessible by the test suite when the wallet is
disabled.
2019-03-06 09:41:39 +13:00
Jack Grigg c233f6fd31
Add comments 2019-03-06 09:03:55 +13:00
Jonas Schnelli 648d6bee65
miner: rename UpdateRequestCount signal to ResetRequestCount 2019-03-06 09:02:50 +13:00
Jonas Schnelli f4055fe158
add CReserveScript to allow modular script keeping/returning
- use one CReserveScript per mining thread
2019-03-06 09:02:50 +13:00
Jonas Schnelli 38da0d16b1
fix GetScriptForMining() CReserveKey::keepKey() issue 2019-03-06 09:02:50 +13:00
Jonas Schnelli b2993bc5d4
detach wallet from miner 2019-03-06 09:02:50 +13:00
Eirik0 6281cc32b7 Use a custom error type if creating joinsplit descriptions fails 2019-02-28 11:29:14 -07:00
Eirik0 9e8729113c Split test in to multiple parts 2019-02-26 15:09:55 -07:00
Jack Grigg cb51e03587 Add Sprout support to TransactionBuilder 2019-02-26 13:36:50 -07:00
Homu 92cd76fcba Auto merge of #3859 - LarryRuane:3708-patched-explorer, r=mdr0id
Simplify DisconnectBlock arguments/return value

DisconnectBlock currently has a complicated interface:

  Situation       Return value
                  pfClean != nullptr   pfClean == nullptr

  All good:       true                 true
  Failure:        false                false
  Unclean rewind: true                 false
                  with *pfClean=false

Change this to return a tristate enum instead. As an added bonus,
remove the ValidationState& argument which was unused.
2019-02-26 10:50:59 -08:00
Pieter Wuille ec555a8e9b Simplify DisconnectBlock arguments/return value
DisconnectBlock currently has a complicated interface:

  Situation       Return value
                  pfClean != nullptr   pfClean == nullptr

  All good:       true                 true
  Failure:        false                false
  Unclean rewind: true                 false
                  with *pfClean=false

Change this to return a tristate enum instead. As an added bonus,
remove the ValidationState& argument which was unused.
2019-02-26 11:10:20 -07:00
Homu 52fbc1ce66 Auto merge of #3657 - Eirik0:3395-sapling-benchmarks, r=str4d
Update zcbenchmarks to include sapling data

Closes #3395

This PR adds a benchmark named `trydecryptsaplingnotes` which is intended to be similar to `trydecryptnotes`. It also adds a benchmark `incnotewitnessessapling` which is similar to `incnotewitnesses`.

As a side note, while looking for examples to follow I ran in to a fair amount of setup, which I wanted to be able to reuse, repeated across several tests. I pulled some of that logic in to a utility functions and refactored the existing tests using that setup.
2019-02-26 09:05:35 -08:00
Homu 48b7dea5a8 Auto merge of #3639 - leto:size_on_disk, r=bitcartel
Port getblockchaininfo.size_on_disk from BTC master

Closes #3630.
2019-02-25 10:08:44 -08:00
Homu e45154f559 Auto merge of #3817 - Eirik0:3646-better-error-msgs, r=mdr0id
Improve some error messages when building a transaction fails

Follow up from #3646
2019-02-19 10:09:43 -08:00
mdr0id 81fbf49883 make-release.py: Versioning changes for 2.0.3. 2019-02-11 09:05:39 -08:00
mdr0id fe0507761a Update nMinimumChainWork with information from the getblockchaininfo RPC 2019-02-11 09:04:13 -08:00
mdr0id 626874390a make-release.py: Versioning changes for 2.0.3-rc1. 2019-02-04 11:51:52 -08:00
Eirik Ogilvie-Wigley caa1203307 Improve some error messages when building a transaction fails 2019-01-30 04:12:15 -07:00
Eirik Ogilvie-Wigley 8a1d19307b Renaming and other minor cleanup 2019-01-29 21:18:10 -07:00
Eirik Ogilvie-Wigley 3e5cc59c2e Change to t->z transaction and create separate benchmark for sapling 2019-01-23 15:04:48 -07:00
Eirik Ogilvie-Wigley 275bd8f67a Add a method for generating a test CKey 2019-01-23 15:04:45 -07:00
Eirik Ogilvie-Wigley 010481c7e5 FakeCoinsViewDB can inherit directly from CCoinsView 2019-01-23 14:45:37 -07:00
Eirik Ogilvie-Wigley a6a17c45b8 benchmarks do not require updating network parameters 2019-01-23 14:45:37 -07:00
Eirik Ogilvie-Wigley b27ac486e4 Prevent header from being included multiple times 2019-01-23 14:45:37 -07:00
Eirik Ogilvie-Wigley edac39b8fd Include Sapling transactions in increment note witness benchmark 2019-01-23 14:45:37 -07:00
Eirik Ogilvie-Wigley 1534671fb0 Add test method for generating master Sapling extended spending keys 2019-01-23 14:45:37 -07:00
Eirik Ogilvie-Wigley 9eadcb3eca Move test SaplingNote creation to utiltest 2019-01-23 14:45:37 -07:00
Eirik Ogilvie-Wigley c3e2de5959 Move reusable Sapling test setup to utiltest 2019-01-23 14:12:02 -07:00
Eirik Ogilvie-Wigley 89e75c8c0d Add benchmark for decrypting sapling notes 2019-01-23 14:12:02 -07:00
Eirik Ogilvie-Wigley 8f41036701 Rename methods to include Sprout 2019-01-23 14:12:02 -07:00
Homu bf8ba762d6 Auto merge of #3737 - gtank:zmq_checkedblock, r=str4d
zmq: add flag to publish all checked blocks

This change adds a hook for the BlockChecked signal to the zmq publisher. This is useful for light wallet daemon initialization (see https://github.com/zcash/zcash/issues/3638 for context, and [lightwalletd](https://github.com/zcash-hackworks/lightwalletd) for implementation).

The new flag is `-zmqpubcheckedblock=address`, in keeping with the established style.
2019-01-23 12:53:51 -08:00
Homu 5862b2921b Auto merge of #3646 - Eirik0:transaction-builder-result, r=daira
Return more information when building a transaction fails

This PR is intended to make it easier to diagnose what went wrong when building a transaction using `TransactionBuilder` fails.
2019-01-22 10:14:27 -08:00
Homu 08dc0904fb Auto merge of #3711 - str4d:wallet-atomic-write-optimisation, r=Eirik0
wallet: Skip transactions with no shielded data in CWallet::SetBestChain()

Co-authored-by: Daira Hopwood <daira@jacaranda.org>

Closes #3495.
2019-01-21 13:16:00 -08:00
Eirik Ogilvie-Wigley c297558169 throw an exception rather than returning false when building invalid transactions 2019-01-17 15:19:13 -07:00
Eirik Ogilvie-Wigley d55d88707c Return more information when building a transaction fails 2019-01-17 15:10:42 -07:00
Homu 8df7a073ce Auto merge of #3647 - LarryRuane:2926-mutex-assert-stop, r=str4d
On shutdown, wait for miner threads to exit (join them)

Closes #2926. Have `Shutdown()` running in the main thread wait for miner threads to exit before exiting.
2019-01-03 08:49:16 -08:00
Jack Grigg a6da0b03da
Set Sprout note data in WalletTest.WriteWitnessCache 2019-01-02 13:23:28 +00:00
Homu abd55f27f2 Auto merge of #3691 - ebfull:printsproutr1cs, r=daira
Allow user to ask server to save the Sprout R1CS to a file during startup.

This adds an experimental feature `-savesproutr1cs` which can be used to save the file `r1cs` containing the constraint system used in the original launch of Zcash. The file is written to the parameters directory. This can be used to recover this file for verification of the Sprout MPC transcript and parameters.
2018-12-18 23:28:06 -08:00
Homu e84b865a55 Auto merge of #3716 - charlieok:initialize_params_in_transaction_builder_tests, r=daira
initialize pCurrentParams in TransactionBuilder tests

In issue https://github.com/zcash/zcash/issues/3715 the failing tests were calling Params(), which includes an assertion that pCurrentParams is not null, without first calling SelectParams(), which will set that pointer. All the other tests in the same test case (which don't fail in the manner described in #3715 ) start out by calling `SelectParams(CBaseChainParams::REGTEST);`.

This change adds an identical call to the affected tests, getting past the failed assertion  in Params() on pCurrentParams.

Here is a GitLab pipeline showing output from these tests run in isolation before this change:
https://gitlab.com/charlieok/zcash/pipelines/38304730

...and here is one with the same set of tests after this change:
https://gitlab.com/charlieok/zcash/pipelines/38307556
2018-12-16 06:01:54 -08:00
George Tankersley 260e81a8b1 zmq: add flag to publish all checked blocks
This change adds a hook for the BlockChecked signal to the zmq
publisher. This is useful for light wallet daemon initialization.

The new flag is `-zmqpubcheckedblock=address`
2018-12-15 00:02:52 -05:00
Homu c4d352166d Auto merge of #3699 - Eirik0:mergetoaddress-doc-update, r=daira
Update z_mergetoaddress documentation

Corrected an error, added clarification, and updated some formatting for z_mergetoaddress documentation.
2018-12-12 11:58:18 -08:00
Eirik Ogilvie-Wigley 25f1f7dc61 Update z_mergetoaddress documentation 2018-12-11 14:25:35 -07:00
Jack Grigg 7afb23ef31
Add Sapling test cases 2018-12-01 15:55:34 +00:00
Jack Grigg c3eaffdb48
Use nullptr instead of NULL in wallet tests 2018-12-01 15:51:00 +00:00
Homu 9cd74866c7 Auto merge of #3262 - str4d:2074-perf-1, r=str4d
Bitcoin 0.12 performance improvements

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6918
- bitcoin/bitcoin#6932

Part of #2074.
2018-11-30 15:25:33 -08:00
Homu 8e2ca4d94e Auto merge of #3714 - mdr0id:release-v2.0.2, r=bitcartel
Release v2.0.2
2018-11-30 10:18:43 -08:00
mdr0id 6f8d182f50 Add Charlie and Ariel alias to author_aliases
Update approx_release_height to allow pre-rel to get into master prior

Bump APPROX_RELEASE_HEIGHT due to transient failures in pre-release 2.0.2 PR
2018-11-30 10:04:49 -08:00
mdr0id 9a126cbb70 Update nnMinimumChainWork per 2.0.2 getblockchaininfo 2018-11-29 10:32:18 -08:00
Charlie O'Keefe 67d2b19caa initialize pCurrentParams in TransactionBuilder tests
These three tests were failing when run in isolation, or sporadically
when test order is randomized, since Params() includes an assertion that
pCurrentParams is not null.
2018-11-29 01:40:37 -07:00
mdr0id d974ec3fec make-release.py: Versioning changes for 2.0.2. 2018-11-28 11:00:22 -08:00
Jack Grigg 0de659946e
wallet: Skip transactions with no shielded data in CWallet::SetBestChain()
Co-authored-by: Daira Hopwood <daira@jacaranda.org>

Closes #3495.
2018-11-28 00:56:42 +01:00
Larry Ruane 23c9deafb7 remove non-ascii characters from help text 2018-11-20 17:41:45 -07:00
mdr0id 4c5943cade make-release.py: Versioning changes for 2.0.2-rc1. 2018-11-18 10:11:46 -08:00
Sean Bowe 685c0ab07f Allow user to ask server to save the Sprout R1CS out during startup. 2018-11-17 17:10:58 -07:00
Simon 6d154ace1a For ZEC-013. RPC sendrawtransaction returns error if tx expiring soon. 2018-11-17 09:02:18 -08:00
Simon 4484c76202 For ZEC-013. RPC createrawtransaction returns error if tx expiring soon. 2018-11-17 09:02:10 -08:00
Simon cc1ab2db55 For ZEC-013. Don't propagate txs which are expiring soon in p2p messages.
When responding to "mempool" message, do not include the txid of an
expiring soon transaction in the "inv" message reply.
When responding to "getdata" message, do not reply with a "tx" message
for a transaction which is expiring soon.
2018-11-17 09:02:00 -08:00
Simon f8cd79c2de For ZEC-013. Mitigate potential tx expiry height related DoS vector.
Don't accept transactions which are about to expire (next 3 blocks).
Don't set a ban score if a peer does propragate these transactions.
See ZEC-013 for more detail.
2018-11-17 09:01:49 -08:00
Homu a47e1fda73 Auto merge of #3684 - str4d:load-sapling-chain-value, r=bitcartel
Load sapling chain value into memory

`CBlockIndex::nSaplingValue` has been correctly set and written to disk since before Sapling activated, meaning that all nodes now are correctly tracking the Sapling shielded pool value on-disk. However, on restart the per-block values are not being read into memory, and so the in-memory pool value appears to be zero on every restart. Setting `nSaplingValue` in-memory during block index loading fixes the problem.
2018-11-16 21:07:46 -08:00
Homu ed6b10018a Auto merge of #3670 - LarryRuane:3399-peer-ban-overwinter, r=bitcartel
don't ban peers when loading pre-sapling (and pre-blossom) blocks

Resolves #3399.
2018-11-16 19:22:48 -08:00
Eirik Ogilvie-Wigley 88d134c251 Add additional z_mergetoaddress parameter tests 2018-11-16 18:14:58 -07:00
Eirik Ogilvie-Wigley 12040363ad Better error messages when sending between Sprout and Sapling 2018-11-16 18:14:58 -07:00
Eirik Ogilvie-Wigley 0adb77d32e Add locking for Sapling notes 2018-11-16 18:14:58 -07:00
Eirik Ogilvie-Wigley 487c9020bd Add Sapling support to z_mergetoaddress 2018-11-16 18:14:58 -07:00
Eirik Ogilvie-Wigley 9c6b6a2be5 Fix z_mergetoaddress parameter tests 2018-11-16 18:00:05 -07:00
Simon 471138a9f3 Update rpc_wallet_tests for new "sapling" default for z_getnewaddress. 2018-11-16 10:16:43 -08:00
Simon 6eec2812a2 Closes #3671 to make "sapling" the default for z_getnewaddress RPC. 2018-11-16 10:16:43 -08:00
Jack Grigg 51df195f5e
Comment in CDiskBlockIndex that LoadBlockIndexGuts also needs updating 2018-11-16 15:13:17 +00:00
Jack Grigg aa9d47f9d5
Set nSaplingValue in-memory when loading block index from disk 2018-11-16 15:11:33 +00:00
Homu ae49175cd4 Auto merge of #3669 - charlieok:init_win_networking_in_test_setup, r=str4d
Add a call to SetupNetworking in BasicTestingSetup

In issue https://github.com/zcash/zcash/issues/3668 , the error code returned by `getaddrinfo_a` (10093) is `WSANOTINITIALISED`:

> Successful WSAStartup not yet performed.  Either the application has not called WSAStartup or WSAStartup  failed. The application may be accessing a socket that the current  active task does not own (that is, trying to share a socket between  tasks), or WSACleanup has been called too many times.

https://docs.microsoft.com/en-us/windows/desktop/winsock/windows-sockets-error-codes-2

`WSAStartup` is called from the `SetupNetworking` function in `util.cpp`, but `SetupNetworking` was not being called during test setup. This pull request adds that call.

Here is a gitlab pipeline running tests in the `test_bitcoin.exe` executable before this change:
https://gitlab.com/charlieok/zcash/pipelines/36483478

...and here is the same set of tests run after this change:
https://gitlab.com/charlieok/zcash/pipelines/36485098
2018-11-15 12:34:11 -08:00
Homu 570e09ea59 Auto merge of #2815 - str4d:2074-relay-pruning, r=bitcartel
Relay blocks when pruning

Cherry-picked from https://github.com/bitcoin/bitcoin/pull/6148

Part of #2074.
2018-11-15 10:28:44 -08:00
Homu 85fefca399 Auto merge of #3663 - garethtdavies:3610-rpc-cleanup, r=bitcartel
Cleaning up RPC output

Closes #3610 and #3661 to clean up RPC help messages.
2018-11-15 08:42:33 -08:00
Homu bc81c12a4f Auto merge of #3585 - str4d:merkle-tree-test-vectors, r=bitcartel
Update IncrementalMerkleTree test vectors to use valid commitments

The original commitments were SHA256 outputs, and some were outside the
scalar field. This didn't affect the Merkle hash, which drops the high
bit from each commitment, but it does affect the creation of the Merkle
path in Rust, which requires path nodes to be valid scalars.

Here, we explicitly drop the high bit of all test vector commitments,
as well as reducing the two that remain outside the field. The test
vectors still pass, and can now also be used in the Rust implementation.
2018-11-14 21:48:35 -08:00
Jonathan "Duke" Leto 719508e703 Backport size_on_disk to RPC call getblockchaininfo.
This commit is extracted from upstream PR:
https://github.com/bitcoin/bitcoin/pull/11367
2018-11-14 15:02:39 -08:00
Larry Ruane 4f53418c88 don't ban peers when loading pre-sapling (and pre-blossom) blocks 2018-11-13 17:37:59 -07:00
Charlie O'Keefe efc2b22465 Add a call to SetupNetworking in BasicTestingSetup 2018-11-13 14:00:52 -07:00
Homu dfc3e186fc Auto merge of #3613 - bitcartel:3597_transaction_builder_version_check, r=bitcartel
Closes #3597. TransactionBuilder should check tx version before adding Sapling spends and outputs
2018-11-12 13:18:47 -08:00
Gareth Davies 4c646bb45b Cleaning up RPC output
Closes #3610 and #3661
2018-11-10 07:56:39 -08:00
Homu 44f5d33465 Auto merge of #3631 - arielgabizon:rename-method, r=bitcartel
rename HaveJoinSplitRequirements for Sapling

The method also checks condition for Sapling spends whilst the method name implies otherwise
2018-11-07 23:39:55 -08:00
Simon 7a9b6f8435 Closes #3597. TransactionBuilder checks tx version before adding Sapling spends and outputs. 2018-11-07 20:38:32 -08:00
Charlie O'Keefe 0ade29546f Save and restore current_path in TestingSetup constructor/destructor 2018-10-31 15:21:46 -06:00
Larry Ruane a17646b1fd wait for miner threads to exit (join them) 2018-10-30 15:41:30 -06:00
arielgabizon 06affbca05 rename HaveJoinSplitRequirements for Sapling 2018-10-29 20:56:13 +01:00
Homu 97fccdbac5 Auto merge of #3605 - LarryRuane:3604-memo-zeros, r=daira
3604 fix sapling default memo - 0xF6 plus zeros

Closes #3604. For Sapling outputs, set the default memo to `no_memo` instead of all zeros. (See section 5.5 of the Sapling protocol specification.)
2018-10-28 03:15:07 -07:00
Homu aee5072af0 Auto merge of #3628 - bitcartel:3329_safe_mode_alert_for_pre_sapling_nodes, r=daira
Closes #3329. Send alert to put non-Sapling nodes into safe mode.

The alert targets nodes running protocol version <= 170006.
Sapling compatible nodes run protocol version >= 170007.
2018-10-28 01:21:05 -07:00
Jack Grigg ee3fa7020e
Pass parameter paths as native strings to librustzcash 2018-10-27 19:19:02 +13:00
Simon fa46ab10b8 Closes #3329. Send alert to put non-Sapling nodes into safe mode.
The alert targets nodes running protocol version <= 170006.
Sapling compatible nodes run protocol version >= 170007.
2018-10-25 11:44:31 -07:00
Eirik Ogilvie-Wigley 81005fb214 Fix error message 2018-10-24 12:05:48 -06:00
Jack Grigg 40e4981a32
Remove the testing of duplicate coinbase transactions
Inapplicable to Zcash because BIP 30 and BIP 34 have been applied from the
beginning.
2018-10-24 20:10:53 +08:00
Alex Morcos dd2d90346c
Add unit test for UpdateCoins 2018-10-24 20:10:53 +08:00
Alex Morcos 244d8a4255
Make CCoinsViewTest behave like CCoinsViewDB
Zcash: Modified to also address Zcash changes.

Co-authored-by: Jack Grigg <jack@z.cash>
2018-10-24 20:03:40 +08:00
Alex Morcos 7335afabd4
ModifyNewCoins saves database lookups
When processing a new transaction, in addition to spending the Coins of its txin's it creates a new Coins for its outputs.  The existing ModifyCoins function will first make sure this Coins does not already exist.  It can not exist due to BIP 30, but because of that the lookup can't be cached and always has to go to the database.  Since we are creating the coins to match the new tx anyway, there is no point in checking if they exist first anyway.

Zcash: Modified to account for the fact that BIP 30 and BIP 34 have applied
from the beginning.
2018-10-24 19:28:39 +08:00
Pieter Wuille cf47f9550e
Don't wipe the sigcache in TestBlockValidity 2018-10-24 19:28:39 +08:00
Pieter Wuille e4734f2748
Evict sigcache entries that are seen in a block 2018-10-24 19:28:39 +08:00
Pieter Wuille 3a78872137
Make sigcache faster and more efficient 2018-10-24 19:28:39 +08:00
Homu dc3398fa88 Auto merge of #3611 - bitcartel:3467_add_sapling_benchmarks, r=bitcartel
Closes #3467. Add benchmarks for Sapling spends and outputs.

Four new benchmarks are added to RPC zcbenchmark:
- createsaplingspend
- createsaplingoutput
- verifysaplingspend
- verifysaplingoutput
2018-10-23 22:52:22 -07:00
Larry Ruane 19621a7993 sapling z_sendmany default memo 0xf6 + zeros 2018-10-23 15:13:41 -06:00
Homu d2019a4ccd Auto merge of #3581 - Eirik0:3580-unspent-note-cleanup, r=daira
Remove GetUnspentFilteredNotes

Closes #3580

This PR generalized `GetFilteredNotes`, expanding its functionality to also do what we do in `GetUnspentFilteredNotes`. This enables us to remove the latter.
2018-10-22 22:36:05 -07:00
Eirik Ogilvie-Wigley 095eee4f4d Wrap long line and update comments 2018-10-22 10:01:17 -06:00