Skip to content

Commit

Permalink
Use lamports in genesis (solana-labs#7631)
Browse files Browse the repository at this point in the history
* Use lamports in genesis

* readability
  • Loading branch information
rob-solana authored Dec 28, 2019
1 parent 44e45aa commit e0564f6
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 71 deletions.
95 changes: 46 additions & 49 deletions genesis/src/genesis_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ use crate::{
unlocks::UnlockInfo,
validators::{create_and_add_validator, ValidatorInfo},
};
use solana_sdk::{
genesis_config::GenesisConfig,
native_token::{lamports_to_sol, sol_to_lamports},
};
use solana_sdk::{genesis_config::GenesisConfig, native_token::SOL_LAMPORTS};

// 30 month schedule is 1/5th every 6 months for 30 months
const UNLOCKS_BY_FIFTHS_FOR_30_MONTHS: UnlockInfo = UnlockInfo {
Expand Down Expand Up @@ -39,151 +36,151 @@ pub const BATCH_FOUR_STAKER_INFOS: &[StakerInfo] = &[
StakerInfo {
name: "impossible pizza",
staker: "CDtJpwRSiPRDGeKrvymWQKM7JY9M3hU7iimEKBDxZyoP",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "wretched texture",
staker: "HbENu65qjWLEB5TrMouSSWLq9mbtGx2bvfhPjk2FpYek",
sol: 225_000.0,
lamports: 225_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "nutritious examination",
staker: "C9CfFpmLDsQsz6wt7MrrZquNB5oS4QkpJkmDAiboVEZZ",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "tidy impression",
staker: "6ne6Rbag4FAnop1KNgVdM1SEHnJEysHSWyqvRpFrzaig",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "unbecoming silver",
staker: "42yapY7Vrs5jqht9TCKZsPoyb4vDFYcPfRkqAP85NSAQ",
sol: 28_800.0,
lamports: 28_800 * SOL_LAMPORTS,
},
StakerInfo {
name: "dramatic treatment",
staker: "GTyawCMwt3kMb51AgDtfdp97mDot7jNwc8ifuS9qqANg",
sol: 1_205_602.0,
lamports: 1_205_602 * SOL_LAMPORTS,
},
StakerInfo {
name: "angry noise",
staker: "Fqxs9MhqjKuMq6YwjBG4ktEapuZQ3kj19mpuHLZKtkg9",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "hard cousin",
staker: "9MYDzj7QuAX9QAK7da1GhzPB4gA3qbPNWsW3MMSZobru",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "inexpensive uncle",
staker: "E4DLNkmdL34ejA48ApfPDoFVuD9XWAFqi8bXzBGRhKst",
sol: 300_000.0,
lamports: 300_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "lopsided skill",
staker: "8cV7zCTF5UMrZakZXiL2Jw5uY3ms2Wz4twzFXEY9Kge2",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "red snake",
staker: "JBGnGdLyo7V2z9hz51mnnbyDp9sBACtw5WYH9YRG8n7e",
sol: 3_655_292.0,
lamports: 3_655_292 * SOL_LAMPORTS,
},
StakerInfo {
name: "hellish money",
staker: "CqKdQ57mBj2mKcAbpjWc28Ls7yXzBXboxSTCRWocmUVj",
sol: 200_000.0,
lamports: 200_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "full grape",
staker: "2SCJKvh7wWo32PtfUZdVZQ84WnMWoUpF4WTm6ZxcCJ15",
sol: 450_000.0,
lamports: 450_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "nice ghost",
staker: "FeumxB3gfzrVQzABBiha8AacKPY3Rf4BTFSh2aZWHqR8",
sol: 650_000.0,
lamports: 650_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "jolly year",
staker: "HBwFWNGPVZgkf3yqUKxuAds5aANGWX62LzUFvZVCWLdJ",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "typical initiative",
staker: "3JMz3kaDUZEVK2JVjRqwERGMp7LbWbgUjAFBb42qxoHb",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "deserted window",
staker: "XTeBBZextvHkoRqDF8yb4hihjcraKQDwTEXhzjd8fip",
sol: 3_655_292.0,
lamports: 3_655_292 * SOL_LAMPORTS,
},
StakerInfo {
name: "eight nation",
staker: "E5bSU5ywqPiz3ije89ef5gaEC7jy81BAc72Zeb9MqeHY",
sol: 103_519.0,
lamports: 103_519 * SOL_LAMPORTS,
},
StakerInfo {
name: "earsplitting meaning",
staker: "4ZemkSoE75RFE1SVLnnmHcaNWT4qN8KFrKP2wAYfv8CB",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "alike cheese",
staker: "72BGEwYee5txFonmpEarTEKCZVN2UxcSUgdphdhcx3V",
sol: 3_880_295.0,
lamports: 3_880_295 * SOL_LAMPORTS,
},
StakerInfo {
name: "noisy honey",
staker: "DRp1Scyn4yJZQfMAdQew2x8RtvRmsNELN37JTK5Xvzgn",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
];

pub const FOUNDATION_STAKER_INFOS: &[StakerInfo] = &[
StakerInfo {
name: "lyrical supermarket",
staker: "GRZwoJGisLTszcxtWpeREJ98EGg8pZewhbtcrikoU7b3",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "frequent description",
staker: "J51tinoLdmEdUR27LUVymrb2LB3xQo1aSHSgmbSGdj58",
sol: 57_500_000.0,
lamports: 57_500_000 * SOL_LAMPORTS,
},
];

pub const GRANTS_STAKER_INFOS: &[StakerInfo] = &[
StakerInfo {
name: "rightful agreement",
staker: "DNaKiBwwbbqk1wVoC5AQxWQbuDhvaDVbAtXzsVos9mrc",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "tasty location",
staker: "HvXQPXAijjG1vnQs6HXVtUUtFVzi5HNgXV9LGnHvYF85",
sol: 15_000_000.0,
lamports: 15_000_000 * SOL_LAMPORTS,
},
];

pub const COMMUNITY_STAKER_INFOS: &[StakerInfo] = &[
StakerInfo {
name: "shrill charity",
staker: "BzuqQFnu7oNUeok9ZoJezpqu2vZJU7XR1PxVLkk6wwUD",
sol: 5_000_000.0,
lamports: 5_000_000 * SOL_LAMPORTS,
},
StakerInfo {
name: "legal gate",
staker: "FwMbkDZUb78aiMWhZY4BEroAcqmnrXZV77nwrg71C57d",
sol: 16_086_641.0,
lamports: 16_086_641 * SOL_LAMPORTS,
},
StakerInfo {
name: "cluttered complaint",
staker: "4h1rt2ic4AXwG7p3Qqhw57EMDD4c3tLYb5J3QstGA2p5",
sol: 153_333_633.41,
lamports: 153_333_633 * SOL_LAMPORTS + 41 * SOL_LAMPORTS / 100,
},
];

Expand All @@ -206,70 +203,70 @@ pub const VALIDATOR_INFOS: &[ValidatorInfo] = &[
name: "01Node",
node: "5n8KCdzqtvTnhkvCrFR7errH6ZUp11kL97r2awXkfzFe",
vote: "4uYMbY5Ae5ZSRNxQ3RWVyXS9rzW7E3AMZYHuUEotxu6K",
node_sol: 500.0,
node_lamports: 500 * SOL_LAMPORTS,
commission: 0,
},
ValidatorInfo {
name: "Bison Trails",
node: "7suRNpX7bJsXphHJtBv4ZsLjJZ1dTGeX256pLqJZdEAm",
vote: "DfirEZ9Up1xbE7sQji9UwtcRGe5uCcRqQtnaGpha5KNY",
node_sol: 500.0,
node_lamports: 500 * SOL_LAMPORTS,
commission: 0,
},
ValidatorInfo {
name: "ChainFlow",
node: "2te46rxywMdCNdkvjumiBBPQoVczJFxhxEaxFavQNqe3",
vote: "8bRCnytB7bySmqxodNGbZuUAtncKkB8T733DD1Dm9WMb",
node_sol: 500.0,
node_lamports: 500 * SOL_LAMPORTS,
commission: 0,
},
ValidatorInfo {
name: "ChorusOne",
node: "ChorusXqjLC2NbiStKR6k9WoD7wu6TVTtFG8qCL5XBVa",
vote: "ChorusvBuPwukqgDvYfWtEg8j4T1NcMgSTQ4b1UbAwgQ",
node_sol: 500.0,
node_lamports: 500 * SOL_LAMPORTS,
commission: 0,
},
ValidatorInfo {
name: "Dokia Capital",
node: "GeZ5PrJi9muVCJiJAaFBNGoCEdxGEqTp7L2BmT2WTTy1",
vote: "7ZdRx2EBYoRuPfyeoNbuHodMUXcAQRcC37MUw3kP6akn",
node_sol: 500.0,
node_lamports: 500 * SOL_LAMPORTS,
commission: 0,
},
ValidatorInfo {
name: "Forbole",
node: "Fe5sLQAAT7RBT8mcH1AAGCbExJQcYxcwXvp1GjrGbvxs",
vote: "Dr8MkZZuvZVQJFKtjShZYEfg6n93sc1GxevqLnGss7FW",
node_sol: 500.0,
node_lamports: 500 * SOL_LAMPORTS,
commission: 0,
},
ValidatorInfo {
name: "P2P.ORG - Secure Non-custodial Staking",
node: "44e8VyWoyZSE2oYHxMHMedAiHkGJqJgPd3tdt6iKoAFL",
vote: "BwwpzEpo1wzgV9N1987ntgNG6jLt3C9532C68pswT7Gp",
node_sol: 500.0,
node_lamports: 500 * SOL_LAMPORTS,
commission: 0,
},
ValidatorInfo {
name: "RockX",
node: "Ez4iUU87ViJLCnmSy1t1Ti3DLoysFXiBseNfnRfoehyY",
vote: "GUdGALCHQBeqkNc2ZAht3tBXab1N5u9qJC3PAzpL54r7",
node_sol: 500.0,
node_lamports: 500 * SOL_LAMPORTS,
commission: 0,
},
ValidatorInfo {
name: "Stake Capital",
node: "HavuVVDXXsJqMzPwQ4KcF5kFm2xqjbChhyi1bgGeCQif",
vote: "HswPkKj1xoLLmpM8t1vy5Pbi8zYYUs9ZawswvofKsFo1",
node_sol: 500.0,
node_lamports: 500 * SOL_LAMPORTS,
commission: 0,
},
ValidatorInfo {
name: "Staking Facilities",
node: "pbAxyqHHPMwgEjv8kmjGxysk9rhNtN7q22eAjReq6Hj",
vote: "4VZ3pJX19PpuGjoSB1qeN9sVQfrqgLVNg16is37adiFp",
node_sol: 500.0,
node_lamports: 500 * SOL_LAMPORTS,
commission: 0,
},
];
Expand All @@ -289,22 +286,22 @@ pub fn add_genesis_accounts(genesis_config: &mut GenesisConfig, mut issued_lampo
genesis_config,
&BATCH_FOUR_STAKER_INFOS,
&UNLOCKS_BY_FIFTHS_FOR_30_MONTHS,
sol_to_lamports(1_000_000.0),
1_000_000 * SOL_LAMPORTS,
) + add_stakes(
genesis_config,
&FOUNDATION_STAKER_INFOS,
&UNLOCKS_BY_TENTHS_FOR_60_MONTHS,
sol_to_lamports(1_000_000.0),
1_000_000 * SOL_LAMPORTS,
) + add_stakes(
genesis_config,
&GRANTS_STAKER_INFOS,
&UNLOCKS_BY_TENTHS_FOR_60_MONTHS,
sol_to_lamports(1_000_000.0),
1_000_000 * SOL_LAMPORTS,
) + add_stakes(
genesis_config,
&COMMUNITY_STAKER_INFOS,
&UNLOCKS_ALL_DAY_ZERO,
sol_to_lamports(1_000_000.0),
1_000_000 * SOL_LAMPORTS,
) + add_validators(genesis_config, &VALIDATOR_INFOS);

// "one thanks" (community pool) gets 500_000_000SOL (total) - above distributions
Expand All @@ -313,10 +310,10 @@ pub fn add_genesis_accounts(genesis_config: &mut GenesisConfig, mut issued_lampo
&StakerInfo {
name: "one thanks",
staker: "3b7akieYUyCgz3Cwt5sTSErMWjg8NEygD6mbGjhGkduB",
sol: 500_000_000.0 - lamports_to_sol(issued_lamports),
lamports: 500_000_000 * SOL_LAMPORTS - issued_lamports,
},
&UNLOCKS_ALL_DAY_ZERO,
sol_to_lamports(1_000_000.0),
1_000_000 * SOL_LAMPORTS,
);
}

Expand All @@ -336,6 +333,6 @@ mod tests {
.map(|(_, account)| account.lamports)
.sum::<u64>();

assert_eq!(500_000_000.0, lamports_to_sol(lamports));
assert_eq!(500_000_000 * SOL_LAMPORTS, lamports);
}
}
18 changes: 9 additions & 9 deletions genesis/src/stakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
unlocks::{UnlockInfo, Unlocks},
};
use solana_sdk::{
account::Account, clock::Slot, genesis_config::GenesisConfig, native_token::sol_to_lamports,
pubkey::Pubkey, system_program, timing::years_as_slots,
account::Account, clock::Slot, genesis_config::GenesisConfig, pubkey::Pubkey, system_program,
timing::years_as_slots,
};
use solana_stake_program::{
self,
Expand All @@ -16,7 +16,7 @@ use solana_stake_program::{
pub struct StakerInfo {
pub name: &'static str,
pub staker: &'static str,
pub sol: f64,
pub lamports: u64,
}

// lamports required to run staking operations for one year
Expand Down Expand Up @@ -54,7 +54,7 @@ pub fn create_and_add_stakes(
.parse::<Pubkey>()
.expect("invalid custodian");

let total_lamports = sol_to_lamports(staker_info.sol);
let total_lamports = staker_info.lamports;

// staker is a system account
let staker_rent_reserve = genesis_config.rent.minimum_balance(0).max(1);
Expand Down Expand Up @@ -154,7 +154,7 @@ pub fn create_and_add_stakes(
#[cfg(test)]
mod tests {
use super::*;
use solana_sdk::{native_token::lamports_to_sol, rent::Rent};
use solana_sdk::rent::Rent;

fn create_and_check_stakes(
genesis_config: &mut GenesisConfig,
Expand Down Expand Up @@ -241,7 +241,7 @@ mod tests {
&StakerInfo {
name: "fun",
staker: "P1aceHo1derPubkey11111111111111111111111111",
sol: lamports_to_sol(total_lamports),
lamports: total_lamports,
},
&UnlockInfo {
cliff_fraction: 0.5,
Expand All @@ -266,7 +266,7 @@ mod tests {
&StakerInfo {
name: "fun",
staker: "P1aceHo1derPubkey11111111111111111111111111",
sol: lamports_to_sol(total_lamports),
lamports: total_lamports,
},
&UnlockInfo {
cliff_fraction: 0.5,
Expand All @@ -291,7 +291,7 @@ mod tests {
&StakerInfo {
name: "fun",
staker: "P1aceHo1derPubkey11111111111111111111111111",
sol: lamports_to_sol(total_lamports),
lamports: total_lamports,
},
&UnlockInfo {
cliff_fraction: 0.5,
Expand All @@ -315,7 +315,7 @@ mod tests {
&StakerInfo {
name: "fun",
staker: "P1aceHo1derPubkey11111111111111111111111111",
sol: lamports_to_sol(total_lamports),
lamports: total_lamports,
},
&UnlockInfo {
cliff_fraction: 0.5,
Expand Down
Loading

0 comments on commit e0564f6

Please sign in to comment.