Skip to content

Commit

Permalink
Update patches
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Oct 18, 2024
1 parent f6ac46b commit a7e3055
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 66 deletions.
30 changes: 15 additions & 15 deletions third-party/patches/agave.patch
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ index c96da3e..3abc16c 100644
impl<'a> InvokeContext<'a> {
#[allow(clippy::too_many_arguments)]
diff --git a/program-runtime/src/sysvar_cache.rs b/program-runtime/src/sysvar_cache.rs
index 8b4bc61..d8c791c 100644
index 76496ce..811e4fc 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 {
Expand Down Expand Up @@ -205,64 +205,64 @@ index 5e81062..821afe7 100644
) -> Result<u64, Box<dyn std::error::Error>> {
let log_collector = invoke_context.get_log_collector();
diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml
index 8793f1e..a9dc134 100644
index 4872798..ea622b2 100644
--- a/sdk/Cargo.toml
+++ b/sdk/Cargo.toml
@@ -76,5 +76,5 @@ qualifier_attr = { workspace = true, optional = true }
@@ -79,5 +79,5 @@ qualifier_attr = { workspace = true, optional = true }
rand = { workspace = true, optional = true }
rand0-7 = { package = "rand", version = "0.7", optional = true }
-serde = { workspace = true }
+serde = { workspace = true, features = ["rc"] }
serde_bytes = { workspace = true }
serde_derive = { workspace = true }
@@ -109,4 +109,6 @@ solana-signature = { workspace = true, features = [
@@ -117,4 +117,6 @@ solana-signature = { workspace = true, features = [
thiserror = { workspace = true }

+test-fuzz = { path = "../../../test-fuzz" }
+
[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.1", features = ["wasm-bindgen"] }
diff --git a/sdk/feature-set/Cargo.toml b/sdk/feature-set/Cargo.toml
index d6f2824..cd164aa 100644
index 7352ff3..d7e4da2 100644
--- a/sdk/feature-set/Cargo.toml
+++ b/sdk/feature-set/Cargo.toml
@@ -20,4 +20,6 @@ solana-frozen-abi-macro = { workspace = true, optional = true, features = [
solana-program = { workspace = true }
@@ -24,4 +24,6 @@ solana-pubkey = { workspace = true }
solana-sha256-hasher = { workspace = true }

+serde = { workspace = true }
+
[features]
frozen-abi = [
diff --git a/sdk/feature-set/src/lib.rs b/sdk/feature-set/src/lib.rs
index 6567404..e35c427 100644
index 83d5974..4c29279 100644
--- a/sdk/feature-set/src/lib.rs
+++ b/sdk/feature-set/src/lib.rs
@@ -1123,5 +1123,5 @@ lazy_static! {
@@ -1121,5 +1121,5 @@ lazy_static! {
/// `FeatureSet` holds the set of currently active/inactive runtime features
#[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))]
-#[derive(Debug, Clone, Eq, PartialEq)]
+#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct FeatureSet {
pub active: HashMap<Pubkey, Slot>,
diff --git a/sdk/src/transaction_context.rs b/sdk/src/transaction_context.rs
index 0bb2f0e..72c11c2 100644
index 95f65c3..94a5c8e 100644
--- a/sdk/src/transaction_context.rs
+++ b/sdk/src/transaction_context.rs
@@ -36,5 +36,5 @@ pub type IndexOfAccount = u16;
@@ -33,5 +33,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 {
@@ -54,5 +54,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<RefCell<AccountSharedData>>,
@@ -130,9 +130,31 @@ impl TransactionAccounts {
@@ -127,9 +127,31 @@ impl TransactionAccounts {
}

+fn serialize_account_keys<'a, S>(
Expand Down Expand Up @@ -295,7 +295,7 @@ index 0bb2f0e..72c11c2 100644
+ )]
account_keys: Pin<Box<[Pubkey]>>,
accounts: Rc<TransactionAccounts>,
@@ -185,7 +207,7 @@ impl TransactionContext {
@@ -182,7 +204,7 @@ impl TransactionContext {
}

- Ok(Rc::try_unwrap(self.accounts)
Expand All @@ -306,7 +306,7 @@ index 0bb2f0e..72c11c2 100644
+ Ok((*self.accounts).clone().into_accounts())
}

@@ -450,5 +472,5 @@ pub struct TransactionReturnData {
@@ -447,5 +469,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)]
Expand Down
32 changes: 16 additions & 16 deletions third-party/patches/solana_rbpf.patch
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ index 781ce87..a999428 100644
+
+[workspace]
diff --git a/src/memory_region.rs b/src/memory_region.rs
index e864855..a8a44e6 100644
index e555bf6..9da7e4e 100644
--- a/src/memory_region.rs
+++ b/src/memory_region.rs
@@ -34,5 +34,5 @@ use std::{
Expand Down Expand Up @@ -138,7 +138,7 @@ index e864855..a8a44e6 100644
cow_cb: Option<MemoryCowCallback>,
}

-impl<'a> fmt::Debug for UnalignedMemoryMapping<'a> {
-impl fmt::Debug for UnalignedMemoryMapping<'_> {
+#[derive(serde::Deserialize, serde::Serialize)]
+struct SerializableUnalignedMemoryMapping {
+ regions: Box<[MemoryRegion]>,
Expand Down Expand Up @@ -223,7 +223,7 @@ index e864855..a8a44e6 100644
+impl fmt::Debug for UnalignedMemoryMapping {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("UnalignedMemoryMapping")
@@ -215,5 +377,5 @@ impl<'a> fmt::Debug for UnalignedMemoryMapping<'a> {
@@ -215,5 +377,5 @@ impl fmt::Debug for UnalignedMemoryMapping<'_> {
}

-impl<'a> UnalignedMemoryMapping<'a> {
Expand Down Expand Up @@ -322,7 +322,7 @@ index e864855..a8a44e6 100644
cow_cb: Option<MemoryCowCallback>,
}

+impl<'a> Clone for AlignedMemoryMapping<'a> {
+impl Clone for AlignedMemoryMapping<'_> {
+ fn clone(&self) -> Self {
+ Self {
+ regions: self.regions.clone(),
Expand All @@ -333,7 +333,7 @@ index e864855..a8a44e6 100644
+ }
+}
+
impl<'a> fmt::Debug for AlignedMemoryMapping<'a> {
impl fmt::Debug for AlignedMemoryMapping<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -728,5 +911,5 @@ impl<'a> AlignedMemoryMapping<'a> {

Expand All @@ -357,24 +357,24 @@ index e864855..a8a44e6 100644
struct MappingCache {
// The cached entries.
diff --git a/src/program.rs b/src/program.rs
index cc80ec2..6f052ad 100644
index 3c84431..e9e5de0 100644
--- a/src/program.rs
+++ b/src/program.rs
@@ -10,5 +10,5 @@ use {

/// Defines a set of sbpf_version of an executable
-#[derive(Debug, PartialEq, PartialOrd, Eq, Clone)]
-#[derive(Debug, PartialEq, PartialOrd, Eq, Clone, Copy)]
+#[derive(Debug, PartialEq, PartialOrd, Eq, Clone, Copy, serde::Deserialize, serde::Serialize)]
pub enum SBPFVersion {
/// The legacy format
@@ -287,5 +287,5 @@ impl<C: ContextObject> std::fmt::Debug for BuiltinProgram<C> {
@@ -301,5 +301,5 @@ impl<C: ContextObject> std::fmt::Debug for BuiltinProgram<C> {
#[macro_export]
macro_rules! declare_builtin_function {
- ($(#[$attr:meta])* $name:ident $(<$($generic_ident:tt : $generic_type:tt),+>)?, fn rust(
+ ($(#[$attr:meta])* $name:ident, fn rust $(<$($lifetime:tt),+>)? (
$vm:ident : &mut $ContextObject:ty,
$arg_a:ident : u64,
@@ -298,7 +298,9 @@ macro_rules! declare_builtin_function {
@@ -312,7 +312,9 @@ macro_rules! declare_builtin_function {
$(#[$attr])*
pub struct $name {}
+ #[test_fuzz::test_fuzz_impl]
Expand All @@ -385,7 +385,7 @@ index cc80ec2..6f052ad 100644
+ pub fn rust $(<$($lifetime),+>)? (
$vm: &mut $ContextObject,
$arg_a: u64,
@@ -309,9 +311,12 @@ macro_rules! declare_builtin_function {
@@ -323,9 +325,12 @@ macro_rules! declare_builtin_function {
$memory_mapping: &mut $MemoryMapping,
) -> $Result {
+ if matches!($memory_mapping, MemoryMapping::Identity) {
Expand All @@ -399,14 +399,14 @@ index cc80ec2..6f052ad 100644
+ pub fn vm $(<$($lifetime),+>)? (
$vm: *mut $crate::vm::EbpfVm<$ContextObject>,
$arg_a: u64,
@@ -323,5 +328,5 @@ macro_rules! declare_builtin_function {
@@ -337,5 +342,5 @@ macro_rules! declare_builtin_function {
use $crate::vm::ContextObject;
let vm = unsafe {
- &mut *($vm.cast::<u64>().offset(-($crate::vm::get_runtime_environment_key() as isize)).cast::<$crate::vm::EbpfVm<$ContextObject>>())
+ &mut *(($vm as *mut u64).offset(-($crate::vm::get_runtime_environment_key() as isize)) as *mut $crate::vm::EbpfVm<$ContextObject>)
};
let config = vm.loader.get_config();
@@ -329,5 +334,5 @@ macro_rules! declare_builtin_function {
@@ -343,5 +348,5 @@ macro_rules! declare_builtin_function {
vm.context_object_pointer.consume(vm.previous_instruction_meter - vm.due_insn_count);
}
- let converted_result: $crate::error::ProgramResult = Self::rust $(::<$($generic_ident),+>)?(
Expand Down Expand Up @@ -502,7 +502,7 @@ index a8d398d..98f35a4 100644
) -> Result<u64, Box<dyn std::error::Error>> {
println!(
diff --git a/src/vm.rs b/src/vm.rs
index f4a9a15..01ded61 100644
index 7bff55c..c06b82e 100644
--- a/src/vm.rs
+++ b/src/vm.rs
@@ -49,5 +49,5 @@ pub fn get_runtime_environment_key() -> i32 {
Expand All @@ -520,17 +520,17 @@ index f4a9a15..01ded61 100644
pub struct TestContextObject {
/// Contains the register state at every instruction in order of execution
diff --git a/tests/execution.rs b/tests/execution.rs
index fae306d..07a48ff 100644
index 760078d..7d6566b 100644
--- a/tests/execution.rs
+++ b/tests/execution.rs
@@ -2534,5 +2534,5 @@ declare_builtin_function!(
@@ -2658,5 +2658,5 @@ declare_builtin_function!(
/// For test_nested_vm_syscall()
SyscallNestedVm,
- fn rust(
+ fn rust<'a>(
_context_object: &mut TestContextObject,
depth: u64,
@@ -2541,5 +2541,5 @@ declare_builtin_function!(
@@ -2665,5 +2665,5 @@ declare_builtin_function!(
_arg4: u64,
_arg5: u64,
- _memory_mapping: &mut MemoryMapping,
Expand Down
59 changes: 27 additions & 32 deletions third-party/patches/substrate_client_transaction_pool.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/substrate/client/transaction-pool/Cargo.toml b/substrate/client/transaction-pool/Cargo.toml
index 98994cc..1b029b4 100644
index d346add..d270d0f 100644
--- a/substrate/client/transaction-pool/Cargo.toml
+++ b/substrate/client/transaction-pool/Cargo.toml
@@ -23,6 +23,6 @@ futures-timer = { workspace = true }
@@ -25,6 +25,6 @@ itertools = { workspace = true }
linked-hash-map = { workspace = true }
log = { workspace = true, default-features = true }
-parking_lot = { workspace = true, default-features = true }
Expand All @@ -11,14 +11,15 @@ index 98994cc..1b029b4 100644
+serde = { features = ["derive", "rc"], workspace = true, default-features = true }
thiserror = { workspace = true }
prometheus-endpoint = { workspace = true, default-features = true }
@@ -37,4 +37,5 @@ sp-runtime = { workspace = true, default-features = true }
sp-tracing = { workspace = true, default-features = true }
sp-transaction-pool = { workspace = true, default-features = true }
+test-fuzz = { path = "../../../../../test-fuzz" }
@@ -42,4 +42,6 @@ tokio-stream = { workspace = true }
tokio = { workspace = true, default-features = true, features = ["macros", "time"] }

+test-fuzz = { path = "../../../../../test-fuzz" }
+
[dev-dependencies]
array-bytes = { workspace = true, default-features = true }
diff --git a/substrate/client/transaction-pool/src/graph/base_pool.rs b/substrate/client/transaction-pool/src/graph/base_pool.rs
index 3288562..0ba77bc 100644
index e4c3a6c..dd840aa 100644
--- a/substrate/client/transaction-pool/src/graph/base_pool.rs
+++ b/substrate/client/transaction-pool/src/graph/base_pool.rs
@@ -85,5 +85,5 @@ pub struct PruneStatus<Hash, Ex> {
Expand Down Expand Up @@ -47,23 +48,23 @@ index 3288562..0ba77bc 100644
/// Create new pool given reject_future_transactions flag.
pub fn new(reject_future_transactions: bool) -> Self {
diff --git a/substrate/client/transaction-pool/src/graph/future.rs b/substrate/client/transaction-pool/src/graph/future.rs
index bad4663..b10e15c 100644
index 2c1e64c..ca41c4f 100644
--- a/substrate/client/transaction-pool/src/graph/future.rs
+++ b/substrate/client/transaction-pool/src/graph/future.rs
@@ -29,4 +29,5 @@ use std::time::Instant;
use super::base_pool::Transaction;
@@ -30,4 +30,5 @@ use super::base_pool::Transaction;
use crate::{common::log_xt::log_xt_trace, LOG_TARGET};

+#[derive(serde::Deserialize, serde::Serialize)]
/// Transaction with partially satisfied dependencies.
pub struct WaitingTransaction<Hash, Ex> {
@@ -36,4 +37,5 @@ pub struct WaitingTransaction<Hash, Ex> {
@@ -37,4 +38,5 @@ pub struct WaitingTransaction<Hash, Ex> {
pub missing_tags: HashSet<Tag>,
/// Time of import to the Future Queue.
+ #[serde(skip, default = "Instant::now")]
pub imported_at: Instant,
}
diff --git a/substrate/client/transaction-pool/src/graph/ready.rs b/substrate/client/transaction-pool/src/graph/ready.rs
index b4a5d9e..f43a43d 100644
index 860bcff..85a3b95 100644
--- a/substrate/client/transaction-pool/src/graph/ready.rs
+++ b/substrate/client/transaction-pool/src/graph/ready.rs
@@ -39,5 +39,5 @@ use super::{
Expand All @@ -83,7 +84,7 @@ index b4a5d9e..f43a43d 100644
@@ -107,5 +107,5 @@ qed

/// Validated transactions that are block ready with all their dependencies met.
-#[derive(Debug)]
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct ReadyTransactions<Hash: hash::Hash + Eq, Ex> {
/// Next free insertion id (used to indicate when a transaction was inserted into the pool).
Expand Down Expand Up @@ -139,7 +140,7 @@ index b4a5d9e..f43a43d 100644
ready: &mut ReadyTransactions<H, Ex>,
tx: Transaction<H, Ex>,
diff --git a/substrate/client/transaction-pool/src/graph/tracked_map.rs b/substrate/client/transaction-pool/src/graph/tracked_map.rs
index 44c2c73..b616365 100644
index 9e92dff..9c849f6 100644
--- a/substrate/client/transaction-pool/src/graph/tracked_map.rs
+++ b/substrate/client/transaction-pool/src/graph/tracked_map.rs
@@ -34,6 +34,9 @@ pub trait Size {
Expand All @@ -154,30 +155,24 @@ index 44c2c73..b616365 100644
+{
index: Arc<RwLock<HashMap<K, V>>>,
bytes: AtomicIsize,
@@ -41,5 +44,21 @@ pub struct TrackedMap<K, V> {
@@ -41,5 +44,8 @@ pub struct TrackedMap<K, V> {
}

-impl<K, V> Default for TrackedMap<K, V> {
+impl<K: Clone, V: Clone> Clone for TrackedMap<K, V>
+where
+ K: Eq + std::hash::Hash,
+{
+ fn clone(&self) -> Self {
+ Self {
+ index: Arc::new(self.clone_map().into()),
+ bytes: self.bytes.load(AtomicOrdering::Relaxed).into(),
+ length: self.length.load(AtomicOrdering::Relaxed).into(),
+ }
+ }
+}
+
+impl<K, V> Default for TrackedMap<K, V>
+where
+ K: Eq + std::hash::Hash,
+{
fn default() -> Self {
Self { index: Arc::new(HashMap::default().into()), bytes: 0.into(), length: 0.into() }
@@ -47,5 +66,8 @@ impl<K, V> Default for TrackedMap<K, V> {
@@ -49,5 +55,5 @@ impl<K, V> Default for TrackedMap<K, V> {
impl<K, V> Clone for TrackedMap<K, V>
where
- K: Clone,
+ K: Clone + Eq + std::hash::Hash,
V: Clone,
{
@@ -61,5 +67,8 @@ where
}

-impl<K, V> TrackedMap<K, V> {
Expand All @@ -187,7 +182,7 @@ index 44c2c73..b616365 100644
+{
/// Current tracked length of the content.
pub fn len(&self) -> usize {
@@ -73,5 +95,8 @@ impl<K, V> TrackedMap<K, V> {
@@ -87,5 +96,8 @@ impl<K, V> TrackedMap<K, V> {
}

-impl<K: Clone, V: Clone> TrackedMap<K, V> {
Expand All @@ -198,12 +193,12 @@ index 44c2c73..b616365 100644
/// Clone the inner map.
pub fn clone_map(&self) -> HashMap<K, V> {
diff --git a/substrate/primitives/runtime/src/transaction_validity.rs b/substrate/primitives/runtime/src/transaction_validity.rs
index ffff94e..ea15881 100644
index 2d800e2..a17a7ee 100644
--- a/substrate/primitives/runtime/src/transaction_validity.rs
+++ b/substrate/primitives/runtime/src/transaction_validity.rs
@@ -228,4 +228,5 @@ impl From<UnknownTransaction> for TransactionValidity {
/// by our local node (for instance off-chain workers).
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, Hash)]
+#[cfg_attr(feature = "std", derive(serde::Deserialize, serde::Serialize))]
pub enum TransactionSource {
/// Transaction is already included in block.
Loading

0 comments on commit a7e3055

Please sign in to comment.