diff --git a/Cargo.lock b/Cargo.lock index ced123b99..920cc8c64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5727,7 +5727,6 @@ dependencies = [ "pallet-balances", "pallet-ddc-verification", "parity-scale-codec", - "polkadot-ckb-merkle-mountain-range", "scale-info", "sp-core", "sp-io", diff --git a/pallets/ddc-clusters/src/cluster.rs b/pallets/ddc-clusters/src/cluster.rs index ebe39aa8c..ae47d63f7 100644 --- a/pallets/ddc-clusters/src/cluster.rs +++ b/pallets/ddc-clusters/src/cluster.rs @@ -15,9 +15,7 @@ pub struct Cluster { pub reserve_id: AccountId, pub props: ClusterProps, pub status: ClusterStatus, - // todo(yahortsaryk): `last_validated_era_id` should be renamed to `last_paid_era` to eliminate - // ambiguity, as the validation step is decoupled from payout step. - pub last_validated_era_id: DdcEra, + pub last_paid_era: DdcEra, } #[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo, PartialEq, Serialize, Deserialize)] @@ -46,7 +44,7 @@ impl Cluster { replication_total: cluster_params.replication_total, }, status: ClusterStatus::Unbonded, - last_validated_era_id: DdcEra::default(), + last_paid_era: DdcEra::default(), } } diff --git a/pallets/ddc-clusters/src/lib.rs b/pallets/ddc-clusters/src/lib.rs index 75a8bbd99..ed86010ea 100644 --- a/pallets/ddc-clusters/src/lib.rs +++ b/pallets/ddc-clusters/src/lib.rs @@ -894,7 +894,7 @@ pub mod pallet { let mut cluster = Clusters::::try_get(cluster_id).map_err(|_| Error::::ClusterDoesNotExist)?; - cluster.last_validated_era_id = era_id; + cluster.last_paid_era = era_id; Clusters::::insert(cluster_id, cluster); Self::deposit_event(Event::::ClusterEraPaid { cluster_id: *cluster_id, era_id }); @@ -905,7 +905,7 @@ pub mod pallet { let cluster = Clusters::::try_get(cluster_id).map_err(|_| Error::::ClusterDoesNotExist)?; - Ok(cluster.last_validated_era_id) + Ok(cluster.last_paid_era) } } diff --git a/pallets/ddc-clusters/src/migrations.rs b/pallets/ddc-clusters/src/migrations.rs index 335b1f6f5..c3b585364 100644 --- a/pallets/ddc-clusters/src/migrations.rs +++ b/pallets/ddc-clusters/src/migrations.rs @@ -465,7 +465,7 @@ pub mod v3 { pub reserve_id: AccountId, pub props: ClusterProps, pub status: ClusterStatus, - pub last_validated_era_id: DdcEra, // new field + pub last_paid_era: DdcEra, // new field } #[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo, PartialEq, Serialize, Deserialize)] @@ -521,7 +521,7 @@ pub mod v3 { replication_total: old_cluster.props.replication_total, }, status: old_cluster.status, - last_validated_era_id: 0, + last_paid_era: 0, }) }, ); @@ -610,7 +610,7 @@ pub mod v3 { erasure_coding_total: 48, replication_total: 20, }, - last_validated_era_id: 0, + last_paid_era: 0, status: ClusterStatus::Activated, }; @@ -625,7 +625,7 @@ pub mod v3 { erasure_coding_total: 48, replication_total: 20, }, - last_validated_era_id: 0, + last_paid_era: 0, status: ClusterStatus::Activated, }; @@ -647,21 +647,21 @@ pub mod v3 { ); assert_eq!(Clusters::::get(cluster_id0).unwrap().props.erasure_coding_total, 48); assert_eq!(Clusters::::get(cluster_id0).unwrap().props.replication_total, 20); - assert_eq!(Clusters::::get(cluster_id0).unwrap().last_validated_era_id, 0); + assert_eq!(Clusters::::get(cluster_id0).unwrap().last_paid_era, 0); assert_eq!( Clusters::::get(cluster_id1).unwrap().props.erasure_coding_required, 16 ); assert_eq!(Clusters::::get(cluster_id1).unwrap().props.erasure_coding_total, 48); assert_eq!(Clusters::::get(cluster_id1).unwrap().props.replication_total, 20); - assert_eq!(Clusters::::get(cluster_id1).unwrap().last_validated_era_id, 0); + assert_eq!(Clusters::::get(cluster_id1).unwrap().last_paid_era, 0); assert_eq!( Clusters::::get(cluster_id2).unwrap().props.erasure_coding_required, 16 ); assert_eq!(Clusters::::get(cluster_id2).unwrap().props.erasure_coding_total, 48); assert_eq!(Clusters::::get(cluster_id2).unwrap().props.replication_total, 20); - assert_eq!(Clusters::::get(cluster_id2).unwrap().last_validated_era_id, 0); + assert_eq!(Clusters::::get(cluster_id2).unwrap().last_paid_era, 0); }); } } diff --git a/pallets/ddc-clusters/src/tests.rs b/pallets/ddc-clusters/src/tests.rs index fc9b41e8d..d85f42288 100644 --- a/pallets/ddc-clusters/src/tests.rs +++ b/pallets/ddc-clusters/src/tests.rs @@ -622,7 +622,7 @@ fn set_last_validated_era_works() { assert_ok!(DdcClusters::set_last_paid_era(&cluster_id, era_id)); let updated_cluster = DdcClusters::clusters(cluster_id).unwrap(); - assert_eq!(updated_cluster.last_validated_era_id, era_id); + assert_eq!(updated_cluster.last_paid_era, era_id); // Checking that event was emitted assert_eq!(System::events().len(), 3); diff --git a/pallets/ddc-payouts/Cargo.toml b/pallets/ddc-payouts/Cargo.toml index 6613de0bf..83c8b4d04 100644 --- a/pallets/ddc-payouts/Cargo.toml +++ b/pallets/ddc-payouts/Cargo.toml @@ -29,7 +29,6 @@ sp-std = { workspace = true } # Cere dependencies ddc-primitives = { workspace = true } -polkadot-ckb-merkle-mountain-range = { workspace = true } [dev-dependencies] chrono = { workspace = true, default-features = true } @@ -42,7 +41,6 @@ substrate-test-utils = { workspace = true, default-features = true } [features] default = ["std"] std = [ - "polkadot-ckb-merkle-mountain-range/std", "hex/std", "codec/std", "ddc-primitives/std", diff --git a/pallets/ddc-staking/src/tests.rs b/pallets/ddc-staking/src/tests.rs index 164e70aff..e80eed4a5 100644 --- a/pallets/ddc-staking/src/tests.rs +++ b/pallets/ddc-staking/src/tests.rs @@ -772,7 +772,7 @@ fn bond_cluster_works() { replication_total: 0 }, status: ClusterStatus::Bonded, - last_validated_era_id: DdcEra::default() + last_paid_era: DdcEra::default() }) ); @@ -922,7 +922,7 @@ fn unbond_bonded_cluster_works() { replication_total: 0 }, status: ClusterStatus::Unbonding, - last_validated_era_id: DdcEra::default() + last_paid_era: DdcEra::default() }) ); @@ -1002,7 +1002,7 @@ fn unbond_activated_cluster_works() { replication_total: 0 }, status: ClusterStatus::Unbonding, - last_validated_era_id: DdcEra::default() + last_paid_era: DdcEra::default() }) ); @@ -1097,7 +1097,7 @@ fn withdraw_unbonded_cluster_works() { replication_total: 0 }, status: ClusterStatus::Unbonded, - last_validated_era_id: DdcEra::default() + last_paid_era: DdcEra::default() }) ); }); @@ -1184,7 +1184,7 @@ fn withdraw_activated_cluster_works() { replication_total: 0 }, status: ClusterStatus::Unbonded, - last_validated_era_id: DdcEra::default() + last_paid_era: DdcEra::default() }) ); }); diff --git a/primitives/src/traits/cluster.rs b/primitives/src/traits/cluster.rs index ad7ec9a4a..c13720877 100644 --- a/primitives/src/traits/cluster.rs +++ b/primitives/src/traits/cluster.rs @@ -98,14 +98,14 @@ pub trait ClusterManager: ClusterQuery { fn get_clusters(status: ClusterStatus) -> Result, DispatchError>; } pub trait ClusterValidator { - /// Updates the `last_validated_era_id` for the given cluster and emits an event indicating the + /// Updates the `last_paid_era` for the given cluster and emits an event indicating the /// update. /// /// # Parameters /// - /// - `cluster_id`: A reference to the unique identifier of the cluster that needs its last - /// validated era updated. - /// - `era_id`: The new era identifier to be set as the last validated era for the cluster. + /// - `cluster_id`: A reference to the unique identifier of the cluster that needs its last paid + /// era updated. + /// - `era_id`: The new era identifier to be set as the last paid era for the cluster. /// /// # Returns /// @@ -116,13 +116,13 @@ pub trait ClusterValidator { /// Emits `ClusterEraPaid` event if the operation is successful. fn set_last_paid_era(cluster_id: &ClusterId, era_id: DdcEra) -> Result<(), DispatchError>; - /// Retrieves the `last_validated_era_id` for the given cluster + /// Retrieves the `last_paid_era` for the given cluster /// update. /// /// # Parameters /// - /// - `cluster_id`: A reference to the unique identifier of the cluster the - /// `last_validated_era_id` is being retrieved for + /// - `cluster_id`: A reference to the unique identifier of the cluster the `last_paid_era` is + /// being retrieved for /// /// # Returns ///