Skip to content

Commit

Permalink
Merge branch 'master' into serde-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius authored Nov 11, 2024
2 parents 726e1bd + e6019c7 commit c532641
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ strip-ansi-escapes = "0.2"
strum_macros = "0.26"
subprocess = "0.2"
syn = { version = "2.0", features = ["full", "parsing", "visit", "visit-mut"] }
tempfile = "3.13"
tempfile = "3.14"
walkdir = "2.5"
xshell = "0.2"

Expand Down
58 changes: 29 additions & 29 deletions third-party/patches/agave.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
diff --git a/compute-budget/Cargo.toml b/compute-budget/Cargo.toml
index 07ba01c..c68aab1 100644
index 961ec9f..ee85710 100644
--- a/compute-budget/Cargo.toml
+++ b/compute-budget/Cargo.toml
@@ -16,4 +16,6 @@ solana-frozen-abi = { workspace = true, optional = true, features = [
solana-sdk = { workspace = true }
@@ -17,4 +17,6 @@ solana-frozen-abi = { workspace = true, optional = true, features = [
solana-program-entrypoint = { workspace = true }

+serde = { workspace = true }
+
[features]
frozen-abi = [
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 577a000..255809a 100644
index 9d1a351..22691a6 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 Down Expand Up @@ -64,16 +64,16 @@ index 4e764de..93cfd6c 100644
[dev-dependencies]
assert_matches = { workspace = true }
diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs
index c96da3e..73ff629 100644
index 1beda1c..b6bb470 100644
--- a/program-runtime/src/invoke_context.rs
+++ b/program-runtime/src/invoke_context.rs
@@ -118,4 +118,5 @@ impl fmt::Display for AllocErr {
@@ -121,4 +121,5 @@ impl fmt::Display for AllocErr {
}

+#[derive(Clone, serde::Deserialize, serde::Serialize)]
pub struct BpfAllocator {
len: u64,
@@ -146,10 +147,16 @@ impl BpfAllocator {
@@ -149,10 +150,16 @@ impl BpfAllocator {
}

+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
Expand All @@ -90,13 +90,13 @@ index c96da3e..73ff629 100644
+ )]
sysvar_cache: &'a SysvarCache,
}
@@ -174,4 +181,5 @@ impl<'a> EnvironmentConfig<'a> {
@@ -177,4 +184,5 @@ impl<'a> EnvironmentConfig<'a> {
}

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

-#[derive(Debug, Clone)]
Expand All @@ -109,7 +109,7 @@ index c96da3e..73ff629 100644
+#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub struct SerializedAccountMetadata {
pub original_data_len: usize,
@@ -189,9 +203,27 @@ pub struct SerializedAccountMetadata {
@@ -192,9 +206,27 @@ pub struct SerializedAccountMetadata {
}

+fn default_program_cache_for_tx_batch<'de, D>(
Expand Down Expand Up @@ -137,13 +137,13 @@ index c96da3e..73ff629 100644
+ )]
pub program_cache_for_tx_batch: &'a mut ProgramCacheForTxBatch,
/// Runtime configurations used to provision the invocation environment.
@@ -204,4 +236,5 @@ pub struct InvokeContext<'a> {
@@ -207,4 +239,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,
@@ -210,4 +243,23 @@ pub struct InvokeContext<'a> {
@@ -213,4 +246,23 @@ pub struct InvokeContext<'a> {
}

+impl<'a> Clone for InvokeContext<'a> {
Expand Down Expand Up @@ -191,10 +191,10 @@ 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 5e81062..821afe7 100644
index 883f0d2..05c9344 100644
--- a/programs/bpf_loader/src/lib.rs
+++ b/programs/bpf_loader/src/lib.rs
@@ -395,6 +395,7 @@ declare_builtin_function!(
@@ -396,6 +396,7 @@ declare_builtin_function!(
);

-pub fn process_instruction_inner(
Expand All @@ -205,47 +205,47 @@ 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 0c8352f..0b0ff72 100644
index cfef796..f3ae967 100644
--- a/sdk/Cargo.toml
+++ b/sdk/Cargo.toml
@@ -81,5 +81,5 @@ qualifier_attr = { workspace = true, optional = true }
@@ -86,5 +86,5 @@ qualifier_attr = { workspace = true, optional = true }
rand = { workspace = true, optional = true }
rand0-7 = { package = "rand", version = "0.7", optional = true }
rand0-7 = { workspace = true, optional = true }
-serde = { workspace = true }
+serde = { workspace = true, features = ["rc"] }
serde_bytes = { workspace = true }
serde_derive = { workspace = true }
@@ -120,4 +120,6 @@ solana-transaction-error = { workspace = true, features = ["serde"], optional =
@@ -138,4 +138,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 7352ff3..d7e4da2 100644
index 19b9075..ab7ed50 100644
--- a/sdk/feature-set/Cargo.toml
+++ b/sdk/feature-set/Cargo.toml
@@ -24,4 +24,6 @@ solana-pubkey = { workspace = true }
@@ -23,4 +23,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 83d5974..4c29279 100644
index 83b556f..b414464 100644
--- a/sdk/feature-set/src/lib.rs
+++ b/sdk/feature-set/src/lib.rs
@@ -1121,5 +1121,5 @@ lazy_static! {
@@ -1130,5 +1130,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>,
pub active: HashMap<Pubkey, u64>,
diff --git a/sdk/src/transaction_context.rs b/sdk/src/transaction_context.rs
index 95f65c3..94a5c8e 100644
index 6cb9513..3363645 100644
--- a/sdk/src/transaction_context.rs
+++ b/sdk/src/transaction_context.rs
@@ -33,5 +33,5 @@ pub type IndexOfAccount = u16;
Expand Down Expand Up @@ -295,7 +295,7 @@ index 95f65c3..94a5c8e 100644
+ )]
account_keys: Pin<Box<[Pubkey]>>,
accounts: Rc<TransactionAccounts>,
@@ -182,7 +204,7 @@ impl TransactionContext {
@@ -190,7 +212,7 @@ impl TransactionContext {
}

- Ok(Rc::try_unwrap(self.accounts)
Expand All @@ -306,7 +306,7 @@ index 95f65c3..94a5c8e 100644
+ Ok((*self.accounts).clone().into_accounts())
}

@@ -447,5 +469,5 @@ pub struct TransactionReturnData {
@@ -455,5 +477,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 All @@ -325,7 +325,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 4687855..2013968 100644
index 2cd7a49..388a027 100644
--- a/timings/src/lib.rs
+++ b/timings/src/lib.rs
@@ -11,5 +11,5 @@ use {
Expand All @@ -335,7 +335,7 @@ index 4687855..2013968 100644
+#[derive(Default, Debug, PartialEq, Eq, Clone, serde::Deserialize, serde::Serialize)]
pub struct ProgramTiming {
pub accumulated_us: u64,
@@ -366,5 +366,5 @@ impl ExecuteAccessoryTimings {
@@ -374,5 +374,5 @@ impl ExecuteAccessoryTimings {
}

-#[derive(Default, Debug, PartialEq, Eq)]
Expand Down
20 changes: 10 additions & 10 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 dbd876f..ee28197 100644
index e0ebfe6..a724fd4 100644
--- a/src/memory_region.rs
+++ b/src/memory_region.rs
@@ -34,5 +34,5 @@ use std::{
Expand Down Expand Up @@ -339,7 +339,7 @@ index dbd876f..ee28197 100644
struct MappingCache {
// The cached entries.
diff --git a/src/program.rs b/src/program.rs
index e40998a..51881e4 100644
index 183b058..116bb53 100644
--- a/src/program.rs
+++ b/src/program.rs
@@ -10,5 +10,5 @@ use {
Expand All @@ -349,14 +349,14 @@ index e40998a..51881e4 100644
+#[derive(Debug, PartialEq, PartialOrd, Eq, Clone, Copy, serde::Deserialize, serde::Serialize)]
pub enum SBPFVersion {
/// The legacy format
@@ -351,5 +351,5 @@ impl<C: ContextObject> std::fmt::Debug for BuiltinProgram<C> {
@@ -361,5 +361,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,
@@ -362,7 +362,9 @@ macro_rules! declare_builtin_function {
@@ -372,7 +372,9 @@ macro_rules! declare_builtin_function {
$(#[$attr])*
pub struct $name {}
+ #[test_fuzz::test_fuzz_impl]
Expand All @@ -367,7 +367,7 @@ index e40998a..51881e4 100644
+ pub fn rust $(<$($lifetime),+>)? (
$vm: &mut $ContextObject,
$arg_a: u64,
@@ -373,9 +375,12 @@ macro_rules! declare_builtin_function {
@@ -383,9 +385,12 @@ macro_rules! declare_builtin_function {
$memory_mapping: &mut $MemoryMapping,
) -> $Result {
+ if matches!($memory_mapping, MemoryMapping::Identity) {
Expand All @@ -381,14 +381,14 @@ index e40998a..51881e4 100644
+ pub fn vm $(<$($lifetime),+>)? (
$vm: *mut $crate::vm::EbpfVm<$ContextObject>,
$arg_a: u64,
@@ -387,5 +392,5 @@ macro_rules! declare_builtin_function {
@@ -397,5 +402,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();
@@ -393,5 +398,5 @@ macro_rules! declare_builtin_function {
@@ -403,5 +408,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,17 +502,17 @@ 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 54c1be0..be96076 100644
index 67314ff..7d1da71 100644
--- a/tests/execution.rs
+++ b/tests/execution.rs
@@ -2698,5 +2698,5 @@ declare_builtin_function!(
@@ -2595,5 +2595,5 @@ declare_builtin_function!(
/// For test_nested_vm_syscall()
SyscallNestedVm,
- fn rust(
+ fn rust<'a>(
_context_object: &mut TestContextObject,
depth: u64,
@@ -2705,5 +2705,5 @@ declare_builtin_function!(
@@ -2602,5 +2602,5 @@ declare_builtin_function!(
_arg4: u64,
_arg5: u64,
- _memory_mapping: &mut MemoryMapping,
Expand Down
34 changes: 18 additions & 16 deletions third-party/tests/third_party.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,24 @@ fn run_test(test: &Test, no_run: bool) {

// smoelius: Use `std::process::Command` so that we can see the output of the command as it
// runs. `assert_cmd::Command` would capture the output.
assert!(Command::new("cargo")
.current_dir(&subdir)
.env_remove("RUSTUP_TOOLCHAIN")
.env("TEST_FUZZ_WRITE", "1")
.args([
"test",
"--package",
&test.package,
"--features",
&("test-fuzz/".to_owned() + test_fuzz::serde_format::as_feature()),
"--",
"--nocapture"
])
.status()
.unwrap()
.success());
for flags in [&["--no-run", "--quiet"], &[]] as [&[&str]; 2] {
assert!(Command::new("cargo")
.current_dir(&subdir)
.env_remove("RUSTUP_TOOLCHAIN")
.env("TEST_FUZZ_WRITE", "1")
.args([
"test",
"--package",
&test.package,
"--features",
&("test-fuzz/".to_owned() + test_fuzz::serde_format::as_feature()),
])
.args(flags)
.args(["--", "--nocapture"])
.status()
.unwrap()
.success());
}

for target in &test.targets {
test_fuzz(&subdir, &test.package, target, ["--display=corpus"])
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": "10bebfaf422b8e09409cc5b56a35ec40defa27aa",
"rev": "2a618b5e01d898af63e0922454b6b0f0eed93528",
"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": "4c618a83d33281fe96f0e2b68a111ed227af22c0",
"rev": "0e09ad448bce27fcd255370cc2827ea5d2cf3892",
"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": "69a52ec6a341bb7374d387173b5e6dc56218fe0c",
"rev": "73f0e76d3abb3b03a317e7f7094911e23f244b52",
"patch": "solana_rbpf.patch",
"subdir": ".",
"package": "solana_rbpf",
Expand Down

0 comments on commit c532641

Please sign in to comment.