From e50801a92fbed0b832317cc0e895d1af8009ff38 Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Thu, 19 Dec 2024 05:37:55 -0300 Subject: [PATCH 1/7] chore: bump nightly to 2024-12-12 --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b7e6eae06..55abb718a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2024-07-27" +channel = "nightly-2024-12-12" components = [ "cargo", "clippy", From 12d54661d016211af93ad76e24b0a49b0078c204 Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Thu, 19 Dec 2024 05:38:40 -0300 Subject: [PATCH 2/7] chore: clippy lints --- bin/strata-cli/src/recovery.rs | 6 +++--- crates/btcio/src/rpc/types.rs | 14 +++++++------- crates/reth/exex/src/cache_db_provider.rs | 2 +- crates/state/src/operation.rs | 3 +-- crates/test-utils/src/bitcoin.rs | 2 +- crates/zkvm/adapters/sp1/src/input.rs | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/bin/strata-cli/src/recovery.rs b/bin/strata-cli/src/recovery.rs index 2cf301344..9a5d973a1 100644 --- a/bin/strata-cli/src/recovery.rs +++ b/bin/strata-cli/src/recovery.rs @@ -49,9 +49,9 @@ impl DescriptorRecovery { .map(|(pubk, privk)| [pubk.to_string(), privk.to_string()]) .map(|[pubk, privk]| { ( - (pubk.as_bytes().len() as u32).to_le_bytes(), + (pubk.len() as u32).to_le_bytes(), pubk, - (privk.as_bytes().len() as u32).to_le_bytes(), + (privk.len() as u32).to_le_bytes(), privk, ) }); @@ -78,7 +78,7 @@ impl DescriptorRecovery { let keymap_len = keymap_iter .clone() .map(|(pubk_len, pubk, privk_len, privk)| { - pubk_len.len() + pubk.as_bytes().len() + privk_len.len() + privk.as_bytes().len() + pubk_len.len() + pubk.len() + privk_len.len() + privk.len() }) .sum::(); diff --git a/crates/btcio/src/rpc/types.rs b/crates/btcio/src/rpc/types.rs index fb78060af..64cc76f3a 100644 --- a/crates/btcio/src/rpc/types.rs +++ b/crates/btcio/src/rpc/types.rs @@ -393,7 +393,7 @@ where { struct SatVisitor; - impl<'d> Visitor<'d> for SatVisitor { + impl Visitor<'_> for SatVisitor { type Value = Amount; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -418,7 +418,7 @@ where { struct SatVisitor; - impl<'d> Visitor<'d> for SatVisitor { + impl Visitor<'_> for SatVisitor { type Value = SignedAmount; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -456,7 +456,7 @@ where { struct TxidVisitor; - impl<'d> Visitor<'d> for TxidVisitor { + impl Visitor<'_> for TxidVisitor { type Value = Txid; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -482,7 +482,7 @@ where { struct TxVisitor; - impl<'d> Visitor<'d> for TxVisitor { + impl Visitor<'_> for TxVisitor { type Value = Transaction; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -512,7 +512,7 @@ where D: Deserializer<'d>, { struct AddressVisitor; - impl<'d> Visitor<'d> for AddressVisitor { + impl Visitor<'_> for AddressVisitor { type Value = Address; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -539,7 +539,7 @@ where { struct BlockHashVisitor; - impl<'d> Visitor<'d> for BlockHashVisitor { + impl Visitor<'_> for BlockHashVisitor { type Value = BlockHash; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -565,7 +565,7 @@ where { struct HeightVisitor; - impl<'d> Visitor<'d> for HeightVisitor { + impl Visitor<'_> for HeightVisitor { type Value = Height; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { diff --git a/crates/reth/exex/src/cache_db_provider.rs b/crates/reth/exex/src/cache_db_provider.rs index ae0404b2c..247eaba0e 100644 --- a/crates/reth/exex/src/cache_db_provider.rs +++ b/crates/reth/exex/src/cache_db_provider.rs @@ -136,6 +136,6 @@ impl DatabaseRef for CacheDBProvider { fn block_hash_ref(&self, number: u64) -> Result { self.provider .block_hash(number)? - .ok_or_else(|| ProviderError::BlockBodyIndicesNotFound(number)) + .ok_or(ProviderError::BlockBodyIndicesNotFound(number)) } } diff --git a/crates/state/src/operation.rs b/crates/state/src/operation.rs index f871910a0..43e1d08e8 100644 --- a/crates/state/src/operation.rs +++ b/crates/state/src/operation.rs @@ -238,8 +238,7 @@ pub fn apply_writes_to_state( // Check if heights match accordingly if !l1v .last_finalized_checkpoint - .as_ref() - .map_or(true, |prev_chp| { + .as_ref().is_none_or(|prev_chp| { checkpt.batch_info.idx() == prev_chp.batch_info.idx() + 1 }) { diff --git a/crates/test-utils/src/bitcoin.rs b/crates/test-utils/src/bitcoin.rs index edde1497d..f448ea6ff 100644 --- a/crates/test-utils/src/bitcoin.rs +++ b/crates/test-utils/src/bitcoin.rs @@ -65,7 +65,7 @@ impl BtcChainSegment { } pub fn get_block(&self, height: u32) -> &Block { - return self.custom_blocks.get(&height).unwrap(); + self.custom_blocks.get(&height).unwrap() } /// Retrieves the timestamps of `N` blocks from a given height diff --git a/crates/zkvm/adapters/sp1/src/input.rs b/crates/zkvm/adapters/sp1/src/input.rs index 9e253f692..d574b5eb2 100644 --- a/crates/zkvm/adapters/sp1/src/input.rs +++ b/crates/zkvm/adapters/sp1/src/input.rs @@ -5,7 +5,7 @@ use strata_zkvm::{AggregationInput, ZKVMInputBuilder}; // A wrapper around SP1Stdin pub struct SP1ProofInputBuilder(SP1Stdin); -impl<'a> ZKVMInputBuilder<'a> for SP1ProofInputBuilder { +impl ZKVMInputBuilder<'_> for SP1ProofInputBuilder { type Input = SP1Stdin; fn new() -> SP1ProofInputBuilder { SP1ProofInputBuilder(SP1Stdin::new()) From 373d6ef2520f5e3b4d39a3928cdcaa3328c6de4d Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Thu, 19 Dec 2024 05:43:18 -0300 Subject: [PATCH 3/7] fix: stable_features for the sp1 toolchain --- crates/state/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs index 85014f0c0..d3b5cefed 100644 --- a/crates/state/src/lib.rs +++ b/crates/state/src/lib.rs @@ -1,5 +1,5 @@ -#![allow(dead_code)] // TODO: remove once the bridge state `sanity_check` fn is used. -#![feature(is_sorted)] // TODO: switch to using crate +#![allow(stable_features)] // FIX: this is needed for sp1 toolchain. +#![feature(is_sorted, is_none_or)] //! Rollup types relating to the consensus-layer state of the rollup. //! From ada1347165ee6e386d7258c517fdecf98c8bf89b Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Thu, 19 Dec 2024 05:43:29 -0300 Subject: [PATCH 4/7] chore: allow dead_code lints --- crates/state/src/bridge_state.rs | 2 ++ crates/storage/src/cache.rs | 4 ++++ crates/storage/src/exec.rs | 4 ++++ crates/tasks/src/pending_tasks.rs | 1 + provers/sp1/tests/helpers/btc.rs | 1 + provers/sp1/tests/helpers/checkpoint.rs | 1 + provers/sp1/tests/helpers/cl.rs | 1 + provers/sp1/tests/helpers/el.rs | 1 + provers/sp1/tests/helpers/l1_batch.rs | 1 + provers/sp1/tests/helpers/l2_batch.rs | 1 + 10 files changed, 17 insertions(+) diff --git a/crates/state/src/bridge_state.rs b/crates/state/src/bridge_state.rs index 1bc2122d8..b6983b611 100644 --- a/crates/state/src/bridge_state.rs +++ b/crates/state/src/bridge_state.rs @@ -94,6 +94,7 @@ impl OperatorTable { } /// Sanity checks the operator table for sensibility. + #[allow(dead_code)] // #FIXME: remove this. fn sanity_check(&self) { if !self.operators.is_sorted_by_key(|e| e.idx) { panic!("bridge_state: operators list not sorted"); @@ -205,6 +206,7 @@ impl DepositsTable { } /// Sanity checks the operator table for sensibility. + #[allow(dead_code)] // #FIXME: remove this. fn sanity_check(&self) { if !self.deposits.is_sorted_by_key(|e| e.deposit_idx) { panic!("bridge_state: deposits list not sorted"); diff --git a/crates/storage/src/cache.rs b/crates/storage/src/cache.rs index b255e6aac..d110eb572 100644 --- a/crates/storage/src/cache.rs +++ b/crates/storage/src/cache.rs @@ -85,6 +85,7 @@ impl CacheTable { /// Gets the number of elements in the cache. // TODO replace this with an atomic we update after every op + #[allow(dead_code)] // #FIXME: remove this. pub async fn get_len_async(&self) -> usize { let cache = self.cache.lock().await; cache.len() @@ -92,6 +93,7 @@ impl CacheTable { /// Gets the number of elements in the cache. // TODO replace this with an atomic we update after every op + #[allow(dead_code)] // #FIXME: remove this. pub fn get_len_blocking(&self) -> usize { let cache = self.cache.blocking_lock(); cache.len() @@ -110,6 +112,7 @@ impl CacheTable { } /// Inserts an entry into the table, dropping the previous value. + #[allow(dead_code)] // #FIXME: remove this. pub async fn insert_async(&self, k: K, v: V) { let slot = Arc::new(RwLock::new(SlotState::Ready(v))); let mut cache = self.cache.lock().await; @@ -117,6 +120,7 @@ impl CacheTable { } /// Inserts an entry into the table, dropping the previous value. + #[allow(dead_code)] // #FIXME: remove this. pub fn insert_blocking(&self, k: K, v: V) { let slot = Arc::new(RwLock::new(SlotState::Ready(v))); let mut cache = self.cache.blocking_lock(); diff --git a/crates/storage/src/exec.rs b/crates/storage/src/exec.rs index 7bf5bc42d..6f435fe16 100644 --- a/crates/storage/src/exec.rs +++ b/crates/storage/src/exec.rs @@ -12,6 +12,7 @@ pub use tracing::*; pub type DbRecv = tokio::sync::oneshot::Receiver>; /// Shim to opaquely execute the operation without being aware of the underlying impl. +#[allow(dead_code)] // #FIXME: remove this. pub struct OpShim { executor_fn: Arc DbResult + Sync + Send + 'static>, } @@ -21,6 +22,7 @@ where T: Sync + Send + 'static, R: Sync + Send + 'static, { + #[allow(dead_code)] // #FIXME: remove this. pub fn wrap(op: F) -> Self where F: Fn(T) -> DbResult + Sync + Send + 'static, @@ -31,6 +33,7 @@ where } /// Executes the operation on the provided thread pool and returns the result over. + #[allow(dead_code)] // #FIXME: remove this. pub async fn exec_async(&self, pool: &threadpool::ThreadPool, arg: T) -> DbResult { let (resp_tx, resp_rx) = tokio::sync::oneshot::channel(); @@ -50,6 +53,7 @@ where } /// Executes the operation directly. + #[allow(dead_code)] // #FIXME: remove this. pub fn exec_blocking(&self, arg: T) -> DbResult { (self.executor_fn)(arg) } diff --git a/crates/tasks/src/pending_tasks.rs b/crates/tasks/src/pending_tasks.rs index c34991aad..77db0afad 100644 --- a/crates/tasks/src/pending_tasks.rs +++ b/crates/tasks/src/pending_tasks.rs @@ -24,6 +24,7 @@ impl PendingTasks { } } + #[allow(dead_code)] // #FIXME: remove this. pub fn current(&self) -> usize { self.counter.load(Ordering::SeqCst) } diff --git a/provers/sp1/tests/helpers/btc.rs b/provers/sp1/tests/helpers/btc.rs index ca42038ce..f74950d91 100644 --- a/provers/sp1/tests/helpers/btc.rs +++ b/provers/sp1/tests/helpers/btc.rs @@ -16,6 +16,7 @@ use crate::helpers::proof_generator::ProofGenerator; pub struct BtcBlockProofGenerator; impl BtcBlockProofGenerator { + #[allow(dead_code)] // #FIXME: remove this. pub fn new() -> Self { Self } diff --git a/provers/sp1/tests/helpers/checkpoint.rs b/provers/sp1/tests/helpers/checkpoint.rs index 1fd8fc5eb..56243cde9 100644 --- a/provers/sp1/tests/helpers/checkpoint.rs +++ b/provers/sp1/tests/helpers/checkpoint.rs @@ -21,6 +21,7 @@ pub struct CheckpointProofGenerator { } impl CheckpointProofGenerator { + #[allow(dead_code)] // #FIXME: remove this. pub fn new( l1_batch_proof_generator: L1BatchProofGenerator, l2_batch_proof_generator: L2BatchProofGenerator, diff --git a/provers/sp1/tests/helpers/cl.rs b/provers/sp1/tests/helpers/cl.rs index 737bb14d6..2a19dd745 100644 --- a/provers/sp1/tests/helpers/cl.rs +++ b/provers/sp1/tests/helpers/cl.rs @@ -20,6 +20,7 @@ pub struct ClProofGenerator { } impl ClProofGenerator { + #[allow(dead_code)] // #FIXME: remove this. pub fn new(el_proof_generator: ElProofGenerator) -> Self { Self { el_proof_generator } } diff --git a/provers/sp1/tests/helpers/el.rs b/provers/sp1/tests/helpers/el.rs index 601f5d5eb..a284e6afa 100644 --- a/provers/sp1/tests/helpers/el.rs +++ b/provers/sp1/tests/helpers/el.rs @@ -14,6 +14,7 @@ use crate::helpers::proof_generator::ProofGenerator; pub struct ElProofGenerator; impl ElProofGenerator { + #[allow(dead_code)] // #FIXME: remove this. pub fn new() -> Self { Self } diff --git a/provers/sp1/tests/helpers/l1_batch.rs b/provers/sp1/tests/helpers/l1_batch.rs index 93ba700c7..14eb3ac8a 100644 --- a/provers/sp1/tests/helpers/l1_batch.rs +++ b/provers/sp1/tests/helpers/l1_batch.rs @@ -19,6 +19,7 @@ pub struct L1BatchProofGenerator { } impl L1BatchProofGenerator { + #[allow(dead_code)] // #FIXME: remove this. pub fn new(btc_proof_generator: BtcBlockProofGenerator) -> Self { Self { btc_proof_generator, diff --git a/provers/sp1/tests/helpers/l2_batch.rs b/provers/sp1/tests/helpers/l2_batch.rs index 88d20f874..f251ffaa6 100644 --- a/provers/sp1/tests/helpers/l2_batch.rs +++ b/provers/sp1/tests/helpers/l2_batch.rs @@ -16,6 +16,7 @@ pub struct L2BatchProofGenerator { } impl L2BatchProofGenerator { + #[allow(dead_code)] // #FIXME: remove this. pub fn new(cl_proof_generator: ClProofGenerator) -> Self { Self { cl_proof_generator } } From 012b80730254ed4185d50390198016f783a8694a Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Thu, 19 Dec 2024 05:47:30 -0300 Subject: [PATCH 5/7] chore: fmt --- crates/state/src/operation.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/state/src/operation.rs b/crates/state/src/operation.rs index 43e1d08e8..2a45fc7cf 100644 --- a/crates/state/src/operation.rs +++ b/crates/state/src/operation.rs @@ -238,7 +238,8 @@ pub fn apply_writes_to_state( // Check if heights match accordingly if !l1v .last_finalized_checkpoint - .as_ref().is_none_or(|prev_chp| { + .as_ref() + .is_none_or(|prev_chp| { checkpt.batch_info.idx() == prev_chp.batch_info.idx() + 1 }) { From 673a5245c4071cc513294eb1ec923574cb54f8e4 Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Thu, 19 Dec 2024 08:06:16 -0300 Subject: [PATCH 6/7] chore: more clippy lints --- bin/prover-client/src/task.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/prover-client/src/task.rs b/bin/prover-client/src/task.rs index 07f6fdd2e..cb125094e 100644 --- a/bin/prover-client/src/task.rs +++ b/bin/prover-client/src/task.rs @@ -81,8 +81,7 @@ impl TaskTracker { .map(|(id, dependent_task)| { let all_dependencies_completed = dependent_task.dependencies.iter().all(|dep_id| { tasks - .get(dep_id) - .map_or(false, |t| t.status == ProvingTaskStatus::Completed) + .get(dep_id).is_some_and(|t| t.status == ProvingTaskStatus::Completed) }); // Return the task ID and completion status of dependencies (*id, all_dependencies_completed) From 9146439871ea711f46647c7725d1a8ee40fd4dda Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Thu, 19 Dec 2024 09:13:18 -0300 Subject: [PATCH 7/7] chore: fmt --- bin/prover-client/src/task.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/prover-client/src/task.rs b/bin/prover-client/src/task.rs index cb125094e..dcc6fd63f 100644 --- a/bin/prover-client/src/task.rs +++ b/bin/prover-client/src/task.rs @@ -81,7 +81,8 @@ impl TaskTracker { .map(|(id, dependent_task)| { let all_dependencies_completed = dependent_task.dependencies.iter().all(|dep_id| { tasks - .get(dep_id).is_some_and(|t| t.status == ProvingTaskStatus::Completed) + .get(dep_id) + .is_some_and(|t| t.status == ProvingTaskStatus::Completed) }); // Return the task ID and completion status of dependencies (*id, all_dependencies_completed)