From 7619421748c5e23dbf1d3a6b13a4d047aacf8785 Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Fri, 18 Aug 2023 15:45:46 +0200 Subject: [PATCH] fix remaining conflicts not smotted by git --- pallets/ddc-staking/src/lib.rs | 24 +----------------------- pallets/ddc-validator/src/lib.rs | 19 +++++++++++++------ runtime/cere-dev/src/lib.rs | 7 ------- 3 files changed, 14 insertions(+), 36 deletions(-) diff --git a/pallets/ddc-staking/src/lib.rs b/pallets/ddc-staking/src/lib.rs index 6f45e0f35..1630df783 100644 --- a/pallets/ddc-staking/src/lib.rs +++ b/pallets/ddc-staking/src/lib.rs @@ -240,7 +240,6 @@ pub mod pallet { type DefaultStorageChillDelay: Get; type RuntimeEvent: From> + IsType<::RuntimeEvent>; - type Event: From> + IsType<::Event>; /// Number of eras that staked funds must remain bonded for. #[pallet::constant] type BondingDuration: Get; @@ -898,6 +897,7 @@ pub mod pallet { >::set(Some(price_per_byte)); Ok(()) } + } impl Pallet { pub fn do_payout_stakers(era: EraIndex) -> DispatchResult { @@ -1063,28 +1063,6 @@ pub mod pallet { Storages::::take(who).is_some() } - /// This function will add a storage network participant to the `Storages` storage map. - /// - /// If the storage network participant already exists, their cluster will be updated. - /// - /// NOTE: you must ALWAYS use this function to add a storage network participant to the - /// system. Any access to `Storages` outside of this function is almost certainly - /// wrong. - pub fn do_add_storage(who: &T::AccountId, cluster: ClusterId) { - Storages::::insert(who, cluster); - } - - /// This function will remove a storage network participant from the `Storages` map. - /// - /// Returns true if `who` was removed from `Storages`, otherwise false. - /// - /// NOTE: you must ALWAYS use this function to remove a storage network participant from the - /// system. Any access to `Storages` outside of this function is almost certainly - /// wrong. - pub fn do_remove_storage(who: &T::AccountId) -> bool { - Storages::::take(who).is_some() - } - /// Reset the chilling era for a controller. pub fn reset_chilling(controller: &T::AccountId) { Ledger::::mutate(&controller, |maybe_ledger| { diff --git a/pallets/ddc-validator/src/lib.rs b/pallets/ddc-validator/src/lib.rs index 8ab55ff2d..21ee1d199 100644 --- a/pallets/ddc-validator/src/lib.rs +++ b/pallets/ddc-validator/src/lib.rs @@ -80,8 +80,8 @@ const ENABLE_DDC_VALIDATION_KEY: &[u8; 21] = b"enable-ddc-validation"; pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"dacv"); -pub const TIME_START_MS: u128 = 1_672_531_200_000; -pub const ERA_DURATION_MS: u128 = 120_000; +pub const DDC_ERA_START_MS: u128 = 1_672_531_200_000; +pub const DDC_ERA_DURATION_MS: u128 = 120_000; pub const ERA_IN_BLOCKS: u8 = 20; pub const BYTES_TO_CERE: u64 = 1; // this should have a logic built on top and adjusted @@ -634,7 +634,7 @@ pub mod pallet { result } - fn assign(quorum_size: usize, era: EraIndex) { + fn assign(quorum_size: usize, era: EraIndex) -> Result<(), AssignmentError> { let validators: Vec = OffchainWorkerKeys::::iter_keys().collect(); log::debug!("Current validators: {:?}.", validators); @@ -744,6 +744,13 @@ pub mod pallet { } } + fn get_current_era() -> EraIndex { + ((::TimeProvider::now().as_millis() - DDC_ERA_START_MS) / + DDC_ERA_DURATION_MS) + .try_into() + .unwrap() + } + fn validate_edges() -> Result<(), &'static str> { let current_ddc_era = ddc_staking::pallet::Pallet::::current_era().ok_or("DDC era not set")?; @@ -787,7 +794,7 @@ pub mod pallet { log::debug!("node aggregates: {:?}", node_aggregates); // No data for node - if (node_aggregates.len() == 0) { + if node_aggregates.len() == 0 { continue } @@ -911,7 +918,7 @@ pub mod pallet { let tx_res = signer.send_signed_transaction(|_acct| Call::set_validation_decision { - era: current_era - 1, + era: current_ddc_era - 1, cdn_node: utils::string_to_account::(edge.clone()), validation_decision: final_res.clone(), }); @@ -931,7 +938,7 @@ pub mod pallet { if cdn_nodes_reward_points.len() > 0 { let _tx_res = signer.send_signed_transaction(|_account| Call::set_era_reward_points { - era: current_era - 1, + era: current_ddc_era - 1, stakers_points: cdn_nodes_reward_points.clone(), }); } diff --git a/runtime/cere-dev/src/lib.rs b/runtime/cere-dev/src/lib.rs index 05f57249f..11be6ce59 100644 --- a/runtime/cere-dev/src/lib.rs +++ b/runtime/cere-dev/src/lib.rs @@ -1324,12 +1324,6 @@ parameter_types! { pub const DefaultStorageChillDelay: EraIndex = 7 * 24 * 60 / 2; // approx. 1 week with 2 min DDC era } -parameter_types! { - pub const DefaultEdgeBondSize: Balance = 100 * DOLLARS; - pub const DefaultEdgeChillDelay: EraIndex = 7 * 24 * 60 / 2; // approx. 1 week with 2 min DDC era - pub const DefaultStorageBondSize: Balance = 100 * DOLLARS; - pub const DefaultStorageChillDelay: EraIndex = 7 * 24 * 60 / 2; // approx. 1 week with 2 min DDC era -} impl pallet_ddc_staking::Config for Runtime { type BondingDuration = BondingDuration; type Currency = Balances; @@ -1338,7 +1332,6 @@ impl pallet_ddc_staking::Config for Runtime { type DefaultStorageBondSize = DefaultStorageBondSize; type DefaultStorageChillDelay = DefaultStorageChillDelay; type RuntimeEvent = RuntimeEvent; - type Event = Event; type TimeProvider = pallet_timestamp::Pallet; type StakersPayoutSource = Ddc_Accounts_Pallet_Id; type UnixTime = Timestamp;