mirror of
https://github.com/pezkuwichain/pezkuwi-runtime-templates.git
synced 2026-04-25 16:47:54 +00:00
Upgrade evm-template to stable2412 (#407)
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use cumulus_client_service::storage_proof_size::HostFunctions as ReclaimHostFunctions;
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use evm_runtime_template::Block;
|
||||
@@ -7,7 +5,7 @@ use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
|
||||
use log::info;
|
||||
use sc_cli::{
|
||||
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
|
||||
NetworkParams, Result, SharedParams, SubstrateCli,
|
||||
NetworkParams, Result, RpcEndpoint, SharedParams, SubstrateCli,
|
||||
};
|
||||
use sc_service::config::{BasePath, PrometheusConfig};
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
@@ -231,7 +229,7 @@ pub fn run() -> Result<()> {
|
||||
let hwbench = (!cli.no_hardware_benchmarks)
|
||||
.then_some(config.database.path().map(|database_path| {
|
||||
let _ = std::fs::create_dir_all(database_path);
|
||||
sc_sysinfo::gather_hwbench(Some(database_path))
|
||||
sc_sysinfo::gather_hwbench(Some(database_path), &SUBSTRATE_REFERENCE_HARDWARE)
|
||||
}))
|
||||
.flatten();
|
||||
|
||||
@@ -310,7 +308,7 @@ impl CliConfiguration<Self> for RelayChainCli {
|
||||
Ok(self.shared_params().base_path()?.or_else(|| self.base_path.clone().map(Into::into)))
|
||||
}
|
||||
|
||||
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
|
||||
fn rpc_addr(&self, default_listen_port: u16) -> sc_cli::Result<Option<Vec<RpcEndpoint>>> {
|
||||
self.base.base.rpc_addr(default_listen_port)
|
||||
}
|
||||
|
||||
@@ -322,15 +320,9 @@ impl CliConfiguration<Self> for RelayChainCli {
|
||||
self.base.base.prometheus_config(default_listen_port, chain_spec)
|
||||
}
|
||||
|
||||
fn init<F>(
|
||||
&self,
|
||||
_support_url: &String,
|
||||
_impl_version: &String,
|
||||
_logger_hook: F,
|
||||
_config: &sc_service::Configuration,
|
||||
) -> Result<()>
|
||||
fn init<F>(&self, _support_url: &String, _impl_version: &String, _logger_hook: F) -> Result<()>
|
||||
where
|
||||
F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration),
|
||||
F: FnOnce(&mut sc_cli::LoggerBuilder),
|
||||
{
|
||||
unreachable!("PolkadotCli is never initialized; qed");
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ use std::sync::Arc;
|
||||
|
||||
use evm_runtime_template::{opaque::Block, AccountId, Balance, Nonce};
|
||||
use sc_client_api::{backend::Backend, AuxStore, BlockchainEvents, StorageProvider, UsageProvider};
|
||||
pub use sc_rpc::DenyUnsafe;
|
||||
use sc_rpc::SubscriptionTaskExecutor;
|
||||
use sc_transaction_pool::ChainApi;
|
||||
use sc_transaction_pool_api::TransactionPool;
|
||||
@@ -32,8 +31,6 @@ pub struct FullDeps<C, P, A: ChainApi, CT, CIDP> {
|
||||
pub client: Arc<C>,
|
||||
/// Transaction pool instance.
|
||||
pub pool: Arc<P>,
|
||||
/// Whether to deny unsafe calls
|
||||
pub deny_unsafe: DenyUnsafe,
|
||||
/// Ethereum-compatibility specific dependencies.
|
||||
pub eth: EthDeps<Block, C, P, A, CT, CIDP>,
|
||||
}
|
||||
@@ -88,9 +85,9 @@ where
|
||||
use substrate_frame_rpc_system::{System, SystemApiServer};
|
||||
|
||||
let mut module = RpcExtension::new(());
|
||||
let FullDeps { client, pool, deny_unsafe, eth } = deps;
|
||||
let FullDeps { client, pool, eth } = deps;
|
||||
|
||||
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
|
||||
module.merge(System::new(client.clone(), pool).into_rpc())?;
|
||||
module.merge(TransactionPayment::new(client).into_rpc())?;
|
||||
let module = create_eth::<_, _, _, _, _, _, _, DefaultEthConfig<C, BE>>(
|
||||
module,
|
||||
|
||||
@@ -31,14 +31,13 @@ use evm_runtime_template::{configs::TransactionConverter, opaque::Block, Runtime
|
||||
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
|
||||
use sc_client_api::Backend;
|
||||
use sc_consensus::ImportQueue;
|
||||
use sc_executor::WasmExecutor;
|
||||
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
|
||||
use sc_network::{config::FullNetworkConfiguration, NetworkBlock};
|
||||
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
use sc_telemetry::TelemetryHandle;
|
||||
use sc_telemetry::{Telemetry, TelemetryWorker, TelemetryWorkerHandle};
|
||||
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||
use sp_core::H256;
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
use sp_core::U256;
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
@@ -76,7 +75,7 @@ pub type Service = PartialComponents<
|
||||
ParachainBackend,
|
||||
(),
|
||||
sc_consensus::DefaultImportQueue<Block>,
|
||||
sc_transaction_pool::FullPool<Block, ParachainClient>,
|
||||
sc_transaction_pool::TransactionPoolHandle<Block, ParachainClient>,
|
||||
(
|
||||
ParachainBlockImport,
|
||||
Option<Telemetry>,
|
||||
@@ -105,7 +104,18 @@ pub fn new_partial(
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
let executor = sc_service::new_wasm_executor(config);
|
||||
let heap_pages = config
|
||||
.executor
|
||||
.default_heap_pages
|
||||
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });
|
||||
|
||||
let executor = ParachainExecutor::builder()
|
||||
.with_execution_method(config.executor.wasm_method)
|
||||
.with_onchain_heap_alloc_strategy(heap_pages)
|
||||
.with_offchain_heap_alloc_strategy(heap_pages)
|
||||
.with_max_runtime_instances(config.executor.max_runtime_instances)
|
||||
.with_runtime_cache_size(config.executor.runtime_cache_size)
|
||||
.build();
|
||||
|
||||
let (client, backend, keystore_container, task_manager) =
|
||||
sc_service::new_full_parts_record_import::<Block, RuntimeApi, _>(
|
||||
@@ -123,12 +133,15 @@ pub fn new_partial(
|
||||
telemetry
|
||||
});
|
||||
|
||||
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
|
||||
config.transaction_pool.clone(),
|
||||
config.role.is_authority().into(),
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_essential_handle(),
|
||||
client.clone(),
|
||||
let transaction_pool = Arc::from(
|
||||
sc_transaction_pool::Builder::new(
|
||||
task_manager.spawn_essential_handle(),
|
||||
client.clone(),
|
||||
config.role.is_authority().into(),
|
||||
)
|
||||
.with_options(config.transaction_pool.clone())
|
||||
.with_prometheus(config.prometheus_registry())
|
||||
.build(),
|
||||
);
|
||||
|
||||
#[cfg(feature = "tanssi")]
|
||||
@@ -252,8 +265,10 @@ async fn start_node_impl(
|
||||
let (_, mut telemetry, telemetry_worker_handle, frontier_backend, overrides) = params.other;
|
||||
|
||||
let frontier_backend = Arc::new(frontier_backend);
|
||||
let net_config: FullNetworkConfiguration<Block, H256, sc_network::NetworkWorker<_, _>> =
|
||||
sc_network::config::FullNetworkConfiguration::new(¶chain_config.network);
|
||||
let net_config = FullNetworkConfiguration::<_, _, sc_network::NetworkWorker<Block, Hash>>::new(
|
||||
¶chain_config.network,
|
||||
parachain_config.prometheus_config.as_ref().map(|cfg| cfg.registry.clone()),
|
||||
);
|
||||
|
||||
let client = params.client.clone();
|
||||
let backend = params.backend.clone();
|
||||
@@ -313,7 +328,7 @@ async fn start_node_impl(
|
||||
is_validator: parachain_config.role.is_authority(),
|
||||
enable_http_requests: false,
|
||||
custom_extensions: move |_| vec![],
|
||||
})
|
||||
})?
|
||||
.run(client.clone(), task_manager.spawn_handle())
|
||||
.boxed(),
|
||||
);
|
||||
@@ -326,7 +341,7 @@ async fn start_node_impl(
|
||||
|
||||
let rpc_builder = {
|
||||
let client = client.clone();
|
||||
let transaction_pool = transaction_pool.clone();
|
||||
let pool = transaction_pool.clone();
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
let target_gas_price = eth_config.target_gas_price;
|
||||
let enable_dev_signer = eth_config.enable_dev_signer;
|
||||
@@ -358,12 +373,18 @@ async fn start_node_impl(
|
||||
let overrides = overrides.clone();
|
||||
let fee_history_cache = fee_history_cache.clone();
|
||||
let pubsub_notification_sinks = pubsub_notification_sinks.clone();
|
||||
|
||||
Box::new(move |deny_unsafe, subscription_task_executor| {
|
||||
let graph_api = Arc::new(sc_transaction_pool::FullChainApi::new(
|
||||
client.clone(),
|
||||
None,
|
||||
&task_manager.spawn_essential_handle(),
|
||||
));
|
||||
let graph =
|
||||
Arc::new(sc_transaction_pool::Pool::new(Default::default(), true.into(), graph_api));
|
||||
Box::new(move |subscription_task_executor| {
|
||||
let eth = crate::rpc::EthDeps {
|
||||
client: client.clone(),
|
||||
pool: transaction_pool.clone(),
|
||||
graph: transaction_pool.pool().clone(),
|
||||
pool: pool.clone(),
|
||||
graph: graph.clone(),
|
||||
converter: Some(TransactionConverter),
|
||||
is_authority: validator,
|
||||
enable_dev_signer,
|
||||
@@ -384,12 +405,7 @@ async fn start_node_impl(
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
pending_create_inherent_data_providers,
|
||||
};
|
||||
let deps = crate::rpc::FullDeps {
|
||||
client: client.clone(),
|
||||
pool: transaction_pool.clone(),
|
||||
deny_unsafe,
|
||||
eth,
|
||||
};
|
||||
let deps = crate::rpc::FullDeps { client: client.clone(), pool: pool.clone(), eth };
|
||||
|
||||
crate::rpc::create_full(
|
||||
deps,
|
||||
@@ -421,7 +437,7 @@ async fn start_node_impl(
|
||||
// Putting a link in there and swapping out the requirements for your
|
||||
// own are probably a good idea. The requirements for a para-chain are
|
||||
// dictated by its relay-chain.
|
||||
match SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) {
|
||||
match SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench, false) {
|
||||
Err(err) if validator => {
|
||||
log::warn!(
|
||||
"⚠️ The hardware does not meet the minimal requirements {} for role \
|
||||
@@ -547,7 +563,7 @@ fn start_consensus(
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
task_manager: &TaskManager,
|
||||
relay_chain_interface: Arc<dyn RelayChainInterface>,
|
||||
transaction_pool: Arc<sc_transaction_pool::FullPool<Block, ParachainClient>>,
|
||||
transaction_pool: Arc<sc_transaction_pool::TransactionPoolHandle<Block, ParachainClient>>,
|
||||
keystore: KeystorePtr,
|
||||
relay_chain_slot_duration: Duration,
|
||||
para_id: ParaId,
|
||||
|
||||
@@ -86,7 +86,7 @@ where
|
||||
let mut module = RpcExtension::new(());
|
||||
let FullDeps { client, pool, deny_unsafe, eth } = deps;
|
||||
|
||||
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
|
||||
module.merge(System::new(client.clone(), pool).into_rpc())?;
|
||||
module.merge(TransactionPayment::new(client).into_rpc())?;
|
||||
let module = create_eth::<_, _, _, _, _, _, DefaultEthConfig<C, BE>>(
|
||||
module,
|
||||
|
||||
Reference in New Issue
Block a user