mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-13 06:29:25 +00:00
Compare commits
5 Commits
b791256648
...
8c18e5d711
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c18e5d711 | ||
|
|
d02a0dd964 | ||
|
|
780f51e857 | ||
|
|
2fb90ebe55 | ||
|
|
b24adcbd14 |
358
Cargo.lock
generated
358
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -184,7 +184,11 @@ alloy-eip2124 = { path = "patches/ethereum/alloy-eip2124" }
|
||||
ark-ff-3 = { package = "ark-ff", path = "patches/ethereum/ark-ff-0.3" }
|
||||
ark-ff-4 = { package = "ark-ff", path = "patches/ethereum/ark-ff-0.4" }
|
||||
c-kzg = { path = "patches/ethereum/c-kzg" }
|
||||
secp256k1-30 = { package = "secp256k1", path = "patches/ethereum/secp256k1-30" }
|
||||
fastrlp-3 = { package = "fastrlp", path = "patches/ethereum/fastrlp-0.3" }
|
||||
fastrlp-4 = { package = "fastrlp", path = "patches/ethereum/fastrlp-0.4" }
|
||||
primitive-types-12 = { package = "primitive-types", path = "patches/ethereum/primitive-types-0.12" }
|
||||
rlp = { path = "patches/ethereum/rlp" }
|
||||
secp256k1-30 = { package = "secp256k1", path = "patches/ethereum/secp256k1-0.30" }
|
||||
|
||||
# Dependencies from monero-oxide which originate from within our own tree, potentially shimmed to account for deviations since publishing
|
||||
std-shims = { path = "patches/std-shims" }
|
||||
|
||||
@@ -6,12 +6,63 @@ pub use std::sync::{Arc, Weak};
|
||||
|
||||
mod mutex_shim {
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use spin::{Mutex, MutexGuard};
|
||||
mod spin_mutex {
|
||||
use core::ops::{Deref, DerefMut};
|
||||
|
||||
// We wrap this in an `Option` so we can consider `None` as poisoned
|
||||
pub(super) struct Mutex<T>(spin::Mutex<Option<T>>);
|
||||
|
||||
/// An acquired view of a `Mutex`.
|
||||
pub struct MutexGuard<'mutex, T> {
|
||||
mutex: spin::MutexGuard<'mutex, Option<T>>,
|
||||
// This is `Some` for the lifetime of this guard, and is only represented as an `Option` due
|
||||
// to needing to move it on `Drop` (which solely gives us a mutable reference to `self`)
|
||||
value: Option<T>,
|
||||
}
|
||||
|
||||
impl<T> Mutex<T> {
|
||||
pub(super) const fn new(value: T) -> Self {
|
||||
Self(spin::Mutex::new(Some(value)))
|
||||
}
|
||||
|
||||
pub(super) fn lock(&self) -> MutexGuard<'_, T> {
|
||||
let mut mutex = self.0.lock();
|
||||
// Take from the `Mutex` so future acquisitions will see `None` unless this is restored
|
||||
let value = mutex.take();
|
||||
// Check the prior acquisition did in fact restore the value
|
||||
if value.is_none() {
|
||||
panic!("locking a `spin::Mutex` held by a thread which panicked");
|
||||
}
|
||||
MutexGuard { mutex, value }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for MutexGuard<'_, T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &T {
|
||||
self.value.as_ref().expect("no value yet checked upon lock acquisition")
|
||||
}
|
||||
}
|
||||
impl<T> DerefMut for MutexGuard<'_, T> {
|
||||
fn deref_mut(&mut self) -> &mut T {
|
||||
self.value.as_mut().expect("no value yet checked upon lock acquisition")
|
||||
}
|
||||
}
|
||||
|
||||
impl<'mutex, T> Drop for MutexGuard<'mutex, T> {
|
||||
fn drop(&mut self) {
|
||||
// Restore the value
|
||||
*self.mutex = self.value.take();
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use spin_mutex::*;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use std::sync::{Mutex, MutexGuard};
|
||||
|
||||
/// A shimmed `Mutex` with an API mutual to `spin` and `std`.
|
||||
#[derive(Default, Debug)]
|
||||
pub struct ShimMutex<T>(Mutex<T>);
|
||||
impl<T> ShimMutex<T> {
|
||||
/// Construct a new `Mutex`.
|
||||
@@ -21,8 +72,9 @@ mod mutex_shim {
|
||||
|
||||
/// Acquire a lock on the contents of the `Mutex`.
|
||||
///
|
||||
/// On no-`std` environments, this may spin until the lock is acquired. On `std` environments,
|
||||
/// this may panic if the `Mutex` was poisoned.
|
||||
/// This will panic if the `Mutex` was poisoned.
|
||||
///
|
||||
/// On no-`std` environments, the implementation presumably defers to that of a spin lock.
|
||||
pub fn lock(&self) -> MutexGuard<'_, T> {
|
||||
#[cfg(feature = "std")]
|
||||
let res = self.0.lock().unwrap();
|
||||
|
||||
@@ -7,8 +7,7 @@ db-urls = ["https://github.com/rustsec/advisory-db"]
|
||||
yanked = "deny"
|
||||
|
||||
ignore = [
|
||||
"RUSTSEC-2022-0061", # https://github.com/serai-dex/serai/227
|
||||
"RUSTSEC-2024-0370", # proc-macro-error is unmaintained
|
||||
"RUSTSEC-2024-0370", # `proc-macro-error` is unmaintained, in-tree due to Substrate/`litep2p`
|
||||
"RUSTSEC-2024-0436", # paste is unmaintained
|
||||
]
|
||||
|
||||
|
||||
19
patches/ethereum/fastrlp-0.3/Cargo.toml
Normal file
19
patches/ethereum/fastrlp-0.3/Cargo.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "fastrlp"
|
||||
version = "0.3.99"
|
||||
description = "Patch to an empty crate"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/patches/ethereum/fastrlp-0.3"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = []
|
||||
edition = "2021"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[workspace]
|
||||
|
||||
[features]
|
||||
alloc = []
|
||||
std = []
|
||||
19
patches/ethereum/fastrlp-0.4/Cargo.toml
Normal file
19
patches/ethereum/fastrlp-0.4/Cargo.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "fastrlp"
|
||||
version = "0.4.99"
|
||||
description = "Patch to an empty crate"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/patches/ethereum/fastrlp-0.4"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = []
|
||||
edition = "2021"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[workspace]
|
||||
|
||||
[features]
|
||||
alloc = []
|
||||
std = []
|
||||
1
patches/ethereum/fastrlp-0.4/src/lib.rs
Normal file
1
patches/ethereum/fastrlp-0.4/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
const _NEVER_COMPILED: [(); 0 - 1] = [(); 0 - 1];
|
||||
18
patches/ethereum/primitive-types-0.12/Cargo.toml
Normal file
18
patches/ethereum/primitive-types-0.12/Cargo.toml
Normal file
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "primitive-types"
|
||||
version = "0.12.99"
|
||||
description = "Patch to an empty crate"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/patches/ethereum/primitive-types"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = []
|
||||
edition = "2021"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[workspace]
|
||||
|
||||
[features]
|
||||
std = []
|
||||
1
patches/ethereum/primitive-types-0.12/src/lib.rs
Normal file
1
patches/ethereum/primitive-types-0.12/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
const _NEVER_COMPILED: [(); 0 - 1] = [(); 0 - 1];
|
||||
18
patches/ethereum/rlp/Cargo.toml
Normal file
18
patches/ethereum/rlp/Cargo.toml
Normal file
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "rlp"
|
||||
version = "0.5.99"
|
||||
description = "Patch to an empty crate"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/patches/ethereum/rlp"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = []
|
||||
edition = "2021"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[workspace]
|
||||
|
||||
[features]
|
||||
std = []
|
||||
1
patches/ethereum/rlp/src/lib.rs
Normal file
1
patches/ethereum/rlp/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
const _NEVER_COMPILED: [(); 0 - 1] = [(); 0 - 1];
|
||||
@@ -3,7 +3,7 @@ name = "secp256k1"
|
||||
version = "0.30.99"
|
||||
description = "Patch to an empty crate"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/patches/ethereum/secp256k1-30"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/patches/ethereum/secp256k1-0.30"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = []
|
||||
edition = "2021"
|
||||
1
patches/ethereum/secp256k1-0.30/src/lib.rs
Normal file
1
patches/ethereum/secp256k1-0.30/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
const _NEVER_COMPILED: [(); 0 - 1] = [(); 0 - 1];
|
||||
@@ -11,6 +11,16 @@ fn main() {
|
||||
const WASM: &str = "-C link-arg=--export-table";
|
||||
const REQUIRED_BY_SUBSTRATE: &str = "--cfg substrate_runtime -C link-arg=--import-memory";
|
||||
const SAFETY: &str = "-C overflow-checks=true -C panic=abort";
|
||||
// `symbol-mangling-version` is defined to provide an explicit, canonical definition of symbols.
|
||||
// `embed-bitcode=false` is set as the bitcode is unnecessary yet takes notable time to compile.
|
||||
/*
|
||||
Rust's LTO requires bitcode, forcing us to defer to the linker's LTO. While this would suggest
|
||||
we _should_ set `embed-bitcode=true`, Rust's documentation suggests that's likely not desired
|
||||
and should solely be done when compiling one library with mixed methods of linking. When
|
||||
compiling and linking just once (as seen here), it's suggested to use the linker's LTO instead.
|
||||
|
||||
https://doc.rust-lang.org/1.91.1/rustc/codegen-options/index.html#embed-bitcode
|
||||
*/
|
||||
const COMPILATION: &str =
|
||||
"-C symbol-mangling-version=v0 -C embed-bitcode=false -C linker-plugin-lto=true";
|
||||
|
||||
@@ -78,6 +88,7 @@ fn main() {
|
||||
let wasm_file = env::var("CARGO_PKG_NAME").unwrap().replace('-', "_") + ".wasm";
|
||||
let src_file = target_dir.join("wasm32v1-none").join(&profile).join(&wasm_file);
|
||||
let dst_file = {
|
||||
// TODO: This sets `dst_dir` to the default target directory, not the actual
|
||||
let mut dst_dir = workspace.clone();
|
||||
// e.g. workspace/target/debug
|
||||
dst_dir.extend(["target", &profile]);
|
||||
|
||||
@@ -73,11 +73,10 @@ impl frame_system::Config for Runtime {
|
||||
// We assume `serai-node` will be run using the RocksDB backend
|
||||
type DbWeight = frame_support::weights::constants::RocksDbWeight;
|
||||
/*
|
||||
Serai does not expose `frame_system::Call` nor does it use transaction extensions. We
|
||||
accordingly have no consequence to using the default weights for these accordingly.
|
||||
Serai does not expose `frame_system::Call`. We accordingly have no consequence to using the
|
||||
default weights for these accordingly.
|
||||
*/
|
||||
type SystemWeightInfo = ();
|
||||
type ExtensionsWeightInfo = ();
|
||||
|
||||
// We also don't use `frame_system`'s account system at all, leaving us to bottom these out.
|
||||
type AccountData = ();
|
||||
|
||||
Reference in New Issue
Block a user