Commit Graph

9111 Commits

Author SHA1 Message Date
Jack Grigg 2ad84e8564 Comment tweaks and cleanups
Co-Authored-By: Daira Hopwood <daira@jacaranda.org>
2020-04-10 09:53:30 +12:00
Homu 6fcfe529d9 Auto merge of #4430 - str4d:build-fixes, r=str4d
Rust build fixes

Fixes cross-compilation, along with some minor adjustments to the Makefile integration.
2020-04-09 21:40:23 +00:00
Alfredo Garcia a43f5daff8 add -lightwalletd experimental option 2020-04-09 11:05:21 -03:00
Homu e7fbdf532c Auto merge of #4424 - oxarbitrage:patch-4, r=str4d
multiple debug categories documentation

The command line help is not clear on how to execute multiple but specific debug categories. Failed with stuff like `-zcashd -debug=category1, category2`, etc to find how to do it after some time.

The proposed line addition should help with that.
2020-04-09 13:43:23 +00:00
Dimitris Apostolou 78ecb9a681
Remove stale comment 2020-04-09 11:03:48 +03:00
Homu 726bd2a2c8 Auto merge of #4371 - str4d:4260-nu-branch-id-errors, r=str4d
Check failing transparent and JoinSplit signatures against the previous network upgrade

This change improves usability across network upgrades, by informing
users when their new transactions are being created with the consensus
branch ID from the previous epoch.

We only check failing signatures against the previous epoch to minimise
the extra computational load on nodes.

A future refactor is needed to similarly check Sapling signatures.

Part of #4260.
2020-04-09 04:27:29 +00:00
Jack Grigg 4216319ee6 test: Assert that GetValidTransaction supports the given branch ID
Also includes a small documentation fix.
2020-04-09 15:43:18 +12:00
Alfredo Garcia 9c3d5b378b Lock with cs_main inside gtests that call chainActive.Height() 2020-04-08 13:00:49 -03:00
Jack Grigg e3ec96d3af build: Connect cargo verbosity to make verbosity 2020-04-08 18:17:19 +12:00
Jack Grigg eca5009825 test: Build Rust tests as part of qa/zcash/full_test_suite.py
The previous version of full_test_suite.py directly called the test
binary, which was being compiled at the same time as the static library.
However, by passing the --tests argument to cargo, rustc was ignoring
several important release-profile configurations, and was also
attempting to link the test binary, which was breaking cross-compilation
builds.

This commit alters src/Makefile.am to only build the static library, and
leaves test compilation to the test runner itself. This ensures that the
tests are only compiled for native builds, when the tests will be run on
the same platform.
2020-04-08 18:17:19 +12:00
Jack Grigg 5c79c26876 build: Correctly remove generated files from .cargo 2020-04-08 13:50:58 +12:00
Jack Grigg 1e2e0216ac build: Move cargo arguments into RUST_BUILD_OPTS 2020-04-08 13:50:51 +12:00
Jack Grigg 82fe37d22b Use a C array for HistoryEntry instead of std::array
std::vector<T> is guaranteed to store T contiguously. However, there is
no guarantee that sizeof(std::array<unsigned char, N>) == N, which
prevents us from interpreting std::vector<std::array<unsigned char, N>>
as &[[u8; N]] on the Rust side of the FFI.

Instead, we define HistoryEntry as a struct wrapping a C array, which
(as checked by static_assert) contains no padding.
2020-04-08 08:49:01 +12:00
Jack Grigg 8a658dfd33 Return the correct root from librustzcash_mmr_{append, delete}
Per https://zips.z.cash/zip-0221#tree-node-specification :

    Once the MMR has been generated, we produce hashChainHistoryRoot,
    which we define as the BLAKE2b-256 digest of the serialization of
    the root node.
2020-04-08 08:49:01 +12:00
Jack Grigg b5c7c4a22f Implement ZIP 221 consensus rules 2020-04-08 08:49:01 +12:00
Jack Grigg 483d35e37c Add ZIP 221 support to miner and getblocktemplate
The "finalsaplingroothash" field of the getblocktemplate output is no
longer guaranteed to match the actual Sapling commitment tree root, and
has been deprecated. Users should migrate to "lightclientroothash".
2020-04-08 08:49:01 +12:00
Jack Grigg cf480fe402 Add ZIP 221 logic to block index
CBlockHeader.hashFinalSaplingRoot has been renamed to hashLightClient.

CBlockIndex now stores:
- hashLightClient as from the block header
- hashFinalSaplingRoot, which is accurate for all blocks prior to
  Heartwood activation, and all blocks from Heartwood activation onward
  that are connected at some point to the main chain in ConnectBlock().
- hashChainHistoryRoot, which is null prior to Heartwood activation, and
  set per ZIP 221 from Heartwood activation.

The new block index fields are only written to disk for client version
2.1.2 and above, which will be the first Heartwood-aware clients (even
if Heartwood doesn't have an activation height).
2020-04-08 08:49:01 +12:00
NikVolf 5608118cc4 use iterative platform-independent log2i 2020-04-08 08:49:01 +12:00
NikVolf 75d2f782b5 update chain history in ConnectBlock and DisconnectBlock 2020-04-08 08:49:01 +12:00
NikVolf cf247bc655 push/pop history with tests
Co-authored-by: Jack Grigg <jack@z.cash>
2020-04-08 08:49:01 +12:00
Alfredo Garcia 24a75fe4f8 change unclear wording in z_import calls address returned 2020-04-07 10:46:42 -03:00
Alfredo Garcia 0a6ab8a5ab return address info in z_importviewingkey 2020-04-07 08:38:12 -03:00
Alfredo Garcia 6039242829
multiple debug categories documentation 2020-04-06 09:09:43 -03:00
Daira Hopwood dd215e8994 Use `SA_RESTART` in `sa_flags` when setting up signal handlers.
Explanation: if a signal interrupts certain syscalls such as `open`, `read`, or `write`,
then the library function will by default fail with `errno` `EINTR`. But we almost never
check for `EINTR`, so this is likely to cause spurious errors. We want to restart the syscall
instead, which is what `SA_RESTART` is intended to do. Since our signal handlers (defined
in init.cpp) only set a flag, restarting the syscall is safe and is always the Right Thing.

See <https://www.gnu.org/software/libc/manual/html_node/Flags-for-Sigaction.html> and
<https://www.gnu.org/software/libc/manual/html_node/Interrupted-Primitives.html> for
further information.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-03-28 19:14:48 +00:00
Homu b5f179d207 Auto merge of #4370 - str4d:3060-sapling-viewing-keys, r=str4d
Add support for Sapling full viewing keys

This PR adds Sapling support to `z_exportviewingkey` and `z_importviewingkey`, and stores imported Sapling viewing keys in the wallet.

Closes #3060.
2020-03-28 02:41:26 +00:00
Homu 08993dcb93 Auto merge of #4408 - oxarbitrage:patch-3, r=daira
Fix comment in rpc_wallet_tests

Address a small comment issue in `rpc_z_shieldcoinbase_parameters` rpx wallet tests.
2020-03-19 00:03:55 +00:00
Homu 2dd4721f84 Auto merge of #4365 - oxarbitrage:issue1361, r=daira
Replace tuples by classes in asyncoperation_sendmany

Close https://github.com/zcash/zcash/issues/1361
2020-03-17 23:56:02 +00:00
Alfredo Garcia 0636fbabbd
minor comment fix 2020-03-17 17:56:25 -03:00
Daira Hopwood 9526e13a02
Make the memo a mandatory argument for SendManyRecipient 2020-03-17 13:41:09 +00:00
Homu a125f3f5f8 Auto merge of #4403 - ebfull:rust-tests, r=str4d
Additional librustzcash integration

This adds librustzcash tests to the full test suite, and brings in the release profile configurations that are currently present in the librustzcash workspace on the other repository. It's very important that we build librustzcash with panic=abort because otherwise the unwinding panics across FFI boundaries could cause undefined behavior.
2020-03-17 07:50:48 +00:00
Homu fc9d0fa72f Auto merge of #4404 - daira:fix-reindex-divby0, r=ebfull
Avoid a theoretical possibility of division-by-zero introduced in #4368

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-03-16 17:13:39 +00:00
Homu 5a626317c7 Auto merge of #4390 - daira:fix-chaintip-race-condition, r=ebfull
Fix race conditions during init

Fix race conditions due to accessing `chainActive.Tip()` during init, and other minor cleanups.
Includes backport of https://github.com/bitcoin/bitcoin/pull/8063 .
2020-03-16 15:11:43 +00:00
Daira Hopwood b49cdee878 Avoid a theoretical possibility of division-by-zero introduced in #4368.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-03-16 14:56:38 +00:00
Sean Bowe 7767f8e9e0
Add librustzcash tests to the full test suite. 2020-03-14 10:58:09 -06:00
Jack Grigg c7b2fc101d Bring in updates to librustzcash crate
Source: https://github.com/zcash/librustzcash.git
Revision: 53bd5d4724c96374c4bf94068207fcc362b01ac7
2020-03-13 14:16:45 +13:00
Alfredo Garcia 3dfcf027e3 change constructors 2020-03-12 09:39:19 -03:00
Homu 8b600df660 Auto merge of #4396 - daira:minimize-zip207-diff, r=str4d
Fix typos/minor error in comments, and wrap some lines

This minimizes the diff in the example implementation of funding streams in ZIP 207.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-03-12 10:51:55 +00:00
Homu c0802cccac Auto merge of #4368 - gladcow:issue3813_reindex_in_metrics, r=str4d
Shows reindex progress in metrics screen

Resolves issue #3813.

The "Downloading blocks" message is changed to "Reindexing blocks" during reindex, after reindex is completed the text is reverted back to the first variant.

Reindex progress is shown as a sum of processed file size (we can't use reindexed block number as a progress because we can't predict how many blocks to process at all, we don't know the size of the block before we process it), the result looks like
```
Reindexing blocks | 22.64 MiB / 336.00 MiB (6%, 13583 blocks)
```
2020-03-12 09:28:35 +00:00
Homu ac4e91c6f4 Auto merge of #4343 - oxarbitrage:issue3083, r=str4d
Add expired transaction notifications

Closes https://github.com/zcash/zcash/issues/3083
2020-03-12 06:35:04 +00:00
Jack Grigg f21de9d0d6 consensus: Check JoinSplit signatures against the previous network upgrade
We only check failing signatures against the previous epoch to minimise
the extra computational load on nodes.
2020-03-12 17:17:48 +13:00
Jack Grigg dc99cd74a0 test: Add Overwinter and Sapling support to GetValidTransaction() helper 2020-03-12 17:14:39 +13:00
Jack Grigg 4441b7bcb4 mempool: Remove duplicate consensusBranchId from AcceptToMemoryPool 2020-03-12 17:14:39 +13:00
Jack Grigg 6bec5685b6 mempool: Check transparent signatures against the previous network upgrade
This change improves usability across network upgrades, by informing
users when their new transactions are being created with the consensus
branch ID from the previous epoch.

We only check failing signatures against the previous epoch to minimise
the extra computational load on nodes.
2020-03-12 17:14:39 +13:00
Jack Grigg 7647f58c3d test: Add missing parameter selection to Validation.ReceivedBlockTransactions
This wasn't breaking CI because earlier tests selected parameters, but
running just the Validation group caused a crash.
2020-03-12 17:14:39 +13:00
Jack Grigg c4ca7e8730 test: Modify ValidationFakeCoinsViewDB to optionally contain a coin 2020-03-12 17:14:39 +13:00
Jack Grigg 28ea36b412 test: Rename FakeCoinsViewDB -> ValidationFakeCoinsViewDB
This ensures we are using the correct test class.
2020-03-12 17:14:39 +13:00
Homu fa67c4e148 Auto merge of #4293 - oxarbitrage:issue2671, r=str4d
Refactor experimental feature handling

Adds new rpc call `getexperimentalfeatures` and also adds experimental features to `getblockchaininfo` output.

Closes #2671.
2020-03-12 02:09:12 +00:00
Alfredo Garcia b7c8ee64d7 minor cleanup style, var names 2020-03-11 13:43:47 -03:00
Daira Hopwood 5d5e6a6762 Fix typos/minor errors in comments, and wrap some lines.
This minimizes the diff in the example implementation of funding streams in ZIP 207.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-03-11 16:41:31 +00:00
Homu 4eb3dc7ec6 Auto merge of #4321 - str4d:internalise-rust, r=str4d
Bring the librustzcash crate into this repository

Rust dependencies are now canonically pinned within this repository by
`Cargo.lock`. We continue to use the depends system for vendoring the
dependencies, to ensure our Gitian builds continue to function (which have
no network access at build time, and fetch dependencies separately).

The `--enable-online-rust` configure flag replicates the behaviour of the
`LIBRUSTZCASH_OVERRIDE` environment variable (enabling the build system to
use https://crates.io instead of vendored dependencies).

This pulls in the exact version of `librustzcash` that we currently depend on
(corresponding to the `0.1.0` tag in https://github.com/zcash/librustzcash).
The changes to the crate since then will be pulled in as a separate PR.

Part of zcash/librustzcash#155.
Part of #4230.
2020-03-11 14:20:17 +00:00
Jack Grigg 684e62e903 Fix Rust static library linking for Windows builds
The library renaming step is necessary because the naming convention
used by rustc does not match the naming convention for libtool/MinGW.
2020-03-12 00:50:45 +13:00
Daira Hopwood 0de0105c80 Exit init early if we request shutdown before having loaded the genesis block.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-03-10 17:57:52 +00:00
Daira Hopwood 3c573f2485 Add comment to `MilliSleep` documenting that it is an interruption point.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-03-10 17:57:52 +00:00
Daira Hopwood 99dc6de485 Setting a std::atomic variable in a signal handler only has defined behaviour if it is lock-free.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-03-10 17:57:52 +00:00
Daira Hopwood 74467f8f02 Resolve a race condition on `chainActive.Tip()` in initialization (introduced in #4379).
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-03-10 17:57:52 +00:00
Patrick Strateman 82e641f3cc Acquire lock to check for genesis block. 2020-03-10 17:57:52 +00:00
gladcow fc2501b63e Move reindex progress globals to metrics.h/cpp 2020-03-10 09:33:35 +03:00
gladcow 003cd8fd8f Byte sizes format 2020-03-10 09:33:35 +03:00
gladcow e72885b690 Use processed file size as progress in metrics during reindex 2020-03-10 09:33:35 +03:00
gladcow 7bdf64f319 Show reindex state in metrics 2020-03-10 09:33:35 +03:00
Homu dcd3614de4 Auto merge of #4359 - str4d:2872-upgrade-libsodium, r=str4d
Upgrade libsodium to 1.0.18

Includes patches that maintain consensus compatibility with libsodium 1.0.15 for Ed25519 pubkey and signature validation.

Replaces #4239. Closes #2872.
2020-03-10 03:10:01 +00:00
Homu ca668cf666 Auto merge of #4374 - daira:rewrite-addtimedata, r=daira
Remove time adjustment; instead warn if peer clocks are too different

The policy is: warn if we have seen at least 8 (TIMEDATA_WARNING_SAMPLES) peer times, in the version messages of the first 20 (TIMEDATA_MAX_SAMPLES) unique (by IP address) peers that connect, that are more than 10 minutes (TIMEDATA_WARNING_THRESHOLD seconds) but less than 10 days (TIMEDATA_IGNORE_THRESHOLD seconds) away from local time.

fixes #4338
2020-03-09 21:15:34 +00:00
MeshCollider d7c62cdd4f Consistent parameter names in txdb.h 2020-03-07 10:21:59 +03:00
MeshCollider e4b66f565a Make fReindex atomic to avoid race 2020-03-07 10:21:59 +03:00
MeshCollider cb8de0395f Fix race for mapBlockIndex in AppInitMain 2020-03-07 10:21:59 +03:00
Alfredo Garcia aa24f921e8 make fInsightExplorer a local 2020-03-06 08:49:16 -03:00
Alfredo Garcia 04012a62c1 refactor experimental features 2020-03-06 07:48:33 -03:00
Alfredo Garcia 92bf83c4bb add getexperimentalfeatures rpc call 2020-03-06 07:48:24 -03:00
Homu 35bff6ac7c Auto merge of #4256 - str4d:zip-213-shielded-coinbase, r=daira
[NU3 Heartwood] Shielded Coinbase

Implements [ZIP 213](https://github.com/zcash/zips/pull/217).
2020-03-06 10:19:13 +00:00
Jack Grigg 5fe41654bf Move root of Rust crate into repo root
This enables IDE integration to work (which requires the Cargo.toml to
be in the repo root).

"make clean" no longer runs "cargo clean", because IDE integrations hold
locks on files within the Rust build directory, and an error inside
"cargo clean" error would prevent "make clean" from completing (and
removing other files).
2020-03-06 16:49:03 +13:00
Jack Grigg 90f7234136 Replace librustzcash from depends system with src/rust
The --enable-online-rust configure flag replicates the behaviour of the
LIBRUSTZCASH_OVERRIDE environment variable (enabling the build system to
use crates.io instead of vendored dependencies).
2020-03-06 16:49:03 +13:00
Jack Grigg 62d0af94cf rust: Adjust Cargo.toml so that it compiles
The Cargo.lock is updated to account for the Zcash Rust crates no longer
being in the same workspace. Dependencies that were not transitive
dependencies of librustzcash are also removed, but no versions change.
2020-03-06 16:24:14 +13:00
Jack Grigg 28b2a65c64 rust: Pin toolchain to 1.36.0, matching depends system 2020-03-06 16:24:14 +13:00
Jack Grigg ef81abdde3 Bring in Cargo.lock from librustzcash repo
Source: https://github.com/zcash/librustzcash.git
Revision: a57dc7f47807ea50cb0a5deec9b84b3e7da11bc0
2020-03-06 16:24:14 +13:00
Jack Grigg 443fe7d092 Bring in librustzcash crate
Source: https://github.com/zcash/librustzcash.git
Revision: a57dc7f47807ea50cb0a5deec9b84b3e7da11bc0
2020-03-06 16:24:14 +13:00
Jack Grigg 06bd43b53c test: Explicitly check Sapling consensus rules apply to shielded coinbase 2020-03-06 15:24:38 +13:00
Jack Grigg d8f0bc9e21 init: Inform on error that -mineraddress must be Sapling or transparent 2020-03-06 13:18:04 +13:00
Jack Grigg 743a5f437f Use DoS level constants and parameters for ZIP 213 rejections 2020-03-06 12:03:57 +13:00
Jack Grigg 3b3382bb48 Adjust comments on ZIP 213 logic 2020-03-06 11:50:15 +13:00
Homu 6c00a8ccf9 Auto merge of #4280 - oxarbitrage:issue2197, r=daira
Allow negative heights in RPC calls

For issue https://github.com/zcash/zcash/issues/2197

Currently adding the feature to `getblock` and `getblockhash`. There is another candidate: `getblocksubsidy` however i want to have some review about these 2 first before repeating what could be a bad approach.
2020-03-05 16:36:32 +00:00
Jack Grigg 162dac1a45 test: Minor tweaks to comments in LibsodiumPubkeyValidation 2020-03-04 06:54:58 +13:00
Larry Ruane 75251cb2bc util: CBufferedFile fixes 2020-03-02 18:03:46 -07:00
Homu 086c2b4d9f Auto merge of #4379 - ebfull:fix-wallet-assertion, r=ebfull
Initialize ThreadNotifyWallets before additional blocks are imported

The intention of this PR is to address #4301. It seems `ThreadNotifyWallets` assumes that `chainActive.Tip()` on initialization reflects the wallet's view of the active tip, but prior to `ThreadNotifyWallets`'s initialization the active chain ends up being modified by blocks that are imported from disk, so our local `pindexLastTip` ends up out of sync with the wallet's actual "last" tip.

This PR moves the initialization of `ThreadNotifyWallets` to earlier in the process while passing in the current active tip. This addresses the problem for non-fresh nodes, and then for fresh nodes we have the notification thread wait until the genesis block has been loaded.
2020-02-28 17:39:45 +00:00
Jack Grigg 9ea5f6907f Add regtest-only -nurejectoldversions option
This enables us to write RPC tests for network upgrades before they have
been activated on testnet.
2020-02-28 13:59:53 +13:00
Jack Grigg 9b3a261831 wallet: Include coinbase txs in Sapling note selection 2020-02-28 13:59:53 +13:00
Jack Grigg 99ec1ff971 Add support for Sapling addresses in -mineraddress 2020-02-28 13:59:53 +13:00
Jack Grigg 80169c940f ZIP 213 consensus rules 2020-02-28 13:59:53 +13:00
Sean Bowe e597ad842a
Clarify comment 2020-02-27 17:57:59 -07:00
Jack Grigg 17b2af94f6 OutputDescriptionInfo::Build() 2020-02-28 13:50:57 +13:00
Homu 95e446bf69 Auto merge of #4380 - oxarbitrage:issue3446, r=ebfull
Change cm to cmu in sapling

Part of https://github.com/zcash/zcash/issues/3446

For each of the 2 commits, suggested change was made, then fixed build errors until compile. Finally ran bitcoin and gtests, both of them passing.
2020-02-27 20:46:05 +00:00
Homu 6ff6c9eeef Auto merge of #4378 - defuse:clean-afl-temp, r=ebfull
Have make clean delete fuzzing-related directories
2020-02-26 21:47:59 +00:00
Sean Bowe b79edf1b55
Handle case of fresh wallets in ThreadNotifyWallets. 2020-02-26 14:47:22 -07:00
Alfredo Garcia 8ebe538eaa change maybe_cm to maybe_cmu 2020-02-26 18:33:49 -03:00
Alfredo Garcia 445ae593d6 change the cm member of OutputDescription to cmu 2020-02-26 17:43:50 -03:00
Alfredo Garcia 4d4cb44440 change cm() to cmu() in SaplingNote class 2020-02-26 16:49:34 -03:00
Sean Bowe faca79eb2f
Initialize ThreadNotifyWallets before additional blocks are imported.
Co-authored-by: Daira Hopwood <daira@electriccoin.co>
2020-02-26 11:20:12 -07:00
Taylor Hornby 171ce8336b Have make clean delete AFL output directories. 2020-02-26 09:31:28 -07:00
Daira Hopwood ee4d73b841 Sort entries in zcash_gtest_SOURCES (other than test_tautology which is deliberately first).
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-25 17:00:10 +00:00
Daira Hopwood 7fa7225509 Update GetAdjustedTime() to GetTime().
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-25 16:57:22 +00:00
Daira Hopwood d631187b39 Replace time adjustment with warning only.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-25 16:48:16 +00:00
Daira Hopwood e1fa4c98fd Remove uses of GetTimeOffset().
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-24 16:27:07 +00:00
Daira Hopwood ddc2bbf742 Revert "Add -maxtimeadjustment with default of 0 instead of the 4200 seconds used in Bitcoin Core."
This reverts commit eb5e328073.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-24 16:27:07 +00:00
Homu 69e0e7ee62 Auto merge of #4369 - daira:port-strMiscraceless, r=str4d
Upstream PRs relating to strMiscWarning

This pulls in upstream PRs bitcoin/bitcoin#7114 and bitcoin/bitcoin#9236 (non-QT parts).

* Fixes bitcoin/bitcoin#6809 - run-of-the-mill exceptions should not get into `strMiscWarning` (which is reported by `getinfo`).
* Eliminate data races for `strMiscWarning` and `fLargeWork*Found`. This moves all access to these data structures through accessor functions and protects them with a lock.
2020-02-21 19:06:29 +00:00
Jack Grigg a62405f44f Store imported Sapling ExtFVKs in wallet database 2020-02-21 01:32:15 +00:00
Gregory Maxwell 9f4ad7e1c6 Move GetWarnings() into its own file.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-21 01:31:16 +00:00
Gregory Maxwell d6a48adb76 Eliminate data races for strMiscWarning and fLargeWork*Found.
This moves all access to these datastructures through accessor functions
and protects them with a lock.

Relative to the upstream commit, we also add GetMiscWarning() to make this accessible to tests.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-21 01:30:23 +00:00
Jack Grigg 1bcbe4e21d Add in-memory Sapling ExtFVK support to z_importviewingkey 2020-02-21 01:30:02 +00:00
Gregory Maxwell 05882459c0 Move GetWarnings and related globals to util.
This is a first step in avoiding racy accesses to strMiscWarning.

By itself this commit causes a link error because global variables relating to alerts
are only accessible in the zcashd server, but util is used in other binaries.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-21 01:28:13 +00:00
Wladimir J. van der Laan f08e31382b util: Don't set strMiscWarning on every exception
Fixes bitcoin/bitcoin#6809 - run-of-the-mill exceptions should not get into
strMiscWarning (which is reported by `getinfo`).
2020-02-21 01:06:00 +00:00
Jack Grigg a1d22b2d4a Add Sapling ExtFVK support to z_exportviewingkey 2020-02-21 00:59:27 +00:00
Jack Grigg 3c7385bc8e Add encoding and decoding for Sapling extended full viewing keys 2020-02-21 00:59:27 +00:00
Homu e50639517f Auto merge of #4362 - str4d:3060-zcash-address-refactor, r=str4d
Refactor shielded address logic

This gets the more menial work out of the way in order to simplify the viewing key PR.

Part of #3060.
2020-02-20 22:28:39 +00:00
Homu d75fe844e3 Auto merge of #4356 - oxarbitrage:issue4286, r=str4d
remove debug noise from gtests

Closes #4286.
2020-02-20 13:28:14 +00:00
Jack Grigg 7de06244e6 test: Add test for CBasicKeyStore::AddSaplingFullViewingKey 2020-02-20 13:01:49 +00:00
Jack Grigg b62bb98087 Remove default address parameter from Sapling keystore methods
Now that we store SaplingExtendedFullViewingKey internally, we have
access to the default address everywhere we require it.
2020-02-20 13:01:49 +00:00
Jack Grigg d74fdd76eb SaplingFullViewingKey -> SaplingExtendedFullViewingKey in keystore maps
All of these maps are created from scratch on wallet load, so we can
alter their contents without compatibility concerns. With this change,
we can use the existing maps to implement viewing key support. The
downside is that the wallet will take more space in memory, but that can
easily be improved in future by storing ExtFVK fingerprints in some of
the maps (which would improve memory usage even compared to the original
layout).
2020-02-20 13:01:49 +00:00
Jack Grigg 9658c87d4a Move ZIP 32 classes inside zcash/Address.hpp
This fixes the dependency graph between the general address-handling
logic, ZIP 32, and the core Sapling address classes.
2020-02-20 12:26:58 +00:00
Jack Grigg 42b423c3a5 Move Sprout and Sapling address logic into separate files 2020-02-20 12:26:58 +00:00
Jack Grigg 4964328210 Deduplicate some wallet keystore logic 2020-02-20 12:26:58 +00:00
Homu 27c04c8f9c Auto merge of #4146 - str4d:z_viewtransaction, r=str4d
z_viewtransaction

This RPC method returns all decryptable information for any transaction in the wallet.

Several values are conditionally included in the output for convenience:
- `recovered`: True if an output is not for a Sapling address in the wallet.
- `memoStr`: The text form of an output's memo, if it is valid UTF-8.
- Values are provided both in decimal currency units, and integer zatoshis.
2020-02-19 20:52:47 +00:00
Homu 3f270a2afa Auto merge of #4360 - oxarbitrage:issue3235, r=str4d
Add destination wrapper functions

Closes #3235.
2020-02-19 17:53:54 +00:00
Alfredo Garcia 11de2d33e7 change tuples to classes 2020-02-19 10:12:26 -03:00
Homu 0e57ffa710 Auto merge of #4353 - daira:blossom-tests, r=str4d
Add missing cases for Blossom in ContextualCheckBlock tests

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-19 12:12:32 +00:00
Alfredo Garcia d53d4d880a add destination wrappers 2020-02-18 13:20:43 -03:00
Jack Grigg 7893f7b752 Add test vectors for small-order Ed25519 pubkeys
I'm not adding test vectors for non-canonical pubkeys, as that would
require grinding to find a private key corresponding to one of the 19
pubkeys that can be non-canonical.
2020-02-18 01:18:37 +00:00
Homu 5dde1a7702 Auto merge of #4328 - oxarbitrage:issue3344, r=str4d
Reduce duplication in key_io decode

Attempt to fix https://github.com/zcash/zcash/issues/3344 by adding a new `DecodeAny` template function with arguments that will handle all the cases. Then on each decoding this new function is called with the appropriate arguments resulting in reducing code duplication.

Some of the complexity(`boost::optional`) will be removed if `ViewingKey` is implemented for sapling.
2020-02-17 21:50:45 +00:00
Alfredo Garcia 0987bf349a add missing calls to DecodeAny 2020-02-17 14:54:08 -03:00
Alfredo Garcia df38c039f5 make type and size a pair in DecodeAny arguments 2020-02-17 14:27:56 -03:00
Alfredo Garcia 9ba20840e9 remove debug noise from 2 gtests 2020-02-17 13:57:49 -03:00
Alfredo Garcia a8f6b8c2e5 fix rpx_wallet_tests 2020-02-17 09:52:40 -03:00
Daira Hopwood fd164f56f2 Add missing cases for Blossom in ContextualCheckBlock tests.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-16 18:38:56 +00:00
Homu a830563309 Auto merge of #4316 - str4d:worst-case-benchmarks, r=str4d
Worst-case block verification benchmarks

The micro-benchmark framework from #3858 is used to measure the time to verify various transaction components. These are leveraged by a script that simulates the verification cost of different compositions of full blocks.
2020-02-14 23:42:44 +00:00
Jack Grigg ec32287fe7 bench: "Use" result of crypto_sign_verify_detached
This fixes compilation with --enable-werror.
2020-02-14 16:48:32 +00:00
Alfredo Garcia e992825e0a add txexpirynotify 2020-02-13 21:42:25 -03:00
Dimitris Apostolou 3247e3c901
Fix typo 2020-02-13 17:14:19 +02:00
Homu c5d20b5da0 Auto merge of #4335 - rex4539:remove-libsnark-flags, r=str4d
Remove libsnark preprocessor flags

Closes https://github.com/zcash/zcash/issues/4285.
2020-02-11 23:47:52 +00:00
Homu 3011702f53 Auto merge of #4302 - oxarbitrage:issue3687, r=str4d
Add z_getnewaddress test

Supercedes #3749. Closes #3687.

It takes the commit from @dagurval where a new test case
`rpc_wallet_z_getnewaddress` is added and it adds a check for too many
arguments.

It uses `CheckRPCThrows()` to test the error message of invalid argument.
However, for too many arguments the full help message is displayed, so I
am just testing there is an runtime exception.
2020-02-11 22:43:44 +00:00
Dimitris Apostolou 439c3dd6d2
Remove libsnark preprocessor flags 2020-02-11 16:28:18 +02:00
Homu e10576434d Auto merge of #4258 - oxarbitrage:issue3575, r=str4d
Changing gtest to CamelCase

This is #3583 with merge conflicts fixed.

Closes #3575.
2020-02-11 13:47:26 +00:00
mdr0id 1ce2e86612 Update #! env for python3 2020-02-10 13:34:29 -08:00
Homu a2d719b9ff Auto merge of #4324 - zancas:4323_replace_boost_fn_w_std_fn, r=str4d
Replace boost::function with std::function

Fixes: #4323

This logic is cherry-picked from the relevant commit, as referenced here:

https://github.com/bitcoin/bitcoin/pull/10395
2020-02-07 20:49:18 +00:00
Homu ba20384845 Auto merge of #4218 - Eirik0:4158-fix-recursive-memusage, r=str4d
Include shielded transaction data in RecursiveDynamicUsage calculation

Fixes #4158
2020-02-07 14:19:31 +00:00
Homu e93586a0c4 Auto merge of #4331 - zcash:hotfix-v2.1.1-1, r=ebfull
Hotfix v2.1.1-1

The commits in this PR have been reviewed internally by our team.
2020-02-07 04:50:43 +00:00
Sean Bowe afc553c448
make-release.py: Versioning changes for 2.1.1-1. 2020-02-06 16:51:15 -07:00
Daira Hopwood ca8d32070a Add string argument to static_asserts to satisfy C++11.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-06 23:35:56 +00:00
Daira Hopwood e9e9bda329 Fix ContextualCheckBlock test (the ban score should be 100 since these are mined transactions).
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-06 21:09:29 +00:00
Alfredo Garcia 750078ae67 dedup decode keys and addresses 2020-02-06 16:13:54 -03:00
ebfull e899837613
Merge pull request #44 from zcash/4283-contextualcheckblock-ban-policy
Apply a consistent ban policy within ContextualCheckTransaction
2020-02-06 11:11:13 -07:00
Jack Grigg 7bbd846f0f Apply a consistent ban policy within ContextualCheckTransaction 2020-02-06 14:30:37 +00:00
Daira Hopwood eb5e328073 Add -maxtimeadjustment with default of 0 instead of the 4200 seconds used in Bitcoin Core.
Based on 40061b05dc

Co-authored-by: mruddy <mruddy@users.noreply.github.com>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-05 17:00:09 +00:00
zancas 8b6d9e55ba
Remove remaining instances of boost::function
These were not addressed by @practicalswift's upstream fix.
2020-02-04 20:08:25 -07:00
practicalswift b841318ce8
Replace boost::function with std::function (C++11) 2020-02-04 19:54:25 -07:00
Daira Hopwood 3010c9277c Cosmetic: brace style in ContextualCheckBlockHeader.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-04 23:40:04 +00:00
Daira Hopwood 4ab896c69d Enable future timestamp soft fork at varying heights according to network.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-04 23:40:04 +00:00
Daira Hopwood bdb985a627 Adjust the miner to satisfy consensus regarding future timestamps relative to median-time-past.
Co-authored-by: Jack Grigg <jack@z.cash>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-04 23:12:36 +00:00
Daira Hopwood 7704ab4846 Soft fork: restrict block timestamps to be no more than 90 minutes after the MTP of the previous block.
Note that the MTP of a block is the median timestamp of the preceding 11 blocks, i.e. it is
typically (with no or only moderate timestamp manipulation) expected to be 6 block intervals
behind that block's timestamp, which *on average* is 450 seconds behind (after Blossom activation).
So the effective limit on future dating of timestamps is ~82.5 minutes. This makes it
exceptionally unlikely --even taking into account feasible timestamp manipulation of this
and previous blocks-- that the chain will stall because no block is found before the limit.
(This may rely on assumptions that do not hold for testnet.)

If an adversary were to have a sufficient fraction of mining power to engineer this situation
then there would be something seriously wrong, and arguably the chain should stall in that
case, pending manual intervention.

Co-authored-by: Jack Grigg <jack@z.cash>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-04 21:34:05 +00:00
Daira Hopwood a3bb1966eb Add constant for how far a block timestamp can be ahead of adjusted time.
Loosely based on e57a1fd899

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-04 19:46:48 +00:00
Daira Hopwood 3a001196b6 Improve messages for timestamp rules.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-04 19:45:03 +00:00
Daira Hopwood df6b4639d2 Move check for block times that are too far ahead of adjusted time, to ContextualCheckBlock.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-02-04 19:40:52 +00:00
zancas 9f4c93a16c
replace "virtual" with "override" in subclasses
The use of virtual on these lines is obsolete.

I ran:

"rm -f ./src/zcash-gtest && rm -f ./src/gtest/*.o && make && ./src/zcash-gtest"

before an after making the change.   In both cases:

206 test ran
from
32 cases
and
1 test was DISABLED
2020-02-01 15:58:21 -07:00
Jack Grigg 1eca94b0b1 Benchmark Zcash verification operations 2020-01-30 19:14:20 +00:00
Homu 8e8a9350c3 Auto merge of #4222 - str4d:configure-updates, r=str4d
./configure updates

Includes code cherry-picked from the following upstream Bitcoin Core PRs:

- bitcoin/bitcoin#6748
- bitcoin/bitcoin#12373
- bitcoin/bitcoin#12692
- bitcoin/bitcoin#12901
- bitcoin/bitcoin#13005
- bitcoin/bitcoin#13445
- bitcoin/bitcoin#12686
- bitcoin/bitcoin#16435

Part of #2074.
2020-01-30 16:01:48 +00:00
Jack Grigg 347de0aae2 RPC: Use OutgoingViewingKeys to recover non-wallet Sapling outputs 2020-01-29 16:05:44 +00:00
Jack Grigg f77915c587 RPC: Display valid UTF-8 memos in z_viewtransaction 2020-01-29 15:59:52 +00:00
Jack Grigg 32ade1edb1 RPC: z_viewtransaction 2020-01-29 15:59:52 +00:00
Alfredo Garcia 0f5ef52d2e add estimatedheight to getblockchaininfo
Co-authored-by: Aditya Kulkarni <adityapk@gmail.com>
2020-01-25 13:24:18 -03:00
Homu 37435aa2c2 Auto merge of #4220 - oxarbitrage:issue3748, r=str4d
Return address and type of imported key in z_importkey

Fixes #3748.
2020-01-25 00:45:00 +00:00
Homu 74ff73abab Auto merge of #3858 - str4d:microbench-1, r=str4d
Micro-benchmarking framework part 1

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6733
- bitcoin/bitcoin#6770
- bitcoin/bitcoin#6892
  - Excluding changes to `src/policy/policy.h` which we don't have yet.
- bitcoin/bitcoin#7934
  - Just the benchmark, not the performance improvements.
- bitcoin/bitcoin#8039
- bitcoin/bitcoin#8107
- bitcoin/bitcoin#8115
- bitcoin/bitcoin#8914
  - Required resolving several merge conflicts in code that had been refactored upstream. The changes were simple enough that I decided it was okay to impose merge conflicts on pulling in those refactors later.
- bitcoin/bitcoin#9200
- bitcoin/bitcoin#9202
  - Adds support for measuring CPU cycles, which is later removed in an upstream PR after the refactor. I am including it to reduce future merge conflicts.
- bitcoin/bitcoin#9281
  - Only changes to `src/bench/bench.cpp`
- bitcoin/bitcoin#9498
- bitcoin/bitcoin#9712
- bitcoin/bitcoin#9547
- bitcoin/bitcoin#9505
  - Just the benchmark, not the performance improvements.
- bitcoin/bitcoin#9792
  - Just the benchmark, not the performance improvements.
- bitcoin/bitcoin#10272
- bitcoin/bitcoin#10395
  - Only changes to `src/bench/`
- bitcoin/bitcoin#10735
  - Only changes to `src/bench/base58.cpp`
- bitcoin/bitcoin#10963
- bitcoin/bitcoin#11303
  - Only the benchmark backend change.
- bitcoin/bitcoin#11562
- bitcoin/bitcoin#11646
- bitcoin/bitcoin#11654

This pulls in all changes to the micro-benchmark framework prior to December 2017, when it was rewritten. The rewrite depends on other upstream PRs we have not pulled in yet.

This does not pull in all benchmarks prior to December 2017. It leaves out benchmarks that either test code we do not have yet (except for the `FastRandomContext` refactor, which I decided to pull in), or would require rewrites to work with our changes to the codebase.
2020-01-24 23:39:50 +00:00
Homu 599ebb9686 Auto merge of #3742 - defuse:pow-security-improvements, r=str4d
Equihash Macro and Testing Improvements
2020-01-24 20:52:30 +00:00
zancas d2c24e47ba
update comment, to correctly specify number of methods injected 2020-01-23 19:26:17 -07:00
Cory Fields 204384c016 build: Split hardening/fPIE options out
This allows for fPIE to be used selectively.

Zcash: Second half of upstream commit 17c4d9d1647bbac4b0557136b1c3d98c951feb79
First half was pulled in as c459de2f03
2020-01-22 21:41:28 +00:00
practicalswift 9f94f493f5 Initialize recently introduced non-static class member lastCycles to zero in constructor
lastCycles was introduced in 35328187463a7078b4206e394c21d5515929c7de which was merged into master yesterday.

Also initialize beginCycles to zero for consistency and completeness.
2020-01-22 21:41:28 +00:00
Matt Corallo 3182cde049 Require a steady clock for bench with at least micro precision 2020-01-22 21:41:28 +00:00
Cory Fields 671432ca2a bench: prefer a steady clock if the resolution is no worse 2020-01-22 21:41:28 +00:00
Cory Fields 101cab5ce3 bench: switch to std::chrono for time measurements
std::chrono removes portability issues.

Rather than storing doubles, store the untouched time_points. Then
convert to nanoseconds for display. This allows for maximum precision, while
keeping results comparable between differing hardware/operating systems.

Also, display full nanosecond counts rather than sub-second floats.
2020-01-22 21:41:28 +00:00
Matt Corallo 3954f0cdc0 Remove countMaskInv caching in bench framework
We were saving a div by caching the inverse as a float, but this
ended up requiring a int -> float -> int conversion, which takes
almost as much time as the difference between float mul and div.

There are lots of other more pressing issues with the bench
framework which probably require simply removing the adaptive
iteration count stuff anyway.
2020-01-22 21:41:28 +00:00
practicalswift 550cb05f94 Restore default format state of cout after printing with std::fixed/setprecision 2020-01-22 21:41:28 +00:00
practicalswift 95b6695ba2 Avoid static analyzer warnings regarding uninitialized arguments
Avoid static analyzer warnings regarding "Function call argument
is a pointer to uninitialized value" in cases where we are
intentionally using such arguments.

This is achieved by using ...

`f(b.begin(), b.end())` (`std::array<char, N>`)

... instead of ...

`f(b, b + N)` (`char b[N]`)

Rationale:
* Reduce false positives by guiding static analyzers regarding our
  intentions.

Before this commit:

```
$ clang-tidy-3.5 -checks=* src/bench/base58.cpp
bench/base58.cpp:23:9: warning: Function call argument is a pointer to uninitialized value [clang-analyzer-core.CallAndMessage]
        EncodeBase58(b, b + 32);
        ^
$ clang-tidy-3.5 -checks=* src/bench/verify_script.cpp
bench/verify_script.cpp:59:5: warning: Function call argument is a pointer to uninitialized value [clang-analyzer-core.CallAndMessage]
    key.Set(vchKey, vchKey + 32, false);
    ^
$
```

After this commit:

```
$ clang-tidy-3.5 -checks=* src/bench/base58.cpp
$ clang-tidy-3.5 -checks=* src/bench/verify_script.cpp
$
```

Zcash: Only applied changes to src/bench/base58.cpp
2020-01-22 21:41:28 +00:00
practicalswift 0c89713553 Replace boost::function with std::function (C++11)
Zcash: Only applied changes to src/bench/
2020-01-22 21:41:28 +00:00
Pavel Janík f84f56610e Prevent warning: variable 'x' is uninitialized 2020-01-22 21:41:28 +00:00
Pieter Wuille 8f23ab088d FastRandom benchmark 2020-01-22 21:41:28 +00:00
Pieter Wuille 2070adad85 Introduce FastRandomContext::randbool() 2020-01-22 21:41:28 +00:00
Jeremy Rubin a908ba71c4 Add prevector destructor benchmark 2020-01-22 21:41:28 +00:00
practicalswift 2edcfea7da Assert that what might look like a possible division by zero is actually unreachable 2020-01-22 21:41:28 +00:00
Wladimir J. van der Laan f619b42ca9 bench: Fix initialization order in registration
The initialization order of global data structures in different
implementation units is undefined. Making use of this is essentially
gambling on what the linker does, the so-called [Static initialization
order fiasco](https://isocpp.org/wiki/faq/ctors#static-init-order).

In this case it apparently worked on Linux but failed on OpenBSD and
FreeBSD.

To create it on first use, make the registration structure local to
a function.

Fixes #8910.
2020-01-22 21:41:28 +00:00
Jeremy Rubin f53305ec8a Address ryanofsky feedback on CCheckQueue benchmarks. Eliminated magic numbers, fixed scoping of vectors (and memory movement component of benchmark). 2020-01-22 21:41:28 +00:00
Jeremy Rubin 7e1cebe44f Add Basic CheckQueue Benchmark 2020-01-22 21:41:28 +00:00
Karl-Johan Alm d2b7c97cb5 Refactoring: Removed using namespace <xxx> from bench/ and test/ source files.
Zcash: Only apply changes to src/bench/bench.cpp
2020-01-22 21:41:28 +00:00
Wladimir J. van der Laan 2561e2664d bench: Add support for measuring CPU cycles
This adds cycle min/max/avg to the statistics.

Supported on x86 and x86_64 (natively through rdtsc), as well as Linux
(perf syscall).
2020-01-22 21:41:28 +00:00
Wladimir J. van der Laan 7266c84e16 bench: Fix subtle counting issue when rescaling iteration count
Make sure that the count is a zero modulo the new mask before
scaling, otherwise the next time until a measure triggers
will take only 1/2 as long as accounted for. This caused
the 'min time' to be potentially off by as much as 100%.
2020-01-22 21:41:28 +00:00
Wladimir J. van der Laan 957e5d216f Kill insecure_random and associated global state
There are only a few uses of `insecure_random` outside the tests.
This PR replaces uses of insecure_random (and its accompanying global
state) in the core code with an FastRandomContext that is automatically
seeded on creation.

This is meant to be used for inner loops. The FastRandomContext
can be in the outer scope, or the class itself, then rand32() is used
inside the loop. Useful e.g. for pushing addresses in CNode or the fee
rounding, or randomization for coin selection.

As a context is created per purpose, thus it gets rid of
cross-thread unprotected shared usage of a single set of globals, this
should also get rid of the potential race conditions.

- I'd say TxMempool::check is not called enough to warrant using a special
  fast random context, this is switched to GetRand() (open for
  discussion...)

- The use of `insecure_rand` in ConnectThroughProxy has been replaced by
  an atomic integer counter. The only goal here is to have a different
  credentials pair for each connection to go on a different Tor circuit,
  it does not need to be random nor unpredictable.

- To avoid having a FastRandomContext on every CNode, the context is
  passed into PushAddress as appropriate.

There remains an insecure_random for test usage in `test_random.h`.

Zcash: Resolved conflicts with the following files

	src/addrman.cpp
	src/main.cpp
	src/net.cpp
	src/net.h
	src/policy/fees.cpp
	src/policy/fees.h
	src/random.cpp
	src/test/merkle_tests.cpp
	src/test/net_tests.cpp
	src/test/prevector_tests.cpp
	src/test/sighash_tests.cpp
	src/test/skiplist_tests.cpp
	src/test/test_bitcoin.cpp
	src/test/versionbits_tests.cpp
	src/wallet/test/crypto_tests.cpp
2020-01-22 21:41:26 +00:00
Gregory Maxwell d442711d58 Avoid integer division in the benchmark inner-most loop.
Previously the benchmark code used an integer division (%) with
 a non-constant in the inner-loop.  This is quite slow on many
 processors, especially ones like ARM that lack a hardware divide.

Even on fairly recent x86_64 like haswell an integer division can
 take something like 100 cycles-- making it comparable to the
 runtime of siphash.

This change avoids the division by using bitmasking instead. This
 was especially easy since the count was only increased by doubling.

This change also restarts the timing when the execution time was
 very low this avoids mintimes of zero in cases where one execution
 ends up below the timer resolution. It also reduces the impact of
 the overhead on the final result.

The formatting of the prints is changed to not use scientific
 notation make it more machine readable (in particular, gnuplot
 croaks on the non-fixedpoint, and it doesn't sort correctly).

This also hoists out all the floating point divisions out of the
 semi-hot path because it was easy to do so.

It might be prudent to break out the critical test into a macro
 just to guarantee that it gets inlined.  It might also make sense
 to just save out the intermediate counts and times and get the
 floating point completely out of the timing loop (because e.g.
 on hardware without a fast hardware FPU like some ARM it will
 still be slow enough to distort the results). I haven't done
 either of these in this commit.
2020-01-22 21:40:38 +00:00
Yuri Zhykin 9585d5a64f bench: Added base58 encoding/decoding benchmarks 2020-01-22 21:40:38 +00:00
Wladimir J. van der Laan 6daf01e402 bench: Add crypto hash benchmarks
Add benchmarks for the cryptographic hash algorithms:

- RIPEMD160
- SHA1
- SHA256
- SHA512

Continues work on #7883.
2020-01-22 21:40:38 +00:00
Pieter Wuille 3161960fc2 Benchmark rolling bloom filter 2020-01-22 21:40:38 +00:00
Philip Kaufmann e72de1864f [Trivial] ensure minimal header conventions
- ensure header namespaces and end comments are correct
- add missing header end comments
- ensure minimal formatting (add newlines etc.)

Zcash: left out change to src/policy/policy.h which we don't yet have.
2020-01-22 21:40:38 +00:00
Pavel Janík 9233b8a15e Ignore bench_bitcoin binary. 2020-01-22 21:40:38 +00:00
Gavin Andresen a81da44a8f Support very-fast-running benchmarks
Avoid calling gettimeofday every time through the benchmarking loop, by keeping
track of how long each loop takes and doubling the number of iterations done
between time checks when they take less than 1/16'th of the total elapsed time.
2020-01-22 21:40:38 +00:00
Gavin Andresen d7a20b6373 Simple benchmarking framework
Benchmarking framework, loosely based on google's micro-benchmarking
library (https://github.com/google/benchmark)

Wny not use the Google Benchmark framework? Because adding Even More Dependencies
isn't worth it. If we get a dozen or three benchmarks and need nanosecond-accurate
timings of threaded code then switching to the full-blown Google Benchmark library
should be considered.

The benchmark framework is hard-coded to run each benchmark for one wall-clock second,
and then spits out .csv-format timing information to stdout. It is left as an
exercise for later (or maybe never) to add command-line arguments to specify which
benchmark(s) to run, how long to run them for, how to format results, etc etc etc.
Again, see the Google Benchmark framework for where that might end up.

See src/bench/MilliSleep.cpp for a sanity-test benchmark that just benchmarks
'sleep 100 milliseconds.'

To compile and run benchmarks:
  cd src; make bench

Sample output:

Benchmark,count,min,max,average
Sleep100ms,10,0.101854,0.105059,0.103881
2020-01-22 21:40:35 +00:00
Alfredo Garcia 76a43b6790 Return address and type of imported key in z_importkey
Co-authored-by: Dagur Valberg Johannsson <dagurval@pvv.ntnu.no>
2020-01-22 14:41:02 -03:00
Alfredo Garcia 3fb8af512c change regex 2020-01-21 21:24:21 -03:00
Alfredo Garcia 5e6d43a3ac minor fix 2020-01-20 18:39:10 -03:00
Alfredo Garcia 7cb45243fe change convention 2020-01-20 12:23:52 -03:00
Alfredo Garcia 30ad88cf4c add status to transactions 2020-01-19 14:30:56 -03:00
Sean Bowe 5133275342
make-release.py: Versioning changes for 2.1.1. 2020-01-17 10:26:14 -07:00
Alfredo Garcia d8eb0b96bc add additional tests to rpc_wallet_z_getnewaddress 2020-01-17 10:30:14 -03:00
Dagur Valberg Johannsson 61bb241bd3 Improve z_getnewaddress tests 2020-01-17 09:35:11 -03:00
Sean Bowe 846868f0c7
make-release.py: Versioning changes for 2.1.1-rc2. 2020-01-13 17:55:01 -07:00
Alfredo Garcia 574963ef87 update docs 2020-01-12 11:06:46 -03:00
Daira Hopwood 7eb5c49d32 Remove temporary workaround for deprecation height.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-01-08 06:14:05 +00:00
Sean Bowe 2c88a156ba
make-release.py: Versioning changes for 2.1.1-rc1. 2020-01-07 20:13:03 -07:00
Homu 043ce3f2ac Auto merge of #3912 - bitcartel:fix_getwalletinfo_help_message, r=daira
Closes #3911. Fix help message of RPC getwalletinfo.
2020-01-06 04:37:09 +00:00
Homu efab5aaca4 Auto merge of #4281 - LarryRuane:test-fixes-enable-debug, r=daira
fix tests for enable-debug build

Addresses part of #4275.
2020-01-06 03:29:34 +00:00
Homu 6a08c22567 Auto merge of #4277 - sandakersmann:master, r=daira
Update copyright year to 2020

Update copyright year to 2020
2020-01-05 20:49:00 +00:00
Larry Ruane 7b5148cc64 fix tests for enable-debug build 2019-12-31 12:18:16 -07:00
Alfredo Garcia fce6000f76 allow negative index to getblockhash 2019-12-31 09:35:37 -03:00
Alfredo Garcia 3ac6dd5f5d add negative height to getblock 2019-12-31 09:16:29 -03:00
Larry Ruane 14ec1016b9 insightexplorer: LOCK(cs_main) during rpcs 2019-12-27 10:21:46 -07:00
sandakersmann 91b8de9151
Update COPYRIGHT_YEAR in clientversion.h to 2020 2019-12-27 18:01:51 +01:00
Pieter Wuille 82eefce0ab
Use anonymous namespace instead of static functions 2019-12-18 18:59:15 -06:00
Pieter Wuille e82901f4fd
Do not treat bare multisig as IsMine
Such outputs can still be watched, and signed for, but they aren't treated as valid payments.
That means they won't cause transactions to appear in listtransactions, their outputs to be
shown under listunspent, or affect balances.
2019-12-18 18:59:15 -06:00
Pieter Wuille 84b4bdbb51
Track difference between scriptPubKey and P2SH execution in IsMine
Inside IsMine we care about the distinction between scriptPubKey execution
and P2SH redeemScript execution. The consensus code does not care about this
distinction, and thus SigVersion does not have a field for P2SH. As the IsMine
code will care, it uses a separate enum with more fields.
2019-12-18 18:59:15 -06:00
Pieter Wuille 36f067bb95
Switch to a private version of SigVersion inside IsMine
This will allow us to have the consensus code and IsMine code diverge.
2019-12-18 18:59:15 -06:00
Pieter Wuille 030e173d98
Do not expose SigVersion argument to IsMine
Only IsMine's internal code needs this, as part of a recursion into P2SH and P2WSH
scripts. The exposed functions always operate on actual scriptPubKeys and not on
redeemScripts or witness scripts.

Zcash: Rewrote this commit so that it instead adds an internal
SigVersion argument (which we didn't have because it was added to
support SegWit logic).

Co-authored-by: Jack Grigg <jack@z.cash>
2019-12-18 18:59:15 -06:00
Pieter Wuille df00e51e3e
Make CScript -> CScriptID conversion explicit
Zcash: Excludes changes to importwallet (missing bitcoin/bitcoin#11667)
and ProcessImport (missing bitcoin/bitcoin#7551).
2019-12-18 18:59:15 -06:00
Jim Posen de9c679770
[script] Unit tests for IsMine
Does not test watch-only addresses.

Zcash: Excluding SegWit tests and isInvalid code (which is part of the
SegWit support structure).
2019-12-18 18:59:15 -06:00
Jim Posen bf2c8b3bc6
[script] Unit tests for script/standard functions
Zcash: Excluding unit tests for SegWit logic.
2019-12-18 18:59:15 -06:00
Pieter Wuille 9ed1fe9c6b
Stop treating importaddress'ed scripts as change
Before this, if someone imported a scriptPubKey directly (in hex form) using
importaddress, outputs sending to it would be treated as change, as the
corresponding CTxDestination was not added to the address book.

Fix this by trying to detect scriptPubKeys that are in fact convertible to a
CTxDestination and add them anyway. Add a warning to the RPC help to warn
against importing raw non-standard scripts.
2019-12-18 18:59:15 -06:00
Homu fa341bcff0 Auto merge of #4270 - str4d:2074-wallet-2, r=str4d
Bitcoin wallet PRs 2

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7576
- bitcoin/bitcoin#7577
- bitcoin/bitcoin#7608
- bitcoin/bitcoin#7691
- bitcoin/bitcoin#7905
2019-12-18 23:53:21 +00:00
Wladimir J. van der Laan e42359dcbf
test: Rename wallet.dat to wallet_test.dat
Indicate that the file name is not hardcoded, and a little bit of safety
so that it never nukes the main wallet.

Suggestion by Marco Falke.
2019-12-18 16:50:29 -06:00
Wladimir J. van der Laan 3782c4d6ab
wallet_ismine.h → script/ismine.h
Removes conditional dependency of `src/test` on wallet.

Makes multisig and P2SH tests complete without wallet built-in.
2019-12-18 16:50:29 -06:00
Wladimir J. van der Laan 91f0b506ca
test: Create test fixture for wallet
Removes all the `#ifdef ENABLE_WALLET` from `test_bitcoin` by
making the wallet tests use their own fixture.
2019-12-18 16:50:29 -06:00
Wladimir J. van der Laan 994a51d4d7
test: move accounting_tests and rpc_wallet_tests to wallet/test
Move the two other wallet tests to where they belong.
2019-12-18 16:50:29 -06:00
Jonas Schnelli 6c1b6c8ccc
[Wallet] refactor wallet/init interaction 2019-12-18 16:50:29 -06:00
MarcoFalke 8822e4e135
[wallet] Move hardcoded file name out of log messages 2019-12-18 16:50:29 -06:00
Jonas Schnelli 5b376b5125
[Wallet] optimize return value of InitLoadWallet() 2019-12-18 16:50:29 -06:00
Jonas Schnelli c3ca0163a8
[Wallet] move "load wallet phase" to CWallet
Zcash: Modified to move our modifications to "load wallet phase".
2019-12-18 16:50:29 -06:00
Jonas Schnelli 8dacb764bc
[Wallet] move wallet help string creation to CWallet 2019-12-18 16:50:29 -06:00
Homu 0a31c163c6 Auto merge of #4252 - str4d:wallet-interface-refactor, r=str4d
Wallet interface refactor

This refactors the logic introduced in #4144 to improve the separation between the node and wallet. The notifier thread now lives next in `src/validationinterface.cpp` directly next to the existing `CMainSignals` node-wallet interface.

Part of #3877.
2019-12-18 22:48:26 +00:00
Jack Grigg 8af85a0d10
Extend comment with reason for taking care with locks 2019-12-18 15:06:54 -06:00
Jack Grigg 03db5c8ca3
Tie sync_blocks in RPC tests to notifier thread 2019-12-18 15:06:54 -06:00
Jack Grigg 9771506acd
Move block-notifying logic into ThreadNotifyWallets 2019-12-18 15:06:54 -06:00
Jack Grigg a71a7341b9
Merge tree and boolean fields in ChainTip API
The trees were being unnecessarily fetched during DisconnectTip.
2019-12-18 15:06:54 -06:00
Jack Grigg a28916d273
Move mempool tx notifying logic out of CTxMemPool
ThreadNotifyWallets now collects all notification-related state at once,
and then executes wallet logic based on the collected state after
dropping any locks it is holding.
2019-12-18 15:06:54 -06:00
Jack Grigg 2c8dff00cc
ThreadNotifyRecentlyAdded -> ThreadNotifyWallets 2019-12-18 15:06:54 -06:00
Denis Lukianov 136e1c09ab
Correct importaddress help reference to importpubkey 2019-12-17 12:18:50 -06:00
MarcoFalke 49a2cbee98
Make sure LogPrintf strings are line-terminated 2019-12-17 12:18:50 -06:00
MarcoFalke f4caccc6ef
Fix doxygen comment for payTxFee 2019-12-17 12:18:50 -06:00
Luke Dashjr 996d6c3f54
Common argument defaults for NODE_BLOOM stuff and -wallet 2019-12-17 12:18:50 -06:00
MarcoFalke 9e4362a486
[doxygen] Actually display comment 2019-12-17 12:18:50 -06:00