From 012b8fddaee025eb6db5d9cbe4a24a459c206809 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Wed, 5 Nov 2025 01:18:21 -0500 Subject: [PATCH] Get `serai-node` to compile again --- substrate/abi/Cargo.toml | 6 +- substrate/client/Cargo.toml | 6 +- substrate/coins/Cargo.toml | 8 +- substrate/core/Cargo.toml | 6 +- substrate/dex/Cargo.toml | 16 +- substrate/economic-security/Cargo.toml | 18 +- substrate/emissions/Cargo.toml | 8 +- substrate/genesis-liquidity/Cargo.toml | 10 +- substrate/in-instructions/Cargo.toml | 20 +- substrate/node/Cargo.toml | 53 ++- substrate/node/build.rs | 5 - substrate/node/src/chain_spec.rs | 148 +++----- substrate/node/src/command.rs | 8 +- substrate/node/src/rpc.rs | 110 +++--- substrate/node/src/service.rs | 3 +- substrate/primitives/Cargo.toml | 2 +- substrate/runtime/Cargo.toml | 37 +- substrate/runtime/src/lib.rs | 506 ++++++++----------------- substrate/signals/Cargo.toml | 6 +- substrate/validator-sets/Cargo.toml | 18 +- substrate/validator-sets/src/lib.rs | 6 + 21 files changed, 403 insertions(+), 597 deletions(-) delete mode 100644 substrate/node/build.rs diff --git a/substrate/abi/Cargo.toml b/substrate/abi/Cargo.toml index d3c14eca..619b6518 100644 --- a/substrate/abi/Cargo.toml +++ b/substrate/abi/Cargo.toml @@ -22,12 +22,12 @@ workspace = true borsh = { version = "1", default-features = false, features = ["derive", "de_strict_order"] } bitvec = { version = "1", default-features = false, features = ["alloc"] } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } serde = { version = "1", default-features = false, features = ["derive"], optional = true } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"], optional = true } -sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false, features = ["serde"], optional = true } -frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false, optional = true } +sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false, features = ["serde"], optional = true } +frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false, optional = true } serai-primitives = { path = "../primitives", version = "0.1", default-features = false } diff --git a/substrate/client/Cargo.toml b/substrate/client/Cargo.toml index 7f34b956..4e5d3d93 100644 --- a/substrate/client/Cargo.toml +++ b/substrate/client/Cargo.toml @@ -31,9 +31,9 @@ serde_json = { version = "1", optional = true } serai-abi = { path = "../abi", version = "0.1" } multiaddr = { version = "0.18", optional = true } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", optional = true } -sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", optional = true } -frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", optional = true } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", optional = true } +sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", optional = true } +frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", optional = true } async-lock = "3" diff --git a/substrate/coins/Cargo.toml b/substrate/coins/Cargo.toml index ba7961b5..3b349af3 100644 --- a/substrate/coins/Cargo.toml +++ b/substrate/coins/Cargo.toml @@ -18,10 +18,10 @@ workspace = true [dependencies] scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } -frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } serai-abi = { path = "../abi", default-features = false, features = ["substrate"] } serai-core-pallet = { path = "../core", default-features = false } @@ -29,7 +29,7 @@ serai-core-pallet = { path = "../core", default-features = false } [dev-dependencies] borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] } -sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false, features = ["std"] } +sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false, features = ["std"] } [features] std = [ diff --git a/substrate/core/Cargo.toml b/substrate/core/Cargo.toml index 655e8ce4..08b1aa69 100644 --- a/substrate/core/Cargo.toml +++ b/substrate/core/Cargo.toml @@ -20,10 +20,10 @@ borsh = { version = "1", default-features = false, features = ["derive", "de_str scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } -frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } serai-abi = { path = "../abi", default-features = false, features = ["substrate"] } diff --git a/substrate/dex/Cargo.toml b/substrate/dex/Cargo.toml index 3dfe7066..df930377 100644 --- a/substrate/dex/Cargo.toml +++ b/substrate/dex/Cargo.toml @@ -21,15 +21,15 @@ workspace = true [dependencies] scale = { package = "parity-scale-codec", version = "3.6.1", default-features = false } -sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } -frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-benchmarking = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false, optional = true } +frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-benchmarking = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false, optional = true } coins-pallet = { package = "serai-coins-pallet", path = "../coins", default-features = false } diff --git a/substrate/economic-security/Cargo.toml b/substrate/economic-security/Cargo.toml index 712af0b7..b7bec356 100644 --- a/substrate/economic-security/Cargo.toml +++ b/substrate/economic-security/Cargo.toml @@ -21,8 +21,8 @@ workspace = true [dependencies] scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } dex-pallet = { package = "serai-dex-pallet", path = "../dex", default-features = false } coins-pallet = { package = "serai-coins-pallet", path = "../coins", default-features = false } @@ -30,16 +30,16 @@ coins-pallet = { package = "serai-coins-pallet", path = "../coins", default-feat serai-primitives = { path = "../primitives", default-features = false } [dev-dependencies] -pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -pallet-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +pallet-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } validator-sets-pallet = { package = "serai-validator-sets-pallet", path = "../validator-sets", default-features = false } -sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } [features] std = [ diff --git a/substrate/emissions/Cargo.toml b/substrate/emissions/Cargo.toml index bd7b2c10..02847089 100644 --- a/substrate/emissions/Cargo.toml +++ b/substrate/emissions/Cargo.toml @@ -21,11 +21,11 @@ workspace = true [dependencies] scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } -sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } coins-pallet = { package = "serai-coins-pallet", path = "../coins", default-features = false } validator-sets-pallet = { package = "serai-validator-sets-pallet", path = "../validator-sets", default-features = false } diff --git a/substrate/genesis-liquidity/Cargo.toml b/substrate/genesis-liquidity/Cargo.toml index e69b6d89..697c6e34 100644 --- a/substrate/genesis-liquidity/Cargo.toml +++ b/substrate/genesis-liquidity/Cargo.toml @@ -21,12 +21,12 @@ workspace = true [dependencies] scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } -sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } dex-pallet = { package = "serai-dex-pallet", path = "../dex", default-features = false } coins-pallet = { package = "serai-coins-pallet", path = "../coins", default-features = false } diff --git a/substrate/in-instructions/Cargo.toml b/substrate/in-instructions/Cargo.toml index b58150bc..0e8de127 100644 --- a/substrate/in-instructions/Cargo.toml +++ b/substrate/in-instructions/Cargo.toml @@ -24,14 +24,14 @@ bitvec = { version = "1", default-features = false, features = ["alloc"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] } -sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-std = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } -frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } serai-primitives = { path = "../primitives", default-features = false } @@ -42,9 +42,9 @@ genesis-liquidity-pallet = { package = "serai-genesis-liquidity-pallet", path = emissions-pallet = { package = "serai-emissions-pallet", path = "../emissions", default-features = false } [dev-dependencies] -pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -pallet-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +pallet-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } economic-security-pallet = { package = "serai-economic-security-pallet", path = "../economic-security", default-features = false } diff --git a/substrate/node/Cargo.toml b/substrate/node/Cargo.toml index e3f01a0e..58f3e1ca 100644 --- a/substrate/node/Cargo.toml +++ b/substrate/node/Cargo.toml @@ -34,19 +34,20 @@ secq256k1 = { path = "../../crypto/secq256k1" } libp2p = "0.56" -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sp-keystore = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sp-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sp-state-machine = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sp-blockchain = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sp-block-builder = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sp-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sp-keystore = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sp-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sp-state-machine = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sp-blockchain = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sp-block-builder = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sp-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } -frame-benchmarking = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } +frame-benchmarking = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +serai-abi = { path = "../abi", features = ["std", "substrate"] } serai-runtime = { path = "../runtime", features = ["std"] } clap = { version = "4", features = ["derive"] } @@ -55,24 +56,22 @@ futures-util = "0.3" tokio = { version = "1", features = ["sync", "rt-multi-thread"] } jsonrpsee = { version = "0.24", features = ["server"] } -sc-transaction-pool = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sc-transaction-pool-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sc-basic-authorship = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sc-executor = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sc-service = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sc-client-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sc-network = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } +sc-transaction-pool = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sc-transaction-pool-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sc-basic-authorship = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sc-executor = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sc-service = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sc-client-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sc-network = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } -sc-consensus = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sc-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sc-consensus-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sc-authority-discovery = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } +sc-consensus = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sc-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sc-consensus-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sc-authority-discovery = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } -sc-telemetry = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sc-chain-spec = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } -sc-cli = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } - -frame-system-rpc-runtime-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } +sc-telemetry = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sc-chain-spec = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } +sc-cli = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } serai-env = { path = "../../common/env" } diff --git a/substrate/node/build.rs b/substrate/node/build.rs deleted file mode 100644 index 5f01139d..00000000 --- a/substrate/node/build.rs +++ /dev/null @@ -1,5 +0,0 @@ -use substrate_build_script_utils::generate_cargo_keys; - -fn main() { - generate_cargo_keys(); -} diff --git a/substrate/node/src/chain_spec.rs b/substrate/node/src/chain_spec.rs index c642e30f..f2ab2f06 100644 --- a/substrate/node/src/chain_spec.rs +++ b/substrate/node/src/chain_spec.rs @@ -1,4 +1,4 @@ -#![expect(unused_imports, dead_code, redundant_closure_call)] +#![expect(unused_imports, dead_code)] use core::marker::PhantomData; @@ -10,103 +10,94 @@ use ciphersuite::{group::GroupEncoding, Ciphersuite}; use embedwards25519::Embedwards25519; use secq256k1::Secq256k1; -use serai_runtime::{ - primitives::*, validator_sets::AllEmbeddedEllipticCurveKeysAtGenesis, WASM_BINARY, - BABE_GENESIS_EPOCH_CONFIG, RuntimeGenesisConfig, SystemConfig, CoinsConfig, ValidatorSetsConfig, - SignalsConfig, BabeConfig, GrandpaConfig, EmissionsConfig, +use serai_abi::{ + primitives::{ + prelude::*, + crypto::{Public, SignedEmbeddedEllipticCurveKeys}, + }, + SubstrateBlock as Block, }; +use serai_runtime::*; pub type ChainSpec = sc_service::GenericChainSpec; -fn account_from_name(name: &'static str) -> PublicKey { - insecure_pair_from_name(name).public() +fn insecure_account_from_name(name: &'static str) -> Public { + sp_core::sr25519::Pair::from_string(&format!("//{name}"), None).unwrap().public().into() } fn insecure_arbitrary_public_key_from_name(name: &'static str) -> Vec { - let key = insecure_arbitrary_key_from_name::(name); + let key = C::hash_to_F(name.as_bytes()); (C::generator() * key).to_bytes().as_ref().to_vec() } +fn insecure_embedded_elliptic_curve_keys_from_name( + name: &'static str, +) -> Vec { + vec![] // TODO +} + fn wasm_binary() -> Vec { // TODO: Accept a config of runtime path - const WASM_PATH: &str = "/runtime/serai.wasm"; - if let Ok(binary) = std::fs::read(WASM_PATH) { - log::info!("using {WASM_PATH}"); + const DEFAULT_WASM_PATH: &str = "/runtime/serai.wasm"; + let path = serai_env::var("SERAI_WASM").unwrap_or(DEFAULT_WASM_PATH.to_string()); + if let Ok(binary) = std::fs::read(&path) { + log::info!("using {path} for the WASM"); return binary; } log::info!("using built-in wasm"); WASM_BINARY.ok_or("compiled in wasm not available").unwrap().to_vec() } -/* fn devnet_genesis( validators: &[&'static str], - endowed_accounts: Vec, + endowed_accounts: Vec, ) -> RuntimeGenesisConfig { let validators = validators .iter() .map(|name| { - ( - account_from_name(name), - AllEmbeddedEllipticCurveKeysAtGenesis { - embedwards25519: insecure_arbitrary_public_key_from_name::(name) - .try_into() - .unwrap(), - secq256k1: insecure_arbitrary_public_key_from_name::(name).try_into().unwrap(), - }, - ) - }) - .collect::>(); - let key_shares = NETWORKS - .iter() - .map(|network| match network { - NetworkId::Serai => (NetworkId::Serai, Amount(50_000 * 10_u64.pow(8))), - NetworkId::External(ExternalNetworkId::Bitcoin) => { - (NetworkId::External(ExternalNetworkId::Bitcoin), Amount(1_000_000 * 10_u64.pow(8))) - } - NetworkId::External(ExternalNetworkId::Ethereum) => { - (NetworkId::External(ExternalNetworkId::Ethereum), Amount(1_000_000 * 10_u64.pow(8))) - } - NetworkId::External(ExternalNetworkId::Monero) => { - (NetworkId::External(ExternalNetworkId::Monero), Amount(100_000 * 10_u64.pow(8))) - } + (insecure_account_from_name(name), insecure_embedded_elliptic_curve_keys_from_name(name)) }) .collect::>(); RuntimeGenesisConfig { system: SystemConfig { _config: PhantomData }, - transaction_payment: Default::default(), - coins: CoinsConfig { accounts: endowed_accounts .into_iter() - .map(|a| (a, Balance { coin: Coin::Serai, amount: Amount(1 << 60) })) + .map(|address| (address.into(), Balance { coin: Coin::Serai, amount: Amount(1 << 60) })) .collect(), - _ignore: Default::default(), + _instance: PhantomData, }, + liquidity_tokens: LiquidityTokensConfig { accounts: vec![], _instance: PhantomData }, + validator_sets: ValidatorSetsConfig { - networks: key_shares.clone(), - participants: validators.clone(), - }, - emissions: EmissionsConfig { - networks: key_shares, - participants: validators.iter().map(|(validator, _)| *validator).collect(), + participants: validators + .iter() + .map(|validator| (validator.0.into(), validator.1.clone())) + .collect(), }, signals: SignalsConfig::default(), babe: BabeConfig { - authorities: validators.iter().map(|validator| ((*validator).into(), 1)).collect(), + authorities: validators + .iter() + .map(|validator| (sp_core::sr25519::Public::from(validator.0).into(), 1)) + .collect(), epoch_config: BABE_GENESIS_EPOCH_CONFIG, _config: PhantomData, }, grandpa: GrandpaConfig { - authorities: validators.into_iter().map(|validator| (validator.0.into(), 1)).collect(), + authorities: validators + .into_iter() + .map(|validator| (sp_core::sr25519::Public::from(validator.0).into(), 1)) + .collect(), _config: PhantomData, }, } } +/* fn testnet_genesis(validators: Vec<&'static str>) -> RuntimeGenesisConfig { let validators = validators .into_iter() @@ -133,21 +124,16 @@ fn testnet_genesis(validators: Vec<&'static str>) -> RuntimeGenesisConfig { RuntimeGenesisConfig { system: SystemConfig { _config: PhantomData }, - transaction_payment: Default::default(), - coins: CoinsConfig { accounts: validators .iter() .map(|a| (*a, Balance { coin: Coin::Serai, amount: Amount(5_000_000 * 10_u64.pow(8)) })) .collect(), - _ignore: Default::default(), }, validator_sets: ValidatorSetsConfig { - networks: key_shares.clone(), participants: validators.clone(), }, - emissions: EmissionsConfig { networks: key_shares, participants: validators.clone() }, signals: SignalsConfig::default(), babe: BabeConfig { authorities: validators.iter().map(|validator| ((*validator).into(), 1)).collect(), @@ -212,22 +198,17 @@ pub fn development_config() -> ChainSpec { "devnet", ChainType::Development, "serai-devnet", - &(move || { - /* - let _ = devnet_genesis( - &["Alice"], - vec![ - account_from_name("Alice"), - account_from_name("Bob"), - account_from_name("Charlie"), - account_from_name("Dave"), - account_from_name("Eve"), - account_from_name("Ferdie"), - ], - ); - */ - todo!("TODO") - })(), + &devnet_genesis( + &["Alice"], + vec![ + insecure_account_from_name("Alice"), + insecure_account_from_name("Bob"), + insecure_account_from_name("Charlie"), + insecure_account_from_name("Dave"), + insecure_account_from_name("Eve"), + insecure_account_from_name("Ferdie"), + ], + ), ) } @@ -237,22 +218,17 @@ pub fn local_config() -> ChainSpec { "local", ChainType::Local, "serai-local", - &(move || { - /* - let _ = devnet_genesis( - &["Alice", "Bob", "Charlie", "Dave"], - vec![ - account_from_name("Alice"), - account_from_name("Bob"), - account_from_name("Charlie"), - account_from_name("Dave"), - account_from_name("Eve"), - account_from_name("Ferdie"), - ], - ); - */ - todo!("TODO") - })(), + &devnet_genesis( + &["Alice", "Bob", "Charlie", "Dave"], + vec![ + insecure_account_from_name("Alice"), + insecure_account_from_name("Bob"), + insecure_account_from_name("Charlie"), + insecure_account_from_name("Dave"), + insecure_account_from_name("Eve"), + insecure_account_from_name("Ferdie"), + ], + ), ) } diff --git a/substrate/node/src/command.rs b/substrate/node/src/command.rs index 6597349a..5b55be25 100644 --- a/substrate/node/src/command.rs +++ b/substrate/node/src/command.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use serai_runtime::Block; +use serai_abi::SubstrateBlock as Block; use sc_service::{PruningMode, PartialComponents}; @@ -18,15 +18,15 @@ impl SubstrateCli for Cli { } fn impl_version() -> String { - env!("SUBSTRATE_CLI_IMPL_VERSION").to_string() + String::new() } fn description() -> String { - env!("CARGO_PKG_DESCRIPTION").to_string() + String::new() } fn author() -> String { - env!("CARGO_PKG_AUTHORS").to_string() + String::new() } fn support_url() -> String { diff --git a/substrate/node/src/rpc.rs b/substrate/node/src/rpc.rs index 379458b2..832fb77a 100644 --- a/substrate/node/src/rpc.rs +++ b/substrate/node/src/rpc.rs @@ -9,20 +9,12 @@ use sp_blockchain::{Error as BlockchainError, HeaderBackend, HeaderMetadata}; use sp_block_builder::BlockBuilder; use sp_api::ProvideRuntimeApi; -use serai_runtime::{ - in_instructions::primitives::Shorthand, - primitives::{ExternalNetworkId, NetworkId, PublicKey, SubstrateAmount, QuotePriceParams}, - // validator_sets::ValidatorSetsApi, - dex::DexApi, - Block, - Nonce, - SeraiRuntimeApi, -}; +use serai_abi::{primitives::prelude::*, SubstrateBlock as Block}; +use serai_runtime::*; use tokio::sync::RwLock; use jsonrpsee::RpcModule; -// use scale::Encode; use sc_client_api::BlockBackend; use sc_transaction_pool_api::TransactionPool; @@ -35,50 +27,44 @@ pub struct FullDeps { } pub fn create_full< - C: ProvideRuntimeApi - + HeaderBackend - + HeaderMetadata - + BlockBackend + C: 'static + Send + Sync - + 'static, - P: TransactionPool + 'static, + + ProvideRuntimeApi + serai_runtime::SeraiApi> + + HeaderBackend + + HeaderMetadata + + BlockBackend, + P: 'static + TransactionPool, >( deps: FullDeps, -) -> Result, Box> -where - C::Api: frame_system_rpc_runtime_api::AccountNonceApi - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + SeraiRuntimeApi - + DexApi - + BlockBuilder, -{ - use substrate_frame_rpc_system::{System, SystemApiServer}; - use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; - use ciphersuite::{GroupIo, WithPreferredHash}; - use ciphersuite_kp256::{k256::elliptic_curve::point::AffineCoordinates, Secp256k1}; - use dalek_ff_group::Ed25519; - use bitcoin_serai::bitcoin; - +) -> Result, Box> { let mut module = RpcModule::new(()); let FullDeps { id, client, pool, authority_discovery } = deps; - module.merge(System::new(client.clone(), pool).into_rpc())?; - module.merge(TransactionPayment::new(client.clone()).into_rpc())?; - if let Some(authority_discovery) = authority_discovery { let mut authority_discovery_module = RpcModule::new((id, client.clone(), RwLock::new(authority_discovery))); authority_discovery_module.register_async_method( "p2p_validators", |params, context, _ext| async move { - let [network]: [NetworkId; 1] = params.parse()?; + let [network]: [String; 1] = params.parse()?; + let network = match network.to_lowercase().as_str() { + "serai" => NetworkId::Serai, + "bitcoin" => ExternalNetworkId::Bitcoin.into(), + "ethereum" => ExternalNetworkId::Ethereum.into(), + "monero" => ExternalNetworkId::Monero.into(), + _ => Err(jsonrpsee::types::error::ErrorObjectOwned::owned( + -1, + "network to fetch the `p2p_validators` of was unrecognized".to_string(), + Option::<()>::None, + ))?, + }; let (id, client, authority_discovery) = &*context; let latest_block = client.info().best_hash; let validators = client.runtime_api().validators(latest_block, network).map_err(|_| { jsonrpsee::types::error::ErrorObjectOwned::owned( - -1, + -2, 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", @@ -122,6 +108,11 @@ where } /* TODO + use ciphersuite::{GroupIo, WithPreferredHash}; + use ciphersuite_kp256::{k256::elliptic_curve::point::AffineCoordinates, Secp256k1}; + use dalek_ff_group::Ed25519; + use bitcoin_serai::bitcoin; + let mut serai_json_module = RpcModule::new(client); // add network address rpc @@ -216,31 +207,28 @@ where */ let mut block_bin_module = RpcModule::new(client); - block_bin_module.register_async_method( - "chain_getBlockBin", - |params, client, _ext| async move { - let [block_hash]: [String; 1] = params.parse()?; - let Some(block_hash) = hex::decode(&block_hash).ok().and_then(|bytes| { - <[u8; 32]>::try_from(bytes.as_slice()) - .map(::Hash::from) - .ok() - }) else { - return Err(jsonrpsee::types::error::ErrorObjectOwned::owned( - -1, - "requested block hash wasn't a valid hash", - Option::<()>::None, - )); - }; - let Some(block) = client.block(block_hash).ok().flatten() else { - return Err(jsonrpsee::types::error::ErrorObjectOwned::owned( - -1, - "couldn't find requested block", - Option::<()>::None, - )); - }; - Ok(hex::encode(block.block.encode())) - }, - )?; + block_bin_module.register_async_method("serai_block", |params, client, _ext| async move { + let [block_hash]: [String; 1] = params.parse()?; + let Some(block_hash) = hex::decode(&block_hash).ok().and_then(|bytes| { + <[u8; 32]>::try_from(bytes.as_slice()) + .map(::Hash::from) + .ok() + }) else { + return Err(jsonrpsee::types::error::ErrorObjectOwned::owned( + -1, + "requested block hash wasn't a valid hash", + Option::<()>::None, + )); + }; + let Some(block) = client.block(block_hash).ok().flatten() else { + return Err(jsonrpsee::types::error::ErrorObjectOwned::owned( + -1, + "couldn't find requested block", + Option::<()>::None, + )); + }; + Ok(hex::encode(block.block.encode())) + })?; module.merge(block_bin_module)?; Ok(module) diff --git a/substrate/node/src/service.rs b/substrate/node/src/service.rs index abde6303..9829ddff 100644 --- a/substrate/node/src/service.rs +++ b/substrate/node/src/service.rs @@ -16,7 +16,8 @@ use sc_client_api::BlockBackend; use sc_telemetry::{Telemetry, TelemetryWorker}; -use serai_runtime::{Block, RuntimeApi}; +use serai_abi::SubstrateBlock as Block; +use serai_runtime::RuntimeApi; use sc_consensus_babe::{self, SlotProportion}; use sc_consensus_grandpa as grandpa; diff --git a/substrate/primitives/Cargo.toml b/substrate/primitives/Cargo.toml index 659710d0..f1698ab2 100644 --- a/substrate/primitives/Cargo.toml +++ b/substrate/primitives/Cargo.toml @@ -21,7 +21,7 @@ borsh = { version = "1", default-features = false, features = ["derive", "de_str bitvec = { version = "1", default-features = false, features = ["alloc"] } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"], optional = true } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } ciphersuite = { path = "../../crypto/ciphersuite", default-features = false, features = ["alloc"] } schnorr-signatures = { path = "../../crypto/schnorr", default-features = false } diff --git a/substrate/runtime/Cargo.toml b/substrate/runtime/Cargo.toml index 1115975b..2491d056 100644 --- a/substrate/runtime/Cargo.toml +++ b/substrate/runtime/Cargo.toml @@ -20,22 +20,28 @@ workspace = true [dependencies] scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-version = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-inherents = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-version = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-consensus-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-block-builder = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-transaction-pool = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-authority-discovery = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } serai-abi = { path = "../abi", default-features = false, features = ["substrate"] } -frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-executive = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-executive = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } -pallet-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -pallet-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +pallet-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +pallet-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } serai-core-pallet = { path = "../core", default-features = false } serai-coins-pallet = { path = "../coins", default-features = false } @@ -43,7 +49,7 @@ serai-validator-sets-pallet = { path = "../validator-sets", default-features = f serai-signals-pallet = { path = "../signals", default-features = false } [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4" } +substrate-wasm-builder = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef" } [features] std = [ @@ -54,6 +60,11 @@ std = [ "sp-version/std", "sp-runtime/std", "sp-api/std", + "sp-consensus-babe/std", + "sp-consensus-grandpa/std", + "sp-block-builder/std", + "sp-transaction-pool/std", + "sp-authority-discovery/std", "serai-abi/std", diff --git a/substrate/runtime/src/lib.rs b/substrate/runtime/src/lib.rs index c7589b50..8b2ed48f 100644 --- a/substrate/runtime/src/lib.rs +++ b/substrate/runtime/src/lib.rs @@ -6,7 +6,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); extern crate alloc; -use alloc::borrow::Cow; +use alloc::{borrow::Cow, vec::Vec}; use sp_core::{ConstU32, ConstU64, sr25519::Public}; use sp_runtime::{Perbill, Weight}; @@ -16,6 +16,7 @@ use serai_abi::{ primitives::{ network_id::{ExternalNetworkId, NetworkId}, balance::{Amount, ExternalBalance}, + validator_sets::ValidatorSet, address::SeraiAddress, }, SubstrateHeader as Header, SubstrateBlock, @@ -319,7 +320,31 @@ impl From for RuntimeCall { type Executive = frame_executive::Executive; +sp_api::decl_runtime_apis! { + #[api_version(1)] + pub trait GenesisApi { + fn build(genesis: RuntimeGenesisConfig); + } + #[api_version(1)] + pub trait SeraiApi { + fn validators(network_id: NetworkId) -> Vec; + } +} + +const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); +pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = + sp_consensus_babe::BabeEpochConfiguration { + c: PRIMARY_PROBABILITY, + allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots, + }; + sp_api::impl_runtime_apis! { + impl crate::GenesisApi for Runtime { + fn build(genesis: RuntimeGenesisConfig) { + ::build(&genesis) + } + } + impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { VERSION @@ -331,6 +356,148 @@ sp_api::impl_runtime_apis! { Executive::execute_block(block); } } + + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic( + extrinsic: ::Extrinsic, + ) -> sp_runtime::ApplyExtrinsicResult { + Executive::apply_extrinsic(extrinsic) + } + + fn finalize_block() -> Header { + Executive::finalize_block() + } + + fn inherent_extrinsics( + data: sp_inherents::InherentData, + ) -> Vec<::Extrinsic> { + data.create_extrinsics() + } + + fn check_inherents( + block: Block, + data: sp_inherents::InherentData, + ) -> sp_inherents::CheckInherentsResult { + data.check_extrinsics(&block) + } + } + + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { + fn validate_transaction( + source: sp_runtime::transaction_validity::TransactionSource, + tx: ::Extrinsic, + block_hash: ::Hash, + ) -> sp_runtime::transaction_validity::TransactionValidity { + Executive::validate_transaction(source, tx, block_hash) + } + } + + impl sp_consensus_babe::BabeApi for Runtime { + fn configuration() -> sp_consensus_babe::BabeConfiguration { + use frame_support::traits::Get; + + let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG); + sp_consensus_babe::BabeConfiguration { + slot_duration: Babe::slot_duration(), + epoch_length: ::EpochDuration::get(), + c: epoch_config.c, + authorities: Babe::authorities().to_vec(), + randomness: Babe::randomness(), + allowed_slots: epoch_config.allowed_slots, + } + } + + fn current_epoch_start() -> sp_consensus_babe::Slot { + Babe::current_epoch_start() + } + + fn current_epoch() -> sp_consensus_babe::Epoch { + Babe::current_epoch() + } + + fn next_epoch() -> sp_consensus_babe::Epoch { + Babe::next_epoch() + } + + // TODO: Revisit + fn generate_key_ownership_proof( + _slot: sp_consensus_babe::Slot, + _authority_id: pallet_babe::AuthorityId, + ) -> Option { + None + } + + // TODO: Revisit + fn submit_report_equivocation_unsigned_extrinsic( + equivocation_proof: sp_consensus_babe::EquivocationProof
, + _: sp_consensus_babe::OpaqueKeyOwnershipProof, + ) -> Option<()> { + None + } + } + + impl sp_consensus_grandpa::GrandpaApi for Runtime { + fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList { + Grandpa::grandpa_authorities() + } + + fn current_set_id() -> sp_consensus_grandpa::SetId { + Grandpa::current_set_id() + } + + // TODO: Revisit + fn generate_key_ownership_proof( + _set_id: sp_consensus_grandpa::SetId, + _authority_id: pallet_grandpa::AuthorityId, + ) -> Option { + None + } + + // TODO: Revisit + fn submit_report_equivocation_unsigned_extrinsic( + equivocation_proof: sp_consensus_grandpa::EquivocationProof< + ::Hash, + u64, + >, + _: sp_consensus_grandpa::OpaqueKeyOwnershipProof, + ) -> Option<()> { + None + } + } + + impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { + fn authorities() -> Vec { + // Converts to `[u8; 32]` so it can be hashed + let mut all = alloc::collections::BTreeSet::<[u8; 32]>::new(); + for network in NetworkId::all() { + for participant in + >::validators(network) { + all.insert(participant.into()); + } + } + all + .into_iter() + .map(|id| sp_authority_discovery::AuthorityId::from(sp_core::sr25519::Public::from(id))) + .collect() + } + } + + impl crate::SeraiApi for Runtime { + fn validators(network: NetworkId) -> Vec { + // Returning the latest-decided, not latest and active, means the active set + // may fail to peer find if there isn't sufficient overlap. If a large amount reboot, + // forcing some validators to successfully peer find in order for the threshold to become + // online again, this may cause a liveness failure. + // + // This is assumed not to matter in real life, yet an interesting note. + let Some(session) = ValidatorSets::latest_decided_session(network) else { + return alloc::vec![] + }; + ValidatorSets::selected_validators(ValidatorSet { network, session }) + .map(|validator| validator.0) + .collect() + } + } } #[derive(Clone, Default, PartialEq, Eq, Debug)] @@ -406,96 +573,8 @@ impl serai_abi::TransactionContext for Context { } /* TODO -use core::marker::PhantomData; - -// Re-export all components -pub use serai_primitives as primitives; -pub use primitives::{BlockNumber, Header}; - -pub use frame_system as system; -pub use frame_support as support; - -pub use pallet_timestamp as timestamp; - -pub use pallet_transaction_payment as transaction_payment; - -pub use coins_pallet as coins; -pub use dex_pallet as dex; - -pub use validator_sets_pallet as validator_sets; - -pub use in_instructions_pallet as in_instructions; - -pub use signals_pallet as signals; - -pub use genesis_liquidity_pallet as genesis_liquidity; -pub use emissions_pallet as emissions; - -pub use economic_security_pallet as economic_security; - -// Actually used by the runtime -use sp_core::OpaqueMetadata; -use sp_std::prelude::*; - -use sp_version::RuntimeVersion; -#[cfg(feature = "std")] -use sp_version::NativeVersion; - -use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, KeyTypeId, - traits::{Convert, BlakeTwo256, Block as BlockT}, - transaction_validity::{TransactionSource, TransactionValidity}, - BoundedVec, Perbill, ApplyExtrinsicResult, -}; - -#[allow(unused_imports)] -use primitives::{ - NetworkId, ExternalNetworkId, PublicKey, AccountLookup, SubstrateAmount, Coin, EXTERNAL_NETWORKS, - MEDIAN_PRICE_WINDOW_LENGTH, HOURS, DAYS, MINUTES, TARGET_BLOCK_TIME, BLOCK_SIZE, - FAST_EPOCH_DURATION, -}; - -use support::{ - traits::{ConstU8, ConstU16, ConstU32, ConstU64, Contains}, - weights::{ - constants::{RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND}, - IdentityFee, Weight, - }, - parameter_types, construct_runtime, -}; - use validator_sets::MembershipProof; -use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; -use babe::AuthorityId as BabeId; -use grandpa::AuthorityId as GrandpaId; - -/// A hash of some data used by the chain. -pub type Hash = sp_core::H256; - -pub type SignedExtra = ( - system::CheckNonZeroSender, - system::CheckWeight, TODO -); - -pub mod opaque { - use super::*; - - impl_opaque_keys! { - pub struct SessionKeys { - pub babe: Babe, - pub grandpa: Grandpa, - } - } -} - -pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); -pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = - sp_consensus_babe::BabeEpochConfiguration { - c: PRIMARY_PROBABILITY, - allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots, - }; - const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); parameter_types! { @@ -589,33 +668,6 @@ impl pallet_authorship::Config for Runtime { /// Longevity of an offence report. pub type ReportLongevity = ::EpochDuration; -construct_runtime!( - pub enum Runtime { - System: system exclude_parts { Call }, - - Timestamp: timestamp, - - TransactionPayment: transaction_payment, - - Coins: coins, - LiquidityTokens: coins::::{Pallet, Call, Storage, Event}, - Dex: dex, - - ValidatorSets: validator_sets, - GenesisLiquidity: genesis_liquidity, - Emissions: emissions, - - EconomicSecurity: economic_security, - - InInstructions: in_instructions, - - Signals: signals, - - Babe: babe, - Grandpa: grandpa, - } -); - #[cfg(feature = "runtime-benchmarks")] #[macro_use] extern crate frame_benchmarking; @@ -637,229 +689,7 @@ mod benches { } sp_api::impl_runtime_apis! { - impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { - VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block); - } - - fn initialize_block(header: &Header) { - Executive::initialize_block(header) - } - } - - impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) - } - - fn metadata_at_version(version: u32) -> Option { - Runtime::metadata_at_version(version) - } - - fn metadata_versions() -> sp_std::vec::Vec { - Runtime::metadata_versions() - } - } - - impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents( - block: Block, - data: sp_inherents::InherentData, - ) -> sp_inherents::CheckInherentsResult { - data.check_extrinsics(&block) - } - } - - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) - } - } - - impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &Header) { - Executive::offchain_worker(header) - } - } - - impl sp_session::SessionKeys for Runtime { - fn generate_session_keys(seed: Option>) -> Vec { - opaque::SessionKeys::generate(seed) - } - - fn decode_session_keys( - encoded: Vec, - ) -> Option, KeyTypeId)>> { - opaque::SessionKeys::decode_into_raw_public_keys(&encoded) - } - } - - impl sp_consensus_babe::BabeApi for Runtime { - fn configuration() -> sp_consensus_babe::BabeConfiguration { - use support::traits::Get; - - let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG); - sp_consensus_babe::BabeConfiguration { - slot_duration: Babe::slot_duration(), - epoch_length: ::EpochDuration::get(), - c: epoch_config.c, - authorities: Babe::authorities().to_vec(), - randomness: Babe::randomness(), - allowed_slots: epoch_config.allowed_slots, - } - } - - fn current_epoch_start() -> sp_consensus_babe::Slot { - Babe::current_epoch_start() - } - - fn current_epoch() -> sp_consensus_babe::Epoch { - Babe::current_epoch() - } - - fn next_epoch() -> sp_consensus_babe::Epoch { - Babe::next_epoch() - } - - // This refers to a key being 'owned' by an authority in a system with multiple keys per - // validator - // Since we do not have such an infrastructure, we do not need this - fn generate_key_ownership_proof( - _slot: sp_consensus_babe::Slot, - _authority_id: BabeId, - ) -> Option { - Some(sp_consensus_babe::OpaqueKeyOwnershipProof::new(vec![])) - } - - fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: sp_consensus_babe::EquivocationProof
, - _: sp_consensus_babe::OpaqueKeyOwnershipProof, - ) -> Option<()> { - let proof = MembershipProof(equivocation_proof.offender.clone().into(), PhantomData); - Babe::submit_unsigned_equivocation_report(equivocation_proof, proof) - } - } - - impl sp_consensus_grandpa::GrandpaApi for Runtime { - fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList { - Grandpa::grandpa_authorities() - } - - fn current_set_id() -> sp_consensus_grandpa::SetId { - Grandpa::current_set_id() - } - - fn generate_key_ownership_proof( - _set_id: sp_consensus_grandpa::SetId, - _authority_id: GrandpaId, - ) -> Option { - Some(sp_consensus_grandpa::OpaqueKeyOwnershipProof::new(vec![])) - } - - fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: sp_consensus_grandpa::EquivocationProof<::Hash, u64>, - _: sp_consensus_grandpa::OpaqueKeyOwnershipProof, - ) -> Option<()> { - let proof = MembershipProof(equivocation_proof.offender().clone().into(), PhantomData); - Grandpa::submit_unsigned_equivocation_report(equivocation_proof, proof) - } - } - - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: PublicKey) -> Nonce { - System::account_nonce(account) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< - Block, - SubstrateAmount - > for Runtime { - fn query_info( - uxt: ::Extrinsic, - len: u32, - ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { - TransactionPayment::query_info(uxt, len) - } - - fn query_fee_details( - uxt: ::Extrinsic, - len: u32, - ) -> transaction_payment::FeeDetails { - TransactionPayment::query_fee_details(uxt, len) - } - - fn query_weight_to_fee(weight: Weight) -> SubstrateAmount { - TransactionPayment::weight_to_fee(weight) - } - - fn query_length_to_fee(length: u32) -> SubstrateAmount { - TransactionPayment::length_to_fee(length) - } - } - - impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { - fn authorities() -> Vec { - // Converts to `[u8; 32]` so it can be hashed - let serai_validators = Babe::authorities() - .into_iter() - .map(|(id, _)| id.into_inner().0) - .collect::>(); - let mut all = serai_validators; - for network in EXTERNAL_NETWORKS { - // Returning the latest-decided, not latest and active, means the active set - // may fail to peer find if there isn't sufficient overlap. If a large amount reboot, - // forcing some validators to successfully peer find in order for the threshold to become - // online again, this may cause a liveness failure. - // - // This is assumed not to matter in real life, yet an interesting note. - let participants = - ValidatorSets::participants_for_latest_decided_set(NetworkId::from(network)) - .map_or(vec![], BoundedVec::into_inner); - for (participant, _) in participants { - all.insert(participant.0); - } - } - all.into_iter().map(|id| AuthorityDiscoveryId::from(PublicKey::from_raw(id))).collect() - } - } - impl validator_sets::ValidatorSetsApi for Runtime { - fn validators(network_id: NetworkId) -> Vec { - if network_id == NetworkId::Serai { - Babe::authorities() - .into_iter() - .map(|(id, _)| id.into_inner()) - .collect() - } else { - ValidatorSets::participants_for_latest_decided_set(network_id) - .map_or( - vec![], - |vec| vec.into_inner().into_iter().map(|(validator, _)| validator).collect() - ) - } - } - fn external_network_key(network: ExternalNetworkId) -> Option> { ValidatorSets::external_network_key(network) } diff --git a/substrate/signals/Cargo.toml b/substrate/signals/Cargo.toml index ddaab6ff..00b13587 100644 --- a/substrate/signals/Cargo.toml +++ b/substrate/signals/Cargo.toml @@ -21,10 +21,10 @@ workspace = true [dependencies] scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } -frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } serai-abi = { path = "../abi", default-features = false, features = ["substrate"] } diff --git a/substrate/validator-sets/Cargo.toml b/substrate/validator-sets/Cargo.toml index 4284ab8c..63d1bbc1 100644 --- a/substrate/validator-sets/Cargo.toml +++ b/substrate/validator-sets/Cargo.toml @@ -20,17 +20,17 @@ bitvec = { version = "1", default-features = false, features = ["alloc", "serde" scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "bit-vec"] } -sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-application-crypto = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-io = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } -frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } -pallet-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } -pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "5dfddc95c32994c1c09bd0c7a9e3633f1e5c7cc4", default-features = false } +pallet-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } +pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "dd8f2ab6c80c609f15714f554194529116b717ef", default-features = false } serai-abi = { path = "../abi", default-features = false, features = ["substrate"] } diff --git a/substrate/validator-sets/src/lib.rs b/substrate/validator-sets/src/lib.rs index 71ee672a..2582e2fe 100644 --- a/substrate/validator-sets/src/lib.rs +++ b/substrate/validator-sets/src/lib.rs @@ -301,6 +301,12 @@ mod pallet { requirement } + pub fn selected_validators( + set: ValidatorSet, + ) -> impl Iterator { + Abstractions::::selected_validators(set) + } + /* TODO pub fn distribute_block_rewards( network: NetworkId,