* Align host addresses (#11384)
* Align host addresses
* support new program abi
* update epoch rollout
* Enforce aligned pointers in cross-program invocations
(cherry picked from commit 9290e561e1
)
# Conflicts:
# core/src/validator.rs
# genesis-programs/src/lib.rs
# programs/bpf_loader/src/deprecated.rs
# programs/bpf_loader/src/lib.rs
# sdk/src/entrypoint_native.rs
# sdk/src/lib.rs
* resolve conflicts
* nudge
Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
@@ -289,12 +289,15 @@ 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;
|
||||
@@ -308,10 +311,20 @@ 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);
|
||||
@@ -322,26 +335,22 @@ static bool sol_deserialize(
|
||||
params->ka[i].data = (uint8_t *) input;
|
||||
input += params->ka[i].data_len;
|
||||
|
||||
// owner
|
||||
params->ka[i].owner = (SolPubkey *) input;
|
||||
input += sizeof(SolPubkey);
|
||||
|
||||
// executable?
|
||||
params->ka[i].executable = *(uint8_t *) input;
|
||||
input += sizeof(uint8_t);
|
||||
input += 16 - (params->ka[i].data_len % 16); // padding
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
crate::declare_id!("BPFLoader1111111111111111111111111111111111");
|
||||
crate::declare_id!("BPFLoader2111111111111111111111111111111111");
|
||||
|
1
sdk/src/bpf_loader_deprecated.rs
Normal file
1
sdk/src/bpf_loader_deprecated.rs
Normal file
@@ -0,0 +1 @@
|
||||
crate::declare_id!("BPFLoader1111111111111111111111111111111111");
|
@@ -76,9 +76,18 @@ 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>();
|
||||
@@ -92,12 +101,7 @@ pub unsafe fn deserialize<'a>(input: *mut u8) -> (&'a Pubkey, Vec<AccountInfo<'a
|
||||
}));
|
||||
offset += data_len;
|
||||
|
||||
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>();
|
||||
offset += 16 - (offset % 16); // padding
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let rent_epoch = *(input.add(offset) as *const u64);
|
||||
@@ -114,6 +118,8 @@ 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());
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ 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, must match the library name in Cargo.toml
|
||||
/// name: Name of the program
|
||||
/// entrypoint: Program's entrypoint, must be of `type Entrypoint`
|
||||
/// id: Path to the program id access function, used if this macro is not
|
||||
/// called in `src/lib`
|
||||
|
@@ -12,6 +12,7 @@ pub mod abi_example;
|
||||
pub mod account;
|
||||
pub mod account_utils;
|
||||
pub mod bpf_loader;
|
||||
pub mod bpf_loader_deprecated;
|
||||
pub mod builtins;
|
||||
pub mod clock;
|
||||
pub mod commitment_config;
|
||||
|
Reference in New Issue
Block a user