Smash serai-client so the processors don't need the entire lib to access their specific code

We prior controlled this with feature flags. It's just better to define their
own crates.
This commit is contained in:
Luke Parker
2025-11-04 19:02:37 -05:00
parent 1b499edfe1
commit 973287d0a1
40 changed files with 232 additions and 79 deletions

View File

@@ -105,4 +105,8 @@ jobs:
uses: ./.github/actions/build-dependencies
- name: Run Tests
run: GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client
run: |
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client-bitcoin
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client-ethereum
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client-monero
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client

View File

@@ -62,8 +62,8 @@ members = [
"processor/ethereum/primitives",
"processor/ethereum/test-primitives",
"processor/ethereum/deployer",
"processor/ethereum/router",
"processor/ethereum/erc20",
"processor/ethereum/router",
"processor/ethereum",
"processor/monero",
@@ -93,6 +93,9 @@ members = [
"substrate/runtime",
"substrate/node",
"substrate/client/bitcoin",
"substrate/client/ethereum",
"substrate/client/monero",
"substrate/client",
"orchestration",

View File

@@ -30,7 +30,8 @@ frost = { package = "modular-frost", path = "../../crypto/frost", default-featur
secp256k1 = { version = "0.29", default-features = false, features = ["std", "global-context", "rand-std"] }
bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["std"] }
serai-client = { path = "../../substrate/client", default-features = false, features = ["bitcoin"] }
serai-primitives = { path = "../../substrate/primitives", default-features = false, features = ["std"] }
serai-client-bitcoin = { path = "../../substrate/client/bitcoin", default-features = false }
zalloc = { path = "../../common/zalloc" }
log = { version = "0.4", default-features = false, features = ["std"] }

View File

@@ -6,7 +6,7 @@ use ciphersuite_kp256::Secp256k1;
use bitcoin_serai::bitcoin::block::{Header, Block as BBlock};
use serai_client::networks::bitcoin::Address;
use serai_client_bitcoin::Address;
use serai_db::Db;
use primitives::{ReceivedOutput, EventualityTracker};

View File

@@ -13,14 +13,12 @@ use bitcoin_serai::{
use borsh::{BorshSerialize, BorshDeserialize};
use serai_db::Get;
use serai_client::{
primitives::{
coin::ExternalCoin,
balance::{Amount, ExternalBalance},
address::ExternalAddress,
},
networks::bitcoin::Address,
use serai_primitives::{
coin::ExternalCoin,
balance::{Amount, ExternalBalance},
address::ExternalAddress,
};
use serai_client_bitcoin::Address;
use primitives::{OutputType, ReceivedOutput};

View File

@@ -18,7 +18,7 @@ use bitcoin_serai::{
use borsh::{BorshSerialize, BorshDeserialize};
use serai_client::networks::bitcoin::Address;
use serai_client_bitcoin::Address;
use crate::output::OutputId;

View File

@@ -2,7 +2,7 @@ use core::future::Future;
use bitcoin_serai::rpc::{RpcError, Rpc as BRpc};
use serai_client::primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount};
use serai_primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount};
use serai_db::Db;
use scanner::ScannerFeed;

View File

@@ -12,7 +12,7 @@ use bitcoin_serai::{
wallet::Scanner,
};
use serai_client::networks::bitcoin::Address;
use serai_client_bitcoin::Address;
use serai_db::Get;
use primitives::OutputType;

View File

@@ -8,10 +8,8 @@ use bitcoin_serai::{
wallet::{TransactionError, SignableTransaction as BSignableTransaction, p2tr_script_buf},
};
use serai_client::{
primitives::{coin::ExternalCoin, balance::Amount},
networks::bitcoin::Address,
};
use serai_primitives::{coin::ExternalCoin, balance::Amount};
use serai_client_bitcoin::Address;
use serai_db::Db;
use primitives::{OutputType, ReceivedOutput, Payment};

View File

@@ -39,7 +39,8 @@ alloy-simple-request-transport = { path = "../../networks/ethereum/alloy-simple-
alloy-rpc-client = { version = "1", default-features = false }
alloy-provider = { version = "1", default-features = false }
serai-client = { path = "../../substrate/client", default-features = false, features = ["ethereum"] }
serai-primitives = { path = "../../substrate/primitives", default-features = false, features = ["std"] }
serai-client-ethereum = { path = "../../substrate/client/ethereum", default-features = false }
zalloc = { path = "../../common/zalloc" }
log = { version = "0.4", default-features = false, features = ["std"] }

View File

@@ -41,7 +41,8 @@ ethereum-primitives = { package = "serai-processor-ethereum-primitives", path =
ethereum-deployer = { package = "serai-processor-ethereum-deployer", path = "../deployer", default-features = false }
erc20 = { package = "serai-processor-ethereum-erc20", path = "../erc20", default-features = false }
serai-client = { path = "../../../substrate/client", default-features = false, features = ["ethereum"] }
serai-primitives = { path = "../../../substrate/primitives", default-features = false, features = ["std"] }
serai-client-ethereum = { path = "../../../substrate/client/ethereum", default-features = false }
futures-util = { version = "0.3", default-features = false, features = ["std"] }

View File

@@ -21,9 +21,8 @@ use alloy_rpc_types_eth::{BlockId, Log, Filter, TransactionInput, TransactionReq
use alloy_transport::{TransportErrorKind, RpcError};
use alloy_provider::{Provider, RootProvider};
use serai_client::{
primitives::instructions::RefundableInInstruction, networks::ethereum::Address as SeraiAddress,
};
use serai_primitives::instructions::RefundableInInstruction;
use serai_client_ethereum::Address as SeraiAddress;
use ethereum_primitives::LogIndex;
use ethereum_schnorr::{PublicKey, Signature};

View File

@@ -5,9 +5,9 @@ use alloy_sol_types::SolCall;
use alloy_consensus::{TxLegacy, Signed};
use serai_client::{
primitives::SeraiAddress,
primitives::instructions::{InInstruction as SeraiInInstruction, RefundableInInstruction},
use serai_primitives::{
address::SeraiAddress,
instructions::{InInstruction as SeraiInInstruction, RefundableInInstruction},
};
use ethereum_primitives::LogIndex;
@@ -17,8 +17,8 @@ use crate::{InInstruction, tests::*};
impl Test {
pub(crate) fn in_instruction() -> RefundableInInstruction {
RefundableInInstruction {
origin: None,
instruction: SeraiInInstruction::Transfer(SeraiAddress([0xff; 32])),
return_address: None,
instruction: SeraiInInstruction::Transfer { to: SeraiAddress([0xff; 32]) },
}
}
@@ -140,7 +140,7 @@ async fn test_erc20_router_in_instruction() {
input: crate::abi::inInstructionCall::new((
coin.into(),
amount,
borsh::to_vec(shorthand).unwrap().into(),
borsh::to_vec(&shorthand).unwrap().into(),
))
.abi_encode()
.into(),

View File

@@ -20,7 +20,7 @@ use alloy_provider::{
use alloy_node_bindings::{Anvil, AnvilInstance};
use serai_client::networks::ethereum::{ContractDeployment, Address as SeraiEthereumAddress};
use serai_client_ethereum::{ContractDeployment, Address as SeraiEthereumAddress};
use ethereum_schnorr::{PublicKey, Signature};
use ethereum_deployer::Deployer;

View File

@@ -14,7 +14,7 @@ use alloy_simple_request_transport::SimpleRequest;
use alloy_rpc_client::ClientBuilder;
use alloy_provider::{Provider, RootProvider};
use serai_client::primitives::validator_sets::Session;
use serai_primitives::validator_sets::Session;
use serai_env as env;
use serai_db::{Get, DbTxn, create_db};

View File

@@ -3,7 +3,7 @@ use std::collections::HashMap;
use ciphersuite::*;
use ciphersuite_kp256::Secp256k1;
use serai_client::networks::ethereum::Address;
use serai_client_ethereum::Address;
use primitives::{ReceivedOutput, EventualityTracker};

View File

@@ -1,6 +1,6 @@
use alloy_core::primitives::{FixedBytes, Address};
use serai_client::primitives::balance::Amount;
use serai_primitives::balance::Amount;
pub(crate) mod output;
pub(crate) mod transaction;

View File

@@ -7,14 +7,12 @@ use alloy_core::primitives::U256;
use borsh::{BorshSerialize, BorshDeserialize};
use serai_client::{
primitives::{
network_id::ExternalNetworkId,
coin::ExternalCoin,
balance::{Amount, ExternalBalance},
},
networks::ethereum::Address,
use serai_primitives::{
network_id::ExternalNetworkId,
coin::ExternalCoin,
balance::{Amount, ExternalBalance},
};
use serai_client_ethereum::Address;
use primitives::{OutputType, ReceivedOutput};
use ethereum_router::{Coin as EthereumCoin, InInstruction as EthereumInInstruction};

View File

@@ -5,7 +5,7 @@ use frost::dkg::ThresholdKeys;
use alloy_core::primitives::{U256, Address as EthereumAddress};
use serai_client::networks::ethereum::Address;
use serai_client_ethereum::Address;
use scheduler::SignableTransaction;

View File

@@ -6,7 +6,7 @@ use alloy_rpc_types_eth::{Header, BlockNumberOrTag};
use alloy_transport::{RpcError, TransportErrorKind};
use alloy_provider::{Provider, RootProvider};
use serai_client::primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount};
use serai_primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount};
use tokio::task::JoinSet;

View File

@@ -2,10 +2,8 @@ use std::collections::HashMap;
use alloy_core::primitives::U256;
use serai_client::{
primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::ExternalBalance},
networks::ethereum::Address,
};
use serai_primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::ExternalBalance};
use serai_client_ethereum::Address;
use serai_db::Db;

View File

@@ -31,7 +31,8 @@ frost = { package = "modular-frost", path = "../../crypto/frost", default-featur
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "030c60974f0f0306849c1795bca854a3bbb757b4", default-features = false, features = ["std", "multisig"] }
monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "030c60974f0f0306849c1795bca854a3bbb757b4", default-features = false }
serai-client = { path = "../../substrate/client", default-features = false, features = ["monero"] }
serai-primitives = { path = "../../substrate/primitives", default-features = false, features = ["std"] }
serai-client-monero = { path = "../../substrate/client/monero", default-features = false }
zalloc = { path = "../../common/zalloc" }
log = { version = "0.4", default-features = false, features = ["std"] }

View File

@@ -8,7 +8,7 @@ use monero_wallet::{
GuaranteedScanner,
};
use serai_client::networks::monero::Address;
use serai_client_monero::Address;
use primitives::{ReceivedOutput, EventualityTracker};
use crate::{

View File

@@ -7,13 +7,11 @@ use monero_wallet::WalletOutput;
use borsh::{BorshSerialize, BorshDeserialize};
use serai_client::{
primitives::{
coin::ExternalCoin,
balance::{Amount, ExternalBalance},
},
networks::monero::Address,
use serai_primitives::{
coin::ExternalCoin,
balance::{Amount, ExternalBalance},
};
use serai_client_monero::Address;
use primitives::{OutputType, ReceivedOutput};

View File

@@ -2,7 +2,7 @@ use core::future::Future;
use monero_simple_request_rpc::{prelude::*, SimpleRequestTransport};
use serai_client::primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount};
use serai_primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount};
use scanner::ScannerFeed;
use signers::TransactionPublisher;

View File

@@ -9,10 +9,8 @@ use dalek_ff_group::Ed25519;
use monero_wallet::interface::prelude::*;
use serai_client::{
primitives::{coin::ExternalCoin, balance::Amount},
networks::monero::Address,
};
use serai_primitives::{coin::ExternalCoin, balance::Amount};
use serai_client_monero::Address;
use primitives::{OutputType, ReceivedOutput, Payment};
use scanner::{KeyFor, AddressFor, OutputFor, BlockFor};

View File

@@ -39,11 +39,9 @@ async-lock = "3"
simple-request = { path = "../../common/request", version = "0.3", 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 = "030c60974f0f0306849c1795bca854a3bbb757b4", version = "0.1.0", default-features = false, features = ["std"], optional = true }
serai-client-bitcoin = { path = "./bitcoin", optional = true }
serai-client-ethereum = { path = "./ethereum", optional = true }
serai-client-monero = { path = "./monero", optional = true }
[dev-dependencies]
rand_core = "0.6"
@@ -67,9 +65,9 @@ serai-docker-tests = { path = "../../tests/docker" }
serai = ["thiserror/std", "scale", "serde", "serde_json", "multiaddr", "sp-core", "sp-runtime", "frame-system", "simple-request"]
networks = []
bitcoin = ["networks", "dep:bitcoin"]
ethereum = ["networks"]
monero = ["networks", "ciphersuite", "dalek-ff-group", "monero-address"]
bitcoin = ["networks", "serai-client-bitcoin"]
ethereum = ["networks", "serai-client-ethereum"]
monero = ["networks", "serai-client-monero"]
# Assumes the default usage is to use Serai as a DEX, which doesn't actually
# require connecting to a Serai node

View File

@@ -0,0 +1,27 @@
[package]
name = "serai-client-bitcoin"
version = "0.1.0"
description = "Bitcoin client library for the Serai network"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/substrate/client/bitcoin"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = ["serai"]
edition = "2021"
rust-version = "1.85"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
borsh = { version = "1", default-features = false, features = ["derive"] }
serai-primitives = { path = "../../primitives", version = "0.1", default-features = false }
bitcoin = { version = "0.32", default-features = false }
[features]
std = ["borsh/std", "serai-primitives/std", "bitcoin/std"]

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022-2025 Luke Parker
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,3 +1,5 @@
#![no_std]
use core::{str::FromStr, fmt};
use borsh::{BorshSerialize, BorshDeserialize};
@@ -10,7 +12,7 @@ use bitcoin::{
address::{AddressType, NetworkChecked, Address as BAddress},
};
use crate::primitives::address::ExternalAddress;
use serai_primitives::address::ExternalAddress;
// SCALE-encodable representation of Bitcoin addresses, used internally.
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]

View File

@@ -0,0 +1,28 @@
[package]
name = "serai-client-ethereum"
version = "0.1.0"
description = "Ethereum client library for the Serai network"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/substrate/client/ethereum"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = ["serai"]
edition = "2021"
rust-version = "1.85"
[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"] }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
borsh = { version = "1", default-features = false, features = ["derive"] }
serai-primitives = { path = "../../primitives", default-features = false, version = "0.1" }
[features]
std = ["std-shims/std", "borsh/std", "serai-primitives/std"]

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022-2025 Luke Parker
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,9 +1,11 @@
#![no_std]
use core::str::FromStr;
use std::io::Read;
use std_shims::{vec::Vec, io::Read};
use borsh::{BorshSerialize, BorshDeserialize};
use crate::primitives::address::ExternalAddress;
use serai_primitives::address::ExternalAddress;
/// THe maximum amount of gas an address is allowed to specify as its gas limit.
///

View File

@@ -0,0 +1,26 @@
[package]
name = "serai-client-monero"
version = "0.1.0"
description = "Monero client library for the Serai network"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/substrate/client/monero"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = ["serai"]
edition = "2021"
rust-version = "1.85"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
borsh = { version = "1", default-features = false, features = ["std"] }
serai-primitives = { path = "../../primitives", version = "0.1", default-features = false, features = ["std"] }
ciphersuite = { path = "../../../crypto/ciphersuite", default-features = false, features = ["std"] }
dalek-ff-group = { path = "../../../crypto/dalek-ff-group", default-features = false, features = ["std"] }
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "030c60974f0f0306849c1795bca854a3bbb757b4", version = "0.1.0", default-features = false, features = ["std"] }

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022-2025 Luke Parker
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -5,7 +5,7 @@ use ciphersuite::GroupIo;
use monero_address::{Network, AddressType as MoneroAddressType, MoneroAddress};
use crate::primitives::address::ExternalAddress;
use serai_primitives::address::ExternalAddress;
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
enum AddressType {

View File

@@ -0,0 +1,8 @@
#[cfg(feature = "bitcoin")]
pub use serai_client_bitcoin;
#[cfg(feature = "ethereum")]
pub mod serai_client_ethereum;
#[cfg(feature = "monero")]
pub mod serai_client_monero;

View File

@@ -1,8 +0,0 @@
#[cfg(feature = "bitcoin")]
pub mod bitcoin;
#[cfg(feature = "ethereum")]
pub mod ethereum;
#[cfg(feature = "monero")]
pub mod monero;

View File

@@ -46,6 +46,9 @@ frost-schnorrkel = { path = "../../crypto/schnorrkel", default-features = false,
bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["hazmat"], optional = true }
serai-client-bitcoin = { path = "../../substrate/client/bitcoin", default-features = false, optional = true }
serai-client-ethereum = { path = "../../substrate/client/ethereum", default-features = false, optional = true }
[features]
alloc = [
"std-shims/alloc",
@@ -75,4 +78,7 @@ alloc = [
"frost-schnorrkel",
"bitcoin-serai",
"serai-client-bitcoin",
"serai-client-ethereum",
]

View File

@@ -30,4 +30,7 @@ pub mod alloc {
pub use frost_schnorrkel;
pub use bitcoin_serai;
pub use serai_client_bitcoin;
pub use serai_client_ethereum;
}