Revert "Revert "Reformat imports to a consistent style for imports""
This reverts commit d7377d4794
.
This commit is contained in:
committed by
Tyera Eulberg
parent
9fff4aa8b8
commit
9f53f3455a
@@ -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,
|
||||
|
@@ -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 {
|
||||
|
@@ -1,8 +1,6 @@
|
||||
#![allow(clippy::upper_case_acronyms)]
|
||||
|
||||
use crate::BpfError;
|
||||
use solana_rbpf::ebpf;
|
||||
use thiserror::Error;
|
||||
use {crate::BpfError, solana_rbpf::ebpf, thiserror::Error};
|
||||
|
||||
/// Error definitions
|
||||
#[derive(Debug, Error, PartialEq)]
|
||||
|
@@ -8,50 +8,52 @@ 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_rbpf::{
|
||||
aligned_memory::AlignedMemory,
|
||||
ebpf::HOST_ALIGN,
|
||||
elf::Executable,
|
||||
error::{EbpfError, UserDefinedError},
|
||||
static_analysis::Analysis,
|
||||
verifier::{self, VerifierError},
|
||||
vm::{Config, EbpfVm, InstructionMeter},
|
||||
};
|
||||
use solana_runtime::message_processor::MessageProcessor;
|
||||
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::{
|
||||
add_missing_program_error_mappings, close_upgradeable_program_accounts, fix_write_privs,
|
||||
reduce_required_deploy_balance, reject_all_elf_rw,
|
||||
reject_deployment_of_unresolved_syscalls,
|
||||
reject_section_virtual_address_file_offset_mismatch, start_verify_shift32_imm,
|
||||
stop_verify_mul64_imm_nonzero, upgradeable_close_instruction,
|
||||
use {
|
||||
crate::{
|
||||
serialization::{deserialize_parameters, serialize_parameters},
|
||||
syscalls::SyscallError,
|
||||
},
|
||||
ic_logger_msg, ic_msg,
|
||||
instruction::{AccountMeta, InstructionError},
|
||||
keyed_account::{from_keyed_account, keyed_account_at_index, KeyedAccount},
|
||||
loader_instruction::LoaderInstruction,
|
||||
loader_upgradeable_instruction::UpgradeableLoaderInstruction,
|
||||
process_instruction::{stable_log, ComputeMeter, Executor, InvokeContext, Logger},
|
||||
program_error::{ACCOUNT_NOT_RENT_EXEMPT, BORSH_IO_ERROR},
|
||||
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_rbpf::{
|
||||
aligned_memory::AlignedMemory,
|
||||
ebpf::HOST_ALIGN,
|
||||
elf::Executable,
|
||||
error::{EbpfError, UserDefinedError},
|
||||
static_analysis::Analysis,
|
||||
verifier::{self, VerifierError},
|
||||
vm::{Config, EbpfVm, InstructionMeter},
|
||||
},
|
||||
solana_runtime::message_processor::MessageProcessor,
|
||||
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::{
|
||||
add_missing_program_error_mappings, close_upgradeable_program_accounts,
|
||||
fix_write_privs, reduce_required_deploy_balance, reject_all_elf_rw,
|
||||
reject_deployment_of_unresolved_syscalls,
|
||||
reject_section_virtual_address_file_offset_mismatch, start_verify_shift32_imm,
|
||||
stop_verify_mul64_imm_nonzero, upgradeable_close_instruction,
|
||||
},
|
||||
ic_logger_msg, ic_msg,
|
||||
instruction::{AccountMeta, InstructionError},
|
||||
keyed_account::{from_keyed_account, keyed_account_at_index, KeyedAccount},
|
||||
loader_instruction::LoaderInstruction,
|
||||
loader_upgradeable_instruction::UpgradeableLoaderInstruction,
|
||||
process_instruction::{stable_log, ComputeMeter, Executor, InvokeContext, Logger},
|
||||
program_error::{ACCOUNT_NOT_RENT_EXEMPT, BORSH_IO_ERROR},
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
rent::Rent,
|
||||
system_instruction::{self, MAX_PERMITTED_DATA_LENGTH},
|
||||
},
|
||||
std::{cell::RefCell, fmt::Debug, pin::Pin, rc::Rc, sync::Arc},
|
||||
thiserror::Error,
|
||||
};
|
||||
use std::{cell::RefCell, fmt::Debug, pin::Pin, rc::Rc, sync::Arc};
|
||||
use thiserror::Error;
|
||||
|
||||
solana_sdk::declare_builtin!(
|
||||
solana_sdk::bpf_loader::ID,
|
||||
@@ -1003,35 +1005,37 @@ impl Executor for BpfExecutor {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use rand::Rng;
|
||||
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_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::Instruction,
|
||||
instruction::{AccountMeta, InstructionError},
|
||||
keyed_account::KeyedAccount,
|
||||
message::Message,
|
||||
native_token::LAMPORTS_PER_SOL,
|
||||
process_instruction::{
|
||||
BpfComputeBudget, InvokeContextStackFrame, MockComputeMeter, MockInvokeContext,
|
||||
MockLogger,
|
||||
},
|
||||
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::Instruction,
|
||||
instruction::{AccountMeta, InstructionError},
|
||||
keyed_account::KeyedAccount,
|
||||
message::Message,
|
||||
native_token::LAMPORTS_PER_SOL,
|
||||
process_instruction::{
|
||||
BpfComputeBudget, InvokeContextStackFrame, MockComputeMeter, MockInvokeContext,
|
||||
MockLogger,
|
||||
},
|
||||
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,
|
||||
|
@@ -1,14 +1,16 @@
|
||||
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,
|
||||
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,
|
||||
},
|
||||
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) {
|
||||
@@ -283,18 +285,19 @@ pub fn deserialize_parameters_aligned(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
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_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]
|
||||
|
@@ -1,56 +1,58 @@
|
||||
use crate::{alloc, BpfError};
|
||||
use alloc::Alloc;
|
||||
use solana_rbpf::{
|
||||
aligned_memory::AlignedMemory,
|
||||
ebpf,
|
||||
error::EbpfError,
|
||||
memory_region::{AccessType, MemoryMapping},
|
||||
question_mark,
|
||||
vm::{EbpfVm, SyscallObject, SyscallRegistry},
|
||||
};
|
||||
use solana_runtime::message_processor::MessageProcessor;
|
||||
use solana_sdk::{
|
||||
account::{Account, AccountSharedData, ReadableAccount},
|
||||
account_info::AccountInfo,
|
||||
account_utils::StateMut,
|
||||
bpf_loader, bpf_loader_deprecated,
|
||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
clock::Clock,
|
||||
entrypoint::{BPF_ALIGN_OF_U128, MAX_PERMITTED_DATA_INCREASE, SUCCESS},
|
||||
epoch_schedule::EpochSchedule,
|
||||
feature_set::{
|
||||
allow_native_ids, check_seed_length, close_upgradeable_program_accounts, cpi_data_cost,
|
||||
demote_program_write_locks, enforce_aligned_host_addrs, keccak256_syscall_enabled,
|
||||
libsecp256k1_0_5_upgrade_enabled, mem_overlap_fix, memory_ops_syscalls,
|
||||
return_data_syscall_enabled, secp256k1_recover_syscall_enabled,
|
||||
set_upgrade_authority_via_cpi_enabled, sol_log_data_syscall_enabled, sysvar_via_syscall,
|
||||
update_data_on_realloc,
|
||||
use {
|
||||
crate::{alloc, BpfError},
|
||||
alloc::Alloc,
|
||||
solana_rbpf::{
|
||||
aligned_memory::AlignedMemory,
|
||||
ebpf,
|
||||
error::EbpfError,
|
||||
memory_region::{AccessType, MemoryMapping},
|
||||
question_mark,
|
||||
vm::{EbpfVm, SyscallObject, SyscallRegistry},
|
||||
},
|
||||
hash::{Hasher, HASH_BYTES},
|
||||
ic_msg,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
keccak,
|
||||
keyed_account::KeyedAccount,
|
||||
native_loader,
|
||||
process_instruction::{self, stable_log, ComputeMeter, InvokeContext, Logger},
|
||||
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_runtime::message_processor::MessageProcessor,
|
||||
solana_sdk::{
|
||||
account::{Account, AccountSharedData, ReadableAccount},
|
||||
account_info::AccountInfo,
|
||||
account_utils::StateMut,
|
||||
bpf_loader, bpf_loader_deprecated,
|
||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
clock::Clock,
|
||||
entrypoint::{BPF_ALIGN_OF_U128, MAX_PERMITTED_DATA_INCREASE, SUCCESS},
|
||||
epoch_schedule::EpochSchedule,
|
||||
feature_set::{
|
||||
allow_native_ids, check_seed_length, close_upgradeable_program_accounts, cpi_data_cost,
|
||||
demote_program_write_locks, enforce_aligned_host_addrs, keccak256_syscall_enabled,
|
||||
libsecp256k1_0_5_upgrade_enabled, mem_overlap_fix, memory_ops_syscalls,
|
||||
return_data_syscall_enabled, secp256k1_recover_syscall_enabled,
|
||||
set_upgrade_authority_via_cpi_enabled, sol_log_data_syscall_enabled,
|
||||
sysvar_via_syscall, update_data_on_realloc,
|
||||
},
|
||||
hash::{Hasher, HASH_BYTES},
|
||||
ic_msg,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
keccak,
|
||||
keyed_account::KeyedAccount,
|
||||
native_loader,
|
||||
process_instruction::{self, stable_log, ComputeMeter, InvokeContext, Logger},
|
||||
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, fees::Fees, Sysvar, SysvarId},
|
||||
},
|
||||
sysvar::{self, fees::Fees, Sysvar, SysvarId},
|
||||
std::{
|
||||
alloc::Layout,
|
||||
cell::{Ref, RefCell, RefMut},
|
||||
cmp::min,
|
||||
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::{Ref, RefCell, RefMut},
|
||||
cmp::min,
|
||||
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;
|
||||
@@ -2762,17 +2764,19 @@ impl<'a> SyscallObject<BpfError> for SyscallLogData<'a> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_rbpf::{
|
||||
ebpf::HOST_ALIGN, memory_region::MemoryRegion, user_error::UserError, vm::Config,
|
||||
use {
|
||||
super::*,
|
||||
solana_rbpf::{
|
||||
ebpf::HOST_ALIGN, memory_region::MemoryRegion, user_error::UserError, vm::Config,
|
||||
},
|
||||
solana_sdk::{
|
||||
bpf_loader,
|
||||
fee_calculator::FeeCalculator,
|
||||
hash::hashv,
|
||||
process_instruction::{MockComputeMeter, MockInvokeContext, MockLogger},
|
||||
},
|
||||
std::str::FromStr,
|
||||
};
|
||||
use solana_sdk::{
|
||||
bpf_loader,
|
||||
fee_calculator::FeeCalculator,
|
||||
hash::hashv,
|
||||
process_instruction::{MockComputeMeter, MockInvokeContext, MockLogger},
|
||||
};
|
||||
use std::str::FromStr;
|
||||
|
||||
macro_rules! assert_access_violation {
|
||||
($result:expr, $va:expr, $len:expr) => {
|
||||
|
@@ -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 {
|
||||
|
@@ -1,17 +1,19 @@
|
||||
//! Config program
|
||||
|
||||
use crate::ConfigKeys;
|
||||
use bincode::deserialize;
|
||||
use solana_sdk::{
|
||||
account::{ReadableAccount, WritableAccount},
|
||||
feature_set, ic_msg,
|
||||
instruction::InstructionError,
|
||||
keyed_account::keyed_account_at_index,
|
||||
process_instruction::InvokeContext,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
use {
|
||||
crate::ConfigKeys,
|
||||
bincode::deserialize,
|
||||
solana_sdk::{
|
||||
account::{ReadableAccount, WritableAccount},
|
||||
feature_set, ic_msg,
|
||||
instruction::InstructionError,
|
||||
keyed_account::keyed_account_at_index,
|
||||
process_instruction::InvokeContext,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
std::collections::BTreeSet,
|
||||
};
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
pub fn process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
@@ -136,18 +138,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_sdk::{
|
||||
account::{Account, AccountSharedData},
|
||||
keyed_account::create_keyed_accounts_unified,
|
||||
process_instruction::MockInvokeContext,
|
||||
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_sdk::{
|
||||
account::{Account, AccountSharedData},
|
||||
keyed_account::create_keyed_accounts_unified,
|
||||
process_instruction::MockInvokeContext,
|
||||
signature::{Keypair, Signer},
|
||||
system_instruction::SystemInstruction,
|
||||
},
|
||||
std::cell::RefCell,
|
||||
};
|
||||
use std::cell::RefCell;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
struct MyConfig {
|
||||
|
@@ -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 {
|
||||
|
@@ -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
|
||||
|
@@ -13,15 +13,17 @@ pub fn process_instruction(
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_sdk::{
|
||||
ed25519_instruction::new_ed25519_instruction,
|
||||
feature_set::FeatureSet,
|
||||
hash::Hash,
|
||||
signature::{Keypair, Signer},
|
||||
transaction::Transaction,
|
||||
use {
|
||||
rand::{thread_rng, Rng},
|
||||
solana_sdk::{
|
||||
ed25519_instruction::new_ed25519_instruction,
|
||||
feature_set::FeatureSet,
|
||||
hash::Hash,
|
||||
signature::{Keypair, Signer},
|
||||
transaction::Transaction,
|
||||
},
|
||||
std::sync::Arc,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
fn test_ed25519() {
|
||||
|
@@ -1,10 +1,13 @@
|
||||
//! Exchange program
|
||||
|
||||
use crate::exchange_state::*;
|
||||
use crate::id;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use solana_sdk::instruction::{AccountMeta, Instruction};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use {
|
||||
crate::{exchange_state::*, id},
|
||||
serde_derive::{Deserialize, Serialize},
|
||||
solana_sdk::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
|
||||
pub struct OrderRequestInfo {
|
||||
|
@@ -1,23 +1,23 @@
|
||||
//! Config processor
|
||||
|
||||
use crate::exchange_instruction::*;
|
||||
use crate::exchange_state::*;
|
||||
use crate::faucet;
|
||||
use log::*;
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
use serde_derive::Serialize;
|
||||
use solana_metrics::inc_new_counter_info;
|
||||
use solana_sdk::{
|
||||
account::{ReadableAccount, WritableAccount},
|
||||
decode_error::DecodeError,
|
||||
instruction::InstructionError,
|
||||
keyed_account::KeyedAccount,
|
||||
process_instruction::InvokeContext,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
use {
|
||||
crate::{exchange_instruction::*, exchange_state::*, faucet},
|
||||
log::*,
|
||||
num_derive::{FromPrimitive, ToPrimitive},
|
||||
serde_derive::Serialize,
|
||||
solana_metrics::inc_new_counter_info,
|
||||
solana_sdk::{
|
||||
account::{ReadableAccount, WritableAccount},
|
||||
decode_error::DecodeError,
|
||||
instruction::InstructionError,
|
||||
keyed_account::KeyedAccount,
|
||||
process_instruction::InvokeContext,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
std::cmp,
|
||||
thiserror::Error,
|
||||
};
|
||||
use std::cmp;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug, Serialize, Clone, PartialEq, FromPrimitive, ToPrimitive)]
|
||||
pub enum ExchangeError {
|
||||
@@ -510,16 +510,19 @@ pub fn process_instruction(
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::{exchange_instruction, id};
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_runtime::bank_client::BankClient;
|
||||
use solana_sdk::client::SyncClient;
|
||||
use solana_sdk::genesis_config::create_genesis_config;
|
||||
use solana_sdk::message::Message;
|
||||
use solana_sdk::signature::{Keypair, Signer};
|
||||
use solana_sdk::system_instruction;
|
||||
use std::mem;
|
||||
use {
|
||||
super::*,
|
||||
crate::{exchange_instruction, id},
|
||||
solana_runtime::{bank::Bank, bank_client::BankClient},
|
||||
solana_sdk::{
|
||||
client::SyncClient,
|
||||
genesis_config::create_genesis_config,
|
||||
message::Message,
|
||||
signature::{Keypair, Signer},
|
||||
system_instruction,
|
||||
},
|
||||
std::mem,
|
||||
};
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn try_calc(
|
||||
|
@@ -1,6 +1,8 @@
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use std::{error, fmt};
|
||||
use {
|
||||
serde_derive::{Deserialize, Serialize},
|
||||
solana_sdk::pubkey::Pubkey,
|
||||
std::{error, fmt},
|
||||
};
|
||||
|
||||
/// Fixed-point scaler, 10 = one base 10 digit to the right of the decimal, 100 = 2, ...
|
||||
/// Used by both price and amount in their fixed point representation
|
||||
|
@@ -13,17 +13,19 @@ pub fn process_instruction(
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_sdk::{
|
||||
feature_set,
|
||||
hash::Hash,
|
||||
secp256k1_instruction::{
|
||||
new_secp256k1_instruction, SecpSignatureOffsets, SIGNATURE_OFFSETS_SERIALIZED_SIZE,
|
||||
use {
|
||||
rand::{thread_rng, Rng},
|
||||
solana_sdk::{
|
||||
feature_set,
|
||||
hash::Hash,
|
||||
secp256k1_instruction::{
|
||||
new_secp256k1_instruction, SecpSignatureOffsets, SIGNATURE_OFFSETS_SERIALIZED_SIZE,
|
||||
},
|
||||
signature::{Keypair, Signer},
|
||||
transaction::Transaction,
|
||||
},
|
||||
signature::{Keypair, Signer},
|
||||
transaction::Transaction,
|
||||
std::sync::Arc,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
fn test_secp256k1() {
|
||||
|
@@ -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.7.2",
|
||||
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() {
|
||||
|
@@ -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.7.2",
|
||||
note = "Please use `solana_sdk::stake::program::id` or `solana_program::stake::program::id` instead"
|
||||
|
@@ -1,3 +1,8 @@
|
||||
#[deprecated(
|
||||
since = "1.7.2",
|
||||
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::*,
|
||||
@@ -17,12 +22,6 @@ use {
|
||||
},
|
||||
};
|
||||
|
||||
#[deprecated(
|
||||
since = "1.7.2",
|
||||
note = "Please use `solana_sdk::stake::instruction` or `solana_program::stake::instruction` instead"
|
||||
)]
|
||||
pub use solana_sdk::stake::instruction::*;
|
||||
|
||||
pub fn process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
data: &[u8],
|
||||
@@ -274,23 +273,25 @@ pub fn process_instruction(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::stake_state::{Meta, StakeState};
|
||||
use bincode::serialize;
|
||||
use solana_sdk::{
|
||||
account::{self, Account, AccountSharedData, WritableAccount},
|
||||
instruction::{AccountMeta, Instruction},
|
||||
keyed_account::KeyedAccount,
|
||||
process_instruction::{mock_set_sysvar, MockInvokeContext},
|
||||
rent::Rent,
|
||||
stake::{
|
||||
config as stake_config,
|
||||
instruction::{self, LockupArgs},
|
||||
state::{Authorized, Lockup, StakeAuthorize},
|
||||
use {
|
||||
super::*,
|
||||
crate::stake_state::{Meta, StakeState},
|
||||
bincode::serialize,
|
||||
solana_sdk::{
|
||||
account::{self, Account, AccountSharedData, WritableAccount},
|
||||
instruction::{AccountMeta, Instruction},
|
||||
keyed_account::KeyedAccount,
|
||||
process_instruction::{mock_set_sysvar, MockInvokeContext},
|
||||
rent::Rent,
|
||||
stake::{
|
||||
config as stake_config,
|
||||
instruction::{self, LockupArgs},
|
||||
state::{Authorized, Lockup, StakeAuthorize},
|
||||
},
|
||||
sysvar::stake_history::StakeHistory,
|
||||
},
|
||||
sysvar::stake_history::StakeHistory,
|
||||
std::{cell::RefCell, rc::Rc, str::FromStr},
|
||||
};
|
||||
use std::{cell::RefCell, rc::Rc, str::FromStr};
|
||||
|
||||
fn create_default_account() -> RefCell<AccountSharedData> {
|
||||
RefCell::new(AccountSharedData::default())
|
||||
|
@@ -3,6 +3,11 @@
|
||||
//! * keep track of rewards
|
||||
//! * own mining pools
|
||||
|
||||
#[deprecated(
|
||||
since = "1.7.2",
|
||||
note = "Please use `solana_sdk::stake::state` or `solana_program::stake::state` instead"
|
||||
)]
|
||||
pub use solana_sdk::stake::state::*;
|
||||
use {
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
@@ -26,12 +31,6 @@ use {
|
||||
std::{collections::HashSet, convert::TryFrom},
|
||||
};
|
||||
|
||||
#[deprecated(
|
||||
since = "1.7.2",
|
||||
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,
|
||||
@@ -1371,18 +1370,20 @@ fn do_create_account(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use proptest::prelude::*;
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, WritableAccount},
|
||||
clock::UnixTimestamp,
|
||||
native_token,
|
||||
process_instruction::MockInvokeContext,
|
||||
pubkey::Pubkey,
|
||||
system_program,
|
||||
use {
|
||||
super::*,
|
||||
proptest::prelude::*,
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, WritableAccount},
|
||||
clock::UnixTimestamp,
|
||||
native_token,
|
||||
process_instruction::MockInvokeContext,
|
||||
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() {
|
||||
|
@@ -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 {
|
||||
|
@@ -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_sdk::{
|
||||
decode_error::DecodeError,
|
||||
feature_set,
|
||||
hash::Hash,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount},
|
||||
process_instruction::InvokeContext,
|
||||
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_sdk::{
|
||||
decode_error::DecodeError,
|
||||
feature_set,
|
||||
hash::Hash,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount},
|
||||
process_instruction::InvokeContext,
|
||||
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)]
|
||||
@@ -388,15 +390,16 @@ pub fn process_instruction(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bincode::serialize;
|
||||
use solana_sdk::{
|
||||
account::{self, Account, AccountSharedData},
|
||||
process_instruction::MockInvokeContext,
|
||||
rent::Rent,
|
||||
use {
|
||||
super::*,
|
||||
bincode::serialize,
|
||||
solana_sdk::{
|
||||
account::{self, Account, AccountSharedData},
|
||||
process_instruction::MockInvokeContext,
|
||||
rent::Rent,
|
||||
},
|
||||
std::{cell::RefCell, str::FromStr},
|
||||
};
|
||||
use std::cell::RefCell;
|
||||
use std::str::FromStr;
|
||||
|
||||
fn create_default_account() -> RefCell<AccountSharedData> {
|
||||
RefCell::new(AccountSharedData::default())
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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 {
|
||||
|
@@ -1,15 +1,16 @@
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
hash::Hash,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
transaction::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,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
transaction::Transaction,
|
||||
},
|
||||
};
|
||||
|
||||
pub fn parse_vote_transaction(tx: &Transaction) -> Option<(Pubkey, Vote, Option<Hash>)> {
|
||||
@@ -82,8 +83,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();
|
||||
|
Reference in New Issue
Block a user