Commit Graph

1970 Commits

Author SHA1 Message Date
Jane Lusby 15698245e1
Deduplicate metrics dependencies (#1561)
## Motivation

This PR is motivated by the regression identified in https://github.com/ZcashFoundation/zebra/issues/1349. That PR notes that the metrics stopped working for most of the crates other than `zebrad`.

## Solution

This PR resolves the regression by deduplicating the `metrics` crate dependency. During a recent change we upgraded the metrics version in `zebrad` and a couple other of our crates, but we never updated the dependencies in `zebra-state`, `zebra-consensus`, or `zebra-network`. This caused the metrics macros to attempt to retrieve the current metrics exporter through the wrong function. We would install the metrics exporter in `0.13`, but then attempt to look it up through the `0.12` crate, which contains a different instance of the metrics exporter static variable which is unset. Doing this causes the metrics macros to return `None` for the current exporter after which they just silently give up.

## Related Issues

closes https://github.com/ZcashFoundation/zebra/issues/1349

## Follow Up Work

I noticed we have quite a few duplicate dependencies in our tree. We might be able to save some compilation time by auditing those and deduplicating them as much as possible.

- https://github.com/ZcashFoundation/zebra/issues/1582
Co-authored-by: teor <teor@riseup.net>
2021-01-12 12:28:56 +10:00
teor caca450904
zebrad acceptance test cleanup (#1560)
Check misconfigured ephemeral doesn't create a state dir

Add extra misconfigured `zebrad` ephemeral mode checks:
* doesn't create a state directory
* doesn't create unexpected files or directories in the working directory

Check ephemeral doesn't delete an existing state directory

Refactor all the ephemeral configs and checks into a single test
function.

Also:
* cleanup acceptance tests using utility functions
* make some checks consistent between tests
* make error messages consistent

Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2021-01-12 12:26:08 +10:00
dependabot[bot] 836c74ae16 build(deps): bump regex from 1.4.2 to 1.4.3
Bumps [regex](https://github.com/rust-lang/regex) from 1.4.2 to 1.4.3.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.4.2...1.4.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-11 20:47:32 -05:00
dependabot[bot] 38ac869f57 build(deps): bump byteorder from 1.3.4 to 1.4.2
Bumps [byteorder](https://github.com/BurntSushi/byteorder) from 1.3.4 to 1.4.2.
- [Release notes](https://github.com/BurntSushi/byteorder/releases)
- [Changelog](https://github.com/BurntSushi/byteorder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/byteorder/compare/1.3.4...1.4.2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-11 18:45:49 -05:00
teor c75cbdea79
Log configured network in every log message (#1568)
* Add the configured network to error reports
* Log the configured network at error level
* Create the global span immediately after activating tracing
And leak the span guard, so the span is always active.

* Include panic metadata in the report and URL
* Use `Main` and `Test` in the global span
`net=Mainnet` is a bit redundant
2021-01-12 07:46:56 +10:00
Deirdre Connolly a21eaad707 Use mdbook 0.4.5
https://blog.rust-lang.org/2021/01/04/mdbook-security-advisory.html
2021-01-08 21:24:31 -05:00
Deirdre Connolly 32ed09262d Stub out Sled trees for zebra-client / blockchain scanning state
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2021-01-08 19:02:40 -05:00
Deirdre Connolly 31421b55d3 Preallocate 0009 for Zebra Client RFC 2021-01-08 19:02:40 -05:00
Deirdre Connolly 62362ef31e Add more detail about the differences between this design and light client protocol
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2021-01-08 19:02:40 -05:00
Deirdre Connolly 5d45bd0116 Clarify that zebra-cli will wrap zebra-client, a library that implements wallet stuff
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2021-01-08 19:02:40 -05:00
Deirdre Connolly 6a4152fe6c Update PR link 2021-01-08 19:02:40 -05:00
Henry de Valence a6b07bdc3d client: further work on client RFC
Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2021-01-08 19:02:40 -05:00
Deirdre Connolly 69a8107c86 Add wip rfc for zebra-client/cli design 2021-01-08 19:02:40 -05:00
teor 40c427cf7c Make `cargo run` use `zebrad` by default
When `cargo run` is run in the workspace directory, it can see two
executables:
- `zebrad`
- `zebra_checkpoints`

Adding `default-run = "zebrad"` to `zebrad/Cargo.toml` makes the
workspace run `zebrad` by default. (Even though it's redundant for the
`zebrad` crate itself.)
2021-01-08 15:14:08 -08:00
dependabot[bot] f222a6805b build(deps): bump primitive-types from 0.7.3 to 0.8.0
Bumps [primitive-types](https://github.com/paritytech/parity-common) from 0.7.3 to 0.8.0.
- [Release notes](https://github.com/paritytech/parity-common/releases)
- [Commits](https://github.com/paritytech/parity-common/compare/primitive-types-v0.7.3...primitive-types-v0.8.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-06 20:26:31 -05:00
teor b7d0a40ee1 Revert unused instrument macros
Reverts most of "Instrument some functions to try to locate the panic"
2021-01-06 13:07:23 -08:00
teor 6d3aa0002c Ensure received client request oneshots are used via the type system
The `peer::Client` translates `Request`s into `ClientRequest`s, which
it sends to a background task. If the send is `Ok(())`, it will assume
that it is safe to unconditionally poll the `Receiver` tied to the
`Sender` used to create the `ClientRequest`.

We enforce this invariant via the type system, by converting
`ClientRequest`s to `InProgressClientRequest`s when they are received by
the background task. These conversions are implemented by
`ClientRequestReceiver`.

Changes:
* Revert `ClientRequest` so it uses a `oneshot::Sender`
* Add `InProgressClientRequest`, which is the same as `ClientRequest`,
  but has a `MustUseOneshotSender`
* `impl From<ClientRequest> for InProgressClientRequest`

* Add a new `ClientRequestReceiver` type that wraps a
  `mpsc::Receiver<ClientRequest>`
* `impl Stream<InProgressClientRequest> for ClientRequestReceiver`,
  converting the successful result of `inner.poll_next_unpin` into an
  `InProgressClientRequest`

* Replace `client_rx: mpsc::Receiver<ClientRequest>` in `Connection`
  with the new `ClientRequestReceiver` type
* `impl From<mpsc::Receiver<ClientRequest>> for ClientRequestReceiver`
2021-01-06 13:07:23 -08:00
teor df1b0c8d58 Defer a timeout fix until later 2021-01-06 13:07:23 -08:00
teor d5cfd5ad5f Clarify the ClientRequest invariant
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2021-01-06 13:07:23 -08:00
teor f8ff2e9c0b Add more sends before dropping ClientRequests
This fix also changes heartbeat behaviour in the following ways:
* if the queue is full, the connection is closed. Previously, the sender
  would wait until the queue had emptied
* if the queue flush fails, Zebra panics, because it can't send an error
  on the ClientRequest sender, so the invariant is broken
2021-01-06 13:07:23 -08:00
teor 3e711ccc8a Instrument some functions to try to locate the panic 2021-01-06 13:07:23 -08:00
teor fa29fca917 Panic when must-use senders are dropped before use
Add a MustUseOneshotSender, which panics if its inner sender is unused.
Callers must call `send()` on the MustUseOneshotSender, or ensure that
the sender is canceled.

Replaces an unreliable panic in `Client::call()` with a reliable panic
when a must-use sender is dropped.
2021-01-06 13:07:23 -08:00
teor b03809ebe3 Add the invalid state to an unreachable panic message 2021-01-06 13:07:23 -08:00
teor 86136c7b5c Stop ignoring errors when the new state is AwaitingRequest
The previous code would send a Nil message on the Sender, even if the
result was actually an error.
2021-01-06 13:07:23 -08:00
teor da5084a10a Split the 3-level match using a temporary 2021-01-06 13:07:23 -08:00
teor fd23c46726 Remove a redundant fmt::Display bound 2021-01-06 13:07:23 -08:00
teor 3892894ffa Call ClientRequest.tx.send() even if there is an error
Previously, tx would be dropped before send if:
- the success case would have used tx to wait for further messages,
- but the response was actually an error.

Instead, send the error on `tx` and call `fail_with()` using the same
error.

To support this change, allow `fail_with()` to take a `PeerError` or a
`SharedPeerError`.
2021-01-06 13:07:23 -08:00
teor 28f3186182 Mark ClientRequest and State::AwaitingResponse as must_use 2021-01-06 13:07:23 -08:00
dependabot[bot] d67de58554 build(deps): bump secp256k1 from 0.19.0 to 0.20.0
Bumps [secp256k1](https://github.com/rust-bitcoin/rust-secp256k1) from 0.19.0 to 0.20.0.
- [Release notes](https://github.com/rust-bitcoin/rust-secp256k1/releases)
- [Changelog](https://github.com/rust-bitcoin/rust-secp256k1/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-bitcoin/rust-secp256k1/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-04 11:05:43 -05:00
teor b1f14f47c6
Rewrite GetData handling to match the zcashd implementation (#1518)
* Rewrite GetData handling to match the zcashd implementation

`zcashd` silently ignores missing blocks, but sends found transactions
followed by a `NotFound` message:
e7b425298f/src/main.cpp (L5497)

This is significantly different to the behaviour expected by the old
Zebra connection state machine, which expected `NotFound` for blocks.

Also change Zebra's GetData responses to peer request so they ignore
missing blocks.

* Stop hanging on incomplete transaction or block responses

Instead, if the peer sends an unexpected block, unexpected transaction,
or NotFound message:
1. end the request, and return a partial response containing any items
   that were successfully received
2. if none of the expected blocks or transactions were received, return
   an error, and close the connection
2021-01-04 13:25:35 +10:00
Deirdre Connolly f9eb4a28df Enable the metrics endpoint inside Docker.build by default 2021-01-02 18:24:02 -05:00
dependabot[bot] 6436a09be6 build(deps): bump serde_json from 1.0.60 to 1.0.61
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.60 to 1.0.61.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.60...v1.0.61)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-30 21:57:27 -05:00
Deirdre Connolly f5b3412a50 Get PathBuf even if /zebrad-cache exists for create_cached_database_height() 2020-12-30 21:32:55 -05:00
dependabot[bot] f2a21ac67c build(deps): bump thiserror from 1.0.22 to 1.0.23
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.22 to 1.0.23.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.22...1.0.23)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-28 16:17:00 -05:00
dependabot[bot] b2a0048968 build(deps): bump serde-big-array from 0.3.0 to 0.3.1
Bumps [serde-big-array](https://github.com/est31/serde-big-array) from 0.3.0 to 0.3.1.
- [Release notes](https://github.com/est31/serde-big-array/releases)
- [Commits](https://github.com/est31/serde-big-array/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-28 15:50:29 -05:00
dependabot[bot] d5f4b55962 build(deps): bump toml from 0.5.7 to 0.5.8
Bumps [toml](https://github.com/alexcrichton/toml-rs) from 0.5.7 to 0.5.8.
- [Release notes](https://github.com/alexcrichton/toml-rs/releases)
- [Commits](https://github.com/alexcrichton/toml-rs/compare/0.5.7...0.5.8)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-26 19:01:18 -05:00
teor 6cd7f255d4
Cleanup acceptance tests using utility functions (#1537)
And add a missing network check.
2020-12-20 09:06:18 +10:00
Jane Lusby cfc339e8ea
export new precompute api in zebra-script (#1493)
* export new precompute api in zebra-script
* remove old API in favor of precompute API
* add multi use test cases and bump version
* update implementation to actually match henry's design
* Add safety comment for zebra-script

Co-authored-by: teor <teor@riseup.net>
2020-12-18 13:18:28 +10:00
teor 3355be4c41
Improve the random port function docs (#1536)
Also:
* rename the function
* create an alternative function for the common case.
2020-12-18 11:32:33 +10:00
Deirdre Connolly 3266265f7f Update testnet sync test 2020-12-16 20:36:31 -05:00
Deirdre Connolly e004d40ac1 Update cached state to @419200 on mainnet, not past it 2020-12-16 17:03:50 -05:00
Deirdre Connolly fbca3c7434 Remove testnet --container-mount-disk for now 2020-12-16 14:45:07 +10:00
Deirdre Connolly 4d387efe1d Disable tesnet post-Sapling sync tests for now 2020-12-16 14:45:07 +10:00
Deirdre Connolly 93b91769d6 Update stateful disks for post-Sapling-activation sync tests 2020-12-16 14:45:07 +10:00
teor 69fcf64d6c
Disable issue URLs for "duplicate hash" errors (#1517)
In our README, we tell users to ignore these errors, so we should also
disable the issue URL.

Also include the hash in the error. (We don't want the span active for
all messages, we just want the hash in the error.)
2020-12-16 08:14:42 +10:00
teor 008577561c Use a sleep future in the async acceptance tests
And wait slightly longer for `zebrad` to launch.

These fixes should reduce the failure rate of the acceptance tests on
busy machines.
2020-12-16 08:09:48 +10:00
teor 1b6bf7f105 Use random ports in the acceptance tests
This change avoids errors when tests are cancelled and re-run within a
short period of time, for example, using `cargo watch`.

It introduces a slight risk of port conflicts between the endpoint tests,
and with (ephemeral) ports used by other services. The risk of conflicts
across 2 tests is very low, and tests should be run in an isolated
environment on busy servers.
2020-12-16 08:09:48 +10:00
dependabot[bot] 5f8891df88 build(deps): bump indexmap from 1.6.0 to 1.6.1
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Commits](https://github.com/bluss/indexmap/compare/1.6.0...1.6.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-15 16:56:00 -05:00
Alfredo Garcia 41833340c1
downgrade remaining version strings to 1.0.0-alpha.0 (#1488) 2020-12-15 11:21:00 +10:00
Alfredo Garcia 436ce00fc2
Move height check to NetworkUpgrade (#1505)
* move height check to NetworkUpgrade
* refactor the max block time height check

Co-authored-by: teor <teor@riseup.net>
2020-12-15 08:30:38 +10:00