diff --git a/Cargo.lock b/Cargo.lock index 13febec8..77934820 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2219,7 +2219,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", ] @@ -2242,7 +2242,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-support", "frame-support-procedural", @@ -2267,7 +2267,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-support", "frame-system", @@ -2296,7 +2296,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "bitflags 1.3.2", "environmental", @@ -2329,7 +2329,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "Inflector", "cfg-expr", @@ -2347,7 +2347,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.3.1", @@ -2359,7 +2359,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "proc-macro2", "quote", @@ -2369,7 +2369,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "cfg-if", "frame-support", @@ -2388,7 +2388,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", "sp-api", @@ -2397,7 +2397,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-support", "parity-scale-codec", @@ -4831,7 +4831,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-support", "frame-system", @@ -4845,7 +4845,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-benchmarking", "frame-support", @@ -4869,7 +4869,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-benchmarking", "frame-support", @@ -4892,7 +4892,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-support", "frame-system", @@ -4913,7 +4913,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-benchmarking", "frame-support", @@ -4931,7 +4931,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-support", "frame-system", @@ -4947,7 +4947,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -4963,7 +4963,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -6116,7 +6116,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "log", "sp-core", @@ -6127,7 +6127,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "futures", @@ -6155,7 +6155,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "futures", "futures-timer", @@ -6178,7 +6178,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -6193,7 +6193,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -6212,7 +6212,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -6223,7 +6223,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "array-bytes", "chrono", @@ -6262,7 +6262,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "fnv", "futures", @@ -6287,7 +6287,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "hash-db", "kvdb", @@ -6313,7 +6313,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "futures", @@ -6338,7 +6338,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "fork-tree", @@ -6374,7 +6374,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "fork-tree", "parity-scale-codec", @@ -6387,7 +6387,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "ahash", "array-bytes", @@ -6428,7 +6428,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "futures", @@ -6451,7 +6451,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", @@ -6473,7 +6473,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -6485,7 +6485,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "anyhow", "cfg-if", @@ -6502,7 +6502,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "anstyle", "futures", @@ -6518,7 +6518,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "array-bytes", "parking_lot 0.12.1", @@ -6532,7 +6532,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "array-bytes", "async-channel", @@ -6574,7 +6574,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-channel", "cid", @@ -6594,7 +6594,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "bitflags 1.3.2", @@ -6611,7 +6611,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "ahash", "futures", @@ -6630,7 +6630,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "array-bytes", "async-channel", @@ -6651,7 +6651,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "array-bytes", "async-channel", @@ -6685,7 +6685,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "array-bytes", "futures", @@ -6703,7 +6703,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "bytes", "fnv", @@ -6735,7 +6735,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -6744,7 +6744,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "futures", "jsonrpsee", @@ -6774,7 +6774,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -6793,7 +6793,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "http", "jsonrpsee", @@ -6808,7 +6808,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "array-bytes", "futures", @@ -6834,7 +6834,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "directories", @@ -6897,7 +6897,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "log", "parity-scale-codec", @@ -6908,7 +6908,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "futures", "libc", @@ -6927,7 +6927,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "chrono", "futures", @@ -6946,7 +6946,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "anstyle", "chrono", @@ -6974,7 +6974,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -6985,7 +6985,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "futures", @@ -7011,7 +7011,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "futures", @@ -7027,7 +7027,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-channel", "futures", @@ -7256,13 +7256,13 @@ dependencies = [ "borsh", "frame-support", "parity-scale-codec", + "scale-info", "serai-coins-primitives", "serai-in-instructions-primitives", "serai-primitives", "serai-signals-primitives", "serai-validator-sets-primitives", "serde", - "sp-application-crypto", "sp-consensus-babe", "sp-consensus-grandpa", "sp-core", @@ -7277,14 +7277,15 @@ dependencies = [ "blake2", "ciphersuite", "dockertest", + "frame-system", "frost-schnorrkel", "hex", "modular-frost", "monero-serai", "parity-scale-codec", "rand_core", + "serai-abi", "serai-docker-tests", - "serai-runtime", "serde", "serde_json", "simple-request", @@ -7567,6 +7568,7 @@ name = "serai-primitives" version = "0.1.0" dependencies = [ "borsh", + "frame-support", "parity-scale-codec", "scale-info", "serde", @@ -8058,7 +8060,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "hash-db", "log", @@ -8079,7 +8081,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "Inflector", "blake2", @@ -8093,7 +8095,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "23.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", "scale-info", @@ -8106,7 +8108,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "16.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "integer-sqrt", "num-traits", @@ -8120,7 +8122,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", "scale-info", @@ -8132,7 +8134,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "sp-api", "sp-inherents", @@ -8143,7 +8145,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "futures", "log", @@ -8161,7 +8163,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "futures", @@ -8175,7 +8177,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "parity-scale-codec", @@ -8194,7 +8196,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "finality-grandpa", "log", @@ -8212,7 +8214,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", "scale-info", @@ -8224,7 +8226,7 @@ dependencies = [ [[package]] name = "sp-core" version = "21.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "array-bytes", "bitflags 1.3.2", @@ -8267,7 +8269,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "9.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "blake2b_simd", "byteorder", @@ -8279,7 +8281,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "9.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "quote", "sp-core-hashing", @@ -8289,7 +8291,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -8298,7 +8300,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "8.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "proc-macro2", "quote", @@ -8308,7 +8310,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.19.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "environmental", "parity-scale-codec", @@ -8319,7 +8321,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -8333,7 +8335,7 @@ dependencies = [ [[package]] name = "sp-io" version = "23.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "bytes", "ed25519", @@ -8355,7 +8357,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "24.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "lazy_static", "sp-core", @@ -8366,7 +8368,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.27.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", @@ -8378,7 +8380,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "thiserror", "zstd 0.12.4", @@ -8387,7 +8389,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -8398,7 +8400,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "sp-api", "sp-core", @@ -8408,7 +8410,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "8.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "backtrace", "lazy_static", @@ -8418,7 +8420,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "rustc-hash", "serde", @@ -8428,7 +8430,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "24.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "either", "hash256-std-hasher", @@ -8450,7 +8452,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "17.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -8468,7 +8470,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "Inflector", "proc-macro-crate 1.3.1", @@ -8480,7 +8482,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", "scale-info", @@ -8495,7 +8497,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -8509,7 +8511,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.28.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "hash-db", "log", @@ -8530,12 +8532,12 @@ dependencies = [ [[package]] name = "sp-std" version = "8.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" [[package]] name = "sp-storage" version = "13.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "impl-serde", "parity-scale-codec", @@ -8548,7 +8550,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "async-trait", "parity-scale-codec", @@ -8561,7 +8563,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "10.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", "sp-std", @@ -8573,7 +8575,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "sp-api", "sp-runtime", @@ -8582,7 +8584,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "22.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "ahash", "hash-db", @@ -8605,7 +8607,7 @@ dependencies = [ [[package]] name = "sp-version" version = "22.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "impl-serde", "parity-scale-codec", @@ -8622,7 +8624,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "8.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -8633,7 +8635,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "14.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -8646,7 +8648,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "20.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "parity-scale-codec", "scale-info", @@ -8824,12 +8826,12 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -8848,7 +8850,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "hyper", "log", @@ -8860,7 +8862,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/serai-dex/substrate#66af818c352bc9bcfbb9a1f04979587d06c7e02c" +source = "git+https://github.com/serai-dex/substrate#34c8c3595e7a3230058ee5e181c9d7e4be329ed2" dependencies = [ "anstyle", "build-helper", diff --git a/coordinator/src/cosign_evaluator.rs b/coordinator/src/cosign_evaluator.rs index 12c6a698..c097acd7 100644 --- a/coordinator/src/cosign_evaluator.rs +++ b/coordinator/src/cosign_evaluator.rs @@ -151,7 +151,7 @@ impl CosignEvaluator { // included the set_keys and one didn't // Because set_keys will force a cosign, it will force detection of distinct blocks // re: set_keys using keys prior to set_keys (assumed amenable to all) - let serai = self.serai.as_of(block.header().parent_hash.into()); + let serai = self.serai.as_of(block.header.parent_hash.into()); let Some(set_with_keys) = set_with_keys_fn(&serai, cosign.network).await? else { return Ok(()); diff --git a/coordinator/src/substrate/mod.rs b/coordinator/src/substrate/mod.rs index c961dca6..b6861928 100644 --- a/coordinator/src/substrate/mod.rs +++ b/coordinator/src/substrate/mod.rs @@ -464,7 +464,7 @@ async fn handle_new_blocks( // Get the keys as of the prior block // That means if this block is setting new keys (which won't lock in until we process this // block), we won't freeze up waiting for the yet-to-be-processed keys to sign this block - let serai = serai.as_of(actual_block.header().parent_hash.into()); + let serai = serai.as_of(actual_block.header.parent_hash.into()); has_no_cosigners = Some(actual_block.clone()); @@ -583,7 +583,7 @@ pub async fn scan_task( loop { match serai.latest_finalized_block().await { Ok(latest) => { - if latest.header().number >= next_substrate_block { + if latest.header.number >= next_substrate_block { return latest; } else { sleep(Duration::from_secs(3)).await; diff --git a/coordinator/src/tests/tributary/dkg.rs b/coordinator/src/tests/tributary/dkg.rs index 5b9d6c45..347e94da 100644 --- a/coordinator/src/tests/tributary/dkg.rs +++ b/coordinator/src/tests/tributary/dkg.rs @@ -4,8 +4,6 @@ use std::collections::HashMap; use zeroize::Zeroizing; use rand_core::{RngCore, OsRng}; -use scale::Decode; - use ciphersuite::{group::GroupEncoding, Ciphersuite, Ristretto}; use frost::Participant; @@ -340,27 +338,10 @@ async fn dkg_test() { let spec = spec.clone(); let key_pair = key_pair.clone(); async move { - // Version, Pallet, Call, Network, Key Pair, Signature - let expected_len = 1 + 1 + 1 + 1 + 32 + 1 + key_pair.1.len() + 64; - // It's length prefixed - assert_eq!(tx.len(), 2 + expected_len); - let expected_len = u16::try_from(expected_len).unwrap(); - - // Check the encoded length - // This is the compact encoding from SCALE, specifically the two-byte length encoding case - let bottom_six = expected_len & 0b111111; - let upper_eight = expected_len >> 6; - assert_eq!(u8::try_from((bottom_six << 2) | 1).unwrap(), tx[0]); - assert_eq!(u8::try_from(upper_eight).unwrap(), tx[1]); - - // Version - assert_eq!(tx[2], 4); - - // Call - let tx = serai_client::runtime::RuntimeCall::decode(&mut &tx[3 ..]).unwrap(); - match tx { - serai_client::runtime::RuntimeCall::ValidatorSets( - serai_client::runtime::validator_sets::Call::set_keys { + assert_eq!(tx.signature, None); + match tx.call { + serai_client::abi::Call::ValidatorSets( + serai_client::abi::validator_sets::Call::set_keys { network, key_pair: set_key_pair, signature, diff --git a/coordinator/src/tributary/dkg_removal.rs b/coordinator/src/tributary/dkg_removal.rs index 454d375e..0120ef06 100644 --- a/coordinator/src/tributary/dkg_removal.rs +++ b/coordinator/src/tributary/dkg_removal.rs @@ -19,7 +19,7 @@ use frost::{ use frost_schnorrkel::Schnorrkel; use serai_client::{ - Public, + Public, SeraiAddress, validator_sets::primitives::{musig_context, remove_participant_message}, }; @@ -190,7 +190,7 @@ impl DkgRemoval { preprocesses: HashMap>, removed: [u8; 32], mut shares: HashMap>, - ) -> Result<(Vec, [u8; 64]), Participant> { + ) -> Result<(Vec, [u8; 64]), Participant> { // TODO: Remove this ugly blob let shares = { let mut shares_participants = shares.keys().cloned().collect::>(); @@ -213,7 +213,7 @@ impl DkgRemoval { new_shares }; - let mut signers = shares.keys().cloned().map(Public).collect::>(); + let mut signers = shares.keys().cloned().map(SeraiAddress).collect::>(); signers.sort(); let machine = Self::share_internal(spec, key, attempt, preprocesses, removed) diff --git a/coordinator/src/tributary/handle.rs b/coordinator/src/tributary/handle.rs index 131c6c4b..499170c5 100644 --- a/coordinator/src/tributary/handle.rs +++ b/coordinator/src/tributary/handle.rs @@ -10,7 +10,7 @@ use frost::dkg::Participant; use scale::{Encode, Decode}; use serai_client::{ - Public, Signature, + Public, SeraiAddress, Signature, validator_sets::primitives::{ValidatorSet, KeyPair}, SeraiValidatorSets, }; @@ -174,7 +174,7 @@ pub(crate) async fn handle_application_tx< D: Db, Pro: Processors, FPst: Future, - PST: Clone + Fn(ValidatorSet, PstTxType, Vec) -> FPst, + PST: Clone + Fn(ValidatorSet, PstTxType, serai_client::Transaction) -> FPst, FPtt: Future, PTT: Clone + Fn(Transaction) -> FPtt, FRid: Future, @@ -734,7 +734,7 @@ pub(crate) async fn handle_application_tx< let tx = serai_client::SeraiValidatorSets::remove_participant( spec.set().network, - Public(data.plan), + SeraiAddress(data.plan), signers, Signature(signature), ); diff --git a/coordinator/src/tributary/scanner.rs b/coordinator/src/tributary/scanner.rs index 150bd571..d196c8f0 100644 --- a/coordinator/src/tributary/scanner.rs +++ b/coordinator/src/tributary/scanner.rs @@ -55,7 +55,7 @@ async fn handle_block< D: Db, Pro: Processors, FPst: Future, - PST: Clone + Fn(ValidatorSet, PstTxType, Vec) -> FPst, + PST: Clone + Fn(ValidatorSet, PstTxType, serai_client::Transaction) -> FPst, FPtt: Future, PTT: Clone + Fn(Transaction) -> FPtt, FRid: Future, @@ -148,7 +148,7 @@ pub(crate) async fn handle_new_blocks< D: Db, Pro: Processors, FPst: Future, - PST: Clone + Fn(ValidatorSet, PstTxType, Vec) -> FPst, + PST: Clone + Fn(ValidatorSet, PstTxType, serai_client::Transaction) -> FPst, FPtt: Future, PTT: Clone + Fn(Transaction) -> FPtt, FRid: Future, diff --git a/substrate/abi/Cargo.toml b/substrate/abi/Cargo.toml index 8de000f2..0b271576 100644 --- a/substrate/abi/Cargo.toml +++ b/substrate/abi/Cargo.toml @@ -14,11 +14,11 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] scale = { package = "parity-scale-codec", version = "3", features = ["derive"] } +scale-info = { version = "2", features = ["derive"] } borsh = { version = "1", features = ["derive", "de_strict_order"], optional = true } serde = { version = "1", features = ["derive", "alloc"], optional = true } -sp-application-crypto = { git = "https://github.com/serai-dex/substrate" } sp-core = { git = "https://github.com/serai-dex/substrate" } sp-runtime = { git = "https://github.com/serai-dex/substrate" } diff --git a/substrate/abi/src/babe.rs b/substrate/abi/src/babe.rs index 24602757..b5fe89cb 100644 --- a/substrate/abi/src/babe.rs +++ b/substrate/abi/src/babe.rs @@ -2,13 +2,15 @@ use sp_consensus_babe::EquivocationProof; use serai_primitives::Header; -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] pub struct ReportEquivocation { pub equivocation_proof: Box>, pub key_owner_proof: (), } -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +// 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` +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] pub enum Call { report_equivocation(ReportEquivocation), report_equivocation_unsigned(ReportEquivocation), diff --git a/substrate/abi/src/coins.rs b/substrate/abi/src/coins.rs index 0b32b36b..c3fa2dad 100644 --- a/substrate/abi/src/coins.rs +++ b/substrate/abi/src/coins.rs @@ -3,7 +3,7 @@ use serai_primitives::{Balance, SeraiAddress}; pub use serai_coins_primitives as primitives; use primitives::OutInstructionWithBalance; -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Call { @@ -12,7 +12,7 @@ pub enum Call { burn_with_instruction { instruction: OutInstructionWithBalance }, } -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Event { diff --git a/substrate/abi/src/dex.rs b/substrate/abi/src/dex.rs index 65d3c3eb..5b69456a 100644 --- a/substrate/abi/src/dex.rs +++ b/substrate/abi/src/dex.rs @@ -6,7 +6,7 @@ type PoolId = Coin; type PoolCoinId = Coin; type MaxSwapPathLength = sp_core::ConstU32<3>; -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Call { add_liquidity { @@ -38,7 +38,7 @@ pub enum Call { }, } -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Event { PoolCreated { diff --git a/substrate/abi/src/grandpa.rs b/substrate/abi/src/grandpa.rs index 2990630e..33c01dac 100644 --- a/substrate/abi/src/grandpa.rs +++ b/substrate/abi/src/grandpa.rs @@ -2,23 +2,24 @@ use sp_consensus_grandpa::EquivocationProof; use serai_primitives::{BlockNumber, SeraiAddress}; -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] pub struct ReportEquivocation { pub equivocation_proof: Box>, pub key_owner_proof: (), } -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] pub enum Call { report_equivocation(ReportEquivocation), report_equivocation_unsigned(ReportEquivocation), } -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Event { NewAuthorities { authority_set: Vec<(SeraiAddress, u64)> }, + // TODO: Remove these Paused, Resumed, } diff --git a/substrate/abi/src/in_instructions.rs b/substrate/abi/src/in_instructions.rs index e66e1e90..1e5d1bb5 100644 --- a/substrate/abi/src/in_instructions.rs +++ b/substrate/abi/src/in_instructions.rs @@ -3,14 +3,14 @@ use serai_primitives::*; pub use serai_in_instructions_primitives as primitives; use primitives::SignedBatch; -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Call { execute_batch { batch: SignedBatch }, } -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Event { diff --git a/substrate/abi/src/lib.rs b/substrate/abi/src/lib.rs index ecfb3ce6..2e873f4c 100644 --- a/substrate/abi/src/lib.rs +++ b/substrate/abi/src/lib.rs @@ -16,9 +16,11 @@ pub mod grandpa; pub use serai_primitives as primitives; -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] pub enum Call { + System, Timestamp(timestamp::Call), + TransactionPayment, Coins(coins::Call), LiquidityTokens(coins::Call), Dex(dex::Call), @@ -29,14 +31,43 @@ pub enum Call { Grandpa(grandpa::Call), } -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +// TODO: Remove this +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] +pub enum TransactionPaymentEvent { + TransactionFeePaid { who: serai_primitives::SeraiAddress, actual_fee: u64, tip: u64 }, +} + +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] pub enum Event { System(system::Event), + Timestamp, + TransactionPayment(TransactionPaymentEvent), Coins(coins::Event), LiquidityTokens(coins::Event), Dex(dex::Event), ValidatorSets(validator_sets::Event), InInstructions(in_instructions::Event), Signals(signals::Event), + Babe, Grandpa(grandpa::Event), } + +#[derive(Clone, Copy, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Extra { + pub era: sp_runtime::generic::Era, + pub nonce: scale::Compact, + pub tip: scale::Compact, +} + +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] +#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct SignedPayloadExtra { + pub spec_version: u32, + pub tx_version: u32, + pub genesis: [u8; 32], + pub mortality_checkpoint: [u8; 32], +} + +pub type Transaction = primitives::Transaction; diff --git a/substrate/abi/src/signals.rs b/substrate/abi/src/signals.rs index 91956374..2c8dd545 100644 --- a/substrate/abi/src/signals.rs +++ b/substrate/abi/src/signals.rs @@ -5,7 +5,7 @@ use serai_validator_sets_primitives::ValidatorSet; pub use serai_signals_primitives as primitives; use primitives::SignalId; -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Call { @@ -16,7 +16,7 @@ pub enum Call { stand_against { signal_id: SignalId, for_network: NetworkId }, } -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Event { diff --git a/substrate/abi/src/system.rs b/substrate/abi/src/system.rs index afbc78f1..bb67c91c 100644 --- a/substrate/abi/src/system.rs +++ b/substrate/abi/src/system.rs @@ -1,8 +1,14 @@ use frame_support::dispatch::{DispatchInfo, DispatchError}; -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +use serai_primitives::SeraiAddress; + +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Event { ExtrinsicSuccess { dispatch_info: DispatchInfo }, ExtrinsicFailed { dispatch_error: DispatchError, dispatch_info: DispatchInfo }, + CodeUpdated, + NewAccount { account: SeraiAddress }, + KilledAccount { account: SeraiAddress }, + Remarked { sender: SeraiAddress, hash: [u8; 32] }, } diff --git a/substrate/abi/src/timestamp.rs b/substrate/abi/src/timestamp.rs index 7c36b052..c6e7d8cd 100644 --- a/substrate/abi/src/timestamp.rs +++ b/substrate/abi/src/timestamp.rs @@ -1,6 +1,5 @@ -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] -#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Call { - set { now: u64 }, + set { now: scale::Compact }, } diff --git a/substrate/abi/src/validator_sets.rs b/substrate/abi/src/validator_sets.rs index 346ca6d1..f6244b1d 100644 --- a/substrate/abi/src/validator_sets.rs +++ b/substrate/abi/src/validator_sets.rs @@ -3,7 +3,7 @@ pub use serai_validator_sets_primitives as primitives; use serai_primitives::*; use serai_validator_sets_primitives::*; -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Call { set_keys { @@ -31,7 +31,7 @@ pub enum Call { }, } -#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] #[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Event { diff --git a/substrate/client/Cargo.toml b/substrate/client/Cargo.toml index 31e142e7..fcf9ac12 100644 --- a/substrate/client/Cargo.toml +++ b/substrate/client/Cargo.toml @@ -2,7 +2,7 @@ name = "serai-client" version = "0.1.0" description = "Client library for the Serai network" -license = "AGPL-3.0-only" +license = "MIT" repository = "https://github.com/serai-dex/serai/tree/develop/substrate/client" authors = ["Luke Parker "] keywords = ["serai"] @@ -19,13 +19,16 @@ thiserror = { version = "1", optional = true } hex = "0.4" scale = { package = "parity-scale-codec", version = "3" } -serde = { version = "1", features = ["derive"] } -serde_json = "1" +serde = { version = "1", features = ["derive"], optional = true } +serde_json = { version = "1", optional = true } -sp-core = { git = "https://github.com/serai-dex/substrate" } -sp-runtime = { git = "https://github.com/serai-dex/substrate" } -serai-runtime = { path = "../runtime", version = "0.1" } -simple-request = { path = "../../common/request", version = "0.1" } +serai-abi = { path = "../abi", version = "0.1" } + +sp-core = { git = "https://github.com/serai-dex/substrate", optional = true } +sp-runtime = { git = "https://github.com/serai-dex/substrate", optional = true } +frame-system = { git = "https://github.com/serai-dex/substrate", optional = true } + +simple-request = { path = "../../common/request", version = "0.1", optional = true } bitcoin = { version = "0.31", optional = true } @@ -48,7 +51,7 @@ dockertest = "0.4" serai-docker-tests = { path = "../../tests/docker" } [features] -serai = ["thiserror"] +serai = ["thiserror", "serde", "serde_json", "sp-core", "sp-runtime", "frame-system", "simple-request"] networks = [] bitcoin = ["networks", "dep:bitcoin"] diff --git a/substrate/client/LICENSE b/substrate/client/LICENSE index c425427c..6779f0ec 100644 --- a/substrate/client/LICENSE +++ b/substrate/client/LICENSE @@ -1,15 +1,21 @@ -AGPL-3.0-only license +MIT License Copyright (c) 2022-2023 Luke Parker -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License Version 3 as -published by the Free Software Foundation. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/substrate/client/src/lib.rs b/substrate/client/src/lib.rs index 3338d323..a780d55c 100644 --- a/substrate/client/src/lib.rs +++ b/substrate/client/src/lib.rs @@ -6,19 +6,18 @@ mod serai; #[cfg(feature = "serai")] pub use serai::*; -// If we aren't exposing the Serai client (subxt), still expose all primitives #[cfg(not(feature = "serai"))] -pub use serai_runtime::primitives; +pub use serai_abi::primitives; #[cfg(not(feature = "serai"))] mod other_primitives { - pub mod in_instructions { - pub use serai_runtime::in_instructions::primitives; - } pub mod coins { - pub use serai_runtime::coins::primitives; + pub use serai_abi::coins::primitives; } pub mod validator_sets { - pub use serai_runtime::validator_sets::primitives; + pub use serai_abi::validator_sets::primitives; + } + pub mod in_instructions { + pub use serai_abi::in_instructions::primitives; } } #[cfg(not(feature = "serai"))] diff --git a/substrate/client/src/serai/coins.rs b/substrate/client/src/serai/coins.rs index 75575119..d13a711c 100644 --- a/substrate/client/src/serai/coins.rs +++ b/substrate/client/src/serai/coins.rs @@ -1,17 +1,14 @@ use scale::Encode; -use serai_runtime::{ - primitives::{SeraiAddress, Amount, Coin, Balance}, - coins, Runtime, -}; -pub use coins::primitives; +use serai_abi::primitives::{SeraiAddress, Amount, Coin, Balance}; +pub use serai_abi::coins::primitives; use primitives::OutInstructionWithBalance; use crate::{TemporalSerai, SeraiError}; const PALLET: &str = "Coins"; -pub type CoinsEvent = coins::Event; +pub type CoinsEvent = serai_abi::coins::Event; #[derive(Clone, Copy)] pub struct SeraiCoins<'a>(pub(crate) TemporalSerai<'a>); @@ -24,7 +21,7 @@ impl<'a> SeraiCoins<'a> { self .0 .events(|event| { - if let serai_runtime::RuntimeEvent::Coins(event) = event { + if let serai_abi::Event::Coins(event) = event { Some(event).filter(|event| matches!(event, CoinsEvent::Mint { .. })) } else { None @@ -37,7 +34,7 @@ impl<'a> SeraiCoins<'a> { self .0 .events(|event| { - if let serai_runtime::RuntimeEvent::Coins(event) = event { + if let serai_abi::Event::Coins(event) = event { Some(event).filter(|event| matches!(event, CoinsEvent::BurnWithInstruction { .. })) } else { None @@ -68,22 +65,15 @@ impl<'a> SeraiCoins<'a> { ) } - pub fn transfer(to: SeraiAddress, balance: Balance) -> serai_runtime::RuntimeCall { - serai_runtime::RuntimeCall::Coins(serai_runtime::coins::Call::::transfer { - to: to.into(), - balance, - }) + pub fn transfer(to: SeraiAddress, balance: Balance) -> serai_abi::Call { + serai_abi::Call::Coins(serai_abi::coins::Call::transfer { to, balance }) } - pub fn burn(balance: Balance) -> serai_runtime::RuntimeCall { - serai_runtime::RuntimeCall::Coins(serai_runtime::coins::Call::::burn { balance }) + pub fn burn(balance: Balance) -> serai_abi::Call { + serai_abi::Call::Coins(serai_abi::coins::Call::burn { balance }) } - pub fn burn_with_instruction( - instruction: OutInstructionWithBalance, - ) -> serai_runtime::RuntimeCall { - serai_runtime::RuntimeCall::Coins( - serai_runtime::coins::Call::::burn_with_instruction { instruction }, - ) + pub fn burn_with_instruction(instruction: OutInstructionWithBalance) -> serai_abi::Call { + serai_abi::Call::Coins(serai_abi::coins::Call::burn_with_instruction { instruction }) } } diff --git a/substrate/client/src/serai/dex.rs b/substrate/client/src/serai/dex.rs index a01a9a8a..5e7043c3 100644 --- a/substrate/client/src/serai/dex.rs +++ b/substrate/client/src/serai/dex.rs @@ -1,12 +1,9 @@ use sp_core::bounded_vec::BoundedVec; -use serai_runtime::{ - primitives::{SeraiAddress, Amount, Coin}, - dex, Runtime, -}; +use serai_abi::primitives::{SeraiAddress, Amount, Coin}; use crate::{SeraiError, TemporalSerai}; -pub type DexEvent = dex::Event; +pub type DexEvent = serai_abi::dex::Event; #[derive(Clone, Copy)] pub struct SeraiDex<'a>(pub(crate) TemporalSerai<'a>); @@ -14,15 +11,7 @@ impl<'a> SeraiDex<'a> { pub async fn events(&self) -> Result, SeraiError> { self .0 - .events( - |event| { - if let serai_runtime::RuntimeEvent::Dex(event) = event { - Some(event) - } else { - None - } - }, - ) + .events(|event| if let serai_abi::Event::Dex(event) = event { Some(event) } else { None }) .await } @@ -33,14 +22,14 @@ impl<'a> SeraiDex<'a> { min_coin_amount: Amount, min_sri_amount: Amount, address: SeraiAddress, - ) -> serai_runtime::RuntimeCall { - serai_runtime::RuntimeCall::Dex(dex::Call::::add_liquidity { + ) -> serai_abi::Call { + serai_abi::Call::Dex(serai_abi::dex::Call::add_liquidity { coin, coin_desired: coin_amount.0, sri_desired: sri_amount.0, coin_min: min_coin_amount.0, sri_min: min_sri_amount.0, - mint_to: address.into(), + mint_to: address, }) } @@ -50,7 +39,7 @@ impl<'a> SeraiDex<'a> { amount_in: Amount, amount_out_min: Amount, address: SeraiAddress, - ) -> serai_runtime::RuntimeCall { + ) -> serai_abi::Call { let path = if to_coin.is_native() { BoundedVec::try_from(vec![from_coin, Coin::Serai]).unwrap() } else if from_coin.is_native() { @@ -59,11 +48,11 @@ impl<'a> SeraiDex<'a> { BoundedVec::try_from(vec![from_coin, Coin::Serai, to_coin]).unwrap() }; - serai_runtime::RuntimeCall::Dex(dex::Call::::swap_exact_tokens_for_tokens { + serai_abi::Call::Dex(serai_abi::dex::Call::swap_exact_tokens_for_tokens { path, amount_in: amount_in.0, amount_out_min: amount_out_min.0, - send_to: address.into(), + send_to: address, }) } } diff --git a/substrate/client/src/serai/in_instructions.rs b/substrate/client/src/serai/in_instructions.rs index f15a007d..3ba92e43 100644 --- a/substrate/client/src/serai/in_instructions.rs +++ b/substrate/client/src/serai/in_instructions.rs @@ -1,13 +1,12 @@ -use serai_runtime::{in_instructions, Runtime}; -pub use in_instructions::primitives; +pub use serai_abi::in_instructions::primitives; use primitives::SignedBatch; use crate::{ primitives::{BlockHash, NetworkId}, - SeraiError, Serai, TemporalSerai, + Transaction, SeraiError, Serai, TemporalSerai, }; -pub type InInstructionsEvent = in_instructions::Event; +pub type InInstructionsEvent = serai_abi::in_instructions::Event; const PALLET: &str = "InInstructions"; @@ -36,7 +35,7 @@ impl<'a> SeraiInInstructions<'a> { self .0 .events(|event| { - if let serai_runtime::RuntimeEvent::InInstructions(event) = event { + if let serai_abi::Event::InInstructions(event) = event { Some(event).filter(|event| matches!(event, InInstructionsEvent::Batch { .. })) } else { None @@ -45,9 +44,9 @@ impl<'a> SeraiInInstructions<'a> { .await } - pub fn execute_batch(batch: SignedBatch) -> Vec { - Serai::unsigned(&serai_runtime::RuntimeCall::InInstructions( - in_instructions::Call::::execute_batch { batch }, + pub fn execute_batch(batch: SignedBatch) -> Transaction { + Serai::unsigned(serai_abi::Call::InInstructions( + serai_abi::in_instructions::Call::execute_batch { batch }, )) } } diff --git a/substrate/client/src/serai/mod.rs b/substrate/client/src/serai/mod.rs index b725c02a..1d6f29bb 100644 --- a/substrate/client/src/serai/mod.rs +++ b/substrate/client/src/serai/mod.rs @@ -10,11 +10,12 @@ pub use sp_core::{ sr25519::{Public, Pair}, }; -pub use serai_runtime::primitives; -pub use primitives::{SeraiAddress, Signature, Amount}; +pub use serai_abi as abi; +pub use abi::{primitives, Transaction}; +use abi::*; -pub use serai_runtime as runtime; -use serai_runtime::{Header, Block as SeraiBlock}; +pub use primitives::{SeraiAddress, Signature, Amount}; +use primitives::Header; pub mod coins; pub use coins::SeraiCoins; @@ -25,36 +26,28 @@ pub use in_instructions::SeraiInInstructions; pub mod validator_sets; pub use validator_sets::SeraiValidatorSets; -pub type Transaction = serai_runtime::UncheckedExtrinsic; - -#[derive(Clone, Debug)] -pub struct Block(SeraiBlock); +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode)] +pub struct Block { + pub header: Header, + pub transactions: Vec, +} impl Block { pub fn hash(&self) -> [u8; 32] { - self.0.header.hash().into() + self.header.hash().into() } pub fn number(&self) -> u64 { - self.0.header.number + self.header.number } /// Returns the time of this block, set by its producer, in milliseconds since the epoch. pub fn time(&self) -> Result { - for extrinsic in &self.0.extrinsics { - if let serai_runtime::RuntimeCall::Timestamp(serai_runtime::timestamp::Call::set { now }) = - &extrinsic.function - { - return Ok(*now); + for transaction in &self.transactions { + if let Call::Timestamp(timestamp::Call::set { now }) = &transaction.call { + return Ok(u64::from(*now)); } } Err(SeraiError::InvalidNode("no time was present in block".to_string())) } - - pub fn header(&self) -> &Header { - &self.0.header - } - pub fn transactions(&self) -> &[Transaction] { - &self.0.extrinsics - } } #[derive(Error, Debug)] @@ -158,54 +151,37 @@ impl Serai { Ok(res) } - fn unsigned(call: &serai_runtime::RuntimeCall) -> Vec { - // TODO: Should Serai purge the old transaction code AND set this to 0/1? - const EXTRINSIC_FORMAT_VERSION: u8 = 4; - - let mut tx = vec![EXTRINSIC_FORMAT_VERSION]; - tx.extend(call.encode()); - - let mut length_prefixed = Compact(u32::try_from(tx.len()).unwrap()).encode(); - length_prefixed.extend(tx); - length_prefixed + fn unsigned(call: Call) -> Transaction { + Transaction { call, signature: None } } - pub fn sign( - &self, - signer: &Pair, - call: &serai_runtime::RuntimeCall, - nonce: u32, - tip: u64, - ) -> Vec { + pub fn sign(&self, signer: &Pair, call: Call, nonce: u32, tip: u64) -> Transaction { const SPEC_VERSION: u32 = 1; const TX_VERSION: u32 = 1; - const EXTRINSIC_FORMAT_VERSION: u8 = 4; - let era = sp_runtime::generic::Era::Immortal; - let extra = (era, Compact(nonce), Compact(tip)); - let genesis = self.genesis; - let mortality_checkpoint = genesis; - let mut signature_payload = - (call, extra, SPEC_VERSION, TX_VERSION, genesis, mortality_checkpoint).encode(); - if signature_payload.len() > 256 { - signature_payload = sp_core::blake2_256(&signature_payload).to_vec(); - } + let extra = + Extra { era: sp_runtime::generic::Era::Immortal, nonce: Compact(nonce), tip: Compact(tip) }; + let signature_payload = ( + &call, + &extra, + SignedPayloadExtra { + spec_version: SPEC_VERSION, + tx_version: TX_VERSION, + genesis: self.genesis, + mortality_checkpoint: self.genesis, + }, + ) + .encode(); let signature = signer.sign(&signature_payload); - let signed = 1 << 7; - let tx = (signed + EXTRINSIC_FORMAT_VERSION, signer.public(), signature, extra, call).encode(); - - let mut length_prefixed = Compact(u32::try_from(tx.len()).unwrap()).encode(); - length_prefixed.extend(tx); - length_prefixed + Transaction { call, signature: Some((signer.public().into(), signature, extra)) } } - // TODO: Move this to take in Transaction - pub async fn publish(&self, tx: &[u8]) -> Result<(), SeraiError> { + pub async fn publish(&self, tx: &Transaction) -> Result<(), SeraiError> { // Drop the returned hash, which is the hash of the raw extrinsic, as extrinsics are allowed // to share hashes and this hash is accordingly useless/unsafe // If we are to return something, it should be block included in and position within block - let _: String = self.call("author_submitExtrinsic", [hex::encode(tx)]).await?; + let _: String = self.call("author_submitExtrinsic", [hex::encode(tx.encode())]).await?; Ok(()) } @@ -221,14 +197,15 @@ impl Serai { } pub async fn block(&self, hash: [u8; 32]) -> Result, SeraiError> { - // TODO: Remove this wrapping from Serai? - #[derive(Deserialize)] - struct WrappedBlock { - block: SeraiBlock, - } - let block: Option = self.call("chain_getBlock", [hex::encode(hash)]).await?; + let block: Option = self.call("chain_getBlockBin", [hex::encode(hash)]).await?; let Some(block) = block else { return Ok(None) }; - Ok(Some(Block(block.block))) + let Ok(bytes) = Self::hex_decode(block) else { + Err(SeraiError::InvalidNode("didn't return a hex-encoded block".to_string()))? + }; + let Ok(block) = Block::decode(&mut bytes.as_slice()) else { + Err(SeraiError::InvalidNode("didn't return a block".to_string()))? + }; + Ok(Some(block)) } pub async fn latest_finalized_block(&self) -> Result { @@ -276,7 +253,7 @@ impl Serai { let hash = self.block_hash(number).await?; let Some(hash) = hash else { return Ok(None) }; let Some(block) = self.block(hash).await? else { return Ok(None) }; - if !self.is_finalized(&block.0.header).await? { + if !self.is_finalized(&block.header).await? { return Ok(None); } Ok(Some(block)) @@ -326,14 +303,10 @@ impl<'a> TemporalSerai<'a> { self.0 } - async fn events( - &self, - filter_map: impl Fn(serai_runtime::RuntimeEvent) -> Option, - ) -> Result, SeraiError> { + async fn events(&self, filter_map: impl Fn(Event) -> Option) -> Result, SeraiError> { let mut res = vec![]; - let all_events: Option< - Vec>, - > = self.storage("System", "Events", ()).await?; + let all_events: Option>> = + self.storage("System", "Events", ()).await?; #[allow(clippy::unwrap_or_default)] for event in all_events.unwrap_or(vec![]) { if let Some(event) = filter_map(event.event) { diff --git a/substrate/client/src/serai/validator_sets.rs b/substrate/client/src/serai/validator_sets.rs index 1b26e8ae..cb6ea81b 100644 --- a/substrate/client/src/serai/validator_sets.rs +++ b/substrate/client/src/serai/validator_sets.rs @@ -2,15 +2,18 @@ use scale::Encode; use sp_core::sr25519::{Public, Signature}; -use serai_runtime::{primitives::Amount, validator_sets, Runtime}; -pub use validator_sets::primitives; +use serai_abi::primitives::Amount; +pub use serai_abi::validator_sets::primitives; use primitives::{Session, ValidatorSet, KeyPair}; -use crate::{primitives::NetworkId, Serai, TemporalSerai, SeraiError}; +use crate::{ + primitives::{NetworkId, SeraiAddress}, + Transaction, Serai, TemporalSerai, SeraiError, +}; const PALLET: &str = "ValidatorSets"; -pub type ValidatorSetsEvent = validator_sets::Event; +pub type ValidatorSetsEvent = serai_abi::validator_sets::Event; #[derive(Clone, Copy)] pub struct SeraiValidatorSets<'a>(pub(crate) TemporalSerai<'a>); @@ -23,7 +26,7 @@ impl<'a> SeraiValidatorSets<'a> { self .0 .events(|event| { - if let serai_runtime::RuntimeEvent::ValidatorSets(event) = event { + if let serai_abi::Event::ValidatorSets(event) = event { Some(event).filter(|event| matches!(event, ValidatorSetsEvent::NewSet { .. })) } else { None @@ -36,7 +39,7 @@ impl<'a> SeraiValidatorSets<'a> { self .0 .events(|event| { - if let serai_runtime::RuntimeEvent::ValidatorSets(event) = event { + if let serai_abi::Event::ValidatorSets(event) = event { Some(event).filter(|event| matches!(event, ValidatorSetsEvent::KeyGen { .. })) } else { None @@ -49,7 +52,7 @@ impl<'a> SeraiValidatorSets<'a> { self .0 .events(|event| { - if let serai_runtime::RuntimeEvent::ValidatorSets(event) = event { + if let serai_abi::Event::ValidatorSets(event) = event { Some(event).filter(|event| matches!(event, ValidatorSetsEvent::SetRetired { .. })) } else { None @@ -107,20 +110,22 @@ impl<'a> SeraiValidatorSets<'a> { self.0.storage(PALLET, "Keys", (sp_core::hashing::twox_64(&set.encode()), set)).await } - pub fn set_keys(network: NetworkId, key_pair: KeyPair, signature: Signature) -> Vec { - Serai::unsigned(&serai_runtime::RuntimeCall::ValidatorSets( - validator_sets::Call::::set_keys { network, key_pair, signature }, - )) + pub fn set_keys(network: NetworkId, key_pair: KeyPair, signature: Signature) -> Transaction { + Serai::unsigned(serai_abi::Call::ValidatorSets(serai_abi::validator_sets::Call::set_keys { + network, + key_pair, + signature, + })) } pub fn remove_participant( network: NetworkId, - to_remove: Public, - signers: Vec, + to_remove: SeraiAddress, + signers: Vec, signature: Signature, - ) -> Vec { - Serai::unsigned(&serai_runtime::RuntimeCall::ValidatorSets( - validator_sets::Call::::remove_participant { + ) -> Transaction { + Serai::unsigned(serai_abi::Call::ValidatorSets( + serai_abi::validator_sets::Call::remove_participant { network, to_remove, signers, diff --git a/substrate/client/tests/batch.rs b/substrate/client/tests/batch.rs index 08a5249a..17e4d374 100644 --- a/substrate/client/tests/batch.rs +++ b/substrate/client/tests/batch.rs @@ -67,7 +67,7 @@ serai_test!( let serai = serai.coins(); assert_eq!( serai.mint_events().await.unwrap(), - vec![CoinsEvent::Mint { to: address.into(), balance }] + vec![CoinsEvent::Mint { to: address, balance }] ); assert_eq!(serai.coin_supply(coin).await.unwrap(), amount); assert_eq!(serai.coin_balance(coin, address).await.unwrap(), amount); diff --git a/substrate/client/tests/burn.rs b/substrate/client/tests/burn.rs index bf46ffd2..67a8359c 100644 --- a/substrate/client/tests/burn.rs +++ b/substrate/client/tests/burn.rs @@ -7,7 +7,7 @@ use blake2::{ use scale::Encode; -use serai_runtime::coins::primitives::OutInstructionWithBalance; +use serai_abi::coins::primitives::OutInstructionWithBalance; use sp_core::Pair; use serai_client::{ @@ -68,7 +68,7 @@ serai_test!( assert_eq!( serai.coins().mint_events().await.unwrap(), - vec![CoinsEvent::Mint { to: address.into(), balance }] + vec![CoinsEvent::Mint { to: address, balance }] ); assert_eq!(serai.coins().coin_supply(coin).await.unwrap(), amount); assert_eq!(serai.coins().coin_balance(coin, address).await.unwrap(), amount); @@ -86,22 +86,17 @@ serai_test!( balance, instruction: OutInstruction { address: external_address, data: Some(data) }, }; + let serai = serai.into_inner(); let block = publish_tx( serai, - &serai - .sign( - &pair, - &SeraiCoins::burn_with_instruction(instruction.clone()), - 0, - 0, - ) + &serai.sign(&pair, SeraiCoins::burn_with_instruction(instruction.clone()), 0, 0), ) .await; let serai = serai.as_of(block).coins(); let events = serai.burn_with_instruction_events().await.unwrap(); - assert_eq!(events, vec![CoinsEvent::BurnWithInstruction { from: address.into(), instruction }]); + assert_eq!(events, vec![CoinsEvent::BurnWithInstruction { from: address, instruction }]); assert_eq!(serai.coin_supply(coin).await.unwrap(), Amount(0)); assert_eq!(serai.coin_balance(coin, address).await.unwrap(), Amount(0)); }) diff --git a/substrate/client/tests/common/dex.rs b/substrate/client/tests/common/dex.rs index 79970cd7..86e53691 100644 --- a/substrate/client/tests/common/dex.rs +++ b/substrate/client/tests/common/dex.rs @@ -1,4 +1,4 @@ -use serai_runtime::primitives::{Coin, Amount}; +use serai_abi::primitives::{Coin, Amount}; use serai_client::{Serai, SeraiDex}; use sp_core::{sr25519::Pair, Pair as PairTrait}; @@ -18,7 +18,7 @@ pub async fn add_liquidity( let tx = serai.sign( &pair, - &SeraiDex::add_liquidity(coin, coin_amount, sri_amount, Amount(1), Amount(1), address.into()), + SeraiDex::add_liquidity(coin, coin_amount, sri_amount, Amount(1), Amount(1), address.into()), nonce, 0, ); @@ -40,7 +40,7 @@ pub async fn swap( let tx = serai.sign( &pair, - &SeraiDex::swap(from_coin, to_coin, amount_in, amount_out_min, address.into()), + SeraiDex::swap(from_coin, to_coin, amount_in, amount_out_min, address.into()), nonce, Default::default(), ); diff --git a/substrate/client/tests/common/tx.rs b/substrate/client/tests/common/tx.rs index 4d7b103a..768499b2 100644 --- a/substrate/client/tests/common/tx.rs +++ b/substrate/client/tests/common/tx.rs @@ -2,12 +2,10 @@ use core::time::Duration; use tokio::time::sleep; -use scale::Encode; - -use serai_client::Serai; +use serai_client::{Transaction, Serai}; #[allow(dead_code)] -pub async fn publish_tx(serai: &Serai, tx: &[u8]) -> [u8; 32] { +pub async fn publish_tx(serai: &Serai, tx: &Transaction) -> [u8; 32] { let mut latest = serai .block(serai.latest_finalized_block_hash().await.unwrap()) .await @@ -39,8 +37,8 @@ pub async fn publish_tx(serai: &Serai, tx: &[u8]) -> [u8; 32] { block.unwrap() }; - for transaction in block.transactions() { - if transaction.encode() == tx { + for transaction in &block.transactions { + if transaction == tx { return block.hash(); } } diff --git a/substrate/client/tests/dex.rs b/substrate/client/tests/dex.rs index ddf742ea..5b096adf 100644 --- a/substrate/client/tests/dex.rs +++ b/substrate/client/tests/dex.rs @@ -3,7 +3,7 @@ use scale::Encode; use sp_core::{Pair as PairTrait, bounded_vec::BoundedVec, hashing::blake2_256}; -use serai_runtime::in_instructions::primitives::DexCall; +use serai_abi::in_instructions::primitives::DexCall; use serai_client::{ primitives::{ @@ -37,22 +37,22 @@ serai_test!( vec![ DexEvent::PoolCreated { pool_id: Coin::Bitcoin, - pool_account: PublicKey::from_raw(blake2_256(&Coin::Bitcoin.encode())), + pool_account: PublicKey::from_raw(blake2_256(&Coin::Bitcoin.encode())).into(), lp_token: Coin::Bitcoin, }, DexEvent::PoolCreated { pool_id: Coin::Ether, - pool_account: PublicKey::from_raw(blake2_256(&Coin::Ether.encode())), + pool_account: PublicKey::from_raw(blake2_256(&Coin::Ether.encode())).into(), lp_token: Coin::Ether, }, DexEvent::PoolCreated { pool_id: Coin::Dai, - pool_account: PublicKey::from_raw(blake2_256(&Coin::Dai.encode())), + pool_account: PublicKey::from_raw(blake2_256(&Coin::Dai.encode())).into(), lp_token: Coin::Dai, }, DexEvent::PoolCreated { pool_id: Coin::Monero, - pool_account: PublicKey::from_raw(blake2_256(&Coin::Monero.encode())), + pool_account: PublicKey::from_raw(blake2_256(&Coin::Monero.encode())).into(), lp_token: Coin::Monero, }, ] @@ -91,8 +91,8 @@ serai_test!( assert_eq!( events, vec![DexEvent::LiquidityAdded { - who: pair.public(), - mint_to: pair.public(), + who: pair.public().into(), + mint_to: pair.public().into(), pool_id: Coin::Monero, coin_amount: coin_amount.0, sri_amount: sri_amount.0, @@ -140,8 +140,8 @@ serai_test!( assert_eq!( events, vec![DexEvent::SwapExecuted { - who: pair.clone().public(), - send_to: pair.public(), + who: pair.clone().public().into(), + send_to: pair.public().into(), path, amount_in: amount_in.0, amount_out: 16633299966633 @@ -160,8 +160,8 @@ serai_test!( assert_eq!( events, vec![DexEvent::SwapExecuted { - who: pair.clone().public(), - send_to: pair.public(), + who: pair.clone().public().into(), + send_to: pair.public().into(), path, amount_in: amount_in.0, amount_out: 17254428681101 @@ -220,8 +220,8 @@ serai_test!( assert_eq!( events, vec![DexEvent::SwapExecuted { - who: pair.clone().public(), - send_to: pair.public(), + who: pair.clone().public().into(), + send_to: pair.public().into(), path, amount_in: amount_in.0, amount_out: 12453103964435, @@ -275,8 +275,8 @@ serai_test!( assert_eq!( events, vec![DexEvent::LiquidityAdded { - who: IN_INSTRUCTION_EXECUTOR.into(), - mint_to: pair.public(), + who: IN_INSTRUCTION_EXECUTOR, + mint_to: pair.public().into(), pool_id: Coin::Bitcoin, coin_amount: 10_000_000_000_000, // half of sent amount sri_amount: 6_947_918_403_646, @@ -363,8 +363,8 @@ serai_test!( assert_eq!( events, vec![DexEvent::SwapExecuted { - who: IN_INSTRUCTION_EXECUTOR.into(), - send_to: IN_INSTRUCTION_EXECUTOR.into(), + who: IN_INSTRUCTION_EXECUTOR, + send_to: IN_INSTRUCTION_EXECUTOR, path, amount_in: 20_000_000_000_000, amount_out: 11066655622377 @@ -402,8 +402,8 @@ serai_test!( assert_eq!( events, vec![DexEvent::SwapExecuted { - who: IN_INSTRUCTION_EXECUTOR.into(), - send_to: out_address.as_native().unwrap().into(), + who: IN_INSTRUCTION_EXECUTOR, + send_to: out_address.as_native().unwrap(), path, amount_in: 20_000_000_000_000, amount_out: 26440798801319 @@ -440,8 +440,8 @@ serai_test!( assert_eq!( events, vec![DexEvent::SwapExecuted { - who: IN_INSTRUCTION_EXECUTOR.into(), - send_to: out_address.as_native().unwrap().into(), + who: IN_INSTRUCTION_EXECUTOR, + send_to: out_address.as_native().unwrap(), path, amount_in: 10_000_000_000_000, amount_out: 10711005507065 diff --git a/substrate/primitives/Cargo.toml b/substrate/primitives/Cargo.toml index 556ce975..4ff63212 100644 --- a/substrate/primitives/Cargo.toml +++ b/substrate/primitives/Cargo.toml @@ -25,8 +25,10 @@ sp-application-crypto = { git = "https://github.com/serai-dex/substrate", defaul sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false } sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false } +frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false } + [features] -std = ["zeroize", "scale/std", "borsh?/std", "serde?/std", "scale-info/std", "sp-core/std", "sp-runtime/std"] +std = ["zeroize", "scale/std", "borsh?/std", "serde?/std", "scale-info/std", "sp-core/std", "sp-runtime/std", "frame-support/std"] borsh = ["dep:borsh"] serde = ["dep:serde"] default = ["std"] diff --git a/substrate/primitives/src/account.rs b/substrate/primitives/src/account.rs index b510da65..77877a14 100644 --- a/substrate/primitives/src/account.rs +++ b/substrate/primitives/src/account.rs @@ -50,6 +50,7 @@ pub fn borsh_deserialize_signature( Ok(Signature(signature)) } +// TODO: Remove this for solely Public? #[derive( Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Encode, Decode, MaxEncodedLen, TypeInfo, )] diff --git a/substrate/primitives/src/lib.rs b/substrate/primitives/src/lib.rs index 965870e3..0e05c9b1 100644 --- a/substrate/primitives/src/lib.rs +++ b/substrate/primitives/src/lib.rs @@ -32,6 +32,9 @@ pub use balance::*; mod account; pub use account::*; +mod tx; +pub use tx::*; + #[cfg(feature = "borsh")] pub fn borsh_serialize_bounded_vec( bounded: &BoundedVec>, diff --git a/substrate/primitives/src/tx.rs b/substrate/primitives/src/tx.rs new file mode 100644 index 00000000..bb3de1f4 --- /dev/null +++ b/substrate/primitives/src/tx.rs @@ -0,0 +1,122 @@ +use scale::Encode; + +use sp_core::sr25519::{Public, Signature}; +use sp_runtime::traits::Verify; + +use crate::SeraiAddress; + +trait TransactionMember: + Clone + PartialEq + Eq + core::fmt::Debug + scale::Encode + scale::Decode + scale_info::TypeInfo +{ +} +impl< + T: Clone + + PartialEq + + Eq + + core::fmt::Debug + + scale::Encode + + scale::Decode + + scale_info::TypeInfo, + > TransactionMember for T +{ +} + +#[allow(private_bounds)] +#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)] +pub struct Transaction { + pub call: Call, + pub signature: Option<(SeraiAddress, Signature, Extra)>, +} + +#[cfg(feature = "serde")] +mod _serde { + use scale::Encode; + use serde::{ser::*, de::*}; + use super::*; + impl Serialize for Transaction { + fn serialize(&self, serializer: S) -> Result { + let encoded = self.encode(); + serializer.serialize_bytes(&encoded) + } + } + #[cfg(feature = "std")] + impl<'a, Call: TransactionMember, Extra: TransactionMember> Deserialize<'a> + for Transaction + { + fn deserialize>(de: D) -> Result { + let bytes = sp_core::bytes::deserialize(de)?; + scale::Decode::decode(&mut &bytes[..]) + .map_err(|e| serde::de::Error::custom(format!("invalid transaction: {}", e))) + } + } +} + +impl sp_runtime::traits::Extrinsic + for Transaction +{ + type Call = Call; + type SignaturePayload = (SeraiAddress, Signature, Extra); + fn is_signed(&self) -> Option { + Some(self.signature.is_some()) + } + fn new(call: Call, signature: Option) -> Option { + Some(Self { call, signature }) + } +} + +impl frame_support::traits::ExtrinsicCall + for Transaction +{ + fn call(&self) -> &Call { + &self.call + } +} + +impl sp_runtime::traits::ExtrinsicMetadata + for Transaction +where + Extra: sp_runtime::traits::SignedExtension, +{ + type SignedExtensions = Extra; + + const VERSION: u8 = 0; +} + +impl frame_support::dispatch::GetDispatchInfo + for Transaction +where + Call: frame_support::dispatch::GetDispatchInfo, +{ + fn get_dispatch_info(&self) -> frame_support::dispatch::DispatchInfo { + self.call.get_dispatch_info() + } +} + +impl sp_runtime::traits::BlindCheckable + for Transaction +where + Extra: sp_runtime::traits::SignedExtension, +{ + type Checked = sp_runtime::generic::CheckedExtrinsic; + + fn check( + self, + ) -> Result { + Ok(match self.signature { + Some((signer, signature, extra)) => { + if !signature.verify( + (&self.call, &extra, extra.additional_signed()?).encode().as_slice(), + &signer.into(), + ) { + Err(sp_runtime::transaction_validity::InvalidTransaction::BadProof)? + } + + sp_runtime::generic::CheckedExtrinsic { + signed: Some((signer.into(), extra)), + function: self.call, + } + } + None => sp_runtime::generic::CheckedExtrinsic { signed: None, function: self.call }, + }) + } +} diff --git a/substrate/runtime/src/lib.rs b/substrate/runtime/src/lib.rs index d9c2ca14..b4828cde 100644 --- a/substrate/runtime/src/lib.rs +++ b/substrate/runtime/src/lib.rs @@ -44,7 +44,7 @@ use sp_runtime::{ Perbill, ApplyExtrinsicResult, }; -use primitives::{PublicKey, SeraiAddress, AccountLookup, Signature, SubstrateAmount}; +use primitives::{PublicKey, AccountLookup, SubstrateAmount}; use support::{ traits::{ConstU8, ConstU32, ConstU64, Contains}, @@ -75,10 +75,9 @@ pub type SignedExtra = ( system::CheckWeight, transaction_payment::ChargeTransactionPayment, ); -pub type UncheckedExtrinsic = - generic::UncheckedExtrinsic; -pub type Block = generic::Block; +pub type Transaction = serai_primitives::Transaction; +pub type Block = generic::Block; pub type BlockId = generic::BlockId; pub mod opaque { diff --git a/tests/coordinator/src/tests/sign.rs b/tests/coordinator/src/tests/sign.rs index fb1eecb7..6f56572e 100644 --- a/tests/coordinator/src/tests/sign.rs +++ b/tests/coordinator/src/tests/sign.rs @@ -207,7 +207,7 @@ async fn sign_test() { serai .publish(&serai.sign( &insecure_pair_from_name("Ferdie"), - &SeraiCoins::transfer(address, balance), + SeraiCoins::transfer(address, balance), 0, Default::default(), )) @@ -252,7 +252,7 @@ async fn sign_test() { // Verify the mint occurred as expected assert_eq!( serai.mint_events().await.unwrap(), - vec![CoinsEvent::Mint { to: serai_addr.into(), balance }] + vec![CoinsEvent::Mint { to: serai_addr, balance }] ); assert_eq!(serai.coin_supply(Coin::Bitcoin).await.unwrap(), amount); assert_eq!(serai.coin_balance(Coin::Bitcoin, serai_addr).await.unwrap(), amount); @@ -269,7 +269,7 @@ async fn sign_test() { serai .publish(&serai.sign( &serai_pair, - &SeraiCoins::burn_with_instruction(out_instruction.clone()), + SeraiCoins::burn_with_instruction(out_instruction.clone()), 0, Default::default(), )) @@ -297,7 +297,7 @@ async fn sign_test() { assert_eq!( burn_events[0], CoinsEvent::BurnWithInstruction { - from: serai_addr.into(), + from: serai_addr, instruction: out_instruction.clone() } ); diff --git a/tests/full-stack/src/tests/mint_and_burn.rs b/tests/full-stack/src/tests/mint_and_burn.rs index c74a28d9..79938596 100644 --- a/tests/full-stack/src/tests/mint_and_burn.rs +++ b/tests/full-stack/src/tests/mint_and_burn.rs @@ -250,7 +250,7 @@ async fn mint_and_burn_test() { serai .publish(&serai.sign( &insecure_pair_from_name("Ferdie"), - &SeraiCoins::transfer(address, balance), + SeraiCoins::transfer(address, balance), 0, Default::default(), )) @@ -504,7 +504,7 @@ async fn mint_and_burn_test() { serai .publish(&serai.sign( serai_pair, - &SeraiCoins::burn_with_instruction(out_instruction), + SeraiCoins::burn_with_instruction(out_instruction), nonce, Default::default(), ))