Skip to content

Commit

Permalink
fix clippy issues (paritytech#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored and serban300 committed Apr 10, 2024
1 parent 10c1c8d commit d2d6593
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion bridges/bin/millau/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub fn new_partial(
.transpose()?;

let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::<Block, RuntimeApi, Executor>(
&config,
config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
)?;
let client = Arc::new(client);
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/rialto/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn new_partial(
.transpose()?;

let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::<Block, RuntimeApi, Executor>(
&config,
config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
)?;
let client = Arc::new(client);
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/ethereum-contract-builtin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub fn verify_substrate_finality_proof(
let best_set = best_set?;

let verify_result = sc_finality_grandpa::GrandpaJustification::<Block>::decode_and_verify_finalizes(
&raw_finality_proof,
raw_finality_proof,
(finality_target_hash, finality_target_number),
best_set_id,
&best_set,
Expand Down
9 changes: 7 additions & 2 deletions bridges/modules/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,14 @@ pub mod pallet {
let set_id = authority_set.set_id;

Ok(
verify_justification::<BridgedHeader<T, I>>((hash, number), set_id, &voter_set, &justification).map_err(
verify_justification::<BridgedHeader<T, I>>((hash, number), set_id, &voter_set, justification).map_err(
|e| {
log::error!(target: "runtime::bridge-grandpa", "Received invalid justification for {:?}: {:?}", hash, e);
log::error!(
target: "runtime::bridge-grandpa",
"Received invalid justification for {:?}: {:?}",
hash,
e,
);
<Error<T, I>>::InvalidJustification
},
)?,
Expand Down
4 changes: 2 additions & 2 deletions bridges/primitives/ethereum-poa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl AuraHeader {

/// Get step this header is generated for.
pub fn step(&self) -> Option<u64> {
self.seal.get(0).map(|x| Rlp::new(&x)).and_then(|x| x.as_val().ok())
self.seal.get(0).map(|x| Rlp::new(x)).and_then(|x| x.as_val().ok())
}

/// Get header author' signature.
Expand Down Expand Up @@ -496,7 +496,7 @@ pub fn transaction_decode_rlp(raw_tx: &[u8]) -> Result<Transaction, DecoderError
let message = unsigned.message(chain_id);

// recover tx sender
let sender_public = sp_io::crypto::secp256k1_ecdsa_recover(&signature, &message.as_fixed_bytes())
let sender_public = sp_io::crypto::secp256k1_ecdsa_recover(&signature, message.as_fixed_bytes())
.map_err(|_| rlp::DecoderError::Custom("Failed to recover transaction sender"))?;
let sender_address = public_to_address(&sender_public);

Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub fn make_justification_for_header<H: HeaderT>(params: JustificationGeneratorP
for (i, (id, _weight)) in authorities.iter().enumerate() {
// Assign authorities to sign pre-commits in a round-robin fashion
let target = unsigned_precommits[i % forks as usize];
let precommit = signed_precommit::<H>(&id, target, round, set_id);
let precommit = signed_precommit::<H>(id, target, round, set_id);

precommits.push(precommit);
}
Expand Down
4 changes: 2 additions & 2 deletions bridges/relays/bin-ethereum/src/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl BridgeInstance for RialtoPoA {
.into_iter()
.map(|header| {
(
into_substrate_ethereum_header(&header.header()),
into_substrate_ethereum_header(header.header()),
into_substrate_ethereum_receipts(header.extra()),
)
})
Expand All @@ -65,7 +65,7 @@ impl BridgeInstance for RialtoPoA {

fn build_unsigned_header_call(&self, header: QueuedEthereumHeader) -> Call {
let pallet_call = rialto_runtime::BridgeEthPoACall::import_unsigned_header(
into_substrate_ethereum_header(&header.header()),
into_substrate_ethereum_header(header.header()),
into_substrate_ethereum_receipts(header.extra()),
);

Expand Down
12 changes: 6 additions & 6 deletions bridges/relays/bin-ethereum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async fn run_command(matches: &clap::ArgMatches<'_>) {
match matches.subcommand() {
("eth-to-sub", Some(eth_to_sub_matches)) => {
log::info!(target: "bridge", "Starting ETH ➡ SUB relay.");
if ethereum_sync_loop::run(match ethereum_sync_params(&eth_to_sub_matches) {
if ethereum_sync_loop::run(match ethereum_sync_params(eth_to_sub_matches) {
Ok(ethereum_sync_params) => ethereum_sync_params,
Err(err) => {
log::error!(target: "bridge", "Error parsing parameters: {}", err);
Expand All @@ -75,7 +75,7 @@ async fn run_command(matches: &clap::ArgMatches<'_>) {
}
("sub-to-eth", Some(sub_to_eth_matches)) => {
log::info!(target: "bridge", "Starting SUB ➡ ETH relay.");
if substrate_sync_loop::run(match substrate_sync_params(&sub_to_eth_matches) {
if substrate_sync_loop::run(match substrate_sync_params(sub_to_eth_matches) {
Ok(substrate_sync_params) => substrate_sync_params,
Err(err) => {
log::error!(target: "bridge", "Error parsing parameters: {}", err);
Expand All @@ -90,7 +90,7 @@ async fn run_command(matches: &clap::ArgMatches<'_>) {
}
("eth-deploy-contract", Some(eth_deploy_matches)) => {
log::info!(target: "bridge", "Deploying ETH contracts.");
ethereum_deploy_contract::run(match ethereum_deploy_contract_params(&eth_deploy_matches) {
ethereum_deploy_contract::run(match ethereum_deploy_contract_params(eth_deploy_matches) {
Ok(ethereum_deploy_params) => ethereum_deploy_params,
Err(err) => {
log::error!(target: "bridge", "Error during contract deployment: {}", err);
Expand All @@ -101,7 +101,7 @@ async fn run_command(matches: &clap::ArgMatches<'_>) {
}
("eth-submit-exchange-tx", Some(eth_exchange_submit_matches)) => {
log::info!(target: "bridge", "Submitting ETH ➡ SUB exchange transaction.");
ethereum_exchange_submit::run(match ethereum_exchange_submit_params(&eth_exchange_submit_matches) {
ethereum_exchange_submit::run(match ethereum_exchange_submit_params(eth_exchange_submit_matches) {
Ok(eth_exchange_submit_params) => eth_exchange_submit_params,
Err(err) => {
log::error!(target: "bridge", "Error submitting Eethereum exchange transaction: {}", err);
Expand All @@ -112,7 +112,7 @@ async fn run_command(matches: &clap::ArgMatches<'_>) {
}
("eth-exchange-sub", Some(eth_exchange_matches)) => {
log::info!(target: "bridge", "Starting ETH ➡ SUB exchange transactions relay.");
ethereum_exchange::run(match ethereum_exchange_params(&eth_exchange_matches) {
ethereum_exchange::run(match ethereum_exchange_params(eth_exchange_matches) {
Ok(eth_exchange_params) => eth_exchange_params,
Err(err) => {
log::error!(target: "bridge", "Error relaying Ethereum transactions proofs: {}", err);
Expand Down Expand Up @@ -285,7 +285,7 @@ fn ethereum_exchange_submit_params(matches: &clap::ArgMatches) -> Result<Ethereu
let eth_nonce = matches
.value_of("eth-nonce")
.map(|eth_nonce| {
relay_ethereum_client::types::U256::from_dec_str(&eth_nonce)
relay_ethereum_client::types::U256::from_dec_str(eth_nonce)
.map_err(|e| format!("Failed to parse eth-nonce: {}", e))
})
.transpose()?;
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/bin-substrate/src/cli/encode_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub(crate) fn preprocess_call<Source: CliEncodeCall + CliChain, Target: CliEncod
} => {
if remark_payload.is_none() {
*remark_payload = Some(HexBytes(generate_remark_payload(
&remark_size,
remark_size,
compute_maximal_message_arguments_size(Source::max_extrinsic_size(), Target::max_extrinsic_size()),
)));
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/bin-substrate/src/cli/send_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl SendMessage {
let target_sign = target_sign.to_keypair::<Target>()?;

encode_call::preprocess_call::<Source, Target>(message, bridge.bridge_instance_index());
let target_call = Target::encode_call(&message)?;
let target_call = Target::encode_call(message)?;

let payload = {
let target_call_weight = prepare_call_dispatch_weight(
Expand Down
6 changes: 3 additions & 3 deletions bridges/relays/exchange/src/exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ async fn wait_transaction_mined<P: TransactionProofPipeline>(
source_tx_hash: &TransactionHashOf<P>,
) -> Result<(HeaderId<P>, usize), String> {
loop {
let source_header_and_tx = source_client.transaction_block(&source_tx_hash).await.map_err(|err| {
let source_header_and_tx = source_client.transaction_block(source_tx_hash).await.map_err(|err| {
format!(
"Error retrieving transaction {} from {} node: {:?}",
source_tx_hash,
Expand Down Expand Up @@ -363,7 +363,7 @@ async fn wait_header_imported<P: TransactionProofPipeline>(
source_header_id: &HeaderId<P>,
) -> Result<(), String> {
loop {
let is_header_known = target_client.is_header_known(&source_header_id).await.map_err(|err| {
let is_header_known = target_client.is_header_known(source_header_id).await.map_err(|err| {
format!(
"Failed to check existence of header {}/{} on {} node: {:?}",
source_header_id.0,
Expand Down Expand Up @@ -406,7 +406,7 @@ async fn wait_header_finalized<P: TransactionProofPipeline>(
) -> Result<(), String> {
loop {
let is_header_finalized = target_client
.is_header_finalized(&source_header_id)
.is_header_finalized(source_header_id)
.await
.map_err(|err| {
format!(
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/exchange/src/exchange_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ async fn run_loop_iteration<P: TransactionProofPipeline>(
state.best_processed_header_number = state.best_processed_header_number + One::one();
storage.set_state(state);

if let Some(ref exchange_loop_metrics) = exchange_loop_metrics {
if let Some(exchange_loop_metrics) = exchange_loop_metrics {
exchange_loop_metrics.update::<P>(
state.best_processed_header_number,
best_finalized_header_id.0,
Expand Down
8 changes: 4 additions & 4 deletions bridges/relays/headers/src/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl<P: HeadersSyncPipeline> QueuedHeaders<P> {
&mut self.orphan,
&mut self.known_headers,
HeaderStatus::Orphan,
&id,
id,
);
return;
}
Expand All @@ -305,7 +305,7 @@ impl<P: HeadersSyncPipeline> QueuedHeaders<P> {
&mut self.maybe_extra,
&mut self.known_headers,
HeaderStatus::MaybeExtra,
&id,
id,
);
}

Expand All @@ -324,7 +324,7 @@ impl<P: HeadersSyncPipeline> QueuedHeaders<P> {
destination_queue,
&mut self.known_headers,
destination_status,
&id,
id,
|header| header,
);
}
Expand Down Expand Up @@ -654,7 +654,7 @@ impl<P: HeadersSyncPipeline> QueuedHeaders<P> {
// remember that the header itself is synced
// (condition is here to avoid duplicate log messages)
if !id_processed {
set_header_status::<P>(&mut self.known_headers, &id, HeaderStatus::Synced);
set_header_status::<P>(&mut self.known_headers, id, HeaderStatus::Synced);
}

// now let's move all descendants from maybe_orphan && orphan queues to
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/messages/src/message_race_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ where
.as_ref()
.and_then(|best_finalized_source_header_id_at_best_target| {
strategy
.select_nonces_to_deliver(&race_state)
.select_nonces_to_deliver(race_state)
.map(|(nonces_range, proof_parameters)| {
(
best_finalized_source_header_id_at_best_target.clone(),
Expand Down

0 comments on commit d2d6593

Please sign in to comment.