From 895f7dbb08f9d4d6eb54a14eac59e06815ba7759 Mon Sep 17 00:00:00 2001 From: nahuseyoum Date: Tue, 30 Apr 2024 16:15:00 +0100 Subject: [PATCH 1/2] SYS-3955 Improve length comparison part 2 --- node/avn-lower-rpc/src/lib.rs | 2 +- node/avn-service/src/lib.rs | 2 +- .../src/tests/adjustment_fee_tests.rs | 7 ++++--- pallets/avn/src/lib.rs | 2 +- pallets/eth-bridge/src/offence.rs | 2 +- pallets/eth-bridge/src/tests/tests.rs | 8 ++++---- pallets/ethereum-events/src/event_parser.rs | 2 +- pallets/ethereum-events/src/offence.rs | 2 +- pallets/nft-manager/src/lib.rs | 2 +- pallets/parachain-staking/src/tests/mock.rs | 4 ++-- pallets/summary/src/offence.rs | 2 +- pallets/validators-manager/src/lib.rs | 2 +- .../validators-manager/src/proxy_tests/nominate_tests.rs | 2 +- primitives/avn-common/src/event_types.rs | 2 +- 14 files changed, 21 insertions(+), 20 deletions(-) diff --git a/node/avn-lower-rpc/src/lib.rs b/node/avn-lower-rpc/src/lib.rs index 11ef5e5ac..8784931ac 100644 --- a/node/avn-lower-rpc/src/lib.rs +++ b/node/avn-lower-rpc/src/lib.rs @@ -57,7 +57,7 @@ where leaf_filter, )?; - if extrinsics.len() > 0 && encoded_leaf.is_some() { + if !extrinsics.is_empty() && encoded_leaf.is_some() { let leaf = encoded_leaf.expect("Leaf exists"); let merkle_path = generate_merkle_path(&leaf, extrinsics)?; let response = MerklePathData { encoded_leaf: leaf, merkle_path }; diff --git a/node/avn-service/src/lib.rs b/node/avn-service/src/lib.rs index 5a2cb016a..bf93bcad9 100644 --- a/node/avn-service/src/lib.rs +++ b/node/avn-service/src/lib.rs @@ -487,7 +487,7 @@ where extrinsics_duration ); - if extrinsics.len() > 0 { + if !extrinsics.is_empty() { let root_hash_start_time = Instant::now(); let root_hash = generate_tree_root(extrinsics)?; let root_hash_duration = root_hash_start_time.elapsed(); diff --git a/pallets/avn-transaction-payment/src/tests/adjustment_fee_tests.rs b/pallets/avn-transaction-payment/src/tests/adjustment_fee_tests.rs index 4c15fdd3c..97bcc7896 100644 --- a/pallets/avn-transaction-payment/src/tests/adjustment_fee_tests.rs +++ b/pallets/avn-transaction-payment/src/tests/adjustment_fee_tests.rs @@ -79,7 +79,7 @@ fn set_known_sender(sender: &AccountId, config: AdjustmentInput) { } pub(crate) fn fee_adjusted_event_emitted() -> bool { - System::events() + let transaction_payment_event_missing = System::events() .into_iter() .map(|r| r.event) .filter_map(|e| { @@ -90,8 +90,9 @@ pub(crate) fn fee_adjusted_event_emitted() -> bool { } }) .collect::>() - .len() > - 0 + .is_empty(); + + return transaction_payment_event_missing == false } /// Rolls desired block number of times. diff --git a/pallets/avn/src/lib.rs b/pallets/avn/src/lib.rs index c3494bf66..5c6e62567 100644 --- a/pallets/avn/src/lib.rs +++ b/pallets/avn/src/lib.rs @@ -313,7 +313,7 @@ impl Pallet { let validators = Self::validators(); // If there are no validators there's no point continuing - if validators.len() == 0 { + if validators.is_empty() { return Err(Error::::NoValidatorsFound) } diff --git a/pallets/eth-bridge/src/offence.rs b/pallets/eth-bridge/src/offence.rs index 5893f9371..b8788a2f7 100644 --- a/pallets/eth-bridge/src/offence.rs +++ b/pallets/eth-bridge/src/offence.rs @@ -67,7 +67,7 @@ pub fn create_and_report_corroboration_offence( ) { let offenders = create_offenders_identification::(offenders_accounts); - if offenders.len() > 0 { + if !offenders.is_empty() { let invalid_event_offence = CorroborationOffence { session_index: >::current_index(), validator_set_count: crate::AVN::::validators().len() as u32, diff --git a/pallets/eth-bridge/src/tests/tests.rs b/pallets/eth-bridge/src/tests/tests.rs index 05df2d92a..ac14b1d61 100644 --- a/pallets/eth-bridge/src/tests/tests.rs +++ b/pallets/eth-bridge/src/tests/tests.rs @@ -502,8 +502,8 @@ mod add_corroboration { .as_active_tx() .unwrap(); - assert_eq!(active_tx.data.valid_tx_hash_corroborations.len(), 0); - assert!(active_tx.data.invalid_tx_hash_corroborations.len() > 0); + assert_eq!(true, active_tx.data.valid_tx_hash_corroborations.is_empty()); + assert_eq!(false, active_tx.data.invalid_tx_hash_corroborations.is_empty()); }); } @@ -514,7 +514,7 @@ mod add_corroboration { let context = setup_context(); let active_tx = setup_corroboration_test(&context, true, false); - assert!(active_tx.data.invalid_tx_hash_corroborations.len() > 0); + assert_eq!(false, active_tx.data.invalid_tx_hash_corroborations.is_empty()); }); } @@ -525,7 +525,7 @@ mod add_corroboration { let context = setup_context(); let active_tx = setup_corroboration_test(&context, true, true); - assert!(active_tx.data.valid_tx_hash_corroborations.len() > 0); + assert_eq!(false, active_tx.data.valid_tx_hash_corroborations.is_empty()); }); } diff --git a/pallets/ethereum-events/src/event_parser.rs b/pallets/ethereum-events/src/event_parser.rs index 4f79a8572..c9b7949bf 100644 --- a/pallets/ethereum-events/src/event_parser.rs +++ b/pallets/ethereum-events/src/event_parser.rs @@ -129,7 +129,7 @@ fn get_data(event: &JsonValue) -> Result>, SimpleError> { let bytes = hex_to_bytes(data)?; - if bytes.len() > 0 { + if !bytes.is_empty() { return Ok(Some(bytes)) } diff --git a/pallets/ethereum-events/src/offence.rs b/pallets/ethereum-events/src/offence.rs index 6bf9acd14..2a74ff43e 100644 --- a/pallets/ethereum-events/src/offence.rs +++ b/pallets/ethereum-events/src/offence.rs @@ -77,7 +77,7 @@ pub fn create_and_report_invalid_log_offence( ) { let offenders = create_offenders_identification::(offenders_accounts); - if offenders.len() > 0 { + if !offenders.is_empty() { let invalid_event_offence = InvalidEthereumLogOffence { session_index: >::current_index(), validator_set_count: >::validators().len() as u32, diff --git a/pallets/nft-manager/src/lib.rs b/pallets/nft-manager/src/lib.rs index 3ec8ee02e..7d385b2d8 100644 --- a/pallets/nft-manager/src/lib.rs +++ b/pallets/nft-manager/src/lib.rs @@ -806,7 +806,7 @@ impl Pallet { fn validate_external_ref( unique_external_ref: &BoundedVec, ) -> DispatchResult { - ensure!(unique_external_ref.len() > 0, Error::::ExternalRefIsMandatory); + ensure!(!unique_external_ref.is_empty(), Error::::ExternalRefIsMandatory); ensure!( Self::is_external_ref_used(&unique_external_ref) == false, Error::::ExternalRefIsAlreadyInUse diff --git a/pallets/parachain-staking/src/tests/mock.rs b/pallets/parachain-staking/src/tests/mock.rs index 30678848e..001590908 100644 --- a/pallets/parachain-staking/src/tests/mock.rs +++ b/pallets/parachain-staking/src/tests/mock.rs @@ -710,7 +710,7 @@ macro_rules! assert_eq_last_events { #[macro_export] macro_rules! assert_tail_eq { ($tail:expr, $arr:expr $(,)?) => { - if $tail.len() != 0 { + if !$tail.is_empty() { // 0-length always passes if $tail.len() > $arr.len() { @@ -722,7 +722,7 @@ macro_rules! assert_tail_eq { } }; ($tail:expr, $arr:expr, $($arg:tt)*) => { - if $tail.len() != 0 { + if !$tail.is_empty() { // 0-length always passes if $tail.len() > $arr.len() { diff --git a/pallets/summary/src/offence.rs b/pallets/summary/src/offence.rs index 7966eb58b..745c1ce34 100644 --- a/pallets/summary/src/offence.rs +++ b/pallets/summary/src/offence.rs @@ -82,7 +82,7 @@ pub fn create_and_report_summary_offence( ) { let offenders = create_offenders_identification::(offenders_accounts); - if offenders.len() > 0 { + if !offenders.is_empty() { let invalid_event_offence = SummaryOffence { session_index: >::current_index(), validator_set_count: crate::AVN::::validators().len() as u32, diff --git a/pallets/validators-manager/src/lib.rs b/pallets/validators-manager/src/lib.rs index 37fd121c3..2b81c80e8 100644 --- a/pallets/validators-manager/src/lib.rs +++ b/pallets/validators-manager/src/lib.rs @@ -201,7 +201,7 @@ pub mod pallet { ensure_root(origin)?; let validator_account_ids = Self::validator_account_ids().ok_or(Error::::NoValidators)?; - ensure!(validator_account_ids.len() > 0, Error::::NoValidators); + ensure!(!validator_account_ids.is_empty(), Error::::NoValidators); ensure!( !validator_account_ids.contains(&collator_account_id), diff --git a/pallets/validators-manager/src/proxy_tests/nominate_tests.rs b/pallets/validators-manager/src/proxy_tests/nominate_tests.rs index c3f396eb1..18ee1bc4f 100644 --- a/pallets/validators-manager/src/proxy_tests/nominate_tests.rs +++ b/pallets/validators-manager/src/proxy_tests/nominate_tests.rs @@ -95,7 +95,7 @@ mod proxy_signed_nominate { let mut sum = 0; exposures.into_iter().for_each(|e| { - if e.others.len() as u32 > 0 { + if !e.others.is_empty() { sum += e.others.iter().find(|o| o.who == staker).unwrap().value; } }); diff --git a/primitives/avn-common/src/event_types.rs b/primitives/avn-common/src/event_types.rs index 182006504..39ab5ede9 100644 --- a/primitives/avn-common/src/event_types.rs +++ b/primitives/avn-common/src/event_types.rs @@ -309,7 +309,7 @@ impl NftMintData { pub fn is_valid(&self) -> bool { return !self.batch_id.is_zero() && !self.t2_owner_public_key.is_zero() && - self.unique_external_ref.len() > 0 + !self.unique_external_ref.is_empty() } pub fn parse_bytes(data: Option>, topics: Vec>) -> Result { From 34e3537e2cbfcb197f8779bd2929b2ef38d38a90 Mon Sep 17 00:00:00 2001 From: aventus-ci-agent Date: Tue, 30 Apr 2024 16:15:21 +0000 Subject: [PATCH 2/2] cargo package, spec and impl versions increased --- Cargo.lock | 36 ++++++++++++++++++------------------ Cargo.toml | 2 +- runtime/avn/src/lib.rs | 2 +- runtime/test/src/lib.rs | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 395c78d4b..ba32ca3df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -691,7 +691,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "avn-lower-rpc" -version = "5.3.0" +version = "5.3.1" dependencies = [ "avn-service", "futures", @@ -713,7 +713,7 @@ dependencies = [ [[package]] name = "avn-node-parachain" -version = "5.3.0" +version = "5.3.1" dependencies = [ "avn-lower-rpc", "avn-parachain-runtime", @@ -793,7 +793,7 @@ dependencies = [ [[package]] name = "avn-parachain-runtime" -version = "5.3.0" +version = "5.3.1" dependencies = [ "avn-runtime-common", "cumulus-pallet-aura-ext", @@ -872,7 +872,7 @@ dependencies = [ [[package]] name = "avn-parachain-test-runtime" -version = "5.3.0" +version = "5.3.1" dependencies = [ "avn-runtime-common", "cumulus-pallet-aura-ext", @@ -951,7 +951,7 @@ dependencies = [ [[package]] name = "avn-runtime-common" -version = "5.3.0" +version = "5.3.1" dependencies = [ "frame-support", "hex-literal 0.4.1", @@ -965,7 +965,7 @@ dependencies = [ [[package]] name = "avn-service" -version = "5.3.0" +version = "5.3.1" dependencies = [ "anyhow", "ethereum-types 0.11.0", @@ -6823,7 +6823,7 @@ dependencies = [ [[package]] name = "pallet-avn" -version = "5.3.0" +version = "5.3.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6849,7 +6849,7 @@ dependencies = [ [[package]] name = "pallet-avn-offence-handler" -version = "5.3.0" +version = "5.3.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6870,7 +6870,7 @@ dependencies = [ [[package]] name = "pallet-avn-proxy" -version = "5.3.0" +version = "5.3.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6893,7 +6893,7 @@ dependencies = [ [[package]] name = "pallet-avn-transaction-payment" -version = "5.3.0" +version = "5.3.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -7160,7 +7160,7 @@ dependencies = [ [[package]] name = "pallet-eth-bridge" -version = "5.3.0" +version = "5.3.1" dependencies = [ "ethabi 13.0.0", "frame-benchmarking", @@ -7186,7 +7186,7 @@ dependencies = [ [[package]] name = "pallet-ethereum-events" -version = "5.3.0" +version = "5.3.1" dependencies = [ "env_logger 0.10.0", "frame-benchmarking", @@ -7381,7 +7381,7 @@ dependencies = [ [[package]] name = "pallet-nft-manager" -version = "5.3.0" +version = "5.3.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -7508,7 +7508,7 @@ dependencies = [ [[package]] name = "pallet-parachain-staking" -version = "5.3.0" +version = "5.3.1" dependencies = [ "assert_matches", "frame-benchmarking", @@ -7785,7 +7785,7 @@ dependencies = [ [[package]] name = "pallet-summary" -version = "5.3.0" +version = "5.3.1" dependencies = [ "assert_matches", "frame-benchmarking", @@ -7852,7 +7852,7 @@ dependencies = [ [[package]] name = "pallet-token-manager" -version = "5.3.0" +version = "5.3.1" dependencies = [ "enumflags2", "frame-benchmarking", @@ -7960,7 +7960,7 @@ dependencies = [ [[package]] name = "pallet-validators-manager" -version = "5.3.0" +version = "5.3.1" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -12556,7 +12556,7 @@ dependencies = [ [[package]] name = "sp-avn-common" -version = "5.3.0" +version = "5.3.1" dependencies = [ "byte-slice-cast", "derive_more", diff --git a/Cargo.toml b/Cargo.toml index ba35bb226..0e53ed819 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ lto = "fat" codegen-units = 1 [workspace.package] -version = "5.3.0" +version = "5.3.1" authors = ["Aventus systems team"] homepage = "https://www.aventus.io/" repository = "https://github.com/Aventus-Network-Services/avn-node-parachain/" diff --git a/runtime/avn/src/lib.rs b/runtime/avn/src/lib.rs index 69cd538ce..75e57c026 100644 --- a/runtime/avn/src/lib.rs +++ b/runtime/avn/src/lib.rs @@ -174,7 +174,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("avn-parachain"), impl_name: create_runtime_str!("avn-parachain"), authoring_version: 1, - spec_version: 62, + spec_version: 63, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtime/test/src/lib.rs b/runtime/test/src/lib.rs index e3fb84c2c..b85b11bf3 100644 --- a/runtime/test/src/lib.rs +++ b/runtime/test/src/lib.rs @@ -169,7 +169,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("avn-test-parachain"), impl_name: create_runtime_str!("avn-test-parachain"), authoring_version: 1, - spec_version: 62, + spec_version: 63, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1,