From 6902ef35370e5980a76302fc756e1a9a56af21b5 Mon Sep 17 00:00:00 2001 From: noot <36753753+noot@users.noreply.github.com> Date: Mon, 10 Jun 2024 13:44:42 -0400 Subject: [PATCH] chore: bump msrv and run clippy (#1167) ## Summary latest rust is now 1.79 and also our code was using items supported in rust 1.76 and the ci is using 1.76.0, so the msrv should be bumped: ``` error: current MSRV (Minimum Supported Rust Version) is `1.73.0` but this item is stable since `1.76.0` --> crates/astria-conductor/src/celestia/convert.rs:151:10 | 151 | .inspect_err(|err| { | __________^ 152 | | info!( 153 | | error = err as &StdError, 154 | | target = SubmittedMetadataList::full_name(), 155 | | "failed decoding blob bytes; dropping the blob", 156 | | ); 157 | | }) | |__________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv ``` also ran clippy and fixed the various lint issues. --- .github/workflows/test.yml | 2 +- crates/astria-bridge-withdrawer/Cargo.toml | 2 +- crates/astria-composer/Cargo.toml | 2 +- crates/astria-composer/src/composer.rs | 2 +- crates/astria-composer/src/config.rs | 2 +- crates/astria-composer/src/executor/tests.rs | 6 +- crates/astria-conductor/Cargo.toml | 2 +- crates/astria-conductor/src/celestia/mod.rs | 6 +- .../tests/blackbox/helpers/mock_grpc.rs | 2 +- crates/astria-core/Cargo.toml | 2 +- crates/astria-core/src/primitive/v1/mod.rs | 2 +- .../src/sequencerblock/v1alpha1/mod.rs | 2 +- crates/astria-sequencer-client/Cargo.toml | 2 +- crates/astria-sequencer-relayer/Cargo.toml | 2 +- crates/astria-sequencer-relayer/src/lib.rs | 1 - .../src/relayer/mod.rs | 13 +--- .../src/relayer/write/conversion.rs | 4 +- .../astria-sequencer-relayer/src/validator.rs | 59 ------------------- .../helpers/mock_celestia_app_server.rs | 2 +- .../blackbox/helpers/mock_sequencer_server.rs | 2 +- crates/astria-sequencer/Cargo.toml | 2 +- 21 files changed, 24 insertions(+), 95 deletions(-) delete mode 100644 crates/astria-sequencer-relayer/src/validator.rs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f1818a6118..22dc6f9fde 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -173,7 +173,7 @@ jobs: - uses: actions/checkout@v4 with: submodules: 'true' - - uses: dtolnay/rust-toolchain@1.76.0 + - uses: dtolnay/rust-toolchain@1.78.0 with: components: clippy - uses: Swatinem/rust-cache@v2.7.3 diff --git a/crates/astria-bridge-withdrawer/Cargo.toml b/crates/astria-bridge-withdrawer/Cargo.toml index 4f5a98de05..fa4970f9fb 100644 --- a/crates/astria-bridge-withdrawer/Cargo.toml +++ b/crates/astria-bridge-withdrawer/Cargo.toml @@ -2,7 +2,7 @@ name = "astria-bridge-withdrawer" version = "0.1.0" edition = "2021" -rust-version = "1.73" +rust-version = "1.76" license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/astriaorg/astria" diff --git a/crates/astria-composer/Cargo.toml b/crates/astria-composer/Cargo.toml index 45d44bd362..d37f07078b 100644 --- a/crates/astria-composer/Cargo.toml +++ b/crates/astria-composer/Cargo.toml @@ -2,7 +2,7 @@ name = "astria-composer" version = "0.7.0" edition = "2021" -rust-version = "1.73" +rust-version = "1.76" license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/astriaorg/astria" diff --git a/crates/astria-composer/src/composer.rs b/crates/astria-composer/src/composer.rs index 90a01b56b1..e22bba7244 100644 --- a/crates/astria-composer/src/composer.rs +++ b/crates/astria-composer/src/composer.rs @@ -79,7 +79,7 @@ pub struct Composer { /// The map of chain ID to the URLs to which geth collectors should connect. rollups: HashMap, /// The gRPC server that listens for incoming requests from the collectors via the - /// GrpcCollector service. It also exposes a health service. + /// `GrpcCollector` service. It also exposes a health service. grpc_server: GrpcServer, /// Used to signal the Composer to shut down. shutdown_token: CancellationToken, diff --git a/crates/astria-composer/src/config.rs b/crates/astria-composer/src/config.rs index 0dbc55bb8d..778bd84ccb 100644 --- a/crates/astria-composer/src/config.rs +++ b/crates/astria-composer/src/config.rs @@ -22,7 +22,7 @@ pub struct Config { /// The chain ID of the sequencer chain pub sequencer_chain_id: String, - /// A list of :: pairs + /// A list of `::` pairs pub rollups: String, /// Path to private key for the sequencer account used for signing transactions diff --git a/crates/astria-composer/src/executor/tests.rs b/crates/astria-composer/src/executor/tests.rs index 3cffccaa97..0e37b1da9b 100644 --- a/crates/astria-composer/src/executor/tests.rs +++ b/crates/astria-composer/src/executor/tests.rs @@ -263,7 +263,7 @@ async fn full_bundle() { // verify only one signed transaction was received by the mock sequencer // i.e. only the full bundle was sent and not the second one due to the block timer - let expected_seq_actions = vec![seq0]; + let expected_seq_actions = [seq0]; let requests = response_guard.received_requests().await; assert_eq!(requests.len(), 1); @@ -347,7 +347,7 @@ async fn bundle_triggered_by_block_timer() { .unwrap(); // verify only one signed transaction was received by the mock sequencer - let expected_seq_actions = vec![seq0]; + let expected_seq_actions = [seq0]; let requests = response_guard.received_requests().await; assert_eq!(requests.len(), 1); @@ -441,7 +441,7 @@ async fn two_seq_actions_single_bundle() { .unwrap(); // verify only one signed transaction was received by the mock sequencer - let expected_seq_actions = vec![seq0, seq1]; + let expected_seq_actions = [seq0, seq1]; let requests = response_guard.received_requests().await; assert_eq!(requests.len(), 1); diff --git a/crates/astria-conductor/Cargo.toml b/crates/astria-conductor/Cargo.toml index 71bb111996..656f9fddd5 100644 --- a/crates/astria-conductor/Cargo.toml +++ b/crates/astria-conductor/Cargo.toml @@ -2,7 +2,7 @@ name = "astria-conductor" version = "0.17.0" edition = "2021" -rust-version = "1.73" +rust-version = "1.76" license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/astriaorg/astria" diff --git a/crates/astria-conductor/src/celestia/mod.rs b/crates/astria-conductor/src/celestia/mod.rs index d69b87f764..9db1dfa6c8 100644 --- a/crates/astria-conductor/src/celestia/mod.rs +++ b/crates/astria-conductor/src/celestia/mod.rs @@ -223,15 +223,15 @@ struct RunningReader { /// The next Celestia height that will be fetched. celestia_next_height: u64, - /// The reference Celestia height. celestia_reference_height + celestia_variance = C is the + /// The reference Celestia height. `celestia_reference_height` + `celestia_variance` = C is the /// maximum Celestia height up to which Celestia's blobs will be fetched. - /// celestia_reference_height is initialized to the base Celestia height stored in the + /// `celestia_reference_height` is initialized to the base Celestia height stored in the /// rollup genesis. It is later advanced to that Celestia height from which the next block /// is derived that will be executed against the rollup (only if greater than the current /// value; it will never go down). celestia_reference_height: u64, - /// celestia_variance + celestia_reference_height define the maximum Celestia height from + /// `celestia_variance` + `celestia_reference_height` define the maximum Celestia height from /// Celestia blobs can be fetched. Set once during initialization to the value stored in /// the rollup genesis. celestia_variance: u64, diff --git a/crates/astria-conductor/tests/blackbox/helpers/mock_grpc.rs b/crates/astria-conductor/tests/blackbox/helpers/mock_grpc.rs index f9f857f4b6..bf0b5807e6 100644 --- a/crates/astria-conductor/tests/blackbox/helpers/mock_grpc.rs +++ b/crates/astria-conductor/tests/blackbox/helpers/mock_grpc.rs @@ -46,7 +46,7 @@ use tonic::{ }; pub struct MockGrpc { - pub _server: JoinHandle>, + _server: JoinHandle>, pub mock_server: MockServer, pub local_addr: SocketAddr, } diff --git a/crates/astria-core/Cargo.toml b/crates/astria-core/Cargo.toml index b9ca603ebe..98f4e90606 100644 --- a/crates/astria-core/Cargo.toml +++ b/crates/astria-core/Cargo.toml @@ -2,7 +2,7 @@ name = "astria-core" version = "0.1.0" edition = "2021" -rust-version = "1.73" +rust-version = "1.76" license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/astriaorg/astria" diff --git a/crates/astria-core/src/primitive/v1/mod.rs b/crates/astria-core/src/primitive/v1/mod.rs index 413340470e..2af5046607 100644 --- a/crates/astria-core/src/primitive/v1/mod.rs +++ b/crates/astria-core/src/primitive/v1/mod.rs @@ -529,7 +529,7 @@ impl std::fmt::Display for Address { /// It is the responsibility of the caller to ensure that the iterable is /// deterministic. Prefer types like `Vec`, `BTreeMap` or `IndexMap` over /// `HashMap`. -pub fn derive_merkle_tree_from_rollup_txs<'a, T: 'a, U: 'a>(rollup_ids_to_txs: T) -> merkle::Tree +pub fn derive_merkle_tree_from_rollup_txs<'a, T, U>(rollup_ids_to_txs: T) -> merkle::Tree where T: IntoIterator, U: AsRef<[Vec]> + 'a + ?Sized, diff --git a/crates/astria-core/src/sequencerblock/v1alpha1/mod.rs b/crates/astria-core/src/sequencerblock/v1alpha1/mod.rs index 62487151cd..21ed5ed2c9 100644 --- a/crates/astria-core/src/sequencerblock/v1alpha1/mod.rs +++ b/crates/astria-core/src/sequencerblock/v1alpha1/mod.rs @@ -24,7 +24,7 @@ use crate::{ }, }; -pub(crate) fn are_rollup_ids_included<'a, TRollupIds: 'a>( +pub(crate) fn are_rollup_ids_included( ids: TRollupIds, proof: &merkle::Proof, data_hash: [u8; 32], diff --git a/crates/astria-sequencer-client/Cargo.toml b/crates/astria-sequencer-client/Cargo.toml index 895770330c..d86fa7bb6a 100644 --- a/crates/astria-sequencer-client/Cargo.toml +++ b/crates/astria-sequencer-client/Cargo.toml @@ -3,7 +3,7 @@ name = "astria-sequencer-client" version = "0.1.0" edition = "2021" license = "MIT OR Apache-2.0" -rust-version = "1.73" +rust-version = "1.76" repository = "https://github.com/astriaorg/astria" homepage = "https://astria.org" diff --git a/crates/astria-sequencer-relayer/Cargo.toml b/crates/astria-sequencer-relayer/Cargo.toml index ee7a25dedb..0805cbbd8f 100644 --- a/crates/astria-sequencer-relayer/Cargo.toml +++ b/crates/astria-sequencer-relayer/Cargo.toml @@ -3,7 +3,7 @@ name = "astria-sequencer-relayer" version = "0.14.0" edition = "2021" license = "MIT OR Apache-2.0" -rust-version = "1.73" +rust-version = "1.76" readme = "README.md" repository = "https://github.com/astriaorg/astria" homepage = "https://astria.org" diff --git a/crates/astria-sequencer-relayer/src/lib.rs b/crates/astria-sequencer-relayer/src/lib.rs index d6eb436f72..0f93186249 100644 --- a/crates/astria-sequencer-relayer/src/lib.rs +++ b/crates/astria-sequencer-relayer/src/lib.rs @@ -5,7 +5,6 @@ pub mod metrics_init; pub(crate) mod relayer; pub mod sequencer_relayer; pub(crate) mod utils; -pub(crate) mod validator; pub use build_info::BUILD_INFO; pub use config::{ diff --git a/crates/astria-sequencer-relayer/src/relayer/mod.rs b/crates/astria-sequencer-relayer/src/relayer/mod.rs index eda2515641..bc631abdcb 100644 --- a/crates/astria-sequencer-relayer/src/relayer/mod.rs +++ b/crates/astria-sequencer-relayer/src/relayer/mod.rs @@ -53,10 +53,7 @@ use tracing::{ Span, }; -use crate::{ - validator::Validator, - IncludeRollup, -}; +use crate::IncludeRollup; mod builder; mod celestia_client; @@ -370,11 +367,3 @@ fn spawn_submitter( ); (tokio::spawn(submitter.run()), handle) } - -struct ReportValidator<'a>(&'a Validator); - -impl<'a> std::fmt::Display for ReportValidator<'a> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_fmt(format_args!("{}", self.0.address)) - } -} diff --git a/crates/astria-sequencer-relayer/src/relayer/write/conversion.rs b/crates/astria-sequencer-relayer/src/relayer/write/conversion.rs index ba6753e452..dd0b6aa5f4 100644 --- a/crates/astria-sequencer-relayer/src/relayer/write/conversion.rs +++ b/crates/astria-sequencer-relayer/src/relayer/write/conversion.rs @@ -449,7 +449,7 @@ where .serialize(serializer) } -fn serialize_sequencer_heights<'a, I: 'a, S>(heights: I, serializer: S) -> Result +fn serialize_sequencer_heights<'a, I, S>(heights: I, serializer: S) -> Result where I: IntoIterator, S: serde::ser::Serializer, @@ -457,7 +457,7 @@ where serializer.collect_seq(heights.into_iter().map(tendermint::block::Height::value)) } -fn serialize_included_rollups<'a, I: 'a, S>(rollups: I, serializer: S) -> Result +fn serialize_included_rollups<'a, I, S>(rollups: I, serializer: S) -> Result where I: IntoIterator, S: serde::ser::Serializer, diff --git a/crates/astria-sequencer-relayer/src/validator.rs b/crates/astria-sequencer-relayer/src/validator.rs deleted file mode 100644 index dc385735a8..0000000000 --- a/crates/astria-sequencer-relayer/src/validator.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::path::Path; - -use astria_eyre::eyre::{ - self, - WrapErr as _, -}; -use tendermint::account; -use tendermint_config::PrivValidatorKey; -use tracing::instrument; - -/// `Validator` holds the ed25519 keys to sign and verify tendermint -/// messages. It also contains its address (`AccountId`) in the tendermint network. -#[derive(Clone, Debug)] -pub(crate) struct Validator { - /// The tendermint validator account address; defined as - /// Sha256(verification_key)[..20]. - pub(super) address: account::Id, -} - -impl Validator { - /// Constructs a `Validator` from a json formatted tendermint private validator key. - /// - /// This file is frequently called `private_validator_key.json` and is generated during - /// the initialization of a tendermint node. - #[instrument(skip_all, fields(path = %path.as_ref().display(), err))] - pub(crate) fn from_path(path: impl AsRef) -> eyre::Result { - let key = PrivValidatorKey::load_json_file(&path.as_ref()) - .wrap_err("failed reading private validator key from file")?; - Ok(Self { - address: key.address, - }) - } -} - -#[cfg(test)] -mod tests { - use super::Validator; - - const VALIDATOR_FILE_BODY: &str = r#" -{ - "address": "468646B2BD3E75229B2163F4D7905748FEC7603E", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "Fj/2NzG404f+CjHJUThMXNS7xJY5GMPuFVlKMKb86MA=" - }, - "priv_key": { - "type": "tendermint/PrivKeyEd25519", - "value": "1hBYYTBKxkMODNTW6Pk//kA023UAkpgSLhM0SjwndSkWP/Y3MbjTh/4KMclROExc1LvEljkYw+4VWUowpvzowA==" - } -} -"#; - - #[test] - fn valid_validator_keys_can_be_read_from_file() { - let tmp_file = tempfile::NamedTempFile::new().unwrap(); - std::fs::write(tmp_file.path(), VALIDATOR_FILE_BODY).unwrap(); - Validator::from_path(tmp_file.path()).unwrap(); - } -} diff --git a/crates/astria-sequencer-relayer/tests/blackbox/helpers/mock_celestia_app_server.rs b/crates/astria-sequencer-relayer/tests/blackbox/helpers/mock_celestia_app_server.rs index a20690b70c..940592d907 100644 --- a/crates/astria-sequencer-relayer/tests/blackbox/helpers/mock_celestia_app_server.rs +++ b/crates/astria-sequencer-relayer/tests/blackbox/helpers/mock_celestia_app_server.rs @@ -100,7 +100,7 @@ const GET_TX_GRPC_NAME: &str = "get_tx"; const BROADCAST_TX_GRPC_NAME: &str = "broadcast_tx"; pub struct MockCelestiaAppServer { - pub _server: JoinHandle>, + _server: JoinHandle>, pub mock_server: MockServer, pub local_addr: SocketAddr, pub namespaces: Arc>>, diff --git a/crates/astria-sequencer-relayer/tests/blackbox/helpers/mock_sequencer_server.rs b/crates/astria-sequencer-relayer/tests/blackbox/helpers/mock_sequencer_server.rs index dd652fd1be..a1cca888f5 100644 --- a/crates/astria-sequencer-relayer/tests/blackbox/helpers/mock_sequencer_server.rs +++ b/crates/astria-sequencer-relayer/tests/blackbox/helpers/mock_sequencer_server.rs @@ -44,7 +44,7 @@ const GET_SEQUENCER_BLOCK_GRPC_NAME: &str = "get_sequencer_block"; const GET_FILTERED_SEQUENCER_BLOCK_GRPC_NAME: &str = "get_filtered_sequencer_block"; pub struct MockSequencerServer { - pub _server: JoinHandle>, + _server: JoinHandle>, pub mock_server: MockServer, pub local_addr: SocketAddr, } diff --git a/crates/astria-sequencer/Cargo.toml b/crates/astria-sequencer/Cargo.toml index 51648227b6..bd282d7fb0 100644 --- a/crates/astria-sequencer/Cargo.toml +++ b/crates/astria-sequencer/Cargo.toml @@ -3,7 +3,7 @@ name = "astria-sequencer" version = "0.13.0" edition = "2021" license = "MIT OR Apache-2.0" -rust-version = "1.73" +rust-version = "1.76" readme = "README.md" repository = "https://github.com/astriaorg/astria" homepage = "https://astria.org"