Reformat imports to a consistent style for imports

rustfmt.toml configuration:
  imports_granularity = "One"
  group_imports = "One"
This commit is contained in:
Michael Vines
2021-12-03 09:00:31 -08:00
parent 0ef1b25e4b
commit b8837c04ec
397 changed files with 5990 additions and 5175 deletions

View File

@ -2,16 +2,19 @@
extern crate test;
use solana_bpf_loader_program::serialization::{
serialize_parameters_aligned, serialize_parameters_unaligned,
use {
solana_bpf_loader_program::serialization::{
serialize_parameters_aligned, serialize_parameters_unaligned,
},
solana_sdk::{
account::{Account, AccountSharedData},
bpf_loader,
keyed_account::KeyedAccount,
pubkey::Pubkey,
},
std::cell::RefCell,
test::Bencher,
};
use solana_sdk::{
account::{Account, AccountSharedData},
bpf_loader,
};
use solana_sdk::{keyed_account::KeyedAccount, pubkey::Pubkey};
use std::cell::RefCell;
use test::Bencher;
fn create_inputs() -> (
Pubkey,

View File

@ -1,10 +1,12 @@
use regex::Regex;
use std::{
fs::File,
io::{prelude::*, BufWriter, Read},
path::PathBuf,
process::exit,
str,
use {
regex::Regex,
std::{
fs::File,
io::{prelude::*, BufWriter, Read},
path::PathBuf,
process::exit,
str,
},
};
/**

View File

@ -1,8 +1,9 @@
use crate::alloc;
use alloc::{Alloc, AllocErr};
use solana_rbpf::aligned_memory::AlignedMemory;
use std::alloc::Layout;
use {
crate::alloc,
alloc::{Alloc, AllocErr},
solana_rbpf::aligned_memory::AlignedMemory,
std::alloc::Layout,
};
#[derive(Debug)]
pub struct BpfAllocator {

View File

@ -8,51 +8,53 @@ pub mod upgradeable;
pub mod upgradeable_with_jit;
pub mod with_jit;
use crate::{
serialization::{deserialize_parameters, serialize_parameters},
syscalls::SyscallError,
};
use log::{log_enabled, trace, Level::Trace};
use solana_measure::measure::Measure;
use solana_program_runtime::{
ic_logger_msg, ic_msg,
invoke_context::{ComputeMeter, Executor, InvokeContext},
log_collector::LogCollector,
stable_log,
};
use solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf::HOST_ALIGN,
elf::Executable,
error::{EbpfError, UserDefinedError},
static_analysis::Analysis,
verifier::{self, VerifierError},
vm::{Config, EbpfVm, InstructionMeter},
};
use solana_sdk::{
account::{ReadableAccount, WritableAccount},
account_utils::State,
bpf_loader, bpf_loader_deprecated,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
clock::Clock,
entrypoint::{HEAP_LENGTH, SUCCESS},
feature_set::{
do_support_realloc, reduce_required_deploy_balance,
reject_deployment_of_unresolved_syscalls,
reject_section_virtual_address_file_offset_mismatch, requestable_heap_size,
start_verify_shift32_imm, stop_verify_mul64_imm_nonzero,
use {
crate::{
serialization::{deserialize_parameters, serialize_parameters},
syscalls::SyscallError,
},
instruction::{AccountMeta, InstructionError},
keyed_account::{from_keyed_account, keyed_account_at_index, KeyedAccount},
loader_instruction::LoaderInstruction,
loader_upgradeable_instruction::UpgradeableLoaderInstruction,
program_utils::limited_deserialize,
pubkey::Pubkey,
rent::Rent,
system_instruction::{self, MAX_PERMITTED_DATA_LENGTH},
log::{log_enabled, trace, Level::Trace},
solana_measure::measure::Measure,
solana_program_runtime::{
ic_logger_msg, ic_msg,
invoke_context::{ComputeMeter, Executor, InvokeContext},
log_collector::LogCollector,
stable_log,
},
solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf::HOST_ALIGN,
elf::Executable,
error::{EbpfError, UserDefinedError},
static_analysis::Analysis,
verifier::{self, VerifierError},
vm::{Config, EbpfVm, InstructionMeter},
},
solana_sdk::{
account::{ReadableAccount, WritableAccount},
account_utils::State,
bpf_loader, bpf_loader_deprecated,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
clock::Clock,
entrypoint::{HEAP_LENGTH, SUCCESS},
feature_set::{
do_support_realloc, reduce_required_deploy_balance,
reject_deployment_of_unresolved_syscalls,
reject_section_virtual_address_file_offset_mismatch, requestable_heap_size,
start_verify_shift32_imm, stop_verify_mul64_imm_nonzero,
},
instruction::{AccountMeta, InstructionError},
keyed_account::{from_keyed_account, keyed_account_at_index, KeyedAccount},
loader_instruction::LoaderInstruction,
loader_upgradeable_instruction::UpgradeableLoaderInstruction,
program_utils::limited_deserialize,
pubkey::Pubkey,
rent::Rent,
system_instruction::{self, MAX_PERMITTED_DATA_LENGTH},
},
std::{cell::RefCell, fmt::Debug, rc::Rc, sync::Arc},
thiserror::Error,
};
use std::{cell::RefCell, fmt::Debug, rc::Rc, sync::Arc};
use thiserror::Error;
solana_sdk::declare_builtin!(
solana_sdk::bpf_loader::ID,
@ -1083,30 +1085,32 @@ impl Executor for BpfExecutor {
#[cfg(test)]
mod tests {
use super::*;
use rand::Rng;
use solana_program_runtime::invoke_context::mock_process_instruction;
use solana_rbpf::vm::SyscallRegistry;
use solana_runtime::{bank::Bank, bank_client::BankClient};
use solana_sdk::{
account::{
create_account_shared_data_for_test as create_account_for_test, AccountSharedData,
use {
super::*,
rand::Rng,
solana_program_runtime::invoke_context::mock_process_instruction,
solana_rbpf::vm::SyscallRegistry,
solana_runtime::{bank::Bank, bank_client::BankClient},
solana_sdk::{
account::{
create_account_shared_data_for_test as create_account_for_test, AccountSharedData,
},
account_utils::StateMut,
client::SyncClient,
clock::Clock,
feature_set::FeatureSet,
genesis_config::create_genesis_config,
instruction::{AccountMeta, Instruction, InstructionError},
message::Message,
native_token::LAMPORTS_PER_SOL,
pubkey::Pubkey,
rent::Rent,
signature::{Keypair, Signer},
system_program, sysvar,
transaction::TransactionError,
},
account_utils::StateMut,
client::SyncClient,
clock::Clock,
feature_set::FeatureSet,
genesis_config::create_genesis_config,
instruction::{AccountMeta, Instruction, InstructionError},
message::Message,
native_token::LAMPORTS_PER_SOL,
pubkey::Pubkey,
rent::Rent,
signature::{Keypair, Signer},
system_program, sysvar,
transaction::TransactionError,
std::{cell::RefCell, fs::File, io::Read, ops::Range, rc::Rc, sync::Arc},
};
use std::{cell::RefCell, fs::File, io::Read, ops::Range, rc::Rc, sync::Arc};
struct TestInstructionMeter {
remaining: u64,

View File

@ -1,15 +1,17 @@
use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
use solana_rbpf::{aligned_memory::AlignedMemory, ebpf::HOST_ALIGN};
use solana_sdk::{
account::{ReadableAccount, WritableAccount},
bpf_loader_deprecated,
entrypoint::{BPF_ALIGN_OF_U128, MAX_PERMITTED_DATA_INCREASE},
instruction::InstructionError,
keyed_account::KeyedAccount,
pubkey::Pubkey,
system_instruction::MAX_PERMITTED_DATA_LENGTH,
use {
byteorder::{ByteOrder, LittleEndian, WriteBytesExt},
solana_rbpf::{aligned_memory::AlignedMemory, ebpf::HOST_ALIGN},
solana_sdk::{
account::{ReadableAccount, WritableAccount},
bpf_loader_deprecated,
entrypoint::{BPF_ALIGN_OF_U128, MAX_PERMITTED_DATA_INCREASE},
instruction::InstructionError,
keyed_account::KeyedAccount,
pubkey::Pubkey,
system_instruction::MAX_PERMITTED_DATA_LENGTH,
},
std::{io::prelude::*, mem::size_of},
};
use std::{io::prelude::*, mem::size_of};
/// Look for a duplicate account and return its position if found
pub fn is_dup(accounts: &[KeyedAccount], keyed_account: &KeyedAccount) -> (bool, usize) {
@ -312,19 +314,20 @@ pub fn deserialize_parameters_aligned(
#[cfg(test)]
mod tests {
use super::*;
use solana_program_runtime::invoke_context::{prepare_mock_invoke_context, InvokeContext};
use solana_sdk::{
account::{Account, AccountSharedData},
account_info::AccountInfo,
bpf_loader,
entrypoint::deserialize,
};
use std::{
cell::RefCell,
rc::Rc,
// Hide Result from bindgen gets confused about generics in non-generic type declarations
slice::{from_raw_parts, from_raw_parts_mut},
use {
super::*,
solana_program_runtime::invoke_context::{prepare_mock_invoke_context, InvokeContext},
solana_sdk::{
account::{Account, AccountSharedData},
account_info::AccountInfo,
bpf_loader,
entrypoint::deserialize,
},
std::{
cell::RefCell,
rc::Rc,
slice::{from_raw_parts, from_raw_parts_mut},
},
};
#[test]

View File

@ -1,56 +1,58 @@
use crate::{alloc, BpfError};
use alloc::Alloc;
use solana_program_runtime::{
ic_logger_msg, ic_msg,
invoke_context::{ComputeMeter, InvokeContext},
stable_log,
};
use solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf,
error::EbpfError,
memory_region::{AccessType, MemoryMapping},
question_mark,
vm::{EbpfVm, SyscallObject, SyscallRegistry},
};
#[allow(deprecated)]
use solana_sdk::sysvar::fees::Fees;
use solana_sdk::{
account::{AccountSharedData, ReadableAccount, WritableAccount},
account_info::AccountInfo,
blake3, bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
clock::Clock,
entrypoint::{BPF_ALIGN_OF_U128, MAX_PERMITTED_DATA_INCREASE, SUCCESS},
epoch_schedule::EpochSchedule,
feature_set::{
blake3_syscall_enabled, demote_program_write_locks, disable_fees_sysvar,
do_support_realloc, libsecp256k1_0_5_upgrade_enabled,
prevent_calling_precompiles_as_programs, return_data_syscall_enabled,
secp256k1_recover_syscall_enabled, sol_log_data_syscall_enabled,
use {
crate::{alloc, BpfError},
alloc::Alloc,
solana_program_runtime::{
ic_logger_msg, ic_msg,
invoke_context::{ComputeMeter, InvokeContext},
stable_log,
},
hash::{Hasher, HASH_BYTES},
instruction::{AccountMeta, Instruction, InstructionError},
keccak,
message::Message,
native_loader,
precompiles::is_precompile,
program::MAX_RETURN_DATA,
pubkey::{Pubkey, PubkeyError, MAX_SEEDS, MAX_SEED_LEN},
rent::Rent,
secp256k1_recover::{
Secp256k1RecoverError, SECP256K1_PUBLIC_KEY_LENGTH, SECP256K1_SIGNATURE_LENGTH,
solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf,
error::EbpfError,
memory_region::{AccessType, MemoryMapping},
question_mark,
vm::{EbpfVm, SyscallObject, SyscallRegistry},
},
sysvar::{self, Sysvar, SysvarId},
solana_sdk::{
account::{AccountSharedData, ReadableAccount, WritableAccount},
account_info::AccountInfo,
blake3, bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
clock::Clock,
entrypoint::{BPF_ALIGN_OF_U128, MAX_PERMITTED_DATA_INCREASE, SUCCESS},
epoch_schedule::EpochSchedule,
feature_set::{
blake3_syscall_enabled, demote_program_write_locks, disable_fees_sysvar,
do_support_realloc, libsecp256k1_0_5_upgrade_enabled,
prevent_calling_precompiles_as_programs, return_data_syscall_enabled,
secp256k1_recover_syscall_enabled, sol_log_data_syscall_enabled,
},
hash::{Hasher, HASH_BYTES},
instruction::{AccountMeta, Instruction, InstructionError},
keccak,
message::Message,
native_loader,
precompiles::is_precompile,
program::MAX_RETURN_DATA,
pubkey::{Pubkey, PubkeyError, MAX_SEEDS, MAX_SEED_LEN},
rent::Rent,
secp256k1_recover::{
Secp256k1RecoverError, SECP256K1_PUBLIC_KEY_LENGTH, SECP256K1_SIGNATURE_LENGTH,
},
sysvar::{self, Sysvar, SysvarId},
},
std::{
alloc::Layout,
cell::{RefCell, RefMut},
mem::{align_of, size_of},
rc::Rc,
slice::from_raw_parts_mut,
str::{from_utf8, Utf8Error},
},
thiserror::Error as ThisError,
};
use std::{
alloc::Layout,
cell::{RefCell, RefMut},
mem::{align_of, size_of},
rc::Rc,
slice::from_raw_parts_mut,
str::{from_utf8, Utf8Error},
};
use thiserror::Error as ThisError;
/// Maximum signers
pub const MAX_SIGNERS: usize = 16;
@ -2641,13 +2643,15 @@ impl<'a, 'b> SyscallObject<BpfError> for SyscallLogData<'a, 'b> {
#[cfg(test)]
mod tests {
use super::*;
use solana_program_runtime::invoke_context::InvokeContext;
use solana_rbpf::{
ebpf::HOST_ALIGN, memory_region::MemoryRegion, user_error::UserError, vm::Config,
use {
super::*,
solana_program_runtime::invoke_context::InvokeContext,
solana_rbpf::{
ebpf::HOST_ALIGN, memory_region::MemoryRegion, user_error::UserError, vm::Config,
},
solana_sdk::{bpf_loader, fee_calculator::FeeCalculator, hash::hashv},
std::str::FromStr,
};
use solana_sdk::{bpf_loader, fee_calculator::FeeCalculator, hash::hashv};
use std::str::FromStr;
macro_rules! assert_access_violation {
($result:expr, $va:expr, $len:expr) => {

View File

@ -1,5 +1,7 @@
use solana_program_runtime::invoke_context::InvokeContext;
use solana_sdk::instruction::InstructionError;
use {
solana_program_runtime::invoke_context::InvokeContext,
solana_sdk::instruction::InstructionError,
};
pub fn process_instruction(
_first_instruction_account: usize,

View File

@ -1,9 +1,10 @@
use crate::id;
use crate::{ConfigKeys, ConfigState};
use solana_sdk::{
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
system_instruction,
use {
crate::{id, ConfigKeys, ConfigState},
solana_sdk::{
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
system_instruction,
},
};
fn initialize_account<T: ConfigState>(config_pubkey: &Pubkey) -> Instruction {

View File

@ -1,17 +1,19 @@
//! Config program
use crate::ConfigKeys;
use bincode::deserialize;
use solana_program_runtime::{ic_msg, invoke_context::InvokeContext};
use solana_sdk::{
account::{ReadableAccount, WritableAccount},
feature_set,
instruction::InstructionError,
keyed_account::keyed_account_at_index,
program_utils::limited_deserialize,
pubkey::Pubkey,
use {
crate::ConfigKeys,
bincode::deserialize,
solana_program_runtime::{ic_msg, invoke_context::InvokeContext},
solana_sdk::{
account::{ReadableAccount, WritableAccount},
feature_set,
instruction::InstructionError,
keyed_account::keyed_account_at_index,
program_utils::limited_deserialize,
pubkey::Pubkey,
},
std::collections::BTreeSet,
};
use std::collections::BTreeSet;
pub fn process_instruction(
first_instruction_account: usize,
@ -137,18 +139,20 @@ pub fn process_instruction(
#[cfg(test)]
mod tests {
use super::*;
use crate::{config_instruction, get_config_data, id, ConfigKeys, ConfigState};
use bincode::serialized_size;
use serde_derive::{Deserialize, Serialize};
use solana_program_runtime::invoke_context::mock_process_instruction;
use solana_sdk::{
account::AccountSharedData,
pubkey::Pubkey,
signature::{Keypair, Signer},
system_instruction::SystemInstruction,
use {
super::*,
crate::{config_instruction, get_config_data, id, ConfigKeys, ConfigState},
bincode::serialized_size,
serde_derive::{Deserialize, Serialize},
solana_program_runtime::invoke_context::mock_process_instruction,
solana_sdk::{
account::AccountSharedData,
pubkey::Pubkey,
signature::{Keypair, Signer},
system_instruction::SystemInstruction,
},
std::{cell::RefCell, rc::Rc},
};
use std::{cell::RefCell, rc::Rc};
fn process_instruction(
instruction_data: &[u8],

View File

@ -1,14 +1,16 @@
use crate::{config_instruction, ConfigState};
///
/// A library for creating a trusted date oracle.
///
use bincode::{deserialize, serialized_size};
use chrono::{
prelude::{Date, DateTime, TimeZone, Utc},
serde::ts_seconds,
use {
crate::{config_instruction, ConfigState},
chrono::{
prelude::{Date, DateTime, TimeZone, Utc},
serde::ts_seconds,
},
serde_derive::{Deserialize, Serialize},
solana_sdk::{instruction::Instruction, pubkey::Pubkey},
};
use serde_derive::{Deserialize, Serialize};
use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct DateConfig {

View File

@ -3,16 +3,17 @@ pub mod config_instruction;
pub mod config_processor;
pub mod date_instruction;
use bincode::{deserialize, serialize, serialized_size};
use serde_derive::{Deserialize, Serialize};
use solana_sdk::{
account::{Account, AccountSharedData},
pubkey::Pubkey,
short_vec,
stake::config::Config as StakeConfig,
};
pub use solana_sdk::config::program::id;
use {
bincode::{deserialize, serialize, serialized_size},
serde_derive::{Deserialize, Serialize},
solana_sdk::{
account::{Account, AccountSharedData},
pubkey::Pubkey,
short_vec,
stake::config::Config as StakeConfig,
},
};
pub trait ConfigState: serde::Serialize + Default {
/// Maximum space that the serialized representation will require

View File

@ -1,20 +1,21 @@
//! config for staking
//! carries variables that the stake program cares about
use bincode::deserialize;
use solana_config_program::{create_config_account, get_config_data};
use solana_sdk::{
account::{AccountSharedData, ReadableAccount, WritableAccount},
genesis_config::GenesisConfig,
instruction::InstructionError,
keyed_account::KeyedAccount,
stake::config::{self, Config},
};
#[deprecated(
since = "1.8.0",
note = "Please use `solana_sdk::stake::config` or `solana_program::stake::config` instead"
)]
pub use solana_sdk::stake::config::*;
use {
bincode::deserialize,
solana_config_program::{create_config_account, get_config_data},
solana_sdk::{
account::{AccountSharedData, ReadableAccount, WritableAccount},
genesis_config::GenesisConfig,
instruction::InstructionError,
keyed_account::KeyedAccount,
stake::config::{self, Config},
},
};
pub fn from<T: ReadableAccount>(account: &T) -> Option<Config> {
get_config_data(account.data())
@ -46,9 +47,7 @@ pub fn add_genesis_account(genesis_config: &mut GenesisConfig) -> u64 {
#[cfg(test)]
mod tests {
use super::*;
use solana_sdk::pubkey::Pubkey;
use std::cell::RefCell;
use {super::*, solana_sdk::pubkey::Pubkey, std::cell::RefCell};
#[test]
fn test() {

View File

@ -1,7 +1,6 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
use solana_sdk::genesis_config::GenesisConfig;
#[deprecated(
since = "1.8.0",
note = "Please use `solana_sdk::stake::program::id` or `solana_program::stake::program::id` instead"

View File

@ -1,3 +1,8 @@
#[deprecated(
since = "1.8.0",
note = "Please use `solana_sdk::stake::instruction` or `solana_program::stake::instruction` instead"
)]
pub use solana_sdk::stake::instruction::*;
use {
crate::{config, stake_state::StakeAccount},
log::*,
@ -16,12 +21,6 @@ use {
},
};
#[deprecated(
since = "1.8.0",
note = "Please use `solana_sdk::stake::instruction` or `solana_program::stake::instruction` instead"
)]
pub use solana_sdk::stake::instruction::*;
pub fn process_instruction(
first_instruction_account: usize,
data: &[u8],
@ -338,25 +337,27 @@ pub fn process_instruction(
#[cfg(test)]
mod tests {
use super::*;
use crate::stake_state::{Meta, StakeState};
use bincode::serialize;
use solana_program_runtime::invoke_context::{
mock_process_instruction, prepare_mock_invoke_context, InvokeContext,
};
use solana_sdk::{
account::{self, AccountSharedData},
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
rent::Rent,
stake::{
config as stake_config,
instruction::{self, LockupArgs},
state::{Authorized, Lockup, StakeAuthorize},
use {
super::*,
crate::stake_state::{Meta, StakeState},
bincode::serialize,
solana_program_runtime::invoke_context::{
mock_process_instruction, prepare_mock_invoke_context, InvokeContext,
},
sysvar::{stake_history::StakeHistory, Sysvar},
solana_sdk::{
account::{self, AccountSharedData},
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
rent::Rent,
stake::{
config as stake_config,
instruction::{self, LockupArgs},
state::{Authorized, Lockup, StakeAuthorize},
},
sysvar::{stake_history::StakeHistory, Sysvar},
},
std::{cell::RefCell, rc::Rc, str::FromStr},
};
use std::{cell::RefCell, rc::Rc, str::FromStr};
fn create_default_account() -> Rc<RefCell<AccountSharedData>> {
AccountSharedData::new_ref(0, 0, &Pubkey::new_unique())

View File

@ -3,6 +3,11 @@
//! * keep track of rewards
//! * own mining pools
#[deprecated(
since = "1.8.0",
note = "Please use `solana_sdk::stake::state` or `solana_program::stake::state` instead"
)]
pub use solana_sdk::stake::state::*;
use {
solana_program_runtime::{ic_msg, invoke_context::InvokeContext},
solana_sdk::{
@ -25,12 +30,6 @@ use {
std::{collections::HashSet, convert::TryFrom},
};
#[deprecated(
since = "1.8.0",
note = "Please use `solana_sdk::stake::state` or `solana_program::stake::state` instead"
)]
pub use solana_sdk::stake::state::*;
#[derive(Debug)]
pub enum SkippedReason {
ZeroPoints,
@ -1374,18 +1373,20 @@ fn do_create_account(
#[cfg(test)]
mod tests {
use super::*;
use proptest::prelude::*;
use solana_program_runtime::invoke_context::InvokeContext;
use solana_sdk::{
account::{AccountSharedData, WritableAccount},
clock::UnixTimestamp,
native_token,
pubkey::Pubkey,
system_program,
use {
super::*,
proptest::prelude::*,
solana_program_runtime::invoke_context::InvokeContext,
solana_sdk::{
account::{AccountSharedData, WritableAccount},
clock::UnixTimestamp,
native_token,
pubkey::Pubkey,
system_program,
},
solana_vote_program::vote_state,
std::{cell::RefCell, iter::FromIterator},
};
use solana_vote_program::vote_state;
use std::{cell::RefCell, iter::FromIterator};
#[test]
fn test_authorized_authorize() {

View File

@ -1,7 +1,9 @@
use log::*;
use serde_derive::{Deserialize, Serialize};
use solana_sdk::{clock::Epoch, pubkey::Pubkey};
use std::collections::BTreeMap;
use {
log::*,
serde_derive::{Deserialize, Serialize},
solana_sdk::{clock::Epoch, pubkey::Pubkey},
std::collections::BTreeMap,
};
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone, AbiExample)]
pub struct AuthorizedVoters {

View File

@ -1,28 +1,30 @@
//! Vote program
//! Receive and processes votes from validators
use crate::{
id,
vote_state::{self, Vote, VoteAuthorize, VoteInit, VoteState},
use {
crate::{
id,
vote_state::{self, Vote, VoteAuthorize, VoteInit, VoteState},
},
log::*,
num_derive::{FromPrimitive, ToPrimitive},
serde_derive::{Deserialize, Serialize},
solana_metrics::inc_new_counter_info,
solana_program_runtime::invoke_context::InvokeContext,
solana_sdk::{
decode_error::DecodeError,
feature_set,
hash::Hash,
instruction::{AccountMeta, Instruction, InstructionError},
keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount},
program_utils::limited_deserialize,
pubkey::Pubkey,
system_instruction,
sysvar::{self, clock::Clock, slot_hashes::SlotHashes},
},
std::collections::HashSet,
thiserror::Error,
};
use log::*;
use num_derive::{FromPrimitive, ToPrimitive};
use serde_derive::{Deserialize, Serialize};
use solana_metrics::inc_new_counter_info;
use solana_program_runtime::invoke_context::InvokeContext;
use solana_sdk::{
decode_error::DecodeError,
feature_set,
hash::Hash,
instruction::{AccountMeta, Instruction, InstructionError},
keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount},
program_utils::limited_deserialize,
pubkey::Pubkey,
system_instruction,
sysvar::{self, clock::Clock, slot_hashes::SlotHashes},
};
use std::collections::HashSet;
use thiserror::Error;
/// Reasons the stake might have had an error
#[derive(Error, Debug, Clone, PartialEq, FromPrimitive, ToPrimitive)]
@ -405,15 +407,16 @@ pub fn process_instruction(
#[cfg(test)]
mod tests {
use super::*;
use bincode::serialize;
use solana_program_runtime::invoke_context::mock_process_instruction;
use solana_sdk::{
account::{self, Account, AccountSharedData},
rent::Rent,
use {
super::*,
bincode::serialize,
solana_program_runtime::invoke_context::mock_process_instruction,
solana_sdk::{
account::{self, Account, AccountSharedData},
rent::Rent,
},
std::{cell::RefCell, rc::Rc, str::FromStr},
};
use std::str::FromStr;
use std::{cell::RefCell, rc::Rc};
fn create_default_account() -> Rc<RefCell<AccountSharedData>> {
AccountSharedData::new_ref(0, 0, &Pubkey::new_unique())

View File

@ -1,26 +1,29 @@
//! Vote state, vote program
//! Receive and processes votes from validators
use crate::authorized_voters::AuthorizedVoters;
use crate::{id, vote_instruction::VoteError};
use bincode::{deserialize, serialize_into, serialized_size, ErrorKind};
use log::*;
use serde_derive::{Deserialize, Serialize};
use solana_sdk::{
account::{AccountSharedData, ReadableAccount, WritableAccount},
account_utils::State,
clock::{Epoch, Slot, UnixTimestamp},
epoch_schedule::MAX_LEADER_SCHEDULE_EPOCH_OFFSET,
hash::Hash,
instruction::InstructionError,
keyed_account::KeyedAccount,
pubkey::Pubkey,
rent::Rent,
slot_hashes::SlotHash,
sysvar::clock::Clock,
use {
crate::{authorized_voters::AuthorizedVoters, id, vote_instruction::VoteError},
bincode::{deserialize, serialize_into, serialized_size, ErrorKind},
log::*,
serde_derive::{Deserialize, Serialize},
solana_sdk::{
account::{AccountSharedData, ReadableAccount, WritableAccount},
account_utils::State,
clock::{Epoch, Slot, UnixTimestamp},
epoch_schedule::MAX_LEADER_SCHEDULE_EPOCH_OFFSET,
hash::Hash,
instruction::InstructionError,
keyed_account::KeyedAccount,
pubkey::Pubkey,
rent::Rent,
slot_hashes::SlotHash,
sysvar::clock::Clock,
},
std::{
boxed::Box,
cmp::Ordering,
collections::{HashSet, VecDeque},
},
};
use std::boxed::Box;
use std::cmp::Ordering;
use std::collections::{HashSet, VecDeque};
mod vote_state_0_23_5;
pub mod vote_state_versions;
@ -793,15 +796,17 @@ pub fn create_account(
#[cfg(test)]
mod tests {
use super::*;
use crate::vote_state;
use solana_sdk::{
account::AccountSharedData,
account_utils::StateMut,
hash::hash,
keyed_account::{get_signers, keyed_account_at_index},
use {
super::*,
crate::vote_state,
solana_sdk::{
account::AccountSharedData,
account_utils::StateMut,
hash::hash,
keyed_account::{get_signers, keyed_account_at_index},
},
std::cell::RefCell,
};
use std::cell::RefCell;
const MAX_RECENT_VOTES: usize = 16;

View File

@ -1,5 +1,4 @@
use super::*;
use crate::vote_state::vote_state_0_23_5::VoteState0_23_5;
use {super::*, crate::vote_state::vote_state_0_23_5::VoteState0_23_5};
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
pub enum VoteStateVersions {

View File

@ -1,16 +1,17 @@
use solana_sdk::{
clock::Slot,
hash::Hash,
instruction::CompiledInstruction,
program_utils::limited_deserialize,
pubkey::Pubkey,
signature::{Keypair, Signer},
transaction::{SanitizedTransaction, Transaction},
};
use crate::{
vote_instruction::{self, VoteInstruction},
vote_state::Vote,
use {
crate::{
vote_instruction::{self, VoteInstruction},
vote_state::Vote,
},
solana_sdk::{
clock::Slot,
hash::Hash,
instruction::CompiledInstruction,
program_utils::limited_deserialize,
pubkey::Pubkey,
signature::{Keypair, Signer},
transaction::{SanitizedTransaction, Transaction},
},
};
pub type ParsedVote = (Pubkey, Vote, Option<Hash>);
@ -104,8 +105,7 @@ pub fn new_vote_transaction(
#[cfg(test)]
mod test {
use super::*;
use solana_sdk::hash::hash;
use {super::*, solana_sdk::hash::hash};
fn run_test_parse_vote_transaction(input_hash: Option<Hash>) {
let node_keypair = Keypair::new();