From 82a1aada920ec9bab6e6ebb146a9216cba95595f Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Mon, 18 Nov 2024 17:47:49 +0400 Subject: [PATCH 01/30] minimize solana_program usage in message module --- sdk/program/src/message/account_keys.rs | 7 +++--- sdk/program/src/message/compiled_keys.rs | 7 +++--- sdk/program/src/message/legacy.rs | 22 +++++++++---------- sdk/program/src/message/sanitized.rs | 15 ++++++------- sdk/program/src/message/versions/mod.rs | 11 ++++------ sdk/program/src/message/versions/sanitized.rs | 3 +-- sdk/program/src/message/versions/v0/loaded.rs | 11 +++++----- sdk/program/src/message/versions/v0/mod.rs | 14 +++++------- 8 files changed, 41 insertions(+), 49 deletions(-) diff --git a/sdk/program/src/message/account_keys.rs b/sdk/program/src/message/account_keys.rs index e7dbd061cede76..648d2d10c009f0 100644 --- a/sdk/program/src/message/account_keys.rs +++ b/sdk/program/src/message/account_keys.rs @@ -1,9 +1,10 @@ use { crate::{ - instruction::{CompiledInstruction, Instruction}, + instruction::CompiledInstruction, message::{v0::LoadedAddresses, CompileError}, - pubkey::Pubkey, }, + solana_instruction::Instruction, + solana_pubkey::Pubkey, std::{collections::BTreeMap, iter::zip, ops::Index}, }; @@ -152,7 +153,7 @@ impl PartialEq for AccountKeys<'_> { #[cfg(test)] mod tests { - use {super::*, crate::instruction::AccountMeta}; + use {super::*, solana_instruction::AccountMeta}; fn test_account_keys() -> [Pubkey; 6] { let key0 = Pubkey::new_unique(); diff --git a/sdk/program/src/message/compiled_keys.rs b/sdk/program/src/message/compiled_keys.rs index a9964c33448be2..cc0416ae47ed74 100644 --- a/sdk/program/src/message/compiled_keys.rs +++ b/sdk/program/src/message/compiled_keys.rs @@ -4,9 +4,8 @@ use crate::{ message::v0::{LoadedAddresses, MessageAddressTableLookup}, }; use { - crate::{instruction::Instruction, message::MessageHeader, pubkey::Pubkey}, - std::collections::BTreeMap, - thiserror::Error, + crate::message::MessageHeader, solana_instruction::Instruction, solana_pubkey::Pubkey, + std::collections::BTreeMap, thiserror::Error, }; /// A helper struct to collect pubkeys compiled for a set of instructions @@ -184,7 +183,7 @@ impl CompiledKeys { #[cfg(test)] mod tests { - use {super::*, crate::instruction::AccountMeta, bitflags::bitflags}; + use {super::*, bitflags::bitflags, solana_instruction::AccountMeta}; bitflags! { #[derive(Clone, Copy)] diff --git a/sdk/program/src/message/legacy.rs b/sdk/program/src/message/legacy.rs index f225e5a646b654..4fc4cda29e9b97 100644 --- a/sdk/program/src/message/legacy.rs +++ b/sdk/program/src/message/legacy.rs @@ -11,20 +11,21 @@ #![allow(clippy::arithmetic_side_effects)] -#[cfg(target_arch = "wasm32")] -use crate::wasm_bindgen; #[allow(deprecated)] pub use builtins::{BUILTIN_PROGRAMS_KEYS, MAYBE_BUILTIN_KEY_OR_SYSVAR}; +#[cfg(target_arch = "wasm32")] +use wasm_bindgen::prelude::wasm_bindgen; use { crate::{ - bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, - hash::Hash, - instruction::{CompiledInstruction, Instruction}, + instruction::CompiledInstruction, message::{compiled_keys::CompiledKeys, MessageHeader}, - pubkey::Pubkey, - system_instruction, system_program, sysvar, + system_instruction, sysvar, }, + solana_hash::Hash, + solana_instruction::Instruction, + solana_pubkey::Pubkey, solana_sanitize::{Sanitize, SanitizeError}, + solana_sdk_ids::{bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, system_program}, solana_short_vec as short_vec, std::{collections::HashSet, convert::TryFrom, str::FromStr}, }; @@ -699,9 +700,8 @@ impl Message { mod tests { #![allow(deprecated)] use { - super::*, - crate::{hash, instruction::AccountMeta, message::MESSAGE_HEADER_LENGTH}, - std::collections::HashSet, + super::*, crate::message::MESSAGE_HEADER_LENGTH, solana_instruction::AccountMeta, + solana_sha256_hasher::hash, std::collections::HashSet, }; #[test] @@ -720,7 +720,7 @@ mod tests { // BUILTIN_PROGRAMS_KEYS without the risk of breaking consensus. let builtins = format!("{:?}", *BUILTIN_PROGRAMS_KEYS); assert_eq!( - format!("{}", hash::hash(builtins.as_bytes())), + format!("{}", hash(builtins.as_bytes())), "ACqmMkYbo9eqK6QrRSrB3HLyR6uHhLf31SCfGUAJjiWj" ); } diff --git a/sdk/program/src/message/sanitized.rs b/sdk/program/src/message/sanitized.rs index d2bfdd5ddd8ba5..d5996c3a1b1957 100644 --- a/sdk/program/src/message/sanitized.rs +++ b/sdk/program/src/message/sanitized.rs @@ -5,22 +5,21 @@ pub use solana_transaction_error::SanitizeMessageError; use { crate::{ - ed25519_program, - hash::Hash, instruction::CompiledInstruction, message::{ legacy, v0::{self, LoadedAddresses}, AccountKeys, AddressLoader, MessageHeader, SanitizedVersionedMessage, VersionedMessage, }, - nonce::NONCED_TX_MARKER_IX_INDEX, - program_utils::limited_deserialize, - pubkey::Pubkey, - secp256k1_program, - solana_program::{system_instruction::SystemInstruction, system_program}, + solana_program::system_instruction::SystemInstruction, }, + solana_bincode::limited_deserialize, + solana_hash::Hash, + solana_instruction::{BorrowedAccountMeta, BorrowedInstruction}, + solana_nonce::NONCED_TX_MARKER_IX_INDEX, + solana_pubkey::Pubkey, solana_sanitize::Sanitize, - solana_sysvar::instructions::{BorrowedAccountMeta, BorrowedInstruction}, + solana_sdk_ids::{ed25519_program, secp256k1_program, system_program}, std::{borrow::Cow, collections::HashSet, convert::TryFrom}, }; diff --git a/sdk/program/src/message/versions/mod.rs b/sdk/program/src/message/versions/mod.rs index 414af8de0b6e83..8cf6042e71d5af 100644 --- a/sdk/program/src/message/versions/mod.rs +++ b/sdk/program/src/message/versions/mod.rs @@ -1,16 +1,15 @@ use { crate::{ - hash::Hash, instruction::CompiledInstruction, message::{legacy::Message as LegacyMessage, v0::MessageAddressTableLookup, MessageHeader}, - pubkey::Pubkey, }, serde::{ de::{self, Deserializer, SeqAccess, Unexpected, Visitor}, ser::{SerializeTuple, Serializer}, }, serde_derive::{Deserialize, Serialize}, - solana_hash::HASH_BYTES, + solana_hash::{Hash, HASH_BYTES}, + solana_pubkey::Pubkey, solana_sanitize::{Sanitize, SanitizeError}, solana_short_vec as short_vec, std::{collections::HashSet, fmt}, @@ -324,10 +323,8 @@ impl<'de> serde::Deserialize<'de> for VersionedMessage { mod tests { use { super::*, - crate::{ - instruction::{AccountMeta, Instruction}, - message::v0::MessageAddressTableLookup, - }, + crate::message::v0::MessageAddressTableLookup, + solana_instruction::{AccountMeta, Instruction}, }; #[test] diff --git a/sdk/program/src/message/versions/sanitized.rs b/sdk/program/src/message/versions/sanitized.rs index b2d43da131dcd8..b0eef789e8ffdb 100644 --- a/sdk/program/src/message/versions/sanitized.rs +++ b/sdk/program/src/message/versions/sanitized.rs @@ -1,6 +1,5 @@ use { - super::VersionedMessage, - crate::{instruction::CompiledInstruction, pubkey::Pubkey}, + super::VersionedMessage, crate::instruction::CompiledInstruction, solana_pubkey::Pubkey, solana_sanitize::SanitizeError, }; diff --git a/sdk/program/src/message/versions/v0/loaded.rs b/sdk/program/src/message/versions/v0/loaded.rs index 1825c5e748e3f4..b7bdfad1971655 100644 --- a/sdk/program/src/message/versions/v0/loaded.rs +++ b/sdk/program/src/message/versions/v0/loaded.rs @@ -1,9 +1,7 @@ use { - crate::{ - bpf_loader_upgradeable, - message::{v0, AccountKeys}, - pubkey::Pubkey, - }, + crate::message::{v0, AccountKeys}, + solana_pubkey::Pubkey, + solana_sdk_ids::bpf_loader_upgradeable, std::{borrow::Cow, collections::HashSet}, }; @@ -187,8 +185,9 @@ impl<'a> LoadedMessage<'a> { mod tests { use { super::*, - crate::{instruction::CompiledInstruction, message::MessageHeader, system_program, sysvar}, + crate::{instruction::CompiledInstruction, message::MessageHeader}, itertools::Itertools, + solana_sdk_ids::{system_program, sysvar}, }; fn check_test_loaded_message() -> (LoadedMessage<'static>, [Pubkey; 6]) { diff --git a/sdk/program/src/message/versions/v0/mod.rs b/sdk/program/src/message/versions/v0/mod.rs index 9eaad5a9b39944..884c2285dcad4a 100644 --- a/sdk/program/src/message/versions/v0/mod.rs +++ b/sdk/program/src/message/versions/v0/mod.rs @@ -13,16 +13,17 @@ pub use loaded::*; use { crate::{ address_lookup_table::AddressLookupTableAccount, - bpf_loader_upgradeable, - hash::Hash, - instruction::{CompiledInstruction, Instruction}, + instruction::CompiledInstruction, message::{ compiled_keys::{CompileError, CompiledKeys}, AccountKeys, MessageHeader, MESSAGE_VERSION_PREFIX, }, - pubkey::Pubkey, }, + solana_hash::Hash, + solana_instruction::Instruction, + solana_pubkey::Pubkey, solana_sanitize::SanitizeError, + solana_sdk_ids::bpf_loader_upgradeable, solana_short_vec as short_vec, std::collections::HashSet, }; @@ -377,10 +378,7 @@ impl Message { #[cfg(test)] mod tests { - use { - super::*, - crate::{instruction::AccountMeta, message::VersionedMessage}, - }; + use {super::*, crate::message::VersionedMessage, solana_instruction::AccountMeta}; #[test] fn test_sanitize() { From 879edc9bb3a5b77823d36542d226a1fd57cafb8c Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 00:02:09 +0400 Subject: [PATCH 02/30] move CompiledInstruction to message module --- sdk/program/src/instruction.rs | 59 ++----------------- sdk/program/src/message/account_keys.rs | 5 +- .../src/message/compiled_instruction.rs | 53 +++++++++++++++++ sdk/program/src/message/legacy.rs | 5 +- sdk/program/src/message/mod.rs | 3 +- sdk/program/src/message/sanitized.rs | 2 +- sdk/program/src/message/versions/mod.rs | 6 +- sdk/program/src/message/versions/sanitized.rs | 4 +- sdk/program/src/message/versions/v0/loaded.rs | 2 +- sdk/program/src/message/versions/v0/mod.rs | 2 +- 10 files changed, 74 insertions(+), 67 deletions(-) create mode 100644 sdk/program/src/message/compiled_instruction.rs diff --git a/sdk/program/src/instruction.rs b/sdk/program/src/instruction.rs index c380ecdbcde9c3..9ae262f69ca2e4 100644 --- a/sdk/program/src/instruction.rs +++ b/sdk/program/src/instruction.rs @@ -1,59 +1,12 @@ #[cfg(feature = "frozen-abi")] use solana_frozen_abi_macro::AbiExample; -pub use solana_instruction::{ - error::InstructionError, AccountMeta, Instruction, ProcessedSiblingInstruction, - TRANSACTION_LEVEL_STACK_HEIGHT, +pub use { + crate::message::compiled_instruction::CompiledInstruction, + solana_instruction::{ + error::InstructionError, AccountMeta, Instruction, ProcessedSiblingInstruction, + TRANSACTION_LEVEL_STACK_HEIGHT, + }, }; -use { - bincode::serialize, serde::Serialize, solana_pubkey::Pubkey, solana_sanitize::Sanitize, - solana_short_vec as short_vec, -}; - -/// A compact encoding of an instruction. -/// -/// A `CompiledInstruction` is a component of a multi-instruction [`Message`], -/// which is the core of a Solana transaction. It is created during the -/// construction of `Message`. Most users will not interact with it directly. -/// -/// [`Message`]: crate::message::Message -#[cfg_attr(feature = "frozen-abi", derive(AbiExample))] -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] -#[serde(rename_all = "camelCase")] -pub struct CompiledInstruction { - /// Index into the transaction keys array indicating the program account that executes this instruction. - pub program_id_index: u8, - /// Ordered indices into the transaction keys array indicating which accounts to pass to the program. - #[serde(with = "short_vec")] - pub accounts: Vec, - /// The program input data. - #[serde(with = "short_vec")] - pub data: Vec, -} - -impl Sanitize for CompiledInstruction {} - -impl CompiledInstruction { - pub fn new(program_ids_index: u8, data: &T, accounts: Vec) -> Self { - let data = serialize(data).unwrap(); - Self { - program_id_index: program_ids_index, - accounts, - data, - } - } - - pub fn new_from_raw_parts(program_id_index: u8, data: Vec, accounts: Vec) -> Self { - Self { - program_id_index, - accounts, - data, - } - } - - pub fn program_id<'a>(&self, program_ids: &'a [Pubkey]) -> &'a Pubkey { - &program_ids[self.program_id_index as usize] - } -} /// Returns a sibling instruction from the processed sibling instruction list. /// diff --git a/sdk/program/src/message/account_keys.rs b/sdk/program/src/message/account_keys.rs index 648d2d10c009f0..c5af6ef4366590 100644 --- a/sdk/program/src/message/account_keys.rs +++ b/sdk/program/src/message/account_keys.rs @@ -1,7 +1,6 @@ use { - crate::{ - instruction::CompiledInstruction, - message::{v0::LoadedAddresses, CompileError}, + crate::message::{ + compiled_instruction::CompiledInstruction, v0::LoadedAddresses, CompileError, }, solana_instruction::Instruction, solana_pubkey::Pubkey, diff --git a/sdk/program/src/message/compiled_instruction.rs b/sdk/program/src/message/compiled_instruction.rs new file mode 100644 index 00000000000000..137810066155e1 --- /dev/null +++ b/sdk/program/src/message/compiled_instruction.rs @@ -0,0 +1,53 @@ +use { + bincode::serialize, + serde_derive::{Deserialize, Serialize}, + solana_pubkey::Pubkey, + solana_sanitize::Sanitize, + solana_short_vec as short_vec, +}; + +/// A compact encoding of an instruction. +/// +/// A `CompiledInstruction` is a component of a multi-instruction [`Message`], +/// which is the core of a Solana transaction. It is created during the +/// construction of `Message`. Most users will not interact with it directly. +/// +/// [`Message`]: crate::message::Message +#[cfg_attr(feature = "frozen-abi", derive(AbiExample))] +#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] +#[serde(rename_all = "camelCase")] +pub struct CompiledInstruction { + /// Index into the transaction keys array indicating the program account that executes this instruction. + pub program_id_index: u8, + /// Ordered indices into the transaction keys array indicating which accounts to pass to the program. + #[serde(with = "short_vec")] + pub accounts: Vec, + /// The program input data. + #[serde(with = "short_vec")] + pub data: Vec, +} + +impl Sanitize for CompiledInstruction {} + +impl CompiledInstruction { + pub fn new(program_ids_index: u8, data: &T, accounts: Vec) -> Self { + let data = serialize(data).unwrap(); + Self { + program_id_index: program_ids_index, + accounts, + data, + } + } + + pub fn new_from_raw_parts(program_id_index: u8, data: Vec, accounts: Vec) -> Self { + Self { + program_id_index, + accounts, + data, + } + } + + pub fn program_id<'a>(&self, program_ids: &'a [Pubkey]) -> &'a Pubkey { + &program_ids[self.program_id_index as usize] + } +} diff --git a/sdk/program/src/message/legacy.rs b/sdk/program/src/message/legacy.rs index 4fc4cda29e9b97..65f659ca14811a 100644 --- a/sdk/program/src/message/legacy.rs +++ b/sdk/program/src/message/legacy.rs @@ -17,8 +17,9 @@ pub use builtins::{BUILTIN_PROGRAMS_KEYS, MAYBE_BUILTIN_KEY_OR_SYSVAR}; use wasm_bindgen::prelude::wasm_bindgen; use { crate::{ - instruction::CompiledInstruction, - message::{compiled_keys::CompiledKeys, MessageHeader}, + message::{ + compiled_instruction::CompiledInstruction, compiled_keys::CompiledKeys, MessageHeader, + }, system_instruction, sysvar, }, solana_hash::Hash, diff --git a/sdk/program/src/message/mod.rs b/sdk/program/src/message/mod.rs index cc7904117e9475..23cbd0e70a449b 100644 --- a/sdk/program/src/message/mod.rs +++ b/sdk/program/src/message/mod.rs @@ -37,6 +37,7 @@ //! types continue to be exposed to Solana programs, for backwards compatibility //! reasons. +pub mod compiled_instruction; mod compiled_keys; pub mod legacy; @@ -74,7 +75,7 @@ pub const MESSAGE_HEADER_LENGTH: usize = 3; /// the single shared account list. /// /// [`Instruction`]: crate::instruction::Instruction -/// [`CompiledInstruction`]: crate::instruction::CompiledInstruction +/// [`CompiledInstruction`]: crate::message::compiled_instruction::CompiledInstruction /// /// The shared account list is ordered by the permissions required of the accounts: /// diff --git a/sdk/program/src/message/sanitized.rs b/sdk/program/src/message/sanitized.rs index d5996c3a1b1957..118fd07620d79e 100644 --- a/sdk/program/src/message/sanitized.rs +++ b/sdk/program/src/message/sanitized.rs @@ -5,8 +5,8 @@ pub use solana_transaction_error::SanitizeMessageError; use { crate::{ - instruction::CompiledInstruction, message::{ + compiled_instruction::CompiledInstruction, legacy, v0::{self, LoadedAddresses}, AccountKeys, AddressLoader, MessageHeader, SanitizedVersionedMessage, VersionedMessage, diff --git a/sdk/program/src/message/versions/mod.rs b/sdk/program/src/message/versions/mod.rs index 8cf6042e71d5af..f0151df0a500c0 100644 --- a/sdk/program/src/message/versions/mod.rs +++ b/sdk/program/src/message/versions/mod.rs @@ -1,7 +1,7 @@ use { - crate::{ - instruction::CompiledInstruction, - message::{legacy::Message as LegacyMessage, v0::MessageAddressTableLookup, MessageHeader}, + crate::message::{ + compiled_instruction::CompiledInstruction, legacy::Message as LegacyMessage, + v0::MessageAddressTableLookup, MessageHeader, }, serde::{ de::{self, Deserializer, SeqAccess, Unexpected, Visitor}, diff --git a/sdk/program/src/message/versions/sanitized.rs b/sdk/program/src/message/versions/sanitized.rs index b0eef789e8ffdb..64b2ce0247b03c 100644 --- a/sdk/program/src/message/versions/sanitized.rs +++ b/sdk/program/src/message/versions/sanitized.rs @@ -1,6 +1,6 @@ use { - super::VersionedMessage, crate::instruction::CompiledInstruction, solana_pubkey::Pubkey, - solana_sanitize::SanitizeError, + super::VersionedMessage, crate::message::compiled_instruction::CompiledInstruction, + solana_pubkey::Pubkey, solana_sanitize::SanitizeError, }; /// Wraps a sanitized `VersionedMessage` to provide a safe API diff --git a/sdk/program/src/message/versions/v0/loaded.rs b/sdk/program/src/message/versions/v0/loaded.rs index b7bdfad1971655..dd51baecad387c 100644 --- a/sdk/program/src/message/versions/v0/loaded.rs +++ b/sdk/program/src/message/versions/v0/loaded.rs @@ -185,7 +185,7 @@ impl<'a> LoadedMessage<'a> { mod tests { use { super::*, - crate::{instruction::CompiledInstruction, message::MessageHeader}, + crate::message::{compiled_instruction::CompiledInstruction, MessageHeader}, itertools::Itertools, solana_sdk_ids::{system_program, sysvar}, }; diff --git a/sdk/program/src/message/versions/v0/mod.rs b/sdk/program/src/message/versions/v0/mod.rs index 884c2285dcad4a..41526f7da0b83f 100644 --- a/sdk/program/src/message/versions/v0/mod.rs +++ b/sdk/program/src/message/versions/v0/mod.rs @@ -13,8 +13,8 @@ pub use loaded::*; use { crate::{ address_lookup_table::AddressLookupTableAccount, - instruction::CompiledInstruction, message::{ + compiled_instruction::CompiledInstruction, compiled_keys::{CompileError, CompiledKeys}, AccountKeys, MessageHeader, MESSAGE_VERSION_PREFIX, }, From 8796525c02f5c54c53dfff3120d32f5c2a339bd1 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 00:05:36 +0400 Subject: [PATCH 03/30] move AddressLookupTableAccount to message module --- sdk/program/src/address_lookup_table/mod.rs | 10 +--------- sdk/program/src/message/mod.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/sdk/program/src/address_lookup_table/mod.rs b/sdk/program/src/address_lookup_table/mod.rs index b1d29aac360a6b..036bd7cebefb31 100644 --- a/sdk/program/src/address_lookup_table/mod.rs +++ b/sdk/program/src/address_lookup_table/mod.rs @@ -9,12 +9,4 @@ pub mod state; pub mod program { pub use solana_sdk_ids::address_lookup_table::{check_id, id, ID}; } - -/// The definition of address lookup table accounts. -/// -/// As used by the `crate::message::v0` message format. -#[derive(Debug, PartialEq, Eq, Clone)] -pub struct AddressLookupTableAccount { - pub key: crate::pubkey::Pubkey, - pub addresses: Vec, -} +pub use crate::message::AddressLookupTableAccount; diff --git a/sdk/program/src/message/mod.rs b/sdk/program/src/message/mod.rs index 23cbd0e70a449b..4254007245d69f 100644 --- a/sdk/program/src/message/mod.rs +++ b/sdk/program/src/message/mod.rs @@ -110,3 +110,12 @@ pub struct MessageHeader { /// read-only accounts. pub num_readonly_unsigned_accounts: u8, } + +/// The definition of address lookup table accounts. +/// +/// As used by the `crate::message::v0` message format. +#[derive(Debug, PartialEq, Eq, Clone)] +pub struct AddressLookupTableAccount { + pub key: solana_pubkey::Pubkey, + pub addresses: Vec, +} From 6e22c78d9d12ecac5c096b44a0b64246ceea98a3 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 00:09:11 +0400 Subject: [PATCH 04/30] update AddressLookupTableAccount import --- sdk/program/src/message/compiled_keys.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/program/src/message/compiled_keys.rs b/sdk/program/src/message/compiled_keys.rs index cc0416ae47ed74..6a926750bd731f 100644 --- a/sdk/program/src/message/compiled_keys.rs +++ b/sdk/program/src/message/compiled_keys.rs @@ -1,7 +1,6 @@ #[cfg(not(target_os = "solana"))] use crate::{ - address_lookup_table::AddressLookupTableAccount, - message::v0::{LoadedAddresses, MessageAddressTableLookup}, + message::{AddressLookupTableAccount, v0::{LoadedAddresses, MessageAddressTableLookup}}, }; use { crate::message::MessageHeader, solana_instruction::Instruction, solana_pubkey::Pubkey, From 51a2f361c6b1c6e36f31d027098c5ceacd051d0f Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 12:09:49 +0400 Subject: [PATCH 05/30] start extracting message crate --- Cargo.lock | 22 +++++++++++++ Cargo.toml | 2 ++ programs/sbf/Cargo.lock | 22 +++++++++++++ sdk/message/Cargo.toml | 33 +++++++++++++++++++ .../message => message/src}/account_keys.rs | 4 +-- .../message => message/src}/address_loader.rs | 2 +- .../src}/compiled_instruction.rs | 2 +- .../message => message/src}/compiled_keys.rs | 5 +-- .../src/message => message/src}/legacy.rs | 15 ++++----- .../src/message/mod.rs => message/src/lib.rs} | 5 +-- .../src/message => message/src}/sanitized.rs | 14 ++++---- .../message => message/src}/versions/mod.rs | 4 +-- .../src}/versions/sanitized.rs | 2 +- .../src}/versions/v0/loaded.rs | 5 +-- .../src}/versions/v0/mod.rs | 18 +++++----- sdk/program/Cargo.toml | 1 + svm/examples/Cargo.lock | 22 +++++++++++++ 17 files changed, 138 insertions(+), 40 deletions(-) create mode 100644 sdk/message/Cargo.toml rename sdk/{program/src/message => message/src}/account_keys.rs (98%) rename sdk/{program/src/message => message/src}/address_loader.rs (92%) rename sdk/{program/src/message => message/src}/compiled_instruction.rs (97%) rename sdk/{program/src/message => message/src}/compiled_keys.rs (99%) rename sdk/{program/src/message => message/src}/legacy.rs (99%) rename sdk/{program/src/message/mod.rs => message/src/lib.rs} (96%) rename sdk/{program/src/message => message/src}/sanitized.rs (98%) rename sdk/{program/src/message => message/src}/versions/mod.rs (99%) rename sdk/{program/src/message => message/src}/versions/sanitized.rs (94%) rename sdk/{program/src/message => message/src}/versions/v0/loaded.rs (98%) rename sdk/{program/src/message => message/src}/versions/v0/mod.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index 917036a9c6928d..fd875a6262354d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7520,6 +7520,27 @@ dependencies = [ "solana-sha256-hasher", ] +[[package]] +name = "solana-message" +version = "2.2.0" +dependencies = [ + "bincode", + "blake3", + "lazy_static", + "serde", + "serde_derive", + "solana-bincode", + "solana-hash", + "solana-instruction", + "solana-nonce", + "solana-pubkey", + "solana-sanitize", + "solana-sdk-ids", + "solana-short-vec", + "solana-transaction-error", + "thiserror 2.0.3", +] + [[package]] name = "solana-metrics" version = "2.2.0" @@ -7825,6 +7846,7 @@ dependencies = [ "solana-keccak-hasher", "solana-last-restart-slot", "solana-logger", + "solana-message", "solana-msg", "solana-native-token", "solana-nonce", diff --git a/Cargo.toml b/Cargo.toml index 37bc56baa87885..12a14a1f5d1f17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,6 +131,7 @@ members = [ "sdk/keypair", "sdk/logger", "sdk/macro", + "sdk/message", "sdk/msg", "sdk/native-token", "sdk/nonce", @@ -487,6 +488,7 @@ solana-log-collector = { path = "log-collector", version = "=2.2.0" } solana-logger = { path = "sdk/logger", version = "=2.2.0" } solana-measure = { path = "measure", version = "=2.2.0" } solana-merkle-tree = { path = "merkle-tree", version = "=2.2.0" } +solana-message = { path = "sdk/message", version = "=2.2.0" } solana-metrics = { path = "metrics", version = "=2.2.0" } solana-msg = { path = "sdk/msg", version = "=2.2.0" } solana-native-token = { path = "sdk/native-token", version = "=2.2.0" } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 538c278ab9c9a7..2ef61548e8c5b5 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5946,6 +5946,27 @@ dependencies = [ "solana-sha256-hasher", ] +[[package]] +name = "solana-message" +version = "2.2.0" +dependencies = [ + "bincode", + "blake3", + "lazy_static", + "serde", + "serde_derive", + "solana-bincode", + "solana-hash", + "solana-instruction", + "solana-nonce", + "solana-pubkey", + "solana-sanitize", + "solana-sdk-ids", + "solana-short-vec", + "solana-transaction-error", + "thiserror 2.0.3", +] + [[package]] name = "solana-metrics" version = "2.2.0" @@ -6155,6 +6176,7 @@ dependencies = [ "solana-instruction", "solana-keccak-hasher", "solana-last-restart-slot", + "solana-message", "solana-msg", "solana-native-token", "solana-nonce", diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml new file mode 100644 index 00000000000000..ed69d1ab400f19 --- /dev/null +++ b/sdk/message/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "solana-message" +description = "Solana transaction message types." +documentation = "https://docs.rs/solana-message" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } + +[dependencies] +bincode = { workspace = true } +blake3 = { workspace = true, features = ["traits-preview"]} +lazy_static = { workspace = true } +serde = { workspace = true } +serde_derive = { workspace = true } +solana-bincode = { workspace = true } +solana-hash = { workspace = true, features = ["serde"] } +solana-instruction = { workspace = true, features = ["std"] } +solana-nonce = { workspace = true } +solana-pubkey = { workspace = true, features = ["serde"] } +solana-sanitize = { workspace = true } +solana-sdk-ids = { workspace = true } +solana-short-vec = { workspace = true } +solana-transaction-error = { workspace = true } +thiserror = { workspace = true } + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[lints] +workspace = true diff --git a/sdk/program/src/message/account_keys.rs b/sdk/message/src/account_keys.rs similarity index 98% rename from sdk/program/src/message/account_keys.rs rename to sdk/message/src/account_keys.rs index c5af6ef4366590..e36349b76418b2 100644 --- a/sdk/program/src/message/account_keys.rs +++ b/sdk/message/src/account_keys.rs @@ -1,7 +1,5 @@ use { - crate::message::{ - compiled_instruction::CompiledInstruction, v0::LoadedAddresses, CompileError, - }, + crate::{compiled_instruction::CompiledInstruction, v0::LoadedAddresses, CompileError}, solana_instruction::Instruction, solana_pubkey::Pubkey, std::{collections::BTreeMap, iter::zip, ops::Index}, diff --git a/sdk/program/src/message/address_loader.rs b/sdk/message/src/address_loader.rs similarity index 92% rename from sdk/program/src/message/address_loader.rs rename to sdk/message/src/address_loader.rs index 632117718660bc..82ac882a7cd2af 100644 --- a/sdk/program/src/message/address_loader.rs +++ b/sdk/message/src/address_loader.rs @@ -1,4 +1,4 @@ -use super::v0::{LoadedAddresses, MessageAddressTableLookup}; +use crate::v0::{LoadedAddresses, MessageAddressTableLookup}; #[deprecated( since = "2.1.0", note = "Use solana_transaction_error::AddressLoaderError instead" diff --git a/sdk/program/src/message/compiled_instruction.rs b/sdk/message/src/compiled_instruction.rs similarity index 97% rename from sdk/program/src/message/compiled_instruction.rs rename to sdk/message/src/compiled_instruction.rs index 137810066155e1..2469d0de21cbb1 100644 --- a/sdk/program/src/message/compiled_instruction.rs +++ b/sdk/message/src/compiled_instruction.rs @@ -12,7 +12,7 @@ use { /// which is the core of a Solana transaction. It is created during the /// construction of `Message`. Most users will not interact with it directly. /// -/// [`Message`]: crate::message::Message +/// [`Message`]: crate::Message #[cfg_attr(feature = "frozen-abi", derive(AbiExample))] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] #[serde(rename_all = "camelCase")] diff --git a/sdk/program/src/message/compiled_keys.rs b/sdk/message/src/compiled_keys.rs similarity index 99% rename from sdk/program/src/message/compiled_keys.rs rename to sdk/message/src/compiled_keys.rs index 6a926750bd731f..5f427b66f8257e 100644 --- a/sdk/program/src/message/compiled_keys.rs +++ b/sdk/message/src/compiled_keys.rs @@ -1,9 +1,10 @@ #[cfg(not(target_os = "solana"))] use crate::{ - message::{AddressLookupTableAccount, v0::{LoadedAddresses, MessageAddressTableLookup}}, + v0::{LoadedAddresses, MessageAddressTableLookup}, + AddressLookupTableAccount, }; use { - crate::message::MessageHeader, solana_instruction::Instruction, solana_pubkey::Pubkey, + crate::MessageHeader, solana_instruction::Instruction, solana_pubkey::Pubkey, std::collections::BTreeMap, thiserror::Error, }; diff --git a/sdk/program/src/message/legacy.rs b/sdk/message/src/legacy.rs similarity index 99% rename from sdk/program/src/message/legacy.rs rename to sdk/message/src/legacy.rs index 65f659ca14811a..41e7e5280f8ca1 100644 --- a/sdk/program/src/message/legacy.rs +++ b/sdk/message/src/legacy.rs @@ -5,8 +5,8 @@ //! `v0` is a [future message format] that encodes more account keys into a //! transaction than the legacy format. //! -//! [`legacy`]: crate::message::legacy -//! [`v0`]: crate::message::v0 +//! [`legacy`]: crate::legacy +//! [`v0`]: crate::v0 //! [future message format]: https://docs.solanalabs.com/proposals/versioned-transactions #![allow(clippy::arithmetic_side_effects)] @@ -17,11 +17,9 @@ pub use builtins::{BUILTIN_PROGRAMS_KEYS, MAYBE_BUILTIN_KEY_OR_SYSVAR}; use wasm_bindgen::prelude::wasm_bindgen; use { crate::{ - message::{ - compiled_instruction::CompiledInstruction, compiled_keys::CompiledKeys, MessageHeader, - }, - system_instruction, sysvar, + compiled_instruction::CompiledInstruction, compiled_keys::CompiledKeys, MessageHeader, }, + serde_derive::{Deserialize, Serialize}, solana_hash::Hash, solana_instruction::Instruction, solana_pubkey::Pubkey, @@ -29,6 +27,7 @@ use { solana_sdk_ids::{bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, system_program}, solana_short_vec as short_vec, std::{collections::HashSet, convert::TryFrom, str::FromStr}, + system_instruction, sysvar, }; #[deprecated( @@ -110,7 +109,7 @@ fn compile_instructions(ixs: &[Instruction], keys: &[Pubkey]) -> Vec serde::Deserialize<'de> for VersionedMessage { mod tests { use { super::*, - crate::message::v0::MessageAddressTableLookup, + crate::v0::MessageAddressTableLookup, solana_instruction::{AccountMeta, Instruction}, }; diff --git a/sdk/program/src/message/versions/sanitized.rs b/sdk/message/src/versions/sanitized.rs similarity index 94% rename from sdk/program/src/message/versions/sanitized.rs rename to sdk/message/src/versions/sanitized.rs index 64b2ce0247b03c..bd95964716c7e9 100644 --- a/sdk/program/src/message/versions/sanitized.rs +++ b/sdk/message/src/versions/sanitized.rs @@ -1,5 +1,5 @@ use { - super::VersionedMessage, crate::message::compiled_instruction::CompiledInstruction, + super::VersionedMessage, crate::compiled_instruction::CompiledInstruction, solana_pubkey::Pubkey, solana_sanitize::SanitizeError, }; diff --git a/sdk/program/src/message/versions/v0/loaded.rs b/sdk/message/src/versions/v0/loaded.rs similarity index 98% rename from sdk/program/src/message/versions/v0/loaded.rs rename to sdk/message/src/versions/v0/loaded.rs index dd51baecad387c..883d7a4b2efab6 100644 --- a/sdk/program/src/message/versions/v0/loaded.rs +++ b/sdk/message/src/versions/v0/loaded.rs @@ -1,5 +1,6 @@ use { - crate::message::{v0, AccountKeys}, + crate::{v0, AccountKeys}, + serde_derive::{Deserialize, Serialize}, solana_pubkey::Pubkey, solana_sdk_ids::bpf_loader_upgradeable, std::{borrow::Cow, collections::HashSet}, @@ -185,7 +186,7 @@ impl<'a> LoadedMessage<'a> { mod tests { use { super::*, - crate::message::{compiled_instruction::CompiledInstruction, MessageHeader}, + crate::{compiled_instruction::CompiledInstruction, MessageHeader}, itertools::Itertools, solana_sdk_ids::{system_program, sysvar}, }; diff --git a/sdk/program/src/message/versions/v0/mod.rs b/sdk/message/src/versions/v0/mod.rs similarity index 98% rename from sdk/program/src/message/versions/v0/mod.rs rename to sdk/message/src/versions/v0/mod.rs index 41526f7da0b83f..57200f79ca748e 100644 --- a/sdk/program/src/message/versions/v0/mod.rs +++ b/sdk/message/src/versions/v0/mod.rs @@ -5,20 +5,18 @@ //! `v0` is a [future message format] that encodes more account keys into a //! transaction than the legacy format. //! -//! [`legacy`]: crate::message::legacy -//! [`v0`]: crate::message::v0 +//! [`legacy`]: crate::legacy +//! [`v0`]: crate::v0 //! [future message format]: https://docs.solanalabs.com/proposals/versioned-transactions pub use loaded::*; use { crate::{ - address_lookup_table::AddressLookupTableAccount, - message::{ - compiled_instruction::CompiledInstruction, - compiled_keys::{CompileError, CompiledKeys}, - AccountKeys, MessageHeader, MESSAGE_VERSION_PREFIX, - }, + compiled_instruction::CompiledInstruction, + compiled_keys::{CompileError, CompiledKeys}, + AccountKeys, AddressLookupTableAccount, MessageHeader, MESSAGE_VERSION_PREFIX, }, + serde_derive::{Deserialize, Serialize}, solana_hash::Hash, solana_instruction::Instruction, solana_pubkey::Pubkey, @@ -53,7 +51,7 @@ pub struct MessageAddressTableLookup { /// /// See the [`message`] module documentation for further description. /// -/// [`message`]: crate::message +/// [`message`]: crate:: #[cfg_attr(feature = "frozen-abi", derive(AbiExample))] #[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone)] #[serde(rename_all = "camelCase")] @@ -378,7 +376,7 @@ impl Message { #[cfg(test)] mod tests { - use {super::*, crate::message::VersionedMessage, solana_instruction::AccountMeta}; + use {super::*, crate::VersionedMessage, solana_instruction::AccountMeta}; #[test] fn test_sanitize() { diff --git a/sdk/program/Cargo.toml b/sdk/program/Cargo.toml index f9d349b45bf4f1..6e94c9ca856d10 100644 --- a/sdk/program/Cargo.toml +++ b/sdk/program/Cargo.toml @@ -56,6 +56,7 @@ solana-instruction = { workspace = true, default-features = false, features = [ ] } solana-keccak-hasher = { workspace = true, features = ["sha3"] } solana-last-restart-slot = { workspace = true, features = ["serde", "sysvar"] } +solana-message = { workspace = true } solana-msg = { workspace = true } solana-native-token = { workspace = true } solana-nonce = { workspace = true, features = ["serde"] } diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 0fae936638bf7e..6e3157a168d079 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5766,6 +5766,27 @@ dependencies = [ "solana-sha256-hasher", ] +[[package]] +name = "solana-message" +version = "2.2.0" +dependencies = [ + "bincode", + "blake3", + "lazy_static", + "serde", + "serde_derive", + "solana-bincode", + "solana-hash", + "solana-instruction", + "solana-nonce", + "solana-pubkey", + "solana-sanitize", + "solana-sdk-ids", + "solana-short-vec", + "solana-transaction-error", + "thiserror 2.0.3", +] + [[package]] name = "solana-metrics" version = "2.2.0" @@ -5975,6 +5996,7 @@ dependencies = [ "solana-instruction", "solana-keccak-hasher", "solana-last-restart-slot", + "solana-message", "solana-msg", "solana-native-token", "solana-nonce", From 6151a0c00042d16271b7dfa67dc897f7d73f9f0a Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 13:54:19 +0400 Subject: [PATCH 06/30] copy ALL_IDS from sysvar module to avoid dependency --- sdk/message/src/legacy.rs | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/sdk/message/src/legacy.rs b/sdk/message/src/legacy.rs index 41e7e5280f8ca1..9ee6a92e2d60f2 100644 --- a/sdk/message/src/legacy.rs +++ b/sdk/message/src/legacy.rs @@ -24,12 +24,36 @@ use { solana_instruction::Instruction, solana_pubkey::Pubkey, solana_sanitize::{Sanitize, SanitizeError}, - solana_sdk_ids::{bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, system_program}, + solana_sdk_ids::{bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, system_program, sysvar}, solana_short_vec as short_vec, std::{collections::HashSet, convert::TryFrom, str::FromStr}, - system_instruction, sysvar, + system_instruction, }; +// copied from deprecated code in solana_sysvar to avoid a dependency. +// This should be removed when the items that depend on it are removed. +lazy_static::lazy_static! { + // This will be deprecated and so this list shouldn't be modified + static ref ALL_IDS: Vec = vec![ + sysvar::clock::id(), + sysvar::epoch_schedule::id(), + sysvar::fees::id(), + sysvar::recent_blockhashes::id(), + sysvar::rent::id(), + sysvar::rewards::id(), + sysvar::slot_hashes::id(), + sysvar::slot_history::id(), + sysvar::stake_history::id(), + sysvar::instructions::id(), + ]; +} + +// copied from deprecated code in solana_sysvar to avoid a dependency. +// This should be removed when the items that depend on it are removed. +fn is_sysvar_id(id: &Pubkey) -> bool { + ALL_IDS.iter().any(|key| key == id) +} + #[deprecated( since = "2.0.0", note = "please use `solana_sdk::reserved_account_keys::ReservedAccountKeys` instead" @@ -65,7 +89,7 @@ mod builtins { pub static ref MAYBE_BUILTIN_KEY_OR_SYSVAR: [bool; 256] = { let mut temp_table: [bool; 256] = [false; 256]; BUILTIN_PROGRAMS_KEYS.iter().for_each(|key| temp_table[key.as_ref()[0] as usize] = true); - sysvar::ALL_IDS.iter().for_each(|key| temp_table[key.as_ref()[0] as usize] = true); + ALL_IDS.iter().for_each(|key| temp_table[key.as_ref()[0] as usize] = true); temp_table }; } @@ -78,7 +102,7 @@ mod builtins { #[allow(deprecated)] pub fn is_builtin_key_or_sysvar(key: &Pubkey) -> bool { if MAYBE_BUILTIN_KEY_OR_SYSVAR[key.as_ref()[0] as usize] { - return sysvar::is_sysvar_id(key) || BUILTIN_PROGRAMS_KEYS.contains(key); + return is_sysvar_id(key) || BUILTIN_PROGRAMS_KEYS.contains(key); } false } From 357b2ea552132f185a2ef264463cb71620f88d24 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 13:54:29 +0400 Subject: [PATCH 07/30] update comment --- sdk/message/src/legacy.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/message/src/legacy.rs b/sdk/message/src/legacy.rs index 9ee6a92e2d60f2..d80925a5767cf6 100644 --- a/sdk/message/src/legacy.rs +++ b/sdk/message/src/legacy.rs @@ -30,7 +30,7 @@ use { system_instruction, }; -// copied from deprecated code in solana_sysvar to avoid a dependency. +// copied from deprecated code in solana_program::sysvar to avoid a dependency. // This should be removed when the items that depend on it are removed. lazy_static::lazy_static! { // This will be deprecated and so this list shouldn't be modified @@ -48,7 +48,7 @@ lazy_static::lazy_static! { ]; } -// copied from deprecated code in solana_sysvar to avoid a dependency. +// copied from deprecated code in solana_program::sysvar to avoid a dependency. // This should be removed when the items that depend on it are removed. fn is_sysvar_id(id: &Pubkey) -> bool { ALL_IDS.iter().any(|key| key == id) From b5de46f61b50c6a1211f4b991233c2da0e0fa43f Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 15:54:52 +0400 Subject: [PATCH 08/30] use system-interface crate --- Cargo.lock | 16 ++++++++++++++++ programs/sbf/Cargo.lock | 16 ++++++++++++++++ sdk/message/Cargo.toml | 3 ++- sdk/message/src/legacy.rs | 6 ++++-- sdk/message/src/sanitized.rs | 2 +- svm/examples/Cargo.lock | 16 ++++++++++++++++ 6 files changed, 55 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd875a6262354d..b398a790f8fb48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7537,6 +7537,7 @@ dependencies = [ "solana-sanitize", "solana-sdk-ids", "solana-short-vec", + "solana-system-interface", "solana-transaction-error", "thiserror 2.0.3", ] @@ -8984,6 +8985,21 @@ dependencies = [ "solana-sdk", ] +[[package]] +name = "solana-system-interface" +version = "0.0.1" +source = "git+https://github.com/solana-program/system.git#1cab018c8da4dbf7bcbe0a65f1d2f4bef135638b" +dependencies = [ + "js-sys", + "num-traits", + "serde", + "serde_derive", + "solana-decode-error", + "solana-instruction", + "solana-pubkey", + "wasm-bindgen", +] + [[package]] name = "solana-system-program" version = "2.2.0" diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 2ef61548e8c5b5..0d60ca6c58ffcc 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5963,6 +5963,7 @@ dependencies = [ "solana-sanitize", "solana-sdk-ids", "solana-short-vec", + "solana-system-interface", "solana-transaction-error", "thiserror 2.0.3", ] @@ -7582,6 +7583,21 @@ dependencies = [ "solana-sdk", ] +[[package]] +name = "solana-system-interface" +version = "0.0.1" +source = "git+https://github.com/solana-program/system.git#1cab018c8da4dbf7bcbe0a65f1d2f4bef135638b" +dependencies = [ + "js-sys", + "num-traits", + "serde", + "serde_derive", + "solana-decode-error", + "solana-instruction", + "solana-pubkey", + "wasm-bindgen", +] + [[package]] name = "solana-system-program" version = "2.2.0" diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index ed69d1ab400f19..4d95fd23dea454 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -11,7 +11,7 @@ edition = { workspace = true } [dependencies] bincode = { workspace = true } -blake3 = { workspace = true, features = ["traits-preview"]} +blake3 = { workspace = true, features = ["traits-preview"] } lazy_static = { workspace = true } serde = { workspace = true } serde_derive = { workspace = true } @@ -23,6 +23,7 @@ solana-pubkey = { workspace = true, features = ["serde"] } solana-sanitize = { workspace = true } solana-sdk-ids = { workspace = true } solana-short-vec = { workspace = true } +solana-system-interface = { git = "https://github.com/solana-program/system.git" } solana-transaction-error = { workspace = true } thiserror = { workspace = true } diff --git a/sdk/message/src/legacy.rs b/sdk/message/src/legacy.rs index d80925a5767cf6..1232406b2f96a3 100644 --- a/sdk/message/src/legacy.rs +++ b/sdk/message/src/legacy.rs @@ -24,10 +24,12 @@ use { solana_instruction::Instruction, solana_pubkey::Pubkey, solana_sanitize::{Sanitize, SanitizeError}, - solana_sdk_ids::{bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, system_program, sysvar}, + solana_sdk_ids::{ + bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, system_program, sysvar, + }, solana_short_vec as short_vec, + solana_system_interface::instruction as system_instruction, std::{collections::HashSet, convert::TryFrom, str::FromStr}, - system_instruction, }; // copied from deprecated code in solana_program::sysvar to avoid a dependency. diff --git a/sdk/message/src/sanitized.rs b/sdk/message/src/sanitized.rs index 42e6030d8ce290..452d4cef8c9caa 100644 --- a/sdk/message/src/sanitized.rs +++ b/sdk/message/src/sanitized.rs @@ -14,10 +14,10 @@ use { solana_hash::Hash, solana_instruction::{BorrowedAccountMeta, BorrowedInstruction}, solana_nonce::NONCED_TX_MARKER_IX_INDEX, - solana_program::system_instruction::SystemInstruction, solana_pubkey::Pubkey, solana_sanitize::Sanitize, solana_sdk_ids::{ed25519_program, secp256k1_program, system_program}, + solana_system_interface::instruction::SystemInstruction, std::{borrow::Cow, collections::HashSet, convert::TryFrom}, }; diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 6e3157a168d079..0abb0b713a2b8e 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5783,6 +5783,7 @@ dependencies = [ "solana-sanitize", "solana-sdk-ids", "solana-short-vec", + "solana-system-interface", "solana-transaction-error", "thiserror 2.0.3", ] @@ -6934,6 +6935,21 @@ dependencies = [ "solana-sdk", ] +[[package]] +name = "solana-system-interface" +version = "0.0.1" +source = "git+https://github.com/solana-program/system.git#1cab018c8da4dbf7bcbe0a65f1d2f4bef135638b" +dependencies = [ + "js-sys", + "num-traits", + "serde", + "serde_derive", + "solana-decode-error", + "solana-instruction", + "solana-pubkey", + "wasm-bindgen", +] + [[package]] name = "solana-system-program" version = "2.2.0" From 886cc7c2401799757dca82909e304f670a51e5b8 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 15:58:38 +0400 Subject: [PATCH 09/30] re-export message crate in solana-program --- sdk/program/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/program/src/lib.rs b/sdk/program/src/lib.rs index 478e55db3eb213..e36ff37750604c 100644 --- a/sdk/program/src/lib.rs +++ b/sdk/program/src/lib.rs @@ -490,7 +490,6 @@ pub mod loader_upgradeable_instruction; pub mod loader_v4; pub mod loader_v4_instruction; pub mod log; -pub mod message; pub mod nonce; pub mod program; pub mod program_error; @@ -524,6 +523,8 @@ pub use solana_fee_calculator as fee_calculator; pub use solana_keccak_hasher as keccak; #[deprecated(since = "2.1.0", note = "Use `solana-last-restart-slot` crate instead")] pub use solana_last_restart_slot as last_restart_slot; +#[deprecated(since = "2.2.0", note = "Use `solana-message` crate instead")] +pub use solana_message as message; #[deprecated(since = "2.1.0", note = "Use `solana-program-memory` crate instead")] pub use solana_program_memory as program_memory; #[deprecated(since = "2.1.0", note = "Use `solana-program-pack` crate instead")] From 90fa81d2f7398d91eee19fdb428ea7120b0018d7 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 16:02:45 +0400 Subject: [PATCH 10/30] fix tests --- Cargo.lock | 7 +++++++ sdk/message/Cargo.toml | 9 +++++++++ sdk/message/src/versions/v0/loaded.rs | 2 -- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b398a790f8fb48..1a3895faa7ad3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7524,18 +7524,25 @@ dependencies = [ name = "solana-message" version = "2.2.0" dependencies = [ + "anyhow", "bincode", + "bitflags 2.6.0", "blake3", + "borsh 1.5.3", + "itertools 0.12.1", "lazy_static", "serde", "serde_derive", + "serde_json", "solana-bincode", "solana-hash", "solana-instruction", "solana-nonce", + "solana-program", "solana-pubkey", "solana-sanitize", "solana-sdk-ids", + "solana-sha256-hasher", "solana-short-vec", "solana-system-interface", "solana-transaction-error", diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 4d95fd23dea454..953f9cca6d08a8 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -27,6 +27,15 @@ solana-system-interface = { git = "https://github.com/solana-program/system.git" solana-transaction-error = { workspace = true } thiserror = { workspace = true } +[dev-dependencies] +anyhow = { workspace = true } +borsh = { workspace = true } +bitflags = { workspace = true } +itertools = { workspace = true } +serde_json = { workspace = true } +solana-program = { path = "../program" } +solana-sha256-hasher = { workspace = true } + [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/sdk/message/src/versions/v0/loaded.rs b/sdk/message/src/versions/v0/loaded.rs index 883d7a4b2efab6..815779b11cb58c 100644 --- a/sdk/message/src/versions/v0/loaded.rs +++ b/sdk/message/src/versions/v0/loaded.rs @@ -270,8 +270,6 @@ mod tests { #[test] fn test_is_writable() { - solana_logger::setup(); - let reserved_account_keys = HashSet::from_iter([sysvar::clock::id(), system_program::id()]); let create_message_with_keys = |keys: Vec| { LoadedMessage::new( From f1d621bc43a5bb93e1d40731882a13671a826bdb Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 16:06:48 +0400 Subject: [PATCH 11/30] fix doc links --- sdk/message/src/legacy.rs | 4 +--- sdk/message/src/lib.rs | 4 ++-- sdk/message/src/versions/v0/mod.rs | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/sdk/message/src/legacy.rs b/sdk/message/src/legacy.rs index 1232406b2f96a3..3f49987308279a 100644 --- a/sdk/message/src/legacy.rs +++ b/sdk/message/src/legacy.rs @@ -133,9 +133,7 @@ fn compile_instructions(ixs: &[Instruction], keys: &[Pubkey]) -> Vec Date: Tue, 19 Nov 2024 16:07:55 +0400 Subject: [PATCH 12/30] add doc_auto_cfg --- sdk/message/Cargo.toml | 2 ++ sdk/message/src/lib.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 953f9cca6d08a8..d5c1413dfa068e 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -38,6 +38,8 @@ solana-sha256-hasher = { workspace = true } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +all-features = true +rustdoc-args = ["--cfg=docsrs"] [lints] workspace = true diff --git a/sdk/message/src/lib.rs b/sdk/message/src/lib.rs index 66005ac8cd65de..013f2df30f3e33 100644 --- a/sdk/message/src/lib.rs +++ b/sdk/message/src/lib.rs @@ -1,3 +1,4 @@ +#![cfg_attr(docsrs, feature(doc_auto_cfg))] //! Sequences of [`Instruction`]s executed within a single transaction. //! //! [`Instruction`]: https://docs.rs/solana-instruction/latest/solana_instruction/struct.Instruction.html From 79d972e419ffa26ed91109e5f96093b90affce9a Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 16:43:20 +0400 Subject: [PATCH 13/30] make serde and bincode optional --- Cargo.lock | 1 + programs/sbf/Cargo.lock | 5 ---- sdk/message/Cargo.toml | 33 ++++++++++++++++----- sdk/message/src/compiled_instruction.rs | 25 ++++++++-------- sdk/message/src/legacy.rs | 39 ++++++++++++++++--------- sdk/message/src/lib.rs | 9 ++++-- sdk/message/src/sanitized.rs | 16 +++++----- sdk/message/src/versions/mod.rs | 23 ++++++++++----- sdk/message/src/versions/v0/loaded.rs | 6 ++-- sdk/message/src/versions/v0/mod.rs | 35 +++++++++++++--------- svm/examples/Cargo.lock | 5 ---- 11 files changed, 121 insertions(+), 76 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a3895faa7ad3d..a232c10256b764 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7537,6 +7537,7 @@ dependencies = [ "solana-bincode", "solana-hash", "solana-instruction", + "solana-message", "solana-nonce", "solana-program", "solana-pubkey", diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 0d60ca6c58ffcc..9b1ce43312f671 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5950,19 +5950,14 @@ dependencies = [ name = "solana-message" version = "2.2.0" dependencies = [ - "bincode", "blake3", "lazy_static", - "serde", - "serde_derive", - "solana-bincode", "solana-hash", "solana-instruction", "solana-nonce", "solana-pubkey", "solana-sanitize", "solana-sdk-ids", - "solana-short-vec", "solana-system-interface", "solana-transaction-error", "thiserror 2.0.3", diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index d5c1413dfa068e..7b91bdb76d5a15 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -10,20 +10,20 @@ license = { workspace = true } edition = { workspace = true } [dependencies] -bincode = { workspace = true } +bincode = { workspace = true, optional = true } blake3 = { workspace = true, features = ["traits-preview"] } lazy_static = { workspace = true } -serde = { workspace = true } -serde_derive = { workspace = true } -solana-bincode = { workspace = true } -solana-hash = { workspace = true, features = ["serde"] } +serde = { workspace = true, optional = true } +serde_derive = { workspace = true, optional = true } +solana-bincode = { workspace = true, optional = true } +solana-hash = { workspace = true } solana-instruction = { workspace = true, features = ["std"] } solana-nonce = { workspace = true } -solana-pubkey = { workspace = true, features = ["serde"] } +solana-pubkey = { workspace = true } solana-sanitize = { workspace = true } solana-sdk-ids = { workspace = true } -solana-short-vec = { workspace = true } -solana-system-interface = { git = "https://github.com/solana-program/system.git" } +solana-short-vec = { workspace = true, optional = true } +solana-system-interface = { git = "https://github.com/solana-program/system.git", optional = true } solana-transaction-error = { workspace = true } thiserror = { workspace = true } @@ -33,9 +33,26 @@ borsh = { workspace = true } bitflags = { workspace = true } itertools = { workspace = true } serde_json = { workspace = true } +solana-message = { path = ".", features = ["dev-context-only-utils"] } solana-program = { path = "../program" } solana-sha256-hasher = { workspace = true } +[features] +bincode = [ + "dep:bincode", + "dep:solana-bincode", + "dep:solana-system-interface", + "serde", +] +dev-context-only-utils = ["bincode"] +serde = [ + "dep:serde", + "dep:serde_derive", + "dep:solana-short-vec", + "solana-hash/serde", + "solana-pubkey/serde", +] + [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] all-features = true diff --git a/sdk/message/src/compiled_instruction.rs b/sdk/message/src/compiled_instruction.rs index 2469d0de21cbb1..0405b87e0c1fef 100644 --- a/sdk/message/src/compiled_instruction.rs +++ b/sdk/message/src/compiled_instruction.rs @@ -1,10 +1,6 @@ -use { - bincode::serialize, - serde_derive::{Deserialize, Serialize}, - solana_pubkey::Pubkey, - solana_sanitize::Sanitize, - solana_short_vec as short_vec, -}; +#[cfg(feature = "serde")] +use serde_derive::{Deserialize, Serialize}; +use {solana_pubkey::Pubkey, solana_sanitize::Sanitize}; /// A compact encoding of an instruction. /// @@ -14,24 +10,29 @@ use { /// /// [`Message`]: crate::Message #[cfg_attr(feature = "frozen-abi", derive(AbiExample))] -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] -#[serde(rename_all = "camelCase")] +#[cfg_attr( + feature = "serde", + derive(Deserialize, Serialize), + serde(rename_all = "camelCase") +)] +#[derive(Debug, PartialEq, Eq, Clone)] pub struct CompiledInstruction { /// Index into the transaction keys array indicating the program account that executes this instruction. pub program_id_index: u8, /// Ordered indices into the transaction keys array indicating which accounts to pass to the program. - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub accounts: Vec, /// The program input data. - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub data: Vec, } impl Sanitize for CompiledInstruction {} impl CompiledInstruction { + #[cfg(feature = "bincode")] pub fn new(program_ids_index: u8, data: &T, accounts: Vec) -> Self { - let data = serialize(data).unwrap(); + let data = bincode::serialize(data).unwrap(); Self { program_id_index: program_ids_index, accounts, diff --git a/sdk/message/src/legacy.rs b/sdk/message/src/legacy.rs index 3f49987308279a..f6c3589928e747 100644 --- a/sdk/message/src/legacy.rs +++ b/sdk/message/src/legacy.rs @@ -13,13 +13,14 @@ #[allow(deprecated)] pub use builtins::{BUILTIN_PROGRAMS_KEYS, MAYBE_BUILTIN_KEY_OR_SYSVAR}; +#[cfg(feature = "serde")] +use serde_derive::{Deserialize, Serialize}; #[cfg(target_arch = "wasm32")] use wasm_bindgen::prelude::wasm_bindgen; use { crate::{ compiled_instruction::CompiledInstruction, compiled_keys::CompiledKeys, MessageHeader, }, - serde_derive::{Deserialize, Serialize}, solana_hash::Hash, solana_instruction::Instruction, solana_pubkey::Pubkey, @@ -27,8 +28,6 @@ use { solana_sdk_ids::{ bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, system_program, sysvar, }, - solana_short_vec as short_vec, - solana_system_interface::instruction as system_instruction, std::{collections::HashSet, convert::TryFrom, str::FromStr}, }; @@ -151,15 +150,19 @@ fn compile_instructions(ixs: &[Instruction], keys: &[Pubkey]) -> Vec, /// The id of a recent ledger entry. @@ -167,7 +170,7 @@ pub struct Message { /// Programs that will be executed in sequence and committed in one atomic transaction if all /// succeed. - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub instructions: Vec, } @@ -181,21 +184,25 @@ pub struct Message { frozen_abi(digest = "4kL6EbLGU25m5eMk4H1cW9YGhA5LejHSgj2w2fhY1NGp"), derive(AbiExample) )] -#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone)] -#[serde(rename_all = "camelCase")] +#[cfg_attr( + feature = "serde", + derive(Deserialize, Serialize), + serde(rename_all = "camelCase") +)] +#[derive(Default, Debug, PartialEq, Eq, Clone)] pub struct Message { #[wasm_bindgen(skip)] pub header: MessageHeader, #[wasm_bindgen(skip)] - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub account_keys: Vec, /// The id of a recent ledger entry. pub recent_blockhash: Hash, #[wasm_bindgen(skip)] - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub instructions: Vec, } @@ -506,14 +513,17 @@ impl Message { /// # create_offline_initialize_tx(&client, program_id, &payer)?; /// # Ok::<(), anyhow::Error>(()) /// ``` + #[cfg(feature = "bincode")] pub fn new_with_nonce( mut instructions: Vec, payer: Option<&Pubkey>, nonce_account_pubkey: &Pubkey, nonce_authority_pubkey: &Pubkey, ) -> Self { - let nonce_ix = - system_instruction::advance_nonce_account(nonce_account_pubkey, nonce_authority_pubkey); + let nonce_ix = solana_system_interface::instruction::advance_nonce_account( + nonce_account_pubkey, + nonce_authority_pubkey, + ); instructions.insert(0, nonce_ix); Self::new(&instructions, payer) } @@ -539,7 +549,7 @@ impl Message { } /// Compute the blake3 hash of this transaction's message. - #[cfg(not(target_os = "solana"))] + #[cfg(all(not(target_os = "solana"), feature = "bincode"))] pub fn hash(&self) -> Hash { let message_bytes = self.serialize(); Self::hash_raw_message(&message_bytes) @@ -560,6 +570,7 @@ impl Message { compile_instruction(ix, &self.account_keys) } + #[cfg(feature = "bincode")] pub fn serialize(&self) -> Vec { bincode::serialize(self).unwrap() } diff --git a/sdk/message/src/lib.rs b/sdk/message/src/lib.rs index 013f2df30f3e33..65099a23a8b3ef 100644 --- a/sdk/message/src/lib.rs +++ b/sdk/message/src/lib.rs @@ -41,6 +41,7 @@ pub mod compiled_instruction; mod compiled_keys; pub mod legacy; +#[cfg(feature = "serde")] use serde_derive::{Deserialize, Serialize}; #[cfg(not(target_os = "solana"))] @@ -95,8 +96,12 @@ pub const MESSAGE_HEADER_LENGTH: usize = 3; /// /// [PoH]: https://docs.solanalabs.com/consensus/synchronization #[cfg_attr(feature = "frozen-abi", derive(AbiExample))] -#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone, Copy)] -#[serde(rename_all = "camelCase")] +#[cfg_attr( + feature = "serde", + derive(Deserialize, Serialize), + serde(rename_all = "camelCase") +)] +#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] pub struct MessageHeader { /// The number of signatures required for this message to be considered /// valid. The signers of those signatures must match the first diff --git a/sdk/message/src/sanitized.rs b/sdk/message/src/sanitized.rs index 452d4cef8c9caa..9e6237a92177ad 100644 --- a/sdk/message/src/sanitized.rs +++ b/sdk/message/src/sanitized.rs @@ -10,14 +10,11 @@ use { v0::{self, LoadedAddresses}, AccountKeys, AddressLoader, MessageHeader, SanitizedVersionedMessage, VersionedMessage, }, - solana_bincode::limited_deserialize, solana_hash::Hash, solana_instruction::{BorrowedAccountMeta, BorrowedInstruction}, - solana_nonce::NONCED_TX_MARKER_IX_INDEX, solana_pubkey::Pubkey, solana_sanitize::Sanitize, - solana_sdk_ids::{ed25519_program, secp256k1_program, system_program}, - solana_system_interface::instruction::SystemInstruction, + solana_sdk_ids::{ed25519_program, secp256k1_program}, std::{borrow::Cow, collections::HashSet, convert::TryFrom}, }; @@ -328,20 +325,23 @@ impl SanitizedMessage { }) } + #[cfg(feature = "bincode")] /// If the message uses a durable nonce, return the pubkey of the nonce account pub fn get_durable_nonce(&self) -> Option<&Pubkey> { self.instructions() - .get(NONCED_TX_MARKER_IX_INDEX as usize) + .get(solana_nonce::NONCED_TX_MARKER_IX_INDEX as usize) .filter( |ix| match self.account_keys().get(ix.program_id_index as usize) { - Some(program_id) => system_program::check_id(program_id), + Some(program_id) => solana_sdk_ids::system_program::check_id(program_id), _ => false, }, ) .filter(|ix| { matches!( - limited_deserialize(&ix.data, 4 /* serialized size of AdvanceNonceAccount */), - Ok(SystemInstruction::AdvanceNonceAccount) + solana_bincode::limited_deserialize( + &ix.data, 4 /* serialized size of AdvanceNonceAccount */ + ), + Ok(solana_system_interface::instruction::SystemInstruction::AdvanceNonceAccount) ) }) .and_then(|ix| { diff --git a/sdk/message/src/versions/mod.rs b/sdk/message/src/versions/mod.rs index 8847f2a24ebb3f..a754ec274a51e6 100644 --- a/sdk/message/src/versions/mod.rs +++ b/sdk/message/src/versions/mod.rs @@ -3,16 +3,19 @@ use { compiled_instruction::CompiledInstruction, legacy::Message as LegacyMessage, v0::MessageAddressTableLookup, MessageHeader, }, + solana_hash::{Hash, HASH_BYTES}, + solana_pubkey::Pubkey, + solana_sanitize::{Sanitize, SanitizeError}, + std::collections::HashSet, +}; +#[cfg(feature = "serde")] +use { serde::{ de::{self, Deserializer, SeqAccess, Unexpected, Visitor}, ser::{SerializeTuple, Serializer}, }, serde_derive::{Deserialize, Serialize}, - solana_hash::{Hash, HASH_BYTES}, - solana_pubkey::Pubkey, - solana_sanitize::{Sanitize, SanitizeError}, - solana_short_vec as short_vec, - std::{collections::HashSet, fmt}, + std::fmt, }; mod sanitized; @@ -145,10 +148,12 @@ impl VersionedMessage { } } + #[cfg(feature = "bincode")] pub fn serialize(&self) -> Vec { bincode::serialize(self).unwrap() } + #[cfg(feature = "bincode")] /// Compute the blake3 hash of this transaction's message pub fn hash(&self) -> Hash { let message_bytes = self.serialize(); @@ -172,6 +177,7 @@ impl Default for VersionedMessage { } } +#[cfg(feature = "serde")] impl serde::Serialize for VersionedMessage { fn serialize(&self, serializer: S) -> Result where @@ -193,11 +199,13 @@ impl serde::Serialize for VersionedMessage { } } +#[cfg(feature = "serde")] enum MessagePrefix { Legacy(u8), Versioned(u8), } +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for MessagePrefix { fn deserialize(deserializer: D) -> Result where @@ -234,6 +242,7 @@ impl<'de> serde::Deserialize<'de> for MessagePrefix { } } +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for VersionedMessage { fn deserialize(deserializer: D) -> Result where @@ -263,10 +272,10 @@ impl<'de> serde::Deserialize<'de> for VersionedMessage { struct RemainingLegacyMessage { pub num_readonly_signed_accounts: u8, pub num_readonly_unsigned_accounts: u8, - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub account_keys: Vec, pub recent_blockhash: Hash, - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub instructions: Vec, } diff --git a/sdk/message/src/versions/v0/loaded.rs b/sdk/message/src/versions/v0/loaded.rs index 815779b11cb58c..94325007e01be8 100644 --- a/sdk/message/src/versions/v0/loaded.rs +++ b/sdk/message/src/versions/v0/loaded.rs @@ -1,6 +1,7 @@ +#[cfg(feature = "serde")] +use serde_derive::{Deserialize, Serialize}; use { crate::{v0, AccountKeys}, - serde_derive::{Deserialize, Serialize}, solana_pubkey::Pubkey, solana_sdk_ids::bpf_loader_upgradeable, std::{borrow::Cow, collections::HashSet}, @@ -20,7 +21,8 @@ pub struct LoadedMessage<'a> { /// Collection of addresses loaded from on-chain lookup tables, split /// by readonly and writable. -#[derive(Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Default, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] pub struct LoadedAddresses { /// List of addresses for writable loaded accounts pub writable: Vec, diff --git a/sdk/message/src/versions/v0/mod.rs b/sdk/message/src/versions/v0/mod.rs index b850d8486fcced..4761e49a47df66 100644 --- a/sdk/message/src/versions/v0/mod.rs +++ b/sdk/message/src/versions/v0/mod.rs @@ -10,19 +10,19 @@ //! [future message format]: https://docs.solanalabs.com/proposals/versioned-transactions pub use loaded::*; +#[cfg(feature = "serde")] +use serde_derive::{Deserialize, Serialize}; use { crate::{ compiled_instruction::CompiledInstruction, compiled_keys::{CompileError, CompiledKeys}, - AccountKeys, AddressLookupTableAccount, MessageHeader, MESSAGE_VERSION_PREFIX, + AccountKeys, AddressLookupTableAccount, MessageHeader, }, - serde_derive::{Deserialize, Serialize}, solana_hash::Hash, solana_instruction::Instruction, solana_pubkey::Pubkey, solana_sanitize::SanitizeError, solana_sdk_ids::bpf_loader_upgradeable, - solana_short_vec as short_vec, std::collections::HashSet, }; @@ -31,16 +31,20 @@ mod loaded; /// Address table lookups describe an on-chain address lookup table to use /// for loading more readonly and writable accounts in a single tx. #[cfg_attr(feature = "frozen-abi", derive(AbiExample))] -#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone)] -#[serde(rename_all = "camelCase")] +#[cfg_attr( + feature = "serde", + derive(Deserialize, Serialize), + serde(rename_all = "camelCase") +)] +#[derive(Default, Debug, PartialEq, Eq, Clone)] pub struct MessageAddressTableLookup { /// Address lookup table account key pub account_key: Pubkey, /// List of indexes used to load writable account addresses - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub writable_indexes: Vec, /// List of indexes used to load readonly account addresses - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub readonly_indexes: Vec, } @@ -52,8 +56,12 @@ pub struct MessageAddressTableLookup { /// See the crate documentation for further description. /// #[cfg_attr(feature = "frozen-abi", derive(AbiExample))] -#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone)] -#[serde(rename_all = "camelCase")] +#[cfg_attr( + feature = "serde", + derive(Deserialize, Serialize), + serde(rename_all = "camelCase") +)] +#[derive(Default, Debug, PartialEq, Eq, Clone)] pub struct Message { /// The message header, identifying signed and read-only `account_keys`. /// Header values only describe static `account_keys`, they do not describe @@ -61,7 +69,7 @@ pub struct Message { pub header: MessageHeader, /// List of accounts loaded by this transaction. - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub account_keys: Vec, /// The blockhash of a recent block. @@ -80,12 +88,12 @@ pub struct Message { /// 1) message `account_keys` /// 2) ordered list of keys loaded from `writable` lookup table indexes /// 3) ordered list of keys loaded from `readable` lookup table indexes - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub instructions: Vec, /// List of address table lookups used to load additional accounts /// for this transaction. - #[serde(with = "short_vec")] + #[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] pub address_table_lookups: Vec, } @@ -286,9 +294,10 @@ impl Message { }) } + #[cfg(feature = "bincode")] /// Serialize this message with a version #0 prefix using bincode encoding. pub fn serialize(&self) -> Vec { - bincode::serialize(&(MESSAGE_VERSION_PREFIX, self)).unwrap() + bincode::serialize(&(crate::MESSAGE_VERSION_PREFIX, self)).unwrap() } /// Returns true if the account at the specified index is called as a program by an instruction diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 0abb0b713a2b8e..d28449261df2a9 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5770,19 +5770,14 @@ dependencies = [ name = "solana-message" version = "2.2.0" dependencies = [ - "bincode", "blake3", "lazy_static", - "serde", - "serde_derive", - "solana-bincode", "solana-hash", "solana-instruction", "solana-nonce", "solana-pubkey", "solana-sanitize", "solana-sdk-ids", - "solana-short-vec", "solana-system-interface", "solana-transaction-error", "thiserror 2.0.3", From 9e4ae97b73e380936a69397f5028e5692af73631 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 16:47:57 +0400 Subject: [PATCH 14/30] inline const from solana_nonce --- Cargo.lock | 1 + sdk/message/Cargo.toml | 3 ++- sdk/message/src/sanitized.rs | 11 ++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a232c10256b764..34ee40d20f0fcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7547,6 +7547,7 @@ dependencies = [ "solana-short-vec", "solana-system-interface", "solana-transaction-error", + "static_assertions", "thiserror 2.0.3", ] diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 7b91bdb76d5a15..1d1aa7bb78e8a8 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -18,7 +18,6 @@ serde_derive = { workspace = true, optional = true } solana-bincode = { workspace = true, optional = true } solana-hash = { workspace = true } solana-instruction = { workspace = true, features = ["std"] } -solana-nonce = { workspace = true } solana-pubkey = { workspace = true } solana-sanitize = { workspace = true } solana-sdk-ids = { workspace = true } @@ -34,8 +33,10 @@ bitflags = { workspace = true } itertools = { workspace = true } serde_json = { workspace = true } solana-message = { path = ".", features = ["dev-context-only-utils"] } +solana-nonce = { workspace = true } solana-program = { path = "../program" } solana-sha256-hasher = { workspace = true } +static_assertions = { workspace = true } [features] bincode = [ diff --git a/sdk/message/src/sanitized.rs b/sdk/message/src/sanitized.rs index 9e6237a92177ad..ac7f61b05010a6 100644 --- a/sdk/message/src/sanitized.rs +++ b/sdk/message/src/sanitized.rs @@ -18,6 +18,15 @@ use { std::{borrow::Cow, collections::HashSet, convert::TryFrom}, }; +// inlined to avoid solana_nonce dep +#[cfg(feature = "bincode")] +const NONCED_TX_MARKER_IX_INDEX: u8 = 0; +#[cfg(test)] +static_assertions::const_assert_eq!( + NONCED_TX_MARKER_IX_INDEX, + solana_nonce::NONCED_TX_MARKER_IX_INDEX +); + #[derive(Debug, Clone, Eq, PartialEq)] pub struct LegacyMessage<'a> { /// Legacy message @@ -329,7 +338,7 @@ impl SanitizedMessage { /// If the message uses a durable nonce, return the pubkey of the nonce account pub fn get_durable_nonce(&self) -> Option<&Pubkey> { self.instructions() - .get(solana_nonce::NONCED_TX_MARKER_IX_INDEX as usize) + .get(NONCED_TX_MARKER_IX_INDEX as usize) .filter( |ix| match self.account_keys().get(ix.program_id_index as usize) { Some(program_id) => solana_sdk_ids::system_program::check_id(program_id), From 773d2be04bfa7c248cda7033c021d245e40659ec Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 16:48:28 +0400 Subject: [PATCH 15/30] update lock file --- programs/sbf/Cargo.lock | 17 ----------------- svm/examples/Cargo.lock | 17 ----------------- 2 files changed, 34 deletions(-) diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 9b1ce43312f671..c5f9683e37b231 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5954,11 +5954,9 @@ dependencies = [ "lazy_static", "solana-hash", "solana-instruction", - "solana-nonce", "solana-pubkey", "solana-sanitize", "solana-sdk-ids", - "solana-system-interface", "solana-transaction-error", "thiserror 2.0.3", ] @@ -7578,21 +7576,6 @@ dependencies = [ "solana-sdk", ] -[[package]] -name = "solana-system-interface" -version = "0.0.1" -source = "git+https://github.com/solana-program/system.git#1cab018c8da4dbf7bcbe0a65f1d2f4bef135638b" -dependencies = [ - "js-sys", - "num-traits", - "serde", - "serde_derive", - "solana-decode-error", - "solana-instruction", - "solana-pubkey", - "wasm-bindgen", -] - [[package]] name = "solana-system-program" version = "2.2.0" diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index d28449261df2a9..59bccec79bbe31 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5774,11 +5774,9 @@ dependencies = [ "lazy_static", "solana-hash", "solana-instruction", - "solana-nonce", "solana-pubkey", "solana-sanitize", "solana-sdk-ids", - "solana-system-interface", "solana-transaction-error", "thiserror 2.0.3", ] @@ -6930,21 +6928,6 @@ dependencies = [ "solana-sdk", ] -[[package]] -name = "solana-system-interface" -version = "0.0.1" -source = "git+https://github.com/solana-program/system.git#1cab018c8da4dbf7bcbe0a65f1d2f4bef135638b" -dependencies = [ - "js-sys", - "num-traits", - "serde", - "serde_derive", - "solana-decode-error", - "solana-instruction", - "solana-pubkey", - "wasm-bindgen", -] - [[package]] name = "solana-system-program" version = "2.2.0" From 6d8e18a855040fe4e860144cc9b42764118692eb Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 16:58:05 +0400 Subject: [PATCH 16/30] remove thiserror --- Cargo.lock | 1 - programs/sbf/Cargo.lock | 1 - sdk/message/Cargo.toml | 1 - sdk/message/src/compiled_keys.rs | 28 ++++++++++++++++++++++------ svm/examples/Cargo.lock | 1 - 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 34ee40d20f0fcc..2f797aaa2dd2b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7548,7 +7548,6 @@ dependencies = [ "solana-system-interface", "solana-transaction-error", "static_assertions", - "thiserror 2.0.3", ] [[package]] diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index c5f9683e37b231..6bcf95dc2238ac 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5958,7 +5958,6 @@ dependencies = [ "solana-sanitize", "solana-sdk-ids", "solana-transaction-error", - "thiserror 2.0.3", ] [[package]] diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 1d1aa7bb78e8a8..2e925653cbcd4a 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -24,7 +24,6 @@ solana-sdk-ids = { workspace = true } solana-short-vec = { workspace = true, optional = true } solana-system-interface = { git = "https://github.com/solana-program/system.git", optional = true } solana-transaction-error = { workspace = true } -thiserror = { workspace = true } [dev-dependencies] anyhow = { workspace = true } diff --git a/sdk/message/src/compiled_keys.rs b/sdk/message/src/compiled_keys.rs index 5f427b66f8257e..c973374791263e 100644 --- a/sdk/message/src/compiled_keys.rs +++ b/sdk/message/src/compiled_keys.rs @@ -4,8 +4,8 @@ use crate::{ AddressLookupTableAccount, }; use { - crate::MessageHeader, solana_instruction::Instruction, solana_pubkey::Pubkey, - std::collections::BTreeMap, thiserror::Error, + crate::MessageHeader, core::fmt, solana_instruction::Instruction, solana_pubkey::Pubkey, + std::collections::BTreeMap, }; /// A helper struct to collect pubkeys compiled for a set of instructions @@ -16,16 +16,32 @@ pub(crate) struct CompiledKeys { } #[cfg_attr(target_os = "solana", allow(dead_code))] -#[derive(PartialEq, Debug, Error, Eq, Clone)] +#[derive(PartialEq, Debug, Eq, Clone)] pub enum CompileError { - #[error("account index overflowed during compilation")] AccountIndexOverflow, - #[error("address lookup table index overflowed during compilation")] AddressTableLookupIndexOverflow, - #[error("encountered unknown account key `{0}` during instruction compilation")] UnknownInstructionKey(Pubkey), } +impl std::error::Error for CompileError {} + +impl fmt::Display for CompileError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + CompileError::AccountIndexOverflow => { + f.write_str("account index overflowed during compilation") + } + CompileError::AddressTableLookupIndexOverflow => { + f.write_str("address lookup table index overflowed during compilation") + } + CompileError::UnknownInstructionKey(key) => f.write_fmt(format_args!( + "encountered unknown account key `{0}` during instruction compilation", + key, + )), + } + } +} + #[derive(Default, Debug, Clone, PartialEq, Eq)] struct CompiledKeyMeta { is_signer: bool, diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 59bccec79bbe31..89cb9e05dffcb3 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5778,7 +5778,6 @@ dependencies = [ "solana-sanitize", "solana-sdk-ids", "solana-transaction-error", - "thiserror 2.0.3", ] [[package]] From 214b21de0fab106e652e0ddcee5ba78f332c525b Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 17:09:10 +0400 Subject: [PATCH 17/30] frozen-abi support --- Cargo.lock | 2 ++ sdk/message/Cargo.toml | 3 +++ sdk/message/src/compiled_instruction.rs | 2 ++ sdk/message/src/legacy.rs | 2 ++ sdk/message/src/lib.rs | 3 +++ sdk/message/src/versions/mod.rs | 2 ++ sdk/message/src/versions/v0/mod.rs | 2 ++ 7 files changed, 16 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 2f797aaa2dd2b6..483d691973a4a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7535,6 +7535,8 @@ dependencies = [ "serde_derive", "serde_json", "solana-bincode", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-hash", "solana-instruction", "solana-message", diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 2e925653cbcd4a..dcd13728e2d31e 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -16,6 +16,8 @@ lazy_static = { workspace = true } serde = { workspace = true, optional = true } serde_derive = { workspace = true, optional = true } solana-bincode = { workspace = true, optional = true } +solana-frozen-abi = { workspace = true, optional = true } +solana-frozen-abi-macro = { workspace = true, optional = true } solana-hash = { workspace = true } solana-instruction = { workspace = true, features = ["std"] } solana-pubkey = { workspace = true } @@ -45,6 +47,7 @@ bincode = [ "serde", ] dev-context-only-utils = ["bincode"] +frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"] serde = [ "dep:serde", "dep:serde_derive", diff --git a/sdk/message/src/compiled_instruction.rs b/sdk/message/src/compiled_instruction.rs index 0405b87e0c1fef..dc972854f6a06c 100644 --- a/sdk/message/src/compiled_instruction.rs +++ b/sdk/message/src/compiled_instruction.rs @@ -1,5 +1,7 @@ #[cfg(feature = "serde")] use serde_derive::{Deserialize, Serialize}; +#[cfg(feature = "frozen-abi")] +use solana_frozen_abi_macro::AbiExample; use {solana_pubkey::Pubkey, solana_sanitize::Sanitize}; /// A compact encoding of an instruction. diff --git a/sdk/message/src/legacy.rs b/sdk/message/src/legacy.rs index f6c3589928e747..8a94caa6807ff3 100644 --- a/sdk/message/src/legacy.rs +++ b/sdk/message/src/legacy.rs @@ -15,6 +15,8 @@ pub use builtins::{BUILTIN_PROGRAMS_KEYS, MAYBE_BUILTIN_KEY_OR_SYSVAR}; #[cfg(feature = "serde")] use serde_derive::{Deserialize, Serialize}; +#[cfg(feature = "frozen-abi")] +use solana_frozen_abi_macro::{frozen_abi, AbiExample}; #[cfg(target_arch = "wasm32")] use wasm_bindgen::prelude::wasm_bindgen; use { diff --git a/sdk/message/src/lib.rs b/sdk/message/src/lib.rs index 65099a23a8b3ef..1233fc73564550 100644 --- a/sdk/message/src/lib.rs +++ b/sdk/message/src/lib.rs @@ -1,4 +1,5 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![cfg_attr(feature = "frozen-abi", feature(min_specialization))] //! Sequences of [`Instruction`]s executed within a single transaction. //! //! [`Instruction`]: https://docs.rs/solana-instruction/latest/solana_instruction/struct.Instruction.html @@ -43,6 +44,8 @@ mod compiled_keys; pub mod legacy; #[cfg(feature = "serde")] use serde_derive::{Deserialize, Serialize}; +#[cfg(feature = "frozen-abi")] +use solana_frozen_abi_macro::AbiExample; #[cfg(not(target_os = "solana"))] #[path = ""] diff --git a/sdk/message/src/versions/mod.rs b/sdk/message/src/versions/mod.rs index a754ec274a51e6..964f160b2abcce 100644 --- a/sdk/message/src/versions/mod.rs +++ b/sdk/message/src/versions/mod.rs @@ -1,3 +1,5 @@ +#[cfg(feature = "frozen-abi")] +use solana_frozen_abi_macro::{frozen_abi, AbiEnumVisitor, AbiExample}; use { crate::{ compiled_instruction::CompiledInstruction, legacy::Message as LegacyMessage, diff --git a/sdk/message/src/versions/v0/mod.rs b/sdk/message/src/versions/v0/mod.rs index 4761e49a47df66..e4a269c0b1b0b0 100644 --- a/sdk/message/src/versions/v0/mod.rs +++ b/sdk/message/src/versions/v0/mod.rs @@ -12,6 +12,8 @@ pub use loaded::*; #[cfg(feature = "serde")] use serde_derive::{Deserialize, Serialize}; +#[cfg(feature = "frozen-abi")] +use solana_frozen_abi_macro::AbiExample; use { crate::{ compiled_instruction::CompiledInstruction, From bc4ac3fbd7e063dbc6424c42249dd41d74b7ce50 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 17:12:05 +0400 Subject: [PATCH 18/30] missing feature activation --- programs/sbf/Cargo.lock | 21 +++++++++++++++++++++ sdk/program/Cargo.toml | 2 +- svm/examples/Cargo.lock | 21 +++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 6bcf95dc2238ac..e849881eddff58 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5950,13 +5950,19 @@ dependencies = [ name = "solana-message" version = "2.2.0" dependencies = [ + "bincode", "blake3", "lazy_static", + "serde", + "serde_derive", + "solana-bincode", "solana-hash", "solana-instruction", "solana-pubkey", "solana-sanitize", "solana-sdk-ids", + "solana-short-vec", + "solana-system-interface", "solana-transaction-error", ] @@ -7575,6 +7581,21 @@ dependencies = [ "solana-sdk", ] +[[package]] +name = "solana-system-interface" +version = "0.0.1" +source = "git+https://github.com/solana-program/system.git#1cab018c8da4dbf7bcbe0a65f1d2f4bef135638b" +dependencies = [ + "js-sys", + "num-traits", + "serde", + "serde_derive", + "solana-decode-error", + "solana-instruction", + "solana-pubkey", + "wasm-bindgen", +] + [[package]] name = "solana-system-program" version = "2.2.0" diff --git a/sdk/program/Cargo.toml b/sdk/program/Cargo.toml index 6e94c9ca856d10..3437ca8da98646 100644 --- a/sdk/program/Cargo.toml +++ b/sdk/program/Cargo.toml @@ -56,7 +56,7 @@ solana-instruction = { workspace = true, default-features = false, features = [ ] } solana-keccak-hasher = { workspace = true, features = ["sha3"] } solana-last-restart-slot = { workspace = true, features = ["serde", "sysvar"] } -solana-message = { workspace = true } +solana-message = { workspace = true, features = ["bincode"] } solana-msg = { workspace = true } solana-native-token = { workspace = true } solana-nonce = { workspace = true, features = ["serde"] } diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 89cb9e05dffcb3..725a814b28cd41 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5770,13 +5770,19 @@ dependencies = [ name = "solana-message" version = "2.2.0" dependencies = [ + "bincode", "blake3", "lazy_static", + "serde", + "serde_derive", + "solana-bincode", "solana-hash", "solana-instruction", "solana-pubkey", "solana-sanitize", "solana-sdk-ids", + "solana-short-vec", + "solana-system-interface", "solana-transaction-error", ] @@ -6927,6 +6933,21 @@ dependencies = [ "solana-sdk", ] +[[package]] +name = "solana-system-interface" +version = "0.0.1" +source = "git+https://github.com/solana-program/system.git#1cab018c8da4dbf7bcbe0a65f1d2f4bef135638b" +dependencies = [ + "js-sys", + "num-traits", + "serde", + "serde_derive", + "solana-decode-error", + "solana-instruction", + "solana-pubkey", + "wasm-bindgen", +] + [[package]] name = "solana-system-program" version = "2.2.0" From 5122ef6dfde924abde6573206e360b41a515df22 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 17:12:36 +0400 Subject: [PATCH 19/30] unused import --- sdk/program/src/instruction.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/program/src/instruction.rs b/sdk/program/src/instruction.rs index 9ae262f69ca2e4..971bbc0e04e5fc 100644 --- a/sdk/program/src/instruction.rs +++ b/sdk/program/src/instruction.rs @@ -1,5 +1,3 @@ -#[cfg(feature = "frozen-abi")] -use solana_frozen_abi_macro::AbiExample; pub use { crate::message::compiled_instruction::CompiledInstruction, solana_instruction::{ From 63e3481e27316780684a928c70c6f0516d790d7b Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 17:36:41 +0400 Subject: [PATCH 20/30] fix frozen-abi support --- sdk/message/Cargo.toml | 7 ++++++- sdk/program/Cargo.toml | 1 + sdk/src/transaction/mod.rs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index dcd13728e2d31e..313a2b9d4df47f 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -47,7 +47,12 @@ bincode = [ "serde", ] dev-context-only-utils = ["bincode"] -frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"] +frozen-abi = [ + "dep:solana-frozen-abi", + "dep:solana-frozen-abi-macro", + "solana-hash/frozen-abi", + "solana-pubkey/frozen-abi", +] serde = [ "dep:serde", "dep:serde_derive", diff --git a/sdk/program/Cargo.toml b/sdk/program/Cargo.toml index 3437ca8da98646..47cda2e1a193b9 100644 --- a/sdk/program/Cargo.toml +++ b/sdk/program/Cargo.toml @@ -153,6 +153,7 @@ frozen-abi = [ "solana-fee-calculator/frozen-abi", "solana-hash/frozen-abi", "solana-instruction/frozen-abi", + "solana-message/frozen-abi", "solana-pubkey/frozen-abi", "solana-rent/frozen-abi", "solana-short-vec/frozen-abi", diff --git a/sdk/src/transaction/mod.rs b/sdk/src/transaction/mod.rs index 6fc088b964a360..d97ecb2bfa8070 100644 --- a/sdk/src/transaction/mod.rs +++ b/sdk/src/transaction/mod.rs @@ -178,7 +178,7 @@ pub enum TransactionVerificationMode { #[cfg_attr( feature = "frozen-abi", derive(AbiExample), - frozen_abi(digest = "GESn6AYYNhpNfzJXdQ6kGjqz4VjpMw3ye9rghqaEqks7") + frozen_abi(digest = "76BDTr3Xm3VP7h4eSiw6pZHKc5yYewDufyia3Yedh6GG") )] #[derive(Debug, PartialEq, Default, Eq, Clone, Serialize, Deserialize)] pub struct Transaction { From be70471019b11e576ac429442ad45fceffadde20 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 17:44:39 +0400 Subject: [PATCH 21/30] missing dep --- Cargo.lock | 1 + sdk/message/Cargo.toml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 483d691973a4a0..e87911228ea34d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7539,6 +7539,7 @@ dependencies = [ "solana-frozen-abi-macro", "solana-hash", "solana-instruction", + "solana-logger", "solana-message", "solana-nonce", "solana-program", diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 313a2b9d4df47f..8e9c891306b0fd 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -20,6 +20,7 @@ solana-frozen-abi = { workspace = true, optional = true } solana-frozen-abi-macro = { workspace = true, optional = true } solana-hash = { workspace = true } solana-instruction = { workspace = true, features = ["std"] } +solana-logger = { workspace = true, optional = true } solana-pubkey = { workspace = true } solana-sanitize = { workspace = true } solana-sdk-ids = { workspace = true } @@ -50,6 +51,7 @@ dev-context-only-utils = ["bincode"] frozen-abi = [ "dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", + "dep:solana-logger", "solana-hash/frozen-abi", "solana-pubkey/frozen-abi", ] From bcc66eb40189ae3702a8b44f87cc6e52bfc8fc75 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 18:28:20 +0400 Subject: [PATCH 22/30] sort deps --- sdk/message/Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 8e9c891306b0fd..4b65cea53166e9 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -30,8 +30,8 @@ solana-transaction-error = { workspace = true } [dev-dependencies] anyhow = { workspace = true } -borsh = { workspace = true } bitflags = { workspace = true } +borsh = { workspace = true } itertools = { workspace = true } serde_json = { workspace = true } solana-message = { path = ".", features = ["dev-context-only-utils"] } @@ -45,7 +45,7 @@ bincode = [ "dep:bincode", "dep:solana-bincode", "dep:solana-system-interface", - "serde", + "serde" ] dev-context-only-utils = ["bincode"] frozen-abi = [ @@ -53,14 +53,14 @@ frozen-abi = [ "dep:solana-frozen-abi-macro", "dep:solana-logger", "solana-hash/frozen-abi", - "solana-pubkey/frozen-abi", + "solana-pubkey/frozen-abi" ] serde = [ "dep:serde", "dep:serde_derive", "dep:solana-short-vec", "solana-hash/serde", - "solana-pubkey/serde", + "solana-pubkey/serde" ] [package.metadata.docs.rs] From 0c5cd7d87be1e0f5b8d055d3ee4f1d910b3b2180 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 19 Nov 2024 18:44:58 +0400 Subject: [PATCH 23/30] update digest --- gossip/src/protocol.rs | 2 +- sdk/message/src/legacy.rs | 4 ++-- sdk/message/src/versions/mod.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gossip/src/protocol.rs b/gossip/src/protocol.rs index 6d5559dd80b02f..5467e758e4f15b 100644 --- a/gossip/src/protocol.rs +++ b/gossip/src/protocol.rs @@ -46,7 +46,7 @@ pub(crate) const PULL_RESPONSE_MIN_SERIALIZED_SIZE: usize = 161; #[cfg_attr( feature = "frozen-abi", derive(AbiExample, AbiEnumVisitor), - frozen_abi(digest = "D8HvpYCkdo6JweUW61WQ9ZQH2AFvzh3G1qthicnvz4E8") + frozen_abi(digest = "ESDND6D3FcRyA6UTUpDVDcS4AkESc5E6UtZWSbT7G8e8") )] #[derive(Serialize, Deserialize, Debug)] #[allow(clippy::large_enum_variant)] diff --git a/sdk/message/src/legacy.rs b/sdk/message/src/legacy.rs index 8a94caa6807ff3..19cdb374aeb0cd 100644 --- a/sdk/message/src/legacy.rs +++ b/sdk/message/src/legacy.rs @@ -149,7 +149,7 @@ fn compile_instructions(ixs: &[Instruction], keys: &[Pubkey]) -> Vec Date: Thu, 21 Nov 2024 12:16:39 +0400 Subject: [PATCH 24/30] update system-interface feature activation --- sdk/message/Cargo.toml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 4b65cea53166e9..6114797996262d 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -25,7 +25,9 @@ solana-pubkey = { workspace = true } solana-sanitize = { workspace = true } solana-sdk-ids = { workspace = true } solana-short-vec = { workspace = true, optional = true } -solana-system-interface = { git = "https://github.com/solana-program/system.git", optional = true } +solana-system-interface = { git = "https://github.com/solana-program/system.git", optional = true, features = [ + "bincode", +] } solana-transaction-error = { workspace = true } [dev-dependencies] @@ -45,7 +47,7 @@ bincode = [ "dep:bincode", "dep:solana-bincode", "dep:solana-system-interface", - "serde" + "serde", ] dev-context-only-utils = ["bincode"] frozen-abi = [ @@ -53,14 +55,14 @@ frozen-abi = [ "dep:solana-frozen-abi-macro", "dep:solana-logger", "solana-hash/frozen-abi", - "solana-pubkey/frozen-abi" + "solana-pubkey/frozen-abi", ] serde = [ "dep:serde", "dep:serde_derive", "dep:solana-short-vec", "solana-hash/serde", - "solana-pubkey/serde" + "solana-pubkey/serde", ] [package.metadata.docs.rs] From a097b01e7d6a17431d74514fbfeede4721539332 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Thu, 21 Nov 2024 12:22:33 +0400 Subject: [PATCH 25/30] update rev --- Cargo.lock | 2 +- programs/sbf/Cargo.lock | 2 +- sdk/message/Cargo.toml | 2 +- svm/examples/Cargo.lock | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e87911228ea34d..266e7a0b0bedd3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8999,7 +8999,7 @@ dependencies = [ [[package]] name = "solana-system-interface" version = "0.0.1" -source = "git+https://github.com/solana-program/system.git#1cab018c8da4dbf7bcbe0a65f1d2f4bef135638b" +source = "git+https://github.com/solana-program/system.git?rev=1d1f1c4#1d1f1c4ebde24302c16f2c09e5f350ab51c1a91e" dependencies = [ "js-sys", "num-traits", diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index e849881eddff58..20e5b67dd3472d 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -7584,7 +7584,7 @@ dependencies = [ [[package]] name = "solana-system-interface" version = "0.0.1" -source = "git+https://github.com/solana-program/system.git#1cab018c8da4dbf7bcbe0a65f1d2f4bef135638b" +source = "git+https://github.com/solana-program/system.git?rev=1d1f1c4#1d1f1c4ebde24302c16f2c09e5f350ab51c1a91e" dependencies = [ "js-sys", "num-traits", diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 6114797996262d..2aebbebc0c8a82 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -25,7 +25,7 @@ solana-pubkey = { workspace = true } solana-sanitize = { workspace = true } solana-sdk-ids = { workspace = true } solana-short-vec = { workspace = true, optional = true } -solana-system-interface = { git = "https://github.com/solana-program/system.git", optional = true, features = [ +solana-system-interface = {git = "https://github.com/solana-program/system.git", rev = "1d1f1c4", optional = true, features = [ "bincode", ] } solana-transaction-error = { workspace = true } diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 725a814b28cd41..a2a44ba11942f0 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -6936,7 +6936,7 @@ dependencies = [ [[package]] name = "solana-system-interface" version = "0.0.1" -source = "git+https://github.com/solana-program/system.git#1cab018c8da4dbf7bcbe0a65f1d2f4bef135638b" +source = "git+https://github.com/solana-program/system.git?rev=1d1f1c4#1d1f1c4ebde24302c16f2c09e5f350ab51c1a91e" dependencies = [ "js-sys", "num-traits", From f36ff63d9d680cb3e22efaa485be5e38f3a4c5e7 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Thu, 21 Nov 2024 16:02:32 +0400 Subject: [PATCH 26/30] fmt --- sdk/message/Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 2aebbebc0c8a82..ea81a956dfa342 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -25,7 +25,7 @@ solana-pubkey = { workspace = true } solana-sanitize = { workspace = true } solana-sdk-ids = { workspace = true } solana-short-vec = { workspace = true, optional = true } -solana-system-interface = {git = "https://github.com/solana-program/system.git", rev = "1d1f1c4", optional = true, features = [ +solana-system-interface = { git = "https://github.com/solana-program/system.git", rev = "1d1f1c4", optional = true, features = [ "bincode", ] } solana-transaction-error = { workspace = true } @@ -47,7 +47,7 @@ bincode = [ "dep:bincode", "dep:solana-bincode", "dep:solana-system-interface", - "serde", + "serde" ] dev-context-only-utils = ["bincode"] frozen-abi = [ @@ -55,14 +55,14 @@ frozen-abi = [ "dep:solana-frozen-abi-macro", "dep:solana-logger", "solana-hash/frozen-abi", - "solana-pubkey/frozen-abi", + "solana-pubkey/frozen-abi" ] serde = [ "dep:serde", "dep:serde_derive", "dep:solana-short-vec", "solana-hash/serde", - "solana-pubkey/serde", + "solana-pubkey/serde" ] [package.metadata.docs.rs] From dcf0688174a42b0bade5186274ed81b7dd7f6c79 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Thu, 21 Nov 2024 23:31:39 +0400 Subject: [PATCH 27/30] use published system-interface crate --- Cargo.lock | 5 +++-- Cargo.toml | 1 + programs/sbf/Cargo.lock | 5 +++-- sdk/message/Cargo.toml | 8 ++++---- svm/examples/Cargo.lock | 5 +++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 266e7a0b0bedd3..1c52a39cde8cea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8998,8 +8998,9 @@ dependencies = [ [[package]] name = "solana-system-interface" -version = "0.0.1" -source = "git+https://github.com/solana-program/system.git?rev=1d1f1c4#1d1f1c4ebde24302c16f2c09e5f350ab51c1a91e" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94d7c18cb1a91c6be5f5a8ac9276a1d7c737e39a21beba9ea710ab4b9c63bc90" dependencies = [ "js-sys", "num-traits", diff --git a/Cargo.toml b/Cargo.toml index 12a14a1f5d1f17..32ef571510dd92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -534,6 +534,7 @@ solana-signature = { path = "sdk/signature", version = "=2.2.0", default-feature solana-signer = { path = "sdk/signer", version = "=2.2.0" } solana-slot-hashes = { path = "sdk/slot-hashes", version = "=2.2.0" } solana-slot-history = { path = "sdk/slot-history", version = "=2.2.0" } +solana-system-interface = "1.0.0" solana-time-utils = { path = "sdk/time-utils", version = "=2.2.0" } solana-timings = { path = "timings", version = "=2.2.0" } solana-unified-scheduler-logic = { path = "unified-scheduler-logic", version = "=2.2.0" } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 20e5b67dd3472d..92066993cfffc2 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -7583,8 +7583,9 @@ dependencies = [ [[package]] name = "solana-system-interface" -version = "0.0.1" -source = "git+https://github.com/solana-program/system.git?rev=1d1f1c4#1d1f1c4ebde24302c16f2c09e5f350ab51c1a91e" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94d7c18cb1a91c6be5f5a8ac9276a1d7c737e39a21beba9ea710ab4b9c63bc90" dependencies = [ "js-sys", "num-traits", diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index ea81a956dfa342..872979663a226d 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -25,7 +25,7 @@ solana-pubkey = { workspace = true } solana-sanitize = { workspace = true } solana-sdk-ids = { workspace = true } solana-short-vec = { workspace = true, optional = true } -solana-system-interface = { git = "https://github.com/solana-program/system.git", rev = "1d1f1c4", optional = true, features = [ +solana-system-interface = { workspace = true, optional = true, features = [ "bincode", ] } solana-transaction-error = { workspace = true } @@ -47,7 +47,7 @@ bincode = [ "dep:bincode", "dep:solana-bincode", "dep:solana-system-interface", - "serde" + "serde", ] dev-context-only-utils = ["bincode"] frozen-abi = [ @@ -55,14 +55,14 @@ frozen-abi = [ "dep:solana-frozen-abi-macro", "dep:solana-logger", "solana-hash/frozen-abi", - "solana-pubkey/frozen-abi" + "solana-pubkey/frozen-abi", ] serde = [ "dep:serde", "dep:serde_derive", "dep:solana-short-vec", "solana-hash/serde", - "solana-pubkey/serde" + "solana-pubkey/serde", ] [package.metadata.docs.rs] diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index a2a44ba11942f0..cc4040f12789b7 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -6935,8 +6935,9 @@ dependencies = [ [[package]] name = "solana-system-interface" -version = "0.0.1" -source = "git+https://github.com/solana-program/system.git?rev=1d1f1c4#1d1f1c4ebde24302c16f2c09e5f350ab51c1a91e" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94d7c18cb1a91c6be5f5a8ac9276a1d7c737e39a21beba9ea710ab4b9c63bc90" dependencies = [ "js-sys", "num-traits", From ace0bf60b5280bc24286fc900834c0ca8e581107 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Fri, 22 Nov 2024 20:41:36 +0400 Subject: [PATCH 28/30] add test for inlined ALL_IDS --- Cargo.lock | 1 + sdk/message/Cargo.toml | 1 + sdk/message/src/legacy.rs | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 1c52a39cde8cea..83dcae8c9c5fc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7549,6 +7549,7 @@ dependencies = [ "solana-sha256-hasher", "solana-short-vec", "solana-system-interface", + "solana-sysvar", "solana-transaction-error", "static_assertions", ] diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 872979663a226d..441e08e31c4459 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -40,6 +40,7 @@ solana-message = { path = ".", features = ["dev-context-only-utils"] } solana-nonce = { workspace = true } solana-program = { path = "../program" } solana-sha256-hasher = { workspace = true } +solana-sysvar = { workspace = true } static_assertions = { workspace = true } [features] diff --git a/sdk/message/src/legacy.rs b/sdk/message/src/legacy.rs index 19cdb374aeb0cd..984ef3851f7337 100644 --- a/sdk/message/src/legacy.rs +++ b/sdk/message/src/legacy.rs @@ -1019,4 +1019,9 @@ mod tests { Hash::from_str("7VWCF4quo2CcWQFNUayZiorxpiR5ix8YzLebrXKf3fMF").unwrap() ) } + + #[test] + fn test_inline_all_ids() { + assert_eq!(solana_sysvar::ALL_IDS.to_vec(), ALL_IDS.to_vec()); + } } From c58c2f3f815bca40cb028563d6ed88c87f27e096 Mon Sep 17 00:00:00 2001 From: Jon C Date: Mon, 25 Nov 2024 23:25:33 +0100 Subject: [PATCH 29/30] Patch extra crates needed to unify build --- sdk/cargo-build-sbf/tests/crates/fail/Cargo.toml | 5 +++++ sdk/cargo-build-sbf/tests/crates/noop/Cargo.toml | 5 +++++ sdk/cargo-build-sbf/tests/crates/package-metadata/Cargo.toml | 5 +++++ .../tests/crates/workspace-metadata/Cargo.toml | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/sdk/cargo-build-sbf/tests/crates/fail/Cargo.toml b/sdk/cargo-build-sbf/tests/crates/fail/Cargo.toml index 671c1c5aac4feb..fd9af12f15747f 100644 --- a/sdk/cargo-build-sbf/tests/crates/fail/Cargo.toml +++ b/sdk/cargo-build-sbf/tests/crates/fail/Cargo.toml @@ -15,4 +15,9 @@ solana-program = { path = "../../../../program", version = "=2.2.0" } [lib] crate-type = ["cdylib"] +[patch.crates-io] +solana-decode-error = { path = "../../../../decode-error" } +solana-instruction = { path = "../../../../instruction" } +solana-pubkey = { path = "../../../../pubkey" } + [workspace] diff --git a/sdk/cargo-build-sbf/tests/crates/noop/Cargo.toml b/sdk/cargo-build-sbf/tests/crates/noop/Cargo.toml index b469dbd2f0fcff..9f1813b6381cfa 100644 --- a/sdk/cargo-build-sbf/tests/crates/noop/Cargo.toml +++ b/sdk/cargo-build-sbf/tests/crates/noop/Cargo.toml @@ -15,4 +15,9 @@ solana-program = { path = "../../../../program", version = "=2.2.0" } [lib] crate-type = ["cdylib"] +[patch.crates-io] +solana-decode-error = { path = "../../../../decode-error" } +solana-instruction = { path = "../../../../instruction" } +solana-pubkey = { path = "../../../../pubkey" } + [workspace] diff --git a/sdk/cargo-build-sbf/tests/crates/package-metadata/Cargo.toml b/sdk/cargo-build-sbf/tests/crates/package-metadata/Cargo.toml index 9bbc58b7f7e5ad..ad7f3fe921e896 100644 --- a/sdk/cargo-build-sbf/tests/crates/package-metadata/Cargo.toml +++ b/sdk/cargo-build-sbf/tests/crates/package-metadata/Cargo.toml @@ -20,4 +20,9 @@ solana-program = { path = "../../../../program", version = "=2.2.0" } [lib] crate-type = ["cdylib"] +[patch.crates-io] +solana-decode-error = { path = "../../../../decode-error" } +solana-instruction = { path = "../../../../instruction" } +solana-pubkey = { path = "../../../../pubkey" } + [workspace] diff --git a/sdk/cargo-build-sbf/tests/crates/workspace-metadata/Cargo.toml b/sdk/cargo-build-sbf/tests/crates/workspace-metadata/Cargo.toml index 83b467a1259bb1..9f6a8c2896431b 100644 --- a/sdk/cargo-build-sbf/tests/crates/workspace-metadata/Cargo.toml +++ b/sdk/cargo-build-sbf/tests/crates/workspace-metadata/Cargo.toml @@ -15,6 +15,11 @@ solana-program = { path = "../../../../program", version = "=2.2.0" } [lib] crate-type = ["cdylib"] +[patch.crates-io] +solana-decode-error = { path = "../../../../decode-error" } +solana-instruction = { path = "../../../../instruction" } +solana-pubkey = { path = "../../../../pubkey" } + [workspace] [workspace.metadata.solana] From daf43fbc88b015b591bb43c45b7ca0ed114c5163 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Tue, 26 Nov 2024 12:31:35 +0400 Subject: [PATCH 30/30] missing wasm-bindgen dep --- Cargo.lock | 1 + programs/sbf/Cargo.lock | 1 + sdk/message/Cargo.toml | 3 +++ svm/examples/Cargo.lock | 1 + 4 files changed, 6 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 83dcae8c9c5fc0..3057297a3676d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7552,6 +7552,7 @@ dependencies = [ "solana-sysvar", "solana-transaction-error", "static_assertions", + "wasm-bindgen", ] [[package]] diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 92066993cfffc2..dd15dcb2f6eb4d 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5964,6 +5964,7 @@ dependencies = [ "solana-short-vec", "solana-system-interface", "solana-transaction-error", + "wasm-bindgen", ] [[package]] diff --git a/sdk/message/Cargo.toml b/sdk/message/Cargo.toml index 441e08e31c4459..70c63d6222b2d2 100644 --- a/sdk/message/Cargo.toml +++ b/sdk/message/Cargo.toml @@ -30,6 +30,9 @@ solana-system-interface = { workspace = true, optional = true, features = [ ] } solana-transaction-error = { workspace = true } +[target.'cfg(target_arch = "wasm32")'.dependencies] +wasm-bindgen = { workspace = true } + [dev-dependencies] anyhow = { workspace = true } bitflags = { workspace = true } diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index cc4040f12789b7..86bfa5572d342e 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5784,6 +5784,7 @@ dependencies = [ "solana-short-vec", "solana-system-interface", "solana-transaction-error", + "wasm-bindgen", ] [[package]]