Reformat imports to a consistent style for imports
rustfmt.toml configuration: imports_granularity = "One" group_imports = "One"
This commit is contained in:
@ -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,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,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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]
|
||||
|
@ -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) => {
|
||||
|
Reference in New Issue
Block a user