use clap::ValueEnum;
#[derive(Debug, Clone, Copy, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum WasmtimeInstantiationStrategy {
PoolingCopyOnWrite,
RecreateInstanceCopyOnWrite,
Pooling,
RecreateInstance,
LegacyInstanceReuse,
}
pub const DEFAULT_WASMTIME_INSTANTIATION_STRATEGY: WasmtimeInstantiationStrategy =
WasmtimeInstantiationStrategy::PoolingCopyOnWrite;
#[derive(Debug, Clone, Copy, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum WasmExecutionMethod {
#[clap(name = "interpreted-i-know-what-i-do")]
Interpreted,
Compiled,
}
impl std::fmt::Display for WasmExecutionMethod {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Interpreted => write!(f, "Interpreted"),
Self::Compiled => write!(f, "Compiled"),
}
}
}
pub fn execution_method_from_cli(
execution_method: WasmExecutionMethod,
_instantiation_strategy: WasmtimeInstantiationStrategy,
) -> sc_service::config::WasmExecutionMethod {
match execution_method {
WasmExecutionMethod::Interpreted => sc_service::config::WasmExecutionMethod::Interpreted,
WasmExecutionMethod::Compiled => sc_service::config::WasmExecutionMethod::Compiled {
instantiation_strategy: match _instantiation_strategy {
WasmtimeInstantiationStrategy::PoolingCopyOnWrite =>
sc_service::config::WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
WasmtimeInstantiationStrategy::RecreateInstanceCopyOnWrite =>
sc_service::config::WasmtimeInstantiationStrategy::RecreateInstanceCopyOnWrite,
WasmtimeInstantiationStrategy::Pooling =>
sc_service::config::WasmtimeInstantiationStrategy::Pooling,
WasmtimeInstantiationStrategy::RecreateInstance =>
sc_service::config::WasmtimeInstantiationStrategy::RecreateInstance,
WasmtimeInstantiationStrategy::LegacyInstanceReuse =>
sc_service::config::WasmtimeInstantiationStrategy::LegacyInstanceReuse,
},
},
}
}
pub const DEFAULT_WASM_EXECUTION_METHOD: WasmExecutionMethod = WasmExecutionMethod::Compiled;
#[allow(missing_docs)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum TracingReceiver {
Log,
}
impl Into<sc_tracing::TracingReceiver> for TracingReceiver {
fn into(self) -> sc_tracing::TracingReceiver {
match self {
TracingReceiver::Log => sc_tracing::TracingReceiver::Log,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum NodeKeyType {
Ed25519,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum CryptoScheme {
Ed25519,
Sr25519,
Ecdsa,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum OutputType {
Json,
Text,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum ExecutionStrategy {
Native,
Wasm,
Both,
NativeElseWasm,
}
impl Into<sc_client_api::ExecutionStrategy> for ExecutionStrategy {
fn into(self) -> sc_client_api::ExecutionStrategy {
match self {
ExecutionStrategy::Native => sc_client_api::ExecutionStrategy::NativeWhenPossible,
ExecutionStrategy::Wasm => sc_client_api::ExecutionStrategy::AlwaysWasm,
ExecutionStrategy::Both => sc_client_api::ExecutionStrategy::Both,
ExecutionStrategy::NativeElseWasm => sc_client_api::ExecutionStrategy::NativeElseWasm,
}
}
}
#[allow(missing_docs)]
#[derive(Debug, Copy, Clone, PartialEq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum RpcMethods {
Auto,
Safe,
Unsafe,
}
impl Into<sc_service::config::RpcMethods> for RpcMethods {
fn into(self) -> sc_service::config::RpcMethods {
match self {
RpcMethods::Auto => sc_service::config::RpcMethods::Auto,
RpcMethods::Safe => sc_service::config::RpcMethods::Safe,
RpcMethods::Unsafe => sc_service::config::RpcMethods::Unsafe,
}
}
}
#[derive(Debug, Clone, PartialEq, Copy, clap::ValueEnum)]
#[value(rename_all = "lower")]
pub enum Database {
#[cfg(feature = "rocksdb")]
RocksDb,
ParityDb,
Auto,
#[value(name = "paritydb-experimental")]
ParityDbDeprecated,
}
impl Database {
pub const fn variants() -> &'static [&'static str] {
&[
#[cfg(feature = "rocksdb")]
"rocksdb",
"paritydb",
"paritydb-experimental",
"auto",
]
}
}
#[allow(missing_docs)]
#[derive(Debug, Clone, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum OffchainWorkerEnabled {
Always,
Never,
WhenAuthority,
}
#[derive(Debug, Clone, Copy, ValueEnum, PartialEq)]
#[value(rename_all = "kebab-case")]
pub enum SyncMode {
Full,
Fast,
FastUnsafe,
Warp,
}
impl Into<sc_network::config::SyncMode> for SyncMode {
fn into(self) -> sc_network::config::SyncMode {
match self {
SyncMode::Full => sc_network::config::SyncMode::Full,
SyncMode::Fast =>
sc_network::config::SyncMode::Fast { skip_proofs: false, storage_chain_mode: false },
SyncMode::FastUnsafe =>
sc_network::config::SyncMode::Fast { skip_proofs: true, storage_chain_mode: false },
SyncMode::Warp => sc_network::config::SyncMode::Warp,
}
}
}
pub const DEFAULT_EXECUTION_SYNCING: ExecutionStrategy = ExecutionStrategy::Wasm;
pub const DEFAULT_EXECUTION_IMPORT_BLOCK: ExecutionStrategy = ExecutionStrategy::Wasm;
pub const DEFAULT_EXECUTION_IMPORT_BLOCK_VALIDATOR: ExecutionStrategy = ExecutionStrategy::Wasm;
pub const DEFAULT_EXECUTION_BLOCK_CONSTRUCTION: ExecutionStrategy = ExecutionStrategy::Wasm;
pub const DEFAULT_EXECUTION_OFFCHAIN_WORKER: ExecutionStrategy = ExecutionStrategy::Wasm;
pub const DEFAULT_EXECUTION_OTHER: ExecutionStrategy = ExecutionStrategy::Wasm;