Skip to content

Commit

Permalink
Upgrade to polkadot-sdk v1.11.0 (#2838)
Browse files Browse the repository at this point in the history
* use polkadot-sdk v1.11.0

* update dependencies pinsˆ

* replace V4V3LocationConverter with WithLatestLocationConverter

* replace OverrideHandle with StorageOverrideHandler

* update jsonrpsee version

* fix build precompile collective

* fix missing weights

* Replace V4V3LocationConverter with WithLatestLocationConverter

* update GenesisBuilder implementation

* add missing frame_system::Config members

* add missing XcmExecuterConfig params

* initialize_block now return ExtrinsicsInclusionMode

* fix return type of correct_and_deposit_fee

* Add IdleMaxServiceWeight to process enqueued messages on_idle

* Add Rate limit for orml_xtokens

* fix validation_data getter

* fix return type

* replace OverrideHandle with StorageOverrideHandler

* Replace CallRequest with TransactionRequest

* fix frontier_backend use

* add metrics to BuildNetworkParams

* use NetworkBackend trait

* Fix data update in TransactionRequest

* fix compilation

* update benchmark command run

* Fix runtime-benchmarks compilation

* fix tests compilation

* make rust tests compile

* fix warnings

* fix test compile

* update host functions

* fix zombie tests

* fix rust tests

* fix(test): fix createProposal helper method

* fix(test): referenda tests

* fix some xcm tests

* fix costs in assets-erc20 precompile tests

* fix typescript tests

* fix eth tracing

* fix tracing test

* match input field before data field

---------

Co-authored-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
Co-authored-by: Agusrodri <agusrodriguez2456@gmail.com>
Co-authored-by: Éloïs <c@elo.tf>
  • Loading branch information
4 people authored Jun 25, 2024
1 parent 6945830 commit 223c623
Show file tree
Hide file tree
Showing 85 changed files with 2,639 additions and 1,403 deletions.
2,299 changes: 1,495 additions & 804 deletions Cargo.lock

Large diffs are not rendered by default.

351 changes: 175 additions & 176 deletions Cargo.toml

Large diffs are not rendered by default.

42 changes: 9 additions & 33 deletions client/rpc/debug/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ use tokio::{
};

use ethereum_types::H256;
use fc_rpc::{frontier_backend_client, internal_err, OverrideHandle};
use fc_rpc::{frontier_backend_client, internal_err};
use fc_storage::StorageOverride;
use fp_rpc::EthereumRuntimeRPCApi;
use moonbeam_client_evm_tracing::{formatters::ResponseFormatter, types::single};
use moonbeam_rpc_core_types::{RequestBlockId, RequestBlockTag};
Expand Down Expand Up @@ -178,7 +179,7 @@ where
backend: Arc<BE>,
frontier_backend: Arc<dyn fc_api::Backend<B> + Send + Sync>,
permit_pool: Arc<Semaphore>,
overrides: Arc<OverrideHandle<B>>,
overrides: Arc<dyn StorageOverride<B>>,
raw_max_memory_usage: usize,
) -> (impl Future<Output = ()>, DebugRequester) {
let (tx, mut rx): (DebugRequester, _) =
Expand Down Expand Up @@ -353,7 +354,7 @@ where
frontier_backend: Arc<dyn fc_api::Backend<B> + Send + Sync>,
request_block_id: RequestBlockId,
params: Option<TraceParams>,
overrides: Arc<OverrideHandle<B>>,
overrides: Arc<dyn StorageOverride<B>>,
) -> RpcResult<Response> {
let (tracer_input, trace_type) = Self::handle_params(params)?;

Expand Down Expand Up @@ -397,21 +398,9 @@ where
// Get parent blockid.
let parent_block_hash = *header.parent_hash();

let schema = fc_storage::onchain_storage_schema::<B, C, BE>(client.as_ref(), hash);

// Using storage overrides we align with `:ethereum_schema` which will result in proper
// SCALE decoding in case of migration.
let statuses = match overrides.schemas.get(&schema) {
Some(schema) => schema
.current_transaction_statuses(hash)
.unwrap_or_default(),
_ => {
return Err(internal_err(format!(
"No storage override at {:?}",
reference_id
)))
}
};
let statuses = overrides
.current_transaction_statuses(hash)
.unwrap_or_default();

// Known ethereum transaction hashes.
let eth_tx_hashes: Vec<_> = statuses.iter().map(|t| t.transaction_hash).collect();
Expand Down Expand Up @@ -514,7 +503,7 @@ where
frontier_backend: Arc<dyn fc_api::Backend<B> + Send + Sync>,
transaction_hash: H256,
params: Option<TraceParams>,
overrides: Arc<OverrideHandle<B>>,
overrides: Arc<dyn StorageOverride<B>>,
raw_max_memory_usage: usize,
) -> RpcResult<Response> {
let (tracer_input, trace_type) = Self::handle_params(params)?;
Expand Down Expand Up @@ -573,20 +562,7 @@ where
));
};

let schema =
fc_storage::onchain_storage_schema::<B, C, BE>(client.as_ref(), reference_hash);

// Get the block that contains the requested transaction. Using storage overrides we align
// with `:ethereum_schema` which will result in proper SCALE decoding in case of migration.
let reference_block = match overrides.schemas.get(&schema) {
Some(schema) => schema.current_block(reference_hash),
_ => {
return Err(internal_err(format!(
"No storage override at {:?}",
reference_hash
)))
}
};
let reference_block = overrides.current_block(reference_hash);

// Get the actual ethereum transaction.
if let Some(block) = reference_block {
Expand Down
36 changes: 15 additions & 21 deletions client/rpc/trace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use substrate_prometheus_endpoint::{
};

use ethereum_types::H256;
use fc_rpc::OverrideHandle;
use fc_storage::StorageOverride;
use fp_rpc::EthereumRuntimeRPCApi;

use moonbeam_client_evm_tracing::{
Expand Down Expand Up @@ -442,7 +442,7 @@ where
backend: Arc<BE>,
cache_duration: Duration,
blocking_permits: Arc<Semaphore>,
overrides: Arc<OverrideHandle<B>>,
overrides: Arc<dyn StorageOverride<B>>,
prometheus: Option<PrometheusRegistry>,
) -> (impl Future<Output = ()>, CacheRequester) {
// Communication with the outside world :
Expand Down Expand Up @@ -535,7 +535,7 @@ where
blocking_tx: &mpsc::Sender<BlockingTaskMessage>,
sender: oneshot::Sender<CacheBatchId>,
blocks: Vec<H256>,
overrides: Arc<OverrideHandle<B>>,
overrides: Arc<dyn StorageOverride<B>>,
) {
tracing::trace!("Starting batch {}", self.next_batch_id);
self.batches.insert(self.next_batch_id, blocks.clone());
Expand Down Expand Up @@ -791,7 +791,7 @@ where
client: Arc<C>,
backend: Arc<BE>,
substrate_hash: H256,
overrides: Arc<OverrideHandle<B>>,
overrides: Arc<dyn StorageOverride<B>>,
) -> TxsTraceRes {
// Get Subtrate block data.
let api = client.runtime_api();
Expand All @@ -808,24 +808,18 @@ where
let height = *block_header.number();
let substrate_parent_hash = *block_header.parent_hash();

let schema =
fc_storage::onchain_storage_schema::<B, C, BE>(client.as_ref(), substrate_hash);

// Get Ethereum block data.
let (eth_block, eth_transactions) = match overrides.schemas.get(&schema) {
Some(schema) => match (
schema.current_block(substrate_hash),
schema.current_transaction_statuses(substrate_hash),
) {
(Some(a), Some(b)) => (a, b),
_ => {
return Err(format!(
"Failed to get Ethereum block data for Substrate block {}",
substrate_hash
))
}
},
_ => return Err(format!("No storage override at {:?}", substrate_hash)),
let (eth_block, eth_transactions) = match (
overrides.current_block(substrate_hash),
overrides.current_transaction_statuses(substrate_hash),
) {
(Some(a), Some(b)) => (a, b),
_ => {
return Err(format!(
"Failed to get Ethereum block data for Substrate block {}",
substrate_hash
))
}
};

let eth_block_hash = eth_block.header.hash();
Expand Down
19 changes: 7 additions & 12 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sc-chain-spec = { workspace = true }
sc-cli = { workspace = true }
sc-client-api = { workspace = true }
sc-consensus-grandpa = { workspace = true }
sc-network = { workspace = true }
sc-service = { workspace = true }
sc-sysinfo = { workspace = true }
sc-telemetry = { workspace = true }
Expand All @@ -29,7 +30,6 @@ sp-io = { workspace = true }
sp-runtime = { workspace = true, features = ["std"] }
sp-wasm-interface = { workspace = true }
substrate-prometheus-endpoint = { workspace = true }
try-runtime-cli = { workspace = true, optional = true }

# Cumulus / Nimbus
cumulus-client-cli = { workspace = true }
Expand All @@ -48,10 +48,10 @@ substrate-build-script-utils = { workspace = true }

[features]
default = [
"moonbase-native",
"moonbeam-native",
"moonriver-native",
"westend-native",
"moonbase-native",
"moonbeam-native",
"moonriver-native",
"westend-native",
]

westend-native = ["polkadot-service/westend-native"]
Expand All @@ -61,13 +61,8 @@ moonbeam-native = ["moonbeam-service/moonbeam-native"]
moonriver-native = ["moonbeam-service/moonriver-native"]

runtime-benchmarks = [
"moonbeam-service/runtime-benchmarks",
"polkadot-service/runtime-benchmarks",
]
try-runtime = [
"moonbeam-service/try-runtime",
"try-runtime-cli/try-runtime",
"polkadot-service/try-runtime",
"moonbeam-service/runtime-benchmarks",
"polkadot-service/runtime-benchmarks",
]

moonbase-runtime-benchmarks = ["moonbeam-service/moonbase-runtime-benchmarks"]
30 changes: 19 additions & 11 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::BenchmarkCmd;
use log::{info, warn};
use moonbeam_cli_opt::EthApi;
use moonbeam_service::{chain_spec, frontier_database_dir, IdentifyVariant};
use moonbeam_service::{
chain_spec, frontier_database_dir, moonbase_runtime, moonbeam_runtime, moonriver_runtime,
HostFunctions, IdentifyVariant,
};
use parity_scale_codec::Encode;
#[cfg(feature = "westend-native")]
use polkadot_service::WestendChainSpec;
Expand All @@ -36,7 +39,9 @@ use sc_service::{
};
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::{
traits::{AccountIdConversion, Block as BlockT, Hash as HashT, Header as HeaderT, Zero},
traits::{
AccountIdConversion, Block as BlockT, Hash as HashT, HashingFor, Header as HeaderT, Zero,
},
StateVersion,
};
use std::{io::Write, net::SocketAddr};
Expand Down Expand Up @@ -487,24 +492,24 @@ pub fn run() -> Result<()> {
#[cfg(feature = "moonriver-native")]
spec if spec.is_moonriver() => {
return runner.sync_run(|config| {
cmd.run::<moonbeam_service::moonriver_runtime::Block, moonbeam_service::HostFunctions>(
config,
cmd.run_with_spec::<HashingFor<moonriver_runtime::Block>, HostFunctions>(
Some(config.chain_spec),
)
})
}
#[cfg(feature = "moonbeam-native")]
spec if spec.is_moonbeam() => {
return runner.sync_run(|config| {
cmd.run::<moonbeam_service::moonbeam_runtime::Block, moonbeam_service::HostFunctions>(
config,
cmd.run_with_spec::<HashingFor<moonbeam_runtime::Block>, HostFunctions>(
Some(config.chain_spec),
)
})
}
#[cfg(feature = "moonbase-native")]
_ => {
return runner.sync_run(|config| {
cmd.run::<moonbeam_service::moonbase_runtime::Block, moonbeam_service::HostFunctions>(
config,
cmd.run_with_spec::<HashingFor<moonbase_runtime::Block>, HostFunctions>(
Some(config.chain_spec),
)
})
}
Expand All @@ -513,8 +518,8 @@ pub fn run() -> Result<()> {
}
} else if cfg!(feature = "moonbase-runtime-benchmarks") {
return runner.sync_run(|config| {
cmd.run::<moonbeam_service::moonbase_runtime::Block, moonbeam_service::HostFunctions>(
config,
cmd.run_with_spec::<HashingFor<moonbeam_service::moonbase_runtime::Block>, HostFunctions>(
Some(config.chain_spec),
)
});
} else {
Expand Down Expand Up @@ -728,20 +733,23 @@ pub fn run() -> Result<()> {
spec if spec.is_moonriver() => moonbeam_service::new_dev::<
moonbeam_service::moonriver_runtime::RuntimeApi,
moonbeam_service::MoonriverCustomizations,
sc_network::NetworkWorker<_, _>,
>(config, author_id, cli.run.sealing, rpc_config, hwbench)
.await
.map_err(Into::into),
#[cfg(feature = "moonbeam-native")]
spec if spec.is_moonbeam() => moonbeam_service::new_dev::<
moonbeam_service::moonbeam_runtime::RuntimeApi,
moonbeam_service::MoonbeamCustomizations,
sc_network::NetworkWorker<_, _>,
>(config, author_id, cli.run.sealing, rpc_config, hwbench)
.await
.map_err(Into::into),
#[cfg(feature = "moonbase-native")]
_ => moonbeam_service::new_dev::<
moonbeam_service::moonbase_runtime::RuntimeApi,
moonbeam_service::MoonbaseCustomizations,
sc_network::NetworkWorker<_, _>,
>(config, author_id, cli.run.sealing, rpc_config, hwbench)
.await
.map_err(Into::into),
Expand All @@ -758,7 +766,7 @@ pub fn run() -> Result<()> {
);

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

let tokio_handle = config.tokio_handle.clone();
let polkadot_config =
Expand Down
Loading

0 comments on commit 223c623

Please sign in to comment.