Skip to content

Commit

Permalink
Chore: cleanup lints (#3276)
Browse files Browse the repository at this point in the history
* Cleanup lints
  • Loading branch information
zbuc authored Nov 2, 2023
1 parent 4a00776 commit 84ed7de
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 58 deletions.
57 changes: 29 additions & 28 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/bin/pcli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use self::ceremony::CeremonyCmd;
//
// https://docs.rs/clap/latest/clap/builder/struct.App.html#method.display_order
#[derive(Debug, clap::Subcommand)]
#[allow(clippy::large_enum_variant)]
pub enum Command {
/// Initialize `pcli` with a new wallet, or reset it.
///
Expand Down
10 changes: 8 additions & 2 deletions crates/bin/pcli/src/command/ceremony.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,17 @@ impl CeremonyCmd {
let index = match *phase {
1 => AddressIndex {
account: 0,
randomizer: b"ceremnyaddr1".as_slice().try_into().unwrap(),
randomizer: b"ceremnyaddr1"
.as_slice()
.try_into()
.expect("12 bytes long"),
},
2 => AddressIndex {
account: 0,
randomizer: b"ceremnyaddr2".as_slice().try_into().unwrap(),
randomizer: b"ceremnyaddr2"
.as_slice()
.try_into()
.expect("12 bytes long"),
},
_ => anyhow::bail!("phase must be 1 or 2."),
};
Expand Down
1 change: 1 addition & 0 deletions crates/bin/pcli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl PcliConfig {
/// The custody backend to use.
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
#[serde(tag = "backend")]
#[allow(clippy::large_enum_variant)]
pub enum CustodyConfig {
/// A view-only client that can't sign transactions.
ViewOnly,
Expand Down
2 changes: 1 addition & 1 deletion crates/bin/pd/src/testnet/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl TestnetConfig {
epoch_duration: Option<u64>,
unbonding_epochs: Option<u64>,
) -> anyhow::Result<TestnetConfig> {
let external_addresses = external_addresses.unwrap_or(Vec::new());
let external_addresses = external_addresses.unwrap_or_default();

let testnet_validators = Self::collect_validators(
validators_input_file,
Expand Down
6 changes: 2 additions & 4 deletions crates/bin/pd/src/testnet/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,8 @@ pub async fn fetch_peers(tm_url: &Url) -> anyhow::Result<Vec<TendermintAddress>>
);
seeds.push(peer_tm_address)
// Otherwise, we check if we've found enough.
} else {
if peers.len() <= threshold {
peers.push(peer_tm_address)
}
} else if peers.len() <= threshold {
peers.push(peer_tm_address)
}
}
if peers.len() < threshold && seeds.is_empty() {
Expand Down
1 change: 1 addition & 0 deletions crates/core/app/src/genesis/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use serde::{Deserialize, Serialize};
/// The application state at genesis.
#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(try_from = "pb::GenesisAppState", into = "pb::GenesisAppState")]
#[allow(clippy::large_enum_variant)]
pub enum AppState {
/// The application state at genesis.
Content(Content),
Expand Down
2 changes: 1 addition & 1 deletion crates/core/asset/src/asset/denom_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl Eq for DenomMetadata {}

impl PartialOrd for DenomMetadata {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.inner.base_denom.partial_cmp(&other.inner.base_denom)
Some(self.cmp(other))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ impl MsgHandler for MsgUpdateClient {
.get_verified_consensus_state(trusted_height, self.client_id.clone())
.await?;

let last_trusted_consensus_state = last_trusted_consensus_state;

// We also have to convert from an IBC height, which has two
// components, to a Tendermint height, which has only one.
let trusted_height = trusted_height
Expand Down
4 changes: 2 additions & 2 deletions crates/core/component/stake/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,13 @@ pub(crate) trait StakingImpl: StateWriteExt {
for d in changes.delegations {
delegations_by_validator
.entry(d.validator_identity.clone())
.or_insert_with(Vec::new)
.or_default()
.push(d);
}
for u in changes.undelegations {
undelegations_by_validator
.entry(u.validator_identity.clone())
.or_insert_with(Vec::new)
.or_default()
.push(u);
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/crypto/proof-setup/src/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ impl Phase2CeremonyContribution {
&old.0[0], &old.0[1], &old.0[2], &old.0[3], &old.0[4], &old.0[5], &old.0[6],
];
Self(transform_parallel(data, |old_i| {
Phase2Contribution::make(&mut OsRng, ContributionHash::dummy(), &old_i)
Phase2Contribution::make(&mut OsRng, ContributionHash::dummy(), old_i)
}))
}
}
Expand Down Expand Up @@ -698,7 +698,7 @@ impl Phase1CeremonyContribution {
&old.0[0], &old.0[1], &old.0[2], &old.0[3], &old.0[4], &old.0[5], &old.0[6],
];
Self(transform_parallel(data, |old_i| {
Phase1Contribution::make(&mut OsRng, ContributionHash::dummy(), &old_i)
Phase1Contribution::make(&mut OsRng, ContributionHash::dummy(), old_i)
}))
}
}
Expand All @@ -723,7 +723,7 @@ impl AllExtraTransitionInformation {
}

pub fn from_bytes(data: &[u8]) -> Result<Self> {
Ok(from_bytes_unchecked::<Self>(data)?)
from_bytes_unchecked::<Self>(data)
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/crypto/proof-setup/src/single/phase1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ impl RawCRSElements {
///
/// This checks if the structure of the elements uses the secret scalars
/// hidden behind the group elements correctly.
#[must_use]
pub fn validate(self) -> anyhow::Result<CRSElements> {
// 0. Check that we can extract a valid degree out of these elements.
let d = self
Expand Down
1 change: 0 additions & 1 deletion crates/storage/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ impl TreeReader for Inner {

/// Gets node given a node key. Returns `None` if the node does not exist.
fn get_node_option(&self, node_key: &NodeKey) -> Result<Option<Node>> {
let node_key = node_key;
let db_node_key = DbNodeKey::from(node_key.clone());
tracing::trace!(?node_key);

Expand Down
2 changes: 1 addition & 1 deletion tools/summonerd/src/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ impl Coordinator {
}
tracing::info!("STRIKE (invalid or partial contribution)");
self.storage.strike(&address).await?;
return Ok(());
Ok(())
}
}
5 changes: 3 additions & 2 deletions tools/summonerd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ struct Opt {

#[derive(Debug, clap::Subcommand)]
/// Hello folks
#[allow(clippy::large_enum_variant)]
enum Command {
/// Generate a phase 1 root (for testing purposes).
GeneratePhase1 {
Expand Down Expand Up @@ -318,8 +319,8 @@ fn write_params(
let vk_location = target_dir.join(format!("{}_vk.param", name));
let id_location = target_dir.join(format!("{}_id.rs", name));

let pk_file = fs::File::create(&pk_location)?;
let vk_file = fs::File::create(&vk_location)?;
let pk_file = fs::File::create(pk_location)?;
let vk_file = fs::File::create(vk_location)?;

let pk_writer = BufWriter::new(pk_file);
let vk_writer = BufWriter::new(vk_file);
Expand Down
10 changes: 4 additions & 6 deletions tools/summonerd/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,13 @@ impl server::CeremonyCoordinatorService for CoordinatorService {
}
ContributionAllowed::Banned => {
tracing::debug!(?address, "is banned");
return Err(Status::permission_denied(format!(
"nyo contwibution *cries* fow you"
)));
return Err(Status::permission_denied(
"nyo contwibution *cries* fow you".to_string(),
));
}
ContributionAllowed::AlreadyContributed => {
tracing::debug!(?address, "already contributed");
return Err(Status::permission_denied(format!(
"Thanks again for your contribution! Participating once is enough to guarantee security, and we'd like to allow other people to participate as well."
)));
return Err(Status::permission_denied("Thanks again for your contribution! Participating once is enough to guarantee security, and we'd like to allow other people to participate as well.".to_string()));
}
};
tracing::info!(?amount, ?address, "bid");
Expand Down
8 changes: 4 additions & 4 deletions tools/summonerd/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl Storage {
.query_row(
"SELECT strikes FROM participant_metadata WHERE address = ?1",
[address.to_vec()],
|row| Ok(row.get::<usize, u64>(0)?),
|row| row.get::<usize, u64>(0),
)
.optional()?
.unwrap_or(0);
Expand All @@ -200,7 +200,7 @@ impl Storage {
// - Bid more than min amount
// - Hasn't already contributed
// - Not banned
let amount = knower.total_amount_sent_to_me(&address).await?;
let amount = knower.total_amount_sent_to_me(address).await?;
if amount < Amount::from(self.config.min_bid_u64) {
return Ok(ContributionAllowed::DidntBidEnough(amount));
}
Expand Down Expand Up @@ -416,13 +416,13 @@ impl Storage {
let tx = conn.transaction()?;
let maybe_data = tx
.query_row("SELECT data FROM transition_aux WHERE id = 0", [], |row| {
Ok(row.get::<usize, Vec<u8>>(0)?)
row.get::<usize, Vec<u8>>(0)
})
.optional()?;
if let Some(data) = maybe_data {
Ok(Some(AllExtraTransitionInformation::from_bytes(&data)?))
} else {
return Ok(None);
Ok(None)
}
}
}

0 comments on commit 84ed7de

Please sign in to comment.