Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clippy + comments from previous PR #22

Merged
merged 2 commits into from
Jan 27, 2024
Merged

Conversation

RedaOps
Copy link
Contributor

@RedaOps RedaOps commented Jan 27, 2024

Hey there! Reviewed and changed some stuff we talked about in #18 . Also fixed clippy and ran a workflow locally and it's looking good now!

Haven't tested these new changes, but I have not modified any functionality whatsoever. The e2e testing pipeline we were talking about is going to be really useful.

closes #21

Copy link
Contributor

@mimoo mimoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks for the PR :) left some random thoughts

if let Ok(response) =
serde_json::from_str::<bitcoincore_rpc::jsonrpc::Response>(&resp)
{
let resp: Round1Response = response.result()?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same problem for result()? though :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it would be cleaner to do something like this:

let res = resp.map_err(|e| format!("connection error: {e}").and_then(|r| serde_json::from_str::< bitcoincore_rpc::jsonrpc::Response>(&r).map_err(|e| format!("json error: {e}"))).and_then(|r| r.result().map_err(|e| format!("rpc error: {e}")));
let resp = match res {
  Ok(x) => x,
  Err(e) => {
     warn!("Round 1 error with {addr}: {e}", addr=member.address);
     self.member_status.write().unwrap().mark_as_disconnected(member_id);
     need_retry = true // since at this point we have waiting for all the response might as well check all of them before retrying (so that we potentially discover multiple disconnects?)
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, saw that. We won't even need the response.result()? part once we have a custom serde struct for Node RPC responses. I can open up an issue for this, but would rather fix this after we have at least some e2e tests so I can just run the job and make sure I don't broken anything by accident, without having to recreate the whole environment each time.

if let Ok(response) =
serde_json::from_str::<bitcoincore_rpc::jsonrpc::Response>(&resp)
{
let round2_response: Round2Response = response.result()?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

pubkey_package,
committee_cfg,
member_status: member_status_state,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps it would be cleaner to do a let ctx = Orchestrator::new(pubkey_package, committee_cfg) and take care of creating the member_status_state there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to add #[allow(clippy::absurd_Extreme_comparisons)] next to where the the warning is being given :o

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, tried that but there were some issues with the ensure! macro where most absurd checks are being done. For some reason clippy ignored the decoration.

@mimoo mimoo merged commit 601b6a4 into sigma0-dev:main Jan 27, 2024
1 check passed
@RedaOps RedaOps deleted the clippy branch January 27, 2024 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix clippy issues
2 participants