Skip to content

Commit

Permalink
Merge branch 'main' into ci-refactor-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavovalverde authored Jan 24, 2022
2 parents 4fd0064 + 9101e9a commit 7703c7b
Show file tree
Hide file tree
Showing 33 changed files with 153 additions and 208 deletions.
19 changes: 19 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

[target.'cfg(all())']
rustflags = [
# Zebra standard lints for Rust 1.58+
"-Dunsafe_code",
"-Drust_2021_compatibility",
"-Dclippy::await_holding_lock",

"-Wmissing_docs",
"-Wnonstandard_style",
"-Wfuture_incompatible",

"-Aclippy::try_err",

# TODOs:

# fix hidden lifetime parameters
#"-Wrust_2018_idioms",
]
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
# Vscode detrius
.vscode/
.zebra-state/
.cargo/
# Nix configs
shell.nix
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion book/src/dev/rfcs/0005-state-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ We use the following rocksdb column families:
| `tx_by_location` | `TransactionLocation` | `Transaction` | Never |
| `hash_by_tx` | `TransactionLocation` | `transaction::Hash` | Never |
| `tx_by_hash` | `transaction::Hash` | `TransactionLocation` | Never |
| `utxo_by_outpoint` | `OutLocation` | `transparent::Utxo` | Delete |
| `utxo_by_outpoint` | `OutLocation` | `transparent::Output` | Delete |
| `balance_by_transparent_addr` | `transparent::Address` | `Amount \|\| FirstOutLocation` | Update |
| `utxo_by_transparent_addr_loc` | `FirstOutLocation` | `AtLeastOne<OutLocation>` | Up/Del |
| `tx_by_transparent_addr_loc` | `FirstOutLocation` | `AtLeastOne<TransactionLocation>` | Append |
Expand Down
7 changes: 7 additions & 0 deletions book/src/dev/rfcs/0011-async-rust-in-zebra.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,13 @@ For example, [`tokio::sync::watch::Receiver::borrow`](https://docs.rs/tokio/1.15
holds a read lock, so the borrowed data should always be cloned.
Use `Arc` for efficient clones if needed.

Never have two active watch borrow guards in the same scope, because that can cause a deadlock. The
`watch::Sender` may start acquiring a write lock while the first borrow guard is active but the
second one isn't. That means that the first read lock was acquired, but the second never will be
because starting to acquire the write lock blocks any other read locks from being acquired. At the
same time, the write lock will also never finish acquiring, because it waits for all read locks to
be released, and the first read lock won't be released before the second read lock is acquired.

In all of these cases:
- make critical sections as short as possible, and
- do not depend on other tasks or locks inside the critical section.
Expand Down
7 changes: 0 additions & 7 deletions tower-batch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@
//! control logic, as it will receive explicit [`Flush`](BatchControl::Flush)
//! requests from the wrapper.
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]

pub mod error;
pub mod future;
mod layer;
Expand Down
6 changes: 0 additions & 6 deletions tower-batch/tests/ed25519.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use std::{
future::Future,
mem,
Expand Down
6 changes: 0 additions & 6 deletions tower-batch/tests/worker.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use std::time::Duration;
use tokio_test::{assert_pending, assert_ready, assert_ready_err, task};
use tower::{Service, ServiceExt};
Expand Down
7 changes: 0 additions & 7 deletions tower-fallback/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
//!
//! [aws-fallback]: https://aws.amazon.com/builders-library/avoiding-fallback-in-distributed-systems/
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]

pub mod future;
mod service;

Expand Down
6 changes: 0 additions & 6 deletions tower-fallback/tests/fallback.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use tower::{service_fn, Service, ServiceExt};
use tower_fallback::Fallback;

Expand Down
6 changes: 1 addition & 5 deletions zebra-chain/benches/block.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Standard lints
// Disabled due to warnings in criterion macros
//#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]
#![allow(missing_docs)]

use std::io::Cursor;

Expand Down
3 changes: 2 additions & 1 deletion zebra-chain/benches/redpallas.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Benchmarks for batch verifiication of RedPallas signatures.
use std::convert::TryFrom;
// Disabled due to warnings in criterion macros
#![allow(missing_docs)]

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use rand::{thread_rng, Rng};
Expand Down
5 changes: 5 additions & 0 deletions zebra-chain/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//! Build script for zebra-chain.
//!
//! Turns the environmental variable `$TEST_FAKE_ACTIVATION_HEIGHTS`
//! into the Rust configuration `cfg(test_fake_activation_heights)`.
use std::env;

fn main() {
Expand Down
6 changes: 0 additions & 6 deletions zebra-chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_chain")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]
// Required by bitvec! macro
#![recursion_limit = "256"]

Expand Down
6 changes: 0 additions & 6 deletions zebra-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_client")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]
7 changes: 0 additions & 7 deletions zebra-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_consensus")]
// Standard lints
// Warn on missing docs for all modules after cleaning the API surface
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]

mod block;
mod checkpoint;
Expand Down
6 changes: 0 additions & 6 deletions zebra-network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_network")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]

#[macro_use]
extern crate pin_project;
Expand Down
6 changes: 0 additions & 6 deletions zebra-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_rpc")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]
12 changes: 4 additions & 8 deletions zebra-script/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_script")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
// we allow unsafe code, so we can call zcash_script

use std::{convert::TryInto, sync::Arc};
// We allow unsafe code, so we can call zcash_script
#![allow(unsafe_code)]

use std::sync::Arc;

use displaydoc::Display;
use thiserror::Error;
Expand Down
5 changes: 5 additions & 0 deletions zebra-state/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//! Build script for zebra-state.
//!
//! Turns the environmental variable `$TEST_FAKE_ACTIVATION_HEIGHTS`
//! into the Rust configuration `cfg(test_fake_activation_heights)`.
use std::env;

fn main() {
Expand Down
6 changes: 0 additions & 6 deletions zebra-state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_state")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]

#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
Expand Down
Loading

0 comments on commit 7703c7b

Please sign in to comment.