Revert "Align host addresses (#11384) (#11836)" (#11876)

This reverts commit 3296c13ef2.
This commit is contained in:
Jack May
2020-08-27 09:19:05 -07:00
committed by GitHub
parent 7e1aa02ce4
commit eeb7503fb6
16 changed files with 163 additions and 655 deletions

View File

@@ -290,15 +290,12 @@ static bool sol_deserialize(
if (dup_info == UINT8_MAX) {
input += sizeof(uint8_t);
input += sizeof(uint8_t);
input += sizeof(SolPubkey);
input += sizeof(uint64_t);
input += *(uint64_t *) input;
input += sizeof(uint64_t);
input += sizeof(SolPubkey);
input += sizeof(uint8_t);
input += 4; // padding
input += sizeof(SolPubkey);
input += sizeof(SolPubkey);
input += sizeof(uint64_t);
uint64_t data_len = *(uint64_t *) input;
input += sizeof(uint64_t);
input += data_len;
input += 16 - (data_len % 16); // padding
input += sizeof(uint64_t);
}
continue;
@@ -312,20 +309,10 @@ static bool sol_deserialize(
params->ka[i].is_writable = *(uint8_t *) input != 0;
input += sizeof(uint8_t);
// executable?
params->ka[i].executable = *(uint8_t *) input;
input += sizeof(uint8_t);
input += 4; // padding
// key
params->ka[i].key = (SolPubkey *) input;
input += sizeof(SolPubkey);
// owner
params->ka[i].owner = (SolPubkey *) input;
input += sizeof(SolPubkey);
// lamports
params->ka[i].lamports = (uint64_t *) input;
input += sizeof(uint64_t);
@@ -336,22 +323,26 @@ static bool sol_deserialize(
params->ka[i].data = (uint8_t *) input;
input += params->ka[i].data_len;
input += 16 - (params->ka[i].data_len % 16); // padding
// owner
params->ka[i].owner = (SolPubkey *) input;
input += sizeof(SolPubkey);
// executable?
params->ka[i].executable = *(uint8_t *) input;
input += sizeof(uint8_t);
// rent epoch
params->ka[i].rent_epoch = *(uint64_t *) input;
input += sizeof(uint64_t);
} else {
params->ka[i].is_signer = params->ka[dup_info].is_signer;
params->ka[i].is_writable = params->ka[dup_info].is_writable;
params->ka[i].executable = params->ka[dup_info].executable;
params->ka[i].key = params->ka[dup_info].key;
params->ka[i].owner = params->ka[dup_info].owner;
params->ka[i].lamports = params->ka[dup_info].lamports;
params->ka[i].data_len = params->ka[dup_info].data_len;
params->ka[i].data = params->ka[dup_info].data;
params->ka[i].owner = params->ka[dup_info].owner;
params->ka[i].executable = params->ka[dup_info].executable;
params->ka[i].rent_epoch = params->ka[dup_info].rent_epoch;
input += 7; // padding
}
}

View File

@@ -1 +1 @@
crate::declare_id!("BPFLoader2111111111111111111111111111111111");
crate::declare_id!("BPFLoader1111111111111111111111111111111111");

View File

@@ -1 +0,0 @@
crate::declare_id!("BPFLoader1111111111111111111111111111111111");

View File

@@ -76,18 +76,9 @@ pub unsafe fn deserialize<'a>(input: *mut u8) -> (&'a Pubkey, Vec<AccountInfo<'a
let is_writable = *(input.add(offset) as *const u8) != 0;
offset += size_of::<u8>();
#[allow(clippy::cast_ptr_alignment)]
let executable = *(input.add(offset) as *const u8) != 0;
offset += size_of::<u8>();
offset += 4; // padding
let key: &Pubkey = &*(input.add(offset) as *const Pubkey);
offset += size_of::<Pubkey>();
let owner: &Pubkey = &*(input.add(offset) as *const Pubkey);
offset += size_of::<Pubkey>();
#[allow(clippy::cast_ptr_alignment)]
let lamports = Rc::new(RefCell::new(&mut *(input.add(offset) as *mut u64)));
offset += size_of::<u64>();
@@ -101,7 +92,12 @@ pub unsafe fn deserialize<'a>(input: *mut u8) -> (&'a Pubkey, Vec<AccountInfo<'a
}));
offset += data_len;
offset += 16 - (offset % 16); // padding
let owner: &Pubkey = &*(input.add(offset) as *const Pubkey);
offset += size_of::<Pubkey>();
#[allow(clippy::cast_ptr_alignment)]
let executable = *(input.add(offset) as *const u8) != 0;
offset += size_of::<u8>();
#[allow(clippy::cast_ptr_alignment)]
let rent_epoch = *(input.add(offset) as *const u64);
@@ -118,8 +114,6 @@ pub unsafe fn deserialize<'a>(input: *mut u8) -> (&'a Pubkey, Vec<AccountInfo<'a
rent_epoch,
});
} else {
offset += 7; // padding
// Duplicate account, clone the original
accounts.push(accounts[dup_info as usize].clone());
}

View File

@@ -33,7 +33,7 @@ pub type LoaderEntrypoint = unsafe extern "C" fn(
#[rustversion::since(1.46.0)]
#[macro_export]
macro_rules! declare_name {
($name:ident, $filename:ident, $id:path) => {
($name:ident) => {
#[macro_export]
macro_rules! $name {
() => {
@@ -66,8 +66,8 @@ macro_rules! declare_name {
// `respan!` respans the path `$crate::id`, which we then call (hence the extra
// parens)
(
stringify!($filename).to_string(),
::solana_sdk::respan!($crate::$id, $name)(),
stringify!($name).to_string(),
::solana_sdk::respan!($crate::id, $name)(),
)
};
}
@@ -77,11 +77,11 @@ macro_rules! declare_name {
#[rustversion::not(since(1.46.0))]
#[macro_export]
macro_rules! declare_name {
($name:ident, $filename:ident, $id:path) => {
($name:ident) => {
#[macro_export]
macro_rules! $name {
() => {
(stringify!($filename).to_string(), $crate::$id())
(stringify!($name).to_string(), $crate::id())
};
}
};
@@ -90,10 +90,8 @@ macro_rules! declare_name {
/// Convenience macro to declare a native program
///
/// bs58_string: bs58 string representation the program's id
/// name: Name of the program
/// filename: must match the library name in Cargo.toml
/// name: Name of the program, must match the library name in Cargo.toml
/// entrypoint: Program's entrypoint, must be of `type Entrypoint`
/// id: Path to the program id access function, used if not called in `src/lib`
///
/// # Examples
///
@@ -161,7 +159,7 @@ macro_rules! declare_name {
macro_rules! declare_program(
($bs58_string:expr, $name:ident, $entrypoint:expr) => (
$crate::declare_id!($bs58_string);
$crate::declare_name!($name, $name, id);
$crate::declare_name!($name);
#[no_mangle]
pub extern "C" fn $name(
@@ -176,16 +174,12 @@ macro_rules! declare_program(
/// Same as declare_program but for native loaders
#[macro_export]
macro_rules! declare_loader {
($bs58_string:expr, $name:ident, $entrypoint:expr) => {
$crate::declare_loader!($bs58_string, $name, $entrypoint, $name, id);
};
($bs58_string:expr, $name:ident, $entrypoint:expr, $filename:ident) => {
$crate::declare_loader!($bs58_string, $name, $entrypoint, $filename, id);
};
($bs58_string:expr, $name:ident, $entrypoint:expr, $filename:ident, $id:path) => {
macro_rules! declare_loader(
($bs58_string:expr, $name:ident, $entrypoint:expr) => (
$crate::declare_id!($bs58_string);
$crate::declare_name!($name, $filename, $id);
$crate::declare_name!($name);
#[no_mangle]
pub extern "C" fn $name(
@@ -196,8 +190,8 @@ macro_rules! declare_loader {
) -> Result<(), $crate::instruction::InstructionError> {
$entrypoint(program_id, keyed_accounts, instruction_data, invoke_context)
}
};
}
)
);
pub type ProcessInstruction = fn(&Pubkey, &[KeyedAccount], &[u8]) -> Result<(), InstructionError>;

View File

@@ -6,7 +6,6 @@ extern crate self as solana_sdk;
pub mod account;
pub mod account_utils;
pub mod bpf_loader;
pub mod bpf_loader_deprecated;
pub mod clock;
pub mod commitment_config;
pub mod decode_error;