diff --git a/Cargo.lock b/Cargo.lock index ec3b7b0408..701fe3413b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1103,7 +1103,7 @@ dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", - "memoffset", + "memoffset 0.6.4", "scopeguard", ] @@ -2772,6 +2772,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + [[package]] name = "merlin" version = "3.0.0" @@ -2899,7 +2908,7 @@ dependencies = [ "bitflags", "cfg-if 1.0.0", "libc", - "memoffset", + "memoffset 0.6.4", "pin-utils", ] @@ -6006,7 +6015,7 @@ dependencies = [ "libc", "libsecp256k1", "log", - "memoffset", + "memoffset 0.6.4", "num-derive", "num-traits", "parking_lot 0.12.1", @@ -6059,7 +6068,7 @@ dependencies = [ "libc", "libsecp256k1", "log", - "memoffset", + "memoffset 0.8.0", "num-bigint 0.4.3", "num-derive", "num-traits", @@ -6393,6 +6402,7 @@ dependencies = [ "lru", "lz4", "memmap2", + "memoffset 0.8.0", "num-derive", "num-traits", "num_cpus", diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 40b12a4b8f..fadeb10bc8 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -971,7 +971,7 @@ dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", - "memoffset", + "memoffset 0.6.4", "scopeguard", ] @@ -2538,6 +2538,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + [[package]] name = "merlin" version = "3.0.0" @@ -2665,7 +2674,7 @@ dependencies = [ "bitflags", "cfg-if 1.0.0", "libc", - "memoffset", + "memoffset 0.6.4", "pin-utils", ] @@ -5006,7 +5015,7 @@ dependencies = [ "libc", "libsecp256k1 0.6.0", "log", - "memoffset", + "memoffset 0.6.4", "num-derive", "num-traits", "parking_lot 0.12.1", @@ -5057,7 +5066,7 @@ dependencies = [ "libc", "libsecp256k1 0.6.0", "log", - "memoffset", + "memoffset 0.8.0", "num-bigint 0.4.3", "num-derive", "num-traits", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index c56719417b..ecb2176d06 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -73,6 +73,7 @@ name = "solana_runtime" assert_matches = "1.5.0" ed25519-dalek = "=1.0.1" libsecp256k1 = "0.6.0" +memoffset = "0.8" rand_chacha = "0.2.2" solana-logger = { path = "../logger", version = "=1.15.0" } static_assertions = "1.1.0" diff --git a/runtime/src/append_vec.rs b/runtime/src/append_vec.rs index bec1d344af..e9a84b5c52 100644 --- a/runtime/src/append_vec.rs +++ b/runtime/src/append_vec.rs @@ -703,6 +703,7 @@ pub mod tests { super::{test_utils::*, *}, crate::accounts_db::INCLUDE_SLOT_IN_HASH_TESTS, assert_matches::assert_matches, + memoffset::offset_of, rand::{thread_rng, Rng}, solana_sdk::{ account::{accounts_equal, WritableAccount}, @@ -1274,4 +1275,18 @@ pub mod tests { let result = AppendVec::new_from_file(path, accounts_len); assert_matches!(result, Err(ref message) if message.to_string().starts_with("incorrect layout/length/data")); } + + #[test] + fn test_type_layout() { + assert_eq!(offset_of!(StoredMeta, write_version_obsolete), 0x00); + assert_eq!(offset_of!(StoredMeta, data_len), 0x08); + assert_eq!(offset_of!(StoredMeta, pubkey), 0x10); + assert_eq!(mem::size_of::(), 0x30); + + assert_eq!(offset_of!(AccountMeta, lamports), 0x00); + assert_eq!(offset_of!(AccountMeta, rent_epoch), 0x08); + assert_eq!(offset_of!(AccountMeta, owner), 0x10); + assert_eq!(offset_of!(AccountMeta, executable), 0x30); + assert_eq!(mem::size_of::(), 0x38); + } } diff --git a/sdk/program/Cargo.toml b/sdk/program/Cargo.toml index a936c6dd27..a922f1d54f 100644 --- a/sdk/program/Cargo.toml +++ b/sdk/program/Cargo.toml @@ -21,7 +21,7 @@ bytemuck = { version = "1.8.0", features = ["derive"] } itertools = "0.10.5" lazy_static = "1.4.0" log = "0.4.17" -memoffset = "0.6" +memoffset = "0.8" num-derive = "0.3" num-traits = { version = "0.2", default-features = true, features = ["i128", "std"] } rustversion = "1.0.7"