use pubkeys in genesis (#6750)
This commit is contained in:
parent
67f636545a
commit
a1fe6265fd
|
@ -15,7 +15,7 @@ use solana_sdk::{
|
||||||
genesis_block::{GenesisBlock, OperatingMode},
|
genesis_block::{GenesisBlock, OperatingMode},
|
||||||
native_token::sol_to_lamports,
|
native_token::sol_to_lamports,
|
||||||
poh_config::PohConfig,
|
poh_config::PohConfig,
|
||||||
pubkey::Pubkey,
|
pubkey::{read_pubkey_file, Pubkey},
|
||||||
rent::Rent,
|
rent::Rent,
|
||||||
signature::{read_keypair_file, Keypair, KeypairUtil},
|
signature::{read_keypair_file, Keypair, KeypairUtil},
|
||||||
system_program, timing,
|
system_program, timing,
|
||||||
|
@ -30,30 +30,34 @@ pub enum AccountFileFormat {
|
||||||
Keypair,
|
Keypair,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_genesis_accounts(
|
fn pubkey_from_file(key_file: &str) -> Result<Pubkey, Box<dyn error::Error>> {
|
||||||
file: &str,
|
read_pubkey_file(key_file)
|
||||||
file_format: AccountFileFormat,
|
.or_else(|_| read_keypair_file(key_file).map(|keypair| keypair.pubkey()))
|
||||||
genesis_block: &mut GenesisBlock,
|
}
|
||||||
) -> io::Result<()> {
|
|
||||||
|
fn pubkey_from_str(key_str: &str) -> Result<Pubkey, Box<dyn error::Error>> {
|
||||||
|
Pubkey::from_str(key_str).or_else(|_| {
|
||||||
|
let bytes: Vec<u8> = serde_json::from_str(key_str)?;
|
||||||
|
let keypair = Keypair::from_bytes(&bytes)
|
||||||
|
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
|
||||||
|
Ok(keypair.pubkey())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_genesis_accounts(file: &str, genesis_block: &mut GenesisBlock) -> io::Result<()> {
|
||||||
let accounts_file = File::open(file.to_string())?;
|
let accounts_file = File::open(file.to_string())?;
|
||||||
|
|
||||||
let genesis_accounts: HashMap<String, Base64Account> =
|
let genesis_accounts: HashMap<String, Base64Account> =
|
||||||
serde_yaml::from_reader(accounts_file)
|
serde_yaml::from_reader(accounts_file)
|
||||||
.map_err(|err| io::Error::new(io::ErrorKind::Other, format!("{:?}", err)))?;
|
.map_err(|err| io::Error::new(io::ErrorKind::Other, format!("{:?}", err)))?;
|
||||||
|
|
||||||
for (account, account_details) in genesis_accounts {
|
for (key, account_details) in genesis_accounts {
|
||||||
let pubkey = match file_format {
|
let pubkey = pubkey_from_str(key.as_str()).map_err(|err| {
|
||||||
AccountFileFormat::Pubkey => Pubkey::from_str(account.as_str()).map_err(|err| {
|
io::Error::new(
|
||||||
io::Error::new(
|
io::ErrorKind::Other,
|
||||||
io::ErrorKind::Other,
|
format!("Invalid pubkey/keypair {}: {:?}", key, err),
|
||||||
format!("Invalid pubkey {}: {:?}", account, err),
|
)
|
||||||
)
|
})?;
|
||||||
})?,
|
|
||||||
AccountFileFormat::Keypair => {
|
|
||||||
let bytes: Vec<u8> = serde_json::from_str(account.as_str()).unwrap();
|
|
||||||
Keypair::from_bytes(&bytes).unwrap().pubkey()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let owner_program_id = Pubkey::from_str(account_details.owner.as_str()).map_err(|err| {
|
let owner_program_id = Pubkey::from_str(account_details.owner.as_str()).map_err(|err| {
|
||||||
io::Error::new(
|
io::Error::new(
|
||||||
|
@ -110,13 +114,13 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
.about(crate_description!())
|
.about(crate_description!())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("bootstrap_leader_keypair_file")
|
Arg::with_name("bootstrap_leader_pubkey_file")
|
||||||
.short("b")
|
.short("b")
|
||||||
.long("bootstrap-leader-keypair")
|
.long("bootstrap-leader-pubkey")
|
||||||
.value_name("BOOTSTRAP LEADER KEYPAIR")
|
.value_name("BOOTSTRAP LEADER PUBKEY")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("Path to file containing the bootstrap leader's keypair"),
|
.help("Path to file containing the bootstrap leader's pubkey"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("ledger_path")
|
Arg::with_name("ledger_path")
|
||||||
|
@ -138,7 +142,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
.help("Number of lamports to create in the mint"),
|
.help("Number of lamports to create in the mint"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("mint_keypair_file")
|
Arg::with_name("mint_pubkey_file")
|
||||||
.short("m")
|
.short("m")
|
||||||
.long("mint")
|
.long("mint")
|
||||||
.value_name("MINT")
|
.value_name("MINT")
|
||||||
|
@ -147,30 +151,30 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
.help("Path to file containing keys of the mint"),
|
.help("Path to file containing keys of the mint"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("bootstrap_vote_keypair_file")
|
Arg::with_name("bootstrap_vote_pubkey_file")
|
||||||
.short("s")
|
.short("s")
|
||||||
.long("bootstrap-vote-keypair")
|
.long("bootstrap-vote-pubkey")
|
||||||
.value_name("BOOTSTRAP VOTE KEYPAIR")
|
.value_name("BOOTSTRAP VOTE PUBKEY")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("Path to file containing the bootstrap leader's voting keypair"),
|
.help("Path to file containing the bootstrap leader's voting pubkey"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("bootstrap_stake_keypair_file")
|
Arg::with_name("bootstrap_stake_pubkey_file")
|
||||||
.short("k")
|
.short("k")
|
||||||
.long("bootstrap-stake-keypair")
|
.long("bootstrap-stake-pubkey")
|
||||||
.value_name("BOOTSTRAP STAKE KEYPAIR")
|
.value_name("BOOTSTRAP STAKE PUBKEY")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("Path to file containing the bootstrap leader's staking keypair"),
|
.help("Path to file containing the bootstrap leader's staking pubkey"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("bootstrap_storage_keypair_file")
|
Arg::with_name("bootstrap_storage_pubkey_file")
|
||||||
.long("bootstrap-storage-keypair")
|
.long("bootstrap-storage-pubkey")
|
||||||
.value_name("BOOTSTRAP STORAGE KEYPAIR")
|
.value_name("BOOTSTRAP STORAGE PUBKEY")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("Path to file containing the bootstrap leader's storage keypair"),
|
.help("Path to file containing the bootstrap leader's storage pubkey"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("bootstrap_leader_lamports")
|
Arg::with_name("bootstrap_leader_lamports")
|
||||||
|
@ -286,15 +290,9 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
.long("primordial-accounts-file")
|
.long("primordial-accounts-file")
|
||||||
.value_name("FILENAME")
|
.value_name("FILENAME")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
|
.multiple(true)
|
||||||
.help("The location of pubkey for primordial accounts and balance"),
|
.help("The location of pubkey for primordial accounts and balance"),
|
||||||
)
|
)
|
||||||
.arg(
|
|
||||||
Arg::with_name("primordial_keypairs_file")
|
|
||||||
.long("primordial-keypairs-file")
|
|
||||||
.value_name("FILENAME")
|
|
||||||
.takes_value(true)
|
|
||||||
.help("The location of keypairs for primordial accounts and balance"),
|
|
||||||
)
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("development")
|
Arg::with_name("development")
|
||||||
.long("dev")
|
.long("dev")
|
||||||
|
@ -302,33 +300,28 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
)
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
let bootstrap_leader_keypair_file = matches.value_of("bootstrap_leader_keypair_file").unwrap();
|
let bootstrap_leader_pubkey_file = matches.value_of("bootstrap_leader_pubkey_file").unwrap();
|
||||||
let bootstrap_vote_keypair_file = matches.value_of("bootstrap_vote_keypair_file").unwrap();
|
let bootstrap_vote_pubkey_file = matches.value_of("bootstrap_vote_pubkey_file").unwrap();
|
||||||
let bootstrap_stake_keypair_file = matches.value_of("bootstrap_stake_keypair_file").unwrap();
|
let bootstrap_stake_pubkey_file = matches.value_of("bootstrap_stake_pubkey_file").unwrap();
|
||||||
let bootstrap_storage_keypair_file =
|
let bootstrap_storage_pubkey_file = matches.value_of("bootstrap_storage_pubkey_file").unwrap();
|
||||||
matches.value_of("bootstrap_storage_keypair_file").unwrap();
|
let mint_pubkey_file = matches.value_of("mint_pubkey_file").unwrap();
|
||||||
let mint_keypair_file = matches.value_of("mint_keypair_file").unwrap();
|
|
||||||
let ledger_path = PathBuf::from(matches.value_of("ledger_path").unwrap());
|
let ledger_path = PathBuf::from(matches.value_of("ledger_path").unwrap());
|
||||||
let lamports = value_t_or_exit!(matches, "lamports", u64);
|
let lamports = value_t_or_exit!(matches, "lamports", u64);
|
||||||
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 =
|
||||||
value_t_or_exit!(matches, "bootstrap_leader_stake_lamports", u64);
|
value_t_or_exit!(matches, "bootstrap_leader_stake_lamports", u64);
|
||||||
|
|
||||||
let bootstrap_leader_keypair = read_keypair_file(bootstrap_leader_keypair_file)?;
|
let bootstrap_leader_pubkey = pubkey_from_file(bootstrap_leader_pubkey_file)?;
|
||||||
let bootstrap_vote_keypair = read_keypair_file(bootstrap_vote_keypair_file)?;
|
let bootstrap_vote_pubkey = pubkey_from_file(bootstrap_vote_pubkey_file)?;
|
||||||
let bootstrap_stake_keypair = read_keypair_file(bootstrap_stake_keypair_file)?;
|
let bootstrap_stake_pubkey = pubkey_from_file(bootstrap_stake_pubkey_file)?;
|
||||||
let bootstrap_storage_keypair = read_keypair_file(bootstrap_storage_keypair_file)?;
|
let bootstrap_storage_pubkey = pubkey_from_file(bootstrap_storage_pubkey_file)?;
|
||||||
let mint_keypair = read_keypair_file(mint_keypair_file)?;
|
let mint_pubkey = pubkey_from_file(mint_pubkey_file)?;
|
||||||
|
|
||||||
let bootstrap_leader_vote_account = vote_state::create_account(
|
let bootstrap_leader_vote_account =
|
||||||
&bootstrap_vote_keypair.pubkey(),
|
vote_state::create_account(&bootstrap_vote_pubkey, &bootstrap_leader_pubkey, 0, 1);
|
||||||
&bootstrap_leader_keypair.pubkey(),
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
);
|
|
||||||
let bootstrap_leader_stake_account = stake_state::create_account(
|
let bootstrap_leader_stake_account = stake_state::create_account(
|
||||||
&bootstrap_leader_keypair.pubkey(),
|
&bootstrap_leader_pubkey,
|
||||||
&bootstrap_vote_keypair.pubkey(),
|
&bootstrap_vote_pubkey,
|
||||||
&bootstrap_leader_vote_account,
|
&bootstrap_leader_vote_account,
|
||||||
bootstrap_leader_stake_lamports,
|
bootstrap_leader_stake_lamports,
|
||||||
);
|
);
|
||||||
|
@ -336,31 +329,19 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
let mut accounts = vec![
|
let mut accounts = vec![
|
||||||
// node needs an account to issue votes from
|
// node needs an account to issue votes from
|
||||||
(
|
(
|
||||||
bootstrap_leader_keypair.pubkey(),
|
bootstrap_leader_pubkey,
|
||||||
Account::new(bootstrap_leader_lamports, 0, &system_program::id()),
|
Account::new(bootstrap_leader_lamports, 0, &system_program::id()),
|
||||||
),
|
),
|
||||||
// where votes go to
|
// where votes go to
|
||||||
|
(bootstrap_vote_pubkey, bootstrap_leader_vote_account),
|
||||||
|
// bootstrap leader stake
|
||||||
|
(bootstrap_stake_pubkey, bootstrap_leader_stake_account),
|
||||||
(
|
(
|
||||||
bootstrap_vote_keypair.pubkey(),
|
bootstrap_storage_pubkey,
|
||||||
bootstrap_leader_vote_account,
|
storage_contract::create_validator_storage_account(bootstrap_leader_pubkey, 1),
|
||||||
),
|
|
||||||
// passive bootstrap leader stake
|
|
||||||
(
|
|
||||||
bootstrap_stake_keypair.pubkey(),
|
|
||||||
bootstrap_leader_stake_account,
|
|
||||||
),
|
|
||||||
(
|
|
||||||
bootstrap_storage_keypair.pubkey(),
|
|
||||||
storage_contract::create_validator_storage_account(
|
|
||||||
bootstrap_leader_keypair.pubkey(),
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
accounts.append(&mut create_genesis_accounts(
|
accounts.append(&mut create_genesis_accounts(&mint_pubkey, lamports));
|
||||||
&mint_keypair.pubkey(),
|
|
||||||
lamports,
|
|
||||||
));
|
|
||||||
|
|
||||||
let ticks_per_slot = value_t_or_exit!(matches, "ticks_per_slot", u64);
|
let ticks_per_slot = value_t_or_exit!(matches, "ticks_per_slot", u64);
|
||||||
let slots_per_epoch = value_t_or_exit!(matches, "slots_per_epoch", u64);
|
let slots_per_epoch = value_t_or_exit!(matches, "slots_per_epoch", u64);
|
||||||
|
@ -414,12 +395,10 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
..GenesisBlock::default()
|
..GenesisBlock::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(file) = matches.value_of("primordial_accounts_file") {
|
if let Some(files) = matches.values_of("primordial_accounts_file") {
|
||||||
add_genesis_accounts(file, AccountFileFormat::Pubkey, &mut genesis_block)?;
|
for file in files {
|
||||||
}
|
add_genesis_accounts(file, &mut genesis_block)?;
|
||||||
|
}
|
||||||
if let Some(file) = matches.value_of("primordial_keypairs_file") {
|
|
||||||
add_genesis_accounts(file, AccountFileFormat::Keypair, &mut genesis_block)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add genesis stuff from storage and stake
|
// add genesis stuff from storage and stake
|
||||||
|
@ -444,12 +423,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_append_primordial_accounts_to_genesis() {
|
fn test_append_primordial_accounts_to_genesis() {
|
||||||
// Test invalid file returns error
|
// Test invalid file returns error
|
||||||
assert!(add_genesis_accounts(
|
assert!(add_genesis_accounts("unknownfile", &mut GenesisBlock::default()).is_err());
|
||||||
"unknownfile",
|
|
||||||
AccountFileFormat::Pubkey,
|
|
||||||
&mut GenesisBlock::default()
|
|
||||||
)
|
|
||||||
.is_err());
|
|
||||||
|
|
||||||
let mut genesis_block = GenesisBlock::default();
|
let mut genesis_block = GenesisBlock::default();
|
||||||
|
|
||||||
|
@ -489,7 +463,6 @@ mod tests {
|
||||||
|
|
||||||
add_genesis_accounts(
|
add_genesis_accounts(
|
||||||
"test_append_primordial_accounts_to_genesis.yml",
|
"test_append_primordial_accounts_to_genesis.yml",
|
||||||
AccountFileFormat::Pubkey,
|
|
||||||
&mut genesis_block,
|
&mut genesis_block,
|
||||||
)
|
)
|
||||||
.expect("test_append_primordial_accounts_to_genesis.yml");
|
.expect("test_append_primordial_accounts_to_genesis.yml");
|
||||||
|
@ -562,7 +535,6 @@ mod tests {
|
||||||
|
|
||||||
add_genesis_accounts(
|
add_genesis_accounts(
|
||||||
"test_append_primordial_accounts_to_genesis.yml",
|
"test_append_primordial_accounts_to_genesis.yml",
|
||||||
AccountFileFormat::Pubkey,
|
|
||||||
&mut genesis_block,
|
&mut genesis_block,
|
||||||
)
|
)
|
||||||
.expect("test_append_primordial_accounts_to_genesis.yml");
|
.expect("test_append_primordial_accounts_to_genesis.yml");
|
||||||
|
@ -663,7 +635,6 @@ mod tests {
|
||||||
|
|
||||||
add_genesis_accounts(
|
add_genesis_accounts(
|
||||||
"test_append_primordial_accounts_to_genesis.yml",
|
"test_append_primordial_accounts_to_genesis.yml",
|
||||||
AccountFileFormat::Keypair,
|
|
||||||
&mut genesis_block,
|
&mut genesis_block,
|
||||||
)
|
)
|
||||||
.expect("genesis");
|
.expect("genesis");
|
||||||
|
@ -796,12 +767,7 @@ mod tests {
|
||||||
file.write_all(yaml_string_pubkey.as_bytes()).unwrap();
|
file.write_all(yaml_string_pubkey.as_bytes()).unwrap();
|
||||||
|
|
||||||
let mut genesis_block = GenesisBlock::default();
|
let mut genesis_block = GenesisBlock::default();
|
||||||
add_genesis_accounts(
|
add_genesis_accounts(path.to_str().unwrap(), &mut genesis_block).expect("genesis");
|
||||||
path.to_str().unwrap(),
|
|
||||||
AccountFileFormat::Pubkey,
|
|
||||||
&mut genesis_block,
|
|
||||||
)
|
|
||||||
.expect("genesis");
|
|
||||||
remove_file(path).unwrap();
|
remove_file(path).unwrap();
|
||||||
|
|
||||||
assert_eq!(genesis_block.accounts.len(), 4);
|
assert_eq!(genesis_block.accounts.len(), 4);
|
||||||
|
@ -829,12 +795,7 @@ mod tests {
|
||||||
file.write_all(yaml_string_keypair.as_bytes()).unwrap();
|
file.write_all(yaml_string_keypair.as_bytes()).unwrap();
|
||||||
|
|
||||||
let mut genesis_block = GenesisBlock::default();
|
let mut genesis_block = GenesisBlock::default();
|
||||||
add_genesis_accounts(
|
add_genesis_accounts(path.to_str().unwrap(), &mut genesis_block).expect("genesis");
|
||||||
path.to_str().unwrap(),
|
|
||||||
AccountFileFormat::Keypair,
|
|
||||||
&mut genesis_block,
|
|
||||||
)
|
|
||||||
.expect("genesis");
|
|
||||||
remove_file(path).unwrap();
|
remove_file(path).unwrap();
|
||||||
|
|
||||||
assert_eq!(genesis_block.accounts.len(), 3);
|
assert_eq!(genesis_block.accounts.len(), 3);
|
||||||
|
|
|
@ -6,7 +6,7 @@ use clap::{
|
||||||
};
|
};
|
||||||
use num_cpus;
|
use num_cpus;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
pubkey::write_pubkey,
|
pubkey::write_pubkey_file,
|
||||||
signature::{
|
signature::{
|
||||||
keypair_from_seed, read_keypair, read_keypair_file, write_keypair, write_keypair_file,
|
keypair_from_seed, read_keypair, read_keypair_file, write_keypair, write_keypair_file,
|
||||||
Keypair, KeypairUtil,
|
Keypair, KeypairUtil,
|
||||||
|
@ -182,7 +182,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
||||||
if matches.is_present("outfile") {
|
if matches.is_present("outfile") {
|
||||||
let outfile = matches.value_of("outfile").unwrap();
|
let outfile = matches.value_of("outfile").unwrap();
|
||||||
check_for_overwrite(&outfile, &matches);
|
check_for_overwrite(&outfile, &matches);
|
||||||
write_pubkey(outfile, keypair.pubkey())?;
|
write_pubkey_file(outfile, keypair.pubkey())?;
|
||||||
} else {
|
} else {
|
||||||
println!("{}", keypair.pubkey());
|
println!("{}", keypair.pubkey());
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,10 @@ $solana_keygen new -o "$SOLANA_CONFIG_DIR"/bootstrap-leader/stake-keypair.json
|
||||||
$solana_keygen new -o "$SOLANA_CONFIG_DIR"/bootstrap-leader/storage-keypair.json
|
$solana_keygen new -o "$SOLANA_CONFIG_DIR"/bootstrap-leader/storage-keypair.json
|
||||||
|
|
||||||
args=("$@")
|
args=("$@")
|
||||||
default_arg --bootstrap-leader-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader/identity-keypair.json
|
default_arg --bootstrap-leader-pubkey "$SOLANA_CONFIG_DIR"/bootstrap-leader/identity-keypair.json
|
||||||
default_arg --bootstrap-vote-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader/vote-keypair.json
|
default_arg --bootstrap-vote-pubkey "$SOLANA_CONFIG_DIR"/bootstrap-leader/vote-keypair.json
|
||||||
default_arg --bootstrap-stake-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader/stake-keypair.json
|
default_arg --bootstrap-stake-pubkey "$SOLANA_CONFIG_DIR"/bootstrap-leader/stake-keypair.json
|
||||||
default_arg --bootstrap-storage-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader/storage-keypair.json
|
default_arg --bootstrap-storage-pubkey "$SOLANA_CONFIG_DIR"/bootstrap-leader/storage-keypair.json
|
||||||
default_arg --ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader
|
default_arg --ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader
|
||||||
default_arg --mint "$SOLANA_CONFIG_DIR"/mint-keypair.json
|
default_arg --mint "$SOLANA_CONFIG_DIR"/mint-keypair.json
|
||||||
default_arg --hashes-per-tick auto
|
default_arg --hashes-per-tick auto
|
||||||
|
|
|
@ -208,7 +208,7 @@ EOF
|
||||||
genesisOptions+=" --primordial-accounts-file config/validator-balances.yml"
|
genesisOptions+=" --primordial-accounts-file config/validator-balances.yml"
|
||||||
fi
|
fi
|
||||||
if [[ -f config/client-accounts.yml ]]; then
|
if [[ -f config/client-accounts.yml ]]; then
|
||||||
genesisOptions+=" --primordial-keypairs-file config/client-accounts.yml"
|
genesisOptions+=" --primordial-accounts-file config/client-accounts.yml"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
args=(
|
args=(
|
||||||
|
|
|
@ -82,7 +82,7 @@ impl fmt::Display for Pubkey {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(not(feature = "program"))]
|
||||||
pub fn write_pubkey(outfile: &str, pubkey: Pubkey) -> Result<(), Box<dyn error::Error>> {
|
pub fn write_pubkey_file(outfile: &str, pubkey: Pubkey) -> Result<(), Box<dyn error::Error>> {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
let printable = format!("{}", pubkey);
|
let printable = format!("{}", pubkey);
|
||||||
|
@ -98,7 +98,7 @@ pub fn write_pubkey(outfile: &str, pubkey: Pubkey) -> Result<(), Box<dyn error::
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(not(feature = "program"))]
|
||||||
pub fn read_pubkey(infile: &str) -> Result<Pubkey, Box<dyn error::Error>> {
|
pub fn read_pubkey_file(infile: &str) -> Result<Pubkey, Box<dyn error::Error>> {
|
||||||
let f = std::fs::File::open(infile.to_string())?;
|
let f = std::fs::File::open(infile.to_string())?;
|
||||||
let printable: String = serde_json::from_reader(f)?;
|
let printable: String = serde_json::from_reader(f)?;
|
||||||
Ok(Pubkey::from_str(&printable)?)
|
Ok(Pubkey::from_str(&printable)?)
|
||||||
|
@ -183,8 +183,8 @@ mod tests {
|
||||||
fn test_read_write_pubkey() -> Result<(), Box<dyn error::Error>> {
|
fn test_read_write_pubkey() -> Result<(), Box<dyn error::Error>> {
|
||||||
let filename = "test_pubkey.json";
|
let filename = "test_pubkey.json";
|
||||||
let pubkey = Pubkey::new_rand();
|
let pubkey = Pubkey::new_rand();
|
||||||
write_pubkey(filename, pubkey)?;
|
write_pubkey_file(filename, pubkey)?;
|
||||||
let read = read_pubkey(filename)?;
|
let read = read_pubkey_file(filename)?;
|
||||||
assert_eq!(read, pubkey);
|
assert_eq!(read, pubkey);
|
||||||
remove_file(filename)?;
|
remove_file(filename)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue