mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Fix accumulated bugs
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -8364,10 +8364,7 @@ dependencies = [
|
|||||||
"sp-blockchain",
|
"sp-blockchain",
|
||||||
"sp-consensus-babe",
|
"sp-consensus-babe",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
"sp-inherents",
|
|
||||||
"sp-io",
|
"sp-io",
|
||||||
"sp-keyring",
|
|
||||||
"sp-runtime",
|
|
||||||
"sp-timestamp",
|
"sp-timestamp",
|
||||||
"substrate-build-script-utils",
|
"substrate-build-script-utils",
|
||||||
"substrate-frame-rpc-system",
|
"substrate-frame-rpc-system",
|
||||||
|
|||||||
@@ -17,20 +17,7 @@ pub enum EthereumError {
|
|||||||
VerificationError,
|
VerificationError,
|
||||||
}
|
}
|
||||||
|
|
||||||
abigen!(Schnorr, "./artifacts/Schnorr.sol/Schnorr.json",);
|
abigen!(Schnorr, "./artifacts/Schnorr.sol/Schnorr.json");
|
||||||
|
|
||||||
pub async fn deploy_schnorr_verifier_contract(
|
|
||||||
client: Arc<SignerMiddleware<Provider<Http>, LocalWallet>>,
|
|
||||||
) -> Result<Schnorr<SignerMiddleware<Provider<Http>, LocalWallet>>> {
|
|
||||||
let path = "./artifacts/Schnorr.sol/Schnorr.json";
|
|
||||||
let artifact: ContractBytecode = serde_json::from_reader(File::open(path).unwrap()).unwrap();
|
|
||||||
let abi = artifact.abi.unwrap();
|
|
||||||
let bin = artifact.bytecode.unwrap().object;
|
|
||||||
let factory = ContractFactory::new(abi, bin.into_bytes().unwrap(), client.clone());
|
|
||||||
let contract = factory.deploy(())?.send().await?;
|
|
||||||
let contract = Schnorr::new(contract.address(), client);
|
|
||||||
Ok(contract)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn call_verify(
|
pub async fn call_verify(
|
||||||
contract: &Schnorr<SignerMiddleware<Provider<Http>, LocalWallet>>,
|
contract: &Schnorr<SignerMiddleware<Provider<Http>, LocalWallet>>,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ FROM rust:1.73-slim-bookworm as builder
|
|||||||
LABEL description="STAGE 1: Build"
|
LABEL description="STAGE 1: Build"
|
||||||
|
|
||||||
# Upgrade and add dev dependencies
|
# Upgrade and add dev dependencies
|
||||||
RUN apt update && apt upgrade -y && apt install -y pkg-config clang libssl-dev && apt autoremove -y && apt clean
|
RUN apt update && apt upgrade -y && apt install -y pkg-config clang && apt autoremove -y && apt clean
|
||||||
|
|
||||||
# Add the wasm toolchain
|
# Add the wasm toolchain
|
||||||
RUN rustup target add wasm32-unknown-unknown
|
RUN rustup target add wasm32-unknown-unknown
|
||||||
@@ -51,8 +51,8 @@ FROM debian:bookworm-slim as image
|
|||||||
COPY --from=mimalloc libmimalloc.so /usr/lib
|
COPY --from=mimalloc libmimalloc.so /usr/lib
|
||||||
RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload
|
RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload
|
||||||
|
|
||||||
# Upgrade packages and install openssl
|
# Upgrade packages and install ca-certificates
|
||||||
RUN apt update && apt upgrade -y && apt install -y libssl-dev && apt autoremove && apt clean
|
RUN apt update && apt upgrade -y && apt install -y ca-certificates && apt autoremove && apt clean
|
||||||
|
|
||||||
# Switch to a non-root user
|
# Switch to a non-root user
|
||||||
RUN useradd --system --create-home --shell /sbin/nologin coordinator
|
RUN useradd --system --create-home --shell /sbin/nologin coordinator
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ FROM rust:1.73-slim-bookworm as builder
|
|||||||
LABEL description="STAGE 1: Build"
|
LABEL description="STAGE 1: Build"
|
||||||
|
|
||||||
# Upgrade and add dev dependencies
|
# Upgrade and add dev dependencies
|
||||||
RUN apt update && apt upgrade -y && apt install -y pkg-config clang libssl-dev && apt autoremove -y && apt clean
|
RUN apt update && apt upgrade -y && apt install -y pkg-config clang && apt autoremove -y && apt clean
|
||||||
|
|
||||||
# Add files for build
|
# Add files for build
|
||||||
ADD common /serai/common
|
ADD common /serai/common
|
||||||
@@ -51,8 +51,8 @@ FROM debian:bookworm-slim as image
|
|||||||
COPY --from=mimalloc libmimalloc.so /usr/lib
|
COPY --from=mimalloc libmimalloc.so /usr/lib
|
||||||
RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload
|
RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload
|
||||||
|
|
||||||
# Upgrade packages and install openssl
|
# Upgrade packages and install ca-certificates
|
||||||
RUN apt update && apt upgrade -y && apt install -y ca-certificates libssl-dev
|
RUN apt update && apt upgrade -y && apt install -y ca-certificates
|
||||||
|
|
||||||
# Switch to a non-root user
|
# Switch to a non-root user
|
||||||
RUN useradd --system --create-home --shell /sbin/nologin processor
|
RUN useradd --system --create-home --shell /sbin/nologin processor
|
||||||
|
|||||||
@@ -18,11 +18,8 @@ futures = "0.3"
|
|||||||
jsonrpsee = { version = "0.16", features = ["server"] }
|
jsonrpsee = { version = "0.16", features = ["server"] }
|
||||||
|
|
||||||
sp-core = { git = "https://github.com/serai-dex/substrate" }
|
sp-core = { git = "https://github.com/serai-dex/substrate" }
|
||||||
sp-keyring = { git = "https://github.com/serai-dex/substrate" }
|
|
||||||
sp-inherents = { git = "https://github.com/serai-dex/substrate" }
|
|
||||||
sp-timestamp = { git = "https://github.com/serai-dex/substrate" }
|
sp-timestamp = { git = "https://github.com/serai-dex/substrate" }
|
||||||
sp-io = { git = "https://github.com/serai-dex/substrate" }
|
sp-io = { git = "https://github.com/serai-dex/substrate" }
|
||||||
sp-runtime = { git = "https://github.com/serai-dex/substrate" }
|
|
||||||
sp-blockchain = { git = "https://github.com/serai-dex/substrate" }
|
sp-blockchain = { git = "https://github.com/serai-dex/substrate" }
|
||||||
sp-api = { git = "https://github.com/serai-dex/substrate" }
|
sp-api = { git = "https://github.com/serai-dex/substrate" }
|
||||||
sp-block-builder = { git = "https://github.com/serai-dex/substrate" }
|
sp-block-builder = { git = "https://github.com/serai-dex/substrate" }
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ use serai_runtime::Block;
|
|||||||
use sc_service::{PruningMode, PartialComponents};
|
use sc_service::{PruningMode, PartialComponents};
|
||||||
|
|
||||||
use sc_cli::SubstrateCli;
|
use sc_cli::SubstrateCli;
|
||||||
use frame_benchmarking_cli::{ExtrinsicFactory, BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
|
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
chain_spec,
|
chain_spec,
|
||||||
cli::{Cli, Subcommand},
|
cli::{Cli, Subcommand},
|
||||||
command_helper::{RemarkBuilder, inherent_benchmark_data},
|
|
||||||
service::{self, FullClient},
|
service::{self, FullClient},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -110,26 +109,9 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
cmd.run(config, client, backend.expose_db(), backend.expose_storage())
|
cmd.run(config, client, backend.expose_db(), backend.expose_storage())
|
||||||
}
|
}
|
||||||
|
|
||||||
BenchmarkCmd::Overhead(cmd) => {
|
BenchmarkCmd::Overhead(_) => Err("Overhead benchmarking isn't supported.".into()),
|
||||||
let client = service::new_partial(&config)?.client;
|
|
||||||
cmd.run(
|
|
||||||
config,
|
|
||||||
client.clone(),
|
|
||||||
inherent_benchmark_data()?,
|
|
||||||
vec![],
|
|
||||||
&RemarkBuilder::new(client),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
BenchmarkCmd::Extrinsic(cmd) => {
|
BenchmarkCmd::Extrinsic(_) => Err("Extrinsic benchmarking isn't supported.".into()),
|
||||||
let client = service::new_partial(&config)?.client;
|
|
||||||
cmd.run(
|
|
||||||
client.clone(),
|
|
||||||
inherent_benchmark_data()?,
|
|
||||||
vec![],
|
|
||||||
&ExtrinsicFactory(vec![Box::new(RemarkBuilder::new(client))]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
BenchmarkCmd::Machine(cmd) => cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),
|
BenchmarkCmd::Machine(cmd) => cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use sp_core::{Encode, Pair};
|
|
||||||
use sp_keyring::Sr25519Keyring;
|
|
||||||
use sp_inherents::InherentData;
|
|
||||||
|
|
||||||
use sp_runtime::OpaqueExtrinsic;
|
|
||||||
|
|
||||||
use sc_cli::Result;
|
|
||||||
use sc_client_api::BlockBackend;
|
|
||||||
|
|
||||||
use serai_runtime::{
|
|
||||||
VERSION, BlockHashCount,
|
|
||||||
system::{self, Call as SystemCall},
|
|
||||||
transaction_payment, RuntimeCall, UncheckedExtrinsic, SignedPayload, Runtime,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::service::FullClient;
|
|
||||||
|
|
||||||
pub struct RemarkBuilder {
|
|
||||||
client: Arc<FullClient>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RemarkBuilder {
|
|
||||||
pub fn new(client: Arc<FullClient>) -> Self {
|
|
||||||
Self { client }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
|
|
||||||
fn pallet(&self) -> &str {
|
|
||||||
"system"
|
|
||||||
}
|
|
||||||
fn extrinsic(&self) -> &str {
|
|
||||||
"remark"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn build(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
|
|
||||||
Ok(OpaqueExtrinsic::from(create_benchmark_extrinsic(
|
|
||||||
self.client.as_ref(),
|
|
||||||
Sr25519Keyring::Bob.pair(),
|
|
||||||
SystemCall::remark { remark: vec![] }.into(),
|
|
||||||
nonce,
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn create_benchmark_extrinsic(
|
|
||||||
client: &FullClient,
|
|
||||||
sender: sp_core::sr25519::Pair,
|
|
||||||
call: RuntimeCall,
|
|
||||||
nonce: u32,
|
|
||||||
) -> UncheckedExtrinsic {
|
|
||||||
let extra = (
|
|
||||||
system::CheckNonZeroSender::<Runtime>::new(),
|
|
||||||
system::CheckSpecVersion::<Runtime>::new(),
|
|
||||||
system::CheckTxVersion::<Runtime>::new(),
|
|
||||||
system::CheckGenesis::<Runtime>::new(),
|
|
||||||
system::CheckEra::<Runtime>::from(sp_runtime::generic::Era::mortal(
|
|
||||||
BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2),
|
|
||||||
client.chain_info().best_number,
|
|
||||||
)),
|
|
||||||
system::CheckNonce::<Runtime>::from(nonce),
|
|
||||||
system::CheckWeight::<Runtime>::new(),
|
|
||||||
transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
|
|
||||||
);
|
|
||||||
|
|
||||||
UncheckedExtrinsic::new_signed(
|
|
||||||
call.clone(),
|
|
||||||
sender.public().into(),
|
|
||||||
SignedPayload::from_raw(
|
|
||||||
call,
|
|
||||||
extra.clone(),
|
|
||||||
(
|
|
||||||
(),
|
|
||||||
VERSION.spec_version,
|
|
||||||
VERSION.transaction_version,
|
|
||||||
client.block_hash(0).ok().flatten().unwrap(),
|
|
||||||
client.chain_info().best_hash,
|
|
||||||
(),
|
|
||||||
(),
|
|
||||||
(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.using_encoded(|e| sender.sign(e)),
|
|
||||||
extra,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn inherent_benchmark_data() -> Result<InherentData> {
|
|
||||||
Ok(InherentData::new())
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
mod chain_spec;
|
mod chain_spec;
|
||||||
mod service;
|
mod service;
|
||||||
|
|
||||||
mod command_helper;
|
|
||||||
mod command;
|
mod command;
|
||||||
|
|
||||||
mod rpc;
|
mod rpc;
|
||||||
|
|||||||
Reference in New Issue
Block a user