From f5abcdb0ad830c0c454251cc150bbe61ac955045 Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Tue, 7 Nov 2023 15:30:54 +0100 Subject: [PATCH 1/5] substitute bond size check with cluster gov params --- pallets/ddc-clusters/src/lib.rs | 17 +++++++++++ pallets/ddc-staking/src/lib.rs | 50 +++++++++++++++++++++++++++------ traits/src/cluster.rs | 6 ++++ 3 files changed, 65 insertions(+), 8 deletions(-) diff --git a/pallets/ddc-clusters/src/lib.rs b/pallets/ddc-clusters/src/lib.rs index 59ce7fb52..08f246e69 100644 --- a/pallets/ddc-clusters/src/lib.rs +++ b/pallets/ddc-clusters/src/lib.rs @@ -31,6 +31,7 @@ use frame_support::{ use frame_system::pallet_prelude::*; pub use pallet::*; use pallet_ddc_nodes::{NodeRepository, NodeTrait}; +use sp_runtime::SaturatedConversion; use sp_std::prelude::*; mod cluster; @@ -247,6 +248,22 @@ pub mod pallet { .map(|_| ()) .ok_or(ClusterVisitorError::ClusterDoesNotExist) } + + fn get_bond_size( + cluster_id: &ClusterId, + node_pub_key: &NodePubKey, + ) -> Result { + // ensure!(ClustersNodes::::contains_key(cluster_id), + // Error::::ClusterDoesNotExist); + let cluster_gov_params = ClustersGovParams::::try_get(cluster_id) + .map_err(|_| ClusterVisitorError::ClusterGovParamsNotSet)?; + match node_pub_key { + NodePubKey::StoragePubKey(_node_pub_key) => + Ok(cluster_gov_params.storage_bond_size.saturated_into::()), + NodePubKey::CDNPubKey(_node_pub_key) => + Ok(cluster_gov_params.cdn_bond_size.saturated_into::()), + } + } } impl From for Error { diff --git a/pallets/ddc-staking/src/lib.rs b/pallets/ddc-staking/src/lib.rs index 55614769b..84c1183c0 100644 --- a/pallets/ddc-staking/src/lib.rs +++ b/pallets/ddc-staking/src/lib.rs @@ -49,7 +49,7 @@ use frame_system::pallet_prelude::*; use scale_info::TypeInfo; use sp_runtime::{ traits::{AccountIdConversion, AtLeast32BitUnsigned, Saturating, StaticLookup, Zero}, - RuntimeDebug, + RuntimeDebug, SaturatedConversion, }; use sp_staking::EraIndex; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; @@ -402,6 +402,7 @@ pub mod pallet { assert_ok!(Pallet::::serve( T::RuntimeOrigin::from(Some(controller.clone()).into()), cluster, + node.clone() )); } @@ -420,6 +421,7 @@ pub mod pallet { assert_ok!(Pallet::::store( T::RuntimeOrigin::from(Some(controller.clone()).into()), cluster, + node.clone(), )); } } @@ -487,6 +489,8 @@ pub mod pallet { NotNodeController, /// No stake found associated with the provided node. NodeHasNoStake, + /// No cluster governance params found for cluster + NoClusterGovParams, /// Conditions for fast chill are not met, try the regular `chill` from FastChillProhibited, } @@ -590,6 +594,7 @@ pub mod pallet { pub fn unbond( origin: OriginFor, #[pallet::compact] value: BalanceOf, + node_pub_key: NodePubKey, ) -> DispatchResult { let controller = ensure_signed(origin)?; let mut ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; @@ -609,10 +614,15 @@ pub mod pallet { ledger.active = Zero::zero(); } + // Check if stash is mapped to the node + let node_stash = >::get(&node_pub_key).ok_or(Error::::BadState)?; + ensure!(ledger.stash.clone() == node_stash, Error::::NotNodeController); + let min_active_bond = if let Some(cluster_id) = Self::edges(&ledger.stash) { - Self::settings(cluster_id).edge_bond_size - } else if let Some(cluster_id) = Self::storages(&ledger.stash) { - Self::settings(cluster_id).storage_bond_size + // Retrieve the respective bond size from Cluster Visitor + let bond_size = T::ClusterVisitor::get_bond_size(&cluster_id, &node_pub_key) + .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; + bond_size.saturated_into::>() } else { Zero::zero() }; @@ -692,19 +702,31 @@ pub mod pallet { /// The dispatch origin for this call must be _Signed_ by the controller, not the stash. The /// bond size must be greater than or equal to the `EdgeBondSize`. #[pallet::weight(T::WeightInfo::serve())] - pub fn serve(origin: OriginFor, cluster_id: ClusterId) -> DispatchResult { + pub fn serve( + origin: OriginFor, + cluster_id: ClusterId, + node_pub_key: NodePubKey, + ) -> DispatchResult { let controller = ensure_signed(origin)?; T::ClusterVisitor::ensure_cluster(&cluster_id) .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; + // Retrieve the respective bond size from Cluster Visitor + let bond_size = T::ClusterVisitor::get_bond_size(&cluster_id, &node_pub_key) + .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; + ensure!( - ledger.active >= Self::settings(cluster_id).edge_bond_size, + ledger.active >= bond_size.saturated_into::>(), Error::::InsufficientBond ); let stash = &ledger.stash; + // Check if stash is mapped to the node + let node_stash = >::get(&node_pub_key).ok_or(Error::::BadState)?; + ensure!(*stash == node_stash, Error::::NotNodeController); + // Can't participate in CDN if already participating in storage network. ensure!(!Storages::::contains_key(&stash), Error::::AlreadyInRole); @@ -729,19 +751,30 @@ pub mod pallet { /// The dispatch origin for this call must be _Signed_ by the controller, not the stash. The /// bond size must be greater than or equal to the `StorageBondSize`. #[pallet::weight(T::WeightInfo::store())] - pub fn store(origin: OriginFor, cluster_id: ClusterId) -> DispatchResult { + pub fn store( + origin: OriginFor, + cluster_id: ClusterId, + node_pub_key: NodePubKey, + ) -> DispatchResult { let controller = ensure_signed(origin)?; T::ClusterVisitor::ensure_cluster(&cluster_id) .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; + // Retrieve the respective bond size from Cluster Visitor + let bond_size = T::ClusterVisitor::get_bond_size(&cluster_id, &node_pub_key) + .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; ensure!( - ledger.active >= Self::settings(cluster_id).storage_bond_size, + ledger.active >= bond_size.saturated_into::>(), Error::::InsufficientBond ); let stash = &ledger.stash; + // Check if stash is mapped to the node + let node_stash = >::get(&node_pub_key).ok_or(Error::::BadState)?; + ensure!(*stash == node_stash, Error::::NotNodeController); + // Can't participate in storage network if already participating in CDN. ensure!(!Edges::::contains_key(&stash), Error::::AlreadyInRole); @@ -1197,6 +1230,7 @@ pub mod pallet { fn from(error: ClusterVisitorError) -> Self { match error { ClusterVisitorError::ClusterDoesNotExist => Error::::NodeHasNoStake, + ClusterVisitorError::ClusterGovParamsNotSet => Error::::NoClusterGovParams, } } } diff --git a/traits/src/cluster.rs b/traits/src/cluster.rs index a1cae3515..505de5298 100644 --- a/traits/src/cluster.rs +++ b/traits/src/cluster.rs @@ -5,8 +5,14 @@ pub trait ClusterVisitor { fn cluster_has_node(cluster_id: &ClusterId, node_pub_key: &NodePubKey) -> bool; fn ensure_cluster(cluster_id: &ClusterId) -> Result<(), ClusterVisitorError>; + + fn get_bond_size( + cluster_id: &ClusterId, + node_pub_key: &NodePubKey, + ) -> Result; } pub enum ClusterVisitorError { ClusterDoesNotExist, + ClusterGovParamsNotSet, } From 1b067e304abfade79d5647675e494de74be99aa4 Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Tue, 7 Nov 2023 16:20:39 +0100 Subject: [PATCH 2/5] remove unnecessary params & update mock --- pallets/ddc-staking/src/lib.rs | 36 ++++++++++----------------------- pallets/ddc-staking/src/mock.rs | 6 ++++++ 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/pallets/ddc-staking/src/lib.rs b/pallets/ddc-staking/src/lib.rs index 84c1183c0..58bfa5b9b 100644 --- a/pallets/ddc-staking/src/lib.rs +++ b/pallets/ddc-staking/src/lib.rs @@ -49,7 +49,7 @@ use frame_system::pallet_prelude::*; use scale_info::TypeInfo; use sp_runtime::{ traits::{AccountIdConversion, AtLeast32BitUnsigned, Saturating, StaticLookup, Zero}, - RuntimeDebug, SaturatedConversion, + AccountId32, RuntimeDebug, SaturatedConversion, }; use sp_staking::EraIndex; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; @@ -402,7 +402,6 @@ pub mod pallet { assert_ok!(Pallet::::serve( T::RuntimeOrigin::from(Some(controller.clone()).into()), cluster, - node.clone() )); } @@ -421,7 +420,6 @@ pub mod pallet { assert_ok!(Pallet::::store( T::RuntimeOrigin::from(Some(controller.clone()).into()), cluster, - node.clone(), )); } } @@ -702,20 +700,18 @@ pub mod pallet { /// The dispatch origin for this call must be _Signed_ by the controller, not the stash. The /// bond size must be greater than or equal to the `EdgeBondSize`. #[pallet::weight(T::WeightInfo::serve())] - pub fn serve( - origin: OriginFor, - cluster_id: ClusterId, - node_pub_key: NodePubKey, - ) -> DispatchResult { + pub fn serve(origin: OriginFor, cluster_id: ClusterId) -> DispatchResult { let controller = ensure_signed(origin)?; + let account = AccountId32::new([0; 32]); T::ClusterVisitor::ensure_cluster(&cluster_id) .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; // Retrieve the respective bond size from Cluster Visitor - let bond_size = T::ClusterVisitor::get_bond_size(&cluster_id, &node_pub_key) - .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; + let bond_size = + T::ClusterVisitor::get_bond_size(&cluster_id, &NodePubKey::CDNPubKey(account)) + .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; ensure!( ledger.active >= bond_size.saturated_into::>(), @@ -723,10 +719,6 @@ pub mod pallet { ); let stash = &ledger.stash; - // Check if stash is mapped to the node - let node_stash = >::get(&node_pub_key).ok_or(Error::::BadState)?; - ensure!(*stash == node_stash, Error::::NotNodeController); - // Can't participate in CDN if already participating in storage network. ensure!(!Storages::::contains_key(&stash), Error::::AlreadyInRole); @@ -751,30 +743,24 @@ pub mod pallet { /// The dispatch origin for this call must be _Signed_ by the controller, not the stash. The /// bond size must be greater than or equal to the `StorageBondSize`. #[pallet::weight(T::WeightInfo::store())] - pub fn store( - origin: OriginFor, - cluster_id: ClusterId, - node_pub_key: NodePubKey, - ) -> DispatchResult { + pub fn store(origin: OriginFor, cluster_id: ClusterId) -> DispatchResult { let controller = ensure_signed(origin)?; + let account = AccountId32::new([0; 32]); T::ClusterVisitor::ensure_cluster(&cluster_id) .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; // Retrieve the respective bond size from Cluster Visitor - let bond_size = T::ClusterVisitor::get_bond_size(&cluster_id, &node_pub_key) - .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; + let bond_size = + T::ClusterVisitor::get_bond_size(&cluster_id, &NodePubKey::StoragePubKey(account)) + .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; ensure!( ledger.active >= bond_size.saturated_into::>(), Error::::InsufficientBond ); let stash = &ledger.stash; - // Check if stash is mapped to the node - let node_stash = >::get(&node_pub_key).ok_or(Error::::BadState)?; - ensure!(*stash == node_stash, Error::::NotNodeController); - // Can't participate in storage network if already participating in CDN. ensure!(!Edges::::contains_key(&stash), Error::::AlreadyInRole); diff --git a/pallets/ddc-staking/src/mock.rs b/pallets/ddc-staking/src/mock.rs index cf55112b7..cac16850e 100644 --- a/pallets/ddc-staking/src/mock.rs +++ b/pallets/ddc-staking/src/mock.rs @@ -124,6 +124,12 @@ impl ClusterVisitor for TestClusterVisitor { fn ensure_cluster(_cluster_id: &ClusterId) -> Result<(), ClusterVisitorError> { Ok(()) } + fn get_bond_size( + _cluster_id: &ClusterId, + _node_pub_key: &NodePubKey, + ) -> Result { + Ok(10) + } } pub struct ExtBuilder { has_edges: bool, From 9fccd392a123882dce31b9fe41df8667c17ebe6c Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Tue, 7 Nov 2023 16:56:37 +0100 Subject: [PATCH 3/5] change the param for getting bond size --- pallets/ddc-clusters/src/lib.rs | 9 ++++----- pallets/ddc-staking/src/lib.rs | 29 ++++++++++++----------------- pallets/ddc-staking/src/mock.rs | 2 +- traits/src/cluster.rs | 4 ++-- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/pallets/ddc-clusters/src/lib.rs b/pallets/ddc-clusters/src/lib.rs index 08f246e69..6bdf9fc84 100644 --- a/pallets/ddc-clusters/src/lib.rs +++ b/pallets/ddc-clusters/src/lib.rs @@ -19,7 +19,7 @@ use crate::{ cluster::{Cluster, ClusterError, ClusterGovParams, ClusterParams}, node_provider_auth::{NodeProviderAuthContract, NodeProviderAuthContractError}, }; -use ddc_primitives::{ClusterId, NodePubKey}; +use ddc_primitives::{ClusterId, NodePubKey, NodeType}; use ddc_traits::{ cluster::{ClusterVisitor, ClusterVisitorError}, staking::{StakingVisitor, StakingVisitorError}, @@ -251,17 +251,16 @@ pub mod pallet { fn get_bond_size( cluster_id: &ClusterId, - node_pub_key: &NodePubKey, + node_pub_key: NodeType, ) -> Result { // ensure!(ClustersNodes::::contains_key(cluster_id), // Error::::ClusterDoesNotExist); let cluster_gov_params = ClustersGovParams::::try_get(cluster_id) .map_err(|_| ClusterVisitorError::ClusterGovParamsNotSet)?; match node_pub_key { - NodePubKey::StoragePubKey(_node_pub_key) => + NodeType::Storage => Ok(cluster_gov_params.storage_bond_size.saturated_into::()), - NodePubKey::CDNPubKey(_node_pub_key) => - Ok(cluster_gov_params.cdn_bond_size.saturated_into::()), + NodeType::CDN => Ok(cluster_gov_params.cdn_bond_size.saturated_into::()), } } } diff --git a/pallets/ddc-staking/src/lib.rs b/pallets/ddc-staking/src/lib.rs index 58bfa5b9b..6ef7d34af 100644 --- a/pallets/ddc-staking/src/lib.rs +++ b/pallets/ddc-staking/src/lib.rs @@ -29,7 +29,7 @@ pub mod weights; use crate::weights::WeightInfo; use codec::{Decode, Encode, HasCompact}; -pub use ddc_primitives::{ClusterId, NodePubKey}; +pub use ddc_primitives::{ClusterId, NodePubKey, NodeType}; use ddc_traits::{ cluster::{ClusterVisitor, ClusterVisitorError}, staking::{StakingVisitor, StakingVisitorError}, @@ -49,7 +49,7 @@ use frame_system::pallet_prelude::*; use scale_info::TypeInfo; use sp_runtime::{ traits::{AccountIdConversion, AtLeast32BitUnsigned, Saturating, StaticLookup, Zero}, - AccountId32, RuntimeDebug, SaturatedConversion, + RuntimeDebug, SaturatedConversion, }; use sp_staking::EraIndex; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; @@ -592,7 +592,6 @@ pub mod pallet { pub fn unbond( origin: OriginFor, #[pallet::compact] value: BalanceOf, - node_pub_key: NodePubKey, ) -> DispatchResult { let controller = ensure_signed(origin)?; let mut ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; @@ -612,15 +611,15 @@ pub mod pallet { ledger.active = Zero::zero(); } - // Check if stash is mapped to the node - let node_stash = >::get(&node_pub_key).ok_or(Error::::BadState)?; - ensure!(ledger.stash.clone() == node_stash, Error::::NotNodeController); - let min_active_bond = if let Some(cluster_id) = Self::edges(&ledger.stash) { - // Retrieve the respective bond size from Cluster Visitor - let bond_size = T::ClusterVisitor::get_bond_size(&cluster_id, &node_pub_key) + let bond_size = T::ClusterVisitor::get_bond_size(&cluster_id, NodeType::CDN) .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; bond_size.saturated_into::>() + } else if let Some(cluster_id) = Self::storages(&ledger.stash) { + let bond_size = + T::ClusterVisitor::get_bond_size(&cluster_id, NodeType::Storage) + .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; + bond_size.saturated_into::>() } else { Zero::zero() }; @@ -702,16 +701,14 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::serve())] pub fn serve(origin: OriginFor, cluster_id: ClusterId) -> DispatchResult { let controller = ensure_signed(origin)?; - let account = AccountId32::new([0; 32]); T::ClusterVisitor::ensure_cluster(&cluster_id) .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; // Retrieve the respective bond size from Cluster Visitor - let bond_size = - T::ClusterVisitor::get_bond_size(&cluster_id, &NodePubKey::CDNPubKey(account)) - .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; + let bond_size = T::ClusterVisitor::get_bond_size(&cluster_id, NodeType::CDN) + .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; ensure!( ledger.active >= bond_size.saturated_into::>(), @@ -745,16 +742,14 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::store())] pub fn store(origin: OriginFor, cluster_id: ClusterId) -> DispatchResult { let controller = ensure_signed(origin)?; - let account = AccountId32::new([0; 32]); T::ClusterVisitor::ensure_cluster(&cluster_id) .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; // Retrieve the respective bond size from Cluster Visitor - let bond_size = - T::ClusterVisitor::get_bond_size(&cluster_id, &NodePubKey::StoragePubKey(account)) - .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; + let bond_size = T::ClusterVisitor::get_bond_size(&cluster_id, NodeType::Storage) + .map_err(|e| Into::>::into(ClusterVisitorError::from(e)))?; ensure!( ledger.active >= bond_size.saturated_into::>(), Error::::InsufficientBond diff --git a/pallets/ddc-staking/src/mock.rs b/pallets/ddc-staking/src/mock.rs index cac16850e..0035892f9 100644 --- a/pallets/ddc-staking/src/mock.rs +++ b/pallets/ddc-staking/src/mock.rs @@ -126,7 +126,7 @@ impl ClusterVisitor for TestClusterVisitor { } fn get_bond_size( _cluster_id: &ClusterId, - _node_pub_key: &NodePubKey, + _node_pub_key: NodeType, ) -> Result { Ok(10) } diff --git a/traits/src/cluster.rs b/traits/src/cluster.rs index 505de5298..e7036df66 100644 --- a/traits/src/cluster.rs +++ b/traits/src/cluster.rs @@ -1,4 +1,4 @@ -use ddc_primitives::{ClusterId, NodePubKey}; +use ddc_primitives::{ClusterId, NodePubKey, NodeType}; use frame_system::Config; pub trait ClusterVisitor { @@ -8,7 +8,7 @@ pub trait ClusterVisitor { fn get_bond_size( cluster_id: &ClusterId, - node_pub_key: &NodePubKey, + node_pub_key: NodeType, ) -> Result; } From c6522e113d6cb74b27aaf9abcd659e417e710d0e Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Tue, 7 Nov 2023 17:15:23 +0100 Subject: [PATCH 4/5] rename param node_pub_key to node_type --- pallets/ddc-clusters/src/lib.rs | 2 +- pallets/ddc-staking/src/mock.rs | 2 +- traits/src/cluster.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/ddc-clusters/src/lib.rs b/pallets/ddc-clusters/src/lib.rs index 6bdf9fc84..0ed7c0e78 100644 --- a/pallets/ddc-clusters/src/lib.rs +++ b/pallets/ddc-clusters/src/lib.rs @@ -251,7 +251,7 @@ pub mod pallet { fn get_bond_size( cluster_id: &ClusterId, - node_pub_key: NodeType, + node_type: NodeType, ) -> Result { // ensure!(ClustersNodes::::contains_key(cluster_id), // Error::::ClusterDoesNotExist); diff --git a/pallets/ddc-staking/src/mock.rs b/pallets/ddc-staking/src/mock.rs index 0035892f9..f009fec41 100644 --- a/pallets/ddc-staking/src/mock.rs +++ b/pallets/ddc-staking/src/mock.rs @@ -126,7 +126,7 @@ impl ClusterVisitor for TestClusterVisitor { } fn get_bond_size( _cluster_id: &ClusterId, - _node_pub_key: NodeType, + _node_type: NodeType, ) -> Result { Ok(10) } diff --git a/traits/src/cluster.rs b/traits/src/cluster.rs index e7036df66..99cd8be6b 100644 --- a/traits/src/cluster.rs +++ b/traits/src/cluster.rs @@ -8,7 +8,7 @@ pub trait ClusterVisitor { fn get_bond_size( cluster_id: &ClusterId, - node_pub_key: NodeType, + node_type: NodeType, ) -> Result; } From 24bb2ea4c23c8f0b716fd71a30dc5fbc681a9c21 Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Tue, 7 Nov 2023 17:19:09 +0100 Subject: [PATCH 5/5] fix small bug --- pallets/ddc-clusters/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/ddc-clusters/src/lib.rs b/pallets/ddc-clusters/src/lib.rs index 0ed7c0e78..6a7c0549b 100644 --- a/pallets/ddc-clusters/src/lib.rs +++ b/pallets/ddc-clusters/src/lib.rs @@ -257,7 +257,7 @@ pub mod pallet { // Error::::ClusterDoesNotExist); let cluster_gov_params = ClustersGovParams::::try_get(cluster_id) .map_err(|_| ClusterVisitorError::ClusterGovParamsNotSet)?; - match node_pub_key { + match node_type { NodeType::Storage => Ok(cluster_gov_params.storage_bond_size.saturated_into::()), NodeType::CDN => Ok(cluster_gov_params.cdn_bond_size.saturated_into::()),