17 Commits

Author SHA1 Message Date
Luke Parker
d74b00b9e4 Update monero-oxide to the branch with the new RPC
See https://github.com/monero-oxide/monero-oxide/pull/66.

Allows us to remove the shim `simple-request 0.1` we had to define as we now
have `simple-request 0.2` in tree.
2025-09-18 19:09:22 -04:00
Luke Parker
3955f92cc2 Merge branch 'next' into next-polkadot-sdk 2025-09-18 18:19:14 -04:00
Luke Parker
a9b1e5293c Support webpki-roots as a fallback in simple-request 2025-09-18 18:15:24 -04:00
Luke Parker
80009ab67f Tidy unused import 2025-09-18 17:49:37 -04:00
Luke Parker
df9fda2971 Fixes from errors in cherry-picked commits 2025-09-18 17:49:32 -04:00
Luke Parker
ca8afb83a1 simple-request 0.2.0 2025-09-18 17:41:31 -04:00
Luke Parker
18a9cf2535 Have simple-request return an error upon failing to find the system's root certificates 2025-09-18 17:41:31 -04:00
Luke Parker
10c126ad92 Misc updates 2025-09-18 17:41:25 -04:00
Luke Parker
19305aebc9 Finally make modular-frost work with alloc alone
Carries the update to `frost-schnorrkel` and `bitcoin-serai`.
2025-09-18 17:06:57 -04:00
Luke Parker
be68e27551 Tweak multiexp to compile on core
On `core`, it'll use a serial implementation of no benefit other than the fact
that when `alloc` _is_ enabled, it'll use the multi-scalar multiplication
algorithms.

`schnorr-signatures` was prior tweaked to include a shim for
`SchnorrSignature::verify` which didn't use `multiexp_vartime` yet this same
premise. Now, instead of callers writing these shims, it's within `multiexp`.
2025-09-18 17:06:42 -04:00
Luke Parker
d6d96fe8ff Correct std-shims feature flagging 2025-09-18 17:06:31 -04:00
Luke Parker
95909d83a4 Expose std_shims::io on core
The `io::Write` trait is somewhat worthless, being implemented for nothing, yet
`Read` remains fully functional. This also allows using its polyfills _without_
requiring `alloc`.

Opportunity taken to make `schnorr-signatures` not require `alloc`.

This will require a version bump before being published due to newly requiring
the `alloc` feature be specified to maintain pre-existing behavior.

Enables resolving https://github.com/monero-oxide/monero-oxide/issues/48.
2025-09-18 17:06:05 -04:00
Luke Parker
3bd48974f3 Add missing alloc feature to multiexp's use of zeroize
Fixes building `multiexp` without default features, without separately
specifying `zeroize` and adding the `alloc` feature.
2025-09-18 17:05:19 -04:00
Luke Parker
29093715e3 Add impl<R: Read> Read for &mut R to std_shims
Increases parity with `std::io`.
2025-09-18 17:05:07 -04:00
Luke Parker
87b4dfc8f3 Expand std_shims::prelude to better match std::prelude 2025-09-18 17:04:54 -04:00
Luke Parker
4db78b1787 Add the ability to bound the response's size limit to simple-request 2025-09-18 17:04:41 -04:00
Luke Parker
02a5f15535 Make the MSRV lint more robust
The prior version would fail if the last entry in the final array was not
originally the last entry.
2025-09-18 17:04:10 -04:00
20 changed files with 201 additions and 114 deletions

138
Cargo.lock generated
View File

@@ -1379,7 +1379,7 @@ dependencies = [
"serde",
"serde_json",
"simple-request",
"std-shims",
"std-shims 0.1.5",
"subtle",
"thiserror 2.0.16",
"tokio",
@@ -1795,7 +1795,7 @@ dependencies = [
"ff-group-tests",
"group",
"hex",
"std-shims",
"std-shims 0.1.5",
"subtle",
"zeroize",
]
@@ -1806,7 +1806,7 @@ version = "0.4.99"
dependencies = [
"ciphersuite 0.4.2",
"dalek-ff-group",
"std-shims",
"std-shims 0.1.5",
"zeroize",
]
@@ -2676,7 +2676,7 @@ version = "0.6.1"
dependencies = [
"borsh",
"ciphersuite 0.4.2",
"std-shims",
"std-shims 0.1.5",
"thiserror 2.0.16",
"zeroize",
]
@@ -2688,7 +2688,7 @@ dependencies = [
"ciphersuite 0.4.2",
"dkg",
"rand_core 0.6.4",
"std-shims",
"std-shims 0.1.5",
"zeroize",
]
@@ -2714,7 +2714,7 @@ dependencies = [
"rand_chacha 0.3.1",
"rand_core 0.6.4",
"secq256k1",
"std-shims",
"std-shims 0.1.5",
"thiserror 2.0.16",
"zeroize",
]
@@ -2729,7 +2729,7 @@ dependencies = [
"dkg-recovery",
"multiexp",
"rand_core 0.6.4",
"std-shims",
"std-shims 0.1.5",
"thiserror 2.0.16",
"zeroize",
]
@@ -2800,7 +2800,7 @@ dependencies = [
"ff",
"group",
"rand_core 0.6.4",
"std-shims",
"std-shims 0.1.99",
"subtle",
"zeroize",
]
@@ -2913,7 +2913,7 @@ dependencies = [
"prime-field",
"rand_core 0.6.4",
"short-weierstrass",
"std-shims",
"std-shims 0.1.5",
"typenum",
"zeroize",
]
@@ -3371,7 +3371,7 @@ dependencies = [
"rand_core 0.6.4",
"schnorr-signatures",
"schnorrkel",
"std-shims",
"std-shims 0.1.5",
"zeroize",
]
@@ -3547,7 +3547,7 @@ dependencies = [
"flexible-transcript",
"multiexp",
"rand_core 0.6.4",
"std-shims",
"std-shims 0.1.99",
"zeroize",
]
@@ -3558,7 +3558,7 @@ source = "git+https://github.com/monero-oxide/monero-oxide?rev=dc1b3dbe436aae61e
dependencies = [
"ciphersuite 0.4.99",
"generalized-bulletproofs",
"std-shims",
"std-shims 0.1.99",
"zeroize",
]
@@ -3570,7 +3570,7 @@ dependencies = [
"ciphersuite 0.4.99",
"generalized-bulletproofs-circuit-abstraction",
"generic-array 1.2.0",
"std-shims",
"std-shims 0.1.99",
]
[[package]]
@@ -4051,6 +4051,7 @@ dependencies = [
"tokio",
"tokio-rustls",
"tower-service",
"webpki-roots 1.0.2",
]
[[package]]
@@ -4271,7 +4272,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
dependencies = [
"equivalent",
"hashbrown 0.15.5",
"hashbrown 0.16.0",
"serde",
"serde_core",
]
@@ -5431,7 +5432,7 @@ dependencies = [
"schnorr-signatures",
"serde_json",
"sha2 0.10.9",
"std-shims",
"std-shims 0.1.5",
"subtle",
"thiserror 2.0.16",
"zeroize",
@@ -5459,7 +5460,7 @@ dependencies = [
[[package]]
name = "monero-address"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"curve25519-dalek",
"monero-base58",
@@ -5471,36 +5472,36 @@ dependencies = [
[[package]]
name = "monero-base58"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"monero-primitives",
"std-shims",
"std-shims 0.1.99",
]
[[package]]
name = "monero-borromean"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"curve25519-dalek",
"monero-generators",
"monero-io",
"monero-primitives",
"std-shims",
"std-shims 0.1.99",
"zeroize",
]
[[package]]
name = "monero-bulletproofs"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"curve25519-dalek",
"monero-generators",
"monero-io",
"monero-primitives",
"rand_core 0.6.4",
"std-shims",
"std-shims 0.1.99",
"thiserror 2.0.16",
"zeroize",
]
@@ -5508,7 +5509,7 @@ dependencies = [
[[package]]
name = "monero-clsag"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"curve25519-dalek",
"dalek-ff-group",
@@ -5520,16 +5521,31 @@ dependencies = [
"monero-primitives",
"rand_chacha 0.3.1",
"rand_core 0.6.4",
"std-shims",
"std-shims 0.1.99",
"subtle",
"thiserror 2.0.16",
"zeroize",
]
[[package]]
name = "monero-daemon-rpc"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"curve25519-dalek",
"hex",
"monero-address",
"monero-interface",
"monero-oxide",
"serde",
"serde_json",
"std-shims 0.1.99",
]
[[package]]
name = "monero-generators"
version = "0.4.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"crypto-bigint 0.5.5",
"curve25519-dalek",
@@ -5537,30 +5553,43 @@ dependencies = [
"group",
"monero-io",
"sha3 0.10.8",
"std-shims",
"std-shims 0.1.99",
"subtle",
]
[[package]]
name = "monero-interface"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"curve25519-dalek",
"hex",
"monero-oxide",
"std-shims 0.1.99",
"thiserror 2.0.16",
"zeroize",
]
[[package]]
name = "monero-io"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"curve25519-dalek",
"std-shims",
"std-shims 0.1.99",
"zeroize",
]
[[package]]
name = "monero-mlsag"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"curve25519-dalek",
"monero-generators",
"monero-io",
"monero-primitives",
"std-shims",
"std-shims 0.1.99",
"thiserror 2.0.16",
"zeroize",
]
@@ -5568,7 +5597,7 @@ dependencies = [
[[package]]
name = "monero-oxide"
version = "0.1.4-alpha"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"curve25519-dalek",
"hex-literal",
@@ -5579,47 +5608,31 @@ dependencies = [
"monero-io",
"monero-mlsag",
"monero-primitives",
"std-shims",
"std-shims 0.1.99",
"zeroize",
]
[[package]]
name = "monero-primitives"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"curve25519-dalek",
"monero-generators",
"monero-io",
"sha3 0.10.8",
"std-shims",
"zeroize",
]
[[package]]
name = "monero-rpc"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
dependencies = [
"curve25519-dalek",
"hex",
"monero-address",
"monero-oxide",
"serde",
"serde_json",
"std-shims",
"thiserror 2.0.16",
"std-shims 0.1.99",
"zeroize",
]
[[package]]
name = "monero-simple-request-rpc"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"digest_auth",
"hex",
"monero-rpc",
"monero-daemon-rpc",
"simple-request",
"tokio",
"zeroize",
@@ -5628,7 +5641,7 @@ dependencies = [
[[package]]
name = "monero-wallet"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
dependencies = [
"curve25519-dalek",
"flexible-transcript",
@@ -5636,13 +5649,13 @@ dependencies = [
"modular-frost",
"monero-address",
"monero-clsag",
"monero-interface",
"monero-oxide",
"monero-rpc",
"rand 0.8.5",
"rand_chacha 0.3.1",
"rand_core 0.6.4",
"rand_distr",
"std-shims",
"std-shims 0.1.99",
"thiserror 2.0.16",
"zeroize",
]
@@ -8620,7 +8633,7 @@ dependencies = [
"multiexp",
"rand_core 0.6.4",
"sha2 0.10.9",
"std-shims",
"std-shims 0.1.5",
"zeroize",
]
@@ -8743,7 +8756,7 @@ dependencies = [
"rand_core 0.6.4",
"sha2 0.11.0-rc.2",
"short-weierstrass",
"std-shims",
"std-shims 0.1.5",
]
[[package]]
@@ -9297,7 +9310,7 @@ dependencies = [
"schnorr-signatures",
"secq256k1",
"short-weierstrass",
"std-shims",
"std-shims 0.1.5",
]
[[package]]
@@ -10000,7 +10013,7 @@ dependencies = [
[[package]]
name = "simple-request"
version = "0.1.1"
version = "0.2.0"
dependencies = [
"base64ct",
"futures-util",
@@ -10719,6 +10732,13 @@ dependencies = [
"spin",
]
[[package]]
name = "std-shims"
version = "0.1.99"
dependencies = [
"std-shims 0.1.5",
]
[[package]]
name = "strsim"
version = "0.11.1"

View File

@@ -5,11 +5,6 @@ members = [
"patches/option-ext",
"patches/directories-next",
# monero-oxide expects `ciphersuite`, yet the `ciphersuite` in-tree here has breaking changes
# This re-exports the in-tree `ciphersuite` _without_ changes breaking to monero-oxide
# Not included in workspace to prevent having two crates with the same name (an error)
# "patches/ciphersuite",
"common/std-shims",
"common/zalloc",
"common/patchable-async-sleep",
@@ -169,7 +164,7 @@ overflow-checks = true
[patch.crates-io]
# Dependencies from monero-oxide which originate from within our own tree
std-shims = { path = "common/std-shims" }
std-shims = { path = "patches/std-shims" }
simple-request = { path = "common/request" }
multiexp = { path = "crypto/multiexp" }
flexible-transcript = { path = "crypto/transcript" }

View File

@@ -1,9 +1,9 @@
[package]
name = "simple-request"
version = "0.1.1"
version = "0.2.0"
description = "A simple HTTP(S) request library"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/common/simple-request"
repository = "https://github.com/serai-dex/serai/tree/develop/common/request"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = ["http", "https", "async", "request", "ssl"]
edition = "2021"
@@ -31,5 +31,6 @@ base64ct = { version = "1", features = ["alloc"], optional = true }
[features]
tls = ["hyper-rustls"]
webpki-roots = ["tls", "hyper-rustls/webpki-roots"]
basic-auth = ["zeroize", "base64ct"]
default = ["tls"]

View File

@@ -52,24 +52,30 @@ pub struct Client {
}
impl Client {
#[allow(clippy::unnecessary_wraps)]
fn connector() -> Result<Connector, Error> {
let mut res = HttpConnector::new();
res.set_keepalive(Some(core::time::Duration::from_secs(60)));
res.set_nodelay(true);
res.set_reuse_address(true);
#[cfg(feature = "tls")]
res.enforce_http(false);
#[cfg(feature = "tls")]
let res = HttpsConnectorBuilder::new()
.with_native_roots()
.map_err(|e| {
Error::ConnectionError(
format!("couldn't load system's SSL root certificates: {e:?}").into(),
)
})?
.https_or_http()
.enable_http1()
.wrap_connector(res);
let https = HttpsConnectorBuilder::new().with_native_roots();
#[cfg(all(feature = "tls", not(feature = "webpki-roots")))]
let https = https.map_err(|e| {
Error::ConnectionError(
format!("couldn't load system's SSL root certificates and webpki-roots unavilable: {e:?}")
.into(),
)
})?;
// Fallback to `webpki-roots` if present
#[cfg(all(feature = "tls", feature = "webpki-roots"))]
let https = https.unwrap_or(HttpsConnectorBuilder::new().with_webpki_roots());
#[cfg(feature = "tls")]
let res = https.https_or_http().enable_http1().wrap_connector(res);
Ok(res)
}

View File

@@ -17,8 +17,8 @@ pub mod error {
#[rustversion::since(1.81)]
pub use core::error;
#[cfg(all(feature = "alloc", not(feature = "std")))]
pub extern crate alloc as extern_alloc;
#[cfg(feature = "alloc")]
extern crate alloc as extern_alloc;
#[cfg(all(feature = "alloc", not(feature = "std")))]
pub use extern_alloc::{alloc, borrow, boxed, ffi, fmt, rc, slice, str, string, task, vec, format};
#[cfg(feature = "std")]
@@ -30,7 +30,7 @@ pub mod sync;
pub mod prelude {
// Shim the `std` prelude
#[cfg(all(feature = "alloc", not(feature = "std")))]
#[cfg(feature = "alloc")]
pub use extern_alloc::{
format, vec,
borrow::ToOwned,

View File

@@ -7,7 +7,7 @@ use rand::{RngCore, CryptoRng, rngs::OsRng};
use blake2::{Digest, Blake2s256};
use dalek_ff_group::Ristretto;
use ciphersuite::{group::Group, *};
use ciphersuite::*;
use schnorr::SchnorrSignature;
use ::tendermint::{

View File

@@ -17,7 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"]
workspace = true
[dependencies]
std-shims = { version = "0.1", default-features = false, features = ["alloc"] }
std-shims = { version = "0.1", path = "../../common/std-shims", default-features = false, features = ["alloc"] }
rand_core = { version = "0.6", default-features = false }
zeroize = { version = "1.5", default-features = false, features = ["zeroize_derive", "alloc"] }

View File

@@ -32,7 +32,7 @@ frost = { package = "modular-frost", path = "../../crypto/frost", version = "0.1
hex = { version = "0.4", default-features = false, optional = true }
serde = { version = "1", default-features = false, features = ["derive"], optional = true }
serde_json = { version = "1", default-features = false, optional = true }
simple-request = { path = "../../common/request", version = "0.1", default-features = false, features = ["tls", "basic-auth"], optional = true }
simple-request = { path = "../../common/request", version = "0.2", default-features = false, features = ["tls", "basic-auth"], optional = true }
[dev-dependencies]
secp256k1 = { version = "0.29", default-features = false, features = ["std"] }

View File

@@ -19,7 +19,7 @@ workspace = true
tower = "0.5"
serde_json = { version = "1", default-features = false }
simple-request = { path = "../../../common/request", version = "0.1", default-features = false }
simple-request = { path = "../../../common/request", version = "0.2", default-features = false }
alloy-json-rpc = { version = "1", default-features = false }
alloy-transport = { version = "1", default-features = false }

View File

@@ -0,0 +1,23 @@
[package]
name = "simple-request"
version = "0.1.99"
description = "simple-request which patches to the latest update"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/patches/simple-request"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = ["nostd", "no_std", "alloc", "io"]
edition = "2021"
rust-version = "1.65"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
simple-request = { path = "../../common/request" }
[features]
tls = ["simple-request/tls"]

View File

@@ -0,0 +1,18 @@
pub use simple_request::{hyper, Error, Request, Response};
#[derive(Clone, Debug)]
pub struct Client(simple_request::Client);
impl Client {
pub fn with_connection_pool() -> Client {
Self(simple_request::Client::with_connection_pool().unwrap())
}
pub fn without_connection_pool(host: &str) -> Result<Client, Error> {
simple_request::Client::without_connection_pool(host).map(Self)
}
pub async fn request<R: Into<Request>>(&self, request: R) -> Result<Response<'_>, Error> {
self.0.request(request).await
}
}

View File

@@ -0,0 +1,23 @@
[package]
name = "std-shims"
version = "0.1.99"
description = "std-shims which patches to the latest update"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/patches/std-shims"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = ["nostd", "no_std", "alloc", "io"]
edition = "2021"
rust-version = "1.65"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
std-shims = { path = "../../common/std-shims", default-features = false, features = ["alloc"] }
[features]
std = ["std-shims/std"]

View File

@@ -0,0 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]
pub extern crate alloc;
pub use std_shims::{str, vec, string, collections, io, sync, prelude};

View File

@@ -28,8 +28,8 @@ dalek-ff-group = { path = "../../crypto/dalek-ff-group", default-features = fals
dkg = { package = "dkg-evrf", path = "../../crypto/dkg/evrf", default-features = false, features = ["std", "ed25519"] }
frost = { package = "modular-frost", path = "../../crypto/frost", default-features = false }
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "2c847f71079a105456376f9957cee86c4b6a9eb8", default-features = false, features = ["std", "multisig"] }
monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "2c847f71079a105456376f9957cee86c4b6a9eb8", default-features = false }
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c", default-features = false, features = ["std", "multisig"] }
monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c", default-features = false }
serai-client = { path = "../../substrate/client", default-features = false, features = ["monero"] }

View File

@@ -6,7 +6,7 @@
static ALLOCATOR: zalloc::ZeroizingAlloc<std::alloc::System> =
zalloc::ZeroizingAlloc(std::alloc::System);
use monero_simple_request_rpc::SimpleRequestRpc;
use monero_simple_request_rpc::SimpleRequestTransport;
mod primitives;
pub(crate) use crate::primitives::*;
@@ -23,7 +23,7 @@ async fn main() {
let db = bin::init();
let feed = Rpc {
rpc: loop {
match SimpleRequestRpc::new(bin::url()).await {
match SimpleRequestTransport::new(bin::url()).await {
Ok(rpc) => break rpc,
Err(e) => {
log::error!("couldn't connect to the Monero node: {e:?}");

View File

@@ -4,7 +4,8 @@ use ciphersuite::*;
use dalek_ff_group::Ed25519;
use monero_wallet::{
block::Block as MBlock, rpc::ScannableBlock as MScannableBlock, ScanError, GuaranteedScanner,
block::Block as MBlock, interface::ScannableBlock as MScannableBlock, ScanError,
GuaranteedScanner,
};
use serai_client::networks::monero::Address;

View File

@@ -1,7 +1,6 @@
use core::future::Future;
use monero_wallet::rpc::{RpcError, Rpc as RpcTrait};
use monero_simple_request_rpc::SimpleRequestRpc;
use monero_simple_request_rpc::{prelude::*, SimpleRequestTransport};
use serai_client::primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount};
@@ -15,7 +14,7 @@ use crate::{
#[derive(Clone)]
pub(crate) struct Rpc {
pub(crate) rpc: SimpleRequestRpc,
pub(crate) rpc: MoneroDaemon<SimpleRequestTransport>,
}
impl ScannerFeed for Rpc {
@@ -31,21 +30,16 @@ impl ScannerFeed for Rpc {
type Block = Block;
type EphemeralError = RpcError;
type EphemeralError = InterfaceError;
fn latest_finalized_block_number(
&self,
) -> impl Send + Future<Output = Result<u64, Self::EphemeralError>> {
async move {
Ok(
self
.rpc
.get_height()
.await?
.checked_sub(1)
.expect("connected to an invalid Monero RPC")
.try_into()
.unwrap(),
u64::try_from(self.rpc.latest_block_number().await?)
.unwrap()
.saturating_sub(Self::CONFIRMATIONS - 1),
)
}
}
@@ -64,11 +58,11 @@ impl ScannerFeed for Rpc {
}
// Fetch all the timestamps within the window
let block_for_time_of = self.rpc.get_block_by_number(number.try_into().unwrap()).await?;
let block_for_time_of = self.rpc.block_by_number(number.try_into().unwrap()).await?;
let mut timestamps = vec![block_for_time_of.header.timestamp];
let mut parent = block_for_time_of.header.previous;
for _ in 1 .. BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW {
let parent_block = self.rpc.get_block(parent).await?;
let parent_block = self.rpc.block(parent).await?;
timestamps.push(parent_block.header.timestamp);
parent = parent_block.header.previous;
}
@@ -94,7 +88,7 @@ impl ScannerFeed for Rpc {
) -> impl Send
+ Future<Output = Result<<Self::Block as primitives::Block>::Header, Self::EphemeralError>>
{
async move { Ok(BlockHeader(self.rpc.get_block_by_number(number.try_into().unwrap()).await?)) }
async move { Ok(BlockHeader(self.rpc.block_by_number(number.try_into().unwrap()).await?)) }
}
#[rustfmt::skip] // It wants to improperly format the `async move` to a single line
@@ -103,7 +97,7 @@ impl ScannerFeed for Rpc {
number: u64,
) -> impl Send + Future<Output = Result<Self::Block, Self::EphemeralError>> {
async move {
Ok(Block(self.rpc.get_scannable_block_by_number(number.try_into().unwrap()).await?))
Ok(Block(self.rpc.scannable_block_by_number(number.try_into().unwrap()).await?))
}
}
@@ -128,7 +122,7 @@ impl ScannerFeed for Rpc {
}
impl TransactionPublisher<Transaction> for Rpc {
type EphemeralError = RpcError;
type EphemeralError = PublishTransactionError;
fn publish(
&self,

View File

@@ -7,7 +7,7 @@ use rand_chacha::ChaCha20Rng;
use ciphersuite::*;
use dalek_ff_group::Ed25519;
use monero_wallet::rpc::{FeeRate, RpcError};
use monero_wallet::interface::prelude::*;
use serai_client::{
primitives::{coin::ExternalCoin, balance::Amount},
@@ -55,7 +55,7 @@ async fn signable_transaction(
inputs: Vec<OutputFor<Rpc>>,
payments: Vec<Payment<AddressFor<Rpc>>>,
change: Option<KeyFor<Rpc>>,
) -> Result<Result<(SignableTransaction, MSignableTransaction), SendError>, RpcError> {
) -> Result<Result<(SignableTransaction, MSignableTransaction), SendError>, TransactionsError> {
assert!(inputs.len() < <Planner as TransactionPlanner<Rpc, ()>>::MAX_INPUTS);
assert!(
(payments.len() + usize::from(u8::from(change.is_some()))) <
@@ -148,7 +148,7 @@ async fn signable_transaction(
#[derive(Clone)]
pub(crate) struct Planner(pub(crate) Rpc);
impl TransactionPlanner<Rpc, ()> for Planner {
type EphemeralError = RpcError;
type EphemeralError = TransactionsError;
type SignableTransaction = SignableTransaction;
@@ -221,8 +221,9 @@ impl TransactionPlanner<Rpc, ()> for Planner {
payments: Vec<Payment<AddressFor<Rpc>>>,
change: Option<KeyFor<Rpc>>,
) -> impl Send
+ Future<Output = Result<PlannedTransaction<Rpc, Self::SignableTransaction, ()>, RpcError>>
{
+ Future<
Output = Result<PlannedTransaction<Rpc, Self::SignableTransaction, ()>, TransactionsError>,
> {
let singular_spent_output = (inputs.len() == 1).then(|| inputs[0].id());
async move {

View File

@@ -37,13 +37,13 @@ frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev =
async-lock = "3"
simple-request = { path = "../../common/request", version = "0.1", optional = true }
simple-request = { path = "../../common/request", version = "0.2", optional = true }
bitcoin = { version = "0.32", optional = true }
ciphersuite = { path = "../../crypto/ciphersuite", optional = true }
dalek-ff-group = { path = "../../crypto/dalek-ff-group", optional = true }
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "2c847f71079a105456376f9957cee86c4b6a9eb8", version = "0.1.0", default-features = false, features = ["std"], optional = true }
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c", version = "0.1.0", default-features = false, features = ["std"], optional = true }
[dev-dependencies]
rand_core = "0.6"

View File

@@ -78,7 +78,7 @@ serai-env = { path = "../../common/env" }
curve25519-dalek = { version = "4", default-features = false, features = ["alloc", "zeroize"] }
bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["std", "hazmat"] }
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "2c847f71079a105456376f9957cee86c4b6a9eb8", default-features = false, features = ["std"] }
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c", default-features = false, features = ["std"] }
[features]
default = []