Skip to content

Commit

Permalink
Update patches
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Nov 21, 2024
1 parent 4732f4f commit 36396ff
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 49 deletions.
103 changes: 64 additions & 39 deletions third-party/patches/agave.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/compute-budget/Cargo.toml b/compute-budget/Cargo.toml
index 961ec9f..ee85710 100644
index 961ec9fc3..ee857103c 100644
--- a/compute-budget/Cargo.toml
+++ b/compute-budget/Cargo.toml
@@ -17,4 +17,6 @@ solana-frozen-abi = { workspace = true, optional = true, features = [
Expand All @@ -10,7 +10,7 @@ index 961ec9f..ee85710 100644
[features]
frozen-abi = ["dep:solana-frozen-abi", "solana-fee-structure/frozen-abi"]
diff --git a/compute-budget/src/compute_budget.rs b/compute-budget/src/compute_budget.rs
index 9d1a351..22691a6 100644
index 9d1a351dd..22691a660 100644
--- a/compute-budget/src/compute_budget.rs
+++ b/compute-budget/src/compute_budget.rs
@@ -19,5 +19,5 @@ pub const MAX_CALL_DEPTH: usize = 64;
Expand All @@ -21,7 +21,7 @@ index 9d1a351..22691a6 100644
pub struct ComputeBudget {
/// Number of compute units that a transaction or individual instruction is
diff --git a/log-collector/Cargo.toml b/log-collector/Cargo.toml
index e22c14c..4d5f335 100644
index e22c14c09..4d5f335c2 100644
--- a/log-collector/Cargo.toml
+++ b/log-collector/Cargo.toml
@@ -13,4 +13,6 @@ edition = { workspace = true }
Expand All @@ -32,7 +32,7 @@ index e22c14c..4d5f335 100644
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
diff --git a/log-collector/src/lib.rs b/log-collector/src/lib.rs
index 612300f..fbc8225 100644
index 612300f8e..fbc822552 100644
--- a/log-collector/src/lib.rs
+++ b/log-collector/src/lib.rs
@@ -4,4 +4,5 @@ use std::{cell::RefCell, rc::Rc};
Expand All @@ -42,7 +42,7 @@ index 612300f..fbc8225 100644
pub struct LogCollector {
pub messages: Vec<String>,
diff --git a/measure/src/measure.rs b/measure/src/measure.rs
index 190abb3..c157072 100644
index 190abb30c..c157072a3 100644
--- a/measure/src/measure.rs
+++ b/measure/src/measure.rs
@@ -4,5 +4,5 @@ use std::{
Expand All @@ -53,47 +53,72 @@ index 190abb3..c157072 100644
pub struct Measure {
name: &'static str,
diff --git a/program-runtime/Cargo.toml b/program-runtime/Cargo.toml
index 4e764de..93cfd6c 100644
index b3a6228ce..b8bae66bb 100644
--- a/program-runtime/Cargo.toml
+++ b/program-runtime/Cargo.toml
@@ -40,4 +40,6 @@ solana_rbpf = { workspace = true }
@@ -39,4 +39,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/invoke_context.rs b/program-runtime/src/invoke_context.rs
index a54e083..05b63f8 100644
index f6e0e4630..54d261399 100644
--- a/program-runtime/src/invoke_context.rs
+++ b/program-runtime/src/invoke_context.rs
@@ -121,4 +121,5 @@ impl fmt::Display for AllocErr {
@@ -120,4 +120,5 @@ impl fmt::Display for AllocErr {
}

+#[derive(Clone, serde::Deserialize, serde::Serialize)]
pub struct BpfAllocator {
len: u64,
@@ -149,10 +150,13 @@ impl BpfAllocator {
@@ -148,12 +149,38 @@ impl BpfAllocator {
}

+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
+fn default_get_epoch_vote_account_stake_callback<'de, D>(
+ _: D,
+) -> Result<&'static dyn Fn(&Pubkey) -> u64, D::Error>
+where
+ D: serde::Deserializer<'de>,
+{
+ Ok(&get_epoch_vote_account_stake_callback)
+}
+
+fn get_epoch_vote_account_stake_callback(_: &Pubkey) -> u64 {
+ 0
+}
+
+#[derive(Clone, serde::Deserialize, serde::Serialize)]
pub struct EnvironmentConfig<'a> {
pub blockhash: Hash,
pub blockhash_lamports_per_signature: u64,
epoch_total_stake: Option<u64>,
+ #[serde(skip)]
epoch_vote_accounts: Option<&'a VoteAccountsHashMap>,
epoch_total_stake: u64,
+ #[serde(
+ skip_serializing,
+ deserialize_with = "default_get_epoch_vote_account_stake_callback"
+ )]
get_epoch_vote_account_stake_callback: &'a dyn Fn(&'a Pubkey) -> u64,
pub feature_set: Arc<FeatureSet>,
+ #[serde(with = "test_fuzz::serde_ref")]
sysvar_cache: &'a SysvarCache,
}
@@ -177,4 +181,5 @@ impl<'a> EnvironmentConfig<'a> {
+
+impl<'a> std::fmt::Debug for EnvironmentConfig<'a> {
+ fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
+ Ok(())
+ }
+}
+
impl<'a> EnvironmentConfig<'a> {
pub fn new(
@@ -176,4 +203,5 @@ impl<'a> EnvironmentConfig<'a> {
}

+#[derive(Clone, serde::Deserialize, serde::Serialize)]
pub struct SyscallContext {
pub allocator: BpfAllocator,
@@ -183,5 +188,11 @@ pub struct SyscallContext {
@@ -182,5 +210,11 @@ pub struct SyscallContext {
}

-#[derive(Debug, Clone)]
Expand All @@ -106,7 +131,7 @@ index a54e083..05b63f8 100644
+#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub struct SerializedAccountMetadata {
pub original_data_len: usize,
@@ -192,9 +203,24 @@ pub struct SerializedAccountMetadata {
@@ -191,9 +225,24 @@ pub struct SerializedAccountMetadata {
}

+fn default_program_cache_for_tx_batch<'de, D>(
Expand All @@ -131,13 +156,13 @@ index a54e083..05b63f8 100644
+ )]
pub program_cache_for_tx_batch: &'a mut ProgramCacheForTxBatch,
/// Runtime configurations used to provision the invocation environment.
@@ -207,4 +233,5 @@ pub struct InvokeContext<'a> {
@@ -206,4 +255,5 @@ pub struct InvokeContext<'a> {
log_collector: Option<Rc<RefCell<LogCollector>>>,
/// Latest measurement not yet accumulated in [ExecuteDetailsTimings::execute_us]
+ #[serde(skip)]
pub execute_time: Option<Measure>,
pub timings: ExecuteDetailsTimings,
@@ -213,4 +240,23 @@ pub struct InvokeContext<'a> {
@@ -212,4 +262,23 @@ pub struct InvokeContext<'a> {
}

+impl<'a> Clone for InvokeContext<'a> {
Expand All @@ -162,7 +187,7 @@ index a54e083..05b63f8 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 76496ce..811e4fc 100644
index 76496ce9e..811e4fc3e 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 All @@ -173,7 +198,7 @@ index 76496ce..811e4fc 100644
pub struct SysvarCache {
// full account data as provided by bank, including any trailing zero bytes
diff --git a/programs/bpf_loader/Cargo.toml b/programs/bpf_loader/Cargo.toml
index 8fb86df..4b48f84 100644
index 3c62ccc69..34b67a657 100644
--- a/programs/bpf_loader/Cargo.toml
+++ b/programs/bpf_loader/Cargo.toml
@@ -31,4 +31,7 @@ solana_rbpf = { workspace = true }
Expand All @@ -185,7 +210,7 @@ index 8fb86df..4b48f84 100644
[dev-dependencies]
assert_matches = { workspace = true }
diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs
index 9f62c4f..ffbf6b8 100644
index 9f62c4f03..ffbf6b89a 100644
--- a/programs/bpf_loader/src/lib.rs
+++ b/programs/bpf_loader/src/lib.rs
@@ -398,6 +398,7 @@ declare_builtin_function!(
Expand All @@ -199,25 +224,25 @@ index 9f62c4f..ffbf6b8 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 fb69474..7c400c6 100644
index 485a8d37e..a15c3ff93 100644
--- a/sdk/Cargo.toml
+++ b/sdk/Cargo.toml
@@ -90,5 +90,5 @@ qualifier_attr = { workspace = true, optional = true }
@@ -94,5 +94,5 @@ qualifier_attr = { workspace = true, optional = true }
rand = { workspace = true, optional = true }
rand0-7 = { workspace = true, optional = true }
-serde = { workspace = true }
+serde = { workspace = true, features = ["rc"] }
serde_bytes = { workspace = true }
serde_derive = { workspace = true }
@@ -148,4 +148,6 @@ solana-transaction-error = { workspace = true, features = ["serde"], optional =
@@ -158,4 +158,6 @@ solana-transaction-error = { workspace = true, features = ["serde"], optional =
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 19b9075..ab7ed50 100644
index 19b907556..ab7ed500c 100644
--- a/sdk/feature-set/Cargo.toml
+++ b/sdk/feature-set/Cargo.toml
@@ -23,4 +23,6 @@ solana-pubkey = { workspace = true }
Expand All @@ -228,35 +253,35 @@ index 19b9075..ab7ed50 100644
[features]
frozen-abi = [
diff --git a/sdk/feature-set/src/lib.rs b/sdk/feature-set/src/lib.rs
index a66da8b..81bc72b 100644
index c465fd126..ab914b2bd 100644
--- a/sdk/feature-set/src/lib.rs
+++ b/sdk/feature-set/src/lib.rs
@@ -1140,5 +1140,5 @@ lazy_static! {
@@ -1149,5 +1149,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, u64>,
diff --git a/sdk/src/transaction_context.rs b/sdk/src/transaction_context.rs
index 6cb9513..3363645 100644
--- a/sdk/src/transaction_context.rs
+++ b/sdk/src/transaction_context.rs
@@ -33,5 +33,5 @@ pub type IndexOfAccount = u16;
diff --git a/sdk/transaction-context/src/lib.rs b/sdk/transaction-context/src/lib.rs
index 33bd6bc98..1fc2e934c 100644
--- a/sdk/transaction-context/src/lib.rs
+++ b/sdk/transaction-context/src/lib.rs
@@ -57,5 +57,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`
@@ -54,5 +54,5 @@ pub struct InstructionAccount {
@@ -78,5 +78,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>>,
@@ -127,9 +127,31 @@ impl TransactionAccounts {
@@ -151,9 +151,31 @@ impl TransactionAccounts {
}

+fn serialize_account_keys<'a, S>(
Expand Down Expand Up @@ -289,7 +314,7 @@ index 6cb9513..3363645 100644
+ )]
account_keys: Pin<Box<[Pubkey]>>,
accounts: Rc<TransactionAccounts>,
@@ -190,7 +212,7 @@ impl TransactionContext {
@@ -222,7 +244,7 @@ impl TransactionContext {
}

- Ok(Rc::try_unwrap(self.accounts)
Expand All @@ -300,15 +325,15 @@ index 6cb9513..3363645 100644
+ Ok((*self.accounts).clone().into_accounts())
}

@@ -455,5 +477,5 @@ pub struct TransactionReturnData {
@@ -499,5 +521,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/timings/Cargo.toml b/timings/Cargo.toml
index c52b46a..5458d4c 100644
index c52b46ad9..5458d4cc2 100644
--- a/timings/Cargo.toml
+++ b/timings/Cargo.toml
@@ -15,4 +15,6 @@ enum-iterator = { workspace = true }
Expand All @@ -319,7 +344,7 @@ index c52b46a..5458d4c 100644
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
diff --git a/timings/src/lib.rs b/timings/src/lib.rs
index 2cd7a49..388a027 100644
index 2cd7a4980..388a027fc 100644
--- a/timings/src/lib.rs
+++ b/timings/src/lib.rs
@@ -11,5 +11,5 @@ use {
Expand Down
14 changes: 7 additions & 7 deletions third-party/patches/solana_rbpf.patch
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ index e0ebfe6..64f1fa0 100644
struct MappingCache {
// The cached entries.
diff --git a/src/program.rs b/src/program.rs
index 183b058..116bb53 100644
index 35f7ed4..ed362d2 100644
--- a/src/program.rs
+++ b/src/program.rs
@@ -10,5 +10,5 @@ use {
Expand All @@ -346,14 +346,14 @@ index 183b058..116bb53 100644
+#[derive(Debug, PartialEq, PartialOrd, Eq, Clone, Copy, serde::Deserialize, serde::Serialize)]
pub enum SBPFVersion {
/// The legacy format
@@ -361,5 +361,5 @@ impl<C: ContextObject> std::fmt::Debug for BuiltinProgram<C> {
@@ -366,5 +366,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,
@@ -372,7 +372,9 @@ macro_rules! declare_builtin_function {
@@ -377,7 +377,9 @@ macro_rules! declare_builtin_function {
$(#[$attr])*
pub struct $name {}
+ #[test_fuzz::test_fuzz_impl]
Expand All @@ -364,7 +364,7 @@ index 183b058..116bb53 100644
+ pub fn rust $(<$($lifetime),+>)? (
$vm: &mut $ContextObject,
$arg_a: u64,
@@ -383,9 +385,12 @@ macro_rules! declare_builtin_function {
@@ -388,9 +390,12 @@ macro_rules! declare_builtin_function {
$memory_mapping: &mut $MemoryMapping,
) -> $Result {
+ if matches!($memory_mapping, MemoryMapping::Identity) {
Expand All @@ -378,14 +378,14 @@ index 183b058..116bb53 100644
+ pub fn vm $(<$($lifetime),+>)? (
$vm: *mut $crate::vm::EbpfVm<$ContextObject>,
$arg_a: u64,
@@ -397,5 +402,5 @@ macro_rules! declare_builtin_function {
@@ -402,5 +407,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();
@@ -403,5 +408,5 @@ macro_rules! declare_builtin_function {
@@ -408,5 +413,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 @@ -499,7 +499,7 @@ index 690be74..d1c7d7c 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 67314ff..7d1da71 100644
index 4c6b857..19a86b3 100644
--- a/tests/execution.rs
+++ b/tests/execution.rs
@@ -2595,5 +2595,5 @@ declare_builtin_function!(
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": "8bf688fe71fb01ba74af9cfd975bfcc6f9d04641",
"rev": "86a70621aeabefdfdd574155e37520342d7e0680",
"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": "ae4b68b36d6da1dd0d6a78643b634296b3fa8039",
"rev": "56d97c3ad8c86e602bc7ac368751210517c4309f",
"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": "8d36530b7071060e2837ebb26f25590db6816048",
"rev": "b78c20f4a3527888da68254863c47f9e0a0a868e",
"patch": "solana_rbpf.patch",
"subdir": ".",
"package": "solana_rbpf",
Expand Down

0 comments on commit 36396ff

Please sign in to comment.