mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 13:39:25 +00:00
* Initial work on an In Inherents pallet * Add an event for when a batch is executed * Add a dummy provider for InInstructions * Add in-instructions to the node * Add the Serai runtime API to the processor * Move processor tests around * Build a subxt Client around Serai * Successfully get Batch events from Serai Renamed processor/substrate to processor/serai. * Much more robust InInstruction pallet * Implement the workaround from https://github.com/paritytech/subxt/issues/602 * Initial prototype of processor generated InInstructions * Correct PendingCoins data flow for InInstructions * Minor lint to in-instructions * Remove the global Serai connection for a partial re-impl * Correct ID handling of the processor test * Workaround the delay in the subscription * Make an unwrap an if let Some, remove old comments * Lint the processor toml * Rebase and update * Move substrate/in-instructions to substrate/in-instructions/pallet * Start an in-instructions primitives lib * Properly update processor to subxt 0.24 Also corrects failures from the rebase. * in-instructions cargo update * Implement IsFatalError * is_inherent -> true * Rename in-instructions crates and misc cleanup * Update documentation * cargo update * Misc update fixes * Replace height with block_number * Update processor src to latest subxt * Correct pipeline for InInstructions testing * Remove runtime::AccountId for serai_primitives::NativeAddress * Rewrite the in-instructions pallet Complete with respect to the currently written docs. Drops the custom serializer for just using SCALE. Makes slight tweaks as relevant. * Move instructions' InherentDataProvider to a client crate * Correct doc gen * Add serde to in-instructions-primitives * Add in-instructions-primitives to pallet * Heights -> BlockNumbers * Get batch pub test loop working * Update in instructions pallet terminology Removes the ambiguous Coin for Update. Removes pending/artificial latency for furture client work. Also moves to using serai_primitives::Coin. * Add a BlockNumber primitive * Belated cargo fmt * Further document why DifferentBatch isn't fatal * Correct processor sleeps * Remove metadata at compile time, add test framework for Serai nodes * Remove manual RPC client * Simplify update test * Improve re-exporting behavior of serai-runtime It now re-exports all pallets underneath it. * Add a function to get storage values to the Serai RPC * Update substrate/ to latest substrate * Create a dedicated crate for the Serai RPC * Remove unused dependencies in substrate/ * Remove unused dependencies in coins/ Out of scope for this branch, just minor and path of least resistance. * Use substrate/serai/client for the Serai RPC lib It's a bit out of place, since these client folders are intended for the node to access pallets and so on. This is for end-users to access Serai as a whole. In that sense, it made more sense as a top level folder, yet that also felt out of place. * Move InInstructions test to serai-client for now * Final cleanup * Update deny.toml * Cargo.lock update from merging develop * Update nightly Attempt to work around the current CI failure, which is a Rust ICE. We previously didn't upgrade due to clippy 10134, yet that's been reverted. * clippy * clippy * fmt * NativeAddress -> SeraiAddress * Sec fix on non-provided updates and doc fixes * Add Serai as a Coin Necessary in order to swap to Serai. * Add a BlockHash type, used for batch IDs * Remove origin from InInstruction Makes InInstructionTarget. Adds RefundableInInstruction with origin. * Document storage items in in-instructions * Rename serai/client/tests/serai.rs to updates.rs It only tested publishing updates and their successful acceptance.
147 lines
4.6 KiB
Rust
147 lines
4.6 KiB
Rust
use serai_runtime::Block;
|
|
|
|
use sc_service::{PruningMode, PartialComponents};
|
|
|
|
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
|
|
use frame_benchmarking_cli::{ExtrinsicFactory, BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
|
|
|
|
use crate::{
|
|
chain_spec,
|
|
cli::{Cli, Subcommand},
|
|
command_helper::{RemarkBuilder, inherent_benchmark_data},
|
|
service,
|
|
};
|
|
|
|
impl SubstrateCli for Cli {
|
|
fn impl_name() -> String {
|
|
"Serai Node".into()
|
|
}
|
|
|
|
fn impl_version() -> String {
|
|
env!("SUBSTRATE_CLI_IMPL_VERSION").to_string()
|
|
}
|
|
|
|
fn description() -> String {
|
|
env!("CARGO_PKG_DESCRIPTION").to_string()
|
|
}
|
|
|
|
fn author() -> String {
|
|
env!("CARGO_PKG_AUTHORS").to_string()
|
|
}
|
|
|
|
fn support_url() -> String {
|
|
"https://github.com/serai-dex/serai/issues/new".to_string()
|
|
}
|
|
|
|
fn copyright_start_year() -> i32 {
|
|
2022
|
|
}
|
|
|
|
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
|
|
match id {
|
|
"dev" | "devnet" => Ok(Box::new(chain_spec::development_config()?)),
|
|
"local" => Ok(Box::new(chain_spec::testnet_config()?)),
|
|
_ => panic!("Unknown network ID"),
|
|
}
|
|
}
|
|
|
|
fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
|
|
&serai_runtime::VERSION
|
|
}
|
|
}
|
|
|
|
pub fn run() -> sc_cli::Result<()> {
|
|
let cli = Cli::from_args();
|
|
|
|
match &cli.subcommand {
|
|
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
|
|
|
|
Some(Subcommand::BuildSpec(cmd)) => {
|
|
cli.create_runner(cmd)?.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
|
}
|
|
|
|
Some(Subcommand::CheckBlock(cmd)) => cli.create_runner(cmd)?.async_run(|config| {
|
|
let PartialComponents { client, task_manager, import_queue, .. } =
|
|
service::new_partial(&config)?.1;
|
|
Ok((cmd.run(client, import_queue), task_manager))
|
|
}),
|
|
|
|
Some(Subcommand::ExportBlocks(cmd)) => cli.create_runner(cmd)?.async_run(|config| {
|
|
let PartialComponents { client, task_manager, .. } = service::new_partial(&config)?.1;
|
|
Ok((cmd.run(client, config.database), task_manager))
|
|
}),
|
|
|
|
Some(Subcommand::ExportState(cmd)) => cli.create_runner(cmd)?.async_run(|config| {
|
|
let PartialComponents { client, task_manager, .. } = service::new_partial(&config)?.1;
|
|
Ok((cmd.run(client, config.chain_spec), task_manager))
|
|
}),
|
|
|
|
Some(Subcommand::ImportBlocks(cmd)) => cli.create_runner(cmd)?.async_run(|config| {
|
|
let PartialComponents { client, task_manager, import_queue, .. } =
|
|
service::new_partial(&config)?.1;
|
|
Ok((cmd.run(client, import_queue), task_manager))
|
|
}),
|
|
|
|
Some(Subcommand::PurgeChain(cmd)) => {
|
|
cli.create_runner(cmd)?.sync_run(|config| cmd.run(config.database))
|
|
}
|
|
|
|
Some(Subcommand::Revert(cmd)) => cli.create_runner(cmd)?.async_run(|config| {
|
|
let PartialComponents { client, task_manager, backend, .. } =
|
|
service::new_partial(&config)?.1;
|
|
Ok((cmd.run(client, backend, None), task_manager))
|
|
}),
|
|
|
|
Some(Subcommand::Benchmark(cmd)) => cli.create_runner(cmd)?.sync_run(|config| match cmd {
|
|
BenchmarkCmd::Pallet(cmd) => cmd.run::<Block, service::ExecutorDispatch>(config),
|
|
|
|
BenchmarkCmd::Block(cmd) => cmd.run(service::new_partial(&config)?.1.client),
|
|
|
|
#[cfg(not(feature = "runtime-benchmarks"))]
|
|
BenchmarkCmd::Storage(_) => {
|
|
Err("Storage benchmarking can be enabled with `--features runtime-benchmarks`.".into())
|
|
}
|
|
|
|
#[cfg(feature = "runtime-benchmarks")]
|
|
BenchmarkCmd::Storage(cmd) => {
|
|
let PartialComponents { client, backend, .. } = service::new_partial(&config)?.1;
|
|
cmd.run(config, client, backend.expose_db(), backend.expose_storage())
|
|
}
|
|
|
|
BenchmarkCmd::Overhead(cmd) => {
|
|
let client = service::new_partial(&config)?.1.client;
|
|
cmd.run(
|
|
config,
|
|
client.clone(),
|
|
inherent_benchmark_data()?,
|
|
vec![],
|
|
&RemarkBuilder::new(client),
|
|
)
|
|
}
|
|
|
|
BenchmarkCmd::Extrinsic(cmd) => {
|
|
let client = service::new_partial(&config)?.1.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()),
|
|
}),
|
|
|
|
Some(Subcommand::ChainInfo(cmd)) => {
|
|
cli.create_runner(cmd)?.sync_run(|config| cmd.run::<Block>(&config))
|
|
}
|
|
|
|
None => cli.create_runner(&cli.run)?.run_node_until_exit(|mut config| async {
|
|
if config.role.is_authority() {
|
|
config.state_pruning = Some(PruningMode::ArchiveAll);
|
|
}
|
|
service::new_full(config).await.map_err(sc_cli::Error::Service)
|
|
}),
|
|
}
|
|
}
|