Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update patches #488

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion macro/src/type_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl VisitMut for ExpandSelfVisitor<'_> {
.path
.segments
.first()
.map_or(false, |segment| segment.ident == "Self")
.is_some_and(|segment| segment.ident == "Self")
{
let segments = path.path.segments.iter().skip(1).collect::<Vec<_>>();
let self_ty = self.self_ty;
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn write_enabled() -> bool {
#[must_use]
fn enabled(opt: &str) -> bool {
let key = "TEST_FUZZ".to_owned() + if opt.is_empty() { "" } else { "_" } + opt;
env::var(key).map_or(false, |value| value != "0")
env::var(key).is_ok_and(|value| value != "0")
}

pub fn write_impl_generic_args<T>(args: &[&str]) {
Expand Down
2 changes: 1 addition & 1 deletion test-fuzz/tests/integration/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,5 @@ fn unmaintained() {

#[must_use]
pub fn enabled(key: &str) -> bool {
var(key).map_or(false, |value| value != "0")
var(key).is_ok_and(|value| value != "0")
}
83 changes: 54 additions & 29 deletions third-party/patches/agave.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 b3a6228..b8bae66 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 f6e0e46..54d2613 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 Down Expand Up @@ -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 3c62ccc..34b67a6 100644
--- a/programs/bpf_loader/Cargo.toml
+++ b/programs/bpf_loader/Cargo.toml
@@ -31,4 +31,7 @@ solana_rbpf = { workspace = true }
Expand All @@ -199,17 +224,17 @@ 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 485a8d3..a15c3ff 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" }
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 c465fd1..ab914b2 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 33bd6bc..1fc2e93 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,7 +325,7 @@ 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)]
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