From bc911e686031cef58c160eb81cc885314913a2e0 Mon Sep 17 00:00:00 2001 From: librelois <c@elo.tf> Date: Mon, 11 Apr 2022 20:56:54 +0200 Subject: [PATCH] fix(chain-spec): gen genesis: ensure genesis smiths have balance --- node/src/chain_spec/gen_genesis_data.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/node/src/chain_spec/gen_genesis_data.rs b/node/src/chain_spec/gen_genesis_data.rs index f799b081f..f9c03b1ee 100644 --- a/node/src/chain_spec/gen_genesis_data.rs +++ b/node/src/chain_spec/gen_genesis_data.rs @@ -21,6 +21,8 @@ use std::collections::BTreeMap; type MembershipData = sp_membership::MembershipData<u32>; +const EXISTENTIAL_DEPOSIT: u64 = 100; + #[derive(Clone)] pub struct GenesisData<Parameters: DeserializeOwned, SessionKeys: Decode> { pub accounts: BTreeMap<AccountId, GenesisAccountData<u64>>, @@ -172,7 +174,7 @@ where } // Money - let balance = if identity.balance >= 100 { + let balance = if identity.balance >= EXISTENTIAL_DEPOSIT { identity.balance } else { //total_dust += identity.balance; @@ -242,6 +244,13 @@ where .get(&idty_name) .ok_or(format!("Identity '{}' not exist", &idty_name))?; + if identity.balance < EXISTENTIAL_DEPOSIT { + return Err(format!( + "Identity '{}' have balance '{}' < EXISTENTIAL_DEPOSIT", + idty_name, identity.balance, + )); + } + // Initial authorities initial_authorities.insert(*idty_index, (identity.pubkey.clone(), smith_data.authority)); -- GitLab