Commit Graph

1335 Commits

Author SHA1 Message Date
Henry de Valence 81e8195f68 network: add connect_isolated distinguisher test
This is currently broken due to a rustc bug.
2020-09-17 12:02:20 -07:00
Henry de Valence b7472de43f network: add a zebra_network::connect_isolated() method.
The peer set provides an automatically managed connection pool, abstracting
away all the details of handling individual peer connections.  However, it's
also useful to be able to create completely isolated and
minimally-distinguishable connections to individual peers, in order to be able
to send specific messages over Tor, or to implement some custom network crawler
logic.
2020-09-17 12:02:20 -07:00
teor 584f2643b7 Update to `RootHash` in comments
We changed the name of the type and function, but forgot the comments.
2020-09-16 12:26:25 -04:00
teor c349f75ffe Split a sentence in a state comment 2020-09-16 12:25:31 -04:00
dependabot[bot] a7d5a80517 build(deps): bump zcash_script from 0.1.0 to 0.1.1
Bumps [zcash_script](https://github.com/ZcashFoundation/zcash_script) from 0.1.0 to 0.1.1.
- [Release notes](https://github.com/ZcashFoundation/zcash_script/releases)
- [Changelog](https://github.com/ZcashFoundation/zcash_script/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ZcashFoundation/zcash_script/compare/v0.1.0...v0.1.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-16 12:24:34 -04:00
dependabot[bot] b441e2cfa5 build(deps): bump color-eyre from 0.5.2 to 0.5.3
Bumps [color-eyre](https://github.com/yaahc/color-eyre) from 0.5.2 to 0.5.3.
- [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.2...v0.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-15 08:04:06 -04:00
teor 2c6287abcb Remove an unused zebra-test dependency on tempdir 2020-09-14 23:06:58 -04:00
dependabot[bot] b86023ad0f
build(deps): bump serde from 1.0.115 to 1.0.116 (#1060)
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.115 to 1.0.116.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.115...v1.0.116)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-14 13:49:27 -07:00
dependabot[bot] ba32d27f6e
build(deps): bump tracing-subscriber from 0.2.11 to 0.2.12 (#1059)
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.2.11 to 0.2.12.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.2.11...tracing-subscriber-0.2.12)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-14 13:49:07 -07:00
Jane Lusby a7b418bfe5
Add test for first checkpoint verification (#1018)
* add test for first checkpoint sync

Prior this this change we've not had any tests that verify our sync /
network logic is well behaved. This PR cleans up the test helper code to
make error reports more consistent and uses this cleaned up API to
implement a checkpoint sync test which runs zebrad until it reads the
first checkpoint event from stdout.

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

* move include out of unix cfg

Co-authored-by: teor <teor@riseup.net>
2020-09-11 13:39:39 -07:00
Henry de Valence bbd8a069bb state: fix bug in SledState::commit_finalized
The previous code filled in block height 0 for a missing coinbase height
in `SledState::commit_finalized`, since the genesis block is the only
block without a coinbase height (because of a mistake when it was
created).

However, @teor2345 noticed that this is incorrect, because we already
parse the genesis block specially and fill in its coinbase height
correctly.  So instead, we can .expect it to be present, because we can
assume that all finalized blocks are valid.
2020-09-11 13:37:49 -07:00
Henry de Valence 2e7f33a958 consensus: restore chain verifier info! event 2020-09-11 13:37:49 -07:00
Henry de Valence aa70db1867 consensus: remove dead code in checkpointer
This was never used anywhere, not even by tests, but nothing noticed
because it had an #[allow(dead_code)].
2020-09-11 13:37:49 -07:00
Henry de Valence de2400031c state: merge SledState::{queue, process_queue}.
We never want to call one without the other, so just do them together.
2020-09-11 13:37:49 -07:00
Henry de Valence 93586867bc consensus: change verifier poll_ready handling.
This makes the component verifiers both always return `poll_ready`,
because they do not exert backpressure and cannot fail.

The checkpoint verifier now immediately rejects any blocks that arrive
after it finishes checkpointing, instead of marking the service itself
as failed.

The chain verifier is agnostic to the readiness behavior of its
components, and reports readiness when they are both ready.
2020-09-11 13:37:49 -07:00
Henry de Valence 526f771ceb state: update SledState docs. 2020-09-11 13:37:49 -07:00
Henry de Valence 8fb0e11674 fix: clippy-redundant closures, fmt 2020-09-11 13:37:49 -07:00
Henry de Valence 0d6303a56f consensus: avoid tower::ServiceExt::oneshot()
This is a really nice function but there might be a bug in its future
implementation: https://github.com/tower-rs/tower/issues/469

This bug may have already been fixed for the 0.4.0 release, so we could change
back then.
2020-09-11 13:37:49 -07:00
Henry de Valence 006596b9a9 state: remove unused variables 2020-09-11 13:37:49 -07:00
Henry de Valence f4db12efcb state: implement Request::Block with sled 2020-09-11 13:37:49 -07:00
Henry de Valence 2cbc60aeae consensus: fix block-not-in-state check in test
The state responds with Ok(None) when the block is not there, and Err(_) to
indicate an error while looking.
2020-09-11 13:37:49 -07:00
Henry de Valence a1d3af9e9c consensus: disable contextual verification test
Contextual verification isn't implemented, so we can't test it yet.
2020-09-11 13:37:49 -07:00
Henry de Valence d5bc8f937d consensus: construct checkpointer with a tip, not a block 2020-09-11 13:37:49 -07:00
Henry de Valence 5d8decd224 state: process CommitFinalizedBlock out of order 2020-09-11 13:37:49 -07:00
Henry de Valence b27ace87eb state: partial implementation of new sled layout 2020-09-11 13:37:49 -07:00
Henry de Valence f1f0b331ac state: make Response::Tip return (height, hash) 2020-09-11 13:37:49 -07:00
Henry de Valence 3133214e4f zebrad: use new state API 2020-09-11 13:37:49 -07:00
Henry de Valence a25801fc2c consensus: remove length-1 checkpoint list test
This test aimed to exercise both the checkpoint and block verifiers by
making a checkpoint list of length 1.  However, the block verifier can't
work on any blocks below Sapling activation.
2020-09-11 13:37:49 -07:00
Henry de Valence 6dd7c6495b consensus: make ChainVerifier a router
Instead of conditionally parsing the hardcoded checkpoint list and
optionally making a CheckpointVerifier, make one unconditionally, and
use the config settings to decide whether to route responses to it.

Then, fix up all of the places needed to make it compile and remove all
of the dead code.
2020-09-11 13:37:49 -07:00
Henry de Valence 93cc6957b1 consensus: partially update to new state API
This disables one test that can't be easily fixed at the moment, because
it tests the wrong thing: the checkpoint and block verifiers will
produce different transcripts.

It also disables the initial_tip logic for now, pending simplification
of the ChainVerifier logic.
2020-09-11 13:37:49 -07:00
Henry de Valence 070013439e state: fill in RFC5-style Request, Response enums
The test transcripts need to be rewritten, so they are removed for now.
2020-09-11 13:37:49 -07:00
Henry de Valence 98d5351206 state: add rustdoc links 2020-09-11 13:37:49 -07:00
Henry de Valence 2ac8b5b9d4 state: create a new wrapper service
The new `StateService` type wraps a `SledState` and a `MemoryState`.
This will allow the sled-related code and the in-memory code to be kept
separate, with the top-level `StateService` making method calls to one
or the other, as appropriate.

This commit removes the existing Service impl for the SledService.  This
saves time in refactoring, and the code needs to be rewritten
anyways so there's no loss to deleting it now.
2020-09-11 13:37:49 -07:00
Henry de Valence 303b02d10a state: split into modules and reorganize
Closes #975.
2020-09-11 13:37:49 -07:00
dependabot[bot] 69032e1007 build(deps): bump sled from 0.34.3 to 0.34.4
Bumps [sled](https://github.com/spacejam/sled) from 0.34.3 to 0.34.4.
- [Release notes](https://github.com/spacejam/sled/releases)
- [Changelog](https://github.com/spacejam/sled/blob/master/CHANGELOG.md)
- [Commits](https://github.com/spacejam/sled/compare/v0.34.3...v0.34.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-11 13:08:16 -04:00
Deirdre Connolly 9f07572bc4 Disable CodeCov annotations via GitHub Checks
They just decided to turn this on by default for all their GitHub users ...

https://docs.codecov.io/docs/github-checks-beta
2020-09-10 14:52:01 -04:00
Deirdre Connolly 6b88479480 Run CI workflow jobs on every PR, just like Cloud Build 2020-09-10 14:26:27 -04:00
teor b1e1291f45 Log inbound peer requests at debug
Logging at info was a bit too verbose.

Also add a short log message.
2020-09-10 09:46:53 -07:00
Henry de Valence 24de90c900 zebrad: tidy sync imports 2020-09-10 09:45:52 -07:00
Henry de Valence 9b6e66c1b9 zebrad: rename Syncer to ChainSync
This name clarifies what is being synced and avoids an agent-noun
construction.
2020-09-10 09:45:52 -07:00
Henry de Valence 0bc79686b8 zebrad: move sync into components module.
Part of #1030.
2020-09-10 09:45:52 -07:00
dependabot[bot] b881eafe47 build(deps): bump jubjub from 0.5.0 to 0.5.1
Bumps [jubjub](https://github.com/zkcrypto/jubjub) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/zkcrypto/jubjub/releases)
- [Changelog](https://github.com/zkcrypto/jubjub/blob/main/RELEASES.md)
- [Commits](https://github.com/zkcrypto/jubjub/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-10 09:45:37 -07:00
teor 9cf7de6253 Temporarily ignore failing state tests
This commit should be reverted when the state can handle out-of-order
blocks.
2020-09-09 15:37:59 -07:00
teor 1cd9f48d19 Add tests for in-order state AddBlock requests
Also fix a bug in the tests, where Mainnet and Testnet were swapped.
2020-09-09 15:37:59 -07:00
teor 7f2bebb97d Stop awaiting the previous block in the block verifier
Instead, the state should cache blocks until the previous block has been
committed.
2020-09-09 15:37:59 -07:00
teor 8463b705c8 Panic when state blocks are inserted out of order
This panic ensures our state is not corrupted. Corrupt states can lead
to future panics when querying the chain.
2020-09-09 15:37:59 -07:00
teor 1285561c3f Perform serialised block writes to the state
As per the state design RFC 0005.
2020-09-09 15:37:59 -07:00
teor 6a79953ab6 Separate state commits into checkpoint and full block verify
* stop committing to the state in the ChainVerifier
* commit to the state in the BlockVerifier
* commit to the state in the CheckpointVerifier

Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-09-09 15:37:59 -07:00
teor 1b76cb0250 Log message and comment cleanups
Also:
* Clarify the out of order block debug message
2020-09-09 15:37:59 -07:00
teor adafe1d189 Restart sync after the first failed ObtainTips
The ObtainTips retry was redundant. The timeout wasn't much shorter, but
it made the code and sync logic more complicated.
2020-09-09 15:35:09 -07:00