Use bs58 strings to declare IDs rather then raw bytes (#7082)

This commit is contained in:
Jack May 2019-11-21 16:34:40 -08:00 committed by GitHub
parent d9e7a5fcbe
commit d8ead57fbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 81 additions and 252 deletions

1
Cargo.lock generated
View File

@ -3860,6 +3860,7 @@ dependencies = [
"generic-array 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -29,16 +29,7 @@ pub const MAX_SHORT_FIELD_LENGTH: usize = 70;
pub const MAX_LONG_FIELD_LENGTH: usize = 300;
pub const MAX_VALIDATOR_INFO: u64 = 576;
// Config account key: Va1idator1nfo111111111111111111111111111111
pub const REGISTER_CONFIG_KEY: [u8; 32] = [
7, 81, 151, 1, 116, 72, 242, 172, 93, 194, 60, 158, 188, 122, 199, 140, 10, 39, 37, 122, 198,
20, 69, 141, 224, 164, 241, 111, 128, 0, 0, 0,
];
solana_sdk::solana_name_id!(
REGISTER_CONFIG_KEY,
"Va1idator1nfo111111111111111111111111111111"
);
solana_sdk::declare_id!("Va1idator1nfo111111111111111111111111111111");
#[derive(Debug, Deserialize, PartialEq, Serialize, Default)]
pub struct ValidatorInfo {

View File

@ -7,7 +7,7 @@ use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
use log::*;
use solana_rbpf::{memory_region::MemoryRegion, EbpfVm};
use solana_sdk::account::KeyedAccount;
use solana_sdk::bpf_loader::PROGRAM_ID;
use solana_sdk::bpf_loader;
use solana_sdk::instruction::InstructionError;
use solana_sdk::instruction_processor_utils::{limited_deserialize, next_keyed_account};
use solana_sdk::loader_instruction::LoaderInstruction;
@ -19,8 +19,7 @@ use std::io::Error;
use std::mem;
solana_sdk::declare_program!(
PROGRAM_ID,
"BPFLoader1111111111111111111111111111111111",
bpf_loader::BS58_STRING,
solana_bpf_loader_program,
process_instruction
);

View File

@ -11,13 +11,7 @@ pub mod utils;
use crate::spv_processor::process_instruction;
pub const BTC_SPV_PROGRAM_ID: [u8; 32] = [
2, 202, 42, 59, 228, 51, 182, 147, 162, 245, 234, 78, 205, 37, 131, 154, 110, 252, 154, 254,
190, 13, 90, 231, 198, 144, 239, 96, 0, 0, 0, 0,
];
solana_sdk::declare_program!(
BTC_SPV_PROGRAM_ID,
"BtcSpv1111111111111111111111111111111111111",
solana_btc_spv_program,
process_instruction

View File

@ -5,13 +5,7 @@ pub mod budget_state;
use crate::budget_processor::process_instruction;
const BUDGET_PROGRAM_ID: [u8; 32] = [
2, 203, 81, 223, 225, 24, 34, 35, 203, 214, 138, 130, 144, 208, 35, 77, 63, 16, 87, 51, 47,
198, 115, 123, 98, 188, 19, 160, 0, 0, 0, 0,
];
solana_sdk::declare_program!(
BUDGET_PROGRAM_ID,
"Budget1111111111111111111111111111111111111",
solana_budget_program,
process_instruction

View File

@ -6,13 +6,7 @@ use bincode::{deserialize, serialize, serialized_size};
use serde_derive::{Deserialize, Serialize};
use solana_sdk::{account::Account, pubkey::Pubkey, short_vec};
const CONFIG_PROGRAM_ID: [u8; 32] = [
3, 6, 74, 163, 0, 47, 116, 220, 200, 110, 67, 49, 15, 12, 5, 42, 248, 197, 218, 39, 246, 16,
64, 25, 163, 35, 239, 160, 0, 0, 0, 0,
];
solana_sdk::declare_program!(
CONFIG_PROGRAM_ID,
"Config1111111111111111111111111111111111111",
solana_config_program,
process_instruction

View File

@ -7,26 +7,12 @@ extern crate solana_metrics;
use crate::exchange_processor::process_instruction;
pub const EXCHANGE_PROGRAM_ID: [u8; 32] = [
3, 147, 111, 103, 210, 47, 14, 213, 108, 116, 49, 115, 232, 171, 14, 111, 167, 140, 221, 234,
33, 70, 185, 192, 42, 31, 141, 152, 0, 0, 0, 0,
];
solana_sdk::declare_program!(
EXCHANGE_PROGRAM_ID,
"Exchange11111111111111111111111111111111111",
solana_exchange_program,
process_instruction
);
pub mod faucet {
pub const EXCHANGE_FAUCET_ID: [u8; 32] = [
3, 147, 111, 103, 210, 47, 23, 11, 176, 29, 147, 89, 237, 155, 21, 62, 107, 105, 157, 1,
98, 204, 206, 211, 54, 212, 79, 15, 160, 0, 0, 0,
];
solana_sdk::solana_name_id!(
EXCHANGE_FAUCET_ID,
"ExchangeFaucet11111111111111111111111111111"
);
solana_sdk::declare_id!("ExchangeFaucet11111111111111111111111111111");
}

View File

@ -2,13 +2,7 @@ use solana_sdk::account::KeyedAccount;
use solana_sdk::instruction::InstructionError;
use solana_sdk::pubkey::Pubkey;
pub const FAILURE_PROGRAM_ID: [u8; 32] = [
3, 188, 64, 34, 171, 255, 206, 240, 89, 4, 11, 161, 30, 250, 18, 135, 195, 82, 6, 72, 220, 142,
53, 26, 45, 144, 70, 112, 0, 0, 0, 0,
];
solana_sdk::declare_program!(
FAILURE_PROGRAM_ID,
"FaiLure111111111111111111111111111111111111",
solana_failure_program,
process_instruction

View File

@ -1,10 +1,4 @@
const LIBRAPAY_PROGRAM_ID: [u8; 32] = [
5, 13, 18, 222, 165, 11, 80, 225, 56, 103, 125, 38, 15, 252, 181, 16, 125, 99, 110, 106, 186,
28, 136, 119, 235, 245, 20, 80, 0, 0, 0, 0,
];
solana_sdk::solana_name_id!(
LIBRAPAY_PROGRAM_ID,
solana_sdk::declare_id!(
"LibraPay11111111111111111111111111111111111"
);

View File

@ -2079,7 +2079,7 @@ dependencies = [
]
[[package]]
name = "solana-move-loader-api"
name = "solana-move-loader-program"
version = "0.21.0"
dependencies = [
"bincode 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2119,6 +2119,7 @@ dependencies = [
"generic-array 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -4,11 +4,10 @@ pub mod error_mappers;
pub mod processor;
use crate::processor::process_instruction;
use solana_sdk::move_loader::PROGRAM_ID;
use solana_sdk::move_loader;
solana_sdk::declare_program!(
PROGRAM_ID,
"MoveLdr111111111111111111111111111111111111",
move_loader::BS58_STRING,
solana_move_loader_program,
process_instruction
);

View File

@ -3,13 +3,7 @@ use solana_sdk::account::KeyedAccount;
use solana_sdk::instruction::InstructionError;
use solana_sdk::pubkey::Pubkey;
pub const NOOP_PROGRAM_ID: [u8; 32] = [
5, 150, 31, 54, 19, 205, 142, 201, 161, 38, 97, 31, 144, 212, 37, 82, 93, 58, 178, 5, 131, 178,
31, 101, 138, 251, 91, 128, 0, 0, 0, 0,
];
solana_sdk::declare_program!(
NOOP_PROGRAM_ID,
"Noop111111111111111111111111111111111111111",
solana_noop_program,
process_instruction

View File

@ -1,12 +1,4 @@
pub mod ownable_instruction;
pub mod ownable_processor;
const OWNABLE_PROGRAM_ID: [u8; 32] = [
12, 6, 169, 236, 232, 53, 216, 159, 221, 186, 8, 8, 33, 45, 166, 249, 243, 55, 177, 184, 195,
132, 141, 34, 63, 108, 219, 80, 0, 0, 0, 0,
];
solana_sdk::solana_name_id!(
OWNABLE_PROGRAM_ID,
"ownab1e111111111111111111111111111111111111"
);
solana_sdk::declare_id!("ownab1e111111111111111111111111111111111111");

View File

@ -10,12 +10,7 @@ use solana_sdk::{
};
// stake config ID
const ID: [u8; 32] = [
6, 161, 216, 23, 165, 2, 5, 11, 104, 7, 145, 230, 206, 109, 184, 142, 30, 91, 113, 80, 246, 31,
198, 121, 10, 78, 180, 209, 0, 0, 0, 0,
];
solana_sdk::solana_name_id!(ID, "StakeConfig11111111111111111111111111111111");
solana_sdk::declare_id!("StakeConfig11111111111111111111111111111111");
// means that no more than RATE of current effective stake may be added or subtracted per
// epoch

View File

@ -5,13 +5,7 @@ pub mod rewards_pools;
pub mod stake_instruction;
pub mod stake_state;
const STAKE_PROGRAM_ID: [u8; 32] = [
6, 161, 216, 23, 145, 55, 84, 42, 152, 52, 55, 189, 254, 42, 122, 178, 85, 127, 83, 92, 138,
120, 114, 43, 104, 164, 157, 192, 0, 0, 0, 0,
];
solana_sdk::declare_program!(
STAKE_PROGRAM_ID,
"Stake11111111111111111111111111111111111111",
solana_stake_program,
stake_instruction::process_instruction

View File

@ -11,18 +11,13 @@ use solana_sdk::{
};
// base rewards pool ID
const ID: [u8; 32] = [
6, 161, 216, 23, 186, 139, 91, 88, 83, 34, 32, 112, 237, 188, 184, 153, 69, 67, 238, 112, 93,
54, 133, 142, 145, 182, 214, 15, 0, 0, 0, 0,
];
solana_sdk::solana_name_id!(ID, "StakeRewards1111111111111111111111111111111");
solana_sdk::declare_id!("StakeRewards1111111111111111111111111111111");
// to cut down on collisions for redemptions, we make multiple accounts
pub const NUM_REWARDS_POOLS: usize = 256;
pub fn random_id() -> Pubkey {
let mut id = Hash::new(&ID);
let mut id = Hash::new(id().as_ref());
for _i in 0..thread_rng().gen_range(0, NUM_REWARDS_POOLS) {
id = hash(id.as_ref());

View File

@ -5,13 +5,7 @@ pub mod storage_processor;
use crate::storage_processor::process_instruction;
const STORAGE_PROGRAM_ID: [u8; 32] = [
6, 162, 25, 123, 127, 68, 233, 59, 131, 151, 21, 152, 162, 120, 90, 37, 154, 88, 86, 5, 156,
221, 182, 201, 142, 103, 151, 112, 0, 0, 0, 0,
];
solana_sdk::declare_program!(
STORAGE_PROGRAM_ID,
"Storage111111111111111111111111111111111111",
solana_storage_program,
process_instruction

View File

@ -10,12 +10,7 @@ use solana_sdk::hash::{hash, Hash};
use solana_sdk::pubkey::Pubkey;
// base rewards pool ID
const ID: [u8; 32] = [
6, 162, 25, 123, 127, 71, 141, 232, 129, 171, 58, 183, 79, 88, 181, 17, 163, 11, 51, 111, 22,
123, 67, 115, 5, 131, 109, 161, 16, 0, 0, 0,
];
solana_sdk::solana_name_id!(ID, "StorageMiningPoo111111111111111111111111111");
solana_sdk::declare_id!("StorageMiningPoo111111111111111111111111111");
// to cut down on collisions for redemptions, we make multiple accounts
pub const NUM_REWARDS_POOLS: usize = 32;
@ -31,7 +26,7 @@ pub fn add_genesis_accounts(genesis_config: &mut GenesisConfig) -> u64 {
}
pub fn random_id() -> Pubkey {
let mut id = Hash::new(&ID);
let mut id = Hash::new(id().as_ref());
for _i in 0..thread_rng().gen_range(0, NUM_REWARDS_POOLS) {
id = hash(id.as_ref());

View File

@ -6,13 +6,7 @@ pub mod vest_state;
use crate::vest_processor::process_instruction;
const VEST_PROGRAM_ID: [u8; 32] = [
7, 87, 23, 47, 219, 236, 238, 33, 137, 188, 215, 141, 32, 229, 155, 195, 133, 124, 23, 232,
113, 153, 252, 252, 111, 5, 187, 128, 0, 0, 0, 0,
];
solana_sdk::declare_program!(
VEST_PROGRAM_ID,
"Vest111111111111111111111111111111111111111",
solana_vest_program,
process_instruction

View File

@ -3,13 +3,7 @@ pub mod vote_state;
use crate::vote_instruction::process_instruction;
const VOTE_PROGRAM_ID: [u8; 32] = [
7, 97, 72, 29, 53, 116, 116, 187, 124, 77, 118, 36, 235, 211, 189, 179, 216, 53, 94, 115, 209,
16, 67, 252, 13, 163, 83, 128, 0, 0, 0, 0,
];
solana_sdk::declare_program!(
VOTE_PROGRAM_ID,
"Vote111111111111111111111111111111111111111",
solana_vote_program,
process_instruction

View File

@ -32,6 +32,7 @@ byteorder = { version = "1.3.2", optional = true }
generic-array = { version = "0.13.2", default-features = false, features = ["serde", "more_lengths"] }
hex = "0.4.0"
itertools = { version = "0.8.1" }
lazy_static = "1.4.0"
log = { version = "0.4.8" }
memmap = { version = "0.6.2", optional = true }
num-derive = { version = "0.3" }

View File

@ -1,6 +1,2 @@
pub const PROGRAM_ID: [u8; 32] = [
2, 168, 246, 145, 78, 136, 161, 107, 189, 35, 149, 133, 95, 100, 4, 217, 180, 244, 86, 183,
130, 27, 176, 20, 87, 73, 66, 140, 0, 0, 0, 0,
];
crate::solana_name_id!(PROGRAM_ID, "BPFLoader1111111111111111111111111111111111");
pub const BS58_STRING: &str = "BPFLoader1111111111111111111111111111111111";
crate::declare_id!(BS58_STRING);

View File

@ -30,8 +30,7 @@ macro_rules! solana_entrypoint(
/// Convenience macro to declare a native program
///
/// id: Variable containing the program's id (public key bytes)
/// bs58: BS58 encoding of the id, used verify check the id bytes
/// bs58_string: bs58 string representation the program's id
/// name: Name of the program, must match the library name in Cargo.toml
/// entrypoint: Program's entrypoint, must be of `type Entrypoint`
///
@ -43,11 +42,6 @@ macro_rules! solana_entrypoint(
/// use solana_sdk::pubkey::Pubkey;
/// use solana_sdk::declare_program;
///
/// const MY_PROGRAM_ID: [u8; 32] = [
/// 6, 161, 216, 23, 145, 55, 84, 42, 152, 52, 55, 189, 254, 42, 122, 178, 85, 127, 83, 92, 138,
/// 120, 114, 43, 104, 164, 157, 192, 0, 0, 0, 0,
/// ];
///
/// fn my_process_instruction(
/// program_id: &Pubkey,
/// keyed_accounts: &mut [KeyedAccount],
@ -58,7 +52,6 @@ macro_rules! solana_entrypoint(
/// }
///
/// solana_sdk::declare_program!(
/// MY_PROGRAM_ID,
/// "My!!!11111111111111111111111111111111111111",
/// solana_my_program,
/// my_process_instruction
@ -66,8 +59,8 @@ macro_rules! solana_entrypoint(
/// ```
#[macro_export]
macro_rules! declare_program(
($id:ident, $bs58:expr, $name:ident, $entrypoint:expr) => (
$crate::solana_name_id!($id, $bs58);
($bs58_string:expr, $name:ident, $entrypoint:expr) => (
$crate::declare_id!($bs58_string);
#[macro_export]
macro_rules! $name {

View File

@ -51,5 +51,6 @@ pub mod transport;
#[macro_use]
extern crate serde_derive;
pub extern crate bs58;
pub extern crate lazy_static;
extern crate log as logger;

View File

@ -1,9 +1,5 @@
pub const PROGRAM_ID: [u8; 32] = [
5, 84, 172, 160, 172, 5, 64, 41, 134, 4, 81, 31, 45, 11, 30, 64, 219, 238, 140, 38, 194, 100,
192, 219, 156, 94, 62, 208, 0, 0, 0, 0,
];
crate::solana_name_id!(PROGRAM_ID, "MoveLdr111111111111111111111111111111111111");
pub const BS58_STRING: &str = "MoveLdr111111111111111111111111111111111111";
crate::declare_id!(BS58_STRING);
pub fn solana_move_loader_program() -> (String, crate::pubkey::Pubkey) {
("solana_move_loader_program".to_string(), id())

View File

@ -1,12 +1,7 @@
use crate::account::Account;
use crate::hash::Hash;
const ID: [u8; 32] = [
5, 135, 132, 191, 20, 139, 164, 40, 47, 176, 18, 87, 72, 136, 169, 241, 83, 160, 125, 173, 247,
101, 192, 69, 92, 154, 151, 3, 128, 0, 0, 0,
];
crate::solana_name_id!(ID, "NativeLoader1111111111111111111111111111111");
crate::declare_id!("NativeLoader1111111111111111111111111111111");
/// Create an executable account with the given shared object name.
pub fn create_loadable_account(name: &str) -> Account {

View File

@ -104,16 +104,52 @@ pub fn read_pubkey_file(infile: &str) -> Result<Pubkey, Box<dyn error::Error>> {
Ok(Pubkey::from_str(&printable)?)
}
/// Convenience macro to declare a static Pubkey and functions to interact with it
///
/// bs58_string: bs58 string representation the program's id
///
/// # Examples
///
/// ```
/// solana_sdk::declare_id!("My!!!11111111111111111111111111111111111111");
/// ```
#[macro_export]
macro_rules! solana_id(
($id:ident) => (
macro_rules!
declare_id(
($bs58_string:expr) => (
use std::str::FromStr;
$crate::lazy_static::lazy_static! {
static ref _PUBKEY: $crate::pubkey::Pubkey = {
match $crate::pubkey::Pubkey::from_str(&$bs58_string) {
Ok(pubkey) => pubkey,
Err(_) => {
let pubkey_vec = $crate::bs58::decode(&$bs58_string)
.into_vec()
.map_err(|e| panic!("Error: {}, {}", $bs58_string, e))
.unwrap();
let expected_len = std::mem::size_of::<$crate::pubkey::Pubkey>();
let len = pubkey_vec.len();
if len != expected_len {
panic!(
"Error: {}, decoded length {}, expected {}",
$bs58_string, len, expected_len);
} else {
panic!(
"Error: {}, not a valid string, cannot determine reason",
$bs58_string);
}
}
}
};
}
pub fn check_id(id: &$crate::pubkey::Pubkey) -> bool {
id.as_ref() == $id
*id == *_PUBKEY
}
pub fn id() -> $crate::pubkey::Pubkey {
$crate::pubkey::Pubkey::new(&$id)
*_PUBKEY
}
#[cfg(test)]
@ -121,23 +157,6 @@ macro_rules! solana_id(
fn test_id() {
assert!(check_id(&id()));
}
)
);
#[macro_export]
macro_rules! solana_name_id(
($id:ident, $name:expr) => (
$crate::solana_id!($id);
#[cfg(test)]
#[test]
fn test_name_id() {
if id().to_string() != $name {
panic!("id for `{}` should be `{:?}`", $name, $crate::pubkey::bs58::decode($name).into_vec().unwrap());
}
}
)
);

View File

@ -1,8 +1,4 @@
const ID: [u8; 32] = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];
crate::solana_name_id!(ID, "11111111111111111111111111111111");
crate::declare_id!("11111111111111111111111111111111");
pub fn solana_system_program() -> (String, crate::pubkey::Pubkey) {
("solana_system_program".to_string(), id())

View File

@ -8,12 +8,7 @@ use crate::{
sysvar::Sysvar,
};
const ID: [u8; 32] = [
6, 167, 213, 23, 24, 199, 116, 201, 40, 86, 99, 152, 105, 29, 94, 182, 139, 94, 184, 163, 155,
75, 109, 92, 115, 85, 91, 33, 0, 0, 0, 0,
];
crate::solana_sysvar_id!(ID, "SysvarC1ock11111111111111111111111111111111", Clock);
crate::declare_sysvar_id!("SysvarC1ock11111111111111111111111111111111", Clock);
impl Sysvar for Clock {}

View File

@ -3,17 +3,7 @@
pub use crate::epoch_schedule::EpochSchedule;
use crate::{account::Account, sysvar::Sysvar};
/// epoch_schedule account pubkey
const ID: [u8; 32] = [
6, 167, 213, 23, 24, 220, 63, 238, 2, 211, 228, 127, 1, 0, 248, 176, 84, 247, 148, 46, 96, 89,
30, 63, 80, 135, 25, 168, 5, 0, 0, 0,
];
crate::solana_sysvar_id!(
ID,
"SysvarEpochSchedu1e111111111111111111111111",
EpochSchedule
);
crate::declare_sysvar_id!("SysvarEpochSchedu1e111111111111111111111111", EpochSchedule);
impl Sysvar for EpochSchedule {}

View File

@ -2,13 +2,7 @@
//!
use crate::{account::Account, fee_calculator::FeeCalculator, sysvar::Sysvar};
/// fees account pubkey
const ID: [u8; 32] = [
6, 167, 213, 23, 24, 226, 90, 141, 131, 80, 60, 37, 26, 122, 240, 113, 38, 253, 114, 0, 223,
111, 196, 237, 82, 106, 156, 144, 0, 0, 0, 0,
];
crate::solana_sysvar_id!(ID, "SysvarFees111111111111111111111111111111111", Fees);
crate::declare_sysvar_id!("SysvarFees111111111111111111111111111111111", Fees);
#[repr(C)]
#[derive(Serialize, Deserialize, Debug, Default)]

View File

@ -28,9 +28,9 @@ pub fn is_sysvar_id(id: &Pubkey) -> bool {
}
#[macro_export]
macro_rules! solana_sysvar_id(
($id:ident, $name:expr, $type:ty) => (
$crate::solana_name_id!($id, $name);
macro_rules! declare_sysvar_id(
($name:expr, $type:ty) => (
$crate::declare_id!($name);
impl $crate::sysvar::SysvarId for $type {
fn check_id(pubkey: &$crate::pubkey::Pubkey) -> bool {
@ -48,14 +48,8 @@ macro_rules! solana_sysvar_id(
)
);
/// "Sysvar1111111111111111111111111111111111111"
/// owner pubkey for sysvar accounts
const ID: [u8; 32] = [
6, 167, 213, 23, 24, 117, 247, 41, 199, 61, 147, 64, 143, 33, 97, 32, 6, 126, 216, 140, 118,
224, 140, 40, 127, 193, 148, 96, 0, 0, 0, 0,
];
crate::solana_name_id!(ID, "Sysvar1111111111111111111111111111111111111");
// owner pubkey for sysvar accounts
crate::declare_id!("Sysvar1111111111111111111111111111111111111");
pub trait SysvarId {
fn check_id(pubkey: &Pubkey) -> bool;

View File

@ -4,13 +4,8 @@ use std::iter::FromIterator;
use std::ops::Deref;
const MAX_ENTRIES: usize = 32;
const ID: [u8; 32] = [
0x06, 0xa7, 0xd5, 0x17, 0x19, 0x2c, 0x56, 0x8e, 0xe0, 0x8a, 0x84, 0x5f, 0x73, 0xd2, 0x97, 0x88,
0xcf, 0x03, 0x5c, 0x31, 0x45, 0xb2, 0x1a, 0xb3, 0x44, 0xd8, 0x06, 0x2e, 0xa9, 0x40, 0x00, 0x00,
];
crate::solana_sysvar_id!(
ID,
crate::declare_sysvar_id!(
"SysvarRecentB1ockHashes11111111111111111111",
RecentBlockhashes
);

View File

@ -8,13 +8,7 @@ use crate::{
sysvar::Sysvar,
};
/// rent account pubkey
const ID: [u8; 32] = [
6, 167, 213, 23, 25, 44, 92, 81, 33, 140, 201, 76, 61, 74, 241, 127, 88, 218, 238, 8, 155, 161,
253, 68, 227, 219, 217, 138, 0, 0, 0, 0,
];
crate::solana_sysvar_id!(ID, "SysvarRent111111111111111111111111111111111", Rent);
crate::declare_sysvar_id!("SysvarRent111111111111111111111111111111111", Rent);
impl Sysvar for Rent {}

View File

@ -2,13 +2,7 @@
//!
use crate::{account::Account, sysvar::Sysvar};
/// account pubkey
const ID: [u8; 32] = [
6, 167, 213, 23, 25, 44, 97, 55, 206, 224, 146, 217, 182, 146, 62, 225, 204, 214, 25, 3, 250,
130, 184, 161, 97, 145, 87, 141, 128, 0, 0, 0,
];
crate::solana_sysvar_id!(ID, "SysvarRewards111111111111111111111111111111", Rewards);
crate::declare_sysvar_id!("SysvarRewards111111111111111111111111111111", Rewards);
#[repr(C)]
#[derive(Serialize, Deserialize, Debug, Default, PartialEq)]

View File

@ -5,16 +5,7 @@
pub use crate::slot_hashes::{SlotHash, SlotHashes};
use crate::{account::Account, sysvar::Sysvar};
const ID: [u8; 32] = [
6, 167, 213, 23, 25, 47, 10, 175, 198, 242, 101, 227, 251, 119, 204, 122, 218, 130, 197, 41,
208, 190, 59, 19, 110, 45, 0, 85, 32, 0, 0, 0,
];
crate::solana_sysvar_id!(
ID,
"SysvarS1otHashes111111111111111111111111111",
SlotHashes
);
crate::declare_sysvar_id!("SysvarS1otHashes111111111111111111111111111", SlotHashes);
pub const MAX_SLOT_HASHES: usize = 512; // 512 slots to get your vote in

View File

@ -7,16 +7,7 @@ pub use crate::clock::Epoch;
use crate::{account::Account, sysvar::Sysvar};
use std::ops::Deref;
const ID: [u8; 32] = [
6, 167, 213, 23, 25, 53, 132, 208, 254, 237, 155, 179, 67, 29, 19, 32, 107, 229, 68, 40, 27,
87, 184, 86, 108, 197, 55, 95, 244, 0, 0, 0,
];
crate::solana_sysvar_id!(
ID,
"SysvarStakeHistory1111111111111111111111111",
StakeHistory
);
crate::declare_sysvar_id!("SysvarStakeHistory1111111111111111111111111", StakeHistory);
pub const MAX_STAKE_HISTORY: usize = 512; // it should never take as many as 512 epochs to warm up or cool down