500M SOL (bp #7361) (#7365)

automerge
This commit is contained in:
mergify[bot]
2019-12-08 15:37:25 -08:00
committed by Grimes
parent 569d0ccb4d
commit 9d0cb47367
2 changed files with 35 additions and 26 deletions

View File

@ -3,7 +3,10 @@ use crate::{
unlocks::UnlockInfo, unlocks::UnlockInfo,
validators::{create_and_add_validator, ValidatorInfo}, validators::{create_and_add_validator, ValidatorInfo},
}; };
use solana_sdk::{genesis_config::GenesisConfig, native_token::sol_to_lamports}; use solana_sdk::{
genesis_config::GenesisConfig,
native_token::{lamports_to_sol, sol_to_lamports},
};
// 30 month schedule is 1/5th every 6 months for 30 months // 30 month schedule is 1/5th every 6 months for 30 months
const UNLOCKS_BY_FIFTHS_FOR_30_MONTHS: UnlockInfo = UnlockInfo { const UNLOCKS_BY_FIFTHS_FOR_30_MONTHS: UnlockInfo = UnlockInfo {
@ -11,7 +14,7 @@ const UNLOCKS_BY_FIFTHS_FOR_30_MONTHS: UnlockInfo = UnlockInfo {
cliff_years: 0.5, cliff_years: 0.5,
unlocks: 4, unlocks: 4,
unlock_years: 0.5, unlock_years: 0.5,
custodian: "11111111111111111111111111111111", custodian: "6LnFgiECFQKUcxNYDvUBMxgjeGQzzy4kgxGhantoxfUe",
}; };
// 60 month schedule is 1/10th every 6 months for 60 months // 60 month schedule is 1/10th every 6 months for 60 months
//const UNLOCKS_BY_TENTHS_FOR_60_MONTHS: UnlockInfo = UnlockInfo { //const UNLOCKS_BY_TENTHS_FOR_60_MONTHS: UnlockInfo = UnlockInfo {
@ -156,11 +159,6 @@ pub const POOL_STAKER_INFOS: &[StakerInfo] = &[
staker: "4h1rt2ic4AXwG7p3Qqhw57EMDD4c3tLYb5J3QstGA2p5", staker: "4h1rt2ic4AXwG7p3Qqhw57EMDD4c3tLYb5J3QstGA2p5",
sol: 153_333_633.41, sol: 153_333_633.41,
}, },
StakerInfo {
name: "one thanks",
staker: "3b7akieYUyCgz3Cwt5sTSErMWjg8NEygD6mbGjhGkduB",
sol: 178_699_925.59,
},
StakerInfo { StakerInfo {
name: "lyrical supermarket", name: "lyrical supermarket",
staker: "GRZwoJGisLTszcxtWpeREJ98EGg8pZewhbtcrikoU7b3", staker: "GRZwoJGisLTszcxtWpeREJ98EGg8pZewhbtcrikoU7b3",
@ -386,8 +384,11 @@ fn add_spare_validators(genesis_config: &mut GenesisConfig) -> u64 {
.sum::<u64>() .sum::<u64>()
} }
pub fn add_genesis_accounts(genesis_config: &mut GenesisConfig) -> u64 { pub fn add_genesis_accounts(genesis_config: &mut GenesisConfig, mut issued_lamports: u64) {
add_stakes( // add_stakes() and add_validators() award tokens for rent exemption and
// to cover an initial transfer-free period of the network
issued_lamports += add_stakes(
genesis_config, genesis_config,
&BATCH_FOUR_STAKER_INFOS, &BATCH_FOUR_STAKER_INFOS,
&UNLOCKS_BY_FIFTHS_FOR_30_MONTHS, &UNLOCKS_BY_FIFTHS_FOR_30_MONTHS,
@ -398,7 +399,19 @@ pub fn add_genesis_accounts(genesis_config: &mut GenesisConfig) -> u64 {
&UNLOCKS_BY_TENTHS_FOR_60_MONTHS, &UNLOCKS_BY_TENTHS_FOR_60_MONTHS,
sol_to_lamports(1_000_000.0), sol_to_lamports(1_000_000.0),
) + add_validators(genesis_config, &VALIDATOR_INFOS) ) + add_validators(genesis_config, &VALIDATOR_INFOS)
+ add_spare_validators(genesis_config) + add_spare_validators(genesis_config);
// "one thanks" gets 500_000_000SOL (total) - above distributions
create_and_add_stakes(
genesis_config,
&StakerInfo {
name: "one thanks",
staker: "3b7akieYUyCgz3Cwt5sTSErMWjg8NEygD6mbGjhGkduB",
sol: 500_000_000.0 - lamports_to_sol(issued_lamports),
},
&UNLOCKS_BY_TENTHS_FOR_60_MONTHS,
sol_to_lamports(1_000_000.0),
);
} }
#[cfg(test)] #[cfg(test)]
@ -409,24 +422,14 @@ mod tests {
fn test_add_genesis_accounts() { fn test_add_genesis_accounts() {
let mut genesis_config = GenesisConfig::default(); let mut genesis_config = GenesisConfig::default();
let bootstrap_lamports = genesis_config add_genesis_accounts(&mut genesis_config, 0);
.accounts
.iter()
.map(|(_, account)| account.lamports)
.sum::<u64>();
let issued_lamports = add_genesis_accounts(&mut genesis_config);
let lamports = genesis_config let lamports = genesis_config
.accounts .accounts
.iter() .iter()
.map(|(_, account)| account.lamports) .map(|(_, account)| account.lamports)
.sum::<u64>(); .sum::<u64>();
// tolerate rounding errors, less than one part in 10M
assert_eq!(issued_lamports, lamports); assert!((500_000_000.0 - lamports_to_sol(lamports)).abs() < lamports_to_sol(100));
let num_spare_validators = 42;
let rent_fees = 2 * (VALIDATOR_INFOS.len() + num_spare_validators) as u64; // TODO: Need a place to pay rent from.
let expected_lamports = 500_000_000_000_000_000 - bootstrap_lamports + rent_fees;
assert_eq!(lamports, expected_lamports);
} }
} }

View File

@ -322,7 +322,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
) )
.get_matches(); .get_matches();
let faucet_lamports = value_t!(matches, "faucet_lamports", u64); let faucet_lamports = value_t!(matches, "faucet_lamports", u64).unwrap_or(0);
let ledger_path = PathBuf::from(matches.value_of("ledger_path").unwrap()); let ledger_path = PathBuf::from(matches.value_of("ledger_path").unwrap());
let bootstrap_leader_lamports = value_t_or_exit!(matches, "bootstrap_leader_lamports", u64); let bootstrap_leader_lamports = value_t_or_exit!(matches, "bootstrap_leader_lamports", u64);
let bootstrap_leader_stake_lamports = let bootstrap_leader_stake_lamports =
@ -447,7 +447,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
if let Some(faucet_pubkey) = faucet_pubkey { if let Some(faucet_pubkey) = faucet_pubkey {
genesis_config.add_account( genesis_config.add_account(
faucet_pubkey, faucet_pubkey,
Account::new(faucet_lamports.unwrap(), 0, &system_program::id()), Account::new(faucet_lamports, 0, &system_program::id()),
); );
} }
@ -461,7 +461,13 @@ fn main() -> Result<(), Box<dyn error::Error>> {
} }
} }
add_genesis_accounts(&mut genesis_config); let issued_lamports = genesis_config
.accounts
.iter()
.map(|(_key, account)| account.lamports)
.sum::<u64>();
add_genesis_accounts(&mut genesis_config, issued_lamports - faucet_lamports);
create_new_ledger(&ledger_path, &genesis_config)?; create_new_ledger(&ledger_path, &genesis_config)?;