Commit Graph

1393 Commits

Author SHA1 Message Date
Deirdre Connolly 915372e6a2 Correctly computing empty internal nodes in the Sapling note commitment tree 2020-10-05 23:43:23 -04:00
Deirdre Connolly b93abea34f Incomplete impl of Sapling note commitment merkle tree 2020-10-05 23:43:23 -04:00
Deirdre Connolly 568edb54e6 Add merkle_crh_sprout() and tidy note* things 2020-10-05 23:43:23 -04:00
Dimitris Apostolou 36279621f0 Fix typos 2020-10-06 12:16:41 +10:00
teor b05273ac16
State RFC: remove duplicate validation steps (#1123) 2020-10-05 19:03:17 -07:00
dependabot[bot] b473476a4a build(deps): bump pin-project from 0.4.25 to 0.4.26
Bumps [pin-project](https://github.com/taiki-e/pin-project) from 0.4.25 to 0.4.26.
- [Release notes](https://github.com/taiki-e/pin-project/releases)
- [Changelog](https://github.com/taiki-e/pin-project/blob/master/CHANGELOG.md)
- [Commits](https://github.com/taiki-e/pin-project/compare/v0.4.25...v0.4.26)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-05 11:27:06 -04:00
dependabot[bot] d769f62a73 build(deps): bump color-eyre from 0.5.5 to 0.5.6
Bumps [color-eyre](https://github.com/yaahc/color-eyre) from 0.5.5 to 0.5.6.
- [Release notes](https://github.com/yaahc/color-eyre/releases)
- [Changelog](https://github.com/yaahc/color-eyre/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yaahc/color-eyre/compare/v0.5.5...v0.5.6)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-05 11:26:23 -04:00
Jane Lusby 86ed13060f
Add tests for `Chain` implementation (#1093)
* Begin work on RFC5 implementation

* I think this is necessary

* holy shit supertrait implemented via subtrait

* implement most of the chain functions

* change to slightly better name

* implement fork

* fix outpoint handling in Chain struct

* update expect for work

* resolve review comment

* split utxo into two sets

* update the Chain definition

* just a little more

* update comment

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

* apply changes from code review

* remove allow attribute in zebra-state/lib.rs

* Update zebra-state/src/memory_state.rs

Co-authored-by: teor <teor@riseup.net>

* merge ChainSet type into MemoryState

* rename state impl types

* Add error messages to asserts

* checkpoint so I can split off arbitrary changes into a PR

* export proptest impls for use in downstream crates

* add testjob for disabled feature in zebra-chain

* run rustfmt

* try to fix github actions syntax

* differentiate name

* prove that github action tests zebra-chain build without features

* revert change from last commit now that test is running

* remove accidentally introduced newline

* checkpoint

* add module doc comment

* update RFC for utxos

* add missing header

* working proptest for Chain

* apply change from chain impl PR

* setup config for proptests

* Update zebra-chain/src/block/arbitrary.rs

Co-authored-by: teor <teor@riseup.net>

* run rustfmt

Co-authored-by: teor <teor@riseup.net>
2020-10-02 15:51:51 -07:00
dependabot[bot] 1b528404cd build(deps): bump pin-project from 0.4.24 to 0.4.25
Bumps [pin-project](https://github.com/taiki-e/pin-project) from 0.4.24 to 0.4.25.
- [Release notes](https://github.com/taiki-e/pin-project/releases)
- [Changelog](https://github.com/taiki-e/pin-project/blob/master/CHANGELOG.md)
- [Commits](https://github.com/taiki-e/pin-project/compare/v0.4.24...v0.4.25)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-02 11:18:13 -04:00
dependabot[bot] ae362d260e build(deps): bump serde_json from 1.0.57 to 1.0.58
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.57 to 1.0.58.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.57...v1.0.58)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-01 16:56:11 -04:00
dependabot[bot] b5ecafa7bc build(deps): bump chrono from 0.4.18 to 0.4.19
Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.18 to 0.4.19.
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.18...v0.4.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-01 15:09:10 -04:00
teor 2db97ba6e4
Send the final checkpoint block to the checkpoint verifier (#1111)
* Send the final checkpoint block to the checkpoint verifier

Also:
  * route blocks with no height to the block verifier
  * update an incorrect comment

* Add missing {

* rustfmt
2020-09-30 12:53:31 -07:00
teor 41b985ee0b Block test vector comment updates 2020-09-30 07:27:16 +10:00
teor 28b0e5d197 Improve a test failure message 2020-09-29 11:42:00 -04:00
teor 1a7e43a31d Manually rustfmt code inside lazy_static! 2020-09-29 11:42:00 -04:00
teor 58041d8a49 Rename TEST_BLOCKS to BLOCKS
To avoid confusion with TESTNET_BLOCKS.

Automated search and replace, made using this script:

sed -i 's/TEST_BLOCKS/BLOCKS/' \
  $(grep -r TEST_BLOCKS zebra* | cut -d: -f1 | sort -u)
2020-09-29 11:42:00 -04:00
teor a35f36dd0b Split TEST_BLOCKS into mainnet and testnet
And add some basic tests to make sure:
* the heights are correct
* the lists aren't truncated or empty
2020-09-29 11:42:00 -04:00
dependabot[bot] 15c5365ca7 build(deps): bump tracing from 0.1.19 to 0.1.21
Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.19 to 0.1.21.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.19...tracing-0.1.21)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-29 11:01:34 -04:00
teor 5ed27dc8a1 State RFC - handle duplicates of finalized blocks 2020-09-29 12:19:56 +10:00
teor df9252c759 Refactor out push_block_on_chain
And tidy up some error handling and panics
2020-09-29 12:19:56 +10:00
teor b264e24cd0 Panic on all commit_block errors 2020-09-29 12:19:56 +10:00
teor 2d183cbff3 Tweak State RFC to handle edge cases
* Reject CommitBlock with pre-sapling blocks: they must use CommitFinalizedBlock
* Clarify adding a new Chain to an empty ChainSet
* Handle duplicate blocks correctly
2020-09-29 12:19:56 +10:00
Deirdre Connolly 2d9198628c
Use ok_or instead of ok_or_else with unnecessary closure (#1106)
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
2020-09-28 21:10:51 -04:00
dependabot[bot] 2230e353df
Merge pull request #1103 from ZcashFoundation/dependabot/cargo/pin-project-0.4.24
build(deps): bump pin-project from 0.4.23 to 0.4.24
2020-09-28 11:13:11 -07:00
dependabot[bot] bf4ddc1074 build(deps): bump chrono from 0.4.15 to 0.4.18
Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.15 to 0.4.18.
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.15...v0.4.18)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-28 11:13:05 -07:00
teor 6f371f3436
Add block test vectors for each network upgrade (#1096)
* Move block test vectors into separate files
* Refactor block test vectors into their own module
* Remove some duplicate test vector data

* Add mainnet block test vectors for each network upgrade
* Add testnet block test vectors for each network upgrade

* Update the TEST_BLOCKS list
* Add basic tests using TEST_BLOCKS

* Ignore shell.nix
2020-09-28 12:42:06 +10:00
Jane Lusby 352721bd88
Implement RFC5: State updates `Chain` type (#1069)
* Begin work on RFC5 implementation

* I think this is necessary

* holy shit supertrait implemented via subtrait

* implement most of the chain functions

* change to slightly better name

* implement fork

* fix outpoint handling in Chain struct

* update expect for work

* resolve review comment

* split utxo into two sets

* update the Chain definition

* just a little more

* update comment

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

* apply changes from code review

* remove allow attribute in zebra-state/lib.rs

* Update zebra-state/src/memory_state.rs

Co-authored-by: teor <teor@riseup.net>

* merge ChainSet type into MemoryState

* rename state impl types

* Add error messages to asserts

* add module doc comment

* update RFC for utxos

* add missing header

Co-authored-by: teor <teor@riseup.net>
2020-09-24 15:46:04 -07:00
dependabot[bot] d5ce5eeee2 build(deps): bump structopt from 0.3.17 to 0.3.18
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.17 to 0.3.18.
- [Release notes](https://github.com/TeXitoi/structopt/releases)
- [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.17...v0.3.18)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-24 18:25:54 -04:00
Jane Lusby 0b4e974c9e
export proptest impls for use in downstream crates (#1092)
* export proptest impls for use in downstream crates

* add testjob for disabled feature in zebra-chain

* run rustfmt

* try to fix github actions syntax

* differentiate name

* prove that github action tests zebra-chain build without features

* revert change from last commit now that test is running

* remove accidentally introduced newline

* Update .github/workflows/ci.yml

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2020-09-23 18:52:52 -07:00
Jane Lusby 40e22808c7
disable reporting url for timeout errors (#1087)
* disable reporting url for timeout errors

* revert newline removal

* switch to released color-eyre version
2020-09-21 16:15:09 -07:00
Henry de Valence 6dd7318d3b deps: use Tower 0.4 from git instead of 0.3.1.
This addresses at least three pain points:

- we were affected by bugs that were already fixed in git, but not in
  the released crate;
- we can use service combinators to transform requests and responses;
- we can use the hedge middleware.

The version in git is still marked as 0.3.1 but these changes will be
part of tower 0.4: https://github.com/tower-rs/tower/issues/431
2020-09-21 14:16:56 -07:00
Henry de Valence 16cc095484
RFC: state updates (#902)
* wip

Co-authored-by: Jane Lusby <jlusby42@gmail.com>

* wip2: add nullifiers

Co-authored-by: Jane Lusby <jlusby42@gmail.com>

* Update book/src/dev/rfcs/0003-state-updates.md

Co-authored-by: teor <teor@riseup.net>

* Move to RFC number 5

* rfc: add PR link to state update RFC

* rfc: change state RFC to store blocks by height.

The rationale for this change is described in the document: it means
that we write blocks only to one end of the Sled tree, and hopefully
helps us with spatial access patterns.

This should help alleviate a major cause of memory use in Zebra's
current WIP Sled structure, which is that:

- blocks are stored in random, sparse order (by hash) in the B-tree;
- the `Request::GetDepth` method opens the entire block store and
  queries a random part of its block data to determine whether a hash is
  present;
- if present, it deserializes the complete block data of both the given
  block and the current tip block, to compute the difference in block
  heights.

This access pattern forces a large amount of B-tree data to remain
resident, and could probably be avoided if we didn't do that.

* rfc: add sprout and sapling anchors to sled trees.

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>

* rfc: fill in details of state service requests.

* rfc: extract commit process from API description

* rfc: add anchor parameters to CommitBlock.

These have to be computed by a verifier, so passing them as parameters
means we don't recompute them.

* WIP for in memory state structs

* tweeks from end of session with henry

* more updates from pairing

* rewrite non-finalized state sections

* update query instructions for each request

* more updates

* updates from pairing with henry

* updates from proofreading solo

* add guide level explanation to state rfc

* add drawbacks section

* Update book/src/dev/rfcs/0005-state-updates.md

Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>

* Apply suggestions from code review

Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>

* Update book/src/dev/rfcs/0005-state-updates.md

Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>

* apply changes from code review

* clarify iteration

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

* apply changes from code review

* Update book/src/dev/rfcs/0005-state-updates.md

Co-authored-by: teor <teor@riseup.net>

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

* Apply suggestions from code review

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

* add info about default constructing chains when forking from finalized state

* Update book/src/dev/rfcs/0005-state-updates.md

Co-authored-by: teor <teor@riseup.net>

* move contextual verification out of Chain

Co-authored-by: Jane Lusby <jlusby42@gmail.com>
Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
Co-authored-by: Jane Lusby <jane@zfnd.org>
2020-09-21 12:05:31 -07:00
Alfredo Garcia c616c7ffd2
Move consensus verification errors (#1070)
* refactor block and tx validation errors

* rename errors module to error

* move NoTransactions to BlockError

* clarify some errors, use dbg format for hash in error

* mnake is_coinbase_first return BlockError

* add new error types for each consensus Service

Co-authored-by: Jane Lusby <jane@zfnd.org>
2020-09-21 11:54:06 -07:00
Deirdre Connolly 33afeb37cb Add a comment about the short looo 2020-09-21 09:26:39 -07:00
Henry de Valence 9e2ff23d54 consensus, state: increase Buffer sizes
Using a Buffer with size 1 is a footgun because it allows only one
sender to call poll_ready at a time.  This is usually undesirable
because it means that a task or service that calls poll_ready but only
makes a service call later (potentially much later) will block all other
callers.
2020-09-21 09:26:39 -07:00
Henry de Valence 6f3288814c network: avoid GetPeers timeout to accelerate init
The GetPeers requests sent while crawling the network are randomly
load-balanced over available peers.  But at the very beginning, they may
be both routed to the same peer, causing network initialization to be
delayed while the second one times out (since zcashd only ever responds
to the first addr message).

Only sending one GetPeers request per candidate set update means we
crawl the network a little more slowly, but avoids hanging on start.
2020-09-21 09:26:39 -07:00
Henry de Valence b72c249b96 network: add a metric+warning when shedding load 2020-09-21 09:26:39 -07:00
Henry de Valence fe61090a64 zebrad: make Inbound Poll::Ready before setup.
The Inbound service only needs the network setup for some requests, but
it can service other requests without it.  Making it return
Poll::Pending until the network setup finishes means that initial
network connections may view the Inbound service as overloaded and
attempt to load-shed.
2020-09-21 09:26:39 -07:00
dependabot[bot] 85241a49d6 build(deps): bump hyper from 0.13.7 to 0.13.8
Bumps [hyper](https://github.com/hyperium/hyper) from 0.13.7 to 0.13.8.
- [Release notes](https://github.com/hyperium/hyper/releases)
- [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md)
- [Commits](https://github.com/hyperium/hyper/compare/v0.13.7...v0.13.8)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-21 11:58:31 -04:00
Henry de Valence 4df5632752 network: handle Message::NotFound as a response
This cleans up the response processing logic a little bit along the way,
but the overall division of responsibility should be better documented
in a future commit.
2020-09-20 10:21:18 -07:00
Henry de Valence 64905563d1 network: remove glob import in message-handling
This clarifies which parts are the handler state and which parts are the
incoming message.
2020-09-20 10:21:18 -07:00
Henry de Valence 9c021025a7 network: fill in remaining request/response pairs 2020-09-20 10:21:18 -07:00
Henry de Valence b289cb9164 network: clean up GetHeaders, GetBlocks modeling 2020-09-20 10:21:18 -07:00
Henry de Valence 3c993f33b1 network: add PeerError::WrongMessage
This lets us distinguish between cases where the message was unsupported
(e.g., BIP11 messages), and cases where the message was uninterpretable
in context (e.g., unsolicited messages).
2020-09-20 10:21:18 -07:00
Henry de Valence 430176dd0d network: clean up message-as-request translation 2020-09-20 10:21:18 -07:00
Henry de Valence 4b35fea492 zebrad: document Inbound, ChainSync responsibilities 2020-09-18 18:34:25 -07:00
Henry de Valence 65877cb4b1 zebrad: make Inbound propagate backpressure 2020-09-18 18:34:25 -07:00
Henry de Valence 55f46967b2 zebrad: serve blocks from Inbound service
The original version of this commit ran into

https://github.com/rust-lang/rust/issues/64552

again.  Thanks to @yaahc for suggesting a workaround (using futures combinators
to avoid writing an async block).
2020-09-18 18:34:25 -07:00
Henry de Valence 170f588ffb network: document load-shedding behavior
This was part of the original design and is described in the Connection
internals, but we never documented it externally.
2020-09-18 18:34:25 -07:00
Henry de Valence 1d0ebf89c6 zebrad: move seed command into inbound component
Remove the seed command entirely, and make the behavior it provided
(responding to `Request::Peers`) part of the ordinary functioning of the
start command.

The new `Inbound` service should be expanded to handle all request
types.
2020-09-18 18:34:25 -07:00