From 03fdb1eb19237323ebc25f7ae6ec574d58d26da9 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Mon, 5 Dec 2022 15:00:02 +0200 Subject: [PATCH 1/2] Use finalized_hash isntead of best_hash in pull_ledger_diff Signed-off-by: Georgi Zlatarev --- pallets/manta-pay/src/rpc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/manta-pay/src/rpc.rs b/pallets/manta-pay/src/rpc.rs index a3d7b97fd..eb5ea90c7 100644 --- a/pallets/manta-pay/src/rpc.rs +++ b/pallets/manta-pay/src/rpc.rs @@ -80,7 +80,7 @@ where max_senders: u64, ) -> RpcResult { let api = self.client.runtime_api(); - let at = BlockId::hash(self.client.info().best_hash); + let at = BlockId::hash(self.client.info().finalized_hash); api.pull_ledger_diff(&at, checkpoint.into(), max_receivers, max_senders) .map_err(|err| { CallError::Custom(ErrorObject::owned( From e867a10ee9f760c9fc6c4e4d5fa68e6adddde0ec Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Mon, 5 Dec 2022 15:39:31 +0200 Subject: [PATCH 2/2] Fix clippy Signed-off-by: Georgi Zlatarev --- node/src/command.rs | 8 ++++---- pallets/collator-selection/src/lib.rs | 2 +- pallets/manta-pay/src/bin/precompute_coins.rs | 5 ++--- pallets/manta-pay/src/rpc.rs | 2 +- pallets/manta-pay/src/test/payment.rs | 2 +- primitives/session-keys/src/util.rs | 2 +- runtime/calamari/src/fee.rs | 14 ++++++-------- .../tests/integrations_mock/integration_tests.rs | 2 +- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/node/src/command.rs b/node/src/command.rs index 00c50cfa0..77b4f9ffe 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -325,7 +325,7 @@ pub fn run_with(cli: Cli) -> Result { &polkadot_cli, config.tokio_handle.clone(), ) - .map_err(|err| format!("Relay chain argument error: {}", err))?; + .map_err(|err| format!("Relay chain argument error: {err}"))?; cmd.run(config, polkadot_config) }) @@ -397,7 +397,7 @@ pub fn run_with(cli: Cli) -> Result { .map(|cfg| &cfg.registry); let task_manager = sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry) - .map_err(|e| format!("Error: {:?}", e))?; + .map_err(|e| format!("Error: {e:?}"))?; if runner.config().chain_spec.is_manta() { runner.async_run(|config| { @@ -453,13 +453,13 @@ pub fn run_with(cli: Cli) -> Result { let block: crate::service::Block = generate_genesis_block(&*config.chain_spec, state_version) - .map_err(|e| format!("{:?}", e))?; + .map_err(|e| format!("{e:?}"))?; let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode())); let tokio_handle = config.tokio_handle.clone(); let polkadot_config = SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle) - .map_err(|err| format!("Relay chain argument error: {}", err))?; + .map_err(|err| format!("Relay chain argument error: {err}"))?; info!("Parachain id: {:?}", id); info!("Parachain Account: {}", parachain_account); diff --git a/pallets/collator-selection/src/lib.rs b/pallets/collator-selection/src/lib.rs index ca367bbdb..ac4f50890 100644 --- a/pallets/collator-selection/src/lib.rs +++ b/pallets/collator-selection/src/lib.rs @@ -639,7 +639,7 @@ pub mod pallet { }) .unwrap_or_else(|why| { log::warn!("Failed to remove candidate due to underperformance {:?}", why); - debug_assert!(false, "failed to remove candidate {:?}", why); + debug_assert!(false, "failed to remove candidate {why:?}"); }); } } diff --git a/pallets/manta-pay/src/bin/precompute_coins.rs b/pallets/manta-pay/src/bin/precompute_coins.rs index 303aa1f95..50a30f8f0 100644 --- a/pallets/manta-pay/src/bin/precompute_coins.rs +++ b/pallets/manta-pay/src/bin/precompute_coins.rs @@ -167,8 +167,7 @@ fn main() -> Result<()> { .unwrap_or(env::current_dir()?.join("precomputed_coins.rs")); assert!( !target_file.exists(), - "Specify a file to place the generated files: {:?}.", - target_file, + "Specify a file to place the generated files: {target_file:?}.", ); fs::create_dir_all( target_file @@ -177,7 +176,7 @@ fn main() -> Result<()> { )?; let directory = tempfile::tempdir().expect("Unable to generate temporary test directory."); - println!("[INFO] Temporary Directory: {:?}", directory); + println!("[INFO] Temporary Directory: {directory:?}"); let mut rng = ChaCha20Rng::from_seed([0; 32]); let (proving_context, _, parameters, utxo_accumulator_model) = diff --git a/pallets/manta-pay/src/rpc.rs b/pallets/manta-pay/src/rpc.rs index eb5ea90c7..82140272c 100644 --- a/pallets/manta-pay/src/rpc.rs +++ b/pallets/manta-pay/src/rpc.rs @@ -86,7 +86,7 @@ where CallError::Custom(ErrorObject::owned( PULL_LEDGER_DIFF_ERROR, "Unable to compute state diff for pull", - Some(format!("{:?}", err)), + Some(format!("{err:?}")), )) .into() }) diff --git a/pallets/manta-pay/src/test/payment.rs b/pallets/manta-pay/src/test/payment.rs index f24005ec5..c359bfe75 100644 --- a/pallets/manta-pay/src/test/payment.rs +++ b/pallets/manta-pay/src/test/payment.rs @@ -166,7 +166,7 @@ where let mut utxo_accumulator = UtxoAccumulator::new(UTXO_ACCUMULATOR_MODEL.clone()); let mut asset_id = 8u128; for i in 0..total { - println!("Current: {:?}", i); + println!("Current: {i:?}"); let mint0 = PalletTransferPost::from(test::payment::to_private::prove_full( &PROVING_CONTEXT.to_private, &PARAMETERS, diff --git a/primitives/session-keys/src/util.rs b/primitives/session-keys/src/util.rs index 639432b37..1992ab478 100644 --- a/primitives/session-keys/src/util.rs +++ b/primitives/session-keys/src/util.rs @@ -32,7 +32,7 @@ pub fn unchecked_public_key(seed: &str) -> PublicKey where T: CryptoType, { - T::Pair::from_string(&format!("//{}", seed), None) + T::Pair::from_string(&format!("//{seed}"), None) .expect("The validity of the seed is unchecked.") .public() } diff --git a/runtime/calamari/src/fee.rs b/runtime/calamari/src/fee.rs index 7150cc2db..3dec0f172 100644 --- a/runtime/calamari/src/fee.rs +++ b/runtime/calamari/src/fee.rs @@ -140,7 +140,7 @@ mod multiplier_tests { // Configure the target cost depending on the current state of the network. let target_daily_congestion_cost_usd = 250000; let kma_price = fetch_kma_price().unwrap(); - println!("KMA/USD price as read from CoinGecko = {}", kma_price); + println!("KMA/USD price as read from CoinGecko = {kma_price}"); let target_daily_congestion_cost_kma = (target_daily_congestion_cost_usd as f32 * kma_price * KMA as f32) as u128; @@ -181,8 +181,8 @@ mod multiplier_tests { let next = runtime_multiplier_update(fee_adjustment); // if no change or less, panic. This should never happen in this case. if fee_adjustment >= next { - println!("final fee_adjustment: {}", fee_adjustment); - println!("final next: {}", next); + println!("final fee_adjustment: {fee_adjustment}"); + println!("final next: {next}"); panic!("The fee should ever increase"); } fee_adjustment = next; @@ -225,9 +225,7 @@ mod multiplier_tests { let next = SlowAdjustingFeeUpdate::::convert(minimum_multiplier); assert!( next > minimum_multiplier, - "{:?} !>= {:?}", - next, - minimum_multiplier + "{next:?} !>= {minimum_multiplier:?}", ); }) } @@ -249,11 +247,11 @@ mod multiplier_tests { run_with_system_weight(block_weight, || { let next = SlowAdjustingFeeUpdate::::convert(multiplier); // ensure that it is growing as well. - assert!(next > multiplier, "{:?} !>= {:?}", next, multiplier); + assert!(next > multiplier, "{next:?} !>= {multiplier:?}"); multiplier = next; }); blocks += 1; - println!("block = {} multiplier {:?}", blocks, multiplier); + println!("block = {blocks} multiplier {multiplier:?}"); } } } diff --git a/runtime/calamari/tests/integrations_mock/integration_tests.rs b/runtime/calamari/tests/integrations_mock/integration_tests.rs index 92d0ed0e5..bf33c59da 100644 --- a/runtime/calamari/tests/integrations_mock/integration_tests.rs +++ b/runtime/calamari/tests/integrations_mock/integration_tests.rs @@ -538,7 +538,7 @@ fn reward_fees_to_block_author_and_treasury() { ); let author_received_reward = Balances::free_balance(alice) - INITIAL_BALANCE; - println!("The rewarded_amount is: {:?}", author_received_reward); + println!("The rewarded_amount is: {author_received_reward:?}"); // Fees split: 40% burned, 40% to treasury, 10% to author. let author_percent = Percent::from_percent(FEES_PERCENTAGE_TO_AUTHOR);