Skip to content

Commit bd843de

Browse files
authored
chore: polkadot-0.9.43 (#541)
## fixes [KILTprotocol/ticket#513](#531) - @ggera is informed about the new CLI for starting a node
1 parent ad37b39 commit bd843de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1895
-1479
lines changed

Cargo.lock

+1,278-1,111
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+102-102
Large diffs are not rendered by default.

nodes/parachain/src/cli.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl RelayChainCli {
139139
) -> Self {
140140
let extension = crate::chain_spec::Extensions::try_get(&*para_config.chain_spec);
141141
let chain_id = extension.map(|e| e.relay_chain.clone());
142-
let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot"));
142+
let base_path = Some(para_config.base_path.path().join("polkadot"));
143143
Self {
144144
base_path,
145145
chain_id,

nodes/parachain/src/command.rs

+5-17
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,10 @@ impl DefaultConfigurationValues for RelayChainCli {
465465
30334
466466
}
467467

468-
fn rpc_ws_listen_port() -> u16 {
468+
fn rpc_listen_port() -> u16 {
469469
9945
470470
}
471471

472-
fn rpc_http_listen_port() -> u16 {
473-
9934
474-
}
475-
476472
fn prometheus_listen_port() -> u16 {
477473
9616
478474
}
@@ -502,16 +498,8 @@ impl CliConfiguration<Self> for RelayChainCli {
502498
.or_else(|| self.base_path.clone().map(Into::into)))
503499
}
504500

505-
fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
506-
self.base.base.rpc_http(default_listen_port)
507-
}
508-
509-
fn rpc_ipc(&self) -> Result<Option<String>> {
510-
self.base.base.rpc_ipc()
511-
}
512-
513-
fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
514-
self.base.base.rpc_ws(default_listen_port)
501+
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
502+
self.base.base.rpc_addr(default_listen_port)
515503
}
516504

517505
fn prometheus_config(
@@ -561,8 +549,8 @@ impl CliConfiguration<Self> for RelayChainCli {
561549
self.base.base.rpc_methods()
562550
}
563551

564-
fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {
565-
self.base.base.rpc_ws_max_connections()
552+
fn rpc_max_connections(&self) -> Result<u32> {
553+
self.base.base.rpc_max_connections()
566554
}
567555

568556
fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {

nodes/parachain/src/service.rs

+2
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,14 @@ where
303303
let prometheus_registry = parachain_config.prometheus_registry().cloned();
304304
let transaction_pool = params.transaction_pool.clone();
305305
let import_queue_service = params.import_queue.service();
306+
let net_config = sc_network::config::FullNetworkConfiguration::new(&parachain_config.network);
306307
let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
307308
cumulus_client_service::build_network(cumulus_client_service::BuildNetworkParams {
308309
parachain_config: &parachain_config,
309310
client: client.clone(),
310311
transaction_pool: transaction_pool.clone(),
311312
para_id: id,
313+
net_config,
312314
spawn_handle: task_manager.spawn_handle(),
313315
relay_chain_interface: relay_chain_interface.clone(),
314316
import_queue: params.import_queue,

nodes/standalone/Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ runtime-common = {workspace = true, features = ["std"]}
3333
frame-system = {workspace = true, features = ["std"]}
3434
pallet-transaction-payment = {workspace = true, features = ["std"]}
3535
sc-basic-authorship.workspace = true
36-
sc-cli = {workspace = true}
36+
sc-cli.workspace = true
3737
sc-client-api.workspace = true
3838
sc-consensus.workspace = true
3939
sc-consensus-aura.workspace = true
40-
sc-executor = {workspace = true}
40+
sc-executor.workspace = true
4141
sc-consensus-grandpa.workspace = true
4242
sc-keystore.workspace = true
43-
sc-service = {workspace = true}
43+
sc-service.workspace = true
44+
sc-network.workspace = true
4445
sc-telemetry.workspace = true
4546
sc-transaction-pool.workspace = true
4647
sc-transaction-pool-api.workspace = true

nodes/standalone/src/service.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub fn new_partial(config: &Configuration) -> Result<PartialComponents, ServiceE
142142
}
143143

144144
/// Builds a new service for a full client.
145-
pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError> {
145+
pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
146146
let sc_service::PartialComponents {
147147
client,
148148
backend,
@@ -159,12 +159,12 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
159159
&config.chain_spec,
160160
);
161161

162-
config
163-
.network
164-
.extra_sets
165-
.push(sc_consensus_grandpa::grandpa_peers_set_config(
166-
grandpa_protocol_name.clone(),
167-
));
162+
let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);
163+
164+
net_config.add_notification_protocol(sc_consensus_grandpa::grandpa_peers_set_config(
165+
grandpa_protocol_name.clone(),
166+
));
167+
168168
let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
169169
backend.clone(),
170170
grandpa_link.shared_authority_set().clone(),
@@ -175,6 +175,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
175175
sc_service::build_network(sc_service::BuildNetworkParams {
176176
config: &config,
177177
client: client.clone(),
178+
net_config,
178179
transaction_pool: transaction_pool.clone(),
179180
spawn_handle: task_manager.spawn_handle(),
180181
block_announce_validator_builder: None,

pallets/attestation/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub mod pallet {
169169
#[pallet::hooks]
170170
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
171171
#[cfg(feature = "try-runtime")]
172-
fn try_state(_n: BlockNumberFor<T>) -> Result<(), &'static str> {
172+
fn try_state(_n: BlockNumberFor<T>) -> Result<(), sp_runtime::TryRuntimeError> {
173173
crate::try_state::do_try_state::<T>()
174174
}
175175
}

pallets/attestation/src/migrations.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ use log;
2525
use sp_runtime::SaturatedConversion;
2626
use sp_std::marker::PhantomData;
2727

28+
#[cfg(feature = "try-runtime")]
29+
use sp_runtime::TryRuntimeError;
30+
2831
use crate::{
2932
AccountIdOf, Attestations, Config, CurrencyOf, HoldReason, Pallet, STORAGE_VERSION as TARGET_STORAGE_VERSION,
3033
};
@@ -60,7 +63,7 @@ where
6063
}
6164

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

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

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

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

pallets/attestation/src/try_state.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@
1919
use frame_support::ensure;
2020
use kilt_support::test_utils::log_and_return_error_message;
2121
use scale_info::prelude::format;
22+
use sp_runtime::TryRuntimeError;
2223

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

25-
pub(crate) fn do_try_state<T: Config>() -> Result<(), &'static str> {
26-
Attestations::<T>::iter().try_for_each(|(claim_hash, attestation_details)| -> Result<(), &'static str> {
26+
pub(crate) fn do_try_state<T: Config>() -> Result<(), TryRuntimeError> {
27+
Attestations::<T>::iter().try_for_each(|(claim_hash, attestation_details)| -> Result<(), TryRuntimeError> {
2728
if let Some(authorization_id) = attestation_details.authorization_id {
2829
ensure!(
2930
ExternalAttestations::<T>::get(&authorization_id, claim_hash),
3031
log_and_return_error_message(format!(
3132
"External attestation with authorization_id: {:?} and claim_hash {:?} does not exist",
3233
authorization_id, claim_hash
3334
))
34-
)
35+
);
3536
}
3637
Ok(())
3738
})

pallets/delegation/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ mod access_control;
6767
pub mod default_weights;
6868
pub mod delegation_hierarchy;
6969
pub mod migrations;
70-
7170
#[cfg(any(feature = "mock", test))]
7271
pub mod mock;
7372

@@ -306,7 +305,7 @@ pub mod pallet {
306305
#[pallet::hooks]
307306
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
308307
#[cfg(feature = "try-runtime")]
309-
fn try_state(_n: BlockNumberFor<T>) -> Result<(), &'static str> {
308+
fn try_state(_n: BlockNumberFor<T>) -> Result<(), sp_runtime::TryRuntimeError> {
310309
crate::try_state::do_try_state::<T>()
311310
}
312311
}

pallets/delegation/src/migrations.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ use log;
2525
use sp_runtime::SaturatedConversion;
2626
use sp_std::marker::PhantomData;
2727

28+
#[cfg(feature = "try-runtime")]
29+
use sp_runtime::TryRuntimeError;
30+
2831
use crate::{
2932
AccountIdOf, Config, CurrencyOf, DelegationNodes, HoldReason, Pallet, STORAGE_VERSION as TARGET_STORAGE_VERSION,
3033
};
@@ -58,7 +61,7 @@ where
5861
}
5962

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

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

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

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

pallets/delegation/src/try_state.rs

+67-48
Original file line numberDiff line numberDiff line change
@@ -19,61 +19,28 @@
1919
use frame_support::ensure;
2020
use kilt_support::test_utils::log_and_return_error_message;
2121
use scale_info::prelude::format;
22+
use sp_runtime::TryRuntimeError;
2223

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

25-
pub(crate) fn do_try_state<T: Config>() -> Result<(), &'static str> {
26-
DelegationNodes::<T>::iter().try_for_each(|(delegation_node_id, delegation_details)| -> Result<(), &'static str> {
27-
let hierarchy_id = delegation_details.hierarchy_root_id;
26+
pub(crate) fn do_try_state<T: Config>() -> Result<(), TryRuntimeError> {
27+
DelegationNodes::<T>::iter().try_for_each(
28+
|(delegation_node_id, delegation_details)| -> Result<(), TryRuntimeError> {
29+
let hierarchy_id = delegation_details.hierarchy_root_id;
2830

29-
// check if node is in part of a delegation hierarchy.
30-
ensure!(
31-
DelegationHierarchies::<T>::contains_key(hierarchy_id),
32-
log_and_return_error_message(format!("Delegation hierarchy {:?} not found", hierarchy_id))
33-
);
34-
35-
let parent_count = DelegationNodes::<T>::iter_values()
36-
.filter(|delegation_node: &DelegationNodeOf<T>| delegation_node.children.contains(&delegation_node_id))
37-
.count();
38-
39-
if delegation_details.parent.is_some() {
40-
// If node is a leaf or intermediate, check if it occurs only once. Otherwise we
41-
// have cycles.
42-
ensure!(
43-
parent_count == 1,
44-
log_and_return_error_message(format!(
45-
"Delegation with cycles detected. Node {:?} in hierarchy {:?} has two or more parents.",
46-
delegation_node_id, hierarchy_id
47-
))
48-
);
49-
} else {
50-
// if parent is None, check that the root is not the children
51-
// from another node.
31+
// check if node is in part of a delegation hierarchy.
5232
ensure!(
53-
parent_count == 0,
54-
log_and_return_error_message(format!(
55-
"Root node {:?} is child from other delegation nodes",
56-
delegation_node_id
57-
))
33+
DelegationHierarchies::<T>::contains_key(hierarchy_id),
34+
log_and_return_error_message(format!("Delegation hierarchy {:?} not found", hierarchy_id))
5835
);
59-
}
6036

61-
// if a node is revoked, the subtree should be revoked as well.
62-
if delegation_details.details.revoked {
63-
let is_subtree_revoked = get_merged_subtree::<T>(delegation_details)
64-
.iter()
65-
.map(|child: &DelegationNodeOf<T>| child.details.revoked)
66-
.all(|x| x);
67-
ensure!(
68-
is_subtree_revoked,
69-
log_and_return_error_message(format!(
70-
"Revoked delegation node {:?} has an unrevoked subtree.",
71-
delegation_node_id
72-
))
73-
);
74-
}
75-
Ok(())
76-
})
37+
// Delegation hierarchy should be a tree.
38+
check_no_cycles::<T>(&delegation_details, &delegation_node_id)?;
39+
40+
// if a node is revoked, the subtree should be revoked as well.
41+
check_subtree_is_revoked::<T>(delegation_details, &delegation_node_id)
42+
},
43+
)
7744
}
7845

7946
fn get_merged_subtree<T: Config>(node: DelegationNodeOf<T>) -> sp_std::vec::Vec<DelegationNodeOf<T>> {
@@ -86,3 +53,55 @@ fn get_merged_subtree<T: Config>(node: DelegationNodeOf<T>) -> sp_std::vec::Vec<
8653
}
8754
children
8855
}
56+
57+
fn check_subtree_is_revoked<T: Config>(
58+
delegation_details: DelegationNodeOf<T>,
59+
delegation_node_id: &<T as Config>::DelegationNodeId,
60+
) -> Result<(), TryRuntimeError> {
61+
if delegation_details.details.revoked {
62+
let is_subtree_revoked = get_merged_subtree::<T>(delegation_details)
63+
.iter()
64+
.map(|child: &DelegationNodeOf<T>| child.details.revoked)
65+
.all(|x| x);
66+
ensure!(
67+
is_subtree_revoked,
68+
log_and_return_error_message(format!(
69+
"Revoked delegation node {:?} has an unrevoked subtree.",
70+
delegation_node_id
71+
))
72+
);
73+
}
74+
Ok(())
75+
}
76+
77+
fn check_no_cycles<T: Config>(
78+
delegation_details: &DelegationNodeOf<T>,
79+
delegation_node_id: &<T as Config>::DelegationNodeId,
80+
) -> Result<(), TryRuntimeError> {
81+
let parent_count = DelegationNodes::<T>::iter_values()
82+
.filter(|delegation_node: &DelegationNodeOf<T>| delegation_node.children.contains(delegation_node_id))
83+
.count();
84+
85+
if delegation_details.parent.is_some() {
86+
// If node is a leaf or intermediate, check if it occurs only once. Otherwise we
87+
// have cycles.
88+
ensure!(
89+
parent_count == 1,
90+
log_and_return_error_message(format!(
91+
"Delegation with cycles detected. Node {:?} in hierarchy {:?} has two or more parents.",
92+
delegation_node_id, delegation_details.hierarchy_root_id
93+
))
94+
);
95+
} else {
96+
// if parent is None, check that the root is not the children
97+
// from another node.
98+
ensure!(
99+
parent_count == 0,
100+
log_and_return_error_message(format!(
101+
"Root node {:?} is child from other delegation nodes",
102+
delegation_node_id
103+
))
104+
);
105+
}
106+
Ok(())
107+
}

pallets/did/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ pub mod pallet {
500500
#[pallet::hooks]
501501
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
502502
#[cfg(feature = "try-runtime")]
503-
fn try_state(_n: BlockNumberFor<T>) -> Result<(), &'static str> {
503+
fn try_state(_n: BlockNumberFor<T>) -> Result<(), sp_runtime::TryRuntimeError> {
504504
crate::try_state::do_try_state::<T>()
505505
}
506506
}

0 commit comments

Comments
 (0)