Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: polkadot-0.9.43 #541

Merged
merged 16 commits into from
Jul 31, 2023
2,389 changes: 1,278 additions & 1,111 deletions Cargo.lock

Large diffs are not rendered by default.

204 changes: 102 additions & 102 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion nodes/parachain/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl RelayChainCli {
) -> Self {
let extension = crate::chain_spec::Extensions::try_get(&*para_config.chain_spec);
let chain_id = extension.map(|e| e.relay_chain.clone());
let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot"));
let base_path = Some(para_config.base_path.path().join("polkadot"));
Self {
base_path,
chain_id,
Expand Down
22 changes: 5 additions & 17 deletions nodes/parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,10 @@ impl DefaultConfigurationValues for RelayChainCli {
30334
}

fn rpc_ws_listen_port() -> u16 {
fn rpc_listen_port() -> u16 {
9945
}

fn rpc_http_listen_port() -> u16 {
9934
}

fn prometheus_listen_port() -> u16 {
9616
}
Expand Down Expand Up @@ -502,16 +498,8 @@ impl CliConfiguration<Self> for RelayChainCli {
.or_else(|| self.base_path.clone().map(Into::into)))
}

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

fn rpc_ipc(&self) -> Result<Option<String>> {
self.base.base.rpc_ipc()
}

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

fn prometheus_config(
Expand Down Expand Up @@ -561,8 +549,8 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.rpc_methods()
}

fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {
self.base.base.rpc_ws_max_connections()
fn rpc_max_connections(&self) -> Result<u32> {
self.base.base.rpc_max_connections()
}

fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {
Expand Down
2 changes: 2 additions & 0 deletions nodes/parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,14 @@ 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 = sc_network::config::FullNetworkConfiguration::new(&parachain_config.network);
let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
cumulus_client_service::build_network(cumulus_client_service::BuildNetworkParams {
parachain_config: &parachain_config,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
para_id: id,
net_config,
spawn_handle: task_manager.spawn_handle(),
relay_chain_interface: relay_chain_interface.clone(),
import_queue: params.import_queue,
Expand Down
1 change: 1 addition & 0 deletions nodes/standalone/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ sc-executor = {workspace = true}
sc-consensus-grandpa.workspace = true
sc-keystore.workspace = true
sc-service = {workspace = true}
weichweich marked this conversation as resolved.
Show resolved Hide resolved
sc-network.workspace = true
sc-telemetry.workspace = true
sc-transaction-pool.workspace = true
sc-transaction-pool-api.workspace = true
Expand Down
15 changes: 8 additions & 7 deletions nodes/standalone/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub fn new_partial(config: &Configuration) -> Result<PartialComponents, ServiceE
}

/// Builds a new service for a full client.
pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError> {
pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
let sc_service::PartialComponents {
client,
backend,
Expand All @@ -159,12 +159,12 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
&config.chain_spec,
);

config
.network
.extra_sets
.push(sc_consensus_grandpa::grandpa_peers_set_config(
grandpa_protocol_name.clone(),
));
let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);

net_config.add_notification_protocol(sc_consensus_grandpa::grandpa_peers_set_config(
grandpa_protocol_name.clone(),
));

let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
grandpa_link.shared_authority_set().clone(),
Expand All @@ -175,6 +175,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
client: client.clone(),
net_config,
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
block_announce_validator_builder: None,
Expand Down
2 changes: 1 addition & 1 deletion pallets/attestation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub mod pallet {
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[cfg(feature = "try-runtime")]
fn try_state(_n: BlockNumberFor<T>) -> Result<(), &'static str> {
fn try_state(_n: BlockNumberFor<T>) -> Result<(), sp_runtime::TryRuntimeError> {
crate::try_state::do_try_state::<T>()
}
}
Expand Down
9 changes: 6 additions & 3 deletions pallets/attestation/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ use log;
use sp_runtime::SaturatedConversion;
use sp_std::marker::PhantomData;

#[cfg(feature = "try-runtime")]
use sp_runtime::TryRuntimeError;

use crate::{
AccountIdOf, Attestations, Config, CurrencyOf, HoldReason, Pallet, STORAGE_VERSION as TARGET_STORAGE_VERSION,
};
Expand Down Expand Up @@ -60,7 +63,7 @@ where
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, &'static str> {
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, TryRuntimeError> {
use sp_std::vec;

let has_all_user_no_holds = Attestations::<T>::iter_values()
Expand All @@ -85,7 +88,7 @@ where
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_pre_state: sp_std::vec::Vec<u8>) -> Result<(), &'static str> {
fn post_upgrade(_pre_state: sp_std::vec::Vec<u8>) -> Result<(), TryRuntimeError> {
use frame_support::traits::fungible::InspectHold;
use sp_runtime::Saturating;
use sp_std::collections::btree_map::BTreeMap;
Expand All @@ -103,7 +106,7 @@ where

map_user_deposit
.iter()
.try_for_each(|(who, amount)| -> Result<(), &'static str> {
.try_for_each(|(who, amount)| -> Result<(), TryRuntimeError> {
let hold_balance: BalanceOf<T> =
<T as Config>::Currency::balance_on_hold(&HoldReason::Deposit.into(), who).saturated_into();

Expand Down
7 changes: 4 additions & 3 deletions pallets/attestation/src/try_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@
use frame_support::ensure;
use kilt_support::test_utils::log_and_return_error_message;
use scale_info::prelude::format;
use sp_runtime::TryRuntimeError;

use crate::{Attestations, Config, ExternalAttestations};

pub(crate) fn do_try_state<T: Config>() -> Result<(), &'static str> {
Attestations::<T>::iter().try_for_each(|(claim_hash, attestation_details)| -> Result<(), &'static str> {
pub(crate) fn do_try_state<T: Config>() -> Result<(), TryRuntimeError> {
Attestations::<T>::iter().try_for_each(|(claim_hash, attestation_details)| -> Result<(), TryRuntimeError> {
if let Some(authorization_id) = attestation_details.authorization_id {
ensure!(
ExternalAttestations::<T>::get(&authorization_id, claim_hash),
log_and_return_error_message(format!(
"External attestation with authorization_id: {:?} and claim_hash {:?} does not exist",
authorization_id, claim_hash
))
)
);
}
Ok(())
})
Expand Down
3 changes: 1 addition & 2 deletions pallets/delegation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ mod access_control;
pub mod default_weights;
pub mod delegation_hierarchy;
pub mod migrations;

#[cfg(any(feature = "mock", test))]
pub mod mock;

Expand Down Expand Up @@ -306,7 +305,7 @@ pub mod pallet {
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[cfg(feature = "try-runtime")]
fn try_state(_n: BlockNumberFor<T>) -> Result<(), &'static str> {
fn try_state(_n: BlockNumberFor<T>) -> Result<(), sp_runtime::TryRuntimeError> {
crate::try_state::do_try_state::<T>()
}
}
Expand Down
9 changes: 6 additions & 3 deletions pallets/delegation/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ use log;
use sp_runtime::SaturatedConversion;
use sp_std::marker::PhantomData;

#[cfg(feature = "try-runtime")]
use sp_runtime::TryRuntimeError;

use crate::{
AccountIdOf, Config, CurrencyOf, DelegationNodes, HoldReason, Pallet, STORAGE_VERSION as TARGET_STORAGE_VERSION,
};
Expand Down Expand Up @@ -58,7 +61,7 @@ where
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, &'static str> {
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, TryRuntimeError> {
use sp_std::vec;

let has_all_user_no_holds = DelegationNodes::<T>::iter_values()
Expand All @@ -82,7 +85,7 @@ where
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_pre_state: sp_std::vec::Vec<u8>) -> Result<(), &'static str> {
fn post_upgrade(_pre_state: sp_std::vec::Vec<u8>) -> Result<(), TryRuntimeError> {
use frame_support::traits::fungible::InspectHold;
use sp_runtime::Saturating;
use sp_std::collections::btree_map::BTreeMap;
Expand All @@ -100,7 +103,7 @@ where

map_user_deposit
.iter()
.try_for_each(|(who, amount)| -> Result<(), &'static str> {
.try_for_each(|(who, amount)| -> Result<(), TryRuntimeError> {
let hold_balance: BalanceOf<T> =
<T as Config>::Currency::balance_on_hold(&HoldReason::Deposit.into(), who).saturated_into();

Expand Down
99 changes: 51 additions & 48 deletions pallets/delegation/src/try_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,61 +19,64 @@
use frame_support::ensure;
use kilt_support::test_utils::log_and_return_error_message;
use scale_info::prelude::format;
use sp_runtime::TryRuntimeError;

use crate::{Config, DelegationHierarchies, DelegationNodeOf, DelegationNodes};

pub(crate) fn do_try_state<T: Config>() -> Result<(), &'static str> {
DelegationNodes::<T>::iter().try_for_each(|(delegation_node_id, delegation_details)| -> Result<(), &'static str> {
let hierarchy_id = delegation_details.hierarchy_root_id;
pub(crate) fn do_try_state<T: Config>() -> Result<(), TryRuntimeError> {
DelegationNodes::<T>::iter().try_for_each(
|(delegation_node_id, delegation_details)| -> Result<(), TryRuntimeError> {
let hierarchy_id = delegation_details.hierarchy_root_id;
weichweich marked this conversation as resolved.
Show resolved Hide resolved

// check if node is in part of a delegation hierarchy.
ensure!(
DelegationHierarchies::<T>::contains_key(hierarchy_id),
log_and_return_error_message(format!("Delegation hierarchy {:?} not found", hierarchy_id))
);

let parent_count = DelegationNodes::<T>::iter_values()
.filter(|delegation_node: &DelegationNodeOf<T>| delegation_node.children.contains(&delegation_node_id))
.count();

if delegation_details.parent.is_some() {
// If node is a leaf or intermediate, check if it occurs only once. Otherwise we
// have cycles.
ensure!(
parent_count == 1,
log_and_return_error_message(format!(
"Delegation with cycles detected. Node {:?} in hierarchy {:?} has two or more parents.",
delegation_node_id, hierarchy_id
))
);
} else {
// if parent is None, check that the root is not the children
// from another node.
// check if node is in part of a delegation hierarchy.
ensure!(
parent_count == 0,
log_and_return_error_message(format!(
"Root node {:?} is child from other delegation nodes",
delegation_node_id
))
DelegationHierarchies::<T>::contains_key(hierarchy_id),
log_and_return_error_message(format!("Delegation hierarchy {:?} not found", hierarchy_id))
);
}

// if a node is revoked, the subtree should be revoked as well.
if delegation_details.details.revoked {
let is_subtree_revoked = get_merged_subtree::<T>(delegation_details)
.iter()
.map(|child: &DelegationNodeOf<T>| child.details.revoked)
.all(|x| x);
ensure!(
is_subtree_revoked,
log_and_return_error_message(format!(
"Revoked delegation node {:?} has an unrevoked subtree.",
delegation_node_id
))
);
}
Ok(())
})
let parent_count = DelegationNodes::<T>::iter_values()
.filter(|delegation_node: &DelegationNodeOf<T>| delegation_node.children.contains(&delegation_node_id))
.count();

if delegation_details.parent.is_some() {
// If node is a leaf or intermediate, check if it occurs only once. Otherwise we
// have cycles.
ensure!(
parent_count == 1,
log_and_return_error_message(format!(
"Delegation with cycles detected. Node {:?} in hierarchy {:?} has two or more parents.",
delegation_node_id, hierarchy_id
))
);
} else {
// if parent is None, check that the root is not the children
// from another node.
ensure!(
parent_count == 0,
log_and_return_error_message(format!(
"Root node {:?} is child from other delegation nodes",
delegation_node_id
))
);
}

// if a node is revoked, the subtree should be revoked as well.
if delegation_details.details.revoked {
let is_subtree_revoked = get_merged_subtree::<T>(delegation_details)
.iter()
.map(|child: &DelegationNodeOf<T>| child.details.revoked)
.all(|x| x);
ensure!(
is_subtree_revoked,
log_and_return_error_message(format!(
"Revoked delegation node {:?} has an unrevoked subtree.",
delegation_node_id
))
);
}
Ok(())
},
)
}

fn get_merged_subtree<T: Config>(node: DelegationNodeOf<T>) -> sp_std::vec::Vec<DelegationNodeOf<T>> {
Expand Down
2 changes: 1 addition & 1 deletion pallets/did/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ pub mod pallet {
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[cfg(feature = "try-runtime")]
fn try_state(_n: BlockNumberFor<T>) -> Result<(), &'static str> {
fn try_state(_n: BlockNumberFor<T>) -> Result<(), sp_runtime::TryRuntimeError> {
crate::try_state::do_try_state::<T>()
}
}
Expand Down
9 changes: 6 additions & 3 deletions pallets/did/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ use log;
use sp_runtime::SaturatedConversion;
use sp_std::marker::PhantomData;

#[cfg(feature = "try-runtime")]
use sp_runtime::TryRuntimeError;

use crate::{AccountIdOf, Config, CurrencyOf, Did, HoldReason, Pallet, STORAGE_VERSION as TARGET_STORAGE_VERSION};

const CURRENT_STORAGE_VERSION: StorageVersion = StorageVersion::new(4);
Expand Down Expand Up @@ -55,7 +58,7 @@ where
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, &'static str> {
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, TryRuntimeError> {
use frame_support::ensure;
use sp_std::vec;

Expand All @@ -78,7 +81,7 @@ where
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_pre_state: sp_std::vec::Vec<u8>) -> Result<(), &'static str> {
fn post_upgrade(_pre_state: sp_std::vec::Vec<u8>) -> Result<(), TryRuntimeError> {
use frame_support::traits::fungible::InspectHold;
use sp_runtime::Saturating;
use sp_std::collections::btree_map::BTreeMap;
Expand All @@ -96,7 +99,7 @@ where

map_user_deposit
.iter()
.try_for_each(|(who, amount)| -> Result<(), &'static str> {
.try_for_each(|(who, amount)| -> Result<(), TryRuntimeError> {
let hold_balance: BalanceOf<T> =
<T as Config>::Currency::balance_on_hold(&HoldReason::Deposit.into(), who).saturated_into();

Expand Down