Skip to content

Commit

Permalink
Upgrade to polkadot stable2409 (#3031)
Browse files Browse the repository at this point in the history
  • Loading branch information
TarekkMA authored Dec 20, 2024
1 parent 823fc90 commit 7dbae97
Show file tree
Hide file tree
Showing 77 changed files with 1,027 additions and 923 deletions.
1,194 changes: 589 additions & 605 deletions Cargo.lock

Large diffs are not rendered by default.

360 changes: 180 additions & 180 deletions Cargo.toml

Large diffs are not rendered by default.

25 changes: 11 additions & 14 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use crate::cli::{Cli, RelayChainCli, RunCmd, Subcommand};
use cumulus_client_cli::extract_genesis_wasm;
use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::BenchmarkCmd;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use log::{info, warn};
use moonbeam_cli_opt::EthApi;

Expand All @@ -36,7 +36,7 @@ use parity_scale_codec::Encode;
use polkadot_service::WestendChainSpec;
use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
NetworkParams, Result, RpcEndpoint, RuntimeVersion, SharedParams, SubstrateCli,
};
use sc_service::{
config::{BasePath, PrometheusConfig},
Expand All @@ -49,7 +49,7 @@ use sp_runtime::{
},
StateVersion,
};
use std::{io::Write, net::SocketAddr};
use std::io::Write;

fn load_spec(
id: &str,
Expand Down Expand Up @@ -768,7 +768,10 @@ pub fn run() -> Result<()> {
let hwbench = if !cli.run.no_hardware_benchmarks {
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,
)
})
} else {
None
Expand Down Expand Up @@ -898,7 +901,7 @@ pub fn run() -> Result<()> {
let id = ParaId::from(cli.run.parachain_id.clone().or(para_id).unwrap_or(1000));

let parachain_account =
AccountIdConversion::<polkadot_primitives::v7::AccountId>::into_account_truncating(&id);
AccountIdConversion::<polkadot_primitives::v8::AccountId>::into_account_truncating(&id);

let tokio_handle = config.tokio_handle.clone();
let polkadot_config =
Expand Down Expand Up @@ -1024,7 +1027,7 @@ impl CliConfiguration<Self> for RelayChainCli {
.or_else(|| Some(self.base_path.clone().into())))
}

fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<Vec<RpcEndpoint>>> {
self.base.base.rpc_addr(default_listen_port)
}

Expand All @@ -1038,15 +1041,9 @@ impl CliConfiguration<Self> for RelayChainCli {
.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");
}
Expand Down
22 changes: 12 additions & 10 deletions node/service/src/lazy_loading/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ where
ClientConfig {
offchain_worker_enabled: config.offchain_worker.enabled,
offchain_indexing_api: config.offchain_worker.indexing_enabled,
wasmtime_precompiled: config.wasmtime_precompiled.clone(),
wasmtime_precompiled: config.executor.wasmtime_precompiled.clone(),
wasm_runtime_overrides: config.wasm_runtime_overrides.clone(),
no_genesis: matches!(
config.network.sync_mode,
Expand Down Expand Up @@ -232,7 +232,7 @@ where
set_prometheus_registry(config, rpc_config.no_prometheus_prefix)?;

// Use ethereum style for subscription ids
config.rpc_id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));
config.rpc.id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));

let telemetry = config
.telemetry_endpoints
Expand All @@ -246,19 +246,20 @@ where
.transpose()?;

let heap_pages = config
.executor
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static {
extra_pages: h as _,
});
let mut wasm_builder = WasmExecutor::builder()
.with_execution_method(config.wasm_method)
.with_execution_method(config.executor.wasm_method)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.with_ignore_onchain_heap_pages(true)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size);
.with_max_runtime_instances(config.executor.max_runtime_instances)
.with_runtime_cache_size(config.executor.runtime_cache_size);

if let Some(ref wasmtime_precompiled_path) = config.wasmtime_precompiled {
if let Some(ref wasmtime_precompiled_path) = config.executor.wasmtime_precompiled {
wasm_builder = wasm_builder.with_wasmtime_precompiled_path(wasmtime_precompiled_path);
}

Expand Down Expand Up @@ -444,7 +445,9 @@ where
));
};

let net_config = FullNetworkConfiguration::<_, _, Net>::new(&config.network);
let prometheus_registry = config.prometheus_registry().cloned();
let net_config =
FullNetworkConfiguration::<_, _, Net>::new(&config.network, prometheus_registry.clone());

let metrics = Net::register_notification_metrics(
config.prometheus_config.as_ref().map(|cfg| &cfg.registry),
Expand All @@ -458,7 +461,7 @@ where
spawn_handle: task_manager.spawn_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync_params: None,
warp_sync_config: None,
net_config,
block_relay: None,
metrics,
Expand Down Expand Up @@ -754,12 +757,11 @@ where

let keystore = keystore_container.keystore();
let command_sink_for_task = command_sink.clone();
move |deny_unsafe, subscription_task_executor| {
move |subscription_task_executor| {
let deps = rpc::FullDeps {
backend: backend.clone(),
client: client.clone(),
command_sink: command_sink_for_task.clone(),
deny_unsafe,
ethapi_cmd: ethapi_cmd.clone(),
filter_pool: filter_pool.clone(),
frontier_backend: match *frontier_backend {
Expand Down
73 changes: 37 additions & 36 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ where
set_prometheus_registry(config, rpc_config.no_prometheus_prefix)?;

// Use ethereum style for subscription ids
config.rpc_id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));
config.rpc.id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));

let telemetry = config
.telemetry_endpoints
Expand All @@ -489,19 +489,20 @@ where
.transpose()?;

let heap_pages = config
.executor
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static {
extra_pages: h as _,
});
let mut wasm_builder = WasmExecutor::builder()
.with_execution_method(config.wasm_method)
.with_execution_method(config.executor.wasm_method)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.with_ignore_onchain_heap_pages(true)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size);
.with_max_runtime_instances(config.executor.max_runtime_instances)
.with_runtime_cache_size(config.executor.runtime_cache_size);

if let Some(ref wasmtime_precompiled_path) = config.wasmtime_precompiled {
if let Some(ref wasmtime_precompiled_path) = config.executor.wasmtime_precompiled {
wasm_builder = wasm_builder.with_wasmtime_precompiled_path(wasmtime_precompiled_path);
}

Expand Down Expand Up @@ -698,7 +699,10 @@ where
let prometheus_registry = parachain_config.prometheus_registry().cloned();
let transaction_pool = params.transaction_pool.clone();
let import_queue_service = params.import_queue.service();
let net_config = FullNetworkConfiguration::<_, _, Net>::new(&parachain_config.network);
let net_config = FullNetworkConfiguration::<_, _, Net>::new(
&parachain_config.network,
prometheus_registry.clone(),
);

let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
cumulus_client_service::build_network(cumulus_client_service::BuildNetworkParams {
Expand Down Expand Up @@ -791,7 +795,7 @@ where
let pubsub_notification_sinks = pubsub_notification_sinks.clone();

let keystore = params.keystore_container.keystore();
move |deny_unsafe, subscription_task_executor| {
move |subscription_task_executor| {
#[cfg(feature = "moonbase-native")]
let forced_parent_hashes = {
let mut forced_parent_hashes = BTreeMap::new();
Expand All @@ -816,7 +820,6 @@ where
backend: backend.clone(),
client: client.clone(),
command_sink: None,
deny_unsafe,
ethapi_cmd: ethapi_cmd.clone(),
filter_pool: filter_pool.clone(),
frontier_backend: match &*frontier_backend {
Expand Down Expand Up @@ -1218,7 +1221,9 @@ where
));
};

let net_config = FullNetworkConfiguration::<_, _, Net>::new(&config.network);
let prometheus_registry = config.prometheus_registry().cloned();
let net_config =
FullNetworkConfiguration::<_, _, Net>::new(&config.network, prometheus_registry.clone());

let metrics = Net::register_notification_metrics(
config.prometheus_config.as_ref().map(|cfg| &cfg.registry),
Expand All @@ -1232,7 +1237,7 @@ where
spawn_handle: task_manager.spawn_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync_params: None,
warp_sync_config: None,
net_config,
block_relay: None,
metrics,
Expand Down Expand Up @@ -1532,12 +1537,11 @@ where
let pubsub_notification_sinks = pubsub_notification_sinks.clone();

let keystore = keystore_container.keystore();
move |deny_unsafe, subscription_task_executor| {
move |subscription_task_executor| {
let deps = rpc::FullDeps {
backend: backend.clone(),
client: client.clone(),
command_sink: command_sink.clone(),
deny_unsafe,
ethapi_cmd: ethapi_cmd.clone(),
filter_pool: filter_pool.clone(),
frontier_backend: match &*frontier_backend {
Expand Down Expand Up @@ -1623,10 +1627,13 @@ where

#[cfg(test)]
mod tests {
use crate::chain_spec::moonbase::{testnet_genesis, ChainSpec};
use crate::chain_spec::Extensions;
use jsonrpsee::server::BatchRequestConfig;
use moonbase_runtime::{currency::UNIT, AccountId};
use prometheus::{proto::LabelPair, Counter};
use sc_network::config::NetworkConfiguration;
use sc_service::config::RpcConfiguration;
use sc_service::ChainType;
use sc_service::{
config::{BasePath, DatabaseSource, KeystoreConfig},
Expand All @@ -1635,9 +1642,6 @@ mod tests {
use std::path::Path;
use std::str::FromStr;

use crate::chain_spec::moonbase::{testnet_genesis, ChainSpec};
use crate::chain_spec::Extensions;

use super::*;

#[test]
Expand Down Expand Up @@ -1768,7 +1772,7 @@ mod tests {
)
.unwrap(),
);
let mut client = TestClientBuilder::with_backend(backend).build();
let client = TestClientBuilder::with_backend(backend).build();

client
.execution_extensions()
Expand Down Expand Up @@ -1842,38 +1846,35 @@ mod tests {
state_pruning: Default::default(),
blocks_pruning: sc_service::BlocksPruning::KeepAll,
chain_spec: Box::new(spec),
wasm_method: Default::default(),
executor: Default::default(),
wasm_runtime_overrides: Default::default(),
rpc_id_provider: None,
rpc_max_connections: Default::default(),
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_request_size: Default::default(),
rpc_max_response_size: Default::default(),
rpc_max_subs_per_conn: Default::default(),
rpc_addr: None,
rpc_port: Default::default(),
rpc_message_buffer_capacity: Default::default(),
rpc: RpcConfiguration {
addr: None,
max_connections: Default::default(),
cors: None,
methods: Default::default(),
max_request_size: Default::default(),
max_response_size: Default::default(),
id_provider: None,
max_subs_per_conn: Default::default(),
port: Default::default(),
message_buffer_capacity: Default::default(),
batch_config: BatchRequestConfig::Unlimited,
rate_limit: Default::default(),
rate_limit_whitelisted_ips: vec![],
rate_limit_trust_proxy_headers: false,
},
data_path: Default::default(),
prometheus_config: None,
telemetry_endpoints: None,
default_heap_pages: None,
offchain_worker: Default::default(),
force_authoring: false,
disable_grandpa: false,
dev_key_seed: None,
tracing_targets: None,
tracing_receiver: Default::default(),
max_runtime_instances: 8,
announce_block: true,
base_path: BasePath::new(Path::new("")),
informant_output_format: Default::default(),
wasmtime_precompiled: None,
runtime_cache_size: 2,
rpc_rate_limit: Default::default(),
rpc_rate_limit_whitelisted_ips: vec![],
rpc_batch_config: BatchRequestConfig::Unlimited,
rpc_rate_limit_trust_proxy_headers: false,
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions node/service/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ use sc_consensus_manual_seal::rpc::{EngineCommand, ManualSeal, ManualSealApiServ
use sc_network::service::traits::NetworkService;
use sc_network_sync::SyncingService;
use sc_rpc::SubscriptionTaskExecutor;
use sc_rpc_api::DenyUnsafe;
use sc_service::TaskManager;
use sc_transaction_pool::{ChainApi, Pool};
use sc_transaction_pool_api::TransactionPool;
Expand Down Expand Up @@ -105,8 +104,6 @@ pub struct FullDeps<C, P, A: ChainApi, BE> {
pub pool: Arc<P>,
/// Graph pool instance.
pub graph: Arc<Pool<A>>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
/// The Node authority flag
pub is_authority: bool,
/// Network service
Expand Down Expand Up @@ -190,7 +187,6 @@ where
client,
pool,
graph,
deny_unsafe,
is_authority,
network,
sync,
Expand All @@ -208,7 +204,7 @@ where
forced_parent_hashes,
} = deps;

io.merge(System::new(Arc::clone(&client), Arc::clone(&pool), deny_unsafe).into_rpc())?;
io.merge(System::new(Arc::clone(&client), Arc::clone(&pool)).into_rpc())?;
io.merge(TransactionPayment::new(Arc::clone(&client)).into_rpc())?;

// TODO: are we supporting signing?
Expand Down
5 changes: 4 additions & 1 deletion pallets/erc20-xcm-bridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ use crate as erc20_xcm_bridge;

use frame_support::traits::Everything;
use frame_support::{construct_runtime, pallet_prelude::*, parameter_types};
use pallet_evm::{AddressMapping, EnsureAddressTruncated, SubstrateBlockHashMapping};
use pallet_evm::{
AddressMapping, EnsureAddressTruncated, FrameSystemAccountProvider, SubstrateBlockHashMapping,
};
use sp_core::{H160, H256, U256};
use sp_runtime::traits::{BlakeTwo256, IdentityLookup};
use sp_runtime::AccountId32;
Expand Down Expand Up @@ -155,6 +157,7 @@ impl pallet_evm::Config for Test {
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Test>;
type AccountProvider = FrameSystemAccountProvider<Test>;
}

parameter_types! {
Expand Down
Loading

0 comments on commit 7dbae97

Please sign in to comment.