replaced chunks with tuples in validator (#30499)
* replaced chunks with tuples in test validator * update Cargo.lock * replaced chunks with tuples in genesis * Update Cargo.lock
This commit is contained in:
parent
7361fe27f9
commit
5631685d30
|
@ -5551,6 +5551,7 @@ dependencies = [
|
|||
"base64 0.13.0",
|
||||
"bincode",
|
||||
"clap 2.33.3",
|
||||
"itertools",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml 0.9.13",
|
||||
|
@ -6957,6 +6958,7 @@ dependencies = [
|
|||
"crossbeam-channel",
|
||||
"fd-lock",
|
||||
"indicatif",
|
||||
"itertools",
|
||||
"jsonrpc-core",
|
||||
"jsonrpc-core-client",
|
||||
"jsonrpc-derive",
|
||||
|
|
|
@ -13,6 +13,7 @@ edition = { workspace = true }
|
|||
base64 = { workspace = true }
|
||||
bincode = { workspace = true }
|
||||
clap = { workspace = true }
|
||||
itertools = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
serde_yaml = { workspace = true }
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
use {
|
||||
clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg, ArgMatches},
|
||||
itertools::Itertools,
|
||||
solana_clap_utils::{
|
||||
input_parsers::{
|
||||
cluster_type_of, pubkey_of, pubkeys_of, unix_timestamp_from_rfc3339_datetime,
|
||||
|
@ -615,85 +616,76 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||
};
|
||||
|
||||
if let Some(values) = matches.values_of("bpf_program") {
|
||||
let values: Vec<&str> = values.collect::<Vec<_>>();
|
||||
for address_loader_program in values.chunks(3) {
|
||||
match address_loader_program {
|
||||
[address, loader, program] => {
|
||||
let address = parse_address(address, "address");
|
||||
let loader = parse_address(loader, "loader");
|
||||
let program_data = parse_program_data(program);
|
||||
genesis_config.add_account(
|
||||
address,
|
||||
AccountSharedData::from(Account {
|
||||
lamports: genesis_config.rent.minimum_balance(program_data.len()),
|
||||
data: program_data,
|
||||
executable: true,
|
||||
owner: loader,
|
||||
rent_epoch: 0,
|
||||
}),
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
for (address, loader, program) in values.tuples() {
|
||||
let address = parse_address(address, "address");
|
||||
let loader = parse_address(loader, "loader");
|
||||
let program_data = parse_program_data(program);
|
||||
genesis_config.add_account(
|
||||
address,
|
||||
AccountSharedData::from(Account {
|
||||
lamports: genesis_config.rent.minimum_balance(program_data.len()),
|
||||
data: program_data,
|
||||
executable: true,
|
||||
owner: loader,
|
||||
rent_epoch: 0,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(values) = matches.values_of("upgradeable_program") {
|
||||
let values: Vec<&str> = values.collect::<Vec<_>>();
|
||||
for address_loader_program_upgrade_authority in values.chunks(4) {
|
||||
match address_loader_program_upgrade_authority {
|
||||
[address, loader, program, upgrade_authority] => {
|
||||
let address = parse_address(address, "address");
|
||||
let loader = parse_address(loader, "loader");
|
||||
let program_data_elf = parse_program_data(program);
|
||||
let upgrade_authority_address = if *upgrade_authority == "none" {
|
||||
Pubkey::default()
|
||||
} else {
|
||||
upgrade_authority.parse::<Pubkey>().unwrap_or_else(|_| {
|
||||
read_keypair_file(upgrade_authority).map(|keypair| keypair.pubkey()).unwrap_or_else(|err| {
|
||||
eprintln!("Error: invalid upgrade_authority {upgrade_authority}: {err}");
|
||||
process::exit(1);
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
let (programdata_address, _) =
|
||||
Pubkey::find_program_address(&[address.as_ref()], &loader);
|
||||
let mut program_data =
|
||||
bincode::serialize(&UpgradeableLoaderState::ProgramData {
|
||||
slot: 0,
|
||||
upgrade_authority_address: Some(upgrade_authority_address),
|
||||
for (address, loader, program, upgrade_authority) in values.tuples() {
|
||||
let address = parse_address(address, "address");
|
||||
let loader = parse_address(loader, "loader");
|
||||
let program_data_elf = parse_program_data(program);
|
||||
let upgrade_authority_address = if upgrade_authority == "none" {
|
||||
Pubkey::default()
|
||||
} else {
|
||||
upgrade_authority.parse::<Pubkey>().unwrap_or_else(|_| {
|
||||
read_keypair_file(upgrade_authority)
|
||||
.map(|keypair| keypair.pubkey())
|
||||
.unwrap_or_else(|err| {
|
||||
eprintln!(
|
||||
"Error: invalid upgrade_authority {upgrade_authority}: {err}"
|
||||
);
|
||||
process::exit(1);
|
||||
})
|
||||
.unwrap();
|
||||
program_data.extend_from_slice(&program_data_elf);
|
||||
genesis_config.add_account(
|
||||
programdata_address,
|
||||
AccountSharedData::from(Account {
|
||||
lamports: genesis_config.rent.minimum_balance(program_data.len()),
|
||||
data: program_data,
|
||||
owner: loader,
|
||||
executable: false,
|
||||
rent_epoch: 0,
|
||||
}),
|
||||
);
|
||||
})
|
||||
};
|
||||
|
||||
let program_data = bincode::serialize(&UpgradeableLoaderState::Program {
|
||||
programdata_address,
|
||||
})
|
||||
.unwrap();
|
||||
genesis_config.add_account(
|
||||
address,
|
||||
AccountSharedData::from(Account {
|
||||
lamports: genesis_config.rent.minimum_balance(program_data.len()),
|
||||
data: program_data,
|
||||
owner: loader,
|
||||
executable: true,
|
||||
rent_epoch: 0,
|
||||
}),
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
let (programdata_address, _) =
|
||||
Pubkey::find_program_address(&[address.as_ref()], &loader);
|
||||
let mut program_data = bincode::serialize(&UpgradeableLoaderState::ProgramData {
|
||||
slot: 0,
|
||||
upgrade_authority_address: Some(upgrade_authority_address),
|
||||
})
|
||||
.unwrap();
|
||||
program_data.extend_from_slice(&program_data_elf);
|
||||
genesis_config.add_account(
|
||||
programdata_address,
|
||||
AccountSharedData::from(Account {
|
||||
lamports: genesis_config.rent.minimum_balance(program_data.len()),
|
||||
data: program_data,
|
||||
owner: loader,
|
||||
executable: false,
|
||||
rent_epoch: 0,
|
||||
}),
|
||||
);
|
||||
|
||||
let program_data = bincode::serialize(&UpgradeableLoaderState::Program {
|
||||
programdata_address,
|
||||
})
|
||||
.unwrap();
|
||||
genesis_config.add_account(
|
||||
address,
|
||||
AccountSharedData::from(Account {
|
||||
lamports: genesis_config.rent.minimum_balance(program_data.len()),
|
||||
data: program_data,
|
||||
owner: loader,
|
||||
executable: true,
|
||||
rent_epoch: 0,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6162,6 +6162,7 @@ dependencies = [
|
|||
"crossbeam-channel",
|
||||
"fd-lock",
|
||||
"indicatif",
|
||||
"itertools",
|
||||
"jsonrpc-core",
|
||||
"jsonrpc-core-client",
|
||||
"jsonrpc-derive",
|
||||
|
|
|
@ -18,6 +18,7 @@ core_affinity = { workspace = true }
|
|||
crossbeam-channel = { workspace = true }
|
||||
fd-lock = { workspace = true }
|
||||
indicatif = { workspace = true }
|
||||
itertools = { workspace = true }
|
||||
jsonrpc-core = { workspace = true }
|
||||
jsonrpc-core-client = { workspace = true, features = ["ipc"] }
|
||||
jsonrpc-derive = { workspace = true }
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use {
|
||||
clap::{crate_name, value_t, value_t_or_exit, values_t_or_exit},
|
||||
crossbeam_channel::unbounded,
|
||||
itertools::Itertools,
|
||||
log::*,
|
||||
solana_clap_utils::{
|
||||
input_parsers::{pubkey_of, pubkeys_of, value_of},
|
||||
|
@ -203,79 +204,61 @@ fn main() {
|
|||
|
||||
let mut upgradeable_programs_to_load = vec![];
|
||||
if let Some(values) = matches.values_of("bpf_program") {
|
||||
let values: Vec<&str> = values.collect::<Vec<_>>();
|
||||
for address_program in values.chunks(2) {
|
||||
match address_program {
|
||||
[address, program] => {
|
||||
let address = parse_address(address, "address");
|
||||
let program_path = parse_program_path(program);
|
||||
for (address, program) in values.into_iter().tuples() {
|
||||
let address = parse_address(address, "address");
|
||||
let program_path = parse_program_path(program);
|
||||
|
||||
upgradeable_programs_to_load.push(UpgradeableProgramInfo {
|
||||
program_id: address,
|
||||
loader: solana_sdk::bpf_loader_upgradeable::id(),
|
||||
upgrade_authority: Pubkey::default(),
|
||||
program_path,
|
||||
});
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
upgradeable_programs_to_load.push(UpgradeableProgramInfo {
|
||||
program_id: address,
|
||||
loader: solana_sdk::bpf_loader_upgradeable::id(),
|
||||
upgrade_authority: Pubkey::default(),
|
||||
program_path,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(values) = matches.values_of("upgradeable_program") {
|
||||
let values: Vec<&str> = values.collect::<Vec<_>>();
|
||||
for address_program_upgrade_authority in values.chunks(3) {
|
||||
match address_program_upgrade_authority {
|
||||
[address, program, upgrade_authority] => {
|
||||
let address = parse_address(address, "address");
|
||||
let program_path = parse_program_path(program);
|
||||
let upgrade_authority_address = if *upgrade_authority == "none" {
|
||||
Pubkey::default()
|
||||
} else {
|
||||
upgrade_authority
|
||||
.parse::<Pubkey>()
|
||||
.or_else(|_| {
|
||||
read_keypair_file(upgrade_authority).map(|keypair| keypair.pubkey())
|
||||
})
|
||||
.unwrap_or_else(|err| {
|
||||
println!(
|
||||
"Error: invalid upgrade_authority {upgrade_authority}: {err}"
|
||||
);
|
||||
exit(1);
|
||||
})
|
||||
};
|
||||
for (address, program, upgrade_authority) in
|
||||
values.into_iter().tuples::<(&str, &str, &str)>()
|
||||
{
|
||||
let address = parse_address(address, "address");
|
||||
let program_path = parse_program_path(program);
|
||||
let upgrade_authority_address = if upgrade_authority == "none" {
|
||||
Pubkey::default()
|
||||
} else {
|
||||
upgrade_authority
|
||||
.parse::<Pubkey>()
|
||||
.or_else(|_| {
|
||||
read_keypair_file(upgrade_authority).map(|keypair| keypair.pubkey())
|
||||
})
|
||||
.unwrap_or_else(|err| {
|
||||
println!("Error: invalid upgrade_authority {upgrade_authority}: {err}");
|
||||
exit(1);
|
||||
})
|
||||
};
|
||||
|
||||
upgradeable_programs_to_load.push(UpgradeableProgramInfo {
|
||||
program_id: address,
|
||||
loader: solana_sdk::bpf_loader_upgradeable::id(),
|
||||
upgrade_authority: upgrade_authority_address,
|
||||
program_path,
|
||||
});
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
upgradeable_programs_to_load.push(UpgradeableProgramInfo {
|
||||
program_id: address,
|
||||
loader: solana_sdk::bpf_loader_upgradeable::id(),
|
||||
upgrade_authority: upgrade_authority_address,
|
||||
program_path,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let mut accounts_to_load = vec![];
|
||||
if let Some(values) = matches.values_of("account") {
|
||||
let values: Vec<&str> = values.collect::<Vec<_>>();
|
||||
for address_filename in values.chunks(2) {
|
||||
match address_filename {
|
||||
[address, filename] => {
|
||||
let address = if *address == "-" {
|
||||
None
|
||||
} else {
|
||||
Some(address.parse::<Pubkey>().unwrap_or_else(|err| {
|
||||
println!("Error: invalid address {address}: {err}");
|
||||
exit(1);
|
||||
}))
|
||||
};
|
||||
for (address, filename) in values.into_iter().tuples() {
|
||||
let address = if address == "-" {
|
||||
None
|
||||
} else {
|
||||
Some(address.parse::<Pubkey>().unwrap_or_else(|err| {
|
||||
println!("Error: invalid address {address}: {err}");
|
||||
exit(1);
|
||||
}))
|
||||
};
|
||||
|
||||
accounts_to_load.push(AccountInfo { address, filename });
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
accounts_to_load.push(AccountInfo { address, filename });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue