Commit Graph

13660 Commits

Author SHA1 Message Date
Homu 66d4c88943 Auto merge of #4572 - oxarbitrage:issue4571, r=str4d
Add solution rates aproximation to metrics

Closes https://github.com/zcash/zcash/issues/4571
2020-07-10 07:02:14 +00:00
Homu 3f4a532588 Auto merge of #4573 - LarryRuane:issue4301-CopyPreviousWitnesses, r=daira
Flush witness data to disk only when it's consistent

Closes #4301. Running this PR's code will not repair a data directory that has been affected by this problem; that requires starting zcashd with the `-rescan` or `-reindex` options.
2020-07-09 11:50:41 +00:00
Larry Ruane 4811dcc426 sync before stopping nodes
This makes the test more deterministic. When the nodes are split, and
partition B (node 1) mines a joinsplit transaction, that block only
sometimes appears on the blockchain after the nodes are all reconnected.
2020-07-08 20:48:50 -06:00
Homu 701adc38cb Auto merge of #4578 - therealyingtong:zip212-impl, r=str4d
ZIP212 implementation

Closes #4557.
(description by @ebfull, taken from #4575)

* The `SaplingNote` structure has a new enum called `zip212Enabled`. This
  member is private and reflects whether the note was or is being created
  using the derivation method of ZIP 212 (i.e., `BeforeZip212` or `AfterZip212`).
* The `SaplingNotePlaintext` structure has a new unsigned char member
  `leadbyte`. This member is private and contains the leading byte of the
  plaintext (e.g. `0x01`, `0x02`).
* The serialization of `SaplingNotePlaintext` sets `zip212Enabled` to
  `BeforeZip212` iff the serialized note plaintext version is not `0x01`.
* The `r`/`rcm` fields have been removed and replaced with a private field
  `rseed`. `SaplingNote` and `SaplingNotePlaintext` now have a helper method
  `rcm()` which returns the `rcm` either by deriving it with `rseed`
  (if `zip212Enabled` is `AfterZip212`) or returning `rseed` by interpreting
  `rseed` as `rcm`.
* All the methods of obtaining a `SaplingNote` account for these changes:
  - The `SaplingNote` constructor that is used by e.g. the transaction builder,
    and internally samples random `rcm`, now takes a `zip212Enabled` argument
    to decide whether to sample `rcm` the "old" way or the "new" way.
  - The bare constructor for `SaplingNote` is removed.
  - The other constructor which takes the raw contents of the note is only used
    in tests or in `Note.cpp`, but now also takes a `zip212Enabled` argument.
  - The other way of obtaining a note, by calling `SaplingNotePlaintext::note()`,
    has been adjusted.
* The `SaplingNotePlaintext` class now has an `generate_or_derive_esk()` method
  that either samples a random `esk` or derives it using the local `rseed`
  depending on the value of `leadbyte`.
* The encryption routine is modified to consult `generate_or_derive_esk()` and
  provide it to the note encryption object.
* The note encryption objects now take an optional `esk` as input and otherwise
  sample a random `esk` internally. This API functionality is preserved to allow
  for testing.
* The `SaplingNotePlaintext` decryption routines are modified:
  - The out and enc decryption routines now check that `epk` is consistent with
    the derived `esk`.
  -  The out decryption routine for plaintexts also checks that `esk` is
    consistent with what is derived by the note.
* The miner and transaction builder consult the activation of Canopy when
  creating `SaplingNote`s.
* The consensus rules are modified so that shielded outputs (miner rewards)
  must have `v2` note plaintexts after Canopy has activated.
2020-07-09 00:29:07 +00:00
Larry Ruane 872af58d59 undo flushing witness data on shutdown
This fixes wallet_anchorfork.py CI failure, but a separate PR
will restore flushing witness data on shutdown while also
fixing DecrementNoteWitnesses() to not assert when
nd->witnessHeight < indexHeight, which can happen when the
node reorgs upon restart (which this test causes to happen).
2020-07-08 07:50:48 -06:00
therealyingtong dde5cc87b7 Directly call RegtestActivate* in gtests
Co-authored by Jack Grigg (jack@electriccoin.co)
2020-07-08 12:53:03 +08:00
therealyingtong 1020254b6a Pass nHeight instead of pindex to AddToWalletIfInvolvingMe()
Co-authored by Jack Grigg (jack@electriccoin.co) and Sean Bowe (ewillbefull@gmail.com)
2020-07-08 12:53:03 +08:00
therealyingtong 119bae082c Remove old SaplingNote() constructor 2020-07-08 12:53:03 +08:00
therealyingtong 31020d6fc9 Minor changes
Co-authored by Daira Hopwood (daira@jacaranda.org) and Jack Grigg (jack@electriccoin.co)
2020-07-08 12:53:01 +08:00
Homu 1192116598 Auto merge of #4581 - ebfull:zip215-impl-2, r=str4d
ZIP 215 Implementation

This is accompanied by 8c97acde89.
2020-07-07 21:39:49 +00:00
Sean Bowe 249de0808d
Remove outdated comment. 2020-07-03 10:24:35 -06:00
Sean Bowe a9d80b0750
Hash "Zcash" to align tests with ZIP 215 test vectors. 2020-07-03 10:20:37 -06:00
Sean Bowe c3b3e07160
Change LIBSODIUM_ERROR to -1.
We only relied on success being 0 and our code was otherwise agnostic to the
actual return code in the event of failed signature verification, but this
change keeps the API consistent.
2020-07-03 09:37:34 -06:00
Sean Bowe 394947de3a
Migrate ZIP 215 test vectors to gtest suite. 2020-07-03 09:36:34 -06:00
therealyingtong c4821ddceb Refactor bool is_zip_212 to enum Zip212Enabled
Co-authored by Kris Nuttycombe (@nuttycom)
2020-07-03 06:59:21 +08:00
therealyingtong eeda663ff7 Remove plaintext check from GetFilteredNotes
Co-authored by Sean Bowe (ewillbefull@gmail.com)
2020-07-03 06:59:06 +08:00
therealyingtong ee83424c6f Remove plaintext check from AddSaplingSpend
Co-authored by Sean Bowe (ewillbefull@gmail.com)
2020-07-03 06:57:57 +08:00
Homu 602e88ddb9 Auto merge of #4489 - therealyingtong:4479-remove-sprout-shielding, r=str4d
[ZIP 211] Disabling Addition of New Value to the Sprout Value Pool

Disables Sprout outputs after NU4 by checking for nonzero `vpub_old` in transactions after NU4 activation height.

Adds gtests to check expected behaviour before and after NU4 activation height.

edit:
Also modifies `z_` methods in `rpcwallet`, and adds a matching RPC test.

Implements [ZIP 211](https://zips.z.cash/zip-0211), closes #4479
2020-07-02 21:53:51 +00:00
Larry Ruane bf568273a7 fix pyflakes CI errors 2020-07-02 14:32:48 -06:00
Sean Bowe 14a09a5fd6
Remove unused imports from remove_sprout_shielding RPC test. 2020-07-02 11:09:22 -06:00
Alfredo Garcia 7db6e37b40 add log aporximation to metrics solution rates 2020-07-02 13:34:07 -03:00
therealyingtong 19d4c47b66 Pass pindex to AddToWalletIfInvolvingMe() 2020-07-02 15:37:37 +08:00
therealyingtong 2f4d7e35c9 Throw error in plaintext deserialization 2020-07-02 15:37:37 +08:00
therealyingtong f24e706079 Replace leadByte in SaplingNote with is_zip_212 2020-07-02 15:37:32 +08:00
Larry Ruane 5b7fed5bbf self.sync_all(), not time.sleep(4) 2020-07-01 10:28:15 -06:00
Kris Nuttycombe 7dd1889944 Trivial copyright fix.
Co-authored-by: str4d <thestr4d@gmail.com>
2020-07-02 00:27:18 +08:00
therealyingtong 5e4d13b49d Add RPC tests
Test that Sprout shielding is accepted before Canopy and rejected after Canopy activation
2020-07-02 00:27:14 +08:00
therealyingtong 1c59f06df0 Add checks to z_ methods in rpcwallet
Disallow Sprout shielding after Canopy in z_sendmany, z_shieldcoinbase, z_mergetoaddress, and zc_raw_joinsplit (deprecated)
2020-07-01 23:47:36 +08:00
therealyingtong 2a2fc2a16f Add gtests
Should accept Sprout shielding before NU4 but reject it afterwards
2020-07-01 23:31:41 +08:00
therealyingtong 01cdea54ee Add contextual check to main.cpp
Reject transactions with nonzero vpub_old after NU4
2020-07-01 23:31:36 +08:00
Homu eed865052b Auto merge of #4579 - rvagg:rvagg/joinSplitRPC, r=str4d
Add joinSplitPubKey and joinSplitSig to RPC

These two properties are required to fully reconstruct a Zcash transaction's binary form from the RPC data.
2020-06-30 23:02:47 +00:00
Rod Vagg a106c15a19
Add joinSplitPubKey and joinSplitSig to RPC
These two properties are required to fully reconstruct a Zcash
transaction's binary form from the RPC data.

Co-authored-by: str4d <thestr4d@gmail.com>
2020-06-30 21:47:51 +10:00
Sean Bowe e9c065df5b
Cargo fmt 2020-06-29 09:40:35 -06:00
Sean Bowe 8918eca876
Add more exhaustive tests for ZIP 215 compatibility. 2020-06-29 09:40:34 -06:00
Sean Bowe 58250b4801
Turn return values for libsodium-like API into constants for clarity. 2020-06-29 09:36:54 -06:00
Larry Ruane 73fae6bf0a review, cleanup: eliminate uninitialized variable 2020-06-25 09:32:36 -06:00
therealyingtong 7a1d119170 Add gtests for v2 plaintexts 2020-06-25 09:12:24 +08:00
therealyingtong 6402c589c6 Refactor SaplingNotePlaintext::decrypt
Break up plaintext decryption into height-dependent and non-height-dependent parts.
2020-06-25 09:12:24 +08:00
therealyingtong 3c8e970358 Check epk vs esk whenever caller has esk 2020-06-25 09:12:24 +08:00
therealyingtong e060d59890 Reject v1 plaintexts after grace period
SaplingNotePlaintext::decrypt() now has to be aware of consensus params and blockheight. Its callers in wallet, rpcwallet, and tests are updated accordingly.

TransactionBuilder is also modified to reject invalid leadBytes.

Co-authored by Daira Hopwood (daira@jacaranda.org)
2020-06-25 09:12:21 +08:00
Sean Bowe 56d4ef8333 Make transaction builder take the next block height into account for use of v2 note plaintexts. 2020-06-25 09:11:43 +08:00
Sean Bowe 4af761121d Require that shielded coinbase output note plaintexts are version 2 if Canopy is active.
Co-authored by Ying Tong (yingtong@electriccoin.co)
2020-06-25 09:11:31 +08:00
Homu ab2b7c0969 Auto merge of #4566 - gtank:new_seeders, r=ebfull
Add Foundation's and gtank's DNS seeders

This adds our new DNS seeders to the list. They're running [CoreDNS](https://coredns.io) with a [Zcash crawler plugin](https://github.com/ZcashFoundation/dnsseeder), the result of a Zcash Foundation in-house development effort to replace zcash-seeder with something memory safe and easier to maintain.

These are validly operated seeders per the existing policy (https://zcash.readthedocs.io/en/latest/rtd_pages/dnsseed_policy.html):

> A DNS seed operating organization or person is expected to follow good host security practices, maintain control of applicable infrastructure, and not sell or transfer control of the DNS seed. Any hosting services contracted by the operator are equally expected to uphold these expectations.

In both cases the code is running on well-operated public cloud infrastructure in either a container or the most sandboxing appropriate to the environment. The DNS records pointing to the seeders are controlled by reputable third-party DNS providers under accounts with 2FA enabled.

> The DNS seed results must consist exclusively of fairly selected and functioning Zcash nodes from the public network to the best of the operator’s understanding and capability.

The crawler attempts to connect to all discoverable Zcash peers and ensures their continued uptime on a regular basis. The results are always a uniformly randomized subset of all known live peers.

> For the avoidance of doubt, the results may be randomized but must not single out any group of hosts to receive different results unless due to an urgent technical necessity and disclosed.

See above. However, we reserve the right to begin offering [NU-targeted results](https://github.com/ZcashFoundation/dnsseeder/issues/3) based on opt-in client queries.

> The results may not be served with a DNS TTL of less than one minute.

Mainnet results are served with a TTL of 600 seconds, and Testnet results with a TTL of 300 seconds to account for greater flux on that network.

> Any logging of DNS queries should be only that which is necessary for the operation of the service or urgent health of the Zcash network and must not be retained longer than necessary nor disclosed to any third party.

There is no logging of DNS queries in either production configuration, which can be somewhat confirmed by examining the Corefile(s) [[1]](https://github.com/ZcashFoundation/coredns-zcash/blob/master/coredns/Corefile)[[2]](https://github.com/ZcashFoundation/coredns-zcash/blob/master/scripts/gcp-start.sh#L9-L27) we use.

> Information gathered as a result of the operators node-spidering (not from DNS queries) may be freely published or retained, but only if this data was not made more complete by biasing node connectivity (a violation of expectation (1)).

The seeder currently has no persistence outside of its static config file, so this data is neither retained nor shared by the operators.

> Operators are encouraged, but not required, to publicly document the details of their operating practices.

Our deployments are described in detail by the [coredns-zcash](https://github.com/ZcashFoundation/coredns-zcash) repo. Reader, you could run one too!

> A reachable email contact address must be published for inquiries related to the DNS seed operation.

For general questions related to either seeder, contact george@zfnd.org or mention @gtank in the Foundation's Discord. For bug reports, open an issue on the [dnsseeder](https://github.com/ZcashFoundation/dnsseeder) repo.
2020-06-25 00:44:33 +00:00
Larry Ruane 0219a97139 flush witness cache correctly
Rather than flushing the witness cache from FlushStateToDisk(), called
by ActivateBestChain() called by ProcessNewBlock(), do so from
ThreadNotifyWallets() after the wallet has updated the in-memory witness
data according to the new block, so it's always consistent on disk.
2020-06-24 16:49:59 -06:00
Sean Bowe 98c6bdbae8
Redirect git checkouts of ebfull/ed25519-zebra through our vendored sources in offline mode. 2020-06-24 14:08:25 -06:00
Homu a23aa9113e Auto merge of #4582 - daira:remove-cs_ParamsIO, r=daira
Remove an unused CCriticalSection.

The code that used this was removed in 5f84491d82.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-06-24 19:04:38 +00:00
Larry Ruane 6335944784 add python test to reproduce bug 4301 2020-06-24 09:27:11 -06:00
Sean Bowe f29c731915
Minor adjustments to librustzcash and tests. 2020-06-23 16:35:19 -06:00
Sean Bowe ba04450945
Remove unused curve25519-dalek dev-dependency. 2020-06-23 16:29:51 -06:00
Sean Bowe 14bdf7e811
Remove bincode crate. 2020-06-23 15:38:59 -06:00