Skip to content

Commit

Permalink
consolidated payout logic
Browse files Browse the repository at this point in the history
  • Loading branch information
aie0 committed Dec 19, 2023
1 parent 5febf20 commit 8b8127c
Show file tree
Hide file tree
Showing 19 changed files with 1,500 additions and 397 deletions.
1 change: 1 addition & 0 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ pub fn cere_dev_genesis(
nomination_pools: Default::default(),
ddc_clusters: Default::default(),
ddc_nodes: Default::default(),
ddc_payouts: Default::default(),
}
}

Expand Down
14 changes: 7 additions & 7 deletions pallets/ddc-clusters/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub use frame_benchmarking::{
};
use frame_system::RawOrigin;
use pallet_contracts::chain_extension::UncheckedFrom;
use sp_runtime::{AccountId32, Perbill};
use sp_runtime::{AccountId32, Perquintill};
use sp_std::prelude::*;
use testing_utils::*;

Expand All @@ -26,9 +26,9 @@ benchmarks! {
let user = account::<T::AccountId>("user", USER_SEED, 0u32);
let cluster_params = ClusterParams { node_provider_auth_contract: Some(user.clone()) };
let cluster_gov_params: ClusterGovParams<BalanceOf<T>, T::BlockNumber> = ClusterGovParams {
treasury_share: Perbill::default(),
validators_share: Perbill::default(),
cluster_reserve_share: Perbill::default(),
treasury_share: Perquintill::default(),
validators_share: Perquintill::default(),
cluster_reserve_share: Perquintill::default(),
storage_bond_size: 100u32.into(),
storage_chill_delay: 50u32.into(),
storage_unbonding_delay: 50u32.into(),
Expand Down Expand Up @@ -89,9 +89,9 @@ benchmarks! {
let user = account::<T::AccountId>("user", USER_SEED, 0u32);
let _ = config_cluster::<T>(user, cluster_id);
let new_cluster_gov_params: ClusterGovParams<BalanceOf<T>, T::BlockNumber> = ClusterGovParams {
treasury_share: Perbill::default(),
validators_share: Perbill::default(),
cluster_reserve_share: Perbill::default(),
treasury_share: Perquintill::default(),
validators_share: Perquintill::default(),
cluster_reserve_share: Perquintill::default(),
storage_bond_size: 10u32.into(),
storage_chill_delay: 5u32.into(),
storage_unbonding_delay: 5u32.into(),
Expand Down
8 changes: 4 additions & 4 deletions pallets/ddc-clusters/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use sp_runtime::{
traits::{
BlakeTwo256, Convert, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, Verify,
},
MultiSignature, Perbill,
MultiSignature, Perquintill,
};

use crate::{self as pallet_ddc_clusters, *};
Expand Down Expand Up @@ -244,9 +244,9 @@ impl ExtBuilder {
.assimilate_storage(&mut storage);

let cluster_gov_params = ClusterGovParams {
treasury_share: Perbill::from_float(0.05),
validators_share: Perbill::from_float(0.01),
cluster_reserve_share: Perbill::from_float(0.02),
treasury_share: Perquintill::from_float(0.05),
validators_share: Perquintill::from_float(0.01),
cluster_reserve_share: Perquintill::from_float(0.02),
storage_bond_size: 100,
storage_chill_delay: 50,
storage_unbonding_delay: 50,
Expand Down
14 changes: 7 additions & 7 deletions pallets/ddc-clusters/src/testing_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub use frame_benchmarking::{
use frame_system::RawOrigin;
use pallet_contracts::chain_extension::UncheckedFrom;
use pallet_ddc_nodes::Node;
use sp_runtime::Perbill;
use sp_runtime::Perquintill;
use sp_std::prelude::*;

use crate::{Pallet as DdcClusters, *};
Expand All @@ -22,9 +22,9 @@ where
{
let cluster_params = ClusterParams { node_provider_auth_contract: Some(user.clone()) };
let cluster_gov_params: ClusterGovParams<BalanceOf<T>, T::BlockNumber> = ClusterGovParams {
treasury_share: Perbill::default(),
validators_share: Perbill::default(),
cluster_reserve_share: Perbill::default(),
treasury_share: Perquintill::default(),
validators_share: Perquintill::default(),
cluster_reserve_share: Perquintill::default(),
storage_bond_size: 100u32.into(),
storage_chill_delay: 50u32.into(),
storage_unbonding_delay: 50u32.into(),
Expand Down Expand Up @@ -62,9 +62,9 @@ where
};

let cluster_gov_params: ClusterGovParams<BalanceOf<T>, T::BlockNumber> = ClusterGovParams {
treasury_share: Perbill::default(),
validators_share: Perbill::default(),
cluster_reserve_share: Perbill::default(),
treasury_share: Perquintill::default(),
validators_share: Perquintill::default(),
cluster_reserve_share: Perquintill::default(),
storage_bond_size: 100u32.into(),
storage_chill_delay: 50u32.into(),
storage_unbonding_delay: 50u32.into(),
Expand Down
44 changes: 22 additions & 22 deletions pallets/ddc-clusters/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ddc_traits::cluster::ClusterManager;
use frame_support::{assert_noop, assert_ok, error::BadOrigin};
use frame_system::Config;
use hex_literal::hex;
use sp_runtime::{traits::Hash, Perbill};
use sp_runtime::{traits::Hash, Perquintill};

use super::{mock::*, *};

Expand All @@ -23,9 +23,9 @@ fn create_cluster_works() {
let auth_contract = AccountId::from([3; 32]);

let cluster_gov_params = ClusterGovParams {
treasury_share: Perbill::from_float(0.05),
validators_share: Perbill::from_float(0.01),
cluster_reserve_share: Perbill::from_float(0.02),
treasury_share: Perquintill::from_float(0.05),
validators_share: Perquintill::from_float(0.01),
cluster_reserve_share: Perquintill::from_float(0.02),
storage_bond_size: 100,
storage_chill_delay: 50,
storage_unbonding_delay: 50,
Expand Down Expand Up @@ -109,9 +109,9 @@ fn add_and_delete_node_works() {
cluster_reserve_id.clone(),
ClusterParams { node_provider_auth_contract: Some(cluster_manager_id.clone()) },
ClusterGovParams {
treasury_share: Perbill::from_float(0.05),
validators_share: Perbill::from_float(0.01),
cluster_reserve_share: Perbill::from_float(0.02),
treasury_share: Perquintill::from_float(0.05),
validators_share: Perquintill::from_float(0.01),
cluster_reserve_share: Perquintill::from_float(0.02),
storage_bond_size: 100,
storage_chill_delay: 50,
storage_unbonding_delay: 50,
Expand Down Expand Up @@ -327,9 +327,9 @@ fn set_cluster_params_works() {
cluster_reserve_id.clone(),
ClusterParams { node_provider_auth_contract: Some(auth_contract_1) },
ClusterGovParams {
treasury_share: Perbill::from_float(0.05),
validators_share: Perbill::from_float(0.01),
cluster_reserve_share: Perbill::from_float(0.02),
treasury_share: Perquintill::from_float(0.05),
validators_share: Perquintill::from_float(0.01),
cluster_reserve_share: Perquintill::from_float(0.02),
storage_bond_size: 100,
storage_chill_delay: 50,
storage_unbonding_delay: 50,
Expand Down Expand Up @@ -372,9 +372,9 @@ fn set_cluster_gov_params_works() {
let auth_contract = AccountId::from([3; 32]);

let cluster_gov_params = ClusterGovParams {
treasury_share: Perbill::from_float(0.05),
validators_share: Perbill::from_float(0.01),
cluster_reserve_share: Perbill::from_float(0.02),
treasury_share: Perquintill::from_float(0.05),
validators_share: Perquintill::from_float(0.01),
cluster_reserve_share: Perquintill::from_float(0.02),
storage_bond_size: 100,
storage_chill_delay: 50,
storage_unbonding_delay: 50,
Expand Down Expand Up @@ -435,9 +435,9 @@ fn cluster_visitor_works() {
let auth_contract = AccountId::from([3; 32]);

let cluster_gov_params = ClusterGovParams {
treasury_share: Perbill::from_float(0.05),
validators_share: Perbill::from_float(0.01),
cluster_reserve_share: Perbill::from_float(0.02),
treasury_share: Perquintill::from_float(0.05),
validators_share: Perquintill::from_float(0.01),
cluster_reserve_share: Perquintill::from_float(0.02),
storage_bond_size: 100,
storage_chill_delay: 50,
storage_unbonding_delay: 50,
Expand Down Expand Up @@ -483,9 +483,9 @@ fn cluster_visitor_works() {
assert_eq!(
<DdcClusters as ClusterVisitor<Test>>::get_fees_params(&cluster_id).unwrap(),
ClusterFeesParams {
treasury_share: Perbill::from_float(0.05),
validators_share: Perbill::from_float(0.01),
cluster_reserve_share: Perbill::from_float(0.02)
treasury_share: Perquintill::from_float(0.05),
validators_share: Perquintill::from_float(0.01),
cluster_reserve_share: Perquintill::from_float(0.02)
}
);

Expand Down Expand Up @@ -544,9 +544,9 @@ fn cluster_creator_works() {
let auth_contract = AccountId::from([3; 32]);

let cluster_gov_params = ClusterGovParams {
treasury_share: Perbill::from_float(0.05),
validators_share: Perbill::from_float(0.01),
cluster_reserve_share: Perbill::from_float(0.02),
treasury_share: Perquintill::from_float(0.05),
validators_share: Perquintill::from_float(0.01),
cluster_reserve_share: Perquintill::from_float(0.02),
storage_bond_size: 100,
storage_chill_delay: 50,
storage_unbonding_delay: 50,
Expand Down
1 change: 1 addition & 0 deletions pallets/ddc-customers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", optional = true }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }

Expand Down
8 changes: 4 additions & 4 deletions pallets/ddc-customers/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use ddc_primitives::{ClusterGovParams, ClusterId, ClusterParams};
use frame_benchmarking::{account, benchmarks, whitelist_account};
use frame_support::traits::Currency;
use sp_runtime::Perbill;
use sp_runtime::Perquintill;
use sp_std::prelude::*;

use super::*;
Expand All @@ -23,9 +23,9 @@ benchmarks! {
let user = account::<T::AccountId>("user", USER_SEED, 0u32);

let cluster_gov_params: ClusterGovParams<BalanceOf<T>, T::BlockNumber> = ClusterGovParams {
treasury_share: Perbill::default(),
validators_share: Perbill::default(),
cluster_reserve_share: Perbill::default(),
treasury_share: Perquintill::default(),
validators_share: Perquintill::default(),
cluster_reserve_share: Perquintill::default(),
storage_bond_size: 100u32.into(),
storage_chill_delay: 50u32.into(),
storage_unbonding_delay: 50u32.into(),
Expand Down
Loading

0 comments on commit 8b8127c

Please sign in to comment.