Update develop to patch-polkadot-sdk

Allows us to finally remove the old `serai-dex/substrate` repository _and_
should have CI pass without issue on `develop` again.

The changes made here should be trivial and maintain all prior
behavior/functionality. The most notable are to `chain_spec.rs`, in order to
still use a SCALE-encoded `GenesisConfig` (avoiding `serde_json`).
This commit is contained in:
Luke Parker
2025-09-21 18:21:18 -04:00
parent 52d15b789c
commit 41bb2c7b2a
102 changed files with 4185 additions and 3472 deletions

6042
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,8 @@
[workspace] [workspace]
resolver = "2" resolver = "2"
members = [ members = [
# Version patches
"patches/parking_lot_core",
"patches/parking_lot",
"patches/zstd",
"patches/rocksdb",
# std patches # std patches
"patches/matches", "patches/matches",
"patches/is-terminal",
# Rewrites/redirects # Rewrites/redirects
"patches/option-ext", "patches/option-ext",
@@ -135,19 +128,7 @@ modular-frost = { path = "crypto/frost" }
# https://github.com/rust-lang-nursery/lazy-static.rs/issues/201 # https://github.com/rust-lang-nursery/lazy-static.rs/issues/201
lazy_static = { git = "https://github.com/rust-lang-nursery/lazy-static.rs", rev = "5735630d46572f1e5377c8f2ba0f79d18f53b10c" } lazy_static = { git = "https://github.com/rust-lang-nursery/lazy-static.rs", rev = "5735630d46572f1e5377c8f2ba0f79d18f53b10c" }
parking_lot_core = { path = "patches/parking_lot_core" } # `matches` has an `std` alternative
parking_lot = { path = "patches/parking_lot" }
# wasmtime pulls in an old version for this
zstd = { path = "patches/zstd" }
# Needed for WAL compression
rocksdb = { path = "patches/rocksdb" }
# 1.0.1 was yanked due to a breaking change (an extra field)
# 2.0 has fewer dependencies and still works within our tree
tiny-bip39 = { path = "patches/tiny-bip39" }
# is-terminal now has an std-based solution with an equivalent API
is-terminal = { path = "patches/is-terminal" }
# So does matches
matches = { path = "patches/matches" } matches = { path = "patches/matches" }
# directories-next was created because directories was unmaintained # directories-next was created because directories was unmaintained
@@ -159,6 +140,7 @@ option-ext = { path = "patches/option-ext" }
directories-next = { path = "patches/directories-next" } directories-next = { path = "patches/directories-next" }
[workspace.lints.clippy] [workspace.lints.clippy]
uninlined_format_args = "allow" # TODO
unwrap_or_default = "allow" unwrap_or_default = "allow"
manual_is_multiple_of = "allow" manual_is_multiple_of = "allow"
incompatible_msrv = "allow" # Manually verified with a GitHub workflow incompatible_msrv = "allow" # Manually verified with a GitHub workflow
@@ -202,7 +184,6 @@ redundant_closure_for_method_calls = "deny"
redundant_else = "deny" redundant_else = "deny"
string_add_assign = "deny" string_add_assign = "deny"
unchecked_duration_subtraction = "deny" unchecked_duration_subtraction = "deny"
uninlined_format_args = "deny"
unnecessary_box_returns = "deny" unnecessary_box_returns = "deny"
unnecessary_join = "deny" unnecessary_join = "deny"
unnecessary_wraps = "deny" unnecessary_wraps = "deny"

View File

@@ -18,7 +18,7 @@ workspace = true
[dependencies] [dependencies]
parity-db = { version = "0.4", default-features = false, optional = true } parity-db = { version = "0.4", default-features = false, optional = true }
rocksdb = { version = "0.21", default-features = false, features = ["zstd"], optional = true } rocksdb = { version = "0.24", default-features = false, features = ["zstd"], optional = true }
[features] [features]
parity-db = ["dep:parity-db"] parity-db = ["dep:parity-db"]

View File

@@ -42,7 +42,7 @@ processor-messages = { package = "serai-processor-messages", path = "../processo
message-queue = { package = "serai-message-queue", path = "../message-queue" } message-queue = { package = "serai-message-queue", path = "../message-queue" }
tributary = { package = "tributary-chain", path = "./tributary" } tributary = { package = "tributary-chain", path = "./tributary" }
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] } sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false, features = ["std"] }
serai-client = { path = "../substrate/client", default-features = false, features = ["serai", "borsh"] } serai-client = { path = "../substrate/client", default-features = false, features = ["serai", "borsh"] }
hex = { version = "0.4", default-features = false, features = ["std"] } hex = { version = "0.4", default-features = false, features = ["std"] }
@@ -57,8 +57,8 @@ libp2p = { version = "0.52", default-features = false, features = ["tokio", "tcp
[dev-dependencies] [dev-dependencies]
tributary = { package = "tributary-chain", path = "./tributary", features = ["tests"] } tributary = { package = "tributary-chain", path = "./tributary", features = ["tests"] }
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] } sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false, features = ["std"] }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false, features = ["std"] }
[features] [features]
longer-reattempts = [] longer-reattempts = []

View File

@@ -12,7 +12,7 @@ use tokio::{
use borsh::BorshSerialize; use borsh::BorshSerialize;
use sp_application_crypto::RuntimePublic; use sp_application_crypto::RuntimePublic;
use serai_client::{ use serai_client::{
primitives::{ExternalNetworkId, Signature, EXTERNAL_NETWORKS}, primitives::{ExternalNetworkId, EXTERNAL_NETWORKS},
validator_sets::primitives::{ExternalValidatorSet, Session}, validator_sets::primitives::{ExternalValidatorSet, Session},
Serai, SeraiError, TemporalSerai, Serai, SeraiError, TemporalSerai,
}; };
@@ -164,7 +164,7 @@ impl<D: Db> CosignEvaluator<D> {
if !keys if !keys
.0 .0
.verify(&cosign_block_msg(cosign.block_number, cosign.block), &Signature(cosign.signature)) .verify(&cosign_block_msg(cosign.block_number, cosign.block), &cosign.signature.into())
{ {
log::warn!("received cosigned block with an invalid signature"); log::warn!("received cosigned block with an invalid signature");
return Ok(()); return Ok(());

View File

@@ -1,3 +1,5 @@
#![expect(clippy::cast_possible_truncation)]
use core::ops::Deref; use core::ops::Deref;
use std::{ use std::{
sync::{OnceLock, Arc}, sync::{OnceLock, Arc},
@@ -269,12 +271,15 @@ async fn handle_processor_message<D: Db, P: P2p>(
coordinator::ProcessorMessage::SignedSlashReport { session, signature } => { coordinator::ProcessorMessage::SignedSlashReport { session, signature } => {
let set = ExternalValidatorSet { network, session: *session }; let set = ExternalValidatorSet { network, session: *session };
let signature: &[u8] = signature.as_ref(); let signature: &[u8] = signature.as_ref();
let signature = serai_client::Signature(signature.try_into().unwrap()); let signature = <[u8; 64]>::try_from(signature).unwrap();
let signature: serai_client::Signature = signature.into();
let slashes = crate::tributary::SlashReport::get(&txn, set) let slashes = crate::tributary::SlashReport::get(&txn, set)
.expect("signed slash report despite not having slash report locally"); .expect("signed slash report despite not having slash report locally");
let slashes_pubs = let slashes_pubs = slashes
slashes.iter().map(|(address, points)| (Public(*address), *points)).collect::<Vec<_>>(); .iter()
.map(|(address, points)| (Public::from(*address), *points))
.collect::<Vec<_>>();
let tx = serai_client::SeraiValidatorSets::report_slashes( let tx = serai_client::SeraiValidatorSets::report_slashes(
network, network,
@@ -284,7 +289,7 @@ async fn handle_processor_message<D: Db, P: P2p>(
.collect::<Vec<_>>() .collect::<Vec<_>>()
.try_into() .try_into()
.unwrap(), .unwrap(),
signature.clone(), signature,
); );
loop { loop {
@@ -501,7 +506,7 @@ async fn handle_processor_message<D: Db, P: P2p>(
&mut txn, &mut txn,
key, key,
spec, spec,
&KeyPair(Public(substrate_key), network_key.try_into().unwrap()), &KeyPair(Public::from(substrate_key), network_key.try_into().unwrap()),
id.attempt, id.attempt,
); );

View File

@@ -55,7 +55,9 @@ pub fn new_spec<R: RngCore + CryptoRng>(
let set_participants = keys let set_participants = keys
.iter() .iter()
.map(|key| (sr25519::Public((<Ristretto as Ciphersuite>::generator() * **key).to_bytes()), 1)) .map(|key| {
(sr25519::Public::from((<Ristretto as Ciphersuite>::generator() * **key).to_bytes()), 1)
})
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let res = TributarySpec::new(serai_block, start_time, set, set_participants); let res = TributarySpec::new(serai_block, start_time, set, set_participants);

View File

@@ -316,7 +316,8 @@ async fn dkg_test() {
OsRng.fill_bytes(&mut substrate_key); OsRng.fill_bytes(&mut substrate_key);
let mut network_key = vec![0; usize::try_from((OsRng.next_u64() % 32) + 32).unwrap()]; let mut network_key = vec![0; usize::try_from((OsRng.next_u64() % 32) + 32).unwrap()];
OsRng.fill_bytes(&mut network_key); OsRng.fill_bytes(&mut network_key);
let key_pair = KeyPair(serai_client::Public(substrate_key), network_key.try_into().unwrap()); let key_pair =
KeyPair(serai_client::Public::from(substrate_key), network_key.try_into().unwrap());
let mut txs = vec![]; let mut txs = vec![];
for (i, key) in keys.iter().enumerate() { for (i, key) in keys.iter().enumerate() {
@@ -361,7 +362,7 @@ async fn dkg_test() {
assert_eq!(self.key_pair, key_pair); assert_eq!(self.key_pair, key_pair);
assert!(signature.verify( assert!(signature.verify(
&*serai_client::validator_sets::primitives::set_keys_message(&set, &[], &key_pair), &*serai_client::validator_sets::primitives::set_keys_message(&set, &[], &key_pair),
&serai_client::Public( &serai_client::Public::from(
dkg_musig::musig_key_vartime::<Ristretto>( dkg_musig::musig_key_vartime::<Ristretto>(
serai_client::validator_sets::primitives::musig_context(set.into()), serai_client::validator_sets::primitives::musig_context(set.into()),
&self.spec.validators().into_iter().map(|(validator, _)| validator).collect::<Vec<_>>() &self.spec.validators().into_iter().map(|(validator, _)| validator).collect::<Vec<_>>()

View File

@@ -9,7 +9,7 @@ use ciphersuite::{group::GroupEncoding, Ciphersuite};
use frost::dkg::Participant; use frost::dkg::Participant;
use scale::{Encode, Decode}; use scale::{Encode, Decode};
use serai_client::{Signature, validator_sets::primitives::KeyPair}; use serai_client::validator_sets::primitives::KeyPair;
use tributary::{Signed, TransactionKind, TransactionTrait}; use tributary::{Signed, TransactionKind, TransactionTrait};
@@ -554,7 +554,7 @@ impl<
self.spec.set(), self.spec.set(),
removed.into_iter().map(|key| key.to_bytes().into()).collect(), removed.into_iter().map(|key| key.to_bytes().into()).collect(),
key_pair, key_pair,
Signature(sig), sig.into(),
) )
.await; .await;
} }

View File

@@ -295,7 +295,7 @@ impl<T: DbTxn> DkgConfirmer<'_, T> {
threshold_i_map_to_keys_and_musig_i_map(self.spec, &self.removed, self.key, preprocesses).1; threshold_i_map_to_keys_and_musig_i_map(self.spec, &self.removed, self.key, preprocesses).1;
let msg = set_keys_message( let msg = set_keys_message(
&self.spec.set(), &self.spec.set(),
&self.removed.iter().map(|key| Public(key.to_bytes())).collect::<Vec<_>>(), &self.removed.iter().map(|key| Public::from(key.to_bytes())).collect::<Vec<_>>(),
key_pair, key_pair,
); );
self.signing_protocol().share_internal(&participants, preprocesses, &msg) self.signing_protocol().share_internal(&participants, preprocesses, &msg)

View File

@@ -1,3 +1,5 @@
#![expect(clippy::cast_possible_truncation)]
use core::fmt::Debug; use core::fmt::Debug;
use std::{ use std::{

View File

@@ -7,10 +7,11 @@ db-urls = ["https://github.com/rustsec/advisory-db"]
yanked = "deny" yanked = "deny"
ignore = [ ignore = [
"RUSTSEC-2020-0168", # mach is unmaintained
"RUSTSEC-2021-0139", # https://github.com/serai-dex/serai/228
"RUSTSEC-2022-0061", # https://github.com/serai-dex/serai/227 "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
"RUSTSEC-2024-0436", # paste is unmaintained
"RUSTSEC-2024-0384", # instant is unmaintained, fixed on `next`
"RUSTSEC-2025-0057", # fxhash is unmaintained, fixed with bytecodealliance/wasmtime/pull/11634
] ]
[licenses] [licenses]
@@ -27,57 +28,58 @@ allow = [
"BSD-2-Clause", "BSD-2-Clause",
"BSD-3-Clause", "BSD-3-Clause",
"ISC", "ISC",
"Unicode-DFS-2016", "Zlib",
"OpenSSL", "Unicode-3.0",
"CDLA-Permissive-2.0",
# Non-invasive copyleft # Non-invasive copyleft
"MPL-2.0", # "MPL-2.0", # Commented as it's not currently in-use within the Serai tree
"Apache-2.0", "Apache-2.0",
"Apache-2.0 WITH LLVM-exception", "Apache-2.0 WITH LLVM-exception",
"GPL-3.0 WITH Classpath-exception-2.0", "GPL-3.0-or-later WITH Classpath-exception-2.0",
] ]
exceptions = [ exceptions = [
{ allow = ["AGPL-3.0"], name = "serai-env" }, { allow = ["AGPL-3.0-only"], name = "serai-env" },
{ allow = ["AGPL-3.0"], name = "ethereum-serai" }, { allow = ["AGPL-3.0-only"], name = "ethereum-serai" },
{ allow = ["AGPL-3.0"], name = "serai-ethereum-relayer" }, { allow = ["AGPL-3.0-only"], name = "serai-ethereum-relayer" },
{ allow = ["AGPL-3.0"], name = "serai-message-queue" }, { allow = ["AGPL-3.0-only"], name = "serai-message-queue" },
{ allow = ["AGPL-3.0"], name = "serai-processor-messages" }, { allow = ["AGPL-3.0-only"], name = "serai-processor-messages" },
{ allow = ["AGPL-3.0"], name = "serai-processor" }, { allow = ["AGPL-3.0-only"], name = "serai-processor" },
{ allow = ["AGPL-3.0"], name = "tributary-chain" }, { allow = ["AGPL-3.0-only"], name = "tributary-chain" },
{ allow = ["AGPL-3.0"], name = "serai-coordinator" }, { allow = ["AGPL-3.0-only"], name = "serai-coordinator" },
{ allow = ["AGPL-3.0"], name = "serai-coins-pallet" }, { allow = ["AGPL-3.0-only"], name = "serai-coins-pallet" },
{ allow = ["AGPL-3.0"], name = "serai-dex-pallet" }, { allow = ["AGPL-3.0-only"], name = "serai-dex-pallet" },
{ allow = ["AGPL-3.0"], name = "serai-genesis-liquidity-pallet" }, { allow = ["AGPL-3.0-only"], name = "serai-genesis-liquidity-pallet" },
{ allow = ["AGPL-3.0"], name = "serai-emissions-pallet" }, { allow = ["AGPL-3.0-only"], name = "serai-emissions-pallet" },
{ allow = ["AGPL-3.0"], name = "serai-economic-security-pallet" }, { allow = ["AGPL-3.0-only"], name = "serai-economic-security-pallet" },
{ allow = ["AGPL-3.0"], name = "serai-in-instructions-pallet" }, { allow = ["AGPL-3.0-only"], name = "serai-in-instructions-pallet" },
{ allow = ["AGPL-3.0"], name = "serai-validator-sets-pallet" }, { allow = ["AGPL-3.0-only"], name = "serai-validator-sets-pallet" },
{ allow = ["AGPL-3.0"], name = "serai-signals-pallet" }, { allow = ["AGPL-3.0-only"], name = "serai-signals-pallet" },
{ allow = ["AGPL-3.0"], name = "serai-runtime" }, { allow = ["AGPL-3.0-only"], name = "serai-runtime" },
{ allow = ["AGPL-3.0"], name = "serai-node" }, { allow = ["AGPL-3.0-only"], name = "serai-node" },
{ allow = ["AGPL-3.0"], name = "serai-orchestrator" }, { allow = ["AGPL-3.0-only"], name = "serai-orchestrator" },
{ allow = ["AGPL-3.0"], name = "mini-serai" }, { allow = ["AGPL-3.0-only"], name = "mini-serai" },
{ allow = ["AGPL-3.0"], name = "serai-docker-tests" }, { allow = ["AGPL-3.0-only"], name = "serai-docker-tests" },
{ allow = ["AGPL-3.0"], name = "serai-message-queue-tests" }, { allow = ["AGPL-3.0-only"], name = "serai-message-queue-tests" },
{ allow = ["AGPL-3.0"], name = "serai-processor-tests" }, { allow = ["AGPL-3.0-only"], name = "serai-processor-tests" },
{ allow = ["AGPL-3.0"], name = "serai-coordinator-tests" }, { allow = ["AGPL-3.0-only"], name = "serai-coordinator-tests" },
{ allow = ["AGPL-3.0"], name = "serai-full-stack-tests" }, { allow = ["AGPL-3.0-only"], name = "serai-full-stack-tests" },
{ allow = ["AGPL-3.0"], name = "serai-reproducible-runtime-tests" }, { allow = ["AGPL-3.0-only"], name = "serai-reproducible-runtime-tests" },
] ]
[[licenses.clarify]] [[licenses.clarify]]
@@ -94,7 +96,11 @@ wildcards = "warn"
highlight = "all" highlight = "all"
deny = [ deny = [
{ name = "serde_derive", version = ">=1.0.172, <1.0.185" }, { name = "serde_derive", version = ">=1.0.172, <1.0.185" },
{ name = "hashbrown", version = ">=0.15" }, { name = "hashbrown", version = "=0.15.0" },
# Legacy which _no one_ should use anymore
{ name = "is-terminal", version = "*" },
# Stop introduction into the tree without realizing it
{ name = "once_cell_polyfill", version = "*" },
] ]
[sources] [sources]
@@ -103,8 +109,7 @@ unknown-git = "deny"
allow-registry = ["https://github.com/rust-lang/crates.io-index"] allow-registry = ["https://github.com/rust-lang/crates.io-index"]
allow-git = [ allow-git = [
"https://github.com/rust-lang-nursery/lazy-static.rs", "https://github.com/rust-lang-nursery/lazy-static.rs",
"https://github.com/kayabaNerve/elliptic-curves",
"https://github.com/monero-oxide/monero-oxide", "https://github.com/monero-oxide/monero-oxide",
"https://github.com/serai-dex/substrate-bip39",
"https://github.com/serai-dex/substrate",
"https://github.com/serai-dex/patch-polkadot-sdk", "https://github.com/serai-dex/patch-polkadot-sdk",
] ]

View File

@@ -1,3 +1,5 @@
#![allow(deprecated)]
use group::ff::PrimeField; use group::ff::PrimeField;
use k256::{ use k256::{
elliptic_curve::{ops::Reduce, point::AffineCoordinates, sec1::ToEncodedPoint}, elliptic_curve::{ops::Reduce, point::AffineCoordinates, sec1::ToEncodedPoint},

View File

@@ -1,3 +1,5 @@
#![allow(deprecated)]
use rand_core::OsRng; use rand_core::OsRng;
use group::ff::{Field, PrimeField}; use group::ff::{Field, PrimeField};

View File

@@ -1,3 +1,5 @@
#![allow(deprecated)]
use std::{sync::Arc, collections::HashMap}; use std::{sync::Arc, collections::HashMap};
use rand_core::OsRng; use rand_core::OsRng;

View File

@@ -1,14 +0,0 @@
[package]
name = "is-terminal"
version = "0.4.10"
description = "is-terminal written around std::io::IsTerminal"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/patches/is-terminal"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = []
edition = "2021"
rust-version = "1.70"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

View File

@@ -1 +0,0 @@
pub use std::io::IsTerminal;

View File

@@ -1,17 +0,0 @@
[package]
name = "parking_lot"
version = "0.11.2"
description = "parking_lot which patches to the latest update"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/patches/parking_lot"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = []
edition = "2021"
rust-version = "1.70"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
parking_lot = "0.12"

View File

@@ -1 +0,0 @@
pub use parking_lot::*;

View File

@@ -1,17 +0,0 @@
[package]
name = "parking_lot_core"
version = "0.8.6"
description = "parking_lot_core which patches to the latest update"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/patches/parking_lot_core"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = []
edition = "2021"
rust-version = "1.70"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
parking_lot_core = "0.9"

View File

@@ -1 +0,0 @@
pub use parking_lot_core::*;

View File

@@ -1,26 +0,0 @@
[package]
name = "rocksdb"
version = "0.21.0"
description = "rocksdb which patches to the latest update"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/patches/rocksdb"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = []
edition = "2021"
rust-version = "1.70"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
rocksdb = { version = "0.22", default-features = false }
[features]
jemalloc = []
snappy = ["rocksdb/snappy"]
lz4 = ["rocksdb/lz4"]
zstd = ["rocksdb/zstd"]
zlib = ["rocksdb/zlib"]
bzip2 = ["rocksdb/bzip2"]
default = ["snappy", "lz4", "zstd", "zlib", "bzip2"]

View File

@@ -1 +0,0 @@
pub use rocksdb::*;

View File

@@ -1,24 +0,0 @@
[package]
name = "tiny-bip39"
version = "1.0.2"
description = "tiny-bip39 which patches to the latest update"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/patches/tiny-bip39"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = []
edition = "2021"
rust-version = "1.70"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.cargo-machete]
ignored = ["tiny-bip39"]
[lib]
name = "bip39"
path = "src/lib.rs"
[dependencies]
tiny-bip39 = "2"

View File

@@ -1 +0,0 @@
pub use bip39::*;

View File

@@ -1,17 +0,0 @@
[package]
name = "zstd"
version = "0.11.2+zstd.1.5.2"
description = "zstd which patches to the latest update"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/patches/zstd"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = []
edition = "2021"
rust-version = "1.70"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
zstd = "0.13"

View File

@@ -1 +0,0 @@
pub use zstd::*;

View File

@@ -76,7 +76,7 @@ message-queue = { package = "serai-message-queue", path = "../message-queue", op
[dev-dependencies] [dev-dependencies]
frost = { package = "modular-frost", path = "../crypto/frost", features = ["tests"] } frost = { package = "modular-frost", path = "../crypto/frost", features = ["tests"] }
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] } sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false, features = ["std"] }
ethereum-serai = { path = "../networks/ethereum", default-features = false, features = ["tests"] } ethereum-serai = { path = "../networks/ethereum", default-features = false, features = ["tests"] }

View File

@@ -1,3 +1,5 @@
#![expect(clippy::cast_possible_truncation)]
use std::collections::HashMap; use std::collections::HashMap;
use scale::{Encode, Decode}; use scale::{Encode, Decode};

View File

@@ -1,3 +1,5 @@
#![allow(deprecated)]
use core::{fmt, time::Duration}; use core::{fmt, time::Duration};
use std::{ use std::{
sync::Arc, sync::Arc,

View File

@@ -183,7 +183,7 @@ impl SlashReportSigner {
.report .report
.clone() .clone()
.into_iter() .into_iter()
.map(|(validator, points)| (Public(validator), points)) .map(|(validator, points)| (Public::from(validator), points))
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
), ),
) { ) {

View File

@@ -118,7 +118,7 @@ fn test_cosigner() {
assert_eq!(signed_block, block); assert_eq!(signed_block, block);
assert!(Public::from_raw(keys[&participant_one].group_key().to_bytes()).verify( assert!(Public::from_raw(keys[&participant_one].group_key().to_bytes()).verify(
&cosign_block_msg(block_number, block), &cosign_block_msg(block_number, block),
&Signature(signature.try_into().unwrap()) &Signature::from(<[u8; 64]>::try_from(signature).unwrap())
)); ));
} }
_ => panic!("didn't get cosigned block back"), _ => panic!("didn't get cosigned block back"),

View File

@@ -125,7 +125,7 @@ pub fn test_key_gen<N: Network>() {
let KeyConfirmed { mut substrate_keys, mut network_keys } = key_gen.confirm( let KeyConfirmed { mut substrate_keys, mut network_keys } = key_gen.confirm(
&mut txn, &mut txn,
ID.session, ID.session,
&KeyPair(sr25519::Public(res.0), res.1.clone().try_into().unwrap()), &KeyPair(sr25519::Public::from(res.0), res.1.clone().try_into().unwrap()),
); );
txn.commit(); txn.commit();

View File

@@ -17,18 +17,18 @@ workspace = true
[dependencies] [dependencies]
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
borsh = { version = "1", default-features = false, features = ["derive", "de_strict_order"], optional = true } borsh = { version = "1", default-features = false, features = ["derive", "de_strict_order"], optional = true }
serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true } serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true }
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-consensus-babe = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-consensus-grandpa = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-consensus-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
serai-primitives = { path = "../primitives", version = "0.1", default-features = false } serai-primitives = { path = "../primitives", version = "0.1", default-features = false }
serai-coins-primitives = { path = "../coins/primitives", version = "0.1", default-features = false } serai-coins-primitives = { path = "../coins/primitives", version = "0.1", default-features = false }
@@ -41,7 +41,6 @@ serai-signals-primitives = { path = "../signals/primitives", version = "0.1", de
[features] [features]
std = [ std = [
"scale/std", "scale/std",
"scale-info/std",
"borsh?/std", "borsh?/std",
"serde?/std", "serde?/std",
@@ -52,6 +51,7 @@ std = [
"sp-consensus-babe/std", "sp-consensus-babe/std",
"sp-consensus-grandpa/std", "sp-consensus-grandpa/std",
"frame-system/std",
"frame-support/std", "frame-support/std",
"serai-primitives/std", "serai-primitives/std",

View File

@@ -2,7 +2,9 @@ use sp_consensus_babe::EquivocationProof;
use serai_primitives::{Header, SeraiAddress}; use serai_primitives::{Header, SeraiAddress};
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
pub struct ReportEquivocation { pub struct ReportEquivocation {
pub equivocation_proof: alloc::boxed::Box<EquivocationProof<Header>>, pub equivocation_proof: alloc::boxed::Box<EquivocationProof<Header>>,
pub key_owner_proof: SeraiAddress, pub key_owner_proof: SeraiAddress,
@@ -10,7 +12,9 @@ pub struct ReportEquivocation {
// We could define a Babe Config here and use the literal pallet_babe::Call // We could define a Babe Config here and use the literal pallet_babe::Call
// The disadvantage to this would be the complexity and presence of junk fields such as `__Ignore` // The disadvantage to this would be the complexity and presence of junk fields such as `__Ignore`
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
pub enum Call { pub enum Call {
report_equivocation(ReportEquivocation), report_equivocation(ReportEquivocation),
report_equivocation_unsigned(ReportEquivocation), report_equivocation_unsigned(ReportEquivocation),

View File

@@ -3,7 +3,9 @@ use serai_primitives::{Balance, SeraiAddress};
pub use serai_coins_primitives as primitives; pub use serai_coins_primitives as primitives;
use primitives::OutInstructionWithBalance; use primitives::OutInstructionWithBalance;
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
@@ -13,7 +15,9 @@ pub enum Call {
burn_with_instruction { instruction: OutInstructionWithBalance }, burn_with_instruction { instruction: OutInstructionWithBalance },
} }
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]

View File

@@ -5,7 +5,9 @@ use serai_primitives::*;
type PoolId = ExternalCoin; type PoolId = ExternalCoin;
type MaxSwapPathLength = sp_core::ConstU32<3>; type MaxSwapPathLength = sp_core::ConstU32<3>;
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
pub enum Call { pub enum Call {
@@ -38,7 +40,9 @@ pub enum Call {
}, },
} }
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
pub enum Event { pub enum Event {

View File

@@ -1,6 +1,8 @@
use serai_primitives::ExternalNetworkId; use serai_primitives::ExternalNetworkId;
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Event { pub enum Event {

View File

@@ -3,14 +3,18 @@ pub use serai_genesis_liquidity_primitives as primitives;
use serai_primitives::*; use serai_primitives::*;
use primitives::*; use primitives::*;
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Call { pub enum Call {
remove_coin_liquidity { balance: ExternalBalance }, remove_coin_liquidity { balance: ExternalBalance },
oraclize_values { values: Values, signature: Signature }, oraclize_values { values: Values, signature: Signature },
} }
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Event { pub enum Event {

View File

@@ -2,19 +2,25 @@ use sp_consensus_grandpa::EquivocationProof;
use serai_primitives::{BlockNumber, SeraiAddress}; use serai_primitives::{BlockNumber, SeraiAddress};
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
pub struct ReportEquivocation { pub struct ReportEquivocation {
pub equivocation_proof: alloc::boxed::Box<EquivocationProof<[u8; 32], BlockNumber>>, pub equivocation_proof: alloc::boxed::Box<EquivocationProof<[u8; 32], BlockNumber>>,
pub key_owner_proof: SeraiAddress, pub key_owner_proof: SeraiAddress,
} }
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
pub enum Call { pub enum Call {
report_equivocation(ReportEquivocation), report_equivocation(ReportEquivocation),
report_equivocation_unsigned(ReportEquivocation), report_equivocation_unsigned(ReportEquivocation),
} }
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
pub enum Event { pub enum Event {

View File

@@ -3,7 +3,9 @@ use serai_primitives::*;
pub use serai_in_instructions_primitives as primitives; pub use serai_in_instructions_primitives as primitives;
use primitives::SignedBatch; use primitives::SignedBatch;
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
@@ -11,7 +13,9 @@ pub enum Call {
execute_batch { batch: SignedBatch }, execute_batch { batch: SignedBatch },
} }
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]

View File

@@ -2,6 +2,7 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![expect(clippy::cast_possible_truncation)]
extern crate alloc; extern crate alloc;
@@ -31,7 +32,9 @@ pub mod grandpa;
pub mod tx; pub mod tx;
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
pub enum Call { pub enum Call {
Timestamp(timestamp::Call), Timestamp(timestamp::Call),
Coins(coins::Call), Coins(coins::Call),
@@ -46,12 +49,16 @@ pub enum Call {
} }
// TODO: Remove this // TODO: Remove this
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
pub enum TransactionPaymentEvent { pub enum TransactionPaymentEvent {
TransactionFeePaid { who: serai_primitives::SeraiAddress, actual_fee: u64, tip: u64 }, TransactionFeePaid { who: serai_primitives::SeraiAddress, actual_fee: u64, tip: u64 },
} }
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
pub enum Event { pub enum Event {
System(system::Event), System(system::Event),
Timestamp, Timestamp,
@@ -69,7 +76,9 @@ pub enum Event {
Grandpa(grandpa::Event), Grandpa(grandpa::Event),
} }
#[derive(Clone, Copy, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, Copy, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
pub struct Extra { pub struct Extra {
@@ -80,7 +89,9 @@ pub struct Extra {
pub tip: u64, pub tip: u64,
} }
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]

View File

@@ -1,6 +1,8 @@
use serai_primitives::{Balance, SeraiAddress}; use serai_primitives::{Balance, SeraiAddress};
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Call { pub enum Call {
@@ -8,7 +10,9 @@ pub enum Call {
transfer { to: SeraiAddress, balance: Balance }, transfer { to: SeraiAddress, balance: Balance },
} }
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Event { pub enum Event {

View File

@@ -5,7 +5,9 @@ use serai_validator_sets_primitives::ValidatorSet;
pub use serai_signals_primitives as primitives; pub use serai_signals_primitives as primitives;
use primitives::SignalId; use primitives::SignalId;
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
@@ -17,7 +19,9 @@ pub enum Call {
stand_against { signal_id: SignalId, for_network: NetworkId }, stand_against { signal_id: SignalId, for_network: NetworkId },
} }
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]

View File

@@ -1,13 +1,15 @@
use frame_support::dispatch::{DispatchInfo, DispatchError}; use frame_system::DispatchEventInfo;
use frame_support::sp_runtime::DispatchError;
use serai_primitives::SeraiAddress; use serai_primitives::SeraiAddress;
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
pub enum Event { pub enum Event {
ExtrinsicSuccess { dispatch_info: DispatchInfo }, ExtrinsicSuccess { dispatch_info: DispatchEventInfo },
ExtrinsicFailed { dispatch_error: DispatchError, dispatch_info: DispatchInfo }, ExtrinsicFailed { dispatch_error: DispatchError, dispatch_info: DispatchEventInfo },
CodeUpdated, CodeUpdated,
NewAccount { account: SeraiAddress }, NewAccount { account: SeraiAddress },
KilledAccount { account: SeraiAddress }, KilledAccount { account: SeraiAddress },
Remarked { sender: SeraiAddress, hash: [u8; 32] },
} }

View File

@@ -1,4 +1,6 @@
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
pub enum Call { pub enum Call {

View File

@@ -1,3 +1,5 @@
#![allow(deprecated)]
use scale::Encode; use scale::Encode;
use sp_core::sr25519::{Public, Signature}; use sp_core::sr25519::{Public, Signature};
@@ -8,18 +10,11 @@ use serai_primitives::SeraiAddress;
use frame_support::dispatch::GetDispatchInfo; use frame_support::dispatch::GetDispatchInfo;
pub trait TransactionMember: pub trait TransactionMember:
Clone + PartialEq + Eq + core::fmt::Debug + scale::Encode + scale::Decode + scale_info::TypeInfo Clone + PartialEq + Eq + core::fmt::Debug + scale::Encode + scale::Decode
{ {
} }
impl< impl<T: Clone + PartialEq + Eq + core::fmt::Debug + scale::Encode + scale::Decode> TransactionMember
T: Clone for T
+ PartialEq
+ Eq
+ core::fmt::Debug
+ scale::Encode
+ scale::Decode
+ scale_info::TypeInfo,
> TransactionMember for T
{ {
} }
@@ -29,8 +24,8 @@ type TransactionDecodeAs<Extra> = (crate::Call, Option<(SeraiAddress, Signature,
// We use our own Transaction struct, over UncheckedExtrinsic, for more control, a bit more // We use our own Transaction struct, over UncheckedExtrinsic, for more control, a bit more
// simplicity, and in order to be immune to https://github.com/paritytech/polkadot-sdk/issues/2947 // simplicity, and in order to be immune to https://github.com/paritytech/polkadot-sdk/issues/2947
#[allow(private_bounds)] #[allow(clippy::multiple_bound_locations)]
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Debug, scale::DecodeWithMemTracking)]
pub struct Transaction< pub struct Transaction<
Call: 'static + TransactionMember + From<crate::Call>, Call: 'static + TransactionMember + From<crate::Call>,
Extra: 'static + TransactionMember, Extra: 'static + TransactionMember,
@@ -69,16 +64,6 @@ impl<Call: 'static + TransactionMember + From<crate::Call>, Extra: 'static + Tra
Ok(Self { call, mapped_call, signature }) Ok(Self { call, mapped_call, signature })
} }
} }
impl<Call: 'static + TransactionMember + From<crate::Call>, Extra: 'static + TransactionMember>
scale_info::TypeInfo for Transaction<Call, Extra>
{
type Identity = TransactionDecodeAs<Extra>;
// Define the type info as the info of the type equivalent to what we encode as
fn type_info() -> scale_info::Type {
TransactionDecodeAs::<Extra>::type_info()
}
}
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
mod _serde { mod _serde {
@@ -129,23 +114,14 @@ impl<
impl< impl<
Call: 'static + TransactionMember + From<crate::Call> + TryInto<crate::Call>, Call: 'static + TransactionMember + From<crate::Call> + TryInto<crate::Call>,
Extra: 'static + TransactionMember, Extra: 'static + TransactionMember,
> frame_support::traits::ExtrinsicCall for Transaction<Call, Extra> > frame_support::sp_runtime::traits::ExtrinsicCall for Transaction<Call, Extra>
{ {
type Call = Call;
fn call(&self) -> &Call { fn call(&self) -> &Call {
&self.mapped_call &self.mapped_call
} }
} }
impl<
Call: 'static + TransactionMember + From<crate::Call>,
Extra: 'static + TransactionMember + sp_runtime::traits::SignedExtension,
> sp_runtime::traits::ExtrinsicMetadata for Transaction<Call, Extra>
{
type SignedExtensions = Extra;
const VERSION: u8 = 0;
}
impl< impl<
Call: 'static + TransactionMember + From<crate::Call> + GetDispatchInfo, Call: 'static + TransactionMember + From<crate::Call> + GetDispatchInfo,
Extra: 'static + TransactionMember, Extra: 'static + TransactionMember,
@@ -156,9 +132,10 @@ impl<
} }
} }
use sp_runtime::generic::ExtrinsicFormat;
impl< impl<
Call: 'static + TransactionMember + From<crate::Call>, Call: 'static + TransactionMember + From<crate::Call> + sp_runtime::traits::Dispatchable,
Extra: 'static + TransactionMember + sp_runtime::traits::SignedExtension, Extra: 'static + TransactionMember + sp_runtime::traits::TransactionExtension<Call>,
> sp_runtime::traits::BlindCheckable for Transaction<Call, Extra> > sp_runtime::traits::BlindCheckable for Transaction<Call, Extra>
{ {
type Checked = sp_runtime::generic::CheckedExtrinsic<Public, Call, Extra>; type Checked = sp_runtime::generic::CheckedExtrinsic<Public, Call, Extra>;
@@ -168,19 +145,33 @@ impl<
) -> Result<Self::Checked, sp_runtime::transaction_validity::TransactionValidityError> { ) -> Result<Self::Checked, sp_runtime::transaction_validity::TransactionValidityError> {
Ok(match self.signature { Ok(match self.signature {
Some((signer, signature, extra)) => { Some((signer, signature, extra)) => {
if !signature.verify( if !signature
(&self.call, &extra, extra.additional_signed()?).encode().as_slice(), .verify((&self.call, &extra, extra.implicit()?).encode().as_slice(), &signer.into())
&signer.into(), {
) {
Err(sp_runtime::transaction_validity::InvalidTransaction::BadProof)? Err(sp_runtime::transaction_validity::InvalidTransaction::BadProof)?
} }
sp_runtime::generic::CheckedExtrinsic { sp_runtime::generic::CheckedExtrinsic {
signed: Some((signer.into(), extra)), format: ExtrinsicFormat::Signed(signer.into(), extra),
function: self.mapped_call, function: self.mapped_call,
} }
} }
None => sp_runtime::generic::CheckedExtrinsic { signed: None, function: self.mapped_call }, None => sp_runtime::generic::CheckedExtrinsic {
format: ExtrinsicFormat::Bare,
function: self.mapped_call,
},
}) })
} }
} }
impl<
Call: 'static + TransactionMember + From<crate::Call> + TryInto<crate::Call>,
Extra: 'static + TransactionMember,
> frame_support::traits::InherentBuilder for Transaction<Call, Extra>
{
/// Panics if the inherent isn't supported.
// TODO: Don't panic here
fn new_inherent(call: Self::Call) -> Self {
sp_runtime::traits::Extrinsic::new(call, None).expect("trying to build an unsupported inherent")
}
}

View File

@@ -5,7 +5,9 @@ pub use serai_validator_sets_primitives as primitives;
use serai_primitives::*; use serai_primitives::*;
use serai_validator_sets_primitives::*; use serai_validator_sets_primitives::*;
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
pub enum Call { pub enum Call {
@@ -34,7 +36,9 @@ pub enum Call {
}, },
} }
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[derive(
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))] #[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]

View File

@@ -28,9 +28,9 @@ serde_json = { version = "1", optional = true }
serai-abi = { path = "../abi", version = "0.1" } serai-abi = { path = "../abi", version = "0.1" }
multiaddr = { version = "0.18", optional = true } multiaddr = { version = "0.18", optional = true }
sp-core = { git = "https://github.com/serai-dex/substrate", optional = true } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", optional = true }
sp-runtime = { git = "https://github.com/serai-dex/substrate", optional = true } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", optional = true }
frame-system = { git = "https://github.com/serai-dex/substrate", optional = true } frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", optional = true }
async-lock = "3" async-lock = "3"

View File

@@ -1,3 +1,5 @@
#![expect(clippy::cast_possible_truncation)]
#[cfg(feature = "networks")] #[cfg(feature = "networks")]
pub mod networks; pub mod networks;

View File

@@ -290,7 +290,7 @@ impl Serai {
self self
.0 .0
.rpc() .rpc()
.system_account_next_index(&sp_core::sr25519::Public(address.0).to_string()) .system_account_next_index(&sp_core::sr25519::Public::from(address.0).to_string())
.await .await
.map_err(|_| SeraiError::ConnectionError) .map_err(|_| SeraiError::ConnectionError)
} }

View File

@@ -8,7 +8,7 @@ use ciphersuite::Ciphersuite;
use dkg_musig::musig; use dkg_musig::musig;
use schnorrkel::Schnorrkel; use schnorrkel::Schnorrkel;
use sp_core::{sr25519::Signature, Pair as PairTrait}; use sp_core::Pair as PairTrait;
use serai_abi::{ use serai_abi::{
genesis_liquidity::primitives::{oraclize_values_message, Values}, genesis_liquidity::primitives::{oraclize_values_message, Values},
@@ -114,6 +114,6 @@ async fn set_values(serai: &Serai, values: &Values) {
// oraclize values // oraclize values
let _ = let _ =
publish_tx(serai, &SeraiGenesisLiquidity::oraclize_values(*values, Signature(sig.to_bytes()))) publish_tx(serai, &SeraiGenesisLiquidity::oraclize_values(*values, sig.to_bytes().into()))
.await; .await;
} }

View File

@@ -4,10 +4,7 @@ use serai_abi::primitives::NetworkId;
use zeroize::Zeroizing; use zeroize::Zeroizing;
use rand_core::OsRng; use rand_core::OsRng;
use sp_core::{ use sp_core::{sr25519::Pair, Pair as PairTrait};
sr25519::{Pair, Signature},
Pair as PairTrait,
};
use dalek_ff_group::Ristretto; use dalek_ff_group::Ristretto;
use ciphersuite::Ciphersuite; use ciphersuite::Ciphersuite;
@@ -69,7 +66,7 @@ pub async fn set_keys(
set.network, set.network,
vec![].try_into().unwrap(), vec![].try_into().unwrap(),
key_pair.clone(), key_pair.clone(),
Signature(sig.to_bytes()), sig.to_bytes().into(),
), ),
) )
.await; .await;

View File

@@ -32,7 +32,7 @@ fn get_random_key_pair() -> KeyPair {
OsRng.fill_bytes(&mut ristretto_key); OsRng.fill_bytes(&mut ristretto_key);
let mut external_key = vec![0; 33]; let mut external_key = vec![0; 33];
OsRng.fill_bytes(&mut external_key); OsRng.fill_bytes(&mut external_key);
KeyPair(Public(ristretto_key), external_key.try_into().unwrap()) KeyPair(Public::from(ristretto_key), external_key.try_into().unwrap())
} }
async fn get_ordered_keys(serai: &Serai, network: NetworkId, accounts: &[Pair]) -> Vec<Pair> { async fn get_ordered_keys(serai: &Serai, network: NetworkId, accounts: &[Pair]) -> Vec<Pair> {

View File

@@ -13,29 +13,28 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.cargo-machete] [package.metadata.cargo-machete]
ignored = ["scale", "scale-info"] ignored = ["scale"]
[lints] [lints]
workspace = true workspace = true
[dependencies] [dependencies]
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
frame-system = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
pallet-transaction-payment = { git = "https://github.com/serai-dex/substrate", default-features = false } pallet-transaction-payment = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
serai-primitives = { path = "../../primitives", default-features = false, features = ["serde"] } serai-primitives = { path = "../../primitives", default-features = false, features = ["serde"] }
coins-primitives = { package = "serai-coins-primitives", path = "../primitives", default-features = false } coins-primitives = { package = "serai-coins-primitives", path = "../primitives", default-features = false }
[dev-dependencies] [dev-dependencies]
sp-io = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] } sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false, features = ["std"] }
[features] [features]
std = [ std = [

View File

@@ -43,12 +43,11 @@ pub mod pallet {
#[pallet::config] #[pallet::config]
pub trait Config<I: 'static = ()>: frame_system::Config<AccountId = Public> { pub trait Config<I: 'static = ()>: frame_system::Config<AccountId = Public> {
type RuntimeEvent: From<Event<Self, I>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type AllowMint: AllowMint; type AllowMint: AllowMint;
} }
#[pallet::genesis_config] #[pallet::genesis_config]
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] #[derive(Clone, Debug)]
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> { pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
pub accounts: Vec<(T::AccountId, Balance)>, pub accounts: Vec<(T::AccountId, Balance)>,
pub _ignore: PhantomData<I>, pub _ignore: PhantomData<I>,
@@ -281,6 +280,22 @@ pub mod pallet {
} }
} }
fn can_withdraw_fee(
who: &Public,
_call: &T::RuntimeCall,
_dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
fee: Self::Balance,
_tip: Self::Balance,
) -> Result<(), TransactionValidityError> {
if fee == 0 {
return Ok(());
}
if Self::balance(*who, Coin::Serai).0 < fee {
Err(InvalidTransaction::Payment)?;
}
Ok(())
}
fn correct_and_deposit_fee( fn correct_and_deposit_fee(
who: &Public, who: &Public,
_dispatch_info: &DispatchInfoOf<T::RuntimeCall>, _dispatch_info: &DispatchInfoOf<T::RuntimeCall>,

View File

@@ -2,16 +2,10 @@
use super::*; use super::*;
use frame_support::{ use frame_support::{construct_runtime, derive_impl};
construct_runtime,
traits::{ConstU32, ConstU64},
};
use sp_core::{H256, sr25519::Public}; use sp_core::sr25519::Public;
use sp_runtime::{ use sp_runtime::{traits::IdentityLookup, BuildStorage};
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
use crate as coins; use crate as coins;
@@ -25,35 +19,14 @@ construct_runtime!(
} }
); );
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = Public; type AccountId = Public;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block; type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
} }
impl Config for Test { impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type AllowMint = (); type AllowMint = ();
} }

View File

@@ -21,15 +21,14 @@ borsh = { version = "1", default-features = false, features = ["derive", "de_str
serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true } serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
serai-primitives = { path = "../../primitives", default-features = false } serai-primitives = { path = "../../primitives", default-features = false }
[dev-dependencies] [dev-dependencies]
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
[features] [features]
std = ["zeroize", "borsh?/std", "serde?/std", "scale/std", "scale-info/std", "sp-runtime/std", "serai-primitives/std"] std = ["zeroize", "borsh?/std", "serde?/std", "scale/std", "sp-runtime/std", "serai-primitives/std"]
borsh = ["dep:borsh", "serai-primitives/borsh"] borsh = ["dep:borsh", "serai-primitives/borsh"]
serde = ["dep:serde", "serai-primitives/serde"] serde = ["dep:serde", "serai-primitives/serde"]
default = ["std"] default = ["std"]

View File

@@ -1,6 +1,7 @@
#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
#![expect(clippy::cast_possible_truncation)]
#[cfg(feature = "std")] #[cfg(feature = "std")]
use zeroize::Zeroize; use zeroize::Zeroize;
@@ -10,14 +11,13 @@ use borsh::{BorshSerialize, BorshDeserialize};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use scale::{Encode, Decode, MaxEncodedLen}; use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
use serai_primitives::{system_address, Data, ExternalAddress, ExternalBalance, SeraiAddress}; use serai_primitives::{system_address, Data, ExternalAddress, ExternalBalance, SeraiAddress};
pub const FEE_ACCOUNT: SeraiAddress = system_address(b"Coins-fees"); pub const FEE_ACCOUNT: SeraiAddress = system_address(b"Coins-fees");
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -26,7 +26,7 @@ pub struct OutInstruction {
pub data: Option<Data>, pub data: Option<Data>,
} }
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -35,7 +35,7 @@ pub struct OutInstructionWithBalance {
pub balance: ExternalBalance, pub balance: ExternalBalance,
} }
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

View File

@@ -13,24 +13,23 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.cargo-machete] [package.metadata.cargo-machete]
ignored = ["scale", "scale-info"] ignored = ["scale"]
[lints] [lints]
workspace = true workspace = true
[dependencies] [dependencies]
scale = { package = "parity-scale-codec", version = "3.6.1", default-features = false } scale = { package = "parity-scale-codec", version = "3.6.1", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-io = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-api = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-system = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-benchmarking = { git = "https://github.com/serai-dex/substrate", default-features = false, optional = true } frame-benchmarking = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false, optional = true }
coins-pallet = { package = "serai-coins-pallet", path = "../../coins/pallet", default-features = false } coins-pallet = { package = "serai-coins-pallet", path = "../../coins/pallet", default-features = false }
@@ -43,7 +42,6 @@ rand_core = { version = "0.6", default-features = false, features = ["getrandom"
default = ["std"] default = ["std"]
std = [ std = [
"scale/std", "scale/std",
"scale-info/std",
"sp-std/std", "sp-std/std",
"sp-io/std", "sp-io/std",

View File

@@ -62,8 +62,10 @@
//! http://localhost:9933/ //! http://localhost:9933/
//! ``` //! ```
//! (This can be run against the kitchen sync node in the `node` folder of this repo.) //! (This can be run against the kitchen sync node in the `node` folder of this repo.)
#![deny(missing_docs)] #![deny(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use frame_support::traits::DefensiveOption; use frame_support::traits::DefensiveOption;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
@@ -132,9 +134,6 @@ pub mod pallet {
+ CoinsConfig + CoinsConfig
+ coins_pallet::Config<coins_pallet::Instance1> + coins_pallet::Config<coins_pallet::Instance1>
{ {
/// Overarching event type.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// A % the liquidity providers will take of every swap. Represents 10ths of a percent. /// A % the liquidity providers will take of every swap. Represents 10ths of a percent.
#[pallet::constant] #[pallet::constant]
type LPFee: Get<u32>; type LPFee: Get<u32>;

View File

@@ -24,15 +24,12 @@ use super::*;
use crate as dex; use crate as dex;
use frame_support::{ use frame_support::{
construct_runtime, construct_runtime, derive_impl,
traits::{ConstU16, ConstU32, ConstU64}, traits::{ConstU16, ConstU32, ConstU64},
}; };
use sp_core::{H256, sr25519::Public}; use sp_core::sr25519::Public;
use sp_runtime::{ use sp_runtime::{traits::IdentityLookup, BuildStorage};
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
use serai_primitives::{Coin, Balance, Amount, system_address}; use serai_primitives::{Coin, Balance, Amount, system_address};
@@ -52,45 +49,22 @@ construct_runtime!(
} }
); );
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = Public; type AccountId = Public;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block; type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
} }
impl coins::Config for Test { impl coins::Config for Test {
type RuntimeEvent = RuntimeEvent;
type AllowMint = (); type AllowMint = ();
} }
impl coins::Config<coins::Instance1> for Test { impl coins::Config<coins::Instance1> for Test {
type RuntimeEvent = RuntimeEvent;
type AllowMint = (); type AllowMint = ();
} }
impl Config for Test { impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = (); type WeightInfo = ();
type LPFee = ConstU32<3>; // means 0.3% type LPFee = ConstU32<3>; // means 0.3%
type MaxSwapPathLength = ConstU32<4>; type MaxSwapPathLength = ConstU32<4>;

View File

@@ -13,17 +13,16 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.cargo-machete] [package.metadata.cargo-machete]
ignored = ["scale", "scale-info"] ignored = ["scale"]
[lints] [lints]
workspace = true workspace = true
[dependencies] [dependencies]
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
frame-system = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
dex-pallet = { package = "serai-dex-pallet", path = "../../dex/pallet", default-features = false } dex-pallet = { package = "serai-dex-pallet", path = "../../dex/pallet", default-features = false }
coins-pallet = { package = "serai-coins-pallet", path = "../../coins/pallet", default-features = false } coins-pallet = { package = "serai-coins-pallet", path = "../../coins/pallet", default-features = false }
@@ -33,7 +32,6 @@ serai-primitives = { path = "../../primitives", default-features = false }
[features] [features]
std = [ std = [
"scale/std", "scale/std",
"scale-info/std",
"frame-system/std", "frame-system/std",
"frame-support/std", "frame-support/std",

View File

@@ -17,9 +17,7 @@ pub mod pallet {
use serai_primitives::*; use serai_primitives::*;
#[pallet::config] #[pallet::config]
pub trait Config: frame_system::Config + CoinsConfig + DexConfig { pub trait Config: frame_system::Config + CoinsConfig + DexConfig {}
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
}
#[pallet::event] #[pallet::event]
#[pallet::generate_deposit(fn deposit_event)] #[pallet::generate_deposit(fn deposit_event)]

View File

@@ -13,20 +13,19 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.cargo-machete] [package.metadata.cargo-machete]
ignored = ["scale", "scale-info"] ignored = ["scale"]
[lints] [lints]
workspace = true workspace = true
[dependencies] [dependencies]
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
frame-system = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
coins-pallet = { package = "serai-coins-pallet", path = "../../coins/pallet", default-features = false } coins-pallet = { package = "serai-coins-pallet", path = "../../coins/pallet", default-features = false }
validator-sets-pallet = { package = "serai-validator-sets-pallet", path = "../../validator-sets/pallet", default-features = false } validator-sets-pallet = { package = "serai-validator-sets-pallet", path = "../../validator-sets/pallet", default-features = false }
@@ -42,7 +41,6 @@ emissions-primitives = { package = "serai-emissions-primitives", path = "../prim
[features] [features]
std = [ std = [
"scale/std", "scale/std",
"scale-info/std",
"frame-system/std", "frame-system/std",
"frame-support/std", "frame-support/std",
@@ -54,7 +52,7 @@ std = [
"validator-sets-pallet/std", "validator-sets-pallet/std",
"dex-pallet/std", "dex-pallet/std",
"genesis-liquidity-pallet/std", "genesis-liquidity-pallet/std",
"economic-security-pallet/std", "economic-security-pallet/std",
"serai-primitives/std", "serai-primitives/std",

View File

@@ -36,11 +36,10 @@ pub mod pallet {
+ GenesisLiquidityConfig + GenesisLiquidityConfig
+ EconomicSecurityConfig + EconomicSecurityConfig
{ {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
} }
#[pallet::genesis_config] #[pallet::genesis_config]
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] #[derive(Clone, Debug)]
pub struct GenesisConfig<T: Config> { pub struct GenesisConfig<T: Config> {
/// Networks to spawn Serai with. /// Networks to spawn Serai with.
pub networks: Vec<(NetworkId, Amount)>, pub networks: Vec<(NetworkId, Amount)>,

View File

@@ -13,21 +13,20 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.cargo-machete] [package.metadata.cargo-machete]
ignored = ["scale", "scale-info"] ignored = ["scale"]
[lints] [lints]
workspace = true workspace = true
[dependencies] [dependencies]
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
frame-system = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
dex-pallet = { package = "serai-dex-pallet", path = "../../dex/pallet", default-features = false } dex-pallet = { package = "serai-dex-pallet", path = "../../dex/pallet", default-features = false }
coins-pallet = { package = "serai-coins-pallet", path = "../../coins/pallet", default-features = false } coins-pallet = { package = "serai-coins-pallet", path = "../../coins/pallet", default-features = false }
@@ -42,7 +41,6 @@ validator-sets-primitives = { package = "serai-validator-sets-primitives", path
[features] [features]
std = [ std = [
"scale/std", "scale/std",
"scale-info/std",
"frame-system/std", "frame-system/std",
"frame-support/std", "frame-support/std",

View File

@@ -40,7 +40,6 @@ pub mod pallet {
+ CoinsConfig + CoinsConfig
+ coins_pallet::Config<coins_pallet::Instance1> + coins_pallet::Config<coins_pallet::Instance1>
{ {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
} }
#[pallet::error] #[pallet::error]

View File

@@ -22,9 +22,8 @@ borsh = { version = "1", default-features = false, features = ["derive", "de_str
serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true } serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
serai-primitives = { path = "../../primitives", default-features = false } serai-primitives = { path = "../../primitives", default-features = false }
validator-sets-primitives = { package = "serai-validator-sets-primitives", path = "../../validator-sets/primitives", default-features = false } validator-sets-primitives = { package = "serai-validator-sets-primitives", path = "../../validator-sets/primitives", default-features = false }
@@ -35,8 +34,7 @@ std = [
"scale/std", "scale/std",
"borsh?/std", "borsh?/std",
"serde?/std", "serde?/std",
"scale-info/std",
"serai-primitives/std", "serai-primitives/std",
"validator-sets-primitives/std", "validator-sets-primitives/std",

View File

@@ -12,8 +12,7 @@ use serde::{Serialize, Deserialize};
use sp_std::vec::Vec; use sp_std::vec::Vec;
use scale::{Encode, Decode, MaxEncodedLen}; use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
use serai_primitives::*; use serai_primitives::*;
use validator_sets_primitives::ValidatorSet; use validator_sets_primitives::ValidatorSet;
@@ -23,7 +22,9 @@ pub const INITIAL_GENESIS_LP_SHARES: u64 = 10_000;
// This is the account to hold and manage the genesis liquidity. // This is the account to hold and manage the genesis liquidity.
pub const GENESIS_LIQUIDITY_ACCOUNT: SeraiAddress = system_address(b"GenesisLiquidity-account"); pub const GENESIS_LIQUIDITY_ACCOUNT: SeraiAddress = system_address(b"GenesisLiquidity-account");
#[derive(Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(
Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -33,7 +34,9 @@ pub struct Values {
pub dai: u64, pub dai: u64,
} }
#[derive(Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(
Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

View File

@@ -13,23 +13,22 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.cargo-machete] [package.metadata.cargo-machete]
ignored = ["scale", "scale-info"] ignored = ["scale"]
[lints] [lints]
workspace = true workspace = true
[dependencies] [dependencies]
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-io = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-system = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
serai-primitives = { path = "../../primitives", default-features = false } serai-primitives = { path = "../../primitives", default-features = false }
in-instructions-primitives = { package = "serai-in-instructions-primitives", path = "../primitives", default-features = false } in-instructions-primitives = { package = "serai-in-instructions-primitives", path = "../primitives", default-features = false }
@@ -43,7 +42,6 @@ emissions-pallet = { package = "serai-emissions-pallet", path = "../../emissions
[features] [features]
std = [ std = [
"scale/std", "scale/std",
"scale-info/std",
"sp-std/std", "sp-std/std",
"sp-application-crypto/std", "sp-application-crypto/std",

View File

@@ -52,7 +52,6 @@ pub mod pallet {
+ GenesisLiqConfig + GenesisLiqConfig
+ EmissionsConfig + EmissionsConfig
{ {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
} }
#[pallet::event] #[pallet::event]

View File

@@ -21,11 +21,10 @@ borsh = { version = "1", default-features = false, features = ["derive", "de_str
serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true } serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
serai-primitives = { path = "../../primitives", default-features = false } serai-primitives = { path = "../../primitives", default-features = false }
coins-primitives = { package = "serai-coins-primitives", path = "../../coins/primitives", default-features = false } coins-primitives = { package = "serai-coins-primitives", path = "../../coins/primitives", default-features = false }
@@ -38,7 +37,6 @@ std = [
"serde?/std", "serde?/std",
"scale/std", "scale/std",
"scale-info/std",
"sp-std/std", "sp-std/std",
"sp-application-crypto/std", "sp-application-crypto/std",

View File

@@ -1,6 +1,7 @@
#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
#![expect(clippy::cast_possible_truncation)]
#[cfg(feature = "std")] #[cfg(feature = "std")]
use zeroize::Zeroize; use zeroize::Zeroize;
@@ -10,14 +11,12 @@ use borsh::{BorshSerialize, BorshDeserialize};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use scale::{Encode, Decode, MaxEncodedLen}; use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_application_crypto::sr25519::Signature; use sp_application_crypto::sr25519::Signature;
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
use sp_std::vec::Vec; use sp_std::vec::Vec;
use sp_runtime::RuntimeDebug;
#[rustfmt::skip] #[rustfmt::skip]
use serai_primitives::{BlockHash, Balance, ExternalNetworkId, NetworkId, SeraiAddress, ExternalBalance, ExternalAddress, system_address}; use serai_primitives::{BlockHash, Balance, ExternalNetworkId, NetworkId, SeraiAddress, ExternalBalance, ExternalAddress, system_address};
@@ -30,7 +29,7 @@ pub const MAX_BATCH_SIZE: usize = 25_000; // ~25kb
// This is the account which will be the origin for any dispatched `InInstruction`s. // This is the account which will be the origin for any dispatched `InInstruction`s.
pub const IN_INSTRUCTION_EXECUTOR: SeraiAddress = system_address(b"InInstructions-executor"); pub const IN_INSTRUCTION_EXECUTOR: SeraiAddress = system_address(b"InInstructions-executor");
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -59,7 +58,7 @@ impl OutAddress {
} }
} }
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -71,7 +70,7 @@ pub enum DexCall {
Swap(Balance, OutAddress), Swap(Balance, OutAddress),
} }
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -82,7 +81,7 @@ pub enum InInstruction {
SwapToStakedSRI(SeraiAddress, NetworkId), SwapToStakedSRI(SeraiAddress, NetworkId),
} }
#[derive(Clone, PartialEq, Eq, Encode, Decode, MaxEncodedLen, TypeInfo, RuntimeDebug)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -91,7 +90,7 @@ pub struct RefundableInInstruction {
pub instruction: InInstruction, pub instruction: InInstruction,
} }
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -100,7 +99,7 @@ pub struct InInstructionWithBalance {
pub balance: ExternalBalance, pub balance: ExternalBalance,
} }
#[derive(Clone, PartialEq, Eq, Encode, Decode, TypeInfo, RuntimeDebug)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -111,7 +110,7 @@ pub struct Batch {
pub instructions: Vec<InInstructionWithBalance>, pub instructions: Vec<InInstructionWithBalance>,
} }
#[derive(Clone, PartialEq, Eq, Encode, Decode, TypeInfo, RuntimeDebug)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking)]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct SignedBatch { pub struct SignedBatch {
@@ -130,7 +129,8 @@ pub struct SignedBatch {
impl Zeroize for SignedBatch { impl Zeroize for SignedBatch {
fn zeroize(&mut self) { fn zeroize(&mut self) {
self.batch.zeroize(); self.batch.zeroize();
self.signature.as_mut().zeroize(); let signature: &mut [u8] = self.signature.as_mut();
signature.zeroize();
} }
} }

View File

@@ -6,8 +6,7 @@ use borsh::{BorshSerialize, BorshDeserialize};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use scale::{Encode, Decode, MaxEncodedLen}; use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
use serai_primitives::{Amount, ExternalAddress, ExternalCoin, SeraiAddress}; use serai_primitives::{Amount, ExternalAddress, ExternalCoin, SeraiAddress};
@@ -17,7 +16,7 @@ use crate::RefundableInInstruction;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use crate::InInstruction; use crate::InInstruction;
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

View File

@@ -29,16 +29,18 @@ schnorrkel = "0.11"
libp2p = "0.52" libp2p = "0.52"
sp-core = { git = "https://github.com/serai-dex/substrate" } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sp-keystore = { git = "https://github.com/serai-dex/substrate" } sp-keystore = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sp-timestamp = { git = "https://github.com/serai-dex/substrate" } sp-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sp-io = { git = "https://github.com/serai-dex/substrate" } sp-state-machine = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sp-blockchain = { git = "https://github.com/serai-dex/substrate" } sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sp-api = { git = "https://github.com/serai-dex/substrate" } sp-blockchain = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sp-block-builder = { git = "https://github.com/serai-dex/substrate" } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sp-consensus-babe = { git = "https://github.com/serai-dex/substrate" } sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sp-block-builder = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sp-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
frame-benchmarking = { git = "https://github.com/serai-dex/substrate" } frame-benchmarking = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
serai-runtime = { path = "../runtime", features = ["std"] } serai-runtime = { path = "../runtime", features = ["std"] }
@@ -46,35 +48,37 @@ clap = { version = "4", features = ["derive"] }
futures-util = "0.3" futures-util = "0.3"
tokio = { version = "1", features = ["sync", "rt-multi-thread"] } tokio = { version = "1", features = ["sync", "rt-multi-thread"] }
jsonrpsee = { version = "0.16", features = ["server"] } jsonrpsee = { version = "0.24", features = ["server"] }
sc-offchain = { git = "https://github.com/serai-dex/substrate" } sc-transaction-pool = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-transaction-pool = { git = "https://github.com/serai-dex/substrate" } sc-transaction-pool-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-transaction-pool-api = { git = "https://github.com/serai-dex/substrate" } sc-basic-authorship = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-basic-authorship = { git = "https://github.com/serai-dex/substrate" } sc-executor = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-executor = { git = "https://github.com/serai-dex/substrate" } sc-service = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-service = { git = "https://github.com/serai-dex/substrate" } sc-client-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-client-api = { git = "https://github.com/serai-dex/substrate" } sc-network-common = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-network-common = { git = "https://github.com/serai-dex/substrate" } sc-network = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-network = { git = "https://github.com/serai-dex/substrate" }
sc-consensus = { git = "https://github.com/serai-dex/substrate" } sc-consensus = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-consensus-babe = { git = "https://github.com/serai-dex/substrate" } sc-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-consensus-grandpa = { git = "https://github.com/serai-dex/substrate" } sc-consensus-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-authority-discovery = { git = "https://github.com/serai-dex/substrate" } sc-authority-discovery = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-telemetry = { git = "https://github.com/serai-dex/substrate" } sc-telemetry = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-cli = { git = "https://github.com/serai-dex/substrate" } sc-chain-spec = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-cli = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-rpc-api = { git = "https://github.com/serai-dex/substrate" } sc-rpc-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
sc-rpc = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
substrate-frame-rpc-system = { git = "https://github.com/serai-dex/substrate" } frame-system-rpc-runtime-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
pallet-transaction-payment-rpc = { git = "https://github.com/serai-dex/substrate" } substrate-frame-rpc-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
pallet-transaction-payment-rpc = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
serai-env = { path = "../../common/env" } serai-env = { path = "../../common/env" }
[build-dependencies] [build-dependencies]
substrate-build-script-utils = { git = "https://github.com/serai-dex/substrate" } substrate-build-script-utils = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
[features] [features]
default = [] default = []

View File

@@ -10,7 +10,7 @@ use serai_runtime::{
CoinsConfig, ValidatorSetsConfig, SignalsConfig, BabeConfig, GrandpaConfig, EmissionsConfig, CoinsConfig, ValidatorSetsConfig, SignalsConfig, BabeConfig, GrandpaConfig, EmissionsConfig,
}; };
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>; pub type ChainSpec = sc_service::GenericChainSpec;
fn account_from_name(name: &'static str) -> PublicKey { fn account_from_name(name: &'static str) -> PublicKey {
insecure_pair_from_name(name).public() insecure_pair_from_name(name).public()
@@ -28,7 +28,6 @@ fn wasm_binary() -> Vec<u8> {
} }
fn devnet_genesis( fn devnet_genesis(
wasm_binary: &[u8],
validators: &[&'static str], validators: &[&'static str],
endowed_accounts: Vec<PublicKey>, endowed_accounts: Vec<PublicKey>,
) -> RuntimeGenesisConfig { ) -> RuntimeGenesisConfig {
@@ -50,7 +49,7 @@ fn devnet_genesis(
.collect::<Vec<_>>(); .collect::<Vec<_>>();
RuntimeGenesisConfig { RuntimeGenesisConfig {
system: SystemConfig { code: wasm_binary.to_vec(), _config: PhantomData }, system: SystemConfig { _config: PhantomData },
transaction_payment: Default::default(), transaction_payment: Default::default(),
@@ -70,7 +69,7 @@ fn devnet_genesis(
signals: SignalsConfig::default(), signals: SignalsConfig::default(),
babe: BabeConfig { babe: BabeConfig {
authorities: validators.iter().map(|validator| ((*validator).into(), 1)).collect(), authorities: validators.iter().map(|validator| ((*validator).into(), 1)).collect(),
epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG), epoch_config: BABE_GENESIS_EPOCH_CONFIG,
_config: PhantomData, _config: PhantomData,
}, },
grandpa: GrandpaConfig { grandpa: GrandpaConfig {
@@ -80,7 +79,7 @@ fn devnet_genesis(
} }
} }
fn testnet_genesis(wasm_binary: &[u8], validators: Vec<&'static str>) -> RuntimeGenesisConfig { fn testnet_genesis(validators: Vec<&'static str>) -> RuntimeGenesisConfig {
let validators = validators let validators = validators
.into_iter() .into_iter()
.map(|validator| Public::decode(&mut hex::decode(validator).unwrap().as_slice()).unwrap()) .map(|validator| Public::decode(&mut hex::decode(validator).unwrap().as_slice()).unwrap())
@@ -104,7 +103,7 @@ fn testnet_genesis(wasm_binary: &[u8], validators: Vec<&'static str>) -> Runtime
assert_eq!(validators.iter().collect::<HashSet<_>>().len(), validators.len()); assert_eq!(validators.iter().collect::<HashSet<_>>().len(), validators.len());
RuntimeGenesisConfig { RuntimeGenesisConfig {
system: SystemConfig { code: wasm_binary.to_vec(), _config: PhantomData }, system: SystemConfig { _config: PhantomData },
transaction_payment: Default::default(), transaction_payment: Default::default(),
@@ -124,7 +123,7 @@ fn testnet_genesis(wasm_binary: &[u8], validators: Vec<&'static str>) -> Runtime
signals: SignalsConfig::default(), signals: SignalsConfig::default(),
babe: BabeConfig { babe: BabeConfig {
authorities: validators.iter().map(|validator| ((*validator).into(), 1)).collect(), authorities: validators.iter().map(|validator| ((*validator).into(), 1)).collect(),
epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG), epoch_config: BABE_GENESIS_EPOCH_CONFIG,
_config: PhantomData, _config: PhantomData,
}, },
grandpa: GrandpaConfig { grandpa: GrandpaConfig {
@@ -134,114 +133,106 @@ fn testnet_genesis(wasm_binary: &[u8], validators: Vec<&'static str>) -> Runtime
} }
} }
pub fn development_config() -> ChainSpec { fn genesis(
let wasm_binary = wasm_binary(); name: &'static str,
id: &'static str,
chain_type: ChainType,
protocol_id: &'static str,
config: &RuntimeGenesisConfig,
) -> ChainSpec {
use sp_core::{
Encode,
traits::{RuntimeCode, WrappedRuntimeCode, CodeExecutor},
};
use sp_runtime::BuildStorage;
ChainSpec::from_genesis( let bin = wasm_binary();
// Name let hash = sp_core::blake2_256(&bin).to_vec();
let chain_spec = sc_chain_spec::ChainSpecBuilder::new(&bin, None)
.with_name(name)
.with_id(id)
.with_chain_type(chain_type)
.with_protocol_id(protocol_id)
.build();
let mut ext = sp_state_machine::BasicExternalities::new_empty();
let code_fetcher = WrappedRuntimeCode(bin.into());
sc_executor::WasmExecutor::<sp_io::SubstrateHostFunctions>::builder()
.with_allow_missing_host_functions(true)
.build()
.call(
&mut ext,
&RuntimeCode { heap_pages: None, code_fetcher: &code_fetcher, hash },
"GenesisApi_build",
&config.encode(),
sp_core::traits::CallContext::Onchain,
)
.0
.unwrap();
chain_spec.assimilate_storage(&mut ext.into_storages()).unwrap();
chain_spec
}
pub fn development_config() -> ChainSpec {
genesis(
"Development Network", "Development Network",
// ID
"devnet", "devnet",
ChainType::Development, ChainType::Development,
move || { "serai-devnet",
devnet_genesis( &devnet_genesis(
&wasm_binary, &["Alice"],
&["Alice"], vec![
vec![ account_from_name("Alice"),
account_from_name("Alice"), account_from_name("Bob"),
account_from_name("Bob"), account_from_name("Charlie"),
account_from_name("Charlie"), account_from_name("Dave"),
account_from_name("Dave"), account_from_name("Eve"),
account_from_name("Eve"), account_from_name("Ferdie"),
account_from_name("Ferdie"), ],
], ),
)
},
// Bootnodes
vec![],
// Telemetry
None,
// Protocol ID
Some("serai-devnet"),
// Fork ID
None,
// Properties
None,
// Extensions
None,
) )
} }
pub fn local_config() -> ChainSpec { pub fn local_config() -> ChainSpec {
let wasm_binary = wasm_binary(); genesis(
ChainSpec::from_genesis(
// Name
"Local Test Network", "Local Test Network",
// ID
"local", "local",
ChainType::Local, ChainType::Local,
move || { "serai-local",
devnet_genesis( &devnet_genesis(
&wasm_binary, &["Alice", "Bob", "Charlie", "Dave"],
&["Alice", "Bob", "Charlie", "Dave"], vec![
vec![ account_from_name("Alice"),
account_from_name("Alice"), account_from_name("Bob"),
account_from_name("Bob"), account_from_name("Charlie"),
account_from_name("Charlie"), account_from_name("Dave"),
account_from_name("Dave"), account_from_name("Eve"),
account_from_name("Eve"), account_from_name("Ferdie"),
account_from_name("Ferdie"), ],
], ),
)
},
// Bootnodes
vec![],
// Telemetry
None,
// Protocol ID
Some("serai-local"),
// Fork ID
None,
// Properties
None,
// Extensions
None,
) )
} }
#[allow(clippy::redundant_closure_call)]
pub fn testnet_config() -> ChainSpec { pub fn testnet_config() -> ChainSpec {
let wasm_binary = wasm_binary(); genesis(
"Test Network 0",
ChainSpec::from_genesis( "testnet-0",
// Name
"Test Network 2",
// ID
"testnet-2",
ChainType::Live, ChainType::Live,
move || { "serai-testnet-0",
let _ = testnet_genesis(&wasm_binary, vec![]); &(move || {
todo!() let _ = testnet_genesis(vec![]);
}, todo!("TODO")
// Bootnodes })(),
vec![],
// Telemetry
None,
// Protocol ID
Some("serai-testnet-2"),
// Fork ID
None,
// Properties
None,
// Extensions
None,
) )
} }
pub fn bootnode_multiaddrs(id: &str) -> Vec<libp2p::Multiaddr> { pub fn bootnode_multiaddrs(id: &str) -> Vec<libp2p::Multiaddr> {
match id { match id {
"devnet" | "local" => vec![], "devnet" | "local" => vec![],
"testnet-2" => todo!(), "testnet-0" => todo!("TODO"),
_ => panic!("unrecognized network ID"), _ => panic!("unrecognized network ID"),
} }
} }

View File

@@ -1,6 +1,6 @@
use zeroize::Zeroize; use zeroize::Zeroize;
use sp_core::{crypto::*, ed25519, sr25519}; use sp_core::{crypto::*, sr25519};
use sp_keystore::*; use sp_keystore::*;
pub struct Keystore(sr25519::Pair); pub struct Keystore(sr25519::Pair);
@@ -58,36 +58,19 @@ impl sp_keystore::Keystore for Keystore {
} }
} }
fn sr25519_vrf_output( fn sr25519_vrf_pre_output(
&self, &self,
_: KeyTypeId, _: KeyTypeId,
public: &sr25519::Public, public: &sr25519::Public,
input: &sr25519::vrf::VrfInput, input: &sr25519::vrf::VrfInput,
) -> Result<Option<sr25519::vrf::VrfOutput>, Error> { ) -> Result<Option<sr25519::vrf::VrfPreOutput>, Error> {
if public == &self.0.public() { if public == &self.0.public() {
Ok(Some(self.0.vrf_output(input))) Ok(Some(self.0.vrf_pre_output(input)))
} else { } else {
Ok(None) Ok(None)
} }
} }
fn ed25519_public_keys(&self, _: KeyTypeId) -> Vec<ed25519::Public> {
panic!("asked for ed25519 keys");
}
fn ed25519_generate_new(&self, _: KeyTypeId, _: Option<&str>) -> Result<ed25519::Public, Error> {
panic!("asked to generate an ed25519 key");
}
fn ed25519_sign(
&self,
_: KeyTypeId,
_: &ed25519::Public,
_: &[u8],
) -> Result<Option<ed25519::Signature>, Error> {
panic!("asked to produce an ed25519 signature");
}
fn insert(&self, _: KeyTypeId, _: &str, _: &[u8]) -> Result<(), ()> { fn insert(&self, _: KeyTypeId, _: &str, _: &[u8]) -> Result<(), ()> {
panic!("asked to insert a key"); panic!("asked to insert a key");
} }

View File

@@ -15,14 +15,12 @@ use tokio::sync::RwLock;
use jsonrpsee::RpcModule; use jsonrpsee::RpcModule;
pub use sc_rpc_api::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool; use sc_transaction_pool_api::TransactionPool;
pub struct FullDeps<C, P> { pub struct FullDeps<C, P> {
pub id: String, pub id: String,
pub client: Arc<C>, pub client: Arc<C>,
pub pool: Arc<P>, pub pool: Arc<P>,
pub deny_unsafe: DenyUnsafe,
pub authority_discovery: Option<sc_authority_discovery::Service>, pub authority_discovery: Option<sc_authority_discovery::Service>,
} }
@@ -38,7 +36,7 @@ pub fn create_full<
deps: FullDeps<C, P>, deps: FullDeps<C, P>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>> ) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where where
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, PublicKey, Nonce> C::Api: frame_system_rpc_runtime_api::AccountNonceApi<Block, PublicKey, Nonce>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, SubstrateAmount> + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, SubstrateAmount>
+ SeraiRuntimeApi<Block> + SeraiRuntimeApi<Block>
+ BlockBuilder<Block>, + BlockBuilder<Block>,
@@ -47,9 +45,9 @@ where
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
let mut module = RpcModule::new(()); let mut module = RpcModule::new(());
let FullDeps { id, client, pool, deny_unsafe, authority_discovery } = deps; let FullDeps { id, client, pool, authority_discovery } = deps;
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(System::new(client.clone(), pool).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
if let Some(authority_discovery) = authority_discovery { if let Some(authority_discovery) = authority_discovery {
@@ -57,17 +55,25 @@ where
RpcModule::new((id, client, RwLock::new(authority_discovery))); RpcModule::new((id, client, RwLock::new(authority_discovery)));
authority_discovery_module.register_async_method( authority_discovery_module.register_async_method(
"p2p_validators", "p2p_validators",
|params, context| async move { |params, context, _ext| async move {
let network: NetworkId = params.parse()?; let network: NetworkId = params.parse()?;
let (id, client, authority_discovery) = &*context; let (id, client, authority_discovery) = &*context;
let latest_block = client.info().best_hash; let latest_block = client.info().best_hash;
let validators = client.runtime_api().validators(latest_block, network).map_err(|_| { let validators = client.runtime_api().validators(latest_block, network).map_err(|_| {
jsonrpsee::core::Error::to_call_error(std::io::Error::other(format!( jsonrpsee::types::error::ErrorObjectOwned::owned(
"couldn't get validators from the latest block, which is likely a fatal bug. {}", -1,
"please report this at https://github.com/serai-dex/serai", format!(
))) "couldn't get validators from the latest block, which is likely a fatal bug. {}",
})?; "please report this at https://github.com/serai-dex/serai",
),
Option::<()>::None,
)
});
let validators = match validators {
Ok(validators) => validators,
Err(e) => return Err(e),
};
// Always return the protocol's bootnodes // Always return the protocol's bootnodes
let mut all_p2p_addresses = crate::chain_spec::bootnode_multiaddrs(id); let mut all_p2p_addresses = crate::chain_spec::bootnode_multiaddrs(id);
// Additionally returns validators found over the DHT // Additionally returns validators found over the DHT
@@ -87,9 +93,9 @@ where
// It isn't beneficial to use multiple addresses for a single peer here // It isn't beneficial to use multiple addresses for a single peer here
if !returned_addresses.is_empty() { if !returned_addresses.is_empty() {
all_p2p_addresses.push( all_p2p_addresses.push(
returned_addresses.remove( returned_addresses
usize::try_from(OsRng.next_u64() >> 32).unwrap() % returned_addresses.len(), .remove(usize::try_from(OsRng.next_u64() >> 32).unwrap() % returned_addresses.len())
), .into(),
); );
} }
} }

View File

@@ -8,12 +8,11 @@ use sp_consensus_babe::{SlotDuration, inherents::InherentDataProvider as BabeInh
use sp_io::SubstrateHostFunctions; use sp_io::SubstrateHostFunctions;
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, WasmExecutor}; use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, WasmExecutor};
use sc_network_common::sync::warp::WarpSyncParams; use sc_network::{Event, NetworkEventStream, NetworkBackend};
use sc_network::{Event, NetworkEventStream};
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, TFullClient}; use sc_service::{error::Error as ServiceError, Configuration, TaskManager, TFullClient};
use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sc_client_api::{BlockBackend, Backend}; use sc_client_api::BlockBackend;
use sc_telemetry::{Telemetry, TelemetryWorker}; use sc_telemetry::{Telemetry, TelemetryWorker};
@@ -40,8 +39,8 @@ type PartialComponents = sc_service::PartialComponents<
FullClient, FullClient,
FullBackend, FullBackend,
SelectChain, SelectChain,
sc_consensus::DefaultImportQueue<Block, FullClient>, sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>, sc_transaction_pool::TransactionPoolWrapper<Block, FullClient>,
( (
BabeBlockImport, BabeBlockImport,
sc_consensus_babe::BabeLink<Block>, sc_consensus_babe::BabeLink<Block>,
@@ -74,11 +73,11 @@ pub fn new_partial(
#[allow(deprecated)] #[allow(deprecated)]
let executor = Executor::new( let executor = Executor::new(
config.wasm_method, config.executor.wasm_method,
config.default_heap_pages, config.executor.default_heap_pages,
config.max_runtime_instances, config.executor.max_runtime_instances,
None, None,
config.runtime_cache_size, config.executor.runtime_cache_size,
); );
let (client, backend, keystore_container, task_manager) = let (client, backend, keystore_container, task_manager) =
@@ -103,16 +102,19 @@ pub fn new_partial(
let select_chain = sc_consensus::LongestChain::new(backend.clone()); let select_chain = sc_consensus::LongestChain::new(backend.clone());
let transaction_pool = sc_transaction_pool::BasicPool::new_full( let transaction_pool = sc_transaction_pool::Builder::new(
config.transaction_pool.clone(),
config.role.is_authority().into(),
config.prometheus_registry(),
task_manager.spawn_essential_handle(), task_manager.spawn_essential_handle(),
client.clone(), client.clone(),
); config.role.is_authority().into(),
)
.with_options(config.transaction_pool.clone())
.with_prometheus(config.prometheus_registry())
.build();
let transaction_pool = Arc::new(transaction_pool);
let (grandpa_block_import, grandpa_link) = grandpa::block_import( let (grandpa_block_import, grandpa_link) = grandpa::block_import(
client.clone(), client.clone(),
u32::MAX,
&client, &client,
select_chain.clone(), select_chain.clone(),
telemetry.as_ref().map(Telemetry::handle), telemetry.as_ref().map(Telemetry::handle),
@@ -181,22 +183,26 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
config.network.listen_addresses = config.network.listen_addresses =
vec!["/ip4/0.0.0.0/tcp/30333".parse().unwrap(), "/ip6/::/tcp/30333".parse().unwrap()]; vec!["/ip4/0.0.0.0/tcp/30333".parse().unwrap(), "/ip6/::/tcp/30333".parse().unwrap()];
let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network); type N = sc_network::service::NetworkWorker<Block, <Block as sp_runtime::traits::Block>::Hash>;
let mut net_config = sc_network::config::FullNetworkConfiguration::<_, _, N>::new(
&config.network,
config.prometheus_registry().cloned(),
);
let metrics = N::register_notification_metrics(config.prometheus_registry());
let grandpa_protocol_name = let grandpa_protocol_name =
grandpa::protocol_standard_name(&client.block_hash(0).unwrap().unwrap(), &config.chain_spec); grandpa::protocol_standard_name(&client.block_hash(0).unwrap().unwrap(), &config.chain_spec);
net_config.add_notification_protocol(sc_consensus_grandpa::grandpa_peers_set_config( let (grandpa_protocol_config, grandpa_notification_service) =
grandpa_protocol_name.clone(), sc_consensus_grandpa::grandpa_peers_set_config::<Block, N>(
)); grandpa_protocol_name.clone(),
metrics.clone(),
net_config.peer_store_handle(),
);
net_config.add_notification_protocol(grandpa_protocol_config);
let publish_non_global_ips = config.network.allow_non_globals_in_dht; let publish_non_global_ips = config.network.allow_non_globals_in_dht;
let warp_sync = Arc::new(grandpa::warp_proof::NetworkProvider::new( let (network, system_rpc_tx, tx_handler_controller, sync_service) =
backend.clone(),
grandpa_link.shared_authority_set().clone(),
vec![],
));
let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
sc_service::build_network(sc_service::BuildNetworkParams { sc_service::build_network(sc_service::BuildNetworkParams {
config: &config, config: &config,
net_config, net_config,
@@ -205,7 +211,9 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
spawn_handle: task_manager.spawn_handle(), spawn_handle: task_manager.spawn_handle(),
import_queue, import_queue,
block_announce_validator_builder: None, block_announce_validator_builder: None,
warp_sync_params: Some(WarpSyncParams::WithProvider(warp_sync)), metrics,
block_relay: None,
warp_sync_config: None,
})?; })?;
task_manager.spawn_handle().spawn("bootnodes", "bootnodes", { task_manager.spawn_handle().spawn("bootnodes", "bootnodes", {
@@ -233,7 +241,10 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
.multiplex(libp2p::yamux::Config::default()); .multiplex(libp2p::yamux::Config::default());
let Ok(transport) = transport.dial(multiaddr.clone()) else { None? }; let Ok(transport) = transport.dial(multiaddr.clone()) else { None? };
let Ok((peer_id, _)) = transport.await else { None? }; let Ok((peer_id, _)) = transport.await else { None? };
Some(sc_network::config::MultiaddrWithPeerId { multiaddr, peer_id }) Some(sc_network::config::MultiaddrWithPeerId {
multiaddr: multiaddr.into(),
peer_id: peer_id.into(),
})
}), }),
)); ));
} }
@@ -261,25 +272,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
} }
}); });
if config.offchain_worker.enabled { let role = config.role;
task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-worker",
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
is_validator: config.role.is_authority(),
keystore: Some(keystore_container.clone()),
offchain_db: backend.offchain_storage(),
transaction_pool: Some(OffchainTransactionPoolFactory::new(transaction_pool.clone())),
network_provider: network.clone(),
enable_http_requests: true,
custom_extensions: |_| vec![],
})
.run(client.clone(), task_manager.spawn_handle()),
);
}
let role = config.role.clone();
let keystore = keystore_container; let keystore = keystore_container;
let prometheus_registry = config.prometheus_registry().cloned(); let prometheus_registry = config.prometheus_registry().cloned();
@@ -294,7 +287,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
worker worker
}, },
client.clone(), client.clone(),
network.clone(), Arc::new(network.clone()),
Box::pin(network.event_stream("authority-discovery").filter_map(|e| async move { Box::pin(network.event_stream("authority-discovery").filter_map(|e| async move {
match e { match e {
Event::Dht(e) => Some(e), Event::Dht(e) => Some(e),
@@ -303,6 +296,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
})), })),
sc_authority_discovery::Role::PublishAndDiscover(keystore.clone()), sc_authority_discovery::Role::PublishAndDiscover(keystore.clone()),
prometheus_registry.clone(), prometheus_registry.clone(),
task_manager.spawn_handle(),
); );
task_manager.spawn_handle().spawn( task_manager.spawn_handle().spawn(
"authority-discovery-worker", "authority-discovery-worker",
@@ -320,12 +314,11 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
let client = client.clone(); let client = client.clone();
let pool = transaction_pool.clone(); let pool = transaction_pool.clone();
Box::new(move |deny_unsafe, _| { Box::new(move |_| {
crate::rpc::create_full(crate::rpc::FullDeps { crate::rpc::create_full(crate::rpc::FullDeps {
id: id.clone(), id: id.clone(),
client: client.clone(), client: client.clone(),
pool: pool.clone(), pool: pool.clone(),
deny_unsafe,
authority_discovery: authority_discovery.clone(), authority_discovery: authority_discovery.clone(),
}) })
.map_err(Into::into) .map_err(Into::into)
@@ -392,7 +385,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
grandpa::run_grandpa_voter(grandpa::GrandpaParams { grandpa::run_grandpa_voter(grandpa::GrandpaParams {
config: grandpa::Config { config: grandpa::Config {
gossip_duration: std::time::Duration::from_millis(333), gossip_duration: std::time::Duration::from_millis(333),
justification_period: 512, justification_generation_period: 512,
name: Some(name), name: Some(name),
observer_enabled: false, observer_enabled: false,
keystore: if role.is_authority() { Some(keystore) } else { None }, keystore: if role.is_authority() { Some(keystore) } else { None },
@@ -408,10 +401,10 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
prometheus_registry, prometheus_registry,
shared_voter_state, shared_voter_state,
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool), offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool),
notification_service: grandpa_notification_service,
})?, })?,
); );
} }
network_starter.start_network();
Ok(task_manager) Ok(task_manager)
} }

View File

@@ -19,24 +19,23 @@ workspace = true
zeroize = { version = "^1.5", features = ["derive"], optional = true } zeroize = { version = "^1.5", features = ["derive"], optional = true }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
borsh = { version = "1", default-features = false, features = ["derive", "de_strict_order"], optional = true } borsh = { version = "1", default-features = false, features = ["derive", "de_strict_order"], optional = true }
serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true } serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true }
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-io = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
[dev-dependencies] [dev-dependencies]
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
[features] [features]
std = ["zeroize", "scale/std", "borsh?/std", "serde?/std", "scale-info/std", "sp-core/std", "sp-runtime/std", "sp-std/std", "frame-support/std"] std = ["zeroize", "scale/std", "borsh?/std", "serde?/std", "sp-core/std", "sp-runtime/std", "sp-std/std", "frame-support/std"]
borsh = ["dep:borsh"] borsh = ["dep:borsh"]
serde = ["dep:serde"] serde = ["dep:serde"]
default = ["std"] default = ["std"]

View File

@@ -6,8 +6,7 @@ use borsh::{BorshSerialize, BorshDeserialize};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use scale::{Encode, Decode, MaxEncodedLen}; use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::sr25519::Public; use sp_core::sr25519::Public;
pub use sp_core::sr25519::Signature; pub use sp_core::sr25519::Signature;
@@ -31,7 +30,7 @@ pub fn borsh_deserialize_public<R: borsh::io::Read>(
reader: &mut R, reader: &mut R,
) -> Result<Public, borsh::io::Error> { ) -> Result<Public, borsh::io::Error> {
let public: [u8; 32] = borsh::BorshDeserialize::deserialize_reader(reader)?; let public: [u8; 32] = borsh::BorshDeserialize::deserialize_reader(reader)?;
Ok(Public(public)) Ok(public.into())
} }
#[cfg(feature = "borsh")] #[cfg(feature = "borsh")]
@@ -47,12 +46,22 @@ pub fn borsh_deserialize_signature<R: borsh::io::Read>(
reader: &mut R, reader: &mut R,
) -> Result<Signature, borsh::io::Error> { ) -> Result<Signature, borsh::io::Error> {
let signature: [u8; 64] = borsh::BorshDeserialize::deserialize_reader(reader)?; let signature: [u8; 64] = borsh::BorshDeserialize::deserialize_reader(reader)?;
Ok(Signature(signature)) Ok(signature.into())
} }
// TODO: Remove this for solely Public? // TODO: Remove this for solely Public?
#[derive( #[derive(
Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Encode, Decode, MaxEncodedLen, TypeInfo, Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
Debug,
Encode,
Decode,
DecodeWithMemTracking,
MaxEncodedLen,
)] )]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]

View File

@@ -11,8 +11,7 @@ use borsh::{BorshSerialize, BorshDeserialize};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use scale::{Encode, Decode, MaxEncodedLen}; use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
/// The type used for amounts within Substrate. /// The type used for amounts within Substrate.
// Distinct from Amount due to Substrate's requirements on this type. // Distinct from Amount due to Substrate's requirements on this type.
@@ -22,7 +21,16 @@ use scale_info::TypeInfo;
pub type SubstrateAmount = u64; pub type SubstrateAmount = u64;
/// The type used for amounts. /// The type used for amounts.
#[derive( #[derive(
Clone, Copy, PartialEq, Eq, PartialOrd, Debug, Encode, Decode, MaxEncodedLen, TypeInfo, Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Debug,
Encode,
Decode,
DecodeWithMemTracking,
MaxEncodedLen,
)] )]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]

View File

@@ -8,13 +8,14 @@ use borsh::{BorshSerialize, BorshDeserialize};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use scale::{Encode, Decode, MaxEncodedLen}; use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
use crate::{Amount, Coin, ExternalCoin}; use crate::{Amount, Coin, ExternalCoin};
/// The type used for balances (a Coin and Balance). /// The type used for balances (a Coin and Balance).
#[derive(Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(
Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -24,7 +25,9 @@ pub struct Balance {
} }
/// The type used for balances (a Coin and Balance). /// The type used for balances (a Coin and Balance).
#[derive(Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(
Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

View File

@@ -6,14 +6,23 @@ use borsh::{BorshSerialize, BorshDeserialize};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use scale::{Encode, Decode, MaxEncodedLen}; use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::H256; use sp_core::H256;
/// The type used to identify block numbers. /// The type used to identify block numbers.
#[derive( #[derive(
Clone, Copy, Default, PartialEq, Eq, Hash, Debug, Encode, Decode, MaxEncodedLen, TypeInfo, Clone,
Copy,
Default,
PartialEq,
Eq,
Hash,
Debug,
Encode,
Decode,
DecodeWithMemTracking,
MaxEncodedLen,
)] )]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
@@ -30,7 +39,9 @@ impl From<u64> for BlockNumber {
// If a block exists with a hash which isn't 32-bytes, it can be hashed into a value with 32-bytes // If a block exists with a hash which isn't 32-bytes, it can be hashed into a value with 32-bytes
// This would require the processor to maintain a mapping of 32-byte IDs to actual hashes, which // This would require the processor to maintain a mapping of 32-byte IDs to actual hashes, which
// would be fine // would be fine
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(
Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

View File

@@ -10,8 +10,7 @@ use borsh::{BorshSerialize, BorshDeserialize};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use scale::{Encode, Decode, MaxEncodedLen}; use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
#[cfg(test)] #[cfg(test)]
use sp_io::TestExternalities; use sp_io::TestExternalities;
@@ -64,7 +63,7 @@ pub fn borsh_deserialize_bounded_vec<R: borsh::io::Read, T: BorshDeserialize, co
// When JAMTIS arrives, it'll become 112 or potentially even 142 bytes // When JAMTIS arrives, it'll become 112 or potentially even 142 bytes
pub const MAX_ADDRESS_LEN: u32 = 196; pub const MAX_ADDRESS_LEN: u32 = 196;
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ExternalAddress( pub struct ExternalAddress(
@@ -108,7 +107,7 @@ impl AsRef<[u8]> for ExternalAddress {
// Should be enough for a Uniswap v3 call // Should be enough for a Uniswap v3 call
pub const MAX_DATA_LEN: u32 = 512; pub const MAX_DATA_LEN: u32 = 512;
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Data( pub struct Data(

View File

@@ -1,8 +1,7 @@
#[cfg(feature = "std")] #[cfg(feature = "std")]
use zeroize::Zeroize; use zeroize::Zeroize;
use scale::{Decode, Encode, EncodeLike, MaxEncodedLen}; use scale::{Encode, EncodeLike, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
#[cfg(feature = "borsh")] #[cfg(feature = "borsh")]
use borsh::{BorshSerialize, BorshDeserialize}; use borsh::{BorshSerialize, BorshDeserialize};
@@ -16,7 +15,7 @@ use sp_std::{vec, vec::Vec};
use crate::{borsh_serialize_bounded_vec, borsh_deserialize_bounded_vec}; use crate::{borsh_serialize_bounded_vec, borsh_deserialize_bounded_vec};
/// The type used to identify external networks. /// The type used to identify external networks.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, TypeInfo)] #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum ExternalNetworkId { pub enum ExternalNetworkId {
@@ -47,6 +46,8 @@ impl Decode for ExternalNetworkId {
} }
} }
impl DecodeWithMemTracking for ExternalNetworkId {}
impl MaxEncodedLen for ExternalNetworkId { impl MaxEncodedLen for ExternalNetworkId {
fn max_encoded_len() -> usize { fn max_encoded_len() -> usize {
1 1
@@ -73,7 +74,7 @@ impl BorshDeserialize for ExternalNetworkId {
} }
/// The type used to identify networks. /// The type used to identify networks.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, TypeInfo)] #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum NetworkId { pub enum NetworkId {
@@ -100,6 +101,8 @@ impl Decode for NetworkId {
} }
} }
impl DecodeWithMemTracking for NetworkId {}
impl MaxEncodedLen for NetworkId { impl MaxEncodedLen for NetworkId {
fn max_encoded_len() -> usize { fn max_encoded_len() -> usize {
1 1
@@ -184,7 +187,7 @@ pub const COINS: [Coin; 5] = [
]; ];
/// The type used to identify external coins. /// The type used to identify external coins.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TypeInfo)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum ExternalCoin { pub enum ExternalCoin {
@@ -217,6 +220,9 @@ impl Decode for ExternalCoin {
} }
} }
} }
impl DecodeWithMemTracking for ExternalCoin {}
impl MaxEncodedLen for ExternalCoin { impl MaxEncodedLen for ExternalCoin {
fn max_encoded_len() -> usize { fn max_encoded_len() -> usize {
1 1
@@ -242,7 +248,7 @@ impl BorshDeserialize for ExternalCoin {
} }
/// The type used to identify coins. /// The type used to identify coins.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TypeInfo)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum Coin { pub enum Coin {
@@ -269,6 +275,8 @@ impl Decode for Coin {
} }
} }
impl DecodeWithMemTracking for Coin {}
impl MaxEncodedLen for Coin { impl MaxEncodedLen for Coin {
fn max_encoded_len() -> usize { fn max_encoded_len() -> usize {
1 1

View File

@@ -13,7 +13,7 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.cargo-machete] [package.metadata.cargo-machete]
ignored = ["scale", "scale-info"] ignored = ["scale"]
[lints] [lints]
workspace = true workspace = true
@@ -22,39 +22,38 @@ workspace = true
hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] } hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-offchain = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-offchain = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-version = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-version = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-inherents = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-inherents = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-session = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-consensus-babe = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-consensus-grandpa = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-consensus-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-authority-discovery = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-authority-discovery = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-transaction-pool = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-transaction-pool = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-block-builder = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-block-builder = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-api = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-system = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-executive = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-executive = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-benchmarking = { git = "https://github.com/serai-dex/substrate", default-features = false, optional = true } frame-benchmarking = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false, optional = true }
serai-primitives = { path = "../primitives", default-features = false } serai-primitives = { path = "../primitives", default-features = false }
serai-abi = { path = "../abi", default-features = false, features = ["serde"] } serai-abi = { path = "../abi", default-features = false, features = ["serde"] }
pallet-timestamp = { git = "https://github.com/serai-dex/substrate", default-features = false } pallet-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
pallet-authorship = { git = "https://github.com/serai-dex/substrate", default-features = false } pallet-authorship = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
pallet-transaction-payment = { git = "https://github.com/serai-dex/substrate", default-features = false } pallet-transaction-payment = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
coins-pallet = { package = "serai-coins-pallet", path = "../coins/pallet", default-features = false } coins-pallet = { package = "serai-coins-pallet", path = "../coins/pallet", default-features = false }
dex-pallet = { package = "serai-dex-pallet", path = "../dex/pallet", default-features = false } dex-pallet = { package = "serai-dex-pallet", path = "../dex/pallet", default-features = false }
@@ -69,19 +68,19 @@ in-instructions-pallet = { package = "serai-in-instructions-pallet", path = "../
signals-pallet = { package = "serai-signals-pallet", path = "../signals/pallet", default-features = false } signals-pallet = { package = "serai-signals-pallet", path = "../signals/pallet", default-features = false }
pallet-babe = { git = "https://github.com/serai-dex/substrate", default-features = false } pallet-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
pallet-grandpa = { git = "https://github.com/serai-dex/substrate", default-features = false } pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-system-rpc-runtime-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/serai-dex/substrate", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
[build-dependencies] [build-dependencies]
substrate-wasm-builder = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "19c487d6aa9893b6b09a21ce0ab8aefb1c299186" } substrate-wasm-builder = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab" }
[features] [features]
std = [ std = [
"scale/std", "scale/std",
"scale-info/std",
"sp-core/std", "sp-core/std",
"sp-std/std", "sp-std/std",
@@ -128,6 +127,7 @@ std = [
"signals-pallet/std", "signals-pallet/std",
"pallet-session/std",
"pallet-babe/std", "pallet-babe/std",
"pallet-grandpa/std", "pallet-grandpa/std",

View File

@@ -205,6 +205,7 @@ impl TryInto<Call> for RuntimeCall {
fn try_into(self) -> Result<Call, ()> { fn try_into(self) -> Result<Call, ()> {
Ok(match self { Ok(match self {
RuntimeCall::System(_) => Err(())?,
RuntimeCall::Timestamp(timestamp::Call::set { now }) => { RuntimeCall::Timestamp(timestamp::Call::set { now }) => {
Call::Timestamp(serai_abi::timestamp::Call::set { now }) Call::Timestamp(serai_abi::timestamp::Call::set { now })
} }

View File

@@ -1,3 +1,4 @@
#![allow(deprecated)]
#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
@@ -36,13 +37,9 @@ pub use emissions_pallet as emissions;
pub use economic_security_pallet as economic_security; pub use economic_security_pallet as economic_security;
// Actually used by the runtime
use sp_core::OpaqueMetadata;
use sp_std::prelude::*; use sp_std::prelude::*;
use sp_version::RuntimeVersion; use sp_version::RuntimeVersion;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, KeyTypeId, create_runtime_str, generic, impl_opaque_keys, KeyTypeId,
@@ -113,16 +110,12 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_name: create_runtime_str!("core"), impl_name: create_runtime_str!("core"),
spec_version: 1, spec_version: 1,
impl_version: 1, impl_version: 1,
authoring_version: 1,
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,
transaction_version: 1, transaction_version: 1,
state_version: 1, system_version: 1,
}; };
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
sp_consensus_babe::BabeEpochConfiguration { sp_consensus_babe::BabeEpochConfiguration {
@@ -136,8 +129,6 @@ parameter_types! {
pub const BlockHashCount: BlockNumber = 2400; pub const BlockHashCount: BlockNumber = 2400;
pub const Version: RuntimeVersion = VERSION; pub const Version: RuntimeVersion = VERSION;
pub const SS58Prefix: u8 = 42; // TODO: Remove for Bech32m
// 1 MB block size limit // 1 MB block size limit
pub BlockLength: system::limits::BlockLength = pub BlockLength: system::limits::BlockLength =
system::limits::BlockLength::max_with_normal_ratio(BLOCK_SIZE, NORMAL_DISPATCH_RATIO); system::limits::BlockLength::max_with_normal_ratio(BLOCK_SIZE, NORMAL_DISPATCH_RATIO);
@@ -181,9 +172,16 @@ impl system::Config for Runtime {
type AccountData = (); type AccountData = ();
type SystemWeightInfo = (); type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix; // TODO: Remove for Bech32m
type MaxConsumers = support::traits::ConstU32<16>; type MaxConsumers = support::traits::ConstU32<16>;
type RuntimeTask = ();
type ExtensionsWeightInfo = (); // TODO
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
} }
impl timestamp::Config for Runtime { impl timestamp::Config for Runtime {
@@ -200,21 +198,18 @@ impl transaction_payment::Config for Runtime {
type WeightToFee = IdentityFee<SubstrateAmount>; type WeightToFee = IdentityFee<SubstrateAmount>;
type LengthToFee = IdentityFee<SubstrateAmount>; type LengthToFee = IdentityFee<SubstrateAmount>;
type FeeMultiplierUpdate = (); type FeeMultiplierUpdate = ();
type WeightInfo = ();
} }
impl coins::Config for Runtime { impl coins::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type AllowMint = ValidatorSets; type AllowMint = ValidatorSets;
} }
impl coins::Config<coins::Instance1> for Runtime { impl coins::Config<coins::Instance1> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AllowMint = (); type AllowMint = ();
} }
impl dex::Config for Runtime { impl dex::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type LPFee = ConstU32<3>; // 0.3% type LPFee = ConstU32<3>; // 0.3%
type MintMinLiquidity = ConstU64<10000>; type MintMinLiquidity = ConstU64<10000>;
@@ -226,8 +221,6 @@ impl dex::Config for Runtime {
} }
impl validator_sets::Config for Runtime { impl validator_sets::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ShouldEndSession = Babe; type ShouldEndSession = Babe;
} }
@@ -239,7 +232,6 @@ impl Convert<PublicKey, Option<PublicKey>> for IdentityValidatorIdOf {
} }
impl signals::Config for Runtime { impl signals::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
// 1 week // 1 week
#[allow(clippy::cast_possible_truncation)] #[allow(clippy::cast_possible_truncation)]
type RetirementValidityDuration = ConstU32<{ (7 * 24 * 60 * 60) / (TARGET_BLOCK_TIME as u32) }>; type RetirementValidityDuration = ConstU32<{ (7 * 24 * 60 * 60) / (TARGET_BLOCK_TIME as u32) }>;
@@ -248,30 +240,13 @@ impl signals::Config for Runtime {
type RetirementLockInDuration = ConstU32<{ (2 * 7 * 24 * 60 * 60) / (TARGET_BLOCK_TIME as u32) }>; type RetirementLockInDuration = ConstU32<{ (2 * 7 * 24 * 60 * 60) / (TARGET_BLOCK_TIME as u32) }>;
} }
impl in_instructions::Config for Runtime { impl in_instructions::Config for Runtime {}
type RuntimeEvent = RuntimeEvent;
}
impl genesis_liquidity::Config for Runtime { impl genesis_liquidity::Config for Runtime {}
type RuntimeEvent = RuntimeEvent;
}
impl emissions::Config for Runtime { impl emissions::Config for Runtime {}
type RuntimeEvent = RuntimeEvent;
}
impl economic_security::Config for Runtime { impl economic_security::Config for Runtime {}
type RuntimeEvent = RuntimeEvent;
}
// for publishing equivocation evidences.
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
where
RuntimeCall: From<C>,
{
type Extrinsic = Transaction;
type OverarchingCall = RuntimeCall;
}
// for validating equivocation evidences. // for validating equivocation evidences.
// The following runtime construction doesn't actually implement the pallet as doing so is // The following runtime construction doesn't actually implement the pallet as doing so is
@@ -301,6 +276,7 @@ impl babe::Config for Runtime {
type WeightInfo = (); type WeightInfo = ();
type MaxAuthorities = MaxAuthorities; type MaxAuthorities = MaxAuthorities;
type MaxNominators = ConstU32<1>;
type KeyOwnerProof = MembershipProof<Self>; type KeyOwnerProof = MembershipProof<Self>;
type EquivocationReportSystem = type EquivocationReportSystem =
@@ -312,6 +288,7 @@ impl grandpa::Config for Runtime {
type WeightInfo = (); type WeightInfo = ();
type MaxAuthorities = MaxAuthorities; type MaxAuthorities = MaxAuthorities;
type MaxNominators = ConstU32<1>;
type MaxSetIdSessionEntries = ConstU64<0>; type MaxSetIdSessionEntries = ConstU64<0>;
type KeyOwnerProof = MembershipProof<Self>; type KeyOwnerProof = MembershipProof<Self>;
@@ -319,6 +296,17 @@ impl grandpa::Config for Runtime {
grandpa::EquivocationReportSystem<Self, ValidatorSets, ValidatorSets, ReportLongevity>; grandpa::EquivocationReportSystem<Self, ValidatorSets, ValidatorSets, ReportLongevity>;
} }
#[doc(hidden)]
pub struct GetCurrentSessionForSubstrate;
impl pallet_session::GetCurrentSessionForSubstrate for GetCurrentSessionForSubstrate {
fn get() -> u32 {
validator_sets::Pallet::<Runtime>::latest_decided_session(NetworkId::Serai).unwrap().0 - 1
}
}
impl pallet_session::Config for Runtime {
type Session = GetCurrentSessionForSubstrate;
}
pub type Executive = frame_executive::Executive< pub type Executive = frame_executive::Executive<
Runtime, Runtime,
Block, Block,
@@ -329,7 +317,7 @@ pub type Executive = frame_executive::Executive<
construct_runtime!( construct_runtime!(
pub enum Runtime { pub enum Runtime {
System: system exclude_parts { Call }, System: system,
Timestamp: timestamp, Timestamp: timestamp,
@@ -379,6 +367,11 @@ sp_api::decl_runtime_apis! {
pub trait SeraiRuntimeApi { pub trait SeraiRuntimeApi {
fn validators(network_id: NetworkId) -> Vec<PublicKey>; fn validators(network_id: NetworkId) -> Vec<PublicKey>;
} }
#[api_version(1)]
pub trait GenesisApi {
fn build(genesis: RuntimeGenesisConfig);
}
} }
sp_api::impl_runtime_apis! { sp_api::impl_runtime_apis! {
@@ -391,22 +384,9 @@ sp_api::impl_runtime_apis! {
Executive::execute_block(block); Executive::execute_block(block);
} }
fn initialize_block(header: &Header) { fn initialize_block(header: &Header) -> sp_runtime::ExtrinsicInclusionMode {
Executive::initialize_block(header) Executive::initialize_block(header);
} sp_runtime::ExtrinsicInclusionMode::AllExtrinsics
}
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
OpaqueMetadata::new(Runtime::metadata().into())
}
fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
Runtime::metadata_at_version(version)
}
fn metadata_versions() -> sp_std::vec::Vec<u32> {
Runtime::metadata_versions()
} }
} }
@@ -606,6 +586,12 @@ sp_api::impl_runtime_apis! {
} }
} }
impl crate::GenesisApi<Block> for Runtime {
fn build(genesis: RuntimeGenesisConfig) {
<RuntimeGenesisConfig as frame_support::traits::BuildGenesisConfig>::build(&genesis)
}
}
impl dex::DexApi<Block> for Runtime { impl dex::DexApi<Block> for Runtime {
fn quote_price_exact_tokens_for_tokens( fn quote_price_exact_tokens_for_tokens(
coin1: Coin, coin1: Coin,
@@ -630,3 +616,20 @@ sp_api::impl_runtime_apis! {
} }
} }
} }
impl<LocalCall> frame_system::offchain::CreateTransactionBase<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
type Extrinsic = <Block as BlockT>::Extrinsic;
type RuntimeCall = RuntimeCall;
}
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_bare(call: RuntimeCall) -> <Block as BlockT>::Extrinsic {
<<Block as BlockT>::Extrinsic as frame_support::traits::InherentBuilder>::new_inherent(call)
}
}

View File

@@ -13,20 +13,19 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.cargo-machete] [package.metadata.cargo-machete]
ignored = ["scale", "scale-info"] ignored = ["scale"]
[lints] [lints]
workspace = true workspace = true
[dependencies] [dependencies]
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-io = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-system = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
serai-primitives = { path = "../../primitives", default-features = false } serai-primitives = { path = "../../primitives", default-features = false }
serai-signals-primitives = { path = "../primitives", default-features = false } serai-signals-primitives = { path = "../primitives", default-features = false }
@@ -37,7 +36,6 @@ in-instructions-pallet = { package = "serai-in-instructions-pallet", path = "../
[features] [features]
std = [ std = [
"scale/std", "scale/std",
"scale-info/std",
"sp-core/std", "sp-core/std",
"sp-io/std", "sp-io/std",

View File

@@ -9,8 +9,6 @@
)] // TODO )] // TODO
#[frame_support::pallet] #[frame_support::pallet]
pub mod pallet { pub mod pallet {
use scale_info::TypeInfo;
use sp_core::sr25519::Public; use sp_core::sr25519::Public;
use sp_io::hashing::blake2_256; use sp_io::hashing::blake2_256;
@@ -25,17 +23,13 @@ pub mod pallet {
use in_instructions_pallet::{Config as IiConfig, Pallet as InInstructions}; use in_instructions_pallet::{Config as IiConfig, Pallet as InInstructions};
#[pallet::config] #[pallet::config]
pub trait Config: pub trait Config: frame_system::Config<AccountId = Public> + VsConfig + IiConfig {
frame_system::Config<AccountId = Public> + VsConfig + IiConfig + TypeInfo
{
type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>;
type RetirementValidityDuration: Get<u32>; type RetirementValidityDuration: Get<u32>;
type RetirementLockInDuration: Get<u32>; type RetirementLockInDuration: Get<u32>;
} }
#[pallet::genesis_config] #[pallet::genesis_config]
#[derive(Debug, Encode, Decode)] #[derive(Debug)]
pub struct GenesisConfig<T: Config> { pub struct GenesisConfig<T: Config> {
_config: PhantomData<T>, _config: PhantomData<T>,
} }
@@ -56,7 +50,7 @@ pub mod pallet {
#[pallet::pallet] #[pallet::pallet]
pub struct Pallet<T>(PhantomData<T>); pub struct Pallet<T>(PhantomData<T>);
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
pub struct RegisteredRetirementSignal<T: Config> { pub struct RegisteredRetirementSignal<T: Config> {
in_favor_of: [u8; 32], in_favor_of: [u8; 32],
registrant: T::AccountId, registrant: T::AccountId,

View File

@@ -19,7 +19,6 @@ workspace = true
zeroize = { version = "^1.5", features = ["derive"], optional = true } zeroize = { version = "^1.5", features = ["derive"], optional = true }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
borsh = { version = "1", default-features = false, features = ["derive", "de_strict_order"], optional = true } borsh = { version = "1", default-features = false, features = ["derive", "de_strict_order"], optional = true }
serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true } serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true }
@@ -31,7 +30,6 @@ std = [
"zeroize", "zeroize",
"scale/std", "scale/std",
"scale-info/std",
"borsh?/std", "borsh?/std",
"serde?/std", "serde?/std",

View File

@@ -1,13 +1,15 @@
#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
#![expect(clippy::cast_possible_truncation)]
use scale::{Encode, Decode, MaxEncodedLen}; use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
use serai_primitives::ExternalNetworkId; use serai_primitives::ExternalNetworkId;
#[derive(Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] #[derive(
Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(zeroize::Zeroize))] #[cfg_attr(feature = "std", derive(zeroize::Zeroize))]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]

View File

@@ -13,7 +13,7 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.cargo-machete] [package.metadata.cargo-machete]
ignored = ["scale", "scale-info"] ignored = ["scale"]
[lints] [lints]
workspace = true workspace = true
@@ -22,21 +22,21 @@ workspace = true
hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] } hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-io = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-session = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-staking = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-staking = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-system = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
pallet-babe = { git = "https://github.com/serai-dex/substrate", default-features = false } pallet-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
pallet-grandpa = { git = "https://github.com/serai-dex/substrate", default-features = false } pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
serai-primitives = { path = "../../primitives", default-features = false } serai-primitives = { path = "../../primitives", default-features = false }
validator-sets-primitives = { package = "serai-validator-sets-primitives", path = "../primitives", default-features = false } validator-sets-primitives = { package = "serai-validator-sets-primitives", path = "../primitives", default-features = false }
@@ -47,19 +47,19 @@ dex-pallet = { package = "serai-dex-pallet", path = "../../dex/pallet", default-
[features] [features]
std = [ std = [
"scale/std", "scale/std",
"scale-info/std",
"sp-core/std", "sp-core/std",
"sp-io/std", "sp-io/std",
"sp-std/std", "sp-std/std",
"sp-application-crypto/std", "sp-application-crypto/std",
"sp-runtime/std",
"sp-session/std", "sp-session/std",
"sp-runtime/std",
"sp-staking/std", "sp-staking/std",
"frame-system/std", "frame-system/std",
"frame-support/std", "frame-support/std",
"pallet-session/std",
"pallet-babe/std", "pallet-babe/std",
"pallet-grandpa/std", "pallet-grandpa/std",

View File

@@ -2,13 +2,13 @@
use core::marker::PhantomData; use core::marker::PhantomData;
use scale::{Encode, Decode}; use scale::{Encode, Decode, DecodeWithMemTracking};
use scale_info::TypeInfo;
use sp_std::{vec, vec::Vec}; use sp_std::{vec, vec::Vec};
use sp_core::sr25519::{Public, Signature}; use sp_core::sr25519::{Public, Signature};
use sp_application_crypto::RuntimePublic; use sp_application_crypto::RuntimePublic;
use sp_session::{ShouldEndSession, GetSessionNumber, GetValidatorCount}; use sp_session::{GetSessionNumber, GetValidatorCount};
use pallet_session::ShouldEndSession;
use sp_runtime::{KeyTypeId, ConsensusEngineId, traits::IsMember}; use sp_runtime::{KeyTypeId, ConsensusEngineId, traits::IsMember};
use sp_staking::offence::{ReportOffence, Offence, OffenceError}; use sp_staking::offence::{ReportOffence, Offence, OffenceError};
@@ -16,7 +16,7 @@ use frame_system::{pallet_prelude::*, RawOrigin};
use frame_support::{ use frame_support::{
pallet_prelude::*, pallet_prelude::*,
sp_runtime::SaturatedConversion, sp_runtime::SaturatedConversion,
traits::{DisabledValidators, KeyOwnerProofSystem, FindAuthor}, traits::{DisabledValidators, KeyOwnerProofSystem, FindAuthor, OneSessionHandler},
BoundedVec, WeakBoundedVec, StoragePrefixedMap, BoundedVec, WeakBoundedVec, StoragePrefixedMap,
}; };
@@ -35,7 +35,7 @@ use pallet_grandpa::{
EquivocationOffence as GrandpaEquivocationOffence, EquivocationOffence as GrandpaEquivocationOffence,
}; };
#[derive(Debug, Encode, Decode, TypeInfo, PartialEq, Eq, Clone)] #[derive(Debug, Encode, Decode, DecodeWithMemTracking, PartialEq, Eq, Clone)]
pub struct MembershipProof<T: pallet::Config>(pub Public, pub PhantomData<T>); pub struct MembershipProof<T: pallet::Config>(pub Public, pub PhantomData<T>);
impl<T: pallet::Config> GetSessionNumber for MembershipProof<T> { impl<T: pallet::Config> GetSessionNumber for MembershipProof<T> {
fn session(&self) -> u32 { fn session(&self) -> u32 {
@@ -74,17 +74,15 @@ pub mod pallet {
frame_system::Config<AccountId = Public> frame_system::Config<AccountId = Public>
+ coins_pallet::Config + coins_pallet::Config
+ dex_pallet::Config + dex_pallet::Config
+ pallet_session::Config
+ pallet_babe::Config + pallet_babe::Config
+ pallet_grandpa::Config + pallet_grandpa::Config
+ TypeInfo
{ {
type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>;
type ShouldEndSession: ShouldEndSession<BlockNumberFor<Self>>; type ShouldEndSession: ShouldEndSession<BlockNumberFor<Self>>;
} }
#[pallet::genesis_config] #[pallet::genesis_config]
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] #[derive(Clone, Debug)]
pub struct GenesisConfig<T: Config> { pub struct GenesisConfig<T: Config> {
/// Networks to spawn Serai with, and the stake requirement per key share. /// Networks to spawn Serai with, and the stake requirement per key share.
/// ///
@@ -242,7 +240,8 @@ pub mod pallet {
Amount(u64::from_be_bytes(raw)) Amount(u64::from_be_bytes(raw))
} }
fn recover_key_from_sorted_allocation_key(key: &[u8]) -> Public { fn recover_key_from_sorted_allocation_key(key: &[u8]) -> Public {
Public(key[(key.len() - 32) ..].try_into().unwrap()) let key: [u8; 32] = key[(key.len() - 32) ..].try_into().unwrap();
key.into()
} }
// Returns if this validator already had an allocation set. // Returns if this validator already had an allocation set.
fn set_allocation(network: NetworkId, key: Public, amount: Amount) -> bool { fn set_allocation(network: NetworkId, key: Public, amount: Amount) -> bool {
@@ -810,10 +809,13 @@ pub mod pallet {
), ),
Some(session), Some(session),
); );
Grandpa::<T>::new_session( fn grandpa_map(i: &(Public, u64)) -> (&Public, GrandpaAuthorityId) {
(&i.0, i.0.into())
}
Grandpa::<T>::on_new_session(
true, true,
session, now_validators.iter().map(grandpa_map),
now_validators.into_iter().map(|(id, w)| (GrandpaAuthorityId::from(id), w)).collect(), next_validators.iter().map(grandpa_map),
); );
// Clear SeraiDisabledIndices, only preserving keys still present in the new session // Clear SeraiDisabledIndices, only preserving keys still present in the new session
@@ -1292,6 +1294,17 @@ pub mod pallet {
fn is_disabled(index: u32) -> bool { fn is_disabled(index: u32) -> bool {
SeraiDisabledIndices::<T>::get(index).is_some() SeraiDisabledIndices::<T>::get(index).is_some()
} }
fn disabled_validators() -> Vec<u32> {
// TODO: Use a storage iterator here
let mut res = vec![];
for i in 0 .. MAX_KEY_SHARES_PER_SET {
let i = i.into();
if Self::is_disabled(i) {
res.push(i);
}
}
res
}
} }
} }

View File

@@ -26,15 +26,14 @@ borsh = { version = "1", default-features = false, features = ["derive", "de_str
serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true } serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
sp-std = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "7f2a8865cd0ded35e1d62fc330915d44dfa3beab", default-features = false }
serai-primitives = { path = "../../primitives", default-features = false } serai-primitives = { path = "../../primitives", default-features = false }
[features] [features]
std = ["zeroize", "ciphersuite/std", "dkg-musig/std", "borsh?/std", "serde?/std", "scale/std", "scale-info/std", "sp-core/std", "sp-std/std", "serai-primitives/std"] std = ["zeroize", "ciphersuite/std", "dkg-musig/std", "borsh?/std", "serde?/std", "scale/std", "sp-core/std", "sp-std/std", "serai-primitives/std"]
borsh = ["dep:borsh", "serai-primitives/borsh"] borsh = ["dep:borsh", "serai-primitives/borsh"]
serde = ["dep:serde", "serai-primitives/serde"] serde = ["dep:serde", "serai-primitives/serde"]
default = ["std"] default = ["std"]

View File

@@ -6,8 +6,7 @@ use zeroize::Zeroize;
use dalek_ff_group::Ristretto; use dalek_ff_group::Ristretto;
use ciphersuite::{group::GroupEncoding, Ciphersuite}; use ciphersuite::{group::GroupEncoding, Ciphersuite};
use scale::{Encode, Decode, MaxEncodedLen}; use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
use scale_info::TypeInfo;
#[cfg(feature = "borsh")] #[cfg(feature = "borsh")]
use borsh::{BorshSerialize, BorshDeserialize}; use borsh::{BorshSerialize, BorshDeserialize};
@@ -27,7 +26,17 @@ pub const MAX_KEY_LEN: u32 = 96;
/// The type used to identify a specific session of validators. /// The type used to identify a specific session of validators.
#[derive( #[derive(
Clone, Copy, PartialEq, Eq, Hash, Default, Debug, Encode, Decode, TypeInfo, MaxEncodedLen, Clone,
Copy,
PartialEq,
Eq,
Hash,
Default,
Debug,
Encode,
Decode,
DecodeWithMemTracking,
MaxEncodedLen,
)] )]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
@@ -35,7 +44,9 @@ pub const MAX_KEY_LEN: u32 = 96;
pub struct Session(pub u32); pub struct Session(pub u32);
/// The type used to identify a specific validator set during a specific session. /// The type used to identify a specific validator set during a specific session.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] #[derive(
Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -45,7 +56,9 @@ pub struct ValidatorSet {
} }
/// The type used to identify a specific validator set during a specific session. /// The type used to identify a specific validator set during a specific session.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] #[derive(
Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -78,7 +91,7 @@ pub type ExternalKey = BoundedVec<u8, MaxKeyLen>;
/// The key pair for a validator set. /// The key pair for a validator set.
/// ///
/// This is their Ristretto key, used for signing Batches, and their key on the external network. /// This is their Ristretto key, used for signing Batches, and their key on the external network.
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen)]
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct KeyPair( pub struct KeyPair(
@@ -128,7 +141,7 @@ pub fn musig_key(set: ValidatorSet, set_keys: &[Public]) -> Public {
.expect("invalid participant"), .expect("invalid participant"),
); );
} }
Public(dkg_musig::musig_key_vartime::<Ristretto>(musig_context(set), &keys).unwrap().to_bytes()) dkg_musig::musig_key_vartime::<Ristretto>(musig_context(set), &keys).unwrap().to_bytes().into()
} }
/// The message for the set_keys signature. /// The message for the set_keys signature.

View File

@@ -28,7 +28,7 @@ use messages::{
}; };
use serai_message_queue::{Service, Metadata, client::MessageQueue}; use serai_message_queue::{Service, Metadata, client::MessageQueue};
use serai_client::{primitives::Signature, Serai}; use serai_client::Serai;
use dockertest::{PullPolicy, Image, TestBodySpecification, DockerOperations}; use dockertest::{PullPolicy, Image, TestBodySpecification, DockerOperations};
@@ -299,18 +299,16 @@ impl Processor {
schnorrkel_key_pair[64 ..].copy_from_slice( schnorrkel_key_pair[64 ..].copy_from_slice(
&(<Ristretto as Ciphersuite>::generator() * *substrate_key).to_bytes(), &(<Ristretto as Ciphersuite>::generator() * *substrate_key).to_bytes(),
); );
let signature = Signature( let signature = schnorrkel::keys::Keypair::from_bytes(&schnorrkel_key_pair)
schnorrkel::keys::Keypair::from_bytes(&schnorrkel_key_pair) .unwrap()
.unwrap() .sign_simple(b"substrate", &cosign_block_msg(block_number, block))
.sign_simple(b"substrate", &cosign_block_msg(block_number, block)) .to_bytes();
.to_bytes(),
);
send_message( send_message(
messages::coordinator::ProcessorMessage::CosignedBlock { messages::coordinator::ProcessorMessage::CosignedBlock {
block_number, block_number,
block, block,
signature: signature.0.to_vec(), signature: signature.to_vec(),
} }
.into(), .into(),
) )

View File

@@ -19,7 +19,7 @@ use dkg::Participant;
use scale::Encode; use scale::Encode;
use serai_client::{ use serai_client::{
primitives::{BlockHash, Signature}, primitives::BlockHash,
in_instructions::{ in_instructions::{
primitives::{Batch, SignedBatch, batch_message}, primitives::{Batch, SignedBatch, batch_message},
InInstructionsEvent, InInstructionsEvent,
@@ -166,12 +166,11 @@ pub async fn batch(
OsRng.fill_bytes(&mut schnorrkel_key_pair[32 .. 64]); OsRng.fill_bytes(&mut schnorrkel_key_pair[32 .. 64]);
schnorrkel_key_pair[64 ..] schnorrkel_key_pair[64 ..]
.copy_from_slice(&(<Ristretto as Ciphersuite>::generator() * **substrate_key).to_bytes()); .copy_from_slice(&(<Ristretto as Ciphersuite>::generator() * **substrate_key).to_bytes());
let signature = Signature( let signature = schnorrkel::keys::Keypair::from_bytes(&schnorrkel_key_pair)
schnorrkel::keys::Keypair::from_bytes(&schnorrkel_key_pair) .unwrap()
.unwrap() .sign_simple(b"substrate", &batch_message(&batch))
.sign_simple(b"substrate", &batch_message(&batch)) .to_bytes()
.to_bytes(), .into();
);
let batch = SignedBatch { batch, signature }; let batch = SignedBatch { batch, signature };

Some files were not shown because too many files have changed in this diff Show More