Skip to content

Commit

Permalink
fixed clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
RedaOps committed Jan 27, 2024
1 parent 19405dc commit 67d65a6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features -- -D warnings
args: --all-features -- -D warnings -A clippy::absurd_extreme_comparisons
6 changes: 3 additions & 3 deletions src/bin/zkbtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ async fn main() -> Result<()> {

info!(
"deploying circuit {} with {num_public_inputs} public inputs",
hex::encode(&vk_hash)
hex::encode(vk_hash)
);

// sanity check for stateful zkapps
Expand Down Expand Up @@ -421,7 +421,7 @@ async fn main() -> Result<()> {
{
let path = output_dir.join("publickey-package.json");
let file =
std::fs::File::create(&path).expect("couldn't create file given output dir");
std::fs::File::create(path).expect("couldn't create file given output dir");
serde_json::to_writer_pretty(file, &pubkey_package).unwrap();
}

Expand All @@ -445,7 +445,7 @@ async fn main() -> Result<()> {
};
let path = output_dir.join("committee-cfg.json");
let file =
std::fs::File::create(&path).expect("couldn't create file given output dir");
std::fs::File::create(path).expect("couldn't create file given output dir");
serde_json::to_writer_pretty(file, &committee_cfg).unwrap();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/bob_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl BobRequest {
// extract new_state
let new_state = public_inputs
.0
.get(0)
.first()
.cloned()
.context("the full public input does not contain a new state")?;

Expand Down Expand Up @@ -196,13 +196,13 @@ impl BobRequest {
let amount_in = string_to_amount(
proof_inputs
.get("amount_in")
.and_then(|x| x.get(0))
.and_then(|x| x.first())
.context("amount_in in proof inputs must be of length 1")?,
)?;
let amount_out = string_to_amount(
proof_inputs
.get("amount_out")
.and_then(|x| x.get(0))
.and_then(|x| x.first())
.context("amount_out in proof inputs must be of length 1")?,
)?;
let new_value = smart_contract.locked_value + amount_in - amount_out;
Expand Down Expand Up @@ -284,7 +284,7 @@ impl BobRequest {
let new_state = new_state.unwrap();
ensure!(
public_inputs.0.len()
== 1 * 2 /* prev/new_state */ + 1 /* truncated txid */ + 1 /* amount_out */ + 1, /* amount_in */
== 2 /* prev/new_state */ + 1 /* truncated txid */ + 1 /* amount_out */ + 1, /* amount_in */
"the number of public inputs is not correct"
);

Expand Down
2 changes: 1 addition & 1 deletion src/committee/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ async fn round_2_signing(
}

async fn is_alive(params: Params<'static>, _context: Arc<NodeState>) -> RpcResult<u64> {
Ok(params.parse::<[u64; 1]>()?[0].clone())
Ok(params.parse::<[u64; 1]>()?[0])
}

//
Expand Down
24 changes: 11 additions & 13 deletions src/committee/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ impl MemberStatusState {
let mut futures = Vec::with_capacity(config.members.len());

for (key, member) in config.members.iter() {
let _ = key_to_addr.insert(key.clone(), member.address.clone());
let _ = key_to_addr.insert(*key, member.address.clone());
futures.push((
key.clone(),
*key,
Self::check_alive(member.address.clone()),
member.address.clone(),
));
}

for (key, future, address) in futures.into_iter() {
let new_status = if future.await == true {
let new_status = if future.await {
info!("{address} is online");
MemberStatus::Online
} else {
Expand Down Expand Up @@ -138,10 +138,8 @@ impl MemberStatusState {

for (member, status) in self.status.iter() {
match *status {
MemberStatus::Online => online.push(member.clone()),
MemberStatus::Offline | MemberStatus::Disconnected(_) => {
offline.push(member.clone())
}
MemberStatus::Online => online.push(*member),
MemberStatus::Offline | MemberStatus::Disconnected(_) => offline.push(*member),
};
}

Expand All @@ -156,12 +154,12 @@ impl MemberStatusState {
}

fn fib(n: u64) -> u64 {
if n <= 0 {
return 0;
if n == 0 {
0
} else if n == 1 {
return 1;
1
} else {
return Self::fib(n - 1) + Self::fib(n - 2);
Self::fib(n - 1) + Self::fib(n - 2)
}
}

Expand Down Expand Up @@ -211,8 +209,8 @@ impl MemberStatusState {
.key_to_addr
.iter()
.map(|(key, addr)| {
let status = r_lock.status.get(key).unwrap().clone();
(key.clone(), addr.clone(), status)
let status = *r_lock.status.get(key).unwrap();
(*key, addr.clone(), status)
})
.filter(|(_, _, status)| match *status {
MemberStatus::Online => true,
Expand Down
2 changes: 1 addition & 1 deletion src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub const CIRCOM_ETH_PRIME_BYTELEN: usize = 32;
pub const STATELESS_ZKAPP_PUBLIC_INPUT_LEN: usize = 1 /* truncated txid */;

/// The expected number of public inputs for a stateful zkapp.
pub const STATEFUL_ZKAPP_PUBLIC_INPUT_LEN: usize = 1 * 2 /* new state + prev state */ + 1 /* truncated txid */ + 1 /* amount_out */ + 1 /* amount_in */;
pub const STATEFUL_ZKAPP_PUBLIC_INPUT_LEN: usize = 2 /* new state + prev state */ + 1 /* truncated txid */ + 1 /* amount_out */ + 1 /* amount_in */;

/// The number of seconds to sleep between orchestrator-node keepalive requests
pub const KEEPALIVE_WAIT_SECONDS: u64 = 5;
Expand Down

0 comments on commit 67d65a6

Please sign in to comment.