Commit Graph

3139 Commits

Author SHA1 Message Date
dependabot[bot] 3ba0326c51
Bump secp256k1 from 0.20.3 to 0.21.2 (#3326)
Bumps [secp256k1](https://github.com/rust-bitcoin/rust-secp256k1) from 0.20.3 to 0.21.2.
- [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)

---
updated-dependencies:
- dependency-name: secp256k1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-01-14 14:25:12 +00:00
dependabot[bot] f731c91e9b
Bump indexmap from 1.7.0 to 1.8.0 (#3335)
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Changelog](https://github.com/bluss/indexmap/blob/master/RELEASES.rst)
- [Commits](https://github.com/bluss/indexmap/compare/1.7.0...1.8.0)

---
updated-dependencies:
- dependency-name: indexmap
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-01-14 13:42:43 +00:00
Deirdre Connolly 89b0403582
Enforce Rust edition 2021 (#3332)
* Rust edition 2021: zebra-network, cargo fix --edition and clippy --fix

* Rust edition 2021: zebra-chain, cargo fix --edition

* Rust edition 2021: tower-batch, cargo fix --edition

* Rust edition 2021: tower-fallback, cargo fix --edition

* Rust edition 2021: zebra-client, cargo fix --edition

* Rust edition 2021: zebra-consensus, cargo fix --edition

* Rust edition 2021: zebra-rpc, cargo fix --edition

* Rust edition 2021: zebra-state, cargo fix --edition

* Rust edition 2021: zebra-state, cargo fix --edition

* Rust edition 2021: zebra-test, cargo fix --edition

* Rust edition 2021: zebra-utils, cargo fix --edition

* Rust edition 2021: zebrad, cargo fix --edition

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-01-14 12:10:18 +00:00
Marek ece2d0f09b
Document the consensus rules for note commitment trees (#3319)
Co-authored-by: teor <teor@riseup.net>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-01-14 01:28:35 +00:00
Deirdre Connolly e9c2125e7e
Upgrade to latest redjubjub commit, hasn't been published to crates.io yet (#3333)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-01-13 23:59:59 +00:00
Gustavo Valverde dc4533d368
Use the correct conditions and merge method in Mergify (#3341)
* fix: Use the correct conditions and merge method

Mergifys Status Checks conditions are based on the job name, not the worflow name. As our worflows have dynamic names, each variant must be considered.

Squash merges are the default being used in the Zebra repo, so mergify must comply with this configuration.

Use condition operators for labels in each pull request rule; previously it was expecting both labels to be set. And update names accordingly.

* fix: Allow mergify to merge dependabot PRs

Also adapt dependabot's configuration to use the recently adapted labels

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-01-13 23:34:09 +00:00
teor 8887ed88aa
Update Zebra's allowed duplicate dependencies (#3316)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-01-13 17:43:42 -05:00
teor ac4ed57751
Cancel heartbeats that are waiting for a peer, rather than hanging Zebra (#3325)
* If the crawler is delayed, delay future crawl intervals by the same amount

* Cancel heartbeats that are waiting for network requests or responses
2022-01-12 19:15:07 +00:00
teor d076b999f3
Fix syncer download order and add sync tests (#3168)
* Refactor so that RetryLimit::Future is std::marker::Sync

* Make the syncer future std::marker::Send by spawning tips futures

* Download synced blocks in chain order, not HashSet order

* Improve MockService failure messages

* Add closure-based responses to the MockService API

* Move MockChainTip to zebra-chain

* Add a MockChainTipSender type alias

* Support MockChainTip in ChainSync and its downloader

* Add syncer tests for obtain tips, extend tips, and wrong block hashes

* Add block too high tests for obtain tips and extend tips

* Add syncer tests for duplicate FindBlocks response hashes

* Allow longer request delays for mocked services in syncer tests
2022-01-11 14:11:35 -03:00
Gustavo Valverde fc1a1cdac1
Add mergify merging queues (#3324)
* Add mergify merging queues

* Fix Mergify invalid configuration

* Improve adaptability to the actual workflow

Do not merge if the pull-request test is not green. Do not move draft PRs to the queue. And update keep all open PRs updated.

* Fix a typo on check-success condition
2022-01-07 19:11:01 -05:00
teor 4c310c0671
3. Cleanup internal network request handler, fix unused request logging (#3295)
* Simplify connection internal request handling code

* Track unused inbound request messages correctly

* Use a custom enum for inbound message handler mappings

* Fix grammar

Co-authored-by: Marek <mail@marek.onl>

Co-authored-by: Marek <mail@marek.onl>
2022-01-07 08:05:24 +10:00
teor 7e63182cdc
Stop ignoring some peers when updating the address book (#3292)
* Make sure MetaAddrChanges are correctly applied to an empty address book

* Add all initial peers to the address book
2022-01-05 18:12:59 -05:00
teor 144c532de4
Cache unsolicited address messages, and provide them to Zebra when requested (#3294) 2022-01-05 15:55:59 -05:00
teor 469fa6b917
1. Fix some address crawler timing issues (#3293)
* Stop holding completed messages until the next inbound message

* Add more info to network message block download debug logs

* Simplify address metrics logs

* Try handling inbound messages as responses, then try as a new request

* Improve address book logging

* Fix a race between the first heartbeat and getaddr requests

* Temporarily reduce the getaddr fanout to 1

* Update metrics when exiting the Connection run loop

* Downgrade some debug logs to trace
2022-01-04 18:43:30 -05:00
dependabot[bot] 9b127168eb
Bump serde from 1.0.132 to 1.0.133 (#3313)
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.132 to 1.0.133.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.132...v1.0.133)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marek <mail@marek.onl>
2022-01-04 14:26:58 +00:00
dependabot[bot] 77a1c686c6
Bump serde_json from 1.0.73 to 1.0.74 (#3312)
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.73 to 1.0.74.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.73...v1.0.74)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marek <mail@marek.onl>
2022-01-04 14:57:49 +01:00
Dimitris Apostolou 1a1ce3dbff
Fix typos (#3314) 2022-01-04 11:25:00 +01:00
dependabot[bot] 454897bc33
Bump inferno from 0.10.8 to 0.10.9 (#3268) 2022-01-03 13:42:35 +01:00
Alfredo Garcia 46a505b68e
Retry Zcash sprout and sapling parameters download (#3306)
* retry download parameters a few times before giving up

* separate sapling and sprout params download to methods

* simpify the new created methods

* Assert the parameters were downloaded to the expected paths

Co-authored-by: teor <teor@riseup.net>
2022-01-02 22:49:12 +00:00
Alfredo Garcia 5f772ebf65
Test for message broadcast to the right number of peers (#3284)
* create a test for message broadcast to peers

* remove dbg comment

* use `prop_assert_eq`

* use a random number of peers with constant version

* fix some docs

* check total peers is equal to active peers

* increase coverage

Co-authored-by: teor <teor@riseup.net>
2021-12-31 00:26:50 +00:00
Alfredo Garcia d2f71f01d6
Document chain value balances consensus rules with new format (#3286)
* improve docs of chain value balances non-negative consensus rules

* Apply suggestions from code review

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

* move comment

* Fix confusion between chain and transaction value pools

Co-authored-by: teor <teor@riseup.net>
2021-12-30 23:50:05 +00:00
teor 534494f075
Upgrade zcash_proofs to get new derived traits (#3308) 2021-12-30 14:38:21 -03:00
teor 0f92b6729a
Fix an unrelated type resolution error (#3304) 2021-12-29 23:44:28 +00:00
Alfredo Garcia 918a337d8b
Document part of the block header consensus rules (#3296)
* document header version consensus rule

* document nbits threshold consensus rule

* document difficulty filter consensus rule

* document header solution consensus rule

* document header time consensus rule

* document upper time limit consensus rule

* document max block size consensus rule

* skip genesis in conesnsus rule check

* remove fixed comment

Co-authored-by: teor <teor@riseup.net>
2021-12-29 23:07:27 +00:00
Alfredo Garcia 041a2693b7
change format of funding stream consensus rule (#3285)
Co-authored-by: teor <teor@riseup.net>
2021-12-28 02:56:31 +00:00
dependabot[bot] a3cbca6245
Bump owo-colors from 3.1.1 to 3.2.0 (#3299)
Bumps [owo-colors](https://github.com/jam1garner/owo-colors) from 3.1.1 to 3.2.0.
- [Release notes](https://github.com/jam1garner/owo-colors/releases)
- [Commits](https://github.com/jam1garner/owo-colors/compare/v3.1.1...v3.2.0)

---
updated-dependencies:
- dependency-name: owo-colors
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-28 11:06:14 +10:00
Conrado Gouvea 1cbc06aa64
Add install.md to checklist, update to use a single PR (#3282)
* Add updating install.md to checklist

* Change to use a single PR for version increment and changelog
2021-12-23 10:16:15 -03:00
Deirdre Connolly 9734ea1014
Check jubjub key correctness independent of redjubjub / jubjub (#3154)
* Ensure that sapling::keys::TransmissionKey jubjub point is always in the prime order group

* Adjust TransmissionKey check; add AuthorizingKey check

* Move ValueCommitment small order check to deserialization

* Apply suggestions from code review

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

* Use is_torsion_free() instead of is_identity() and is_prime_order()

* Add EphemeralPublicKey small order check on instantiation; remove old checks

* Use VerificationKey instead of VerificationKeyBytes; fix tests

* Use ValidatingKey instead of VerificationKeyBytes for rk

* Reject identity when creating an Orchard EphemeralPublicKey

* Make documentation more consistent, use generator in tests

* s/JubJub/Jubjub/

* Fix zebra-consensus tests (insert_fake_orchard_shielded_data)

* Create NotSmallOrderValueCommitment, since intermediate values can be the identity

* Clarify documentation

* rustdoc

* Tidy rustdoc

Co-authored-by: Conrado Gouvea <conrado@zfnd.org>
Co-authored-by: Pili Guerra <mpguerra@users.noreply.github.com>
2021-12-22 15:10:34 +00:00
teor 361125079e
Draft design for lightwalletd database support (#3137)
* Draft design for lightwalletd database support

* Explain how to create blocks from headers and transactions

* Make keys smaller to improve database performance

* Support transparent address balances and UTXOs

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2021-12-22 06:09:53 +00:00
dependabot[bot] 31b083ff27
Bump serde from 1.0.131 to 1.0.132 (#3259)
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.131 to 1.0.132.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.131...v1.0.132)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-22 02:48:57 +00:00
teor 3b75e912d1
Add a copy-state zebrad command, which copies blocks between two state services (#3175)
* Add a copy-state command, which copies blocks between two state services

* Check blocks were written correctly

* Add extra logging to debug shutdown

* Add a block height limit argument

* Let the target state start from any height

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2021-12-22 02:07:52 +00:00
Janito Vaqueiro Ferreira Filho 1010773b05
Keep track of background peer tasks (#3253)
* Refactor to create heartbeat sender function

Move the code that's part of the heartbeat task into a separate helper
function.

* Move `Client` initialization down

Keep it closer to where it's actually used, and make it easier to add
new fields to `Client` for the connection and heartbeat tasks.

* Add background task handles to `Client` type

Prepare it to be able to check for panics or errors from the background
tasks.

* Add dummy background tasks to `ClientTestHarness`

Spawn simple timeout tasks as mock connection and heartbeat tasks.

* Fix `PeerSet` tests that use `ClientTestHarness`

Building a `ClientTestHarness` requires a Tokio runtime to be set up, so
the calls were moved into the `async` block.

* Refactor to create `set_task_exited_error`

Make the code reusable for both background tasks.

* Check heartbeat task for errors

Periodically poll it to check if the task has unexpectedly stopped.

* Check if connection background task has stopped

The client service should stop if the connection background task has
exited, because then it's not able to receive any replies.

* Allow aborting mocked `Client` background tasks

Wrap the background tasks in `Abortable`, so that they can be aborted
through the `ClientTestHarness`.

* Test if stopped connection task is detected

Check that stopping the background connection task is something that the
`Client` instance detects and handles correctly.

* Test if stopped heartbeat task is detected

Check that stopping the background heartbeat task is something that the
`Client` instance detects and handles correctly.

* Allow setting custom background tasks

Will be used later to create background tasks that panic.

* Test if `Client` handles panics in connection task

Use a mock background connection task that panics immediately, and check
that the `Client` handles it gracefully.

* Test if `Client` handles panics in heartbeat task

Use a mock background heartbeat task that panics immediately, and check
that the `Client` handles it gracefully.

* Change ticket referenced by `TODO`

The previously linked issue was a broad plan to improve Zebra's shutdown
behavior, while the new issue is more specific, and can be scheduled
sooner.

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

Co-authored-by: teor <teor@riseup.net>
2021-12-22 01:35:38 +00:00
teor 52bdc4c5cd
Re-enable code coverage comments on PRs (#3246)
* Re-enable code coverage comments on PRs

* Post a coverage comment, even if coverage hasn't changed

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2021-12-22 00:52:08 +00:00
Conrado Gouvea 074011eaad
Bump futures crates to 0.3.19 (#3276)
Co-authored-by: teor <teor@riseup.net>
2021-12-21 23:12:58 +00:00
Conrado Gouvea a5713da0af
Release Zebra v1.0.0-beta.3 (#3256)
* Release Zebra v1.0.0-beta.3

* Apply suggestions from code review

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

* Bump date

* Add recently merged entry to changelog

* Bump date, add recent merged PR to changelog

* Apply suggestions from code review

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

* Apply suggestions from code review

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

Co-authored-by: teor <teor@riseup.net>
2021-12-21 19:42:39 -03:00
Janito Vaqueiro Ferreira Filho b71833292d
Use `MockedClientHandle` in other tests (#3241)
* Move `MockedClientHandle` to `peer` module

It's more closely related to a `Client` than the `PeerSet`, and this
prepares it to be used by other tests.

* Rename `MockedClientHandle` to `ClientTestHarness`

Reduce confusion, and clarify that the client is not mocked.

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

* Add clarification to `mock_peers` documentation

Explicitly say how the generated data is returned.

* Rename method to `wants_connection_heartbeats`

The `Client` service only represents one direction of a connection, so
`is_connected` is not the exact term.

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

* Mock `Client` instead of `LoadTrackedClient`

Move where the conversion from mocked `Client` to mocked
`LoadTrackedClient` in order to make the test helper more easily used by
other tests.

* Use `ClientTestHarness` in `initialize` tests

Replace the boilerplate code to create a fake `Client` instance with
usages of the `ClientTestHarness` constructor.

* Allow receiving requests from `Client` instance

Create a helper type to wrap the result, to make it easier to assert on
specific events after trying to receive a request.

* Allow inspecting the current error in the slot

Share the `ErrorSlot` between the `Client` and the handle, so that the
handle can be used to inspect the contents of the `ErrorSlot`.

* Allow placing an error into the `ErrorSlot`

Assuming it is initially empty. If it already has an error, the code
will panic.

* Allow gracefully closing the request receiver

Close the endpoint with the appropriate call to the `close()` method.

* Allow dropping the request receiver endpoint

Forcefully closes the endpoint.

* Rename field to `client_request_receiver`

Also rename the related methods to include
`outbound_client_request_receiver` to make it more precise.

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

* Allow dropping the heartbeat shutdown receiver

Allows the `Client` to detect that the channel has been closed.

* Rename fn. to `drop_heartbeat_shutdown_receiver`

Make it clear that it affects the heartbeat task.

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

* Move `NowOrLater` into a new `now-or-later` crate

Make it easily accessible to other crates.

* Add `IsReady` extension trait for `Service`

Simplifies checking if a service is immediately ready to be called.

* Add extension method to check for readiness error

Checks if the `Service` isn't immediately ready because a call to
`ready` immediately returns an error.

* Rename method to `is_failed`

Avoid negated method names.

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

* Add a `IsReady::is_pending` extension method

Checks if a `Service` is not ready to be called.

* Use `ClientTestHarness` in `Client` test vectors

Reduce repeated code and try to improve readability.

* Create a new `ClientTestHarnessBuilder` type

A builder to create test `Client` instances using mock data which can be
tracked and manipulated through a `ClientTestHarness`.

* Allow configuring the `Client`'s mocked version

Add a `with_version` builder method.

* Use `ClientTestHarnessBuilder` in `PeerVersions`

Use the builder to set the peer version, so that the `version` parameter
can be removed from the constructor later.

* Use a default mock version where possible

Reduce noise when setting up the harness for tests that don't really
care about the remote peer version.

* Remove `Version` parameter from the `build` method

The `with_version` builder method should be used instead.

* Fix some typos and outdated info in the release checklist

* Add extra client tests for zero and multiple readiness checks (#3273)

And document existing tests.

* Replace `NowOrLater` with `futures::poll!` (#3272)

* Replace NowOrLater with the futures::poll! macro in zebrad

* Replace NowOrLater with the futures::poll! macro in zebra-test

* Remove the now-or-later crate

* remove unused imports

* rustfmt

Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-12-22 06:13:26 +10:00
teor 8db0528165
Revert "Stop ignoring some completed Responses" (#3274)
* Revert "Stop ignoring some completed Responses"

This reverts commit 0383562e10 from PR #3120,
but keeps the metrics and logging changes since that commit.

* Document why the request handling needs to happen in this order
2021-12-21 11:55:20 -03:00
teor a8d2e45e08
Refactor code to avoid incorrect clippy::unnecessary_to_owned lint (#3270)
Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2021-12-21 07:58:24 +00:00
teor 6814525a7a
Update async correctness docs and the async in Zebra RFC (#3243)
* Justify that the ErrorSlot Mutex is deadlock-safe

* Document cancellation safety in the async RFC

* Document task starvation in the async RFC

Co-authored-by: Marek <mail@marek.onl>
2021-12-21 07:10:15 +00:00
dependabot[bot] c47ea80529
Bump metrics from 0.17.0 to 0.17.1 (#3258)
Bumps [metrics](https://github.com/metrics-rs/metrics) from 0.17.0 to 0.17.1.
- [Release notes](https://github.com/metrics-rs/metrics/releases)
- [Changelog](https://github.com/metrics-rs/metrics/blob/main/release.toml)
- [Commits](https://github.com/metrics-rs/metrics/compare/metrics-v0.17.0...metrics-v0.17.1)

---
updated-dependencies:
- dependency-name: metrics
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-20 21:00:40 +00:00
teor d0e6de8040
Avoid deadlocks in the address book mutex (#3244)
* Tweak crawler timings so peers are more likely to be available

* Tweak min peer connection interval so we try all peers

* Let other tasks run between fanouts, so we're more likely to choose different peers

* Let other tasks run between retries, so we're more likely to choose different peers

* Let other tasks run after peer crawler DemandDrop

This makes it more likely that peers will become ready.

* Spawn the address book updater on a blocking thread

* Spawn CandidateSet address book operations on blocking threads

* Replace the PeerSet address book with a metrics watch channel

* Fix comment

* Await spawned address book tasks

* Run the address book update tasks concurrently (except for the mutex)

* Explain an internal-only method better

* Fix a typo

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-12-20 00:44:43 +00:00
Janito Vaqueiro Ferreira Filho 410133435e
Add some proptests for lock time validation (#3089)
* Create a strategy for block heights after Sapling

Provides an arbitrary network (mainnet or testnet) and a block height
between the Sapling activation height on that network and the maximum
block height.

* Create a helper function to select block heights

Allows generating block heights inside a range using a scale factor
between 0 and 1.

* Allow specifying the outpoint index for mock UTXOs

Avoid creating multiple transparent transfers in the same transaction
with the same source UTXO, which would lead to a double spend.

* Create helper function to mock multiple transfers

Given relative block height scale factors, create a mock transparent
transfer for each one of them.

Also add a constant that serves as a guideline for the maximum number of
transparent transfers to mock.

* Create helper function to sanitize tx. version

Make sure the arbitrary transaction version is valid for the network
(testnet or mainnet) at the specified block height.

* Create `mock_transparent_transaction` helper func.

Creates a V4 or V5 mock transaction that only includes transparent
inputs and outputs.

* Create helper function for transaction validation

Performs the actual tested action of verifying a transaction. It sets up
the verifier and uses it to obtain the verification result.

* Test if zero lock time means unlocked

Generate arbitrary transactions with zero lock time, and check that they
are accepted by the transaction verifier.

* Allow changing the sequence number of an input

Add a setter method for a `transparent::Input`'s sequence number. This
setter is only available for testing.

* Test if sequence numbers can disable lock time

Create arbitrary transactions and set the sequence numbers of all of its
inputs to `u32::MAX` to see if that disables the lock time and the
transactions are accepted by the verifier.

* Test block height lock times

Make sure that the transaction verifier rejects transactions that are
still locked at a certain block height.

* Test block time lock times

Test that the transaction verifier rejects a transaction that is
validated at a block time that's before the transaction's lock time.

* Test unlocking by block height

Test that transactions unlocked at an earlier block height are accepted
by the transaction verifier.

* Test transactions unlocked by the block time

Test that transactions that were unlocked at a previous block time are
accepted by the transaction verifier.

* Fix an incorrect method comment

Co-authored-by: teor <teor@riseup.net>
2021-12-19 23:44:12 +00:00
teor 6cbd7dce43
Fix task handling bugs, so peers are more likely to be available (#3191)
* Tweak crawler timings so peers are more likely to be available

* Tweak min peer connection interval so we try all peers

* Let other tasks run between fanouts, so we're more likely to choose different peers

* Let other tasks run between retries, so we're more likely to choose different peers

* Let other tasks run after peer crawler DemandDrop

This makes it more likely that peers will become ready.
2021-12-20 09:02:31 +10:00
dependabot[bot] cb213210b1 Bump metrics-exporter-prometheus from 0.6.1 to 0.7.0
Bumps [metrics-exporter-prometheus](https://github.com/metrics-rs/metrics) from 0.6.1 to 0.7.0.
- [Release notes](https://github.com/metrics-rs/metrics/releases)
- [Changelog](https://github.com/metrics-rs/metrics/blob/main/release.toml)
- [Commits](https://github.com/metrics-rs/metrics/compare/metrics-exporter-prometheus-v0.6.1...metrics-exporter-prometheus-v0.7.0)

---
updated-dependencies:
- dependency-name: metrics-exporter-prometheus
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-17 23:27:26 -05:00
teor a4d1a1801c
Security: Drop blocks that are a long way ahead of the tip (#3167)
* Document the chain verifier

* Drop gossiped blocks that are too far ahead of the tip

* Add extra gossiped block metrics

* Allow extra gossiped blocks, now we have a stricter limit

* Fix a comment

* Check the exact number of blocks in a downloaded block response

* Drop synced blocks that are too far ahead of the tip

* Add extra synced block metrics

* Test dropping gossiped blocks that are too far ahead of the tip

* Allow an extra checkpoint's worth of blocks in the verifier queues

* Actually let's try two extra checkpoints

* Scale extra height limit with lookahead limit

* Also drop blocks that are behind the finalized tip

* Downgrade a noisy log

* Use a debug log for already verified gossiped blocks

* Use debug logs for already verified synced blocks
2021-12-17 13:31:51 -03:00
dependabot[bot] 852c5d63bb
Bump tokio from 1.14.0 to 1.15.0 (#3245)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.14.0 to 1.15.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.14.0...tokio-1.15.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-17 06:58:07 +10:00
teor ea01e305ed
Silence expected anchor errors in tests (#3237) 2021-12-15 22:20:53 +00:00
teor f176bb59a2
Stop ignoring some connection errors that could make the peer set hang (#3200)
* Drop peer services if their cancel handles are dropped

* Exit the client task if the heartbeat task exits

* Allow multiple errors on a connection without panicking

* Explain why we don't need to send an error when the request is cancelled

* Document connection fields

* Make sure connections don't hang due to spurious timer or channel usage

* Actually shut down the client when the heartbeat task exits

* Add tests for unready services

* Close all senders to peer when `Client` is dropped

* Return a Client error if the error slot has an error

* Add tests for peer Client service errors

* Make Client drop and error cleanups consistent

* Use a ClientDropped error when the Client struct is dropped

* Test channel and error state in peer Client tests

* Move all Connection cleanup into a single method

* Add tests for Connection

* fix typo in comment

Co-authored-by: Conrado Gouvea <conrado@zfnd.org>

Co-authored-by: Conrado Gouvea <conrado@zfnd.org>
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-12-15 14:52:44 +00:00
Conrado Gouvea bd9c954667
Disable Sprout anchor check (#3206)
Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2021-12-15 11:16:59 -03:00
dependabot[bot] a09169d4bb
Bump once_cell from 1.8.0 to 1.9.0 (#3208)
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.8.0 to 1.9.0.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.8.0...v1.9.0)

---
updated-dependencies:
- dependency-name: once_cell
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-14 22:43:07 +00:00