Commit Graph

2985 Commits

Author SHA1 Message Date
Conrado Gouvea 4367b232fc
Improve documentation for Beta release (#2894)
* Improve documentation

* Incorporate text about Zebra from the last newsletter

* Organize README and user docs

* Add table of contents, organize heading levels

* Fix link

* capitalize list items

* fix table of contents

* format spacing issue

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-29 19:25:30 +00:00
Pili Guerra 78529bd009
Updates to README for Beta release (#2967)
* Update zebra beta goals

* Update known issues

* Fix NU5 missing validation

* Update future work

* Add issue numbers to link descriptions for known issues

* Add some more known issues

* Sprout-on-Groth16 came in NU1 (Sapling)

* Add in 'Validation of JoinSplit proofs using BCTV14 verifier' under Sprout, for clarity

* Update current features

* Update future work

* Add link to github releases

* minor formatting typo

Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>

* Apply suggestions from code review

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

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
Co-authored-by: Conrado Gouvea <conrado@zfnd.org>
2021-10-29 17:43:29 +00:00
Alfredo Garcia 07610feef3
Reduce outgoing peers demand (#2969)
* reduce demand

* use `saturating_sub`
2021-10-29 16:29:52 +00:00
Alfredo Garcia 6b39edc74b
add `compile_fail` instead of `ignore` for doc test (#2970) 2021-10-29 14:58:04 +00:00
Deirdre Connolly 761782e236
Mempool rustdoc improvements (#2965)
* Tidy links and notes for some mempool rustdoc

* Fix link

* Fix some links and linewraps

* minor spacing

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-29 14:12:51 +00:00
Janito Vaqueiro Ferreira Filho 2c285b0f8e
Expand documentation in `mempool::crawler` module (#2968)
Describe how the crawler works, and add a simple example on how to start
it.

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-29 13:08:30 +00:00
Conrado Gouvea df65b8cb65
Restore and update mempool tests (#2966)
* Restore mempool_storage_basic

* Restore storage_is_cleared_on_chain_resets

* Restore mempool_service_basic() and mempool_queue()

* Fix tests and repeat multiple times to catch intermittent bugs

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-28 20:55:05 +00:00
Marek 8f04c9a243
Refactor the mempool error docs (#2963)
* Change the error messages

* Refactor the error messages

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

Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-28 20:09:05 +00:00
Alfredo Garcia 3402c1d8a2
Add user agent metrics (#2957)
* add remote peer user agent metrics

* add user agent to obsolete peers
2021-10-28 19:23:09 +00:00
Deirdre Connolly e592df2b3a
Add a note to mempool::Storage (#2964) 2021-10-28 17:27:59 +00:00
Janito Vaqueiro Ferreira Filho 36d488edb4
Reject a mempool transaction if it has internal spend conflicts (#2843)
* Reorder imports to follow convention

Place the imports from `std` at the top.

* Add transaction errors for double spends

Add a variant for each pool. They represent a double spend inside a
transaction.

* Add `check::spend_conflicts` implementation

Checks if a transaction has spend conflicts, i.e., if a transaction
spends a UTXO more than once or if it reveals a nullifier more than
once.

* Reject transactions with internal spend conflicts

The transaction verifier should reject transactions that spend the same
transparent UTXO or that reveal the same nullifier.

* Add transparent spend consensus rule

Add it to the documentation to help with understanding and auditing it.

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

* Use different nullifiers by default

Don't use the same nullifier twice when mocking a
`sprout::JoinSplitData` because it will lead to an invalid transaction.

* Test transactions with repeated spend outpoints

Since that represents a spend conflict, they should be rejected.

* Test duplicate nullifiers in joinsplit

Check if a mock transaction with a joinsplit that reveals the same
nullifier twice is rejected.

* Test duplicate nullifiers across joinsplits

Check if a duplicate nullifier in two different joinsplits in the same
transaction is rejected.

* Test V4 transaction with duplicate Sapling spend

Check if a V4 transaction that has a duplicate Sapling spend is
rejected.

* Test V5 transaction with duplicate Sapling spend

Check if a V5 transaction that has a duplicate Sapling spend is
rejected.

* Test V5 transaction with duplicate Orchard actions

Check if a V5 transaction that has duplicate Orchard actions is rejected
by the transaction verifier.

Co-authored-by: teor <teor@riseup.net>
2021-10-28 02:49:28 +00:00
teor f26a60b801
Limit the number of inbound peer connections (#2961)
* Limit open inbound connections based on the config

* Log inbound connection errors at debug level

* Test inbound connection limits

* Use clone directly in function call argument lists

* Remove an outdated comment

* Update tests to use an unbounded channel rather than mem::forget

And rename some variables.

* Use a lower limit in a slow test and require that it is exceeded
2021-10-28 01:49:31 +00:00
Conrado Gouvea 8d01750459
Rate-limit initial seed peer connections (#2943)
* Rate-limit initial seed peer connections

* Revert "Rate-limit initial seed peer connections"

This reverts commit f779a1eb9e.

* Simplify logic

* Avoid cooperative async task starvation in the peer crawler and listener

If we don't yield in these loops, they can run for a long time before
tokio forces them to yield.

* Add test

* Check for task panics in initial peers test

* Remove duplicate code in rebase

Co-authored-by: teor <teor@riseup.net>
2021-10-27 23:46:43 +00:00
teor 3e03d48799
Limit the number of outbound peer connections (#2944)
* Limit the number of outbound connections in the crawler

* Make zebra-network channel bounds depend on config.peerset_initial_target_size

* Bias Zebra towards outbound connections

And turn connection limits into `Config` methods.

* Downgrade some connection logs to debug

* Remove verbose or outdated fields in tracing logs

* Clarify connection limits

Includes:
- `fastmod OUTBOUND_PEER_BIAS_FRACTION OUTBOUND_PEER_BIAS_DENOMINATOR zebra*`
- clarify connection limit documentation

* Clarify inventory channel capacity

* Add zebra_network::initialize tests with limited numbers of peers

* Avoid cooperative async task starvation in the peer crawler and listener

If we don't yield in these loops, they can run for a long time before
tokio forces them to yield.

* Test the crawler with small connection limits

And use the multi-threaded runtime to avoid long hangs.

* Stop using the multi-threaded executor in tests where it's not needed

* Avoid starvation for every connection

Adds yields after inbound successes and initial peer connections.

* Add a crawler peer connection success test

* Add outbound connection limit tests

* Improve outbound tests
2021-10-27 21:28:51 +00:00
Conrado Gouvea 46fb33a04f
Limit the size and age of the ZIP-401 rejected transaction ID list (#2932)
* Limit the size and age of the ZIP-401 rejected transaction ID list

* Apply suggestions from code review

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

* Fix bug in EvictionList; improve documentation

* Separate public and non-public parts of the documentation

* Fix tests

* Apply suggestions from code review

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

* Fix bug in EvictionList::len()

* Make EvictionList::len() mutable; prune the list inside it

* Limit the size of EvictedList::ordered_entries

* Increase eviction_list_time_mixed time constants to try to make it pass on MacOS

* Simplify logic by assuming refreshes will never happen

* Apply suggestions from code review

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

* Compiling fixes

* Remove MEMPOOL_SIZE and just rely on the ZIP-401 cost limit

Co-authored-by: teor <teor@riseup.net>
2021-10-27 20:27:00 +00:00
Deirdre Connolly 0381c2347b
ZIP-401: weighted random mempool eviction (#2889)
* ZIP-401 weighted random mempool eviction

* rename zcash.mempool.total_cost.bytes to zcash.mempool.cost.bytes

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

* Remove duplicated lines

* Add cost() method to UnminedTx

Update serialization failure messages

* More docs quoting ZIP-401 rules

* Change mempool::Storage::new() to handle Copy-less HashMap, HashSet

* mempool: tidy cost types and evict_one()

* More consensus rule docs

* Refactor calculating mempool costs for Unmined transactions

* Add a note on asympotic performance of calculating weights of txs in mempool

* Bump test mempool / storage config to avoid weighted random cost limits

* Use mempool tx_cost_limit = u64::MAX for some tests

* Remove failing tests for now

* Allow(clippy::field-reassign-with-default) because of a move on a type that doesn't impl Copy

* Fix mistaken doctest formatting

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

* Increase test timeout for Windows builds

Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Conrado Gouvea <conrado@zfnd.org>
2021-10-27 00:21:19 +00:00
teor a166964a34
Document why CheckForVerifiedTransactions is required (#2955) 2021-10-26 10:19:12 -03:00
Deirdre Connolly 52357f7522
Remove dconnolly as default assignee and reviewer on dependabot PRs, and make them low priority (#2951)
* Remove dconnolly as default assignee and reviewer on dependabot PRs

* Assign dependabot PRs low priority by default

Co-authored-by: teor <teor@riseup.net>
2021-10-26 00:22:51 +00:00
Marek 537c1e909e
Improve mempool errors documentation (#2942)
* Remove unused error variants

* Improve mempool errors documentation

* Update zebrad/src/components/mempool/error.rs

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

* Improve the mempool errors documentation

* Fix a missing doc sentence

Co-authored-by: teor <teor@riseup.net>
2021-10-25 23:41:23 +00:00
teor c2734f5661
Simplify calling `add_initial_peers` (#2945)
Co-authored-by: Conrado Gouvea <conrado@zfnd.org>
2021-10-25 20:16:35 +00:00
teor c7a5db3c24
Fix or disable the new clippy::question_mark lint (#2946)
Co-authored-by: Conrado Gouvea <conrado@zfnd.org>
2021-10-25 19:34:34 +00:00
Marek 2920d838ff
Limit transaction size in the mempool (#2917)
* Limit tx size

Zebra now limits the transaction size in the `zcash_deserialize()` method for
`Transaction`.

* Remove unused error variants (#2941)

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

* Limit tx size

Zebra now limits the transaction size in the `zcash_deserialize()` method for
`Transaction`.

* Test the tx deserialization limit

Co-authored-by: Conrado Gouvea <conrado@zfnd.org>
2021-10-25 15:25:28 -03:00
Marek 451448ef99
Remove unused error variants (#2941)
Co-authored-by: Conrado Gouvea <conrado@zfnd.org>
2021-10-22 20:25:01 +00:00
Janito Vaqueiro Ferreira Filho 2a1d4281c5
Manually pin `Sleep` futures (#2914)
* Wrap `Sleep` timer in a `Pin<Box<_>>`

The `Sleep` type doesn't implement `Unpin` in newer versions of Tokio.

* Wrap `Sleep` type in a `Pin<Box<_>>`

In newer Tokio versions the `Sleep` type doesn't implement `Unpin`, so
it needs to be manually pinned.
2021-10-22 16:06:03 -03:00
dependabot[bot] ae6c90f914
Bump vergen from 5.1.12 to 5.1.16 (#2926)
Bumps [vergen](https://github.com/rustyhorde/vergen) from 5.1.12 to 5.1.16.
- [Release notes](https://github.com/rustyhorde/vergen/releases)
- [Commits](https://github.com/rustyhorde/vergen/compare/5.1.12...5.1.16)

---
updated-dependencies:
- dependency-name: vergen
  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: teor <teor@riseup.net>
2021-10-22 03:34:46 +00:00
Marek 4f7a977565
Test multiple chain resets (#2897)
* Try simulating a chain growth

* Adjust the transaction expiry height

The mempool evicts expired transactions. When working with mocked data,
appending a new block typically clears the mempool because transactions become
expired. For this reason, the expiry height of each transactions is adjusted so
that it is greater than the new chain tip's height.

* Refactor the code so that it works with `VerifiedUnminedTx`

* Fix a typo

* Fix clippy warnings

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2021-10-22 02:54:08 +00:00
teor 67327ac462
Downgrade some less interesting info-level logs to debug (#2938)
There are a lot of these messages when Zebra starts up.
They might be slowing down CI and causing timeouts.

Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
2021-10-22 02:11:09 +00:00
teor 424edfa4d9
Improve documentation and types in the PeerSet (#2925)
* Replace some unit tuples with named unit structs

This helps distinguish generic channels and make them type-safe.

Also tidy imports and documentation in `peer_set::set`.

* Link to the tower balance crate from docs

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

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-22 01:26:04 +00:00
Alfredo Garcia ad5f5ff24a
Rate limit the amount of inbound connections (#2928)
* add sleep to `accept_inbound_connections()`

* Expand docs

* Expand comments again

Co-authored-by: teor <teor@riseup.net>
2021-10-22 00:35:34 +00:00
teor 35290db052
Only run fake activation heights tests on zebra-state (#2929)
Also only run the zebrad acceptance tests on macOS.

Re-running the compiler and test binaries for unused crates is slow in CI.

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2021-10-21 23:51:20 +00:00
Alfredo Garcia 2de93bba8e
Limit the number of initial peers (#2913)
* limit the number of initial peers

* Move more code out of zebra_network::initialize

* Always limit the number of initial peers in the Config

This way, we can never get the unused peers out.

* Revert "Always limit the number of initial peers in the Config"

This reverts commit 81ede597c8.

Actually, this doesn't work, because we want those extra peers.

* Minor tweaks

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
Co-authored-by: teor <teor@riseup.net>
2021-10-21 23:04:46 +00:00
teor 4cdd12e2c4
Track the number of active inbound and outbound peer connections (#2912)
* Count the number of active inbound and outbound peer connections

And reduce the count when each connection fails.

* Fix a comment typo

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

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-21 21:36:42 +00:00
Marek 86d05c5e90
Update the documentation for value pools (#2919)
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-21 20:30:11 +00:00
Janito Vaqueiro Ferreira Filho 39ed7d70d3
Use single thread Tokio runtime for tests (#2916)
Newer versions of Tokio panic if `tokio::time::pause()` is called from a
multi-thread executor, and `#[tokio::test]` defaults to a single thread
runtime, so it makes sense to always use a single thread runtime in all
tests.
2021-10-21 16:22:12 +00:00
teor fc4a2664fd
Disable mempool large sync test unless specifically requested (#2924)
This matches the settings for `sync_large_checkpoints_mainnet`.

Also reduce the number of blocks synced to reduce network load.

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-21 12:30:11 +00:00
Janito Vaqueiro Ferreira Filho 192a45ccf1
Refactor rate limiting to not store `Sleep` type (#2915)
In newer Tokio versions the `Sleep` type doesn't implement `Unpin`, so
it's a little more complicated to use it. In this case it was easier to
refactor the code to not store the `Sleep` type instead of wrapping it
in a `Pin` type.
2021-10-21 11:47:04 +00:00
Marek d2a5af0ea5
V1.0.0 alpha.19 (#2907)
* Increment the crates that have new commits since the last version

* Increment the crates that depend on crates that have changed

* Increment the version of `zebra-script`

* Use the `zebrad` version in the `zebra-network` user agent string

* Use the `v1.0.0-alpha.19` git tag in `README.md`

* Copy the draft changelog into `CHANGELOG.md`

* Delete bumps

* Update CHANGELOG.md

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

* Add newly merged PRs

Co-authored-by: teor <teor@riseup.net>
2021-10-21 12:33:35 +02:00
teor 3db5ecb80e
Keep reading buffered test process output after it has exited (#2923) 2021-10-20 21:40:39 -04:00
Janito Vaqueiro Ferreira Filho 595d75d5fb
Fix synchronization delay issue (#2921)
* Create a `NowOrLater` helper type

A replacement for `FutureExt::now_or_never` that ensures that the task
is scheduled for waking up later when the inner future is ready.

* Use `NowOrLater` to fix possible delay bug

Previous usage of `now_or_never` meant that the underlying task wasn't
being scheduled to awake when the `Downloads` stream produced a new
item. Using `NowOrLater` instead fixes that issue.
2021-10-21 10:34:12 +10:00
Marek ffa6fed7b3
Improve the template for release versioning (#2906)
* Specify the location of the user agent string

* Specify the `cargo install` command

* Fix a typo

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
2021-10-20 18:02:07 +00:00
teor e277975d85
Try flushing streams before exiting Zebra (#2911) 2021-10-20 13:57:09 +00:00
teor 92634f788b
Increase Zebra's restart acceptance test timeout (#2910)
* Increase the restart test timeout to 10 seconds

It shouldn't take this long.
But maybe the CI VMs are under a lot of load?

* Add extensive logging to diagnose CI state reload failures
2021-10-20 01:59:09 +00:00
Conrado Gouvea 84f2c07fbc
Ignore AlreadyInChain error in the syncer (#2890)
* Ignore AlreadyInChain error in the syncer

* Split Cancelled errors; add them to should_restart_sync exceptions

* Also filter 'block is already comitted'; try to detect a wrong downcast
2021-10-20 11:07:19 +10:00
Conrado Gouvea a5d1467624
Additional mempool metrics (#2878)
* Rename tx downloader & verifier metrics

* Add version to mempool metrics

* Add new metrics

* Make sure mempool gauges are zeroed when instances are dropped

* Updated mempool grafana dashboard

* Removed transaction verification dashboard; moved to mempool

* Update mempool dashboard

* Add reason to error labels in mempool dashboard

* Rename some metrics per review

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-19 17:10:25 +00:00
teor 4b8b65a627
Avoid spurious acceptance test failures by decreasing the peer crawler timeout (#2905)
* Improve logging for initial peer connections

* Decrease the initial peer crawl timeout to make tests more reliable

Co-authored-by: Conrado Gouvea <conrado@zfnd.org>
2021-10-19 15:29:03 +00:00
dependabot[bot] 12a96e9bef
Bump structopt from 0.3.23 to 0.3.25 (#2899)
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.23 to 0.3.25.
- [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.23...v0.3.25)

---
updated-dependencies:
- dependency-name: structopt
  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: teor <teor@riseup.net>
2021-10-19 04:42:19 +00:00
dependabot[bot] 0b25257bef
Bump actions/checkout from 2.3.4 to 2.3.5 (#2898)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.4 to 2.3.5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2.3.4...v2.3.5)

---
updated-dependencies:
- dependency-name: actions/checkout
  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: teor <teor@riseup.net>
2021-10-19 04:03:10 +00:00
Conrado Gouvea 128b8be95d
Improve mempool::downloads documentation (#2879)
* Improve mempool::downloads documentation

* Apply suggestions from code review

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

Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-18 20:02:40 +00:00
teor 303c8cf5ef
Add a queue checker task, to make sure mempool transactions propagate (#2888)
* Guarantee unique IDs in mempool service responses

* Guarantee unique IDs in crawler task mempool Queue requests

Also update the tests to use unique IDs.

* Add a CheckForVerifiedTransactions mempool request

Also document the mempool request and response variants.

* Spawn a QueueChecker task to check for newly verified transactions

This task makes sure that transactions reliably propagate,
rather than relying on peer requests or responses to trigger propagation.

* Update the start command documentation

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-18 19:23:21 +00:00
teor c8ad19080a
Improve logging for initial peer connections (#2896)
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2021-10-18 18:43:12 +00:00