From 130955cae5d49054140960d75255aa1a0791f753 Mon Sep 17 00:00:00 2001 From: 1xstj <106580853+1xstj@users.noreply.github.com> Date: Mon, 16 Dec 2024 22:28:09 +0530 Subject: [PATCH] use stable fmt --- .../evm-tracing/src/formatters/blockscout.rs | 2 +- .../evm-tracing/src/formatters/call_tracer.rs | 37 +++++---- .../src/formatters/trace_filter.rs | 15 ++-- client/evm-tracing/src/listeners/call_list.rs | 71 ++++++++++------- client/evm-tracing/src/listeners/raw.rs | 12 +-- client/evm-tracing/src/types/serialization.rs | 4 +- client/rpc-core/txpool/src/types/content.rs | 15 ++-- client/rpc/debug/src/lib.rs | 78 +++++++++++-------- client/rpc/trace/src/lib.rs | 47 ++++++----- client/rpc/txpool/src/lib.rs | 2 +- frost/frost-ristretto255/src/lib.rs | 5 +- frost/src/keys.rs | 2 +- frost/src/lib.rs | 10 +-- frost/src/round1.rs | 6 +- frost/src/scalar_mul.rs | 6 +- frost/src/signature.rs | 6 +- frost/src/signing_key.rs | 2 +- node/src/distributions/mainnet.rs | 42 +++++----- node/src/manual_seal.rs | 2 +- node/src/service.rs | 8 +- node/src/utils.rs | 2 +- pallets/claims/src/lib.rs | 15 ++-- pallets/claims/src/utils/mod.rs | 5 +- .../src/functions/delegate.rs | 2 +- .../src/functions/deposit.rs | 5 +- pallets/multi-asset-delegation/src/mock.rs | 5 +- .../multi-asset-delegation/src/mock_evm.rs | 14 ++-- .../src/tests/operator.rs | 6 +- pallets/services/rpc/src/lib.rs | 10 ++- pallets/services/src/functions.rs | 5 +- pallets/services/src/lib.rs | 5 +- pallets/services/src/mock.rs | 7 +- pallets/services/src/mock_evm.rs | 14 ++-- pallets/services/src/tests.rs | 5 +- pallets/tangle-lst/src/lib.rs | 11 +-- pallets/tangle-lst/src/types/bonded_pool.rs | 12 +-- pallets/tangle-lst/src/types/commission.rs | 8 +- precompiles/assets-erc20/src/lib.rs | 6 +- precompiles/assets-erc20/src/tests.rs | 4 +- precompiles/balances-erc20/src/lib.rs | 10 +-- precompiles/balances-erc20/src/tests.rs | 4 +- precompiles/batch/src/lib.rs | 40 ++++++---- precompiles/call-permit/src/lib.rs | 7 +- precompiles/multi-asset-delegation/src/lib.rs | 32 ++++---- .../multi-asset-delegation/src/tests.rs | 8 +- precompiles/pallet-democracy/src/lib.rs | 2 +- precompiles/pallet-democracy/src/tests.rs | 36 +++++---- precompiles/precompile-registry/src/lib.rs | 7 +- precompiles/proxy/src/lib.rs | 25 +++--- precompiles/services/src/lib.rs | 9 ++- precompiles/services/src/mock.rs | 2 +- precompiles/services/src/mock_evm.rs | 14 ++-- precompiles/services/src/tests.rs | 5 +- precompiles/staking/src/lib.rs | 2 +- precompiles/tangle-lst/src/lib.rs | 2 +- .../verify-bls381-signature/src/lib.rs | 4 +- .../verify-schnorr-signatures/src/lib.rs | 2 +- precompiles/vesting/src/lib.rs | 4 +- primitives/rpc/evm-tracing-events/src/evm.rs | 20 +++-- .../rpc/evm-tracing-events/src/gasometer.rs | 20 +++-- .../rpc/evm-tracing-events/src/runtime.rs | 15 ++-- primitives/src/chain_identifier.rs | 16 ++-- primitives/src/services/field.rs | 20 ++--- primitives/src/services/mod.rs | 14 ++-- primitives/src/verifier/circom.rs | 10 +-- runtime/mainnet/src/filters.rs | 4 +- runtime/mainnet/src/frontier_evm.rs | 15 ++-- runtime/mainnet/src/lib.rs | 26 ++++--- runtime/testnet/src/filters.rs | 4 +- runtime/testnet/src/frontier_evm.rs | 6 +- runtime/testnet/src/lib.rs | 26 ++++--- 71 files changed, 516 insertions(+), 408 deletions(-) diff --git a/client/evm-tracing/src/formatters/blockscout.rs b/client/evm-tracing/src/formatters/blockscout.rs index 9efe1505e..61b8033e2 100644 --- a/client/evm-tracing/src/formatters/blockscout.rs +++ b/client/evm-tracing/src/formatters/blockscout.rs @@ -36,7 +36,7 @@ impl super::ResponseFormatter for Formatter { if let Some(entry) = listener.entries.last() { return Some(TransactionTrace::CallList( entry.iter().map(|(_, value)| Call::Blockscout(value.clone())).collect(), - )) + )); } None } diff --git a/client/evm-tracing/src/formatters/call_tracer.rs b/client/evm-tracing/src/formatters/call_tracer.rs index b72ea0c99..6b2d7ae4a 100644 --- a/client/evm-tracing/src/formatters/call_tracer.rs +++ b/client/evm-tracing/src/formatters/call_tracer.rs @@ -56,13 +56,14 @@ impl super::ResponseFormatter for Formatter { gas_used, trace_address: Some(trace_address.clone()), inner: match inner.clone() { - BlockscoutCallInner::Call { input, to, res, call_type } => + BlockscoutCallInner::Call { input, to, res, call_type } => { CallTracerInner::Call { call_type: match call_type { CallType::Call => "CALL".as_bytes().to_vec(), CallType::CallCode => "CALLCODE".as_bytes().to_vec(), - CallType::DelegateCall => - "DELEGATECALL".as_bytes().to_vec(), + CallType::DelegateCall => { + "DELEGATECALL".as_bytes().to_vec() + }, CallType::StaticCall => "STATICCALL".as_bytes().to_vec(), }, to, @@ -73,7 +74,8 @@ impl super::ResponseFormatter for Formatter { CallResult::Output { .. } => it.logs.clone(), CallResult::Error { .. } => Vec::new(), }, - }, + } + }, BlockscoutCallInner::Create { init, res } => CallTracerInner::Create { input: init, error: match res { @@ -87,19 +89,21 @@ impl super::ResponseFormatter for Formatter { CreateResult::Error { .. } => None, }, output: match res { - CreateResult::Success { created_contract_code, .. } => - Some(created_contract_code), + CreateResult::Success { created_contract_code, .. } => { + Some(created_contract_code) + }, CreateResult::Error { .. } => None, }, value, call_type: "CREATE".as_bytes().to_vec(), }, - BlockscoutCallInner::SelfDestruct { balance, to } => + BlockscoutCallInner::SelfDestruct { balance, to } => { CallTracerInner::SelfDestruct { value: balance, to, call_type: "SELFDESTRUCT".as_bytes().to_vec(), - }, + } + }, }, calls: Vec::new(), }) @@ -161,11 +165,11 @@ impl super::ResponseFormatter for Formatter { let sibling_greater_than = |a: &Vec, b: &Vec| -> bool { for (i, a_value) in a.iter().enumerate() { if a_value > &b[i] { - return true + return true; } else if a_value < &b[i] { - return false + return false; } else { - continue + continue; } } false @@ -189,10 +193,11 @@ impl super::ResponseFormatter for Formatter { ( Call::CallTracer(CallTracerCall { trace_address: Some(a), .. }), Call::CallTracer(CallTracerCall { trace_address: Some(b), .. }), - ) => - &b[..] == - a.get(0..a.len() - 1) - .expect("non-root element while traversing trace result"), + ) => { + &b[..] + == a.get(0..a.len() - 1) + .expect("non-root element while traversing trace result") + }, _ => unreachable!(), }) { // Remove `trace_address` from result. @@ -223,7 +228,7 @@ impl super::ResponseFormatter for Formatter { } } if traces.is_empty() { - return None + return None; } Some(traces) } diff --git a/client/evm-tracing/src/formatters/trace_filter.rs b/client/evm-tracing/src/formatters/trace_filter.rs index f8844c8fd..9bb032107 100644 --- a/client/evm-tracing/src/formatters/trace_filter.rs +++ b/client/evm-tracing/src/formatters/trace_filter.rs @@ -56,11 +56,12 @@ impl super::ResponseFormatter for Formatter { // Can't be known here, must be inserted upstream. block_number: 0, output: match res { - CallResult::Output(output) => + CallResult::Output(output) => { TransactionTraceOutput::Result(TransactionTraceResult::Call { gas_used: trace.gas_used, output, - }), + }) + }, CallResult::Error(error) => TransactionTraceOutput::Error(error), }, subtraces: trace.subtraces, @@ -86,14 +87,16 @@ impl super::ResponseFormatter for Formatter { CreateResult::Success { created_contract_address_hash, created_contract_code, - } => + } => { TransactionTraceOutput::Result(TransactionTraceResult::Create { gas_used: trace.gas_used, code: created_contract_code, address: created_contract_address_hash, - }), - CreateResult::Error { error } => - TransactionTraceOutput::Error(error), + }) + }, + CreateResult::Error { error } => { + TransactionTraceOutput::Error(error) + }, }, subtraces: trace.subtraces, trace_address: trace.trace_address.clone(), diff --git a/client/evm-tracing/src/listeners/call_list.rs b/client/evm-tracing/src/listeners/call_list.rs index 5ca1eb15e..9da8a66a0 100644 --- a/client/evm-tracing/src/listeners/call_list.rs +++ b/client/evm-tracing/src/listeners/call_list.rs @@ -224,9 +224,9 @@ impl Listener { pub fn gasometer_event(&mut self, event: GasometerEvent) { match event { - GasometerEvent::RecordCost { snapshot, .. } | - GasometerEvent::RecordDynamicCost { snapshot, .. } | - GasometerEvent::RecordStipend { snapshot, .. } => { + GasometerEvent::RecordCost { snapshot, .. } + | GasometerEvent::RecordDynamicCost { snapshot, .. } + | GasometerEvent::RecordStipend { snapshot, .. } => { if let Some(context) = self.context_stack.last_mut() { if context.start_gas.is_none() { context.start_gas = Some(snapshot.gas()); @@ -497,12 +497,13 @@ impl Listener { // behavior (like batch precompile does) thus we simply consider this a call. self.call_type = Some(CallType::Call); }, - EvmEvent::Log { address, topics, data } => + EvmEvent::Log { address, topics, data } => { if self.with_log { if let Some(stack) = self.context_stack.last_mut() { stack.logs.push(Log { address, topics, data }); } - }, + } + }, // We ignore other kinds of message if any (new ones may be added in the future). #[allow(unreachable_patterns)] @@ -536,13 +537,15 @@ impl Listener { match context.context_type { ContextType::Call(call_type) => { let res = match &reason { - ExitReason::Succeed(ExitSucceed::Returned) => - CallResult::Output(return_value.to_vec()), + ExitReason::Succeed(ExitSucceed::Returned) => { + CallResult::Output(return_value.to_vec()) + }, ExitReason::Succeed(_) => CallResult::Output(vec![]), ExitReason::Error(error) => CallResult::Error(error_message(error)), - ExitReason::Revert(_) => - CallResult::Error(b"execution reverted".to_vec()), + ExitReason::Revert(_) => { + CallResult::Error(b"execution reverted".to_vec()) + }, ExitReason::Fatal(_) => CallResult::Error(vec![]), }; @@ -568,10 +571,12 @@ impl Listener { created_contract_address_hash: context.to, created_contract_code: return_value.to_vec(), }, - ExitReason::Error(error) => - CreateResult::Error { error: error_message(error) }, - ExitReason::Revert(_) => - CreateResult::Error { error: b"execution reverted".to_vec() }, + ExitReason::Error(error) => { + CreateResult::Error { error: error_message(error) } + }, + ExitReason::Revert(_) => { + CreateResult::Error { error: b"execution reverted".to_vec() } + }, ExitReason::Fatal(_) => CreateResult::Error { error: vec![] }, }; @@ -620,14 +625,15 @@ impl ListenerT for Listener { Event::Gasometer(gasometer_event) => self.gasometer_event(gasometer_event), Event::Runtime(runtime_event) => self.runtime_event(runtime_event), Event::Evm(evm_event) => self.evm_event(evm_event), - Event::CallListNew() => + Event::CallListNew() => { if !self.call_list_first_transaction { self.finish_transaction(); self.skip_next_context = false; self.entries.push(BTreeMap::new()); } else { self.call_list_first_transaction = false; - }, + } + }, }; } @@ -726,8 +732,9 @@ mod tests { target: H160::default(), balance: U256::zero(), }, - TestEvmEvent::Exit => - EvmEvent::Exit { reason: exit_reason.unwrap(), return_value: Vec::new() }, + TestEvmEvent::Exit => { + EvmEvent::Exit { reason: exit_reason.unwrap(), return_value: Vec::new() } + }, TestEvmEvent::TransactCall => EvmEvent::TransactCall { caller: H160::default(), address: H160::default(), @@ -750,8 +757,9 @@ mod tests { gas_limit: 0u64, address: H160::default(), }, - TestEvmEvent::Log => - EvmEvent::Log { address: H160::default(), topics: Vec::new(), data: Vec::new() }, + TestEvmEvent::Log => { + EvmEvent::Log { address: H160::default(), topics: Vec::new(), data: Vec::new() } + }, } } @@ -764,8 +772,9 @@ mod tests { stack: test_stack(), memory: test_memory(), }, - TestRuntimeEvent::StepResult => - RuntimeEvent::StepResult { result: Ok(()), return_value: Vec::new() }, + TestRuntimeEvent::StepResult => { + RuntimeEvent::StepResult { result: Ok(()), return_value: Vec::new() } + }, TestRuntimeEvent::SLoad => RuntimeEvent::SLoad { address: H160::default(), index: H256::default(), @@ -781,20 +790,24 @@ mod tests { fn test_emit_gasometer_event(event_type: TestGasometerEvent) -> GasometerEvent { match event_type { - TestGasometerEvent::RecordCost => - GasometerEvent::RecordCost { cost: 0u64, snapshot: test_snapshot() }, - TestGasometerEvent::RecordRefund => - GasometerEvent::RecordRefund { refund: 0i64, snapshot: test_snapshot() }, - TestGasometerEvent::RecordStipend => - GasometerEvent::RecordStipend { stipend: 0u64, snapshot: test_snapshot() }, + TestGasometerEvent::RecordCost => { + GasometerEvent::RecordCost { cost: 0u64, snapshot: test_snapshot() } + }, + TestGasometerEvent::RecordRefund => { + GasometerEvent::RecordRefund { refund: 0i64, snapshot: test_snapshot() } + }, + TestGasometerEvent::RecordStipend => { + GasometerEvent::RecordStipend { stipend: 0u64, snapshot: test_snapshot() } + }, TestGasometerEvent::RecordDynamicCost => GasometerEvent::RecordDynamicCost { gas_cost: 0u64, memory_gas: 0u64, gas_refund: 0i64, snapshot: test_snapshot(), }, - TestGasometerEvent::RecordTransaction => - GasometerEvent::RecordTransaction { cost: 0u64, snapshot: test_snapshot() }, + TestGasometerEvent::RecordTransaction => { + GasometerEvent::RecordTransaction { cost: 0u64, snapshot: test_snapshot() } + }, } } diff --git a/client/evm-tracing/src/listeners/raw.rs b/client/evm-tracing/src/listeners/raw.rs index 2b39fe238..483ea0a3d 100644 --- a/client/evm-tracing/src/listeners/raw.rs +++ b/client/evm-tracing/src/listeners/raw.rs @@ -161,7 +161,7 @@ impl Listener { .and_then(|inner| inner.checked_sub(memory.data.len())); if self.remaining_memory_usage.is_none() { - return + return; } Some(memory.data.clone()) @@ -176,7 +176,7 @@ impl Listener { .and_then(|inner| inner.checked_sub(stack.data.len())); if self.remaining_memory_usage.is_none() { - return + return; } Some(stack.data.clone()) @@ -205,7 +205,7 @@ impl Listener { }); if self.remaining_memory_usage.is_none() { - return + return; } Some(context.storage_cache.clone()) @@ -277,8 +277,8 @@ impl Listener { _ => (), } }, - RuntimeEvent::SLoad { address: _, index, value } | - RuntimeEvent::SStore { address: _, index, value } => { + RuntimeEvent::SLoad { address: _, index, value } + | RuntimeEvent::SStore { address: _, index, value } => { if let Some(context) = self.context_stack.last_mut() { if !self.disable_storage { context.storage_cache.insert(index, value); @@ -295,7 +295,7 @@ impl Listener { impl ListenerT for Listener { fn event(&mut self, event: Event) { if self.remaining_memory_usage.is_none() { - return + return; } match event { diff --git a/client/evm-tracing/src/types/serialization.rs b/client/evm-tracing/src/types/serialization.rs index 9f31f709f..f786ffafd 100644 --- a/client/evm-tracing/src/types/serialization.rs +++ b/client/evm-tracing/src/types/serialization.rs @@ -54,7 +54,7 @@ where S: Serializer, { if let Some(bytes) = bytes.as_ref() { - return serializer.serialize_str(&format!("0x{}", hex::encode(&bytes[..]))) + return serializer.serialize_str(&format!("0x{}", hex::encode(&bytes[..]))); } Err(S::Error::custom("String serialize error.")) } @@ -87,7 +87,7 @@ where let d = std::str::from_utf8(&value[..]) .map_err(|_| S::Error::custom("String serialize error."))? .to_string(); - return serializer.serialize_str(&d) + return serializer.serialize_str(&d); } Err(S::Error::custom("String serialize error.")) } diff --git a/client/rpc-core/txpool/src/types/content.rs b/client/rpc-core/txpool/src/types/content.rs index 581be1737..ec98a00f4 100644 --- a/client/rpc-core/txpool/src/types/content.rs +++ b/client/rpc-core/txpool/src/types/content.rs @@ -66,12 +66,15 @@ where impl GetT for Transaction { fn get(hash: H256, from_address: H160, txn: &EthereumTransaction) -> Self { let (nonce, action, value, gas_price, gas_limit, input) = match txn { - EthereumTransaction::Legacy(t) => - (t.nonce, t.action, t.value, t.gas_price, t.gas_limit, t.input.clone()), - EthereumTransaction::EIP2930(t) => - (t.nonce, t.action, t.value, t.gas_price, t.gas_limit, t.input.clone()), - EthereumTransaction::EIP1559(t) => - (t.nonce, t.action, t.value, t.max_fee_per_gas, t.gas_limit, t.input.clone()), + EthereumTransaction::Legacy(t) => { + (t.nonce, t.action, t.value, t.gas_price, t.gas_limit, t.input.clone()) + }, + EthereumTransaction::EIP2930(t) => { + (t.nonce, t.action, t.value, t.gas_price, t.gas_limit, t.input.clone()) + }, + EthereumTransaction::EIP1559(t) => { + (t.nonce, t.action, t.value, t.max_fee_per_gas, t.gas_limit, t.input.clone()) + }, }; Self { hash, diff --git a/client/rpc/debug/src/lib.rs b/client/rpc/debug/src/lib.rs index c1878acac..aa85097d8 100644 --- a/client/rpc/debug/src/lib.rs +++ b/client/rpc/debug/src/lib.rs @@ -353,12 +353,15 @@ where let reference_id: BlockId = match request_block_id { RequestBlockId::Number(n) => Ok(BlockId::Number(n.unique_saturated_into())), - RequestBlockId::Tag(RequestBlockTag::Latest) => - Ok(BlockId::Number(client.info().best_number)), - RequestBlockId::Tag(RequestBlockTag::Earliest) => - Ok(BlockId::Number(0u32.unique_saturated_into())), - RequestBlockId::Tag(RequestBlockTag::Pending) => - Err(internal_err("'pending' blocks are not supported")), + RequestBlockId::Tag(RequestBlockTag::Latest) => { + Ok(BlockId::Number(client.info().best_number)) + }, + RequestBlockId::Tag(RequestBlockTag::Earliest) => { + Ok(BlockId::Number(0u32.unique_saturated_into())) + }, + RequestBlockId::Tag(RequestBlockTag::Pending) => { + Err(internal_err("'pending' blocks are not supported")) + }, RequestBlockId::Hash(eth_hash) => { match futures::executor::block_on(frontier_backend_client::load_hash::( client.as_ref(), @@ -378,7 +381,7 @@ where let blockchain = backend.blockchain(); // Get the header I want to work with. let Ok(hash) = client.expect_block_hash_from_id(&reference_id) else { - return Err(internal_err("Block header not found")) + return Err(internal_err("Block header not found")); }; let header = match client.header(hash) { Ok(Some(h)) => h, @@ -395,7 +398,7 @@ where // If there are no ethereum transactions in the block return empty trace right away. if eth_tx_hashes.is_empty() { - return Ok(Response::Block(vec![])) + return Ok(Response::Block(vec![])); } // Get block extrinsics. @@ -410,7 +413,7 @@ where { api_version } else { - return Err(internal_err("Runtime api version call failed (trace)".to_string())) + return Err(internal_err("Runtime api version call failed (trace)".to_string())); }; // Trace the block. @@ -425,7 +428,7 @@ where { api_version } else { - return Err(internal_err("Runtime api version call failed (core)".to_string())) + return Err(internal_err("Runtime api version call failed (core)".to_string())); }; // Initialize block: calls the "on_initialize" hook on every pallet @@ -470,10 +473,11 @@ where proxy.using(f)?; proxy.finish_transaction(); let response = match tracer_input { - TracerInput::CallTracer => + TracerInput::CallTracer => { client_evm_tracing::formatters::CallTracer::format(proxy) .ok_or("Trace result is empty.") - .map_err(|e| internal_err(format!("{:?}", e))), + .map_err(|e| internal_err(format!("{:?}", e))) + }, _ => Err(internal_err("Bug: failed to resolve the tracer format.".to_string())), }?; @@ -533,7 +537,7 @@ where let blockchain = backend.blockchain(); // Get the header I want to work with. let Ok(reference_hash) = client.expect_block_hash_from_id(&reference_id) else { - return Err(internal_err("Block header not found")) + return Err(internal_err("Block header not found")); }; let header = match client.header(reference_hash) { Ok(Some(h)) => h, @@ -554,7 +558,7 @@ where { api_version } else { - return Err(internal_err("Runtime api version call failed (trace)".to_string())) + return Err(internal_err("Runtime api version call failed (trace)".to_string())); }; let reference_block = overrides.current_block(reference_hash); @@ -576,7 +580,7 @@ where } else { return Err(internal_err( "Runtime api version call failed (core)".to_string(), - )) + )); }; // Initialize block: calls the "on_initialize" hook on every pallet @@ -608,17 +612,20 @@ where // Pre-london update, legacy transactions. match transaction { ethereum::TransactionV2::Legacy(tx) => + { #[allow(deprecated)] api.trace_transaction_before_version_4( parent_block_hash, exts, tx, - ), - _ => + ) + }, + _ => { return Err(internal_err( "Bug: pre-london runtime expects legacy transactions" .to_string(), - )), + )) + }, } } }; @@ -659,10 +666,11 @@ where proxy.using(f)?; proxy.finish_transaction(); let response = match tracer_input { - TracerInput::Blockscout => + TracerInput::Blockscout => { client_evm_tracing::formatters::Blockscout::format(proxy) .ok_or("Trace result is empty.") - .map_err(|e| internal_err(format!("{:?}", e))), + .map_err(|e| internal_err(format!("{:?}", e))) + }, TracerInput::CallTracer => { let mut res = client_evm_tracing::formatters::CallTracer::format(proxy) @@ -680,7 +688,7 @@ where "Bug: `handle_transaction_request` does not support {:?}.", not_supported ))), - } + }; } } Err(internal_err("Runtime block call failed".to_string())) @@ -698,12 +706,15 @@ where let reference_id: BlockId = match request_block_id { RequestBlockId::Number(n) => Ok(BlockId::Number(n.unique_saturated_into())), - RequestBlockId::Tag(RequestBlockTag::Latest) => - Ok(BlockId::Number(client.info().best_number)), - RequestBlockId::Tag(RequestBlockTag::Earliest) => - Ok(BlockId::Number(0u32.unique_saturated_into())), - RequestBlockId::Tag(RequestBlockTag::Pending) => - Err(internal_err("'pending' blocks are not supported")), + RequestBlockId::Tag(RequestBlockTag::Latest) => { + Ok(BlockId::Number(client.info().best_number)) + }, + RequestBlockId::Tag(RequestBlockTag::Earliest) => { + Ok(BlockId::Number(0u32.unique_saturated_into())) + }, + RequestBlockId::Tag(RequestBlockTag::Pending) => { + Err(internal_err("'pending' blocks are not supported")) + }, RequestBlockId::Hash(eth_hash) => { match futures::executor::block_on(frontier_backend_client::load_hash::( client.as_ref(), @@ -721,7 +732,7 @@ where let api = client.runtime_api(); // Get the header I want to work with. let Ok(hash) = client.expect_block_hash_from_id(&reference_id) else { - return Err(internal_err("Block header not found")) + return Err(internal_err("Block header not found")); }; let header = match client.header(hash) { Ok(Some(h)) => h, @@ -736,11 +747,11 @@ where { api_version } else { - return Err(internal_err("Runtime api version call failed (trace)".to_string())) + return Err(internal_err("Runtime api version call failed (trace)".to_string())); }; if trace_api_version <= 5 { - return Err(internal_err("debug_traceCall not supported with old runtimes".to_string())) + return Err(internal_err("debug_traceCall not supported with old runtimes".to_string())); } let TraceCallParams { @@ -795,7 +806,7 @@ where } else { return Err(internal_err( "block unavailable, cannot query gas limit".to_string(), - )) + )); } }, }; @@ -847,10 +858,11 @@ where proxy.using(f)?; proxy.finish_transaction(); let response = match tracer_input { - TracerInput::Blockscout => + TracerInput::Blockscout => { client_evm_tracing::formatters::Blockscout::format(proxy) .ok_or("Trace result is empty.") - .map_err(|e| internal_err(format!("{:?}", e))), + .map_err(|e| internal_err(format!("{:?}", e))) + }, TracerInput::CallTracer => { let mut res = client_evm_tracing::formatters::CallTracer::format(proxy) .ok_or("Trace result is empty.") diff --git a/client/rpc/trace/src/lib.rs b/client/rpc/trace/src/lib.rs index 4514ce79b..72c564dfd 100644 --- a/client/rpc/trace/src/lib.rs +++ b/client/rpc/trace/src/lib.rs @@ -100,8 +100,9 @@ where .try_into() .map_err(|_| "Block number overflow")?), Some(RequestBlockId::Tag(RequestBlockTag::Earliest)) => Ok(0), - Some(RequestBlockId::Tag(RequestBlockTag::Pending)) => - Err("'pending' is not supported"), + Some(RequestBlockId::Tag(RequestBlockTag::Pending)) => { + Err("'pending' is not supported") + }, Some(RequestBlockId::Hash(_)) => Err("Block hash not supported"), } } @@ -117,14 +118,14 @@ where return Err(format!( "count ({}) can't be greater than maximum ({})", count, self.max_count - )) + )); } // Build a list of all the Substrate block hashes that need to be traced. let mut block_hashes = vec![]; for block_height in block_heights { if block_height == 0 { - continue // no traces for genesis block. + continue; // no traces for genesis block. } let block_hash = self @@ -173,15 +174,18 @@ where let mut block_traces: Vec<_> = block_traces .iter() .filter(|trace| match trace.action { - block::TransactionTraceAction::Call { from, to, .. } => - (from_address.is_empty() || from_address.contains(&from)) && - (to_address.is_empty() || to_address.contains(&to)), - block::TransactionTraceAction::Create { from, .. } => - (from_address.is_empty() || from_address.contains(&from)) && - to_address.is_empty(), - block::TransactionTraceAction::Suicide { address, .. } => - (from_address.is_empty() || from_address.contains(&address)) && - to_address.is_empty(), + block::TransactionTraceAction::Call { from, to, .. } => { + (from_address.is_empty() || from_address.contains(&from)) + && (to_address.is_empty() || to_address.contains(&to)) + }, + block::TransactionTraceAction::Create { from, .. } => { + (from_address.is_empty() || from_address.contains(&from)) + && to_address.is_empty() + }, + block::TransactionTraceAction::Suicide { address, .. } => { + (from_address.is_empty() || from_address.contains(&address)) + && to_address.is_empty() + }, }) .cloned() .collect(); @@ -207,11 +211,11 @@ where "the amount of traces goes over the maximum ({}), please use 'after' \ and 'count' in your request", self.max_count - )) + )); } traces = traces.into_iter().take(count).collect(); - break + break; } } } @@ -648,8 +652,8 @@ where // We remove early the block cache if this batch is the last // pooling this block. if let Some(block_cache) = self.cached_blocks.get_mut(block) { - if block_cache.active_batch_count == 1 && - matches!( + if block_cache.active_batch_count == 1 + && matches!( block_cache.state, CacheBlockState::Pooled { started: false, .. } ) { @@ -756,11 +760,12 @@ where overrides.current_transaction_statuses(substrate_hash), ) { (Some(a), Some(b)) => (a, b), - _ => + _ => { return Err(format!( "Failed to get Ethereum block data for Substrate block {}", substrate_hash - )), + )) + }, }; let eth_block_hash = eth_block.header.hash(); @@ -781,7 +786,7 @@ where { api_version } else { - return Err("Runtime api version call failed (trace)".to_string()) + return Err("Runtime api version call failed (trace)".to_string()); }; // Trace the block. @@ -795,7 +800,7 @@ where { api_version } else { - return Err("Runtime api version call failed (core)".to_string()) + return Err("Runtime api version call failed (core)".to_string()); }; // Initialize block: calls the "on_initialize" hook on every pallet diff --git a/client/rpc/txpool/src/lib.rs b/client/rpc/txpool/src/lib.rs index c00ad9359..101050c5b 100644 --- a/client/rpc/txpool/src/lib.rs +++ b/client/rpc/txpool/src/lib.rs @@ -74,7 +74,7 @@ where if let Ok(Some(api_version)) = api.api_version::>(best_block) { api_version } else { - return Err(internal_err("failed to retrieve Runtime Api version".to_string())) + return Err(internal_err("failed to retrieve Runtime Api version".to_string())); }; let ethereum_txns: TxPoolResponse = if api_version == 1 { #[allow(deprecated)] diff --git a/frost/frost-ristretto255/src/lib.rs b/frost/frost-ristretto255/src/lib.rs index a3322ef47..a4d955fc5 100644 --- a/frost/frost-ristretto255/src/lib.rs +++ b/frost/frost-ristretto255/src/lib.rs @@ -102,12 +102,13 @@ impl Group for RistrettoGroup { .map_err(|_| GroupError::MalformedElement)? .decompress() { - Some(point) => + Some(point) => { if point == RistrettoPoint::identity() { Err(GroupError::InvalidIdentityElement) } else { Ok(WrappedRistrettoPoint(point)) - }, + } + }, None => Err(GroupError::MalformedElement), } } diff --git a/frost/src/keys.rs b/frost/src/keys.rs index 5069d93f3..1c2656da4 100644 --- a/frost/src/keys.rs +++ b/frost/src/keys.rs @@ -384,7 +384,7 @@ where let result = evaluate_vss(self.identifier, &self.commitment); if !(f_result == result) { - return Err(Error::InvalidSecretShare) + return Err(Error::InvalidSecretShare); } Ok((VerifyingShare(result), self.commitment.verifying_key()?)) diff --git a/frost/src/lib.rs b/frost/src/lib.rs index 5bd2fdff9..ede2024db 100644 --- a/frost/src/lib.rs +++ b/frost/src/lib.rs @@ -66,7 +66,7 @@ pub fn random_nonzero(rng: &mut R) -> Sc let scalar = <::Field>::random(rng); if scalar != <::Field>::zero() { - return scalar + return scalar; } } } @@ -203,7 +203,7 @@ fn compute_lagrange_coefficient( x_i: Identifier, ) -> Result, Error> { if x_set.is_empty() { - return Err(Error::IncorrectNumberOfIdentifiers) + return Err(Error::IncorrectNumberOfIdentifiers); } let mut num = <::Field>::one(); let mut den = <::Field>::one(); @@ -213,7 +213,7 @@ fn compute_lagrange_coefficient( for x_j in x_set.iter() { if x_i == *x_j { x_i_found = true; - continue + continue; } if let Some(x) = x { @@ -226,7 +226,7 @@ fn compute_lagrange_coefficient( } } if !x_i_found { - return Err(Error::UnknownIdentifier) + return Err(Error::UnknownIdentifier); } Ok(num * <::Field>::invert(&den).map_err(|_| Error::DuplicatedIdentifier)?) @@ -396,7 +396,7 @@ where // The following check prevents a party from accidentally revealing their share. // Note that the '&&' operator would be sufficient. if identity == commitment.binding.0 || identity == commitment.hiding.0 { - return Err(Error::IdentityCommitment) + return Err(Error::IdentityCommitment); } let binding_factor = diff --git a/frost/src/round1.rs b/frost/src/round1.rs index 52f7d61af..54039c005 100644 --- a/frost/src/round1.rs +++ b/frost/src/round1.rs @@ -106,9 +106,9 @@ where /// Checks if the commitments are valid. pub fn is_valid(&self) -> bool { - element_is_valid::(&self.hiding.0) && - element_is_valid::(&self.binding.0) && - self.hiding.0 != self.binding.0 + element_is_valid::(&self.hiding.0) + && element_is_valid::(&self.binding.0) + && self.hiding.0 != self.binding.0 } } diff --git a/frost/src/scalar_mul.rs b/frost/src/scalar_mul.rs index a80b98b32..8211ac83e 100644 --- a/frost/src/scalar_mul.rs +++ b/frost/src/scalar_mul.rs @@ -118,7 +118,7 @@ where // If carry == 1 and window & 1 == 0, then bit_buf & 1 == 1 so the next carry should // be 1 pos += 1; - continue + continue; } if window < width / 2 { @@ -197,14 +197,14 @@ where .collect::>>()?; if nafs.len() != lookup_tables.len() { - return None + return None; } let mut r = ::identity(); // All NAFs will have the same size, so get it from the first if nafs.is_empty() { - return Some(r) + return Some(r); } let naf_length = nafs[0].len(); diff --git a/frost/src/signature.rs b/frost/src/signature.rs index c7f059e50..5a1f89bef 100644 --- a/frost/src/signature.rs +++ b/frost/src/signature.rs @@ -210,10 +210,10 @@ where lambda_i: Scalar, challenge: &Challenge, ) -> Result<(), Error> { - if (::generator() * self.share) != - (group_commitment_share.0 + (verifying_share.0 * challenge.0 * lambda_i)) + if (::generator() * self.share) + != (group_commitment_share.0 + (verifying_share.0 * challenge.0 * lambda_i)) { - return Err(Error::InvalidSignatureShare) + return Err(Error::InvalidSignatureShare); } Ok(()) diff --git a/frost/src/signing_key.rs b/frost/src/signing_key.rs index 9307d5ed3..758600f51 100644 --- a/frost/src/signing_key.rs +++ b/frost/src/signing_key.rs @@ -44,7 +44,7 @@ where <::Field as Field>::deserialize(&bytes).map_err(Error::from)?; if scalar == <::Field as Field>::zero() { - return Err(Error::MalformedSigningKey) + return Err(Error::MalformedSigningKey); } Ok(Self { scalar }) diff --git a/node/src/distributions/mainnet.rs b/node/src/distributions/mainnet.rs index cfbec8755..a88ba554d 100644 --- a/node/src/distributions/mainnet.rs +++ b/node/src/distributions/mainnet.rs @@ -44,7 +44,7 @@ fn read_contents_to_substrate_accounts(path_str: &str) -> BTreeMap BTreeMap BTreeMap Result<(), S // Ensure key is present if !ensure_keytype_exists_in_keystore(key_type, key_store.clone()) { println!("{key_type:?} key not found!"); - return Err("Key not found!".to_string()) + return Err("Key not found!".to_string()); } } diff --git a/pallets/claims/src/lib.rs b/pallets/claims/src/lib.rs index 40964208f..161de15db 100644 --- a/pallets/claims/src/lib.rs +++ b/pallets/claims/src/lib.rs @@ -94,14 +94,16 @@ impl StatementKind { /// Convert this to the (English) statement it represents. fn to_text(self) -> &'static [u8] { match self { - StatementKind::Regular => + StatementKind::Regular => { &b"I hereby agree to the terms of the statement whose sha2256sum is \ 5627de05cfe235cd4ffa0d6375c8a5278b89cc9b9e75622fa2039f4d1b43dadf. (This may be found at the URL: \ - https://statement.tangle.tools/airdrop-statement.html)"[..], - StatementKind::Safe => + https://statement.tangle.tools/airdrop-statement.html)"[..] + }, + StatementKind::Safe => { &b"I hereby agree to the terms of the statement whose sha2256sum is \ 7eae145b00c1912c8b01674df5df4ad9abcf6d18ea3f33d27eb6897a762f4273. (This may be found at the URL: \ - https://statement.tangle.tools/safe-claim-statement)"[..], + https://statement.tangle.tools/safe-claim-statement)"[..] + }, } } } @@ -639,9 +641,10 @@ impl Pallet { statement: Vec, ) -> Result> { let signer = match signature { - MultiAddressSignature::EVM(ethereum_signature) => + MultiAddressSignature::EVM(ethereum_signature) => { Self::eth_recover(ðereum_signature, &data, &statement[..]) - .ok_or(Error::::InvalidEthereumSignature)?, + .ok_or(Error::::InvalidEthereumSignature)? + }, MultiAddressSignature::Native(sr25519_signature) => { ensure!(!signer.is_none(), Error::::InvalidNativeAccount); Self::sr25519_recover(signer.unwrap(), &sr25519_signature, &data, &statement[..]) diff --git a/pallets/claims/src/utils/mod.rs b/pallets/claims/src/utils/mod.rs index f25596857..a387457fc 100644 --- a/pallets/claims/src/utils/mod.rs +++ b/pallets/claims/src/utils/mod.rs @@ -45,8 +45,9 @@ impl Hash for MultiAddress { impl MultiAddress { pub fn to_account_id_32(&self) -> AccountId32 { match self { - MultiAddress::EVM(ethereum_address) => - HashedAddressMapping::::into_account_id(H160::from(ethereum_address.0)), + MultiAddress::EVM(ethereum_address) => { + HashedAddressMapping::::into_account_id(H160::from(ethereum_address.0)) + }, MultiAddress::Native(substrate_address) => substrate_address.clone(), } } diff --git a/pallets/multi-asset-delegation/src/functions/delegate.rs b/pallets/multi-asset-delegation/src/functions/delegate.rs index 73a858324..03c95e663 100644 --- a/pallets/multi-asset-delegation/src/functions/delegate.rs +++ b/pallets/multi-asset-delegation/src/functions/delegate.rs @@ -121,7 +121,7 @@ impl Pallet { // Update storage Operators::::insert(&operator, operator_metadata); } else { - return Err(Error::::NotAnOperator.into()) + return Err(Error::::NotAnOperator.into()); } Ok(()) diff --git a/pallets/multi-asset-delegation/src/functions/deposit.rs b/pallets/multi-asset-delegation/src/functions/deposit.rs index 34410afed..08cff321e 100644 --- a/pallets/multi-asset-delegation/src/functions/deposit.rs +++ b/pallets/multi-asset-delegation/src/functions/deposit.rs @@ -190,7 +190,7 @@ impl Pallet { Preservation::Expendable, ) .is_ok(), - Asset::Erc20(asset_address) => + Asset::Erc20(asset_address) => { if let Some(evm_addr) = evm_address { if let Ok((success, _weight)) = Self::erc20_transfer( asset_address, @@ -204,7 +204,8 @@ impl Pallet { } } else { false - }, + } + }, } } else { true diff --git a/pallets/multi-asset-delegation/src/mock.rs b/pallets/multi-asset-delegation/src/mock.rs index 32dbc36a8..d5d9abd45 100644 --- a/pallets/multi-asset-delegation/src/mock.rs +++ b/pallets/multi-asset-delegation/src/mock.rs @@ -649,10 +649,11 @@ pub fn assert_events(mut expected: Vec) { for evt in expected { let next = actual.pop().expect("RuntimeEvent expected"); match (&next, &evt) { - (left_val, right_val) => + (left_val, right_val) => { if !(*left_val == *right_val) { panic!("Events don't match\nactual: {actual:#?}\nexpected: {evt:#?}"); - }, + } + }, }; } } diff --git a/pallets/multi-asset-delegation/src/mock_evm.rs b/pallets/multi-asset-delegation/src/mock_evm.rs index 86325eff9..ece3807aa 100644 --- a/pallets/multi-asset-delegation/src/mock_evm.rs +++ b/pallets/multi-asset-delegation/src/mock_evm.rs @@ -165,7 +165,7 @@ impl OnChargeEVMTransaction for CustomEVMCurrencyAdapter { pallet_multi_asset_delegation::Pallet::::pallet_evm_account(); // Make pallet multi_asset_delegation account free to use if who == &pallet_multi_asset_delegation_address { - return Ok(None) + return Ok(None); } // fallback to the default implementation as OnChargeEVMTransaction< @@ -183,7 +183,7 @@ impl OnChargeEVMTransaction for CustomEVMCurrencyAdapter { pallet_multi_asset_delegation::Pallet::::pallet_evm_account(); // Make pallet multi_asset_delegation account free to use if who == &pallet_multi_asset_delegation_address { - return already_withdrawn + return already_withdrawn; } // fallback to the default implementation as OnChargeEVMTransaction< @@ -269,8 +269,9 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { len: usize, ) -> Option> { match self { - RuntimeCall::Ethereum(call) => - call.pre_dispatch_self_contained(info, dispatch_info, len), + RuntimeCall::Ethereum(call) => { + call.pre_dispatch_self_contained(info, dispatch_info, len) + }, _ => None, } } @@ -280,8 +281,9 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { info: Self::SignedInfo, ) -> Option>> { match self { - call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => - Some(call.dispatch(RuntimeOrigin::from(RawOrigin::EthereumTransaction(info)))), + call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => { + Some(call.dispatch(RuntimeOrigin::from(RawOrigin::EthereumTransaction(info)))) + }, _ => None, } } diff --git a/pallets/multi-asset-delegation/src/tests/operator.rs b/pallets/multi-asset-delegation/src/tests/operator.rs index 27ed16a18..69bec2708 100644 --- a/pallets/multi-asset-delegation/src/tests/operator.rs +++ b/pallets/multi-asset-delegation/src/tests/operator.rs @@ -302,8 +302,8 @@ fn schedule_operator_unstake_success() { // Verify remaining stake is above minimum assert!( - operator_info.stake.saturating_sub(unstake_amount) >= - MinOperatorBondAmount::get().into() + operator_info.stake.saturating_sub(unstake_amount) + >= MinOperatorBondAmount::get().into() ); // Verify event @@ -373,7 +373,7 @@ fn schedule_operator_unstake_not_an_operator() { // // Attempt to schedule unstake with active services // assert_noop!( -// +// // MultiAssetDelegation::schedule_operator_unstake(RuntimeOrigin::signed(Alice.to_account_id()), // unstake_amount), Error::::ActiveServicesUsingTNT // ); diff --git a/pallets/services/rpc/src/lib.rs b/pallets/services/rpc/src/lib.rs index e25f3c232..ce67fb1b7 100644 --- a/pallets/services/rpc/src/lib.rs +++ b/pallets/services/rpc/src/lib.rs @@ -113,10 +113,12 @@ impl From for i32 { fn custom_error_into_rpc_err(err: Error) -> ErrorObjectOwned { match err { - Error::RuntimeError(e) => - ErrorObject::owned(RUNTIME_ERROR, "Runtime error", Some(format!("{e}"))), - Error::DecodeError => - ErrorObject::owned(2, "Decode error", Some("Transaction was not decodable")), + Error::RuntimeError(e) => { + ErrorObject::owned(RUNTIME_ERROR, "Runtime error", Some(format!("{e}"))) + }, + Error::DecodeError => { + ErrorObject::owned(2, "Decode error", Some("Transaction was not decodable")) + }, Error::CustomDispatchError(msg) => ErrorObject::owned(3, "Dispatch error", Some(msg)), } } diff --git a/pallets/services/src/functions.rs b/pallets/services/src/functions.rs index 4fd786b7f..5080ebe2c 100644 --- a/pallets/services/src/functions.rs +++ b/pallets/services/src/functions.rs @@ -77,8 +77,9 @@ impl Pallet { pub fn mbsm_address_of(blueprint: &ServiceBlueprint) -> Result> { match blueprint.master_manager_revision { MasterBlueprintServiceManagerRevision::Specific(rev) => Self::mbsm_address(rev), - MasterBlueprintServiceManagerRevision::Latest => - Self::mbsm_address(Self::mbsm_latest_revision()), + MasterBlueprintServiceManagerRevision::Latest => { + Self::mbsm_address(Self::mbsm_latest_revision()) + }, other => unimplemented!("Got unexpected case for {:?}", other), } } diff --git a/pallets/services/src/lib.rs b/pallets/services/src/lib.rs index 06677d2f1..7a8d82c37 100644 --- a/pallets/services/src/lib.rs +++ b/pallets/services/src/lib.rs @@ -1071,8 +1071,9 @@ pub mod module { .operators_with_approval_state .into_iter() .filter_map(|(v, state)| match state { - ApprovalState::Approved { restaking_percent } => - Some((v, restaking_percent)), + ApprovalState::Approved { restaking_percent } => { + Some((v, restaking_percent)) + }, // N.B: this should not happen, as all operators are approved and checked // above. _ => None, diff --git a/pallets/services/src/mock.rs b/pallets/services/src/mock.rs index 3ba4c7c39..7f161aef3 100644 --- a/pallets/services/src/mock.rs +++ b/pallets/services/src/mock.rs @@ -275,7 +275,7 @@ impl tangle_primitives::traits::MultiAssetDelegationInfo fn is_operator_active(operator: &AccountId) -> bool { if operator == &mock_pub_key(10) { - return false + return false; } true } @@ -775,10 +775,11 @@ pub fn assert_events(mut expected: Vec) { for evt in expected { let next = actual.pop().expect("RuntimeEvent expected"); match (&next, &evt) { - (left_val, right_val) => + (left_val, right_val) => { if !(*left_val == *right_val) { panic!("Events don't match\nactual: {actual:#?}\nexpected: {evt:#?}"); - }, + } + }, }; } } diff --git a/pallets/services/src/mock_evm.rs b/pallets/services/src/mock_evm.rs index 46b7ea04f..02bc329c8 100644 --- a/pallets/services/src/mock_evm.rs +++ b/pallets/services/src/mock_evm.rs @@ -163,7 +163,7 @@ impl OnChargeEVMTransaction for CustomEVMCurrencyAdapter { let pallet_services_address = pallet_services::Pallet::::address(); // Make pallet services account free to use if who == &pallet_services_address { - return Ok(None) + return Ok(None); } // fallback to the default implementation as OnChargeEVMTransaction< @@ -180,7 +180,7 @@ impl OnChargeEVMTransaction for CustomEVMCurrencyAdapter { let pallet_services_address = pallet_services::Pallet::::address(); // Make pallet services account free to use if who == &pallet_services_address { - return already_withdrawn + return already_withdrawn; } // fallback to the default implementation as OnChargeEVMTransaction< @@ -266,8 +266,9 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { len: usize, ) -> Option> { match self { - RuntimeCall::Ethereum(call) => - call.pre_dispatch_self_contained(info, dispatch_info, len), + RuntimeCall::Ethereum(call) => { + call.pre_dispatch_self_contained(info, dispatch_info, len) + }, _ => None, } } @@ -277,8 +278,9 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { info: Self::SignedInfo, ) -> Option>> { match self { - call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => - Some(call.dispatch(RuntimeOrigin::from(RawOrigin::EthereumTransaction(info)))), + call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => { + Some(call.dispatch(RuntimeOrigin::from(RawOrigin::EthereumTransaction(info)))) + }, _ => None, } } diff --git a/pallets/services/src/tests.rs b/pallets/services/src/tests.rs index 0a4796ca2..7a35b33c1 100644 --- a/pallets/services/src/tests.rs +++ b/pallets/services/src/tests.rs @@ -59,8 +59,9 @@ fn price_targets(kind: MachineKind) -> PriceTargets { storage_ssd: 100, storage_nvme: 150, }, - MachineKind::Small => - PriceTargets { cpu: 500, mem: 250, storage_hdd: 25, storage_ssd: 50, storage_nvme: 75 }, + MachineKind::Small => { + PriceTargets { cpu: 500, mem: 250, storage_hdd: 25, storage_ssd: 50, storage_nvme: 75 } + }, } } diff --git a/pallets/tangle-lst/src/lib.rs b/pallets/tangle-lst/src/lib.rs index 028e5c542..b439669f8 100644 --- a/pallets/tangle-lst/src/lib.rs +++ b/pallets/tangle-lst/src/lib.rs @@ -844,7 +844,7 @@ pub mod pallet { let pool_id = member.get_by_pool_id(current_era, pool_id); if pool_id.is_none() { - return Err(Error::::PoolNotFound.into()) + return Err(Error::::PoolNotFound.into()); } // checked above @@ -1506,7 +1506,7 @@ impl Pallet { let balance = T::U256ToBalance::convert; if current_balance.is_zero() || current_points.is_zero() || points.is_zero() { // There is nothing to unbond - return Zero::zero() + return Zero::zero(); } // Equivalent of (current_balance / current_points) * points @@ -1614,8 +1614,9 @@ impl Pallet { bonded_pool.ok_to_join()?; let (_points_issued, bonded) = match extra { - BondExtra::FreeBalance(amount) => - (bonded_pool.try_bond_funds(&member_account, amount, BondType::Later)?, amount), + BondExtra::FreeBalance(amount) => { + (bonded_pool.try_bond_funds(&member_account, amount, BondType::Later)?, amount) + }, }; bonded_pool.ok_to_be_open()?; @@ -1681,7 +1682,7 @@ impl Pallet { let min_balance = T::Currency::minimum_balance(); if pre_frozen_balance == min_balance { - return Err(Error::::NothingToAdjust.into()) + return Err(Error::::NothingToAdjust.into()); } // Update frozen amount with current ED. diff --git a/pallets/tangle-lst/src/types/bonded_pool.rs b/pallets/tangle-lst/src/types/bonded_pool.rs index bcddfb941..bca834932 100644 --- a/pallets/tangle-lst/src/types/bonded_pool.rs +++ b/pallets/tangle-lst/src/types/bonded_pool.rs @@ -160,8 +160,8 @@ impl BondedPool { } pub fn can_nominate(&self, who: &T::AccountId) -> bool { - self.is_root(who) || - self.roles.nominator.as_ref().map_or(false, |nominator| nominator == who) + self.is_root(who) + || self.roles.nominator.as_ref().map_or(false, |nominator| nominator == who) } pub fn can_kick(&self, who: &T::AccountId) -> bool { @@ -262,9 +262,9 @@ impl BondedPool { // any unbond must comply with the balance condition: ensure!( - is_full_unbond || - balance_after_unbond >= - if is_depositor { + is_full_unbond + || balance_after_unbond + >= if is_depositor { Pallet::::depositor_min_bond() } else { MinJoinBond::::get() @@ -296,7 +296,7 @@ impl BondedPool { }, (false, true) => { // the depositor can simply not be unbonded permissionlessly, period. - return Err(Error::::DoesNotHavePermission.into()) + return Err(Error::::DoesNotHavePermission.into()); }, }; diff --git a/pallets/tangle-lst/src/types/commission.rs b/pallets/tangle-lst/src/types/commission.rs index 01ecdd0e2..9fbee7550 100644 --- a/pallets/tangle-lst/src/types/commission.rs +++ b/pallets/tangle-lst/src/types/commission.rs @@ -55,13 +55,13 @@ impl Commission { // do not throttle if `to` is the same or a decrease in commission. if *to <= commission_as_percent { - return false + return false; } // Test for `max_increase` throttling. // // Throttled if the attempted increase in commission is greater than `max_increase`. if (*to).saturating_sub(commission_as_percent) > t.max_increase { - return true + return true; } // Test for `min_delay` throttling. @@ -84,7 +84,7 @@ impl Commission { blocks_surpassed < t.min_delay } }, - ) + ); } false } @@ -145,7 +145,7 @@ impl Commission { ); if let Some(old) = self.max.as_mut() { if new_max > *old { - return Err(Error::::MaxCommissionRestricted.into()) + return Err(Error::::MaxCommissionRestricted.into()); } *old = new_max; } else { diff --git a/precompiles/assets-erc20/src/lib.rs b/precompiles/assets-erc20/src/lib.rs index fae8c1d3a..91a074166 100644 --- a/precompiles/assets-erc20/src/lib.rs +++ b/precompiles/assets-erc20/src/lib.rs @@ -127,7 +127,7 @@ where fn discriminant(address: H160, gas: u64) -> DiscriminantResult> { let extra_cost = RuntimeHelper::::db_read_gas_cost(); if gas < extra_cost { - return DiscriminantResult::OutOfGas + return DiscriminantResult::OutOfGas; } let asset_id = match Runtime::address_to_asset_id(address) { @@ -254,8 +254,8 @@ where handle.record_db_read::(136)?; // If previous approval exists, we need to clean it - if pallet_assets::Pallet::::allowance(asset_id.clone(), &owner, &spender) != - 0u32.into() + if pallet_assets::Pallet::::allowance(asset_id.clone(), &owner, &spender) + != 0u32.into() { RuntimeHelper::::try_dispatch( handle, diff --git a/precompiles/assets-erc20/src/tests.rs b/precompiles/assets-erc20/src/tests.rs index 05d48cf8c..7152d4c41 100644 --- a/precompiles/assets-erc20/src/tests.rs +++ b/precompiles/assets-erc20/src/tests.rs @@ -441,8 +441,8 @@ fn transfer_not_enough_founds() { ForeignPCall::transfer { to: Address(Charlie.into()), value: 50.into() }, ) .execute_reverts(|output| { - from_utf8(output).unwrap().contains("Dispatched call failed with error: ") && - from_utf8(output).unwrap().contains("BalanceLow") + from_utf8(output).unwrap().contains("Dispatched call failed with error: ") + && from_utf8(output).unwrap().contains("BalanceLow") }); }); } diff --git a/precompiles/balances-erc20/src/lib.rs b/precompiles/balances-erc20/src/lib.rs index 8c05ca462..aa3a6b4f5 100644 --- a/precompiles/balances-erc20/src/lib.rs +++ b/precompiles/balances-erc20/src/lib.rs @@ -437,7 +437,7 @@ where fn deposit(handle: &mut impl PrecompileHandle) -> EvmResult { // Deposit only makes sense for the native currency. if !Metadata::is_native_currency() { - return Err(RevertReason::UnknownSelector.into()) + return Err(RevertReason::UnknownSelector.into()); } let caller: Runtime::AccountId = @@ -446,7 +446,7 @@ where let amount = Self::u256_to_amount(handle.context().apparent_value)?; if amount.into() == U256::from(0u32) { - return Err(revert("deposited amount must be non-zero")) + return Err(revert("deposited amount must be non-zero")); } handle.record_log_costs_manual(2, 32)?; @@ -476,7 +476,7 @@ where fn withdraw(handle: &mut impl PrecompileHandle, value: U256) -> EvmResult { // Withdraw only makes sense for the native currency. if !Metadata::is_native_currency() { - return Err(RevertReason::UnknownSelector.into()) + return Err(RevertReason::UnknownSelector.into()); } handle.record_log_costs_manual(2, 32)?; @@ -488,7 +488,7 @@ where }; if value > account_amount { - return Err(revert("Trying to withdraw more than owned")) + return Err(revert("Trying to withdraw more than owned")); } log2( @@ -548,7 +548,7 @@ where }, _ => { // Return err if account length is wrong - return Err(revert("Error while parsing staker's address")) + return Err(revert("Error while parsing staker's address")); }, }; diff --git a/precompiles/balances-erc20/src/tests.rs b/precompiles/balances-erc20/src/tests.rs index f62c1a4de..6e176e808 100644 --- a/precompiles/balances-erc20/src/tests.rs +++ b/precompiles/balances-erc20/src/tests.rs @@ -306,8 +306,8 @@ fn transfer_not_enough_funds() { PCall::transfer { to: Address(Bob.into()), value: 1400.into() }, ) .execute_reverts(|output| { - from_utf8(&output).unwrap().contains("Dispatched call failed with error: ") && - from_utf8(&output).unwrap().contains("FundsUnavailable") + from_utf8(&output).unwrap().contains("Dispatched call failed with error: ") + && from_utf8(&output).unwrap().contains("FundsUnavailable") }); }); } diff --git a/precompiles/batch/src/lib.rs b/precompiles/batch/src/lib.rs index 943216e35..d26ac2ba1 100644 --- a/precompiles/batch/src/lib.rs +++ b/precompiles/batch/src/lib.rs @@ -146,8 +146,9 @@ where let forwarded_gas = match (remaining_gas.checked_sub(log_cost), mode) { (Some(remaining), _) => remaining, - (None, Mode::BatchAll) => - return Err(PrecompileFailure::Error { exit_status: ExitError::OutOfGas }), + (None, Mode::BatchAll) => { + return Err(PrecompileFailure::Error { exit_status: ExitError::OutOfGas }) + }, (None, _) => return Ok(()), }; @@ -162,10 +163,11 @@ where log.record(handle)?; match mode { - Mode::BatchAll => + Mode::BatchAll => { return Err(PrecompileFailure::Error { exit_status: ExitError::OutOfGas, - }), + }) + }, Mode::BatchSomeUntilFailure => return Ok(()), Mode::BatchSome => continue, } @@ -182,10 +184,11 @@ where log.record(handle)?; match mode { - Mode::BatchAll => + Mode::BatchAll => { return Err(PrecompileFailure::Error { exit_status: ExitError::OutOfGas, - }), + }) + }, Mode::BatchSomeUntilFailure => return Ok(()), Mode::BatchSome => continue, } @@ -216,19 +219,23 @@ where // How to proceed match (mode, reason) { // _: Fatal is always fatal - (_, ExitReason::Fatal(exit_status)) => - return Err(PrecompileFailure::Fatal { exit_status }), + (_, ExitReason::Fatal(exit_status)) => { + return Err(PrecompileFailure::Fatal { exit_status }) + }, // BatchAll : Reverts and errors are immediatly forwarded. - (Mode::BatchAll, ExitReason::Revert(exit_status)) => - return Err(PrecompileFailure::Revert { exit_status, output }), - (Mode::BatchAll, ExitReason::Error(exit_status)) => - return Err(PrecompileFailure::Error { exit_status }), + (Mode::BatchAll, ExitReason::Revert(exit_status)) => { + return Err(PrecompileFailure::Revert { exit_status, output }) + }, + (Mode::BatchAll, ExitReason::Error(exit_status)) => { + return Err(PrecompileFailure::Error { exit_status }) + }, // BatchSomeUntilFailure : Reverts and errors prevent subsequent subcalls to // be executed but the precompile still succeed. - (Mode::BatchSomeUntilFailure, ExitReason::Revert(_) | ExitReason::Error(_)) => - return Ok(()), + (Mode::BatchSomeUntilFailure, ExitReason::Revert(_) | ExitReason::Error(_)) => { + return Ok(()) + }, // Success or ignored revert/error. (_, _) => (), @@ -263,8 +270,9 @@ where match mode { Mode::BatchSome => Self::batch_some { to, value, call_data, gas_limit }, - Mode::BatchSomeUntilFailure => - Self::batch_some_until_failure { to, value, call_data, gas_limit }, + Mode::BatchSomeUntilFailure => { + Self::batch_some_until_failure { to, value, call_data, gas_limit } + }, Mode::BatchAll => Self::batch_all { to, value, call_data, gas_limit }, } } diff --git a/precompiles/call-permit/src/lib.rs b/precompiles/call-permit/src/lib.rs index 0f5df485f..ea1906ba7 100644 --- a/precompiles/call-permit/src/lib.rs +++ b/precompiles/call-permit/src/lib.rs @@ -170,7 +170,7 @@ where .ok_or_else(|| revert("Call require too much gas (uint64 overflow)"))?; if total_cost > handle.remaining_gas() { - return Err(revert("Gaslimit is too low to dispatch provided call")) + return Err(revert("Gaslimit is too low to dispatch provided call")); } // VERIFY PERMIT @@ -216,8 +216,9 @@ where match reason { ExitReason::Error(exit_status) => Err(PrecompileFailure::Error { exit_status }), ExitReason::Fatal(exit_status) => Err(PrecompileFailure::Fatal { exit_status }), - ExitReason::Revert(_) => - Err(PrecompileFailure::Revert { exit_status: ExitRevert::Reverted, output }), + ExitReason::Revert(_) => { + Err(PrecompileFailure::Revert { exit_status: ExitRevert::Reverted, output }) + }, ExitReason::Succeed(_) => Ok(output.into()), } } diff --git a/precompiles/multi-asset-delegation/src/lib.rs b/precompiles/multi-asset-delegation/src/lib.rs index 21707fef7..b8d54921a 100644 --- a/precompiles/multi-asset-delegation/src/lib.rs +++ b/precompiles/multi-asset-delegation/src/lib.rs @@ -82,7 +82,7 @@ where }, _ => { // Return err if account length is wrong - return Err(revert("Error while parsing staker's address")) + return Err(revert("Error while parsing staker's address")); }, }; @@ -266,8 +266,9 @@ where let (deposit_asset, amount) = match (asset_id.as_u32(), token_address.0 .0) { (0, erc20_token) => (Asset::Erc20(erc20_token.into()), amount), (other_asset_id, zero_address) => (Asset::Custom(other_asset_id.into()), amount), - (_other_asset_id, _erc20_token) => - return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)), + (_other_asset_id, _erc20_token) => { + return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)) + }, }; // Get origin account. @@ -306,8 +307,9 @@ where let (deposit_asset, amount) = match (asset_id.as_u32(), token_address.0 .0) { (0, erc20_token) => (Asset::Erc20(erc20_token.into()), amount), (other_asset_id, zero_address) => (Asset::Custom(other_asset_id.into()), amount), - (_other_asset_id, _erc20_token) => - return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)), + (_other_asset_id, _erc20_token) => { + return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)) + }, }; let call = pallet_multi_asset_delegation::Call::::schedule_withdraw { @@ -349,8 +351,9 @@ where let (deposit_asset, amount) = match (asset_id.as_u32(), token_address.0 .0) { (0, erc20_token) => (Asset::Erc20(erc20_token.into()), amount), (other_asset_id, zero_address) => (Asset::Custom(other_asset_id.into()), amount), - (_other_asset_id, _erc20_token) => - return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)), + (_other_asset_id, _erc20_token) => { + return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)) + }, }; // Build call with origin. @@ -393,8 +396,9 @@ where let (deposit_asset, amount) = match (asset_id.as_u32(), token_address.0 .0) { (0, erc20_token) => (Asset::Erc20(erc20_token.into()), amount), (other_asset_id, zero_address) => (Asset::Custom(other_asset_id.into()), amount), - (_other_asset_id, _erc20_token) => - return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)), + (_other_asset_id, _erc20_token) => { + return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)) + }, }; // Build call with origin. @@ -431,8 +435,9 @@ where let (deposit_asset, amount) = match (asset_id.as_u32(), token_address.0 .0) { (0, erc20_token) => (Asset::Erc20(erc20_token.into()), amount), (other_asset_id, zero_address) => (Asset::Custom(other_asset_id.into()), amount), - (_other_asset_id, _erc20_token) => - return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)), + (_other_asset_id, _erc20_token) => { + return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)) + }, }; // Build call with origin. @@ -479,8 +484,9 @@ where let (deposit_asset, amount) = match (asset_id.as_u32(), token_address.0 .0) { (0, erc20_token) => (Asset::Erc20(erc20_token.into()), amount), (other_asset_id, zero_address) => (Asset::Custom(other_asset_id.into()), amount), - (_other_asset_id, _erc20_token) => - return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)), + (_other_asset_id, _erc20_token) => { + return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)) + }, }; // Build call with origin. diff --git a/precompiles/multi-asset-delegation/src/tests.rs b/precompiles/multi-asset-delegation/src/tests.rs index 2c7d65333..c6ed8d645 100644 --- a/precompiles/multi-asset-delegation/src/tests.rs +++ b/precompiles/multi-asset-delegation/src/tests.rs @@ -432,8 +432,8 @@ fn test_operator_go_offline_and_online() { .execute_returns(()); assert!( - MultiAssetDelegation::operator_info(operator_account).unwrap().status == - OperatorStatus::Inactive + MultiAssetDelegation::operator_info(operator_account).unwrap().status + == OperatorStatus::Inactive ); PrecompilesValue::get() @@ -441,8 +441,8 @@ fn test_operator_go_offline_and_online() { .execute_returns(()); assert!( - MultiAssetDelegation::operator_info(operator_account).unwrap().status == - OperatorStatus::Active + MultiAssetDelegation::operator_info(operator_account).unwrap().status + == OperatorStatus::Active ); assert_eq!(Balances::free_balance(operator_account), 20_000 - 10_000); diff --git a/precompiles/pallet-democracy/src/lib.rs b/precompiles/pallet-democracy/src/lib.rs index 7371074c2..ca29013f0 100644 --- a/precompiles/pallet-democracy/src/lib.rs +++ b/precompiles/pallet-democracy/src/lib.rs @@ -467,7 +467,7 @@ where if !<::Preimages as QueryPreimage>::is_requested( &proposal_hash, ) { - return Err(revert("not imminent preimage (preimage not requested)")) + return Err(revert("not imminent preimage (preimage not requested)")); }; let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); diff --git a/precompiles/pallet-democracy/src/tests.rs b/precompiles/pallet-democracy/src/tests.rs index 9fdb6a6fe..697eae1b4 100644 --- a/precompiles/pallet-democracy/src/tests.rs +++ b/precompiles/pallet-democracy/src/tests.rs @@ -220,8 +220,9 @@ fn lowest_unbaked_non_zero() { .dispatch(RuntimeOrigin::signed(Alice.into()))); let voting = match pallet_democracy::VotingOf::::get(AccountId::from(Alice)) { - Voting::Direct { votes, delegations, prior } => - (votes.into_inner(), delegations, prior), + Voting::Direct { votes, delegations, prior } => { + (votes.into_inner(), delegations, prior) + }, _ => panic!("Votes are not direct"), }; @@ -243,9 +244,9 @@ fn lowest_unbaked_non_zero() { // Run it through until it is baked roll_to( - ::VotingPeriod::get() + - ::LaunchPeriod::get() + - 1000, + ::VotingPeriod::get() + + ::LaunchPeriod::get() + + 1000, ); precompiles() @@ -558,8 +559,9 @@ fn standard_vote_aye_works() { ); let voting = match pallet_democracy::VotingOf::::get(AccountId::from(Alice)) { - Voting::Direct { votes, delegations, prior } => - (votes.into_inner(), delegations, prior), + Voting::Direct { votes, delegations, prior } => { + (votes.into_inner(), delegations, prior) + }, _ => panic!("Votes are not direct"), }; @@ -642,8 +644,9 @@ fn standard_vote_nay_conviction_works() { ); let voting = match pallet_democracy::VotingOf::::get(AccountId::from(Alice)) { - Voting::Direct { votes, delegations, prior } => - (votes.into_inner(), delegations, prior), + Voting::Direct { votes, delegations, prior } => { + (votes.into_inner(), delegations, prior) + }, _ => panic!("Votes are not direct"), }; @@ -721,8 +724,9 @@ fn remove_vote_works() { ); let voting = match pallet_democracy::VotingOf::::get(AccountId::from(Alice)) { - Voting::Direct { votes, delegations, prior } => - (votes.into_inner(), delegations, prior), + Voting::Direct { votes, delegations, prior } => { + (votes.into_inner(), delegations, prior) + }, _ => panic!("Votes are not direct"), }; @@ -793,8 +797,9 @@ fn delegate_works() { ); let alice_voting = match pallet_democracy::VotingOf::::get(AccountId::from(Alice)) { - Voting::Delegating { balance, target, conviction, delegations, prior } => - (balance, target, conviction, delegations, prior), + Voting::Delegating { balance, target, conviction, delegations, prior } => { + (balance, target, conviction, delegations, prior) + }, _ => panic!("Votes are not delegating"), }; @@ -807,8 +812,9 @@ fn delegate_works() { let bob_voting = match pallet_democracy::VotingOf::::get(AccountId::from(Bob)) { - Voting::Direct { votes, delegations, prior } => - (votes.into_inner(), delegations, prior), + Voting::Direct { votes, delegations, prior } => { + (votes.into_inner(), delegations, prior) + }, _ => panic!("Votes are not direct"), }; diff --git a/precompiles/precompile-registry/src/lib.rs b/precompiles/precompile-registry/src/lib.rs index 554e1cd6d..15e94ee07 100644 --- a/precompiles/precompile-registry/src/lib.rs +++ b/precompiles/precompile-registry/src/lib.rs @@ -69,8 +69,9 @@ where .is_active_precompile(address.0, handle.remaining_gas()) { IsPrecompileResult::Answer { is_precompile, .. } => Ok(is_precompile), - IsPrecompileResult::OutOfGas => - Err(PrecompileFailure::Error { exit_status: ExitError::OutOfGas }), + IsPrecompileResult::OutOfGas => { + Err(PrecompileFailure::Error { exit_status: ExitError::OutOfGas }) + }, } } @@ -85,7 +86,7 @@ where // Blake2_128(16) + AssetId(16) + AssetDetails((4 * AccountId(20)) + (3 * Balance(16)) + 15) handle.record_db_read::(175)?; if !is_precompile_or_fail::(address.0, handle.remaining_gas())? { - return Err(revert("provided address is not a precompile")) + return Err(revert("provided address is not a precompile")); } // pallet_evm::create_account read storage item pallet_evm::AccountCodes diff --git a/precompiles/proxy/src/lib.rs b/precompiles/proxy/src/lib.rs index 92e27d5ab..8cf818165 100644 --- a/precompiles/proxy/src/lib.rs +++ b/precompiles/proxy/src/lib.rs @@ -60,8 +60,9 @@ where fn is_allowed(_caller: H160, selector: Option) -> bool { match selector { None => false, - Some(selector) => - ProxyPrecompileCall::::is_proxy_selectors().contains(&selector), + Some(selector) => { + ProxyPrecompileCall::::is_proxy_selectors().contains(&selector) + }, } } @@ -91,11 +92,12 @@ where fn is_allowed(_caller: H160, selector: Option) -> bool { match selector { None => false, - Some(selector) => - ProxyPrecompileCall::::is_proxy_selectors().contains(&selector) || - ProxyPrecompileCall::::proxy_selectors().contains(&selector) || - ProxyPrecompileCall::::proxy_force_type_selectors() - .contains(&selector), + Some(selector) => { + ProxyPrecompileCall::::is_proxy_selectors().contains(&selector) + || ProxyPrecompileCall::::proxy_selectors().contains(&selector) + || ProxyPrecompileCall::::proxy_force_type_selectors() + .contains(&selector) + }, } } @@ -185,7 +187,7 @@ where .iter() .any(|pd| pd.delegate == delegate) { - return Err(revert("Cannot add more than one proxy")) + return Err(revert("Cannot add more than one proxy")); } let delegate: ::Source = @@ -341,7 +343,7 @@ where // Check that we only perform proxy calls on behalf of externally owned accounts let AddressType::EOA = precompile_set::get_address_type::(handle, real.into())? else { - return Err(revert("real address must be EOA")) + return Err(revert("real address must be EOA")); }; // Read proxy @@ -417,8 +419,9 @@ where // Return subcall result match reason { ExitReason::Fatal(exit_status) => Err(PrecompileFailure::Fatal { exit_status }), - ExitReason::Revert(exit_status) => - Err(PrecompileFailure::Revert { exit_status, output }), + ExitReason::Revert(exit_status) => { + Err(PrecompileFailure::Revert { exit_status, output }) + }, ExitReason::Error(exit_status) => Err(PrecompileFailure::Error { exit_status }), ExitReason::Succeed(_) => Ok(()), } diff --git a/precompiles/services/src/lib.rs b/precompiles/services/src/lib.rs index d9a3bea4d..7739a2409 100644 --- a/precompiles/services/src/lib.rs +++ b/precompiles/services/src/lib.rs @@ -206,18 +206,19 @@ where (0, zero_address) => (Asset::Custom(0u32.into()), value), (0, erc20_token) => { if value != Default::default() { - return Err(revert_custom_error(Self::VALUE_NOT_ZERO_FOR_ERC20)) + return Err(revert_custom_error(Self::VALUE_NOT_ZERO_FOR_ERC20)); } (Asset::Erc20(erc20_token.into()), amount) }, (other_asset_id, zero_address) => { if value != Default::default() { - return Err(revert_custom_error(Self::VALUE_NOT_ZERO_FOR_CUSTOM_ASSET)) + return Err(revert_custom_error(Self::VALUE_NOT_ZERO_FOR_CUSTOM_ASSET)); } (Asset::Custom(other_asset_id.into()), amount) }, - (_other_asset_id, _erc20_token) => - return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)), + (_other_asset_id, _erc20_token) => { + return Err(revert_custom_error(Self::PAYMENT_ASSET_SHOULD_BE_CUSTOM_OR_ERC20)) + }, }; let call = pallet_services::Call::::request { diff --git a/precompiles/services/src/mock.rs b/precompiles/services/src/mock.rs index 76677de79..7ab17b0b9 100644 --- a/precompiles/services/src/mock.rs +++ b/precompiles/services/src/mock.rs @@ -407,7 +407,7 @@ impl tangle_primitives::traits::MultiAssetDelegationInfo fn is_operator_active(operator: &AccountId) -> bool { if operator == &mock_pub_key(10) { - return false + return false; } true } diff --git a/precompiles/services/src/mock_evm.rs b/precompiles/services/src/mock_evm.rs index c3bdf41b8..cd0ccbcfe 100644 --- a/precompiles/services/src/mock_evm.rs +++ b/precompiles/services/src/mock_evm.rs @@ -151,7 +151,7 @@ impl OnChargeEVMTransaction for CustomEVMCurrencyAdapter { let pallet_services_address = pallet_services::Pallet::::address(); // Make pallet services account free to use if who == &pallet_services_address { - return Ok(None) + return Ok(None); } // fallback to the default implementation as OnChargeEVMTransaction< @@ -168,7 +168,7 @@ impl OnChargeEVMTransaction for CustomEVMCurrencyAdapter { let pallet_services_address = pallet_services::Pallet::::address(); // Make pallet services account free to use if who == &pallet_services_address { - return already_withdrawn + return already_withdrawn; } // fallback to the default implementation as OnChargeEVMTransaction< @@ -254,8 +254,9 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { len: usize, ) -> Option> { match self { - RuntimeCall::Ethereum(call) => - call.pre_dispatch_self_contained(info, dispatch_info, len), + RuntimeCall::Ethereum(call) => { + call.pre_dispatch_self_contained(info, dispatch_info, len) + }, _ => None, } } @@ -265,8 +266,9 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { info: Self::SignedInfo, ) -> Option>> { match self { - call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => - Some(call.dispatch(RuntimeOrigin::from(RawOrigin::EthereumTransaction(info)))), + call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => { + Some(call.dispatch(RuntimeOrigin::from(RawOrigin::EthereumTransaction(info)))) + }, _ => None, } } diff --git a/precompiles/services/src/tests.rs b/precompiles/services/src/tests.rs index 0cde095d0..43a0aa017 100644 --- a/precompiles/services/src/tests.rs +++ b/precompiles/services/src/tests.rs @@ -45,8 +45,9 @@ fn price_targets(kind: MachineKind) -> PriceTargets { storage_ssd: 100, storage_nvme: 150, }, - MachineKind::Small => - PriceTargets { cpu: 500, mem: 250, storage_hdd: 25, storage_ssd: 50, storage_nvme: 75 }, + MachineKind::Small => { + PriceTargets { cpu: 500, mem: 250, storage_hdd: 25, storage_ssd: 50, storage_nvme: 75 } + }, } } diff --git a/precompiles/staking/src/lib.rs b/precompiles/staking/src/lib.rs index 1ab81ec64..aa08dbe3e 100644 --- a/precompiles/staking/src/lib.rs +++ b/precompiles/staking/src/lib.rs @@ -78,7 +78,7 @@ where }, _ => { // Return err if account length is wrong - return Err(revert("Error while parsing staker's address")) + return Err(revert("Error while parsing staker's address")); }, }; diff --git a/precompiles/tangle-lst/src/lib.rs b/precompiles/tangle-lst/src/lib.rs index cabd6dd67..b49fdc010 100644 --- a/precompiles/tangle-lst/src/lib.rs +++ b/precompiles/tangle-lst/src/lib.rs @@ -344,7 +344,7 @@ where }, _ => { // Return err if account length is wrong - return Err(revert("Error while parsing staker's address")) + return Err(revert("Error while parsing staker's address")); }, }; diff --git a/precompiles/verify-bls381-signature/src/lib.rs b/precompiles/verify-bls381-signature/src/lib.rs index 136957780..08e14fd2e 100644 --- a/precompiles/verify-bls381-signature/src/lib.rs +++ b/precompiles/verify-bls381-signature/src/lib.rs @@ -55,14 +55,14 @@ impl Bls381Precompile { { p_key } else { - return Ok(false) + return Ok(false); }; let signature = if let Ok(sig) = snowbridge_milagro_bls::Signature::from_bytes(&signature_bytes) { sig } else { - return Ok(false) + return Ok(false); }; let is_confirmed = signature.verify(&message, &public_key); diff --git a/precompiles/verify-schnorr-signatures/src/lib.rs b/precompiles/verify-schnorr-signatures/src/lib.rs index 242463259..19b5636b7 100644 --- a/precompiles/verify-schnorr-signatures/src/lib.rs +++ b/precompiles/verify-schnorr-signatures/src/lib.rs @@ -55,7 +55,7 @@ pub fn to_slice_32(val: &[u8]) -> Option<[u8; 32]> { let mut key = [0u8; 32]; key[..32].copy_from_slice(val); - return Some(key) + return Some(key); } None } diff --git a/precompiles/vesting/src/lib.rs b/precompiles/vesting/src/lib.rs index 173396a5c..d4c48406d 100644 --- a/precompiles/vesting/src/lib.rs +++ b/precompiles/vesting/src/lib.rs @@ -79,7 +79,7 @@ where }, _ => { // Return err if account length is wrong - return Err(revert("Error while parsing staker's address")) + return Err(revert("Error while parsing staker's address")); }, }; @@ -153,7 +153,7 @@ where match pallet_vesting::Vesting::::get(origin.clone()) { Some(schedules) => { if index >= schedules.len() as u8 { - return Err(revert("Invalid vesting schedule index")) + return Err(revert("Invalid vesting schedule index")); } // Make the call to transfer the vested funds to the `target` account. let target = Self::convert_to_account_id(target)?; diff --git a/primitives/rpc/evm-tracing-events/src/evm.rs b/primitives/rpc/evm-tracing-events/src/evm.rs index 688861fdd..2b997eaeb 100644 --- a/primitives/rpc/evm-tracing-events/src/evm.rs +++ b/primitives/rpc/evm-tracing-events/src/evm.rs @@ -61,8 +61,9 @@ impl From for CreateScheme { fn from(i: evm_runtime::CreateScheme) -> Self { match i { evm_runtime::CreateScheme::Legacy { caller } => Self::Legacy { caller }, - evm_runtime::CreateScheme::Create2 { caller, code_hash, salt } => - Self::Create2 { caller, code_hash, salt }, + evm_runtime::CreateScheme::Create2 { caller, code_hash, salt } => { + Self::Create2 { caller, code_hash, salt } + }, evm_runtime::CreateScheme::Fixed(address) => Self::Fixed(address), } } @@ -166,12 +167,15 @@ impl<'a> From> for EvmEvent { init_code: init_code.to_vec(), target_gas, }, - evm::tracing::Event::Suicide { address, target, balance } => - Self::Suicide { address, target, balance }, - evm::tracing::Event::Exit { reason, return_value } => - Self::Exit { reason: reason.clone(), return_value: return_value.to_vec() }, - evm::tracing::Event::TransactCall { caller, address, value, data, gas_limit } => - Self::TransactCall { caller, address, value, data: data.to_vec(), gas_limit }, + evm::tracing::Event::Suicide { address, target, balance } => { + Self::Suicide { address, target, balance } + }, + evm::tracing::Event::Exit { reason, return_value } => { + Self::Exit { reason: reason.clone(), return_value: return_value.to_vec() } + }, + evm::tracing::Event::TransactCall { caller, address, value, data, gas_limit } => { + Self::TransactCall { caller, address, value, data: data.to_vec(), gas_limit } + }, evm::tracing::Event::TransactCreate { caller, value, diff --git a/primitives/rpc/evm-tracing-events/src/gasometer.rs b/primitives/rpc/evm-tracing-events/src/gasometer.rs index d1fbb453e..85d8352ba 100644 --- a/primitives/rpc/evm-tracing-events/src/gasometer.rs +++ b/primitives/rpc/evm-tracing-events/src/gasometer.rs @@ -59,12 +59,15 @@ pub enum GasometerEvent { impl From for GasometerEvent { fn from(i: evm_gasometer::tracing::Event) -> Self { match i { - evm_gasometer::tracing::Event::RecordCost { cost, snapshot } => - Self::RecordCost { cost, snapshot: snapshot.into() }, - evm_gasometer::tracing::Event::RecordRefund { refund, snapshot } => - Self::RecordRefund { refund, snapshot: snapshot.into() }, - evm_gasometer::tracing::Event::RecordStipend { stipend, snapshot } => - Self::RecordStipend { stipend, snapshot: snapshot.into() }, + evm_gasometer::tracing::Event::RecordCost { cost, snapshot } => { + Self::RecordCost { cost, snapshot: snapshot.into() } + }, + evm_gasometer::tracing::Event::RecordRefund { refund, snapshot } => { + Self::RecordRefund { refund, snapshot: snapshot.into() } + }, + evm_gasometer::tracing::Event::RecordStipend { stipend, snapshot } => { + Self::RecordStipend { stipend, snapshot: snapshot.into() } + }, evm_gasometer::tracing::Event::RecordDynamicCost { gas_cost, memory_gas, @@ -76,8 +79,9 @@ impl From for GasometerEvent { gas_refund, snapshot: snapshot.into(), }, - evm_gasometer::tracing::Event::RecordTransaction { cost, snapshot } => - Self::RecordTransaction { cost, snapshot: snapshot.into() }, + evm_gasometer::tracing::Event::RecordTransaction { cost, snapshot } => { + Self::RecordTransaction { cost, snapshot: snapshot.into() } + }, } } } diff --git a/primitives/rpc/evm-tracing-events/src/runtime.rs b/primitives/rpc/evm-tracing-events/src/runtime.rs index ad738f739..089932d55 100644 --- a/primitives/rpc/evm-tracing-events/src/runtime.rs +++ b/primitives/rpc/evm-tracing-events/src/runtime.rs @@ -92,7 +92,7 @@ impl RuntimeEvent { filter: crate::StepEventFilter, ) -> Self { match i { - evm_runtime::tracing::Event::Step { context, opcode, position, stack, memory } => + evm_runtime::tracing::Event::Step { context, opcode, position, stack, memory } => { Self::Step { context: context.clone().into(), opcode: opcodes_string(opcode), @@ -102,7 +102,8 @@ impl RuntimeEvent { }, stack: if filter.enable_stack { Some(stack.into()) } else { None }, memory: if filter.enable_memory { Some(memory.into()) } else { None }, - }, + } + }, evm_runtime::tracing::Event::StepResult { result, return_value } => Self::StepResult { result: match result { Ok(_) => Ok(()), @@ -113,10 +114,12 @@ impl RuntimeEvent { }, return_value: return_value.to_vec(), }, - evm_runtime::tracing::Event::SLoad { address, index, value } => - Self::SLoad { address, index, value }, - evm_runtime::tracing::Event::SStore { address, index, value } => - Self::SStore { address, index, value }, + evm_runtime::tracing::Event::SLoad { address, index, value } => { + Self::SLoad { address, index, value } + }, + evm_runtime::tracing::Event::SStore { address, index, value } => { + Self::SStore { address, index, value } + }, } } } diff --git a/primitives/src/chain_identifier.rs b/primitives/src/chain_identifier.rs index d916c2a2a..72155a8a7 100644 --- a/primitives/src/chain_identifier.rs +++ b/primitives/src/chain_identifier.rs @@ -65,14 +65,14 @@ impl TypedChainId { #[must_use] pub const fn underlying_chain_id(&self) -> u32 { match self { - TypedChainId::Evm(id) | - TypedChainId::Substrate(id) | - TypedChainId::PolkadotParachain(id) | - TypedChainId::KusamaParachain(id) | - TypedChainId::RococoParachain(id) | - TypedChainId::Cosmos(id) | - TypedChainId::Solana(id) | - TypedChainId::Ink(id) => *id, + TypedChainId::Evm(id) + | TypedChainId::Substrate(id) + | TypedChainId::PolkadotParachain(id) + | TypedChainId::KusamaParachain(id) + | TypedChainId::RococoParachain(id) + | TypedChainId::Cosmos(id) + | TypedChainId::Solana(id) + | TypedChainId::Ink(id) => *id, Self::None => 0, } } diff --git a/primitives/src/services/field.rs b/primitives/src/services/field.rs index 8fd27a350..c03869aaf 100644 --- a/primitives/src/services/field.rs +++ b/primitives/src/services/field.rs @@ -172,13 +172,13 @@ impl PartialEq for Field { (Self::AccountId(l0), Self::AccountId(r0)) => l0 == r0, (Self::Struct(l_name, l_fields), Self::Struct(r_name, r_fields)) => { if l_name != r_name || l_fields.len() != r_fields.len() { - return false + return false; } for ((l_field_name, l_field_value), (r_field_name, r_field_value)) in l_fields.iter().zip(r_fields.iter()) { if l_field_name != r_field_name || l_field_value != r_field_value { - return false + return false; } } true @@ -307,16 +307,18 @@ impl PartialEq for Field { (Self::Int64(_), FieldType::Int64) => true, (Self::String(_), FieldType::String) => true, (Self::Bytes(_), FieldType::Bytes) => true, - (Self::Array(a), FieldType::Array(len, b)) => - a.len() == *len as usize && a.iter().all(|f| f.eq(b.as_ref())), + (Self::Array(a), FieldType::Array(len, b)) => { + a.len() == *len as usize && a.iter().all(|f| f.eq(b.as_ref())) + }, (Self::List(a), FieldType::List(b)) => a.iter().all(|f| f.eq(b.as_ref())), (Self::AccountId(_), FieldType::AccountId) => true, - (Self::Struct(_, fields_a), FieldType::Struct(_, fields_b)) => - fields_a.into_iter().len() == fields_b.into_iter().len() && - fields_a + (Self::Struct(_, fields_a), FieldType::Struct(_, fields_b)) => { + fields_a.into_iter().len() == fields_b.into_iter().len() + && fields_a .into_iter() .zip(fields_b) - .all(|((_, v_a), (_, v_b))| v_a.as_ref().eq(v_b)), + .all(|((_, v_a), (_, v_b))| v_a.as_ref().eq(v_b)) + }, _ => false, } } @@ -420,7 +422,7 @@ impl Field { /// Encode the fields to ethabi bytes. pub fn encode_to_ethabi(fields: &[Self]) -> ethabi::Bytes { if fields.is_empty() { - return Default::default() + return Default::default(); } let tokens: Vec = fields.iter().map(Self::to_ethabi_token).collect(); ethabi::encode(&tokens) diff --git a/primitives/src/services/mod.rs b/primitives/src/services/mod.rs index 80c9e9fcf..ee4138bf3 100644 --- a/primitives/src/services/mod.rs +++ b/primitives/src/services/mod.rs @@ -148,7 +148,7 @@ pub fn type_checker( return Err(TypeCheckError::NotEnoughArguments { expected: params.len() as u8, actual: args.len() as u8, - }) + }); } for i in 0..args.len() { let arg = &args[i]; @@ -158,7 +158,7 @@ pub fn type_checker( index: i as u8, expected: expected.clone(), actual: arg.clone().into(), - }) + }); } } Ok(()) @@ -472,10 +472,12 @@ impl ServiceBlueprint { }, // Master Manager Revision match self.master_manager_revision { - MasterBlueprintServiceManagerRevision::Latest => - ethabi::Token::Uint(ethabi::Uint::MAX), - MasterBlueprintServiceManagerRevision::Specific(rev) => - ethabi::Token::Uint(rev.into()), + MasterBlueprintServiceManagerRevision::Latest => { + ethabi::Token::Uint(ethabi::Uint::MAX) + }, + MasterBlueprintServiceManagerRevision::Specific(rev) => { + ethabi::Token::Uint(rev.into()) + }, }, // Gadget ? ]) diff --git a/primitives/src/verifier/circom.rs b/primitives/src/verifier/circom.rs index 34251912b..4dbf7303a 100644 --- a/primitives/src/verifier/circom.rs +++ b/primitives/src/verifier/circom.rs @@ -51,28 +51,28 @@ impl super::InstanceVerifier for CircomVerifierGroth16Bn254 { Ok(v) => v, Err(e) => { log::error!("Failed to convert public input bytes to field elements: {e:?}",); - return Err(e) + return Err(e); }, }; let vk = match ArkVerifyingKey::deserialize_compressed(vk_bytes) { Ok(v) => v, Err(e) => { log::error!("Failed to deserialize verifying key: {e:?}"); - return Err(e.into()) + return Err(e.into()); }, }; let proof = match Proof::decode(proof_bytes).and_then(|v| v.try_into()) { Ok(v) => v, Err(e) => { log::error!("Failed to deserialize proof: {e:?}"); - return Err(e) + return Err(e); }, }; let res = match verify_groth16(&vk, &public_input_field_elts, &proof) { Ok(v) => v, Err(e) => { log::error!("Failed to verify proof: {e:?}"); - return Err(e) + return Err(e); }, }; @@ -246,7 +246,7 @@ fn point_to_u256(point: F) -> Result { let point = point.into_bigint(); let point_bytes = point.to_bytes_be(); if point_bytes.len() != 32 { - return Err(CircomError::InvalidProofBytes.into()) + return Err(CircomError::InvalidProofBytes.into()); } Ok(U256::from(&point_bytes[..])) } diff --git a/runtime/mainnet/src/filters.rs b/runtime/mainnet/src/filters.rs index de74c9ff8..1307096ed 100644 --- a/runtime/mainnet/src/filters.rs +++ b/runtime/mainnet/src/filters.rs @@ -22,14 +22,14 @@ impl Contains for MainnetCallFilter { let is_core_call = matches!(call, RuntimeCall::System(_) | RuntimeCall::Timestamp(_)); if is_core_call { // always allow core call - return true + return true; } let is_allowed_to_dispatch = as Contains>::contains(call); if !is_allowed_to_dispatch { // tx is paused and not allowed to dispatch. - return false + return false; } true diff --git a/runtime/mainnet/src/frontier_evm.rs b/runtime/mainnet/src/frontier_evm.rs index 39b31cd1a..8f135bae7 100644 --- a/runtime/mainnet/src/frontier_evm.rs +++ b/runtime/mainnet/src/frontier_evm.rs @@ -61,7 +61,7 @@ impl> FindAuthor for FindAuthorTruncated { { if let Some(author_index) = F::find_author(digests) { let authority_id = Babe::authorities()[author_index as usize].clone(); - return Some(H160::from_slice(&authority_id.0.to_raw_vec()[4..24])) + return Some(H160::from_slice(&authority_id.0.to_raw_vec()[4..24])); } None } @@ -119,20 +119,21 @@ impl pallet_evm_precompile_proxy::EvmProxyCallFilter for ProxyType { ) -> precompile_utils::EvmResult { Ok(match self { ProxyType::Any => true, - ProxyType::Governance => - call.value == U256::zero() && - matches!( + ProxyType::Governance => { + call.value == U256::zero() + && matches!( PrecompileName::from_address(call.to.0), Some(ref precompile) if is_governance_precompile(precompile) - ), + ) + }, // The proxy precompile does not contain method cancel_proxy ProxyType::CancelProxy => false, ProxyType::Balances => { // Allow only "simple" accounts as recipient (no code nor precompile). // Note: Checking the presence of the code is not enough because some precompiles // have no code. - !recipient_has_code && - !precompile_utils::precompile_set::is_precompile_or_fail::( + !recipient_has_code + && !precompile_utils::precompile_set::is_precompile_or_fail::( call.to.0, gas, )? }, diff --git a/runtime/mainnet/src/lib.rs b/runtime/mainnet/src/lib.rs index dad95a925..5db6de9bb 100644 --- a/runtime/mainnet/src/lib.rs +++ b/runtime/mainnet/src/lib.rs @@ -656,8 +656,8 @@ impl Get> for OffchainRandomBalancing { max => { let seed = sp_io::offchain::random_seed(); let random = ::decode(&mut TrailingZeroInput::new(&seed)) - .expect("input is padded with zeroes; qed") % - max.saturating_add(1); + .expect("input is padded with zeroes; qed") + % max.saturating_add(1); random as usize }, }; @@ -1148,15 +1148,15 @@ impl InstanceFilter for ProxyType { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - RuntimeCall::Balances(..) | - RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) + RuntimeCall::Balances(..) + | RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) ), ProxyType::Governance => matches!( c, - RuntimeCall::Democracy(..) | - RuntimeCall::Council(..) | - RuntimeCall::Elections(..) | - RuntimeCall::Treasury(..) + RuntimeCall::Democracy(..) + | RuntimeCall::Council(..) + | RuntimeCall::Elections(..) + | RuntimeCall::Treasury(..) ), ProxyType::Staking => { matches!(c, RuntimeCall::Staking(..)) @@ -1468,8 +1468,9 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { len: usize, ) -> Option> { match self { - RuntimeCall::Ethereum(call) => - call.pre_dispatch_self_contained(info, dispatch_info, len), + RuntimeCall::Ethereum(call) => { + call.pre_dispatch_self_contained(info, dispatch_info, len) + }, _ => None, } } @@ -1479,10 +1480,11 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { info: Self::SignedInfo, ) -> Option>> { match self { - call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => + call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => { Some(call.dispatch(RuntimeOrigin::from( pallet_ethereum::RawOrigin::EthereumTransaction(info), - ))), + ))) + }, _ => None, } } diff --git a/runtime/testnet/src/filters.rs b/runtime/testnet/src/filters.rs index 65e021b6a..d46f09140 100644 --- a/runtime/testnet/src/filters.rs +++ b/runtime/testnet/src/filters.rs @@ -22,14 +22,14 @@ impl Contains for TestnetCallFilter { let is_core_call = matches!(call, RuntimeCall::System(_) | RuntimeCall::Timestamp(_)); if is_core_call { // always allow core call - return true + return true; } let is_allowed_to_dispatch = as Contains>::contains(call); if !is_allowed_to_dispatch { // tx is paused and not allowed to dispatch. - return false + return false; } true diff --git a/runtime/testnet/src/frontier_evm.rs b/runtime/testnet/src/frontier_evm.rs index a11fe1f74..23fb1f1a3 100644 --- a/runtime/testnet/src/frontier_evm.rs +++ b/runtime/testnet/src/frontier_evm.rs @@ -64,7 +64,7 @@ impl> FindAuthor for FindAuthorTruncated { { if let Some(author_index) = F::find_author(digests) { let authority_id = Babe::authorities()[author_index as usize].clone(); - return Some(H160::from_slice(&authority_id.0.to_raw_vec()[4..24])) + return Some(H160::from_slice(&authority_id.0.to_raw_vec()[4..24])); } None } @@ -99,7 +99,7 @@ impl OnChargeEVMTransaction for CustomEVMCurrencyAdapter { let pallet_services_address = pallet_services::Pallet::::address(); // Make pallet services account free to use if who == &pallet_services_address { - return Ok(None) + return Ok(None); } // fallback to the default implementation > as OnChargeEVMTransaction< @@ -116,7 +116,7 @@ impl OnChargeEVMTransaction for CustomEVMCurrencyAdapter { let pallet_services_address = pallet_services::Pallet::::address(); // Make pallet services account free to use if who == &pallet_services_address { - return already_withdrawn + return already_withdrawn; } // fallback to the default implementation > as OnChargeEVMTransaction< diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index 1a0974b5f..7fb9e15bf 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -663,8 +663,8 @@ impl Get> for OffchainRandomBalancing { max => { let seed = sp_io::offchain::random_seed(); let random = ::decode(&mut TrailingZeroInput::new(&seed)) - .expect("input is padded with zeroes; qed") % - max.saturating_add(1); + .expect("input is padded with zeroes; qed") + % max.saturating_add(1); random as usize }, }; @@ -1146,15 +1146,15 @@ impl InstanceFilter for ProxyType { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - RuntimeCall::Balances(..) | - RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) + RuntimeCall::Balances(..) + | RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) ), ProxyType::Governance => matches!( c, - RuntimeCall::Democracy(..) | - RuntimeCall::Council(..) | - RuntimeCall::Elections(..) | - RuntimeCall::Treasury(..) + RuntimeCall::Democracy(..) + | RuntimeCall::Council(..) + | RuntimeCall::Elections(..) + | RuntimeCall::Treasury(..) ), ProxyType::Staking => { matches!(c, RuntimeCall::Staking(..)) @@ -1387,8 +1387,9 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { len: usize, ) -> Option> { match self { - RuntimeCall::Ethereum(call) => - call.pre_dispatch_self_contained(info, dispatch_info, len), + RuntimeCall::Ethereum(call) => { + call.pre_dispatch_self_contained(info, dispatch_info, len) + }, _ => None, } } @@ -1398,10 +1399,11 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { info: Self::SignedInfo, ) -> Option>> { match self { - call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => + call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => { Some(call.dispatch(RuntimeOrigin::from( pallet_ethereum::RawOrigin::EthereumTransaction(info), - ))), + ))) + }, _ => None, } }