difftreelog
feat add PoV estimate
in: master
19 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5362,6 +5362,7 @@
"substrate-wasm-builder",
"up-common",
"up-data-structs",
+ "up-pov-estimate-rpc",
"up-rpc",
"up-sponsorship",
"xcm",
@@ -5806,6 +5807,7 @@
"sp-runtime",
"sp-std",
"up-data-structs",
+ "up-pov-estimate-rpc",
]
[[package]]
@@ -8917,6 +8919,7 @@
"substrate-wasm-builder",
"up-common",
"up-data-structs",
+ "up-pov-estimate-rpc",
"up-rpc",
"up-sponsorship",
"xcm",
@@ -12824,18 +12827,31 @@
dependencies = [
"anyhow",
"app-promotion-rpc",
+ "frame-benchmarking",
"jsonrpsee",
+ "opal-runtime",
"pallet-common",
"pallet-evm",
"parity-scale-codec 3.2.1",
+ "quartz-runtime",
"rmrk-rpc",
+ "sc-client-api",
+ "sc-executor",
+ "sc-rpc-api",
+ "sc-service",
"sp-api",
"sp-blockchain",
"sp-core",
+ "sp-externalities",
"sp-rpc",
"sp-runtime",
+ "sp-state-machine",
+ "unique-runtime",
+ "up-common",
"up-data-structs",
+ "up-pov-estimate-rpc",
"up-rpc",
+ "zstd",
]
[[package]]
@@ -12978,10 +12994,12 @@
"substrate-prometheus-endpoint",
"tokio",
"try-runtime-cli",
+ "uc-rpc",
"unique-rpc",
"unique-runtime",
"up-common",
"up-data-structs",
+ "up-pov-estimate-rpc",
"up-rpc",
]
@@ -13032,6 +13050,7 @@
"uc-rpc",
"up-common",
"up-data-structs",
+ "up-pov-estimate-rpc",
"up-rpc",
]
@@ -13125,6 +13144,7 @@
"substrate-wasm-builder",
"up-common",
"up-data-structs",
+ "up-pov-estimate-rpc",
"up-rpc",
"up-sponsorship",
"xcm",
@@ -13194,6 +13214,19 @@
]
[[package]]
+name = "up-pov-estimate-rpc"
+version = "0.1.0"
+dependencies = [
+ "parity-scale-codec 3.2.1",
+ "scale-info",
+ "serde",
+ "sp-api",
+ "sp-core",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
name = "up-rpc"
version = "0.1.3"
dependencies = [
client/rpc/Cargo.tomldiffbeforeafterboth--- a/client/rpc/Cargo.toml
+++ b/client/rpc/Cargo.toml
@@ -7,16 +7,40 @@
[dependencies]
pallet-common = { default-features = false, path = '../../pallets/common' }
up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
+up-common = { default-features = false, path = '../../primitives/common' }
up-rpc = { path = "../../primitives/rpc" }
app-promotion-rpc = { path = "../../primitives/app_promotion_rpc" }
rmrk-rpc = { path = "../../primitives/rmrk-rpc" }
+up-pov-estimate-rpc = { path = "../../primitives/pov-estimate-rpc", optional = true }
codec = { package = "parity-scale-codec", version = "3.1.2" }
jsonrpsee = { version = "0.16.2", features = ["server", "macros"] }
anyhow = "1.0.57"
+zstd = { version = "0.11.2", default-features = false }
+sc-rpc-api = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
+sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
+sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
+sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
+sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
sp-api = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
sp-blockchain = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
sp-rpc = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.36" }
+
+frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
+
+sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
+
+unique-runtime = { path = '../../runtime/unique', optional = true }
+quartz-runtime = { path = '../../runtime/quartz', optional = true }
+opal-runtime = { path = '../../runtime/opal' }
+
+[features]
+pov-estimate = [
+ 'up-pov-estimate-rpc',
+ 'unique-runtime?/pov-estimate',
+ 'quartz-runtime?/pov-estimate',
+ 'opal-runtime/pov-estimate',
+]
client/rpc/src/lib.rsdiffbeforeafterboth--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -42,6 +42,9 @@
pub use app_promotion_unique_rpc::AppPromotionApiServer;
pub use rmrk_unique_rpc::RmrkApiServer;
+#[cfg(feature = "pov-estimate")]
+pub mod pov_estimate;
+
#[rpc(server)]
#[async_trait]
pub trait UniqueApi<BlockHash, CrossAccountId, AccountId> {
@@ -420,17 +423,18 @@
}
}
+#[macro_export]
macro_rules! define_struct_for_server_api {
- ($name:ident) => {
- pub struct $name<C, P> {
- client: Arc<C>,
- _marker: std::marker::PhantomData<P>,
+ ($name:ident { $($arg:ident: $arg_ty:ty),+ $(,)? }) => {
+ pub struct $name<Client, Block: BlockT> {
+ $($arg: $arg_ty),+,
+ _marker: std::marker::PhantomData<Block>,
}
- impl<C, P> $name<C, P> {
- pub fn new(client: Arc<C>) -> Self {
+ impl<Client, Block: BlockT> $name<Client, Block> {
+ pub fn new($($arg: $arg_ty),+) -> Self {
Self {
- client,
+ $($arg),+,
_marker: Default::default(),
}
}
@@ -438,9 +442,23 @@
};
}
-define_struct_for_server_api!(Unique);
-define_struct_for_server_api!(AppPromotion);
-define_struct_for_server_api!(Rmrk);
+define_struct_for_server_api! {
+ Unique {
+ client: Arc<Client>
+ }
+}
+
+define_struct_for_server_api! {
+ AppPromotion {
+ client: Arc<Client>
+ }
+}
+
+define_struct_for_server_api! {
+ Rmrk {
+ client: Arc<Client>
+ }
+}
macro_rules! pass_method {
(
client/rpc/src/pov_estimate.rsdiffbeforeafterboth--- /dev/null
+++ b/client/rpc/src/pov_estimate.rs
@@ -0,0 +1,205 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+use std::sync::Arc;
+
+use codec::Encode;
+
+use up_pov_estimate_rpc::{PovEstimateApi as PovEstimateRuntimeApi};
+use up_common::types::opaque::RuntimeId;
+
+use sc_service::{NativeExecutionDispatch, config::ExecutionStrategy};
+use sp_state_machine::{StateMachine, TrieBackendBuilder};
+
+use jsonrpsee::{
+ core::RpcResult as Result,
+ proc_macros::rpc,
+};
+use anyhow::anyhow;
+
+use sc_client_api::backend::Backend;
+use sp_blockchain::HeaderBackend;
+use sp_api::{AsTrieBackend, BlockId, BlockT, ProvideRuntimeApi};
+
+use sc_executor::NativeElseWasmExecutor;
+use sc_rpc_api::DenyUnsafe;
+
+use sp_runtime::traits::Header;
+
+use up_pov_estimate_rpc::PovInfo;
+
+use crate::define_struct_for_server_api;
+
+type HasherOf<Block> = <<Block as BlockT>::Header as Header>::Hashing;
+type StateOf<Block> = <sc_service::TFullBackend<Block> as Backend<Block>>::State;
+
+pub struct ExecutorParams {
+ pub wasm_method: sc_service::config::WasmExecutionMethod,
+ pub default_heap_pages: Option<u64>,
+ pub max_runtime_instances: usize,
+ pub runtime_cache_size: u8,
+}
+
+#[cfg(feature = "unique-runtime")]
+pub struct UniqueRuntimeExecutor;
+
+#[cfg(feature = "quartz-runtime")]
+pub struct QuartzRuntimeExecutor;
+
+pub struct OpalRuntimeExecutor;
+
+#[cfg(feature = "unique-runtime")]
+impl NativeExecutionDispatch for UniqueRuntimeExecutor {
+ type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
+
+ fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
+ unique_runtime::api::dispatch(method, data)
+ }
+
+ fn native_version() -> sc_executor::NativeVersion {
+ unique_runtime::native_version()
+ }
+}
+
+#[cfg(feature = "quartz-runtime")]
+impl NativeExecutionDispatch for QuartzRuntimeExecutor {
+ type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
+
+ fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
+ quartz_runtime::api::dispatch(method, data)
+ }
+
+ fn native_version() -> sc_executor::NativeVersion {
+ quartz_runtime::native_version()
+ }
+}
+
+impl NativeExecutionDispatch for OpalRuntimeExecutor {
+ type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
+
+ fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
+ opal_runtime::api::dispatch(method, data)
+ }
+
+ fn native_version() -> sc_executor::NativeVersion {
+ opal_runtime::native_version()
+ }
+}
+
+#[cfg(feature = "pov-estimate")]
+define_struct_for_server_api! {
+ PovEstimate {
+ client: Arc<Client>,
+ backend: Arc<sc_service::TFullBackend<Block>>,
+ deny_unsafe: DenyUnsafe,
+ exec_params: ExecutorParams,
+ runtime_id: RuntimeId,
+ }
+}
+
+#[rpc(server)]
+#[async_trait]
+pub trait PovEstimateApi<BlockHash> {
+ #[method(name = "unique_povEstimate")]
+ fn pov_estimate(&self, encoded_xt: Vec<u8>, at: Option<BlockHash>) -> Result<PovInfo>;
+}
+
+#[allow(deprecated)]
+#[cfg(feature = "pov-estimate")]
+impl<C, Block>
+ PovEstimateApiServer<<Block as BlockT>::Hash> for PovEstimate<C, Block>
+where
+ Block: BlockT,
+ C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,
+ C::Api: PovEstimateRuntimeApi<Block>,
+{
+ fn pov_estimate(&self, encoded_xt: Vec<u8>, at: Option<<Block as BlockT>::Hash>,) -> Result<PovInfo> {
+ self.deny_unsafe.check_if_safe()?;
+
+ let at = BlockId::<Block>::hash(at.unwrap_or_else(|| self.client.info().best_hash));
+ let state = self.backend.state_at(at).map_err(|_| anyhow!("unable to fetch the state at {at:?}"))?;
+ match &self.runtime_id {
+ #[cfg(feature = "unique-runtime")]
+ RuntimeId::Unique => execute_extrinsic_in_sandbox::<Block, UniqueRuntimeExecutor>(state, &self.exec_params, encoded_xt),
+
+ #[cfg(feature = "quartz-runtime")]
+ RuntimeId::Quartz => execute_extrinsic_in_sandbox::<Block, QuartzRuntimeExecutor>(state, &self.exec_params, encoded_xt),
+
+ RuntimeId::Opal => execute_extrinsic_in_sandbox::<Block, OpalRuntimeExecutor>(state, &self.exec_params, encoded_xt),
+
+ runtime_id => Err(anyhow!("unknown runtime id {:?}", runtime_id).into()),
+ }
+ }
+}
+
+fn execute_extrinsic_in_sandbox<Block, D>(state: StateOf<Block>, exec_params: &ExecutorParams, encoded_xt: Vec<u8>) -> Result<PovInfo>
+where
+ Block: BlockT,
+ D: NativeExecutionDispatch + 'static,
+{
+ let backend = state.as_trie_backend().clone();
+ let mut changes = Default::default();
+ let runtime_code_backend = sp_state_machine::backend::BackendRuntimeCode::new(backend);
+
+ let proving_backend =
+ TrieBackendBuilder::wrap(&backend).with_recorder(Default::default()).build();
+
+ let runtime_code = runtime_code_backend.runtime_code()
+ .map_err(|_| anyhow!("runtime code backend creation failed"))?;
+
+ let pre_root = *backend.root();
+
+ let executor = NativeElseWasmExecutor::<D>::new(
+ exec_params.wasm_method,
+ exec_params.default_heap_pages,
+ exec_params.max_runtime_instances,
+ exec_params.runtime_cache_size,
+ );
+ let execution = ExecutionStrategy::NativeElseWasm;
+
+ StateMachine::new(
+ &proving_backend,
+ &mut changes,
+ &executor,
+ "PovEstimateApi_pov_estimate",
+ encoded_xt.as_slice(),
+ sp_externalities::Extensions::default(),
+ &runtime_code,
+ sp_core::testing::TaskExecutor::new(),
+ )
+ .execute(execution.into())
+ .map_err(|e| anyhow!("failed to execute the extrinsic {:?}", e))?;
+
+ let proof = proving_backend
+ .extract_proof()
+ .expect("A recorder was set and thus, a storage proof can be extracted; qed");
+ let proof_size = proof.encoded_size();
+ let compact_proof = proof
+ .clone()
+ .into_compact_proof::<HasherOf<Block>>(pre_root)
+ .map_err(|e| anyhow!("failed to generate compact proof {:?}", e))?;
+ let compact_proof_size = compact_proof.encoded_size();
+
+ let compressed_proof = zstd::stream::encode_all(&compact_proof.encode()[..], 0)
+ .map_err(|e| anyhow!("failed to generate compact proof {:?}", e))?;
+ let compressed_proof_size = compressed_proof.len();
+
+ Ok(PovInfo {
+ proof_size: proof_size as u64,
+ compact_proof_size: compact_proof_size as u64,
+ compressed_proof_size: compressed_proof_size as u64,
+ })
+}
node/cli/Cargo.tomldiffbeforeafterboth--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -319,8 +319,10 @@
pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.36" }
unique-rpc = { default-features = false, path = "../rpc" }
+uc-rpc = { default-features = false, path = "../../client/rpc" }
app-promotion-rpc = { path = "../../primitives/app_promotion_rpc", default-features = false }
rmrk-rpc = { path = "../../primitives/rmrk-rpc" }
+up-pov-estimate-rpc = { path = "../../primitives/pov-estimate-rpc", default-features = false }
[features]
default = ["opal-runtime"]
@@ -339,3 +341,10 @@
'try-runtime-cli/try-runtime',
]
sapphire-runtime = ['opal-runtime', 'opal-runtime/become-sapphire']
+pov-estimate = [
+ 'unique-runtime?/pov-estimate',
+ 'quartz-runtime?/pov-estimate',
+ 'opal-runtime/pov-estimate',
+ 'uc-rpc/pov-estimate',
+ 'unique-rpc/pov-estimate',
+]
node/cli/src/chain_spec.rsdiffbeforeafterboth--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -54,17 +54,6 @@
#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
pub type DefaultChainSpec = OpalChainSpec;
-pub enum RuntimeId {
- #[cfg(feature = "unique-runtime")]
- Unique,
-
- #[cfg(feature = "quartz-runtime")]
- Quartz,
-
- Opal,
- Unknown(String),
-}
-
#[cfg(not(feature = "unique-runtime"))]
/// PARA_ID for Opal/Sapphire/Quartz
const PARA_ID: u32 = 2095;
node/cli/src/command.rsdiffbeforeafterboth--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -33,7 +33,7 @@
// limitations under the License.
use crate::{
- chain_spec::{self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification},
+ chain_spec::{self, RuntimeIdentification, ServiceId, ServiceIdentification},
cli::{Cli, RelayChainCli, Subcommand},
service::{new_partial, start_node, start_dev_node},
};
@@ -66,13 +66,13 @@
use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
use std::{net::SocketAddr, time::Duration};
-use up_common::types::opaque::Block;
+use up_common::types::opaque::{Block, RuntimeId};
macro_rules! no_runtime_err {
- ($chain_name:expr) => {
+ ($runtime_id:expr) => {
format!(
- "No runtime valid runtime was found for chain {}",
- $chain_name
+ "No runtime valid runtime was found for chain {:#?}",
+ $runtime_id
)
};
}
@@ -94,7 +94,7 @@
RuntimeId::Quartz => Box::new(chain_spec::QuartzChainSpec::from_json_file(path)?),
RuntimeId::Opal => chain_spec,
- RuntimeId::Unknown(chain) => return Err(no_runtime_err!(chain)),
+ runtime_id => return Err(no_runtime_err!(runtime_id)),
}
}
})
@@ -147,7 +147,7 @@
RuntimeId::Quartz => &quartz_runtime::VERSION,
RuntimeId::Opal => &opal_runtime::VERSION,
- RuntimeId::Unknown(chain) => panic!("{}", no_runtime_err!(chain)),
+ runtime_id => panic!("{}", no_runtime_err!(runtime_id)),
}
}
}
@@ -235,7 +235,7 @@
runner, $components, $cli, $cmd, $config, $( $code )*
),
- RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into())
+ runtime_id => Err(no_runtime_err!(runtime_id).into())
}
}}
}
@@ -274,7 +274,7 @@
runner, $components, $cli, $cmd, $config, $( $code )*
),
- RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into())
+ runtime_id => Err(no_runtime_err!(runtime_id).into())
}
}}
}
@@ -302,7 +302,7 @@
OpalRuntimeExecutor,
>($config $(, $($args),+)?) $($code)*,
- RuntimeId::Unknown(chain) => Err(no_runtime_err!(chain).into()),
+ runtime_id => Err(no_runtime_err!(runtime_id).into()),
}
};
}
@@ -445,7 +445,7 @@
sp_io::SubstrateHostFunctions,
<OpalRuntimeExecutor as NativeExecutionDispatch>::ExtendHostFunctions,
>>()),
- RuntimeId::Unknown(chain) => return Err(no_runtime_err!(chain).into()),
+ runtime_id => return Err(no_runtime_err!(runtime_id).into()),
},
task_manager,
))
node/cli/src/service.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// std18use std::sync::Arc;19use std::sync::Mutex;20use std::collections::BTreeMap;21use std::time::Duration;22use std::pin::Pin;23use fc_rpc_core::types::FeeHistoryCache;24use futures::{25 Stream, StreamExt,26 stream::select,27 task::{Context, Poll},28};29use tokio::time::Interval;3031use unique_rpc::overrides_handle;3233use serde::{Serialize, Deserialize};3435// Cumulus Imports36use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};37use cumulus_client_consensus_common::{38 ParachainConsensus, ParachainBlockImport as TParachainBlockImport,39};40use cumulus_client_service::{41 prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,42};43use cumulus_client_cli::CollatorOptions;44use cumulus_client_network::BlockAnnounceValidator;45use cumulus_primitives_core::ParaId;46use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;47use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};48use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node;4950// Substrate Imports51use sp_api::BlockT;52use sc_executor::NativeElseWasmExecutor;53use sc_executor::NativeExecutionDispatch;54use sc_network::{NetworkService, NetworkBlock};55use sc_service::{BasePath, Configuration, PartialComponents, TaskManager};56use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};57use sp_keystore::SyncCryptoStorePtr;58use sp_runtime::traits::BlakeTwo256;59use substrate_prometheus_endpoint::Registry;60use sc_client_api::BlockchainEvents;61use sc_consensus::ImportQueue;6263use polkadot_service::CollatorPair;6465// Frontier Imports66use fc_rpc_core::types::FilterPool;67use fc_mapping_sync::{MappingSyncWorker, SyncStrategy};6869use up_common::types::opaque::{70 AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block, BlockNumber,71};7273// RMRK74use up_data_structs::{75 RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,76 RmrkPartType, RmrkTheme,77};7879/// Unique native executor instance.80#[cfg(feature = "unique-runtime")]81pub struct UniqueRuntimeExecutor;8283#[cfg(feature = "quartz-runtime")]84/// Quartz native executor instance.85pub struct QuartzRuntimeExecutor;8687/// Opal native executor instance.88pub struct OpalRuntimeExecutor;8990#[cfg(all(feature = "unique-runtime", feature = "runtime-benchmarks"))]91pub type DefaultRuntimeExecutor = UniqueRuntimeExecutor;9293#[cfg(all(94 not(feature = "unique-runtime"),95 feature = "quartz-runtime",96 feature = "runtime-benchmarks"97))]98pub type DefaultRuntimeExecutor = QuartzRuntimeExecutor;99100#[cfg(all(101 not(feature = "unique-runtime"),102 not(feature = "quartz-runtime"),103 feature = "runtime-benchmarks"104))]105pub type DefaultRuntimeExecutor = OpalRuntimeExecutor;106107#[cfg(feature = "unique-runtime")]108impl NativeExecutionDispatch for UniqueRuntimeExecutor {109 /// Only enable the benchmarking host functions when we actually want to benchmark.110 #[cfg(feature = "runtime-benchmarks")]111 type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;112 /// Otherwise we only use the default Substrate host functions.113 #[cfg(not(feature = "runtime-benchmarks"))]114 type ExtendHostFunctions = ();115116 fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {117 unique_runtime::api::dispatch(method, data)118 }119120 fn native_version() -> sc_executor::NativeVersion {121 unique_runtime::native_version()122 }123}124125#[cfg(feature = "quartz-runtime")]126impl NativeExecutionDispatch for QuartzRuntimeExecutor {127 /// Only enable the benchmarking host functions when we actually want to benchmark.128 #[cfg(feature = "runtime-benchmarks")]129 type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;130 /// Otherwise we only use the default Substrate host functions.131 #[cfg(not(feature = "runtime-benchmarks"))]132 type ExtendHostFunctions = ();133134 fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {135 quartz_runtime::api::dispatch(method, data)136 }137138 fn native_version() -> sc_executor::NativeVersion {139 quartz_runtime::native_version()140 }141}142143impl NativeExecutionDispatch for OpalRuntimeExecutor {144 /// Only enable the benchmarking host functions when we actually want to benchmark.145 #[cfg(feature = "runtime-benchmarks")]146 type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;147 /// Otherwise we only use the default Substrate host functions.148 #[cfg(not(feature = "runtime-benchmarks"))]149 type ExtendHostFunctions = ();150151 fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {152 opal_runtime::api::dispatch(method, data)153 }154155 fn native_version() -> sc_executor::NativeVersion {156 opal_runtime::native_version()157 }158}159160pub struct AutosealInterval {161 interval: Interval,162}163164impl AutosealInterval {165 pub fn new(config: &Configuration, interval: Duration) -> Self {166 let _tokio_runtime = config.tokio_handle.enter();167 let interval = tokio::time::interval(interval);168169 Self { interval }170 }171}172173impl Stream for AutosealInterval {174 type Item = tokio::time::Instant;175176 fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {177 self.interval.poll_tick(cx).map(Some)178 }179}180181pub fn open_frontier_backend<Block: BlockT, C: sp_blockchain::HeaderBackend<Block>>(182 client: Arc<C>,183 config: &Configuration,184) -> Result<Arc<fc_db::Backend<Block>>, String> {185 let config_dir = config186 .base_path187 .as_ref()188 .map(|base_path| base_path.config_dir(config.chain_spec.id()))189 .unwrap_or_else(|| {190 BasePath::from_project("", "", "unique").config_dir(config.chain_spec.id())191 });192 let database_dir = config_dir.join("frontier").join("db");193194 Ok(Arc::new(fc_db::Backend::<Block>::new(195 client,196 &fc_db::DatabaseSettings {197 source: fc_db::DatabaseSource::RocksDb {198 path: database_dir,199 cache_size: 0,200 },201 },202 )?))203}204205type FullClient<RuntimeApi, ExecutorDispatch> =206 sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;207type FullBackend = sc_service::TFullBackend<Block>;208type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;209type ParachainBlockImport<RuntimeApi, ExecutorDispatch> =210 TParachainBlockImport<Block, Arc<FullClient<RuntimeApi, ExecutorDispatch>>, FullBackend>;211212/// Starts a `ServiceBuilder` for a full service.213///214/// Use this macro if you don't actually need the full service, but just the builder in order to215/// be able to perform chain operations.216#[allow(clippy::type_complexity)]217pub fn new_partial<RuntimeApi, ExecutorDispatch, BIQ>(218 config: &Configuration,219 build_import_queue: BIQ,220) -> Result<221 PartialComponents<222 FullClient<RuntimeApi, ExecutorDispatch>,223 FullBackend,224 FullSelectChain,225 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,226 sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,227 (228 Option<Telemetry>,229 Option<FilterPool>,230 Arc<fc_db::Backend<Block>>,231 Option<TelemetryWorkerHandle>,232 FeeHistoryCache,233 ),234 >,235 sc_service::Error,236>237where238 sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,239 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>240 + Send241 + Sync242 + 'static,243 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,244 ExecutorDispatch: NativeExecutionDispatch + 'static,245 BIQ: FnOnce(246 Arc<FullClient<RuntimeApi, ExecutorDispatch>>,247 Arc<FullBackend>,248 &Configuration,249 Option<TelemetryHandle>,250 &TaskManager,251 ) -> Result<252 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,253 sc_service::Error,254 >,255{256 let _telemetry = config257 .telemetry_endpoints258 .clone()259 .filter(|x| !x.is_empty())260 .map(|endpoints| -> Result<_, sc_telemetry::Error> {261 let worker = TelemetryWorker::new(16)?;262 let telemetry = worker.handle().new_telemetry(endpoints);263 Ok((worker, telemetry))264 })265 .transpose()?;266267 let telemetry = config268 .telemetry_endpoints269 .clone()270 .filter(|x| !x.is_empty())271 .map(|endpoints| -> Result<_, sc_telemetry::Error> {272 let worker = TelemetryWorker::new(16)?;273 let telemetry = worker.handle().new_telemetry(endpoints);274 Ok((worker, telemetry))275 })276 .transpose()?;277278 let executor = NativeElseWasmExecutor::<ExecutorDispatch>::new(279 config.wasm_method,280 config.default_heap_pages,281 config.max_runtime_instances,282 config.runtime_cache_size,283 );284285 let (client, backend, keystore_container, task_manager) =286 sc_service::new_full_parts::<Block, RuntimeApi, _>(287 config,288 telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),289 executor,290 )?;291 let client = Arc::new(client);292293 let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle());294295 let telemetry = telemetry.map(|(worker, telemetry)| {296 task_manager297 .spawn_handle()298 .spawn("telemetry", None, worker.run());299 telemetry300 });301302 let select_chain = sc_consensus::LongestChain::new(backend.clone());303304 let transaction_pool = sc_transaction_pool::BasicPool::new_full(305 config.transaction_pool.clone(),306 config.role.is_authority().into(),307 config.prometheus_registry(),308 task_manager.spawn_essential_handle(),309 client.clone(),310 );311312 let filter_pool: Option<FilterPool> = Some(Arc::new(Mutex::new(BTreeMap::new())));313314 let frontier_backend = open_frontier_backend(client.clone(), config)?;315316 let import_queue = build_import_queue(317 client.clone(),318 backend.clone(),319 config,320 telemetry.as_ref().map(|telemetry| telemetry.handle()),321 &task_manager,322 )?;323 let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));324325 let params = PartialComponents {326 backend,327 client,328 import_queue,329 keystore_container,330 task_manager,331 transaction_pool,332 select_chain,333 other: (334 telemetry,335 filter_pool,336 frontier_backend,337 telemetry_worker_handle,338 fee_history_cache,339 ),340 };341342 Ok(params)343}344345async fn build_relay_chain_interface(346 polkadot_config: Configuration,347 parachain_config: &Configuration,348 telemetry_worker_handle: Option<TelemetryWorkerHandle>,349 task_manager: &mut TaskManager,350 collator_options: CollatorOptions,351 hwbench: Option<sc_sysinfo::HwBench>,352) -> RelayChainResult<(353 Arc<(dyn RelayChainInterface + 'static)>,354 Option<CollatorPair>,355)> {356 if collator_options.relay_chain_rpc_urls.is_empty() {357 build_inprocess_relay_chain(358 polkadot_config,359 parachain_config,360 telemetry_worker_handle,361 task_manager,362 hwbench,363 )364 } else {365 build_minimal_relay_chain_node(366 polkadot_config,367 task_manager,368 collator_options.relay_chain_rpc_urls,369 )370 .await371 }372}373374/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.375///376/// This is the actual implementation that is abstract over the executor and the runtime api.377#[sc_tracing::logging::prefix_logs_with("Parachain")]378async fn start_node_impl<Runtime, RuntimeApi, ExecutorDispatch, BIQ, BIC>(379 parachain_config: Configuration,380 polkadot_config: Configuration,381 collator_options: CollatorOptions,382 id: ParaId,383 build_import_queue: BIQ,384 build_consensus: BIC,385 hwbench: Option<sc_sysinfo::HwBench>,386) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>387where388 sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,389 Runtime: RuntimeInstance + Send + Sync + 'static,390 <Runtime as RuntimeInstance>::CrossAccountId: Serialize,391 for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,392 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>393 + Send394 + Sync395 + 'static,396 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>397 + fp_rpc::EthereumRuntimeRPCApi<Block>398 + fp_rpc::ConvertTransactionRuntimeApi<Block>399 + sp_session::SessionKeys<Block>400 + sp_block_builder::BlockBuilder<Block>401 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>402 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>403 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>404 + app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>405 + rmrk_rpc::RmrkApi<406 Block,407 AccountId,408 RmrkCollectionInfo<AccountId>,409 RmrkInstanceInfo<AccountId>,410 RmrkResourceInfo,411 RmrkPropertyInfo,412 RmrkBaseInfo<AccountId>,413 RmrkPartType,414 RmrkTheme,415 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>416 + sp_api::Metadata<Block>417 + sp_offchain::OffchainWorkerApi<Block>418 + cumulus_primitives_core::CollectCollationInfo<Block>,419 ExecutorDispatch: NativeExecutionDispatch + 'static,420 BIQ: FnOnce(421 Arc<FullClient<RuntimeApi, ExecutorDispatch>>,422 Arc<FullBackend>,423 &Configuration,424 Option<TelemetryHandle>,425 &TaskManager,426 ) -> Result<427 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,428 sc_service::Error,429 >,430 BIC: FnOnce(431 Arc<FullClient<RuntimeApi, ExecutorDispatch>>,432 Arc<FullBackend>,433 Option<&Registry>,434 Option<TelemetryHandle>,435 &TaskManager,436 Arc<dyn RelayChainInterface>,437 Arc<sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>>,438 Arc<NetworkService<Block, Hash>>,439 SyncCryptoStorePtr,440 bool,441 ) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,442{443 let parachain_config = prepare_node_config(parachain_config);444445 let params =446 new_partial::<RuntimeApi, ExecutorDispatch, BIQ>(¶chain_config, build_import_queue)?;447 let (mut telemetry, filter_pool, frontier_backend, telemetry_worker_handle, fee_history_cache) =448 params.other;449450 let client = params.client.clone();451 let backend = params.backend.clone();452 let mut task_manager = params.task_manager;453454 let (relay_chain_interface, collator_key) = build_relay_chain_interface(455 polkadot_config,456 ¶chain_config,457 telemetry_worker_handle,458 &mut task_manager,459 collator_options.clone(),460 hwbench.clone(),461 )462 .await463 .map_err(|e| match e {464 RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,465 s => s.to_string().into(),466 })?;467468 let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id);469470 let force_authoring = parachain_config.force_authoring;471 let validator = parachain_config.role.is_authority();472 let prometheus_registry = parachain_config.prometheus_registry().cloned();473 let transaction_pool = params.transaction_pool.clone();474 let import_queue_service = params.import_queue.service();475476 let (network, system_rpc_tx, tx_handler_controller, start_network) =477 sc_service::build_network(sc_service::BuildNetworkParams {478 config: ¶chain_config,479 client: client.clone(),480 transaction_pool: transaction_pool.clone(),481 spawn_handle: task_manager.spawn_handle(),482 import_queue: params.import_queue,483 block_announce_validator_builder: Some(Box::new(|_| {484 Box::new(block_announce_validator)485 })),486 warp_sync: None,487 })?;488489 let rpc_client = client.clone();490 let rpc_pool = transaction_pool.clone();491 let select_chain = params.select_chain.clone();492 let rpc_network = network.clone();493494 let rpc_frontier_backend = frontier_backend.clone();495496 let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(497 task_manager.spawn_handle(),498 overrides_handle::<_, _, Runtime>(client.clone()),499 50,500 50,501 prometheus_registry.clone(),502 ));503504 task_manager.spawn_essential_handle().spawn(505 "frontier-mapping-sync-worker",506 None,507 MappingSyncWorker::new(508 client.import_notification_stream(),509 Duration::new(6, 0),510 client.clone(),511 backend.clone(),512 frontier_backend.clone(),513 3,514 0,515 SyncStrategy::Normal,516 )517 .for_each(|()| futures::future::ready(())),518 );519520 let rpc_builder = Box::new(move |deny_unsafe, subscription_task_executor| {521 let full_deps = unique_rpc::FullDeps {522 backend: rpc_frontier_backend.clone(),523 deny_unsafe,524 client: rpc_client.clone(),525 pool: rpc_pool.clone(),526 graph: rpc_pool.pool().clone(),527 // TODO: Unhardcode528 enable_dev_signer: false,529 filter_pool: filter_pool.clone(),530 network: rpc_network.clone(),531 select_chain: select_chain.clone(),532 is_authority: validator,533 // TODO: Unhardcode534 max_past_logs: 10000,535 block_data_cache: block_data_cache.clone(),536 fee_history_cache: fee_history_cache.clone(),537 // TODO: Unhardcode538 fee_history_limit: 2048,539 };540541 unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(542 full_deps,543 subscription_task_executor,544 )545 .map_err(Into::into)546 });547548 sc_service::spawn_tasks(sc_service::SpawnTasksParams {549 rpc_builder,550 client: client.clone(),551 transaction_pool: transaction_pool.clone(),552 task_manager: &mut task_manager,553 config: parachain_config,554 keystore: params.keystore_container.sync_keystore(),555 backend: backend.clone(),556 network: network.clone(),557 system_rpc_tx,558 telemetry: telemetry.as_mut(),559 tx_handler_controller,560 })?;561562 if let Some(hwbench) = hwbench {563 sc_sysinfo::print_hwbench(&hwbench);564565 if let Some(ref mut telemetry) = telemetry {566 let telemetry_handle = telemetry.handle();567 task_manager.spawn_handle().spawn(568 "telemetry_hwbench",569 None,570 sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),571 );572 }573 }574575 let announce_block = {576 let network = network.clone();577 Arc::new(Box::new(move |hash, data| {578 network.announce_block(hash, data)579 }))580 };581582 let relay_chain_slot_duration = Duration::from_secs(6);583584 if validator {585 let parachain_consensus = build_consensus(586 client.clone(),587 backend.clone(),588 prometheus_registry.as_ref(),589 telemetry.as_ref().map(|t| t.handle()),590 &task_manager,591 relay_chain_interface.clone(),592 transaction_pool,593 network,594 params.keystore_container.sync_keystore(),595 force_authoring,596 )?;597598 let spawner = task_manager.spawn_handle();599600 let params = StartCollatorParams {601 para_id: id,602 block_status: client.clone(),603 announce_block,604 client: client.clone(),605 task_manager: &mut task_manager,606 spawner,607 parachain_consensus,608 import_queue: import_queue_service,609 collator_key: collator_key.expect("Command line arguments do not allow this. qed"),610 relay_chain_interface,611 relay_chain_slot_duration,612 };613614 start_collator(params).await?;615 } else {616 let params = StartFullNodeParams {617 client: client.clone(),618 announce_block,619 task_manager: &mut task_manager,620 para_id: id,621 import_queue: import_queue_service,622 relay_chain_interface,623 relay_chain_slot_duration,624 };625626 start_full_node(params)?;627 }628629 start_network.start_network();630631 Ok((task_manager, client))632}633634/// Build the import queue for the the parachain runtime.635pub fn parachain_build_import_queue<RuntimeApi, ExecutorDispatch>(636 client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,637 backend: Arc<FullBackend>,638 config: &Configuration,639 telemetry: Option<TelemetryHandle>,640 task_manager: &TaskManager,641) -> Result<642 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,643 sc_service::Error,644>645where646 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>647 + Send648 + Sync649 + 'static,650 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>651 + sp_block_builder::BlockBuilder<Block>652 + sp_consensus_aura::AuraApi<Block, AuraId>653 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,654 ExecutorDispatch: NativeExecutionDispatch + 'static,655{656 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;657658 let block_import = ParachainBlockImport::new(client.clone(), backend.clone());659660 cumulus_client_consensus_aura::import_queue::<661 sp_consensus_aura::sr25519::AuthorityPair,662 _,663 _,664 _,665 _,666 _,667 >(cumulus_client_consensus_aura::ImportQueueParams {668 block_import,669 client: client.clone(),670 create_inherent_data_providers: move |_, _| async move {671 let time = sp_timestamp::InherentDataProvider::from_system_time();672673 let slot =674 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(675 *time,676 slot_duration,677 );678679 Ok((slot, time))680 },681 registry: config.prometheus_registry(),682 spawner: &task_manager.spawn_essential_handle(),683 telemetry,684 })685 .map_err(Into::into)686}687688/// Start a normal parachain node.689pub async fn start_node<Runtime, RuntimeApi, ExecutorDispatch>(690 parachain_config: Configuration,691 polkadot_config: Configuration,692 collator_options: CollatorOptions,693 id: ParaId,694 hwbench: Option<sc_sysinfo::HwBench>,695) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>696where697 Runtime: RuntimeInstance + Send + Sync + 'static,698 <Runtime as RuntimeInstance>::CrossAccountId: Serialize,699 for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,700 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>701 + Send702 + Sync703 + 'static,704 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>705 + fp_rpc::EthereumRuntimeRPCApi<Block>706 + fp_rpc::ConvertTransactionRuntimeApi<Block>707 + sp_session::SessionKeys<Block>708 + sp_block_builder::BlockBuilder<Block>709 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>710 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>711 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>712 + app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>713 + rmrk_rpc::RmrkApi<714 Block,715 AccountId,716 RmrkCollectionInfo<AccountId>,717 RmrkInstanceInfo<AccountId>,718 RmrkResourceInfo,719 RmrkPropertyInfo,720 RmrkBaseInfo<AccountId>,721 RmrkPartType,722 RmrkTheme,723 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>724 + sp_api::Metadata<Block>725 + sp_offchain::OffchainWorkerApi<Block>726 + cumulus_primitives_core::CollectCollationInfo<Block>727 + sp_consensus_aura::AuraApi<Block, AuraId>,728 ExecutorDispatch: NativeExecutionDispatch + 'static,729{730 start_node_impl::<Runtime, RuntimeApi, ExecutorDispatch, _, _>(731 parachain_config,732 polkadot_config,733 collator_options,734 id,735 parachain_build_import_queue,736 |client,737 backend,738 prometheus_registry,739 telemetry,740 task_manager,741 relay_chain_interface,742 transaction_pool,743 sync_oracle,744 keystore,745 force_authoring| {746 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;747748 let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(749 task_manager.spawn_handle(),750 client.clone(),751 transaction_pool,752 prometheus_registry,753 telemetry.clone(),754 );755756 let block_import = ParachainBlockImport::new(client.clone(), backend.clone());757758 Ok(AuraConsensus::build::<759 sp_consensus_aura::sr25519::AuthorityPair,760 _,761 _,762 _,763 _,764 _,765 _,766 >(BuildAuraConsensusParams {767 proposer_factory,768 create_inherent_data_providers: move |_, (relay_parent, validation_data)| {769 let relay_chain_interface = relay_chain_interface.clone();770 async move {771 let parachain_inherent =772 cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(773 relay_parent,774 &relay_chain_interface,775 &validation_data,776 id,777 ).await;778779 let time = sp_timestamp::InherentDataProvider::from_system_time();780781 let slot =782 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(783 *time,784 slot_duration,785 );786787 let parachain_inherent = parachain_inherent.ok_or_else(|| {788 Box::<dyn std::error::Error + Send + Sync>::from(789 "Failed to create parachain inherent",790 )791 })?;792 Ok((slot, time, parachain_inherent))793 }794 },795 block_import,796 para_client: client,797 backoff_authoring_blocks: Option::<()>::None,798 sync_oracle,799 keystore,800 force_authoring,801 slot_duration,802 // We got around 500ms for proposing803 block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),804 telemetry,805 max_block_proposal_slot_portion: None,806 }))807 },808 hwbench,809 )810 .await811}812813fn dev_build_import_queue<RuntimeApi, ExecutorDispatch>(814 client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,815 _: Arc<FullBackend>,816 config: &Configuration,817 _: Option<TelemetryHandle>,818 task_manager: &TaskManager,819) -> Result<820 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,821 sc_service::Error,822>823where824 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>825 + Send826 + Sync827 + 'static,828 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>829 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,830 ExecutorDispatch: NativeExecutionDispatch + 'static,831{832 Ok(sc_consensus_manual_seal::import_queue(833 Box::new(client.clone()),834 &task_manager.spawn_essential_handle(),835 config.prometheus_registry(),836 ))837}838839/// Builds a new development service. This service uses instant seal, and mocks840/// the parachain inherent841pub fn start_dev_node<Runtime, RuntimeApi, ExecutorDispatch>(842 config: Configuration,843 autoseal_interval: Duration,844) -> sc_service::error::Result<TaskManager>845where846 Runtime: RuntimeInstance + Send + Sync + 'static,847 <Runtime as RuntimeInstance>::CrossAccountId: Serialize,848 for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,849 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>850 + Send851 + Sync852 + 'static,853 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>854 + fp_rpc::EthereumRuntimeRPCApi<Block>855 + fp_rpc::ConvertTransactionRuntimeApi<Block>856 + sp_session::SessionKeys<Block>857 + sp_block_builder::BlockBuilder<Block>858 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>859 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>860 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>861 + app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>862 + rmrk_rpc::RmrkApi<863 Block,864 AccountId,865 RmrkCollectionInfo<AccountId>,866 RmrkInstanceInfo<AccountId>,867 RmrkResourceInfo,868 RmrkPropertyInfo,869 RmrkBaseInfo<AccountId>,870 RmrkPartType,871 RmrkTheme,872 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>873 + sp_api::Metadata<Block>874 + sp_offchain::OffchainWorkerApi<Block>875 + cumulus_primitives_core::CollectCollationInfo<Block>876 + sp_consensus_aura::AuraApi<Block, AuraId>,877 ExecutorDispatch: NativeExecutionDispatch + 'static,878{879 use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams};880 use fc_consensus::FrontierBlockImport;881 use sc_client_api::HeaderBackend;882883 let sc_service::PartialComponents {884 client,885 backend,886 mut task_manager,887 import_queue,888 keystore_container,889 select_chain: maybe_select_chain,890 transaction_pool,891 other:892 (telemetry, filter_pool, frontier_backend, _telemetry_worker_handle, fee_history_cache),893 } = new_partial::<RuntimeApi, ExecutorDispatch, _>(894 &config,895 dev_build_import_queue::<RuntimeApi, ExecutorDispatch>,896 )?;897 let prometheus_registry = config.prometheus_registry().cloned();898899 let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(900 task_manager.spawn_handle(),901 overrides_handle::<_, _, Runtime>(client.clone()),902 50,903 50,904 prometheus_registry.clone(),905 ));906907 let (network, system_rpc_tx, tx_handler_controller, network_starter) =908 sc_service::build_network(sc_service::BuildNetworkParams {909 config: &config,910 client: client.clone(),911 transaction_pool: transaction_pool.clone(),912 spawn_handle: task_manager.spawn_handle(),913 import_queue,914 block_announce_validator_builder: None,915 warp_sync: None,916 })?;917918 if config.offchain_worker.enabled {919 sc_service::build_offchain_workers(920 &config,921 task_manager.spawn_handle(),922 client.clone(),923 network.clone(),924 );925 }926927 let collator = config.role.is_authority();928929 let select_chain = maybe_select_chain.clone();930931 if collator {932 let block_import =933 FrontierBlockImport::new(client.clone(), client.clone(), frontier_backend.clone());934935 let env = sc_basic_authorship::ProposerFactory::new(936 task_manager.spawn_handle(),937 client.clone(),938 transaction_pool.clone(),939 prometheus_registry.as_ref(),940 telemetry.as_ref().map(|x| x.handle()),941 );942943 let transactions_commands_stream: Box<944 dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,945 > = Box::new(946 transaction_pool947 .pool()948 .validated_pool()949 .import_notification_stream()950 .map(|_| EngineCommand::SealNewBlock {951 create_empty: true,952 finalize: false,953 parent_hash: None,954 sender: None,955 }),956 );957958 let autoseal_interval = Box::pin(AutosealInterval::new(&config, autoseal_interval));959 let idle_commands_stream: Box<960 dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,961 > = Box::new(autoseal_interval.map(|_| EngineCommand::SealNewBlock {962 create_empty: true,963 finalize: false,964 parent_hash: None,965 sender: None,966 }));967968 let commands_stream = select(transactions_commands_stream, idle_commands_stream);969970 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;971 let client_set_aside_for_cidp = client.clone();972973 task_manager.spawn_essential_handle().spawn_blocking(974 "authorship_task",975 Some("block-authoring"),976 run_manual_seal(ManualSealParams {977 block_import,978 env,979 client: client.clone(),980 pool: transaction_pool.clone(),981 commands_stream,982 select_chain: select_chain.clone(),983 consensus_data_provider: None,984 create_inherent_data_providers: move |block: Hash, ()| {985 let current_para_block = client_set_aside_for_cidp986 .number(block)987 .expect("Header lookup should succeed")988 .expect("Header passed in as parent should be present in backend.");989990 let client_for_xcm = client_set_aside_for_cidp.clone();991 async move {992 let time = sp_timestamp::InherentDataProvider::from_system_time();993994 let mocked_parachain = cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider {995 current_para_block,996 relay_offset: 1000,997 relay_blocks_per_para_block: 2,998 para_blocks_per_relay_epoch: 0,999 xcm_config: cumulus_primitives_parachain_inherent::MockXcmConfig::new(1000 &*client_for_xcm,1001 block,1002 Default::default(),1003 Default::default(),1004 ),1005 relay_randomness_config: (),1006 raw_downward_messages: vec![],1007 raw_horizontal_messages: vec![],1008 };10091010 let slot =1011 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(1012 *time,1013 slot_duration,1014 );10151016 Ok((time, slot, mocked_parachain))1017 }1018 },1019 }),1020 );1021 }10221023 task_manager.spawn_essential_handle().spawn(1024 "frontier-mapping-sync-worker",1025 Some("block-authoring"),1026 MappingSyncWorker::new(1027 client.import_notification_stream(),1028 Duration::new(6, 0),1029 client.clone(),1030 backend.clone(),1031 frontier_backend.clone(),1032 3,1033 0,1034 SyncStrategy::Normal,1035 )1036 .for_each(|()| futures::future::ready(())),1037 );10381039 let rpc_client = client.clone();1040 let rpc_pool = transaction_pool.clone();1041 let rpc_network = network.clone();1042 let rpc_frontier_backend = frontier_backend.clone();1043 let rpc_builder = Box::new(move |deny_unsafe, subscription_executor| {1044 let full_deps = unique_rpc::FullDeps {1045 backend: rpc_frontier_backend.clone(),1046 deny_unsafe,1047 client: rpc_client.clone(),1048 pool: rpc_pool.clone(),1049 graph: rpc_pool.pool().clone(),1050 // TODO: Unhardcode1051 enable_dev_signer: false,1052 filter_pool: filter_pool.clone(),1053 network: rpc_network.clone(),1054 select_chain: select_chain.clone(),1055 is_authority: collator,1056 // TODO: Unhardcode1057 max_past_logs: 10000,1058 block_data_cache: block_data_cache.clone(),1059 fee_history_cache: fee_history_cache.clone(),1060 // TODO: Unhardcode1061 fee_history_limit: 2048,1062 };10631064 unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(1065 full_deps,1066 subscription_executor,1067 )1068 .map_err(Into::into)1069 });10701071 sc_service::spawn_tasks(sc_service::SpawnTasksParams {1072 network,1073 client,1074 keystore: keystore_container.sync_keystore(),1075 task_manager: &mut task_manager,1076 transaction_pool,1077 rpc_builder,1078 backend,1079 system_rpc_tx,1080 config,1081 telemetry: None,1082 tx_handler_controller,1083 })?;10841085 network_starter.start_network();1086 Ok(task_manager)1087}node/rpc/Cargo.tomldiffbeforeafterboth--- a/node/rpc/Cargo.toml
+++ b/node/rpc/Cargo.toml
@@ -55,6 +55,7 @@
up-rpc = { path = "../../primitives/rpc" }
app-promotion-rpc = { path = "../../primitives/app_promotion_rpc" }
rmrk-rpc = { path = "../../primitives/rmrk-rpc" }
+up-pov-estimate-rpc = { path = "../../primitives/pov-estimate-rpc" }
up-data-structs = { default-features = false, path = "../../primitives/data-structs" }
[dependencies.serde]
@@ -65,3 +66,4 @@
default = []
std = []
unique-runtime = []
+pov-estimate = ['uc-rpc/pov-estimate']
node/rpc/src/lib.rsdiffbeforeafterboth--- a/node/rpc/src/lib.rs
+++ b/node/rpc/src/lib.rs
@@ -40,7 +40,7 @@
use sc_service::TransactionPool;
use std::{collections::BTreeMap, sync::Arc};
-use up_common::types::opaque::{Hash, AccountId, RuntimeInstance, Index, Block, BlockNumber, Balance};
+use up_common::types::opaque::*;
// RMRK
use up_data_structs::{
@@ -48,6 +48,8 @@
RmrkPartType, RmrkTheme,
};
+type FullBackend = sc_service::TFullBackend<Block>;
+
/// Extra dependencies for GRANDPA
pub struct GrandpaDeps<B> {
/// Voting round info.
@@ -82,8 +84,18 @@
pub deny_unsafe: DenyUnsafe,
/// EthFilterApi pool.
pub filter_pool: Option<FilterPool>,
- /// Backend.
- pub backend: Arc<fc_db::Backend<Block>>,
+
+ #[cfg(feature = "pov-estimate")]
+ pub runtime_id: RuntimeId,
+ /// Executor params for PoV estimating
+ #[cfg(feature = "pov-estimate")]
+ pub exec_params: uc_rpc::pov_estimate::ExecutorParams,
+ /// Substrate Backend.
+ #[cfg(feature = "pov-estimate")]
+ pub backend: Arc<FullBackend>,
+
+ /// Ethereum Backend.
+ pub eth_backend: Arc<fc_db::Backend<Block>>,
/// Maximum number of logs in a query.
pub max_past_logs: u32,
/// Maximum fee history cache size.
@@ -162,6 +174,7 @@
RmrkPartType,
RmrkTheme,
>,
+ C::Api: up_pov_estimate_rpc::PovEstimateApi<Block>,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
P: TransactionPool<Block = Block> + 'static,
@@ -182,6 +195,9 @@
#[cfg(not(feature = "unique-runtime"))]
use uc_rpc::{RmrkApiServer, Rmrk};
+ #[cfg(feature = "pov-estimate")]
+ use uc_rpc::pov_estimate::{PovEstimateApiServer, PovEstimate};
+
// use pallet_contracts_rpc::{Contracts, ContractsApi};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};
@@ -200,7 +216,17 @@
network,
deny_unsafe,
filter_pool,
+
+ #[cfg(feature = "pov-estimate")]
+ runtime_id,
+
+ #[cfg(feature = "pov-estimate")]
+ exec_params,
+
+ #[cfg(feature = "pov-estimate")]
backend,
+
+ eth_backend,
max_past_logs,
} = deps;
@@ -226,7 +252,7 @@
network.clone(),
signers,
overrides.clone(),
- backend.clone(),
+ eth_backend.clone(),
is_authority,
block_data_cache.clone(),
fee_history_cache,
@@ -244,11 +270,14 @@
#[cfg(not(feature = "unique-runtime"))]
io.merge(Rmrk::new(client.clone()).into_rpc())?;
+ #[cfg(feature = "pov-estimate")]
+ io.merge(PovEstimate::new(client.clone(), backend, deny_unsafe, exec_params, runtime_id).into_rpc())?;
+
if let Some(filter_pool) = filter_pool {
io.merge(
EthFilter::new(
client.clone(),
- backend,
+ eth_backend,
filter_pool,
500_usize, // max stored filters
max_past_logs,
pallets/common/Cargo.tomldiffbeforeafterboth--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -23,6 +23,7 @@
evm-coder = { default-features = false, path = '../../crates/evm-coder' }
ethereum = { version = "0.14.0", default-features = false }
pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.36" }
+up-pov-estimate-rpc = { default-features = false, path = "../../primitives/pov-estimate-rpc" }
serde = { version = "1.0.130", default-features = false }
scale-info = { version = "2.0.1", default-features = false, features = [
@@ -39,6 +40,7 @@
"fp-evm-mapping/std",
"up-data-structs/std",
"pallet-evm/std",
+ "up-pov-estimate-rpc/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -115,6 +115,7 @@
RmrkNftChild,
CollectionPermissions,
};
+use up_pov_estimate_rpc::PovInfo;
pub use pallet::*;
use sp_core::H160;
@@ -881,6 +882,8 @@
RmrkPartType,
RmrkBoundedTheme,
RmrkNftChild,
+ // PoV Estimate Info
+ PovInfo,
)>,
),
QueryKind = OptionQuery,
primitives/common/src/types.rsdiffbeforeafterboth--- a/primitives/common/src/types.rs
+++ b/primitives/common/src/types.rs
@@ -29,6 +29,14 @@
pub use super::{BlockNumber, Signature, AccountId, Balance, Index, Hash, AuraId};
+ #[derive(Debug, Clone)]
+ pub enum RuntimeId {
+ Unique,
+ Quartz,
+ Opal,
+ Unknown(sp_std::vec::Vec<u8>),
+ }
+
/// Opaque block header type.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
primitives/pov-estimate-rpc/Cargo.tomldiffbeforeafterboth--- /dev/null
+++ b/primitives/pov-estimate-rpc/Cargo.toml
@@ -0,0 +1,28 @@
+[package]
+name = "up-pov-estimate-rpc"
+version = "0.1.0"
+license = "GPLv3"
+edition = "2021"
+
+[dependencies]
+codec = { package = "parity-scale-codec", version = "3.1.2", default-features = false, features = [
+ "derive",
+] }
+serde = { version = "1.0.130", features = ["derive"], default-features = false, optional = true }
+scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
+sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
+sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
+sp-api = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
+sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
+
+[features]
+default = ["std"]
+std = [
+ "codec/std",
+ "serde/std",
+ "scale-info/std",
+ "sp-core/std",
+ "sp-std/std",
+ "sp-api/std",
+ "sp-runtime/std",
+]
primitives/pov-estimate-rpc/src/lib.rsdiffbeforeafterboth--- /dev/null
+++ b/primitives/pov-estimate-rpc/src/lib.rs
@@ -0,0 +1,39 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+#![cfg_attr(not(feature = "std"), no_std)]
+
+use codec::{Decode, Encode, MaxEncodedLen};
+use scale_info::TypeInfo;
+
+#[cfg(feature = "std")]
+use serde::Serialize;
+
+use sp_runtime::ApplyExtrinsicResult;
+
+#[cfg_attr(feature = "std", derive(Serialize))]
+#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
+pub struct PovInfo {
+ pub proof_size: u64,
+ pub compact_proof_size: u64,
+ pub compressed_proof_size: u64,
+}
+
+sp_api::decl_runtime_apis! {
+ pub trait PovEstimateApi {
+ fn pov_estimate(uxt: Block::Extrinsic) -> ApplyExtrinsicResult;
+ }
+}
runtime/common/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -39,7 +39,7 @@
use sp_runtime::{
Permill,
traits::Block as BlockT,
- transaction_validity::{TransactionSource, TransactionValidity},
+ transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError, InvalidTransaction},
ApplyExtrinsicResult, DispatchError,
};
use fp_rpc::TransactionStatus;
@@ -778,6 +778,17 @@
}
}
+ impl up_pov_estimate_rpc::PovEstimateApi<Block> for Runtime {
+ #[allow(unused_variables)]
+ fn pov_estimate(uxt: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
+ #[cfg(feature = "pov-estimate")]
+ return Executive::apply_extrinsic(uxt);
+
+ #[cfg(not(feature = "pov-estimate"))]
+ return Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
+ }
+ }
+
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(checks: bool) -> (frame_support::pallet_prelude::Weight, frame_support::pallet_prelude::Weight) {
runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -127,6 +127,7 @@
'pallet-base-fee/std',
'fp-rpc/std',
'up-rpc/std',
+ 'up-pov-estimate-rpc/std',
'app-promotion-rpc/std',
'fp-evm-mapping/std',
'fp-self-contained/std',
@@ -184,6 +185,7 @@
'pallet-test-utils',
]
become-sapphire = []
+pov-estimate = []
refungible = []
scheduler = []
@@ -468,6 +470,7 @@
derivative = "2.2.0"
pallet-unique = { path = '../../pallets/unique', default-features = false }
up-rpc = { path = "../../primitives/rpc", default-features = false }
+up-pov-estimate-rpc = { path = "../../primitives/pov-estimate-rpc", default-features = false }
app-promotion-rpc = { path = "../../primitives/app_promotion_rpc", default-features = false }
rmrk-rpc = { path = "../../primitives/rmrk-rpc", default-features = false }
fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.36" }
runtime/quartz/Cargo.tomldiffbeforeafterboth--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -122,6 +122,7 @@
'pallet-base-fee/std',
'fp-rpc/std',
'up-rpc/std',
+ 'up-pov-estimate-rpc/std',
'app-promotion-rpc/std',
'fp-evm-mapping/std',
'fp-self-contained/std',
@@ -169,6 +170,7 @@
]
limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
quartz-runtime = ['refungible', 'app-promotion', 'foreign-assets']
+pov-estimate = []
refungible = []
scheduler = []
@@ -461,6 +463,7 @@
derivative = "2.2.0"
pallet-unique = { path = '../../pallets/unique', default-features = false }
up-rpc = { path = "../../primitives/rpc", default-features = false }
+up-pov-estimate-rpc = { path = "../../primitives/pov-estimate-rpc", default-features = false }
app-promotion-rpc = { path = "../../primitives/app_promotion_rpc", default-features = false }
fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.36" }
fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.36" }
runtime/unique/Cargo.tomldiffbeforeafterboth--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -123,6 +123,7 @@
'pallet-base-fee/std',
'fp-rpc/std',
'up-rpc/std',
+ 'up-pov-estimate-rpc/std',
'app-promotion-rpc/std',
'fp-evm-mapping/std',
'fp-self-contained/std',
@@ -170,6 +171,7 @@
]
limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
unique-runtime = ['foreign-assets']
+pov-estimate = []
stubgen = ["evm-coder/stubgen"]
refungible = []
@@ -454,6 +456,7 @@
derivative = "2.2.0"
pallet-unique = { path = '../../pallets/unique', default-features = false }
up-rpc = { path = "../../primitives/rpc", default-features = false }
+up-pov-estimate-rpc = { path = "../../primitives/pov-estimate-rpc", default-features = false }
app-promotion-rpc = { path = "../../primitives/app_promotion_rpc", default-features = false }
rmrk-rpc = { path = "../../primitives/rmrk-rpc", default-features = false }
pallet-inflation = { path = '../../pallets/inflation', default-features = false }