mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 04:09:23 +00:00
Localize stake into networks
Sets a stake requirement of 100k for Serai and Monero, as Serai doesn't have stake requirements and Monero isn't expected to see as much volume/institutional support as Bitcoin/Ethereum.
This commit is contained in:
@@ -55,8 +55,15 @@ fn testnet_genesis(
|
|||||||
},
|
},
|
||||||
|
|
||||||
validator_sets: ValidatorSetsConfig {
|
validator_sets: ValidatorSetsConfig {
|
||||||
stake: Amount(1_000_000 * 10_u64.pow(8)),
|
networks: serai_runtime::primitives::NETWORKS
|
||||||
networks: serai_runtime::primitives::NETWORKS.to_vec(),
|
.iter()
|
||||||
|
.map(|network| match network {
|
||||||
|
NetworkId::Serai => (NetworkId::Serai, Amount(100_000 * 10_u64.pow(8))),
|
||||||
|
NetworkId::Bitcoin => (NetworkId::Bitcoin, Amount(1_000_000 * 10_u64.pow(8))),
|
||||||
|
NetworkId::Ethereum => (NetworkId::Bitcoin, Amount(1_000_000 * 10_u64.pow(8))),
|
||||||
|
NetworkId::Monero => (NetworkId::Bitcoin, Amount(100_000 * 10_u64.pow(8))),
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
participants: validators.iter().map(|name| account_from_name(name)).collect(),
|
participants: validators.iter().map(|name| account_from_name(name)).collect(),
|
||||||
},
|
},
|
||||||
session: SessionConfig { keys: validators.iter().map(|name| session_key(*name)).collect() },
|
session: SessionConfig { keys: validators.iter().map(|name| session_key(*name)).collect() },
|
||||||
|
|||||||
@@ -29,13 +29,12 @@ pub mod pallet {
|
|||||||
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)]
|
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)]
|
||||||
pub struct GenesisConfig<T: Config> {
|
pub struct GenesisConfig<T: Config> {
|
||||||
/// Stake requirement to join the initial validator sets.
|
/// Stake requirement to join the initial validator sets.
|
||||||
|
|
||||||
|
/// Networks to spawn Serai with, and the stake requirement per key share.
|
||||||
///
|
///
|
||||||
/// Every participant at genesis will automatically be assumed to have this much stake.
|
/// Every participant at genesis will automatically be assumed to have this much stake.
|
||||||
/// This stake cannot be withdrawn however as there's no actual stake behind it.
|
/// This stake cannot be withdrawn however as there's no actual stake behind it.
|
||||||
// TODO: Localize stake to network
|
pub networks: Vec<(NetworkId, Amount)>,
|
||||||
pub stake: Amount,
|
|
||||||
/// Networks to spawn Serai with.
|
|
||||||
pub networks: Vec<NetworkId>,
|
|
||||||
/// List of participants to place in the initial validator sets.
|
/// List of participants to place in the initial validator sets.
|
||||||
pub participants: Vec<T::AccountId>,
|
pub participants: Vec<T::AccountId>,
|
||||||
}
|
}
|
||||||
@@ -43,7 +42,6 @@ pub mod pallet {
|
|||||||
impl<T: Config> Default for GenesisConfig<T> {
|
impl<T: Config> Default for GenesisConfig<T> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
GenesisConfig {
|
GenesisConfig {
|
||||||
stake: Amount(1),
|
|
||||||
networks: Default::default(),
|
networks: Default::default(),
|
||||||
participants: Default::default(),
|
participants: Default::default(),
|
||||||
}
|
}
|
||||||
@@ -327,10 +325,10 @@ pub mod pallet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for id in self.networks.clone() {
|
for (id, stake) in self.networks.clone() {
|
||||||
AllocationPerKeyShare::<T>::set(id, Some(self.stake));
|
AllocationPerKeyShare::<T>::set(id, Some(stake));
|
||||||
for participant in self.participants.clone() {
|
for participant in self.participants.clone() {
|
||||||
Pallet::<T>::set_allocation(id, participant, self.stake);
|
Pallet::<T>::set_allocation(id, participant, stake);
|
||||||
}
|
}
|
||||||
Pallet::<T>::new_set(id);
|
Pallet::<T>::new_set(id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user