Revert "Reformat imports to a consistent style for imports"

This reverts commit 139d15cd84.
This commit is contained in:
Trent Nelson
2021-12-13 08:48:39 -07:00
committed by Tao Zhu
parent d1e0941289
commit d7377d4794
380 changed files with 5320 additions and 6094 deletions

View File

@@ -2,19 +2,16 @@
extern crate test;
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_bpf_loader_program::serialization::{
serialize_parameters_aligned, serialize_parameters_unaligned,
};
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,9 +1,8 @@
use {
crate::alloc,
alloc::{Alloc, AllocErr},
solana_rbpf::aligned_memory::AlignedMemory,
std::alloc::Layout,
};
use crate::alloc;
use alloc::{Alloc, AllocErr};
use solana_rbpf::aligned_memory::AlignedMemory;
use std::alloc::Layout;
#[derive(Debug)]
pub struct BpfAllocator {

View File

@@ -1,6 +1,8 @@
#![allow(clippy::upper_case_acronyms)]
use {crate::BpfError, solana_rbpf::ebpf, thiserror::Error};
use crate::BpfError;
use solana_rbpf::ebpf;
use thiserror::Error;
/// Error definitions
#[derive(Debug, Error, PartialEq)]

View File

@@ -9,50 +9,47 @@ pub mod upgradeable;
pub mod upgradeable_with_jit;
pub mod with_jit;
use {
crate::{
bpf_verifier::VerifierError,
serialization::{deserialize_parameters, serialize_parameters},
syscalls::SyscallError,
},
log::{log_enabled, trace, Level::Trace},
solana_measure::measure::Measure,
solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf::{HOST_ALIGN, MM_HEAP_START},
error::{EbpfError, UserDefinedError},
memory_region::MemoryRegion,
static_analysis::Analysis,
vm::{Config, EbpfVm, Executable, 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, requestable_heap_size,
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, rc::Rc, sync::Arc},
thiserror::Error,
use crate::{
bpf_verifier::VerifierError,
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, MM_HEAP_START},
error::{EbpfError, UserDefinedError},
memory_region::MemoryRegion,
static_analysis::Analysis,
vm::{Config, EbpfVm, Executable, 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, requestable_heap_size, 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},
};
use std::{cell::RefCell, fmt::Debug, rc::Rc, sync::Arc};
use thiserror::Error;
solana_sdk::declare_builtin!(
solana_sdk::bpf_loader::ID,
@@ -1002,35 +999,34 @@ impl Executor for BpfExecutor {
#[cfg(test)]
mod tests {
use {
super::*,
rand::Rng,
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},
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,
use super::*;
use rand::Rng;
use solana_runtime::{bank::Bank, bank_client::BankClient};
use solana_sdk::{
account::{
create_account_shared_data_for_test as create_account_for_test, AccountSharedData,
},
std::{cell::RefCell, fs::File, io::Read, ops::Range, rc::Rc, sync::Arc},
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,
};
use std::{cell::RefCell, fs::File, io::Read, ops::Range, rc::Rc, sync::Arc};
struct TestInstructionMeter {
remaining: u64,

View File

@@ -1,16 +1,14 @@
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 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 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) {
@@ -285,19 +283,18 @@ pub fn deserialize_parameters_aligned(
#[cfg(test)]
mod tests {
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},
},
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},
};
#[test]

View File

@@ -1,58 +1,56 @@
use {
crate::{alloc, BpfError},
alloc::Alloc,
solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf::MM_HEAP_START,
error::EbpfError,
memory_region::{AccessType, MemoryMapping},
question_mark,
vm::{EbpfVm, SyscallObject, SyscallRegistry},
},
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},
},
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 crate::{alloc, BpfError};
use alloc::Alloc;
use solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf::MM_HEAP_START,
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,
},
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},
};
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;
@@ -2764,19 +2762,17 @@ impl<'a> SyscallObject<BpfError> for SyscallLogData<'a> {
#[cfg(test)]
mod tests {
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 super::*;
use solana_rbpf::{
ebpf::HOST_ALIGN, memory_region::MemoryRegion, user_error::UserError, vm::Config,
};
use solana_sdk::{
bpf_loader,
fee_calculator::FeeCalculator,
hash::hashv,
process_instruction::{MockComputeMeter, MockInvokeContext, MockLogger},
};
use std::str::FromStr;
const DEFAULT_CONFIG: Config = Config {
max_call_depth: 20,