Skip to content

Commit

Permalink
Update patches
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Oct 24, 2024
1 parent a7e3055 commit 55f3f64
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 60 deletions.
8 changes: 4 additions & 4 deletions third-party/patches/agave.patch
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,17 @@ 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 4872798..ea622b2 100644
index 0c8352f..0b0ff72 100644
--- a/sdk/Cargo.toml
+++ b/sdk/Cargo.toml
@@ -79,5 +79,5 @@ qualifier_attr = { workspace = true, optional = true }
@@ -81,5 +81,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 }
@@ -117,4 +117,6 @@ solana-signature = { workspace = true, features = [
@@ -120,4 +120,6 @@ solana-transaction-error = { workspace = true, features = ["serde"], optional =
thiserror = { workspace = true }

+test-fuzz = { path = "../../../test-fuzz" }
Expand Down Expand Up @@ -314,7 +314,7 @@ index 95f65c3..94a5c8e 100644
pub struct InstructionContext {
nesting_level: usize,
diff --git a/timings/Cargo.toml b/timings/Cargo.toml
index e36975b..84ce3a0 100644
index c52b46a..5458d4c 100644
--- a/timings/Cargo.toml
+++ b/timings/Cargo.toml
@@ -15,4 +15,6 @@ enum-iterator = { workspace = true }
Expand Down
84 changes: 33 additions & 51 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 e555bf6..9da7e4e 100644
index dbd876f..ee28197 100644
--- a/src/memory_region.rs
+++ b/src/memory_region.rs
@@ -34,5 +34,5 @@ use std::{
Expand Down Expand Up @@ -126,16 +126,14 @@ index e555bf6..9da7e4e 100644
+pub struct UnalignedMemoryMapping {
/// Mapped memory regions
regions: Box<[MemoryRegion]>,
@@ -189,12 +270,93 @@ pub struct UnalignedMemoryMapping<'a> {
@@ -189,5 +270,5 @@ pub struct UnalignedMemoryMapping<'a> {
cache: UnsafeCell<MappingCache>,
/// VM configuration
- config: &'a Config,
+ config: Config,
/// Executable sbpf_version
- sbpf_version: &'a SBPFVersion,
+ sbpf_version: SBPFVersion,
/// CoW callback
cow_cb: Option<MemoryCowCallback>,
sbpf_version: SBPFVersion,
@@ -196,5 +277,86 @@ pub struct UnalignedMemoryMapping<'a> {
}

-impl fmt::Debug for UnalignedMemoryMapping<'_> {
Expand Down Expand Up @@ -230,75 +228,63 @@ index e555bf6..9da7e4e 100644
+impl<'a> UnalignedMemoryMapping {
fn construct_eytzinger_order(
&mut self,
@@ -261,6 +423,6 @@ impl<'a> UnalignedMemoryMapping<'a> {
@@ -261,5 +423,5 @@ impl<'a> UnalignedMemoryMapping<'a> {
region_addresses: vec![0; regions.len()].into_boxed_slice(),
cache: UnsafeCell::new(MappingCache::new()),
- config,
- sbpf_version,
+ config: config.clone(),
+ sbpf_version: *sbpf_version,
sbpf_version,
cow_cb,
};
@@ -332,6 +494,6 @@ impl<'a> UnalignedMemoryMapping<'a> {
@@ -332,5 +494,5 @@ impl<'a> UnalignedMemoryMapping<'a> {
None => {
return generate_access_violation(
- self.config,
- self.sbpf_version,
+ &self.config,
+ &self.sbpf_version,
self.sbpf_version,
access_type,
vm_addr,
@@ -347,5 +509,5 @@ impl<'a> UnalignedMemoryMapping<'a> {
}

- generate_access_violation(self.config, self.sbpf_version, access_type, vm_addr, len)
+ generate_access_violation(&self.config, &self.sbpf_version, access_type, vm_addr, len)
+ generate_access_violation(&self.config, self.sbpf_version, access_type, vm_addr, len)
}

@@ -377,6 +539,6 @@ impl<'a> UnalignedMemoryMapping<'a> {
@@ -377,5 +539,5 @@ impl<'a> UnalignedMemoryMapping<'a> {
None => {
return generate_access_violation(
- self.config,
- self.sbpf_version,
+ &self.config,
+ &self.sbpf_version,
self.sbpf_version,
AccessType::Load,
vm_addr,
@@ -420,6 +582,6 @@ impl<'a> UnalignedMemoryMapping<'a> {
@@ -420,5 +582,5 @@ impl<'a> UnalignedMemoryMapping<'a> {

generate_access_violation(
- self.config,
- self.sbpf_version,
+ &self.config,
+ &self.sbpf_version,
self.sbpf_version,
AccessType::Load,
initial_vm_addr,
@@ -457,6 +619,6 @@ impl<'a> UnalignedMemoryMapping<'a> {
@@ -457,5 +619,5 @@ impl<'a> UnalignedMemoryMapping<'a> {
_ => {
return generate_access_violation(
- self.config,
- self.sbpf_version,
+ &self.config,
+ &self.sbpf_version,
self.sbpf_version,
AccessType::Store,
vm_addr,
@@ -499,6 +661,6 @@ impl<'a> UnalignedMemoryMapping<'a> {
@@ -499,5 +661,5 @@ impl<'a> UnalignedMemoryMapping<'a> {

generate_access_violation(
- self.config,
- self.sbpf_version,
+ &self.config,
+ &self.sbpf_version,
self.sbpf_version,
AccessType::Store,
initial_vm_addr,
@@ -526,5 +688,5 @@ impl<'a> UnalignedMemoryMapping<'a> {
}
Err(
- generate_access_violation(self.config, self.sbpf_version, access_type, vm_addr, 0)
+ generate_access_violation(&self.config, &self.sbpf_version, access_type, vm_addr, 0)
+ generate_access_violation(&self.config, self.sbpf_version, access_type, vm_addr, 0)
.unwrap_err(),
)
@@ -549,15 +711,36 @@ impl<'a> UnalignedMemoryMapping<'a> {
@@ -549,15 +711,32 @@ impl<'a> UnalignedMemoryMapping<'a> {
/// Memory mapping that uses the upper half of an address to identify the
/// underlying memory region.
+#[derive(serde::Deserialize, serde::Serialize)]
Expand All @@ -312,11 +298,7 @@ index e555bf6..9da7e4e 100644
+ )]
config: &'a Config,
/// Executable sbpf_version
+ #[serde(
+ serialize_with = "test_fuzz::serialize_ref",
+ deserialize_with = "test_fuzz::deserialize_ref"
+ )]
sbpf_version: &'a SBPFVersion,
sbpf_version: SBPFVersion,
/// CoW callback
+ #[serde(skip)]
cow_cb: Option<MemoryCowCallback>,
Expand All @@ -335,29 +317,29 @@ index e555bf6..9da7e4e 100644
+
impl fmt::Debug for AlignedMemoryMapping<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -728,5 +911,5 @@ impl<'a> AlignedMemoryMapping<'a> {
@@ -728,5 +907,5 @@ impl<'a> AlignedMemoryMapping<'a> {

/// Maps virtual memory to host memory.
-#[derive(Debug)]
+#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub enum MemoryMapping<'a> {
/// Used when address translation is disabled
@@ -736,5 +919,5 @@ pub enum MemoryMapping<'a> {
@@ -736,5 +915,5 @@ pub enum MemoryMapping<'a> {
Aligned(AlignedMemoryMapping<'a>),
/// Memory mapping that allows mapping unaligned memory regions.
- Unaligned(UnalignedMemoryMapping<'a>),
+ Unaligned(UnalignedMemoryMapping),
}

@@ -906,5 +1089,5 @@ fn generate_access_violation(
@@ -906,5 +1085,5 @@ fn generate_access_violation(

/// Fast, small linear cache used to speed up unaligned memory mapping.
-#[derive(Debug)]
+#[derive(Debug, Clone)]
struct MappingCache {
// The cached entries.
diff --git a/src/program.rs b/src/program.rs
index 3c84431..e9e5de0 100644
index e40998a..51881e4 100644
--- a/src/program.rs
+++ b/src/program.rs
@@ -10,5 +10,5 @@ use {
Expand All @@ -367,14 +349,14 @@ index 3c84431..e9e5de0 100644
+#[derive(Debug, PartialEq, PartialOrd, Eq, Clone, Copy, serde::Deserialize, serde::Serialize)]
pub enum SBPFVersion {
/// The legacy format
@@ -301,5 +301,5 @@ impl<C: ContextObject> std::fmt::Debug for BuiltinProgram<C> {
@@ -351,5 +351,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,
@@ -312,7 +312,9 @@ macro_rules! declare_builtin_function {
@@ -362,7 +362,9 @@ macro_rules! declare_builtin_function {
$(#[$attr])*
pub struct $name {}
+ #[test_fuzz::test_fuzz_impl]
Expand All @@ -385,7 +367,7 @@ index 3c84431..e9e5de0 100644
+ pub fn rust $(<$($lifetime),+>)? (
$vm: &mut $ContextObject,
$arg_a: u64,
@@ -323,9 +325,12 @@ macro_rules! declare_builtin_function {
@@ -373,9 +375,12 @@ macro_rules! declare_builtin_function {
$memory_mapping: &mut $MemoryMapping,
) -> $Result {
+ if matches!($memory_mapping, MemoryMapping::Identity) {
Expand All @@ -399,14 +381,14 @@ index 3c84431..e9e5de0 100644
+ pub fn vm $(<$($lifetime),+>)? (
$vm: *mut $crate::vm::EbpfVm<$ContextObject>,
$arg_a: u64,
@@ -337,5 +342,5 @@ macro_rules! declare_builtin_function {
@@ -387,5 +392,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();
@@ -343,5 +348,5 @@ macro_rules! declare_builtin_function {
@@ -393,5 +398,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 +484,7 @@ index a8d398d..98f35a4 100644
) -> Result<u64, Box<dyn std::error::Error>> {
println!(
diff --git a/src/vm.rs b/src/vm.rs
index 7bff55c..c06b82e 100644
index 690be74..d1c7d7c 100644
--- a/src/vm.rs
+++ b/src/vm.rs
@@ -49,5 +49,5 @@ pub fn get_runtime_environment_key() -> i32 {
Expand All @@ -520,17 +502,17 @@ index 7bff55c..c06b82e 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 760078d..7d6566b 100644
index 54c1be0..be96076 100644
--- a/tests/execution.rs
+++ b/tests/execution.rs
@@ -2658,5 +2658,5 @@ declare_builtin_function!(
@@ -2698,5 +2698,5 @@ declare_builtin_function!(
/// For test_nested_vm_syscall()
SyscallNestedVm,
- fn rust(
+ fn rust<'a>(
_context_object: &mut TestContextObject,
depth: u64,
@@ -2665,5 +2665,5 @@ declare_builtin_function!(
@@ -2705,5 +2705,5 @@ declare_builtin_function!(
_arg4: u64,
_arg5: u64,
- _memory_mapping: &mut MemoryMapping,
Expand Down
4 changes: 2 additions & 2 deletions third-party/patches/substrate_client_transaction_pool.patch
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ index 9e92dff..9c849f6 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 2d800e2..a17a7ee 100644
index a48c8ee..e1a3bfe 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 {
@@ -236,4 +236,5 @@ impl From<UnknownTransaction> for TransactionValidity {
/// by our local node (for instance off-chain workers).
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, Hash)]
+#[cfg_attr(feature = "std", derive(serde::Deserialize, serde::Serialize))]
Expand Down
6 changes: 3 additions & 3 deletions third-party/third_party.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"flags": ["EXPENSIVE", "SKIP_NIGHTLY"],
"url": "https://github.com/anza-xyz/agave",
"rev": "2bde0fc99cbe0884516c0bbccc210d06a877d0b6",
"rev": "b1a543823f1dce8ed91d3de6c8f17e51f101620c",
"patch": "agave.patch",
"subdir": ".",
"package": "solana-bpf-loader-program",
Expand All @@ -20,7 +20,7 @@
{
"flags": ["EXPENSIVE", "SKIP_NIGHTLY"],
"url": "https://github.com/paritytech/polkadot-sdk",
"rev": "7240b474b92028a1645de6fdb9e0a8aa28dc86be",
"rev": "0596928e649dbd7b8ea8f94cf301926555943534",
"patch": "substrate_client_transaction_pool.patch",
"subdir": ".",
"package": "sc-transaction-pool",
Expand All @@ -38,7 +38,7 @@
{
"flags": [],
"url": "https://github.com/solana-labs/rbpf",
"rev": "e1a9c32c7f2b33e57098ae74a95574de06640a0c",
"rev": "69a52ec6a341bb7374d387173b5e6dc56218fe0c",
"patch": "solana_rbpf.patch",
"subdir": ".",
"package": "solana_rbpf",
Expand Down

0 comments on commit 55f3f64

Please sign in to comment.