Skip to content

Commit 721ecf0

Browse files
smoeliusclaude
authored andcommitted
Fix third-party tests
1 parent 591536c commit 721ecf0

File tree

3 files changed

+103
-77
lines changed

3 files changed

+103
-77
lines changed

macro/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ proc-macro = true
1616
darling = { workspace = true }
1717
itertools = { workspace = true }
1818
prettyplease = { workspace = true }
19-
proc-macro2 = { workspace = true }
19+
proc-macro2 = { workspace = true, features = ["span-locations"] }
2020
quote = { workspace = true }
2121
syn = { workspace = true }
2222

third-party/patches/solana-sbpf.patch

Lines changed: 100 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Cargo.toml b/Cargo.toml
2-
index 35f484a..e19b4f1 100644
2+
index 2199b6c..6c350c6 100644
33
--- a/Cargo.toml
44
+++ b/Cargo.toml
55
@@ -31,4 +31,7 @@ shuttle = { version = "0.7.1", optional = true }
@@ -10,18 +10,18 @@ index 35f484a..e19b4f1 100644
1010
+
1111
[target.'cfg(windows)'.dependencies]
1212
winapi = { version = "0.3", features = ["memoryapi", "sysinfoapi", "winnt", "errhandlingapi"], optional = true }
13-
@@ -49,2 +52,4 @@ elf = "0.0.10"
13+
@@ -50,2 +53,4 @@ elf = "0.0.10"
1414
json = "0.12"
1515
test_utils = { path = "test_utils/" }
1616
+
1717
+[workspace]
1818
diff --git a/src/memory_region.rs b/src/memory_region.rs
19-
index 5ca5cc5..83a6797 100644
19+
index 69d09d2..affb30d 100644
2020
--- a/src/memory_region.rs
2121
+++ b/src/memory_region.rs
22-
@@ -58,4 +58,85 @@ pub struct MemoryRegion {
22+
@@ -59,4 +59,85 @@ pub struct MemoryRegion {
2323
}
24-
24+
2525
+#[derive(serde::Deserialize, serde::Serialize)]
2626
+struct SerializableMemoryRegion {
2727
+ host_mem_seed: Option<u64>,
@@ -105,54 +105,18 @@ index 5ca5cc5..83a6797 100644
105105
+
106106
impl MemoryRegion {
107107
fn new(slice: &[u8], vm_addr: u64, vm_gap_size: u64, writable: bool) -> Self {
108-
@@ -183,8 +264,10 @@ pub enum AccessType {
109-
110-
/// Common parts of [UnalignedMemoryMapping] and [AlignedMemoryMapping]
111-
+#[derive(serde::Deserialize, serde::Serialize)]
112-
pub struct CommonMemoryMapping {
113-
/// Mapped memory regions
114-
regions: Box<[MemoryRegion]>,
115-
/// Access violation handler
116-
+ #[serde(skip, default = "boxed_default_access_violation_handler")]
117-
access_violation_handler: AccessViolationHandler,
118-
/// VM configuration
119-
@@ -196,4 +279,21 @@ pub struct CommonMemoryMapping {
108+
@@ -195,4 +276,36 @@ pub struct UnalignedMemoryMapping {
120109
}
121-
122-
+impl Clone for CommonMemoryMapping {
123-
+ fn clone(&self) -> Self {
124-
+ Self {
125-
+ regions: self.regions.clone(),
126-
+ access_violation_handler: boxed_default_access_violation_handler(),
127-
+ allow_memory_region_zero: self.allow_memory_region_zero,
128-
+ max_call_depth: self.max_call_depth,
129-
+ stack_frame_size: self.stack_frame_size,
130-
+ sbpf_version: self.sbpf_version,
131-
+ }
132-
+ }
133-
+}
134-
+
135-
+fn boxed_default_access_violation_handler() -> AccessViolationHandler {
136-
+ Box::new(default_access_violation_handler)
137-
+}
138-
+
139-
impl CommonMemoryMapping {
140-
fn generate_access_violation(
141-
@@ -246,4 +346,39 @@ pub struct UnalignedMemoryMapping {
142-
}
143-
110+
144111
+impl<'de> serde::Deserialize<'de> for UnalignedMemoryMapping {
145112
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
146113
+ where
147114
+ D: serde::Deserializer<'de>,
148115
+ {
149-
+ let common = CommonMemoryMapping::deserialize(deserializer)?;
150-
+ Ok(Self {
151-
+ common,
152-
+ region_addresses: Box::new([]),
153-
+ region_index_lookup: Box::new([]),
154-
+ cache: UnsafeCell::new(MappingCache::new()),
155-
+ })
116+
+ let regions = Vec::<MemoryRegion>::deserialize(deserializer)?;
117+
+ let mut mapping = Self::new_uninitialized(regions);
118+
+ mapping.initialize().map_err(serde::de::Error::custom)?;
119+
+ Ok(mapping)
156120
+ }
157121
+}
158122
+
@@ -161,14 +125,14 @@ index 5ca5cc5..83a6797 100644
161125
+ where
162126
+ S: serde::Serializer,
163127
+ {
164-
+ self.common.serialize(serializer)
128+
+ self.regions.serialize(serializer)
165129
+ }
166130
+}
167131
+
168132
+impl Clone for UnalignedMemoryMapping {
169133
+ fn clone(&self) -> Self {
170134
+ Self {
171-
+ common: self.common.clone(),
135+
+ regions: self.regions.clone(),
172136
+ region_addresses: self.region_addresses.clone(),
173137
+ region_index_lookup: self.region_index_lookup.clone(),
174138
+ cache: UnsafeCell::new(unsafe { &*self.cache.get() as &MappingCache }.clone()),
@@ -178,45 +142,112 @@ index 5ca5cc5..83a6797 100644
178142
+
179143
impl fmt::Debug for UnalignedMemoryMapping {
180144
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
181-
@@ -356,4 +491,5 @@ impl<'a> UnalignedMemoryMapping {
145+
@@ -302,5 +415,5 @@ impl UnalignedMemoryMapping {
182146
/// Memory mapping that uses the upper half of an address to identify the
183147
/// underlying memory region.
184-
+#[derive(Clone, serde::Deserialize, serde::Serialize)]
148+
-#[derive(Debug)]
149+
+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
185150
pub struct AlignedMemoryMapping {
186-
/// Common parts
187-
@@ -460,5 +596,5 @@ impl AlignedMemoryMapping {
151+
regions: Vec<MemoryRegion>,
152+
@@ -424,6 +537,71 @@ impl fmt::Debug for MemoryMapping {
153+
}
188154

155+
+impl Clone for MemoryMapping {
156+
+ fn clone(&self) -> Self {
157+
+ Self {
158+
+ access_violation_handler: Box::new(default_access_violation_handler),
159+
+ max_call_depth: self.max_call_depth,
160+
+ stack_frame_size: self.stack_frame_size,
161+
+ disable_address_translation: self.disable_address_translation,
162+
+ sbpf_version: self.sbpf_version,
163+
+ initialized: self.initialized,
164+
+ ty: self.ty.clone(),
165+
+ }
166+
+ }
167+
+}
168+
+
169+
+impl<'de> serde::Deserialize<'de> for MemoryMapping {
170+
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
171+
+ where
172+
+ D: serde::Deserializer<'de>,
173+
+ {
174+
+ #[derive(serde::Deserialize)]
175+
+ struct Helper {
176+
+ max_call_depth: i64,
177+
+ stack_frame_size: i64,
178+
+ disable_address_translation: bool,
179+
+ sbpf_version: SBPFVersion,
180+
+ initialized: bool,
181+
+ ty: MemoryMappingType,
182+
+ }
183+
+ let Helper {
184+
+ max_call_depth,
185+
+ stack_frame_size,
186+
+ disable_address_translation,
187+
+ sbpf_version,
188+
+ initialized,
189+
+ ty,
190+
+ } = Helper::deserialize(deserializer)?;
191+
+ Ok(Self {
192+
+ access_violation_handler: Box::new(default_access_violation_handler),
193+
+ max_call_depth,
194+
+ stack_frame_size,
195+
+ disable_address_translation,
196+
+ sbpf_version,
197+
+ initialized,
198+
+ ty,
199+
+ })
200+
+ }
201+
+}
202+
+
203+
+impl serde::Serialize for MemoryMapping {
204+
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
205+
+ where
206+
+ S: serde::Serializer,
207+
+ {
208+
+ use serde::ser::SerializeStruct;
209+
+ let mut state = serializer.serialize_struct("MemoryMapping", 6)?;
210+
+ state.serialize_field("max_call_depth", &self.max_call_depth)?;
211+
+ state.serialize_field("stack_frame_size", &self.stack_frame_size)?;
212+
+ state.serialize_field("disable_address_translation", &self.disable_address_translation)?;
213+
+ state.serialize_field("sbpf_version", &self.sbpf_version)?;
214+
+ state.serialize_field("initialized", &self.initialized)?;
215+
+ state.serialize_field("ty", &self.ty)?;
216+
+ state.end()
217+
+ }
218+
+}
219+
+
189220
/// Maps virtual memory to host memory.
190221
-#[derive(Debug)]
191-
+#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
192-
pub enum MemoryMapping {
193-
/// Used when address translation is disabled
194-
@@ -646,5 +782,5 @@ impl MemoryMapping {
222+
+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
223+
pub enum MemoryMappingType {
224+
/// Aligned memory mapping which uses the upper half of an address to
225+
@@ -678,5 +856,5 @@ impl MemoryMapping {
195226

196227
/// Fast, small linear cache used to speed up unaligned memory mapping.
197228
-#[derive(Debug)]
198229
+#[derive(Debug, Clone)]
199230
struct MappingCache {
200231
// The cached entries.
201232
diff --git a/src/program.rs b/src/program.rs
202-
index af2642e..f5a69ec 100644
233+
index a886e9a..684f0a7 100644
203234
--- a/src/program.rs
204235
+++ b/src/program.rs
205-
@@ -11,5 +11,5 @@ use {
236+
@@ -10,5 +10,5 @@ use {
206237

207238
/// Defines a set of sbpf_version of an executable
208239
-#[derive(Debug, PartialEq, PartialOrd, Eq, Clone, Copy)]
209240
+#[derive(Debug, PartialEq, PartialOrd, Eq, Clone, Copy, serde::Deserialize, serde::Serialize)]
210241
pub enum SBPFVersion {
211242
/// The legacy format
212-
@@ -423,5 +423,5 @@ macro_rules! declare_builtin_function {
243+
@@ -414,5 +414,5 @@ macro_rules! declare_builtin_function {
213244
(
214245
$(#[$attr:meta])*
215246
- $name:ident $(<$($generic_ident:tt : $generic_type:tt),+>)?,
216247
+ $name:ident,
217248
fn rust(
218249
$vm:ident : &mut $ContextObject:ty,
219-
@@ -440,4 +440,54 @@ macro_rules! declare_builtin_function {
250+
@@ -430,4 +430,49 @@ macro_rules! declare_builtin_function {
220251
$($codegen:tt)*
221252
})?
222253
+ ) => {
@@ -236,11 +267,7 @@ index af2642e..f5a69ec 100644
236267
+ $arg_c: u64,
237268
+ $arg_d: u64,
238269
+ $arg_e: u64,
239-
+ $memory_mapping: &mut $MemoryMapping,
240270
+ ) -> core::result::Result<$Ok, $Err> {
241-
+ if matches!($memory_mapping, MemoryMapping::Identity) {
242-
+ std::process::exit(0);
243-
+ }
244271
+ $($rust)*
245272
+ }
246273
+ $(fn codegen(
@@ -260,7 +287,6 @@ index af2642e..f5a69ec 100644
260287
+ $arg_c:ident : u64,
261288
+ $arg_d:ident : u64,
262289
+ $arg_e:ident : u64,
263-
+ $memory_mapping:ident : &mut $MemoryMapping:ty,
264290
+ ) -> Result<$Ok:ty, $Err:ty> {
265291
+ $($rust:tt)*
266292
+ }
@@ -271,7 +297,7 @@ index af2642e..f5a69ec 100644
271297
+ })?
272298
) => {
273299
$(#[$attr])*
274-
@@ -462,7 +512,7 @@ macro_rules! declare_builtin_function {
300+
@@ -451,7 +496,7 @@ macro_rules! declare_builtin_function {
275301
}
276302
$(fn codegen(
277303
- $jit: &mut $crate::program::JitCompiler<$ContextObject2>,
@@ -282,18 +308,18 @@ index af2642e..f5a69ec 100644
282308
})?
283309
}
284310
diff --git a/src/vm.rs b/src/vm.rs
285-
index 58d6b3e..b9bf426 100644
311+
index ba8d41a..e6aefb3 100644
286312
--- a/src/vm.rs
287313
+++ b/src/vm.rs
288-
@@ -59,5 +59,5 @@ pub enum ExecutionMode {
314+
@@ -111,5 +111,5 @@ pub enum ExecutionMode {
289315

290316
/// VM configuration settings
291317
-#[derive(Debug, Clone, PartialEq, Eq)]
292318
+#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
293319
pub struct Config {
294320
/// Maximum call depth
295321
diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml
296-
index ef2eed6..d29c1d7 100644
322+
index a4da443..6d93e6a 100644
297323
--- a/test_utils/Cargo.toml
298324
+++ b/test_utils/Cargo.toml
299325
@@ -9,2 +9,5 @@ publish = false
@@ -303,13 +329,13 @@ index ef2eed6..d29c1d7 100644
303329
+serde = "1.0"
304330
+test-fuzz = { path = "../../../test-fuzz" }
305331
diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs
306-
index 6f2a799..880ef16 100644
332+
index c94415b..04b2577 100644
307333
--- a/test_utils/src/lib.rs
308334
+++ b/test_utils/src/lib.rs
309-
@@ -23,5 +23,5 @@ pub mod syscalls;
335+
@@ -25,5 +25,5 @@ pub mod syscalls;
310336

311337
/// Simple instruction meter for testing
312-
-#[derive(Debug, Clone, Default)]
313-
+#[derive(Debug, Clone, Default, serde::Deserialize, serde::Serialize)]
338+
-#[derive(Debug)]
339+
+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
314340
pub struct TestContextObject {
315341
/// Maximal amount of instructions which still can be executed

third-party/third_party.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{
1313
"flags": ["EXPENSIVE", "SKIP_NIGHTLY"],
1414
"url": "https://github.com/paritytech/polkadot-sdk",
15-
"rev": "2ca02c71569a782e2cdd7ee3426871ae060ed347",
15+
"rev": "f8df552131f87ab50bab8577a4254e31a63bfc62",
1616
"patch": "substrate_client_transaction_pool.patch",
1717
"subdir": ".",
1818
"test_package": "sc-transaction-pool",
@@ -32,7 +32,7 @@
3232
{
3333
"flags": [],
3434
"url": "https://github.com/anza-xyz/sbpf",
35-
"rev": "4bd09575983cad003b8b308b681f2499cf67ac55",
35+
"rev": "67858e4bf901c6ef5eea2cbd3bd17d9b45efcaf1",
3636
"patch": "solana-sbpf.patch",
3737
"subdir": ".",
3838
"test_package": "solana-sbpf",

0 commit comments

Comments
 (0)