Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove certain endowed accounts from chain #819

Merged
merged 4 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion node/cli/src/chain_spec/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn development_genesis_config(
root_key: AccountId,
threshold_server_endpoints: Vec<&str>,
) -> serde_json::Value {
let (mut endowed_accounts, funded_accounts) = endowed_accounts_dev();
let (mut endowed_accounts, funded_accounts) = endowed_accounts_dev(false);
// endow all authorities and nominators.
initial_authorities.iter().map(|x| &x.0).chain(initial_nominators.iter()).for_each(|x| {
if !endowed_accounts.contains(x) {
Expand Down
2 changes: 1 addition & 1 deletion node/cli/src/chain_spec/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn integration_tests_genesis_config(
initial_nominators: Vec<AccountId>,
root_key: AccountId,
) -> serde_json::Value {
let (mut endowed_accounts, funded_accounts) = endowed_accounts_dev();
let (mut endowed_accounts, funded_accounts) = endowed_accounts_dev(false);
// endow all authorities and nominators.
initial_authorities.iter().map(|x| &x.0).chain(initial_nominators.iter()).for_each(|x| {
if !endowed_accounts.contains(x) {
Expand Down
2 changes: 1 addition & 1 deletion node/cli/src/chain_spec/testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ pub fn testnet_genesis_config(
"Each validator node needs to have an accompanying threshold server."
);

let (mut endowed_accounts, mut funded_accounts) = endowed_accounts_dev();
let (mut endowed_accounts, mut funded_accounts) = endowed_accounts_dev(true);

// Ensure that the `testnet-local` config doesn't have a duplicate balance since `Alice` is
// both a validator and root.
Expand Down
47 changes: 25 additions & 22 deletions node/cli/src/endowed_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct AddressStruct {
name: String,
}

pub fn endowed_accounts_dev() -> (Vec<AccountId>, Vec<AccountId>) {
pub fn endowed_accounts_dev(is_prod: bool) -> (Vec<AccountId>, Vec<AccountId>) {
// handle user submitted file for tokens
let mut externally_endowed_accounts: Vec<AddressStruct> = Vec::new();
let project_root = get_project_root();
Expand All @@ -40,28 +40,31 @@ pub fn endowed_accounts_dev() -> (Vec<AccountId>, Vec<AccountId>) {
serde_json::from_str(&data).expect("JSON parse error");
externally_endowed_accounts.append(&mut incoming_accounts)
};
let mut inital_accounts = vec![];
if !is_prod {
inital_accounts = vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("One"),
get_account_id_from_seed::<sr25519::Public>("Two"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
get_account_id_from_seed::<sr25519::Public>("One//stash"),
get_account_id_from_seed::<sr25519::Public>("Two//stash"),
crate::chain_spec::tss_account_id::ALICE.clone(),
crate::chain_spec::tss_account_id::BOB.clone(),
crate::chain_spec::tss_account_id::CHARLIE.clone(),
];
}

let inital_accounts = vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("One"),
get_account_id_from_seed::<sr25519::Public>("Two"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
get_account_id_from_seed::<sr25519::Public>("One//stash"),
get_account_id_from_seed::<sr25519::Public>("Two//stash"),
crate::chain_spec::tss_account_id::ALICE.clone(),
crate::chain_spec::tss_account_id::BOB.clone(),
crate::chain_spec::tss_account_id::CHARLIE.clone(),
];
let mut funded_accounts = inital_accounts.clone();
for address in externally_endowed_accounts {
funded_accounts.push(AccountId::from_string(&address.address).unwrap_or_else(|_| {
Expand Down