mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 13:09:24 +00:00
Compare commits
3 Commits
c12c471602
...
0b377f3c4e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b377f3c4e | ||
|
|
3655ae68df | ||
|
|
3f2c1bf303 |
@@ -118,7 +118,7 @@ WORKDIR /home/{user}
|
||||
|
||||
Os::Debian => format!(
|
||||
r#"
|
||||
FROM debian:bookworm-slim AS image
|
||||
FROM debian:trixie-slim AS image
|
||||
|
||||
COPY --from=mimalloc-debian libmimalloc.so /usr/lib
|
||||
RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload
|
||||
|
||||
@@ -16,7 +16,7 @@ RUN git clone https://github.com/microsoft/mimalloc && \
|
||||
"#;
|
||||
|
||||
const DEBIAN_MIMALLOC: &str = r#"
|
||||
FROM debian:bookworm-slim AS mimalloc-debian
|
||||
FROM debian:trixie-slim AS mimalloc-debian
|
||||
|
||||
RUN apt update && apt upgrade -y && apt install -y gcc g++ make cmake git
|
||||
RUN git clone https://github.com/microsoft/mimalloc && \
|
||||
|
||||
@@ -48,7 +48,7 @@ impl SubstrateCli for Cli {
|
||||
}
|
||||
|
||||
pub fn run() -> sc_cli::Result<()> {
|
||||
let cli = Cli::from_args();
|
||||
let mut cli = Cli::from_args();
|
||||
|
||||
match &cli.subcommand {
|
||||
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
|
||||
@@ -98,11 +98,20 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
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).map_err(sc_cli::Error::Service)
|
||||
}),
|
||||
None => {
|
||||
cli.run.network_params.node_key_params = sc_cli::NodeKeyParams {
|
||||
node_key: None,
|
||||
node_key_file: None,
|
||||
node_key_type: sc_cli::arg_enums::NodeKeyType::Ed25519,
|
||||
unsafe_force_node_key_generation: true,
|
||||
};
|
||||
|
||||
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).map_err(sc_cli::Error::Service)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::{sync::Arc, collections::HashSet};
|
||||
|
||||
use rand_core::{RngCore, OsRng};
|
||||
|
||||
use sp_core::Encode;
|
||||
use sp_blockchain::{Error as BlockchainError, HeaderBackend, HeaderMetadata};
|
||||
use sp_block_builder::BlockBuilder;
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
@@ -15,6 +16,7 @@ use tokio::sync::RwLock;
|
||||
|
||||
use jsonrpsee::RpcModule;
|
||||
|
||||
use sc_client_api::BlockBackend;
|
||||
use sc_transaction_pool_api::TransactionPool;
|
||||
|
||||
pub struct FullDeps<C, P> {
|
||||
@@ -28,6 +30,7 @@ pub fn create_full<
|
||||
C: ProvideRuntimeApi<Block>
|
||||
+ HeaderBackend<Block>
|
||||
+ HeaderMetadata<Block, Error = BlockchainError>
|
||||
+ BlockBackend<Block>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
@@ -52,7 +55,7 @@ where
|
||||
|
||||
if let Some(authority_discovery) = authority_discovery {
|
||||
let mut authority_discovery_module =
|
||||
RpcModule::new((id, client, RwLock::new(authority_discovery)));
|
||||
RpcModule::new((id, client.clone(), RwLock::new(authority_discovery)));
|
||||
authority_discovery_module.register_async_method(
|
||||
"p2p_validators",
|
||||
|params, context, _ext| async move {
|
||||
@@ -105,5 +108,33 @@ where
|
||||
module.merge(authority_discovery_module)?;
|
||||
}
|
||||
|
||||
let mut block_bin_module = RpcModule::new(client);
|
||||
block_bin_module.register_async_method(
|
||||
"chain_getBlockBin",
|
||||
|params, client, _ext| async move {
|
||||
let [block_hash]: [String; 1] = params.parse()?;
|
||||
let Some(block_hash) = hex::decode(&block_hash).ok().and_then(|bytes| {
|
||||
<[u8; 32]>::try_from(bytes.as_slice())
|
||||
.map(<Block as sp_runtime::traits::Block>::Hash::from)
|
||||
.ok()
|
||||
}) else {
|
||||
return Err(jsonrpsee::types::error::ErrorObjectOwned::owned(
|
||||
-1,
|
||||
"requested block hash wasn't a valid hash",
|
||||
Option::<()>::None,
|
||||
));
|
||||
};
|
||||
let Some(block) = client.block(block_hash).ok().flatten() else {
|
||||
return Err(jsonrpsee::types::error::ErrorObjectOwned::owned(
|
||||
-1,
|
||||
"couldn't find requested block",
|
||||
Option::<()>::None,
|
||||
));
|
||||
};
|
||||
Ok(hex::encode(block.block.encode()))
|
||||
},
|
||||
)?;
|
||||
module.merge(block_bin_module)?;
|
||||
|
||||
Ok(module)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user