From 70d1ae04c403134e9a4e0ed4b833bf9edb58bea4 Mon Sep 17 00:00:00 2001 From: Siddhesh Z Date: Fri, 31 Jan 2025 22:46:55 +0530 Subject: [PATCH 1/5] Remove unused cfg attributes --- crates/floresta-chain/Cargo.toml | 1 + crates/floresta-chain/src/pruned_utreexo/error.rs | 5 ----- crates/floresta-electrum/src/error.rs | 5 ----- crates/floresta-watch-only/Cargo.toml | 1 + florestad/src/error.rs | 9 +-------- 5 files changed, 3 insertions(+), 18 deletions(-) diff --git a/crates/floresta-chain/Cargo.toml b/crates/floresta-chain/Cargo.toml index 0bc62e0a..696b6e41 100644 --- a/crates/floresta-chain/Cargo.toml +++ b/crates/floresta-chain/Cargo.toml @@ -45,6 +45,7 @@ hex = "0.4.3" default = [] bitcoinconsensus = ["bitcoin/bitcoinconsensus", "dep:bitcoinconsensus"] metrics = ["dep:metrics"] +no-std = [] [[bench]] name = "chain_state_bench" diff --git a/crates/floresta-chain/src/pruned_utreexo/error.rs b/crates/floresta-chain/src/pruned_utreexo/error.rs index 33e7758e..0cc0ba57 100644 --- a/crates/floresta-chain/src/pruned_utreexo/error.rs +++ b/crates/floresta-chain/src/pruned_utreexo/error.rs @@ -3,8 +3,6 @@ use core::fmt::Debug; use bitcoin::blockdata::script; use bitcoin::OutPoint; use bitcoin::Txid; -#[cfg(feature = "cli-blockchain")] -use btcd_rpc::error::UtreexodError; use floresta_common::impl_error_from; use crate::prelude::*; @@ -12,9 +10,6 @@ pub trait DatabaseError: Debug + Send + Sync + 'static {} #[derive(Debug)] pub enum BlockchainError { BlockNotPresent, - #[cfg(feature = "cli-blockchain")] - #[error("Json-Rpc error")] - JsonRpcError(#[from] UtreexodError), Parsing(String), BlockValidation(BlockValidationErrors), TransactionError(TransactionError), diff --git a/crates/floresta-electrum/src/error.rs b/crates/floresta-electrum/src/error.rs index ad09e902..8c741345 100644 --- a/crates/floresta-electrum/src/error.rs +++ b/crates/floresta-electrum/src/error.rs @@ -1,12 +1,7 @@ -#[cfg(feature = "cli-blockchain")] -use btcd_rpc::error::UtreexodError; use thiserror::Error; #[derive(Error, Debug)] pub enum Error { - #[error("Utreexod error")] - #[cfg(feature = "cli-blockchain")] - BackendError(#[from] UtreexodError), #[error("Invalid params passed in")] InvalidParams, #[error("Invalid json string {0}")] diff --git a/crates/floresta-watch-only/Cargo.toml b/crates/floresta-watch-only/Cargo.toml index 0d4048f9..6fc16025 100644 --- a/crates/floresta-watch-only/Cargo.toml +++ b/crates/floresta-watch-only/Cargo.toml @@ -26,5 +26,6 @@ rand = "0.8.5" [features] default = ["std"] memory-database = [] +no-std = [] # The default features in common are `std` and `descriptors-std` (which is a superset of `descriptors-no-std`) std = ["floresta-common/default", "serde/std"] diff --git a/florestad/src/error.rs b/florestad/src/error.rs index def8a0b3..c9cf731d 100644 --- a/florestad/src/error.rs +++ b/florestad/src/error.rs @@ -1,14 +1,10 @@ use bitcoin::consensus::encode; -#[cfg(feature = "cli-blockchain")] -use btcd_rpc::error::UtreexodError; use floresta_chain::BlockValidationErrors; use floresta_chain::BlockchainError; use crate::slip132; #[derive(Debug)] pub enum Error { - #[cfg(feature = "cli-blockchain")] - UtreexodError(UtreexodError), Encode(encode::Error), Db(kv::Error), ParseNum(std::num::ParseIntError), @@ -28,8 +24,6 @@ impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Error::Encode(err) => write!(f, "Encode error: {err}"), - #[cfg(feature = "cli-blockchain")] - Error::UtreexodError(_) => write!(f, "UtreexodError"), Error::Db(err) => write!(f, "Database error {err}"), Error::ParseNum(err) => write!(f, "int parse error: {err}"), Error::Rustreexo(err) => write!(f, "Rustreexo error: {err}"), @@ -57,8 +51,7 @@ macro_rules! impl_from_error { }; } // impl_from_error!(Parsing, bitcoin::hashes::hex::Error); -#[cfg(feature = "cli-blockchain")] -impl_from_error!(UtreexodError, UtreexodError); + impl_from_error!(Encode, encode::Error); impl_from_error!(Db, kv::Error); impl_from_error!(ParseNum, std::num::ParseIntError); From 2f75d4c3b090841d7d6e725b71328276d77c6a96 Mon Sep 17 00:00:00 2001 From: Siddhesh Z Date: Sat, 1 Feb 2025 09:04:07 +0530 Subject: [PATCH 2/5] code quality: remove unused cfg attributes and fix warning --- crates/floresta-chain/Cargo.toml | 1 - crates/floresta-chain/src/lib.rs | 1 + crates/floresta-watch-only/Cargo.toml | 1 - crates/floresta-watch-only/src/lib.rs | 2 +- 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/floresta-chain/Cargo.toml b/crates/floresta-chain/Cargo.toml index 696b6e41..0bc62e0a 100644 --- a/crates/floresta-chain/Cargo.toml +++ b/crates/floresta-chain/Cargo.toml @@ -45,7 +45,6 @@ hex = "0.4.3" default = [] bitcoinconsensus = ["bitcoin/bitcoinconsensus", "dep:bitcoinconsensus"] metrics = ["dep:metrics"] -no-std = [] [[bench]] name = "chain_state_bench" diff --git a/crates/floresta-chain/src/lib.rs b/crates/floresta-chain/src/lib.rs index 2d689e6e..8f38830a 100644 --- a/crates/floresta-chain/src/lib.rs +++ b/crates/floresta-chain/src/lib.rs @@ -10,6 +10,7 @@ //! All data is stored in a `ChainStore` implementation, which is generic over the //! underlying database. See the ChainStore trait for more information. For a //! ready-to-use implementation, see the [KvChainStore] struct. +#![allow(unexpected_cfgs)] #![cfg_attr(any(feature = "no-std", not(test)), no_std)] pub mod pruned_utreexo; diff --git a/crates/floresta-watch-only/Cargo.toml b/crates/floresta-watch-only/Cargo.toml index 6fc16025..0d4048f9 100644 --- a/crates/floresta-watch-only/Cargo.toml +++ b/crates/floresta-watch-only/Cargo.toml @@ -26,6 +26,5 @@ rand = "0.8.5" [features] default = ["std"] memory-database = [] -no-std = [] # The default features in common are `std` and `descriptors-std` (which is a superset of `descriptors-no-std`) std = ["floresta-common/default", "serde/std"] diff --git a/crates/floresta-watch-only/src/lib.rs b/crates/floresta-watch-only/src/lib.rs index b0881adc..35bf536d 100644 --- a/crates/floresta-watch-only/src/lib.rs +++ b/crates/floresta-watch-only/src/lib.rs @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT - +#![allow(unexpected_cfgs)] #![cfg_attr(feature = "no-std", no_std)] use core::cmp::Ordering; use core::fmt::Debug; From f780ccc9f9c8826ea0198e216f078b66d379862c Mon Sep 17 00:00:00 2001 From: Siddhesh Z Date: Tue, 4 Feb 2025 15:39:10 +0530 Subject: [PATCH 3/5] review comment resolved-code quality: replaced "#![allow(unexpected_cfgs)]" with concise "#![cfg_attr(not(test), no_std)]"" --- crates/floresta-chain/src/lib.rs | 3 +-- crates/floresta-chain/src/pruned_utreexo/chain_state.rs | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/floresta-chain/src/lib.rs b/crates/floresta-chain/src/lib.rs index 8f38830a..24c67315 100644 --- a/crates/floresta-chain/src/lib.rs +++ b/crates/floresta-chain/src/lib.rs @@ -10,8 +10,7 @@ //! All data is stored in a `ChainStore` implementation, which is generic over the //! underlying database. See the ChainStore trait for more information. For a //! ready-to-use implementation, see the [KvChainStore] struct. -#![allow(unexpected_cfgs)] -#![cfg_attr(any(feature = "no-std", not(test)), no_std)] +#![cfg_attr(not(test), no_std)] pub mod pruned_utreexo; pub(crate) use floresta_common::prelude; diff --git a/crates/floresta-chain/src/pruned_utreexo/chain_state.rs b/crates/floresta-chain/src/pruned_utreexo/chain_state.rs index a36b7cd8..c4637b9a 100644 --- a/crates/floresta-chain/src/pruned_utreexo/chain_state.rs +++ b/crates/floresta-chain/src/pruned_utreexo/chain_state.rs @@ -1,6 +1,4 @@ extern crate alloc; -#[cfg(not(feature = "no-std"))] -extern crate std; use alloc::borrow::ToOwned; use alloc::fmt::format; From fe85afc13d1da4de919531dc030383d7507310e7 Mon Sep 17 00:00:00 2001 From: Siddhesh Z Date: Tue, 4 Feb 2025 15:43:21 +0530 Subject: [PATCH 4/5] review comment resolved- removed commented part --- florestad/src/error.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/florestad/src/error.rs b/florestad/src/error.rs index c9cf731d..29f4648c 100644 --- a/florestad/src/error.rs +++ b/florestad/src/error.rs @@ -50,7 +50,6 @@ macro_rules! impl_from_error { } }; } -// impl_from_error!(Parsing, bitcoin::hashes::hex::Error); impl_from_error!(Encode, encode::Error); impl_from_error!(Db, kv::Error); From 62dcc18d5ba6f266aea8460a0b983505a1c49001 Mon Sep 17 00:00:00 2001 From: Siddhesh Z Date: Tue, 4 Feb 2025 22:13:13 +0530 Subject: [PATCH 5/5] review comment resolved- Remove #![cfg] rather than turning linting off --- crates/floresta-watch-only/src/lib.rs | 2 -- florestad/src/slip132.rs | 1 - 2 files changed, 3 deletions(-) diff --git a/crates/floresta-watch-only/src/lib.rs b/crates/floresta-watch-only/src/lib.rs index 35bf536d..5c600536 100644 --- a/crates/floresta-watch-only/src/lib.rs +++ b/crates/floresta-watch-only/src/lib.rs @@ -1,6 +1,4 @@ // SPDX-License-Identifier: MIT -#![allow(unexpected_cfgs)] -#![cfg_attr(feature = "no-std", no_std)] use core::cmp::Ordering; use core::fmt::Debug; diff --git a/florestad/src/slip132.rs b/florestad/src/slip132.rs index 14dcb9ba..38bd50e0 100644 --- a/florestad/src/slip132.rs +++ b/florestad/src/slip132.rs @@ -152,7 +152,6 @@ pub struct DefaultResolver; derive(Serialize, Deserialize), serde(crate = "serde_crate") )] -#[cfg_attr(feature = "strict_encoding", derive(StrictEncode, StrictDecode))] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] #[non_exhaustive] pub enum KeyApplication {