From 250a089d24b898ed3bd0a52b5319bb26e5eac52b Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Fri, 6 Dec 2024 14:03:28 +0000 Subject: [PATCH] Remove Solana third-party test --- third-party/patches/solana.patch | 263 ------------------------------- third-party/third_party.json | 9 -- 2 files changed, 272 deletions(-) delete mode 100644 third-party/patches/solana.patch diff --git a/third-party/patches/solana.patch b/third-party/patches/solana.patch deleted file mode 100644 index bd2cadcf..00000000 --- a/third-party/patches/solana.patch +++ /dev/null @@ -1,263 +0,0 @@ -diff --git a/program-runtime/Cargo.toml b/program-runtime/Cargo.toml -index afec735..6896c4d 100644 ---- a/program-runtime/Cargo.toml -+++ b/program-runtime/Cargo.toml -@@ -31,4 +31,6 @@ solana_rbpf = { workspace = true } - thiserror = { workspace = true } - -+test-fuzz = { path = "../../../test-fuzz" } -+ - [dev-dependencies] - assert_matches = { workspace = true } -diff --git a/program-runtime/src/compute_budget.rs b/program-runtime/src/compute_budget.rs -index 0657df5..f1bd04f 100644 ---- a/program-runtime/src/compute_budget.rs -+++ b/program-runtime/src/compute_budget.rs -@@ -16,5 +16,5 @@ impl ::solana_frozen_abi::abi_example::AbiExample for ComputeBudget { - pub const DEFAULT_HEAP_COST: u64 = 8; - --#[derive(Clone, Copy, Debug, PartialEq, Eq)] -+#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize)] - pub struct ComputeBudget { - /// Number of compute units that a transaction or individual instruction is -diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs -index 5b2d417..97c388f 100644 ---- a/program-runtime/src/invoke_context.rs -+++ b/program-runtime/src/invoke_context.rs -@@ -111,4 +111,5 @@ impl fmt::Display for AllocErr { - } - -+#[derive(Clone, serde::Deserialize, serde::Serialize)] - pub struct BpfAllocator { - len: u64, -@@ -139,4 +140,5 @@ impl BpfAllocator { - } - -+#[derive(Clone, serde::Deserialize, serde::Serialize)] - pub struct SyscallContext { - pub allocator: BpfAllocator, -@@ -145,5 +147,11 @@ pub struct SyscallContext { - } - --#[derive(Debug, Clone)] -+impl std::fmt::Debug for SyscallContext { -+ fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { -+ Ok(()) -+ } -+} -+ -+#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] - pub struct SerializedAccountMetadata { - pub original_data_len: usize, -@@ -154,6 +162,16 @@ pub struct SerializedAccountMetadata { - } - -+fn default_loaded_programs<'de, D>(_: D) -> Result<&'static mut LoadedProgramsForTxBatch, D::Error> -+where -+ D: serde::Deserializer<'de>, -+{ -+ Ok(Box::leak(Box::new(LoadedProgramsForTxBatch::default()))) -+} -+ -+#[derive(Debug, serde::Deserialize, serde::Serialize)] - pub struct InvokeContext<'a> { -+ #[serde(with = "test_fuzz::serde_ref_mut")] - pub transaction_context: &'a mut TransactionContext, -+ #[serde(with = "test_fuzz::serde_ref")] - sysvar_cache: &'a SysvarCache, - log_collector: Option>>, -@@ -161,5 +179,7 @@ pub struct InvokeContext<'a> { - current_compute_budget: ComputeBudget, - compute_meter: RefCell, -+ #[serde(skip_serializing, deserialize_with = "default_loaded_programs")] - pub programs_loaded_for_tx_batch: &'a LoadedProgramsForTxBatch, -+ #[serde(skip_serializing, deserialize_with = "default_loaded_programs")] - pub programs_modified_by_tx: &'a mut LoadedProgramsForTxBatch, - pub feature_set: Arc, -@@ -171,4 +191,23 @@ pub struct InvokeContext<'a> { - } - -+impl<'a> Clone for InvokeContext<'a> { -+ fn clone(&self) -> Self { -+ Self { -+ transaction_context: Box::leak(Box::new(self.transaction_context.clone())), -+ log_collector: self.log_collector.clone(), -+ compute_meter: self.compute_meter.clone(), -+ programs_loaded_for_tx_batch: Box::leak(Box::new( -+ self.programs_loaded_for_tx_batch.clone(), -+ )), -+ programs_modified_by_tx: Box::leak(Box::new(self.programs_modified_by_tx.clone())), -+ feature_set: self.feature_set.clone(), -+ timings: self.timings.clone(), -+ syscall_context: self.syscall_context.clone(), -+ traces: self.traces.clone(), -+ ..*self -+ } -+ } -+} -+ - impl<'a> InvokeContext<'a> { - #[allow(clippy::too_many_arguments)] -diff --git a/program-runtime/src/log_collector.rs b/program-runtime/src/log_collector.rs -index 8c801b8..93bb50b 100644 ---- a/program-runtime/src/log_collector.rs -+++ b/program-runtime/src/log_collector.rs -@@ -4,4 +4,5 @@ use std::{cell::RefCell, rc::Rc}; - const LOG_MESSAGES_BYTES_LIMIT: usize = 10 * 1000; - -+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] - pub struct LogCollector { - messages: Vec, -diff --git a/program-runtime/src/sysvar_cache.rs b/program-runtime/src/sysvar_cache.rs -index c403f1c..45b9844 100644 ---- a/program-runtime/src/sysvar_cache.rs -+++ b/program-runtime/src/sysvar_cache.rs -@@ -25,5 +25,5 @@ impl ::solana_frozen_abi::abi_example::AbiExample for SysvarCache { - } - --#[derive(Default, Clone, Debug)] -+#[derive(Default, Clone, Debug, serde::Deserialize, serde::Serialize)] - pub struct SysvarCache { - clock: Option>, -diff --git a/program-runtime/src/timings.rs b/program-runtime/src/timings.rs -index 8eeb9c5..d95800a 100644 ---- a/program-runtime/src/timings.rs -+++ b/program-runtime/src/timings.rs -@@ -9,5 +9,5 @@ use { - }; - --#[derive(Default, Debug, PartialEq, Eq)] -+#[derive(Default, Debug, PartialEq, Eq, Clone, serde::Deserialize, serde::Serialize)] - pub struct ProgramTiming { - pub accumulated_us: u64, -@@ -381,5 +381,5 @@ impl ExecuteAccessoryTimings { - } - --#[derive(Default, Debug, PartialEq, Eq)] -+#[derive(Default, Debug, PartialEq, Eq, Clone, serde::Deserialize, serde::Serialize)] - pub struct ExecuteDetailsTimings { - pub serialize_us: u64, -diff --git a/programs/bpf_loader/Cargo.toml b/programs/bpf_loader/Cargo.toml -index 48d771b..e89765b 100644 ---- a/programs/bpf_loader/Cargo.toml -+++ b/programs/bpf_loader/Cargo.toml -@@ -23,4 +23,7 @@ solana_rbpf = { workspace = true } - thiserror = { workspace = true } - -+serde = { workspace = true } -+test-fuzz = { path = "../../../../test-fuzz" } -+ - [dev-dependencies] - assert_matches = { workspace = true } -diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs -index 2cae8b5..a607290 100644 ---- a/programs/bpf_loader/src/lib.rs -+++ b/programs/bpf_loader/src/lib.rs -@@ -366,6 +366,7 @@ declare_builtin_function!( - ); - --pub fn process_instruction_inner( -- invoke_context: &mut InvokeContext, -+#[test_fuzz::test_fuzz] -+pub fn process_instruction_inner<'a>( -+ invoke_context: &mut InvokeContext<'a>, - ) -> Result> { - let log_collector = invoke_context.get_log_collector(); -diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml -index 57bf073..c3be7db 100644 ---- a/sdk/Cargo.toml -+++ b/sdk/Cargo.toml -@@ -69,5 +69,5 @@ rand = { workspace = true, optional = true } - rand0-7 = { package = "rand", version = "0.7", optional = true } - rustversion = { workspace = true } --serde = { workspace = true } -+serde = { workspace = true, features = ["rc"] } - serde_bytes = { workspace = true } - serde_derive = { workspace = true } -@@ -86,4 +86,6 @@ uriparse = { workspace = true } - wasm-bindgen = { workspace = true } - -+test-fuzz = { path = "../../../test-fuzz" } -+ - [target.'cfg(target_arch = "wasm32")'.dependencies] - js-sys = { workspace = true } -diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs -index 55ce4c1..c952cd1 100644 ---- a/sdk/src/feature_set.rs -+++ b/sdk/src/feature_set.rs -@@ -1009,5 +1009,5 @@ lazy_static! { - - /// `FeatureSet` holds the set of currently active/inactive runtime features --#[derive(AbiExample, Debug, Clone, Eq, PartialEq)] -+#[derive(AbiExample, Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] - pub struct FeatureSet { - pub active: HashMap, -diff --git a/sdk/src/transaction_context.rs b/sdk/src/transaction_context.rs -index 7df7fc9..d5ff356 100644 ---- a/sdk/src/transaction_context.rs -+++ b/sdk/src/transaction_context.rs -@@ -36,5 +36,5 @@ pub type IndexOfAccount = u16; - /// - /// It also contains indices to other structures for faster lookup. --#[derive(Clone, Debug, Eq, PartialEq)] -+#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)] - pub struct InstructionAccount { - /// Points to the account and its key in the `TransactionContext` -@@ -57,5 +57,5 @@ pub struct InstructionAccount { - pub type TransactionAccount = (Pubkey, AccountSharedData); - --#[derive(Clone, Debug, PartialEq)] -+#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] - pub struct TransactionAccounts { - accounts: Vec>, -@@ -130,9 +130,31 @@ impl TransactionAccounts { - } - -+fn serialize_account_keys<'a, S>( -+ account_keys: &Pin>, -+ serializer: S, -+) -> Result -+where -+ S: serde::Serializer, -+{ -+ <[Pubkey] as serde::Serialize>::serialize(&**account_keys, serializer) -+} -+ -+fn deserialize_account_keys<'de, D>(deserializer: D) -> Result>, D::Error> -+where -+ D: serde::Deserializer<'de>, -+{ -+ let account_keys = as serde::de::Deserialize>::deserialize(deserializer)?; -+ Ok(Pin::new(account_keys.into_boxed_slice())) -+} -+ - /// Loaded transaction shared between runtime and programs. - /// - /// This context is valid for the entire duration of a transaction being processed. --#[derive(Debug, Clone, PartialEq)] -+#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] - pub struct TransactionContext { -+ #[serde( -+ serialize_with = "serialize_account_keys", -+ deserialize_with = "deserialize_account_keys" -+ )] - account_keys: Pin>, - accounts: Rc, -@@ -185,7 +207,7 @@ impl TransactionContext { - } - -- Ok(Rc::try_unwrap(self.accounts) -- .expect("transaction_context.accounts has unexpected outstanding refs") -- .into_accounts()) -+ // smoelius: Our implementation of `Clone` for `InvokeContext` leaks a copy of a -+ // `TransactionContext`, which is why a call to `Rc::try_unwrap(self.accounts)` would fail. -+ Ok((*self.accounts).clone().into_accounts()) - } - -@@ -450,5 +472,5 @@ pub struct TransactionReturnData { - /// - /// This context is valid for the entire duration of a (possibly cross program) instruction being processed. --#[derive(Debug, Clone, Default, Eq, PartialEq)] -+#[derive(Debug, Clone, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize)] - pub struct InstructionContext { - nesting_level: usize, diff --git a/third-party/third_party.json b/third-party/third_party.json index f218bc01..a206d737 100644 --- a/third-party/third_party.json +++ b/third-party/third_party.json @@ -43,14 +43,5 @@ "subdir": ".", "package": "solana_rbpf", "targets": ["syscall_str_cmp_rust"] - }, - { - "flags": ["EXPENSIVE", "SKIP_NIGHTLY"], - "url": "https://github.com/solana-labs/solana", - "rev": "27eff8408b7223bb3c4ab70523f8a8dca3ca6645", - "patch": "solana.patch", - "subdir": ".", - "package": "solana-bpf-loader-program", - "targets": ["process_instruction"] } ]