mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-07 19:59:23 +00:00
Compare commits
3 Commits
3ce90c55d9
...
36ac9c56a4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36ac9c56a4 | ||
|
|
57bf4984f8 | ||
|
|
87750407de |
@@ -52,7 +52,7 @@ runs:
|
||||
- name: Install solc
|
||||
shell: bash
|
||||
run: |
|
||||
cargo +1.91.1 install svm-rs --version =0.5.21
|
||||
cargo +1.91.1 install svm-rs --version =0.5.22
|
||||
svm install 0.8.29
|
||||
svm use 0.8.29
|
||||
|
||||
|
||||
2
.github/workflows/daily-deny.yml
vendored
2
.github/workflows/daily-deny.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
|
||||
|
||||
- name: Install cargo deny
|
||||
run: cargo +1.91.1 install cargo-deny --version =0.18.7
|
||||
run: cargo +1.91.1 install cargo-deny --version =0.18.8
|
||||
|
||||
- name: Run cargo deny
|
||||
run: cargo deny -L error --all-features check --hide-inclusion-graph
|
||||
|
||||
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@@ -46,7 +46,7 @@ jobs:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
|
||||
|
||||
- name: Install cargo deny
|
||||
run: cargo +1.91.1 install cargo-deny --version =0.18.7
|
||||
run: cargo +1.91.1 install cargo-deny --version =0.18.8
|
||||
|
||||
- name: Run cargo deny
|
||||
run: cargo deny -L error --all-features check --hide-inclusion-graph
|
||||
|
||||
25
Cargo.lock
generated
25
Cargo.lock
generated
@@ -1112,9 +1112,9 @@ checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba"
|
||||
|
||||
[[package]]
|
||||
name = "bech32"
|
||||
version = "0.11.0"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d"
|
||||
checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f"
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
@@ -1136,8 +1136,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bip39"
|
||||
version = "2.2.0"
|
||||
source = "git+https://github.com/rust-bitcoin/rust-bip39#f735e2559f30049f6738d1bf68c69a0b7bd7b858"
|
||||
version = "2.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90dbd31c98227229239363921e60fcf5e558e43ec69094d46fc4996f08d1d5bc"
|
||||
dependencies = [
|
||||
"bitcoin_hashes",
|
||||
"rand 0.8.5",
|
||||
@@ -1221,9 +1222,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bitcoin_hashes"
|
||||
version = "0.14.0"
|
||||
version = "0.14.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
|
||||
checksum = "26ec84b80c482df901772e931a9a681e26a1b9ee2302edeff23cb30328745c8b"
|
||||
dependencies = [
|
||||
"bitcoin-io",
|
||||
"hex-conservative",
|
||||
@@ -3727,9 +3728,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hyper-util"
|
||||
version = "0.1.18"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56"
|
||||
checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
@@ -4729,9 +4730,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.28"
|
||||
version = "0.4.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
|
||||
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||
|
||||
[[package]]
|
||||
name = "loom"
|
||||
@@ -4971,9 +4972,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873"
|
||||
checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi",
|
||||
|
||||
17
Cargo.toml
17
Cargo.toml
@@ -116,6 +116,19 @@ members = [
|
||||
"tests/reproducible-runtime",
|
||||
]
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
overflow-checks = true
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
overflow-checks = true
|
||||
# These do not respect the `panic` configuration value, so we don't provide them
|
||||
[profile.test]
|
||||
# panic = "abort" # https://github.com/rust-lang/issues/67650
|
||||
overflow-checks = true
|
||||
[profile.bench]
|
||||
overflow-checks = true
|
||||
|
||||
[profile.dev.package]
|
||||
# Always compile Monero (and a variety of dependencies) with optimizations due
|
||||
# to the extensive operations required for Bulletproofs
|
||||
@@ -165,10 +178,6 @@ revm-precompile = { opt-level = 3 }
|
||||
revm-primitives = { opt-level = 3 }
|
||||
revm-state = { opt-level = 3 }
|
||||
|
||||
[profile.release]
|
||||
panic = "unwind"
|
||||
overflow-checks = true
|
||||
|
||||
[patch.crates-io]
|
||||
# Point to empty crates for crates unused within in our tree
|
||||
alloy-eip2124 = { path = "patches/ethereum/alloy-eip2124" }
|
||||
|
||||
@@ -79,7 +79,6 @@ exceptions = [
|
||||
{ allow = ["AGPL-3.0-only"], name = "serai-coordinator-libp2p-p2p" },
|
||||
{ allow = ["AGPL-3.0-only"], name = "serai-coordinator" },
|
||||
|
||||
{ allow = ["AGPL-3.0-only"], name = "pallet-session" },
|
||||
{ allow = ["AGPL-3.0-only"], name = "substrate-median" },
|
||||
|
||||
{ allow = ["AGPL-3.0-only"], name = "serai-core-pallet" },
|
||||
@@ -152,6 +151,5 @@ allow-git = [
|
||||
"https://github.com/rust-lang-nursery/lazy-static.rs",
|
||||
"https://github.com/kayabaNerve/elliptic-curves",
|
||||
"https://github.com/monero-oxide/monero-oxide",
|
||||
"https://github.com/rust-bitcoin/rust-bip39",
|
||||
"https://github.com/serai-dex/patch-polkadot-sdk",
|
||||
]
|
||||
|
||||
@@ -1,28 +1,8 @@
|
||||
#check=skip=FromPlatformFlagConstDisallowed
|
||||
# We want to explicitly set the platform to ensure a constant host environment
|
||||
|
||||
# rust:1.91.1-alpine as of November 11th, 2025 (GMT)
|
||||
FROM --platform=linux/amd64 rust@sha256:700c0959b23445f69c82676b72caa97ca4359decd075dca55b13339df27dc4d3
|
||||
|
||||
# In order to compile the runtime, including the `proc-macro`s and build scripts, we need the
|
||||
# required development libraries. These are traditionally provided by `musl-dev` which is not
|
||||
# inherently included with this image (https://github.com/rust-lang/docker-rust/issues/68). While we
|
||||
# could install it here, we'd be unable to pin the installed package by its hash as desired.
|
||||
#
|
||||
# Rust does have self-contained libraries, intended to be used when the desired development files
|
||||
# are not otherwise available. These can be enabled with `link-self-contained=yes`. Unfortunately,
|
||||
# this doesn't work here (https://github.com/rust-lang/rust/issues/149371).
|
||||
#
|
||||
# While we can't set `link-self-contained=yes`, we can install Rust's self-contained libraries onto
|
||||
# our system so they're generally available.
|
||||
RUN echo '#!/bin/sh' > libs.sh
|
||||
RUN echo 'set -e' >> libs.sh
|
||||
RUN echo 'SYSROOT=$(rustc --print sysroot)' >> libs.sh
|
||||
RUN echo 'LIBS=$SYSROOT/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained' >> libs.sh
|
||||
RUN echo 'ln -s $LIBS/Scrt1.o $LIBS/crti.o $LIBS/crtn.o /usr/lib' >> libs.sh
|
||||
# We also need `libc.so` which is already present on the system, just not under that name
|
||||
RUN echo 'ln -s /lib/libc.musl-x86_64.so.1 /usr/lib/libc.so' >> libs.sh
|
||||
RUN /bin/sh ./libs.sh
|
||||
# rust:1.91.1-alpine as of December 4th, 2025 (GMT)
|
||||
FROM --platform=linux/amd64 rust@sha256:84f263251b0ada72c1913d82a824d47be15a607f3faf015d8bdae48db544cdf2 AS builder
|
||||
|
||||
# Add the WASM toolchain
|
||||
RUN rustup target add wasm32v1-none
|
||||
@@ -47,11 +27,16 @@ ADD AGPL-3.0 /serai
|
||||
WORKDIR /serai
|
||||
|
||||
# Build the runtime
|
||||
RUN cargo build --release -p serai-runtime
|
||||
# Copy the artifact
|
||||
RUN cp /serai/target/release/wbuild/serai-runtime/serai_runtime.wasm /serai/serai.wasm
|
||||
# Clean up the build directory
|
||||
RUN cargo clean
|
||||
RUN cargo build --release -p serai-runtime --no-default-features
|
||||
|
||||
# Copy the runtime to the provided volume
|
||||
CMD ["cp", "/serai/serai.wasm", "/volume/serai.wasm"]
|
||||
# Copy the artifact to its own image which solely exists to further export it
|
||||
FROM scratch
|
||||
# Copy `busybox`, including the necessary shared libraries, from the builder for a functioning `cp`
|
||||
COPY --from=builder /lib/ld-musl-x86_64.so.1 /lib/libc.musl-x86_64.so.1 /lib/
|
||||
COPY --from=builder /bin/busybox /bin/
|
||||
ENV LD_LIBRARY_PATH=/lib/
|
||||
ENV PATH=/bin
|
||||
# Copy the artifact itself
|
||||
COPY --from=builder /serai/target/release/wbuild/serai-runtime/serai_runtime.wasm /serai.wasm
|
||||
# By default, copy the artifact to `/volume`, presumably a provided volume
|
||||
CMD ["busybox", "cp", "/serai.wasm", "/volume/serai.wasm"]
|
||||
|
||||
@@ -15,7 +15,7 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||
[workspace]
|
||||
|
||||
[dependencies]
|
||||
bip39 = { git = "https://github.com/rust-bitcoin/rust-bip39", commit = "f735e2559f30049f6738d1bf68c69a0b7bd7b858", default-features = false }
|
||||
bip39 = { version = "2.2.1", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["bip39/default"]
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![no_std]
|
||||
|
||||
pub use bip39::*;
|
||||
|
||||
@@ -17,11 +17,31 @@ ignored = ["scale"]
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
|
||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"], optional = true }
|
||||
|
||||
sp-version = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false, optional = true }
|
||||
sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false, optional = true }
|
||||
|
||||
sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false, optional = true }
|
||||
sp-transaction-pool = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false, optional = true }
|
||||
sp-inherents = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false, optional = true }
|
||||
sp-block-builder = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false, optional = true }
|
||||
sp-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false, optional = true }
|
||||
sp-consensus-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false, optional = true }
|
||||
sp-authority-discovery = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false, optional = true }
|
||||
|
||||
serai-abi = { path = "../abi", default-features = false, features = ["substrate"], optional = true }
|
||||
|
||||
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
|
||||
borsh = { version = "1", default-features = false }
|
||||
|
||||
sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
sp-version = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
sp-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
sp-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
|
||||
sp-api = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
sp-transaction-pool = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
@@ -31,15 +51,6 @@ sp-consensus-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", d
|
||||
sp-consensus-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
sp-authority-discovery = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
|
||||
serai-abi = { path = "../abi", default-features = false, features = ["substrate"] }
|
||||
|
||||
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||
borsh = { version = "1", default-features = false }
|
||||
|
||||
sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
sp-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
sp-timestamp = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
|
||||
frame-system = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
frame-executive = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
@@ -49,6 +60,8 @@ pallet-session = { git = "https://github.com/serai-dex/patch-polkadot-sdk", defa
|
||||
pallet-babe = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
pallet-grandpa = { git = "https://github.com/serai-dex/patch-polkadot-sdk", default-features = false }
|
||||
|
||||
serai-abi = { path = "../abi", default-features = false, features = ["substrate"] }
|
||||
|
||||
serai-core-pallet = { path = "../core", default-features = false }
|
||||
serai-coins-pallet = { path = "../coins", default-features = false }
|
||||
serai-validator-sets-pallet = { path = "../validator-sets", default-features = false }
|
||||
@@ -72,6 +85,7 @@ std = [
|
||||
"sp-runtime/std",
|
||||
"sp-api/std",
|
||||
"sp-transaction-pool/std",
|
||||
"sp-inherents/std",
|
||||
"sp-block-builder/std",
|
||||
"sp-consensus-babe/std",
|
||||
"sp-consensus-grandpa/std",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fn main() {
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
substrate_wasm_builder::WasmBuilder::build_using_defaults();
|
||||
}
|
||||
|
||||
39
substrate/runtime/src/common.rs
Normal file
39
substrate/runtime/src/common.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use alloc::vec::Vec;
|
||||
use serai_abi::{
|
||||
primitives::{
|
||||
crypto::{Public, EmbeddedEllipticCurveKeys, SignedEmbeddedEllipticCurveKeys, KeyPair},
|
||||
network_id::{ExternalNetworkId, NetworkId},
|
||||
validator_sets::{Session, ExternalValidatorSet, ValidatorSet},
|
||||
balance::{Amount, Balance},
|
||||
address::SeraiAddress,
|
||||
},
|
||||
Event,
|
||||
};
|
||||
|
||||
/// The genesis configuration for Serai.
|
||||
#[derive(scale::Encode, scale::Decode)]
|
||||
pub struct GenesisConfig {
|
||||
/// The genesis validators for the network.
|
||||
pub validators: Vec<(Public, Vec<SignedEmbeddedEllipticCurveKeys>)>,
|
||||
/// The accounts to start with balances, intended solely for testing purposes.
|
||||
pub coins: Vec<(Public, Balance)>,
|
||||
}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait GenesisApi {
|
||||
fn build(genesis: GenesisConfig);
|
||||
}
|
||||
pub trait SeraiApi {
|
||||
fn events() -> Vec<Vec<Vec<u8>>>;
|
||||
fn validators(network: NetworkId) -> Vec<Public>;
|
||||
fn current_session(network: NetworkId) -> Option<Session>;
|
||||
fn current_stake(network: NetworkId) -> Option<Amount>;
|
||||
fn keys(set: ExternalValidatorSet) -> Option<KeyPair>;
|
||||
fn current_validators(network: NetworkId) -> Option<Vec<SeraiAddress>>;
|
||||
fn pending_slash_report(network: ExternalNetworkId) -> bool;
|
||||
fn embedded_elliptic_curve_keys(
|
||||
validator: SeraiAddress,
|
||||
network: ExternalNetworkId,
|
||||
) -> Option<EmbeddedEllipticCurveKeys>;
|
||||
}
|
||||
}
|
||||
@@ -1,222 +1,24 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg(any(feature = "std", target_family = "wasm"))]
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use serai_abi::{
|
||||
primitives::{
|
||||
crypto::{Public, EmbeddedEllipticCurveKeys, SignedEmbeddedEllipticCurveKeys, KeyPair},
|
||||
network_id::{ExternalNetworkId, NetworkId},
|
||||
validator_sets::{Session, ExternalValidatorSet, ValidatorSet},
|
||||
balance::{Amount, Balance},
|
||||
address::SeraiAddress,
|
||||
},
|
||||
Event,
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
#[cfg(any(feature = "std", target_family = "wasm"))]
|
||||
mod common;
|
||||
#[cfg(any(feature = "std", target_family = "wasm"))]
|
||||
pub use common::*;
|
||||
|
||||
// If this is WASM, we build the runtime proper
|
||||
#[cfg(target_family = "wasm")]
|
||||
mod wasm;
|
||||
|
||||
/// The genesis configuration for Serai.
|
||||
#[derive(scale::Encode, scale::Decode)]
|
||||
pub struct GenesisConfig {
|
||||
/// The genesis validators for the network.
|
||||
pub validators: Vec<(Public, Vec<SignedEmbeddedEllipticCurveKeys>)>,
|
||||
/// The accounts to start with balances, intended solely for testing purposes.
|
||||
pub coins: Vec<(Public, Balance)>,
|
||||
}
|
||||
// If this is `std`, we solely stub with `impl_runtime_apis` for the `RuntimeApi` the node requires
|
||||
#[cfg(feature = "std")]
|
||||
mod std_runtime_api;
|
||||
#[cfg(feature = "std")]
|
||||
pub use std_runtime_api::RuntimeApi;
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
pub trait GenesisApi {
|
||||
fn build(genesis: GenesisConfig);
|
||||
}
|
||||
pub trait SeraiApi {
|
||||
fn events() -> Vec<Vec<Vec<u8>>>;
|
||||
fn validators(network: NetworkId) -> Vec<Public>;
|
||||
fn current_session(network: NetworkId) -> Option<Session>;
|
||||
fn current_stake(network: NetworkId) -> Option<Amount>;
|
||||
fn keys(set: ExternalValidatorSet) -> Option<KeyPair>;
|
||||
fn current_validators(network: NetworkId) -> Option<Vec<SeraiAddress>>;
|
||||
fn pending_slash_report(network: ExternalNetworkId) -> bool;
|
||||
fn embedded_elliptic_curve_keys(
|
||||
validator: SeraiAddress,
|
||||
network: ExternalNetworkId,
|
||||
) -> Option<EmbeddedEllipticCurveKeys>;
|
||||
}
|
||||
}
|
||||
|
||||
// We stub `impl_runtime_apis` to generate the `RuntimeApi` object the node needs
|
||||
// If this isn't WASM, regardless of what it is, we include the WASM blob from the build script
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
mod apis {
|
||||
use alloc::borrow::Cow;
|
||||
use serai_abi::{SubstrateHeader as Header, SubstrateBlock as Block};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[sp_version::runtime_version]
|
||||
pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
|
||||
spec_name: Cow::Borrowed("serai"),
|
||||
impl_name: Cow::Borrowed("core"),
|
||||
authoring_version: 0,
|
||||
// Use the highest possible value so the node doesn't attempt to use this in place of the WASM
|
||||
spec_version: 0xffffffff,
|
||||
impl_version: 0,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
transaction_version: 0,
|
||||
system_version: 0,
|
||||
};
|
||||
|
||||
/// A `struct` representing the runtime as necessary to define the available APIs.
|
||||
pub struct Runtime;
|
||||
sp_api::impl_runtime_apis! {
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> sp_version::RuntimeVersion {
|
||||
VERSION
|
||||
}
|
||||
fn initialize_block(header: &Header) -> sp_runtime::ExtrinsicInclusionMode {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn execute_block(block: Block) {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_block_builder::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(
|
||||
extrinsic: <Block as sp_runtime::traits::Block>::Extrinsic,
|
||||
) -> sp_runtime::ApplyExtrinsicResult {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn finalize_block() -> Header {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(
|
||||
data: sp_inherents::InherentData,
|
||||
) -> Vec<<Block as sp_runtime::traits::Block>::Extrinsic> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn check_inherents(
|
||||
block: Block,
|
||||
data: sp_inherents::InherentData,
|
||||
) -> sp_inherents::CheckInherentsResult {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
||||
fn validate_transaction(
|
||||
source: sp_runtime::transaction_validity::TransactionSource,
|
||||
tx: <Block as sp_runtime::traits::Block>::Extrinsic,
|
||||
block_hash: <Block as sp_runtime::traits::Block>::Hash,
|
||||
) -> sp_runtime::transaction_validity::TransactionValidity {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_consensus_babe::BabeApi<Block> for Runtime {
|
||||
fn configuration() -> sp_consensus_babe::BabeConfiguration {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn current_epoch_start() -> sp_consensus_babe::Slot {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn current_epoch() -> sp_consensus_babe::Epoch {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn next_epoch() -> sp_consensus_babe::Epoch {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn generate_key_ownership_proof(
|
||||
_slot: sp_consensus_babe::Slot,
|
||||
_authority_id: sp_consensus_babe::AuthorityId,
|
||||
) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn submit_report_equivocation_unsigned_extrinsic(
|
||||
equivocation_proof: sp_consensus_babe::EquivocationProof<Header>,
|
||||
_: sp_consensus_babe::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_consensus_grandpa::GrandpaApi<Block> for Runtime {
|
||||
fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn current_set_id() -> sp_consensus_grandpa::SetId {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn generate_key_ownership_proof(
|
||||
_set_id: sp_consensus_grandpa::SetId,
|
||||
_authority_id: sp_consensus_grandpa::AuthorityId,
|
||||
) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn submit_report_equivocation_unsigned_extrinsic(
|
||||
equivocation_proof: sp_consensus_grandpa::EquivocationProof<
|
||||
<Block as sp_runtime::traits::Block>::Hash,
|
||||
u64,
|
||||
>,
|
||||
_: sp_consensus_grandpa::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
|
||||
fn authorities() -> Vec<sp_authority_discovery::AuthorityId> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::SeraiApi<Block> for Runtime {
|
||||
fn events() -> Vec<Vec<Vec<u8>>> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn validators(
|
||||
network: NetworkId
|
||||
) -> Vec<serai_abi::primitives::crypto::Public> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn current_session(network: NetworkId) -> Option<Session> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn current_stake(network: NetworkId) -> Option<Amount> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn keys(set: ExternalValidatorSet) -> Option<KeyPair> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn current_validators(network: NetworkId) -> Option<Vec<SeraiAddress>> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn pending_slash_report(network: ExternalNetworkId) -> bool {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn embedded_elliptic_curve_keys(
|
||||
validator: SeraiAddress,
|
||||
network: ExternalNetworkId,
|
||||
) -> Option<EmbeddedEllipticCurveKeys> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
pub use apis::RuntimeApi;
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
|
||||
174
substrate/runtime/src/std_runtime_api.rs
Normal file
174
substrate/runtime/src/std_runtime_api.rs
Normal file
@@ -0,0 +1,174 @@
|
||||
use alloc::borrow::Cow;
|
||||
use serai_abi::{
|
||||
primitives::{
|
||||
crypto::{KeyPair, EmbeddedEllipticCurveKeys},
|
||||
network_id::{ExternalNetworkId, NetworkId},
|
||||
validator_sets::{Session, ExternalValidatorSet},
|
||||
balance::Amount,
|
||||
address::SeraiAddress,
|
||||
},
|
||||
SubstrateHeader as Header, SubstrateBlock as Block,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[sp_version::runtime_version]
|
||||
pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
|
||||
spec_name: Cow::Borrowed("serai"),
|
||||
impl_name: Cow::Borrowed("core"),
|
||||
authoring_version: 0,
|
||||
// Use the highest possible value so the node doesn't attempt to use this in place of the WASM
|
||||
spec_version: 0xffffffff,
|
||||
impl_version: 0,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
transaction_version: 0,
|
||||
system_version: 0,
|
||||
};
|
||||
|
||||
/// A `struct` representing the runtime as necessary to define the available APIs.
|
||||
pub struct Runtime;
|
||||
sp_api::impl_runtime_apis! {
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> sp_version::RuntimeVersion {
|
||||
VERSION
|
||||
}
|
||||
fn initialize_block(header: &Header) -> sp_runtime::ExtrinsicInclusionMode {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn execute_block(block: Block) {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_block_builder::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(
|
||||
extrinsic: <Block as sp_runtime::traits::Block>::Extrinsic,
|
||||
) -> sp_runtime::ApplyExtrinsicResult {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn finalize_block() -> Header {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(
|
||||
data: sp_inherents::InherentData,
|
||||
) -> Vec<<Block as sp_runtime::traits::Block>::Extrinsic> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn check_inherents(
|
||||
block: Block,
|
||||
data: sp_inherents::InherentData,
|
||||
) -> sp_inherents::CheckInherentsResult {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
||||
fn validate_transaction(
|
||||
source: sp_runtime::transaction_validity::TransactionSource,
|
||||
tx: <Block as sp_runtime::traits::Block>::Extrinsic,
|
||||
block_hash: <Block as sp_runtime::traits::Block>::Hash,
|
||||
) -> sp_runtime::transaction_validity::TransactionValidity {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_consensus_babe::BabeApi<Block> for Runtime {
|
||||
fn configuration() -> sp_consensus_babe::BabeConfiguration {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn current_epoch_start() -> sp_consensus_babe::Slot {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn current_epoch() -> sp_consensus_babe::Epoch {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn next_epoch() -> sp_consensus_babe::Epoch {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn generate_key_ownership_proof(
|
||||
_slot: sp_consensus_babe::Slot,
|
||||
_authority_id: sp_consensus_babe::AuthorityId,
|
||||
) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn submit_report_equivocation_unsigned_extrinsic(
|
||||
equivocation_proof: sp_consensus_babe::EquivocationProof<Header>,
|
||||
_: sp_consensus_babe::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_consensus_grandpa::GrandpaApi<Block> for Runtime {
|
||||
fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn current_set_id() -> sp_consensus_grandpa::SetId {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn generate_key_ownership_proof(
|
||||
_set_id: sp_consensus_grandpa::SetId,
|
||||
_authority_id: sp_consensus_grandpa::AuthorityId,
|
||||
) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
|
||||
fn submit_report_equivocation_unsigned_extrinsic(
|
||||
equivocation_proof: sp_consensus_grandpa::EquivocationProof<
|
||||
<Block as sp_runtime::traits::Block>::Hash,
|
||||
u64,
|
||||
>,
|
||||
_: sp_consensus_grandpa::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
|
||||
fn authorities() -> Vec<sp_authority_discovery::AuthorityId> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::SeraiApi<Block> for Runtime {
|
||||
fn events() -> Vec<Vec<Vec<u8>>> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn validators(
|
||||
network: NetworkId
|
||||
) -> Vec<serai_abi::primitives::crypto::Public> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn current_session(network: NetworkId) -> Option<Session> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn current_stake(network: NetworkId) -> Option<Amount> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn keys(set: ExternalValidatorSet) -> Option<KeyPair> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn current_validators(network: NetworkId) -> Option<Vec<SeraiAddress>> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn pending_slash_report(network: ExternalNetworkId) -> bool {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
fn embedded_elliptic_curve_keys(
|
||||
validator: SeraiAddress,
|
||||
network: ExternalNetworkId,
|
||||
) -> Option<EmbeddedEllipticCurveKeys> {
|
||||
unimplemented!("runtime is only implemented when WASM")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,8 +54,9 @@ pub fn reproducibly_builds() {
|
||||
.arg("--quiet")
|
||||
.arg("--rm")
|
||||
.arg(&image)
|
||||
.arg("busybox")
|
||||
.arg("sha256sum")
|
||||
.arg("/serai/serai.wasm")
|
||||
.arg("/serai.wasm")
|
||||
.output(),
|
||||
);
|
||||
// Attempt to clean up the image
|
||||
|
||||
Reference in New Issue
Block a user