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

update to polkadot-v0.9.39 #548

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,742 changes: 2,356 additions & 1,386 deletions Cargo.lock

Large diffs are not rendered by default.

214 changes: 107 additions & 107 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dkg-gadget/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ scale-info = { workspace = true }
curv = { workspace = true }

codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
prometheus = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
prometheus = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.39" }

sp-api = { workspace = true }
sp-application-crypto = { workspace = true }
Expand Down
8 changes: 4 additions & 4 deletions dkg-gadget/src/async_protocols/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ mod tests {
fn should_create_offline_id_from_keygen_id() {
let party_id = 1;
let keygen_id = KeygenPartyId::try_from(party_id).unwrap();
let s_l = (1..=3).into_iter().map(KeygenPartyId).collect::<Vec<_>>();
let s_l = (1..=3).map(KeygenPartyId).collect::<Vec<_>>();
let offline_id = OfflinePartyId::try_from_keygen_party_id(keygen_id, &s_l).unwrap();
assert_eq!(*offline_id.as_ref(), 1);
assert_eq!(offline_id.to_index(), 0);
Expand All @@ -703,7 +703,7 @@ mod tests {
fn should_return_the_correct_offline_id() {
let party_id = 1;
let keygen_id = KeygenPartyId::try_from(party_id).unwrap();
let s_l = (1..=3).into_iter().map(KeygenPartyId).collect::<Vec<_>>();
let s_l = (1..=3).map(KeygenPartyId).collect::<Vec<_>>();
let s_l_raw = s_l.iter().map(|id| id.0).collect::<Vec<_>>();
let offline_id = OfflinePartyId::try_from_keygen_party_id(keygen_id, &s_l).unwrap();
let expected_offline_id = get_offline_stage_index(&s_l_raw, party_id).unwrap();
Expand All @@ -720,7 +720,7 @@ mod tests {
fn should_convert_from_keygen_id_to_offline_id_and_back() {
let party_id = 1;
let orig_keygen_id = KeygenPartyId::try_from(party_id).unwrap();
let s_l = (1..=3).into_iter().map(KeygenPartyId).collect::<Vec<_>>();
let s_l = (1..=3).map(KeygenPartyId).collect::<Vec<_>>();
let offline_id = OfflinePartyId::try_from_keygen_party_id(orig_keygen_id, &s_l).unwrap();
let keygen_id = offline_id.try_to_keygen_party_id(&s_l).unwrap();
assert_eq!(keygen_id, orig_keygen_id);
Expand All @@ -742,7 +742,7 @@ mod tests {
.unwrap();
assert_eq!(party_i, 2);
let keygen_id = KeygenPartyId::try_from(party_i).unwrap();
let s_l = (1..=3).into_iter().map(KeygenPartyId).collect::<Vec<_>>();
let s_l = (1..=3).map(KeygenPartyId).collect::<Vec<_>>();
let offline_id = OfflinePartyId::try_from_keygen_party_id(keygen_id, &s_l).unwrap();
assert_eq!(offline_id.to_index(), 1);
assert_eq!(*offline_id.as_ref(), 2);
Expand Down
73 changes: 41 additions & 32 deletions dkg-gadget/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ use dkg_primitives::utils::select_random_set;
use futures::StreamExt;
use itertools::Itertools;
use multi_party_ecdsa::protocols::multi_party_ecdsa::gg_2020::state_machine::keygen::LocalKey;
use parking_lot::RwLock;
use sc_client_api::{Backend, FinalityNotification};
use sc_keystore::LocalKeystore;
use sp_arithmetic::traits::CheckedRem;
use sp_core::ecdsa;
use sp_runtime::traits::Get;
use sp_runtime::traits::{Block, Get, Header, NumberFor, Zero};
use std::{
collections::{BTreeSet, HashMap, HashSet},
future::Future,
Expand All @@ -39,14 +42,6 @@ use std::{
Arc,
},
};

use parking_lot::RwLock;

use sc_client_api::{Backend, FinalityNotification};

use sp_api::BlockId;
use sp_arithmetic::traits::CheckedRem;
use sp_runtime::traits::{Block, Header, NumberFor, Zero};
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};

use dkg_primitives::{
Expand Down Expand Up @@ -589,50 +584,60 @@ where

/// Get the signature threshold at a specific block
pub fn get_signature_threshold(&self, header: &B::Header) -> u16 {
let at: BlockId<B> = BlockId::hash(header.hash());
return self.client.runtime_api().signature_threshold(&at).unwrap_or_default()
return self.client.runtime_api().signature_threshold(header.hash()).unwrap_or_default()
}

/// Get the next signature threshold at a specific block
pub fn get_next_signature_threshold(&self, header: &B::Header) -> u16 {
let at: BlockId<B> = BlockId::hash(header.hash());
return self.client.runtime_api().next_signature_threshold(&at).unwrap_or_default()
return self
.client
.runtime_api()
.next_signature_threshold(header.hash())
.unwrap_or_default()
}

/// Get the active DKG public key
pub fn get_dkg_pub_key(&self, header: &B::Header) -> (AuthoritySetId, Vec<u8>) {
let at: BlockId<B> = BlockId::hash(header.hash());
return self.client.runtime_api().dkg_pub_key(&at).ok().unwrap_or_default()
return self.client.runtime_api().dkg_pub_key(header.hash()).ok().unwrap_or_default()
}

/// Get the next DKG public key
#[allow(dead_code)]
pub fn get_next_dkg_pub_key(&self, header: &B::Header) -> Option<(AuthoritySetId, Vec<u8>)> {
let at: BlockId<B> = BlockId::hash(header.hash());
return self.client.runtime_api().next_dkg_pub_key(&at).ok().unwrap_or_default()
return self
.client
.runtime_api()
.next_dkg_pub_key(header.hash())
.ok()
.unwrap_or_default()
}

/// Get the jailed keygen authorities
#[allow(dead_code)]
pub fn get_keygen_jailed(&self, header: &B::Header, set: &[AuthorityId]) -> Vec<AuthorityId> {
let at: BlockId<B> = BlockId::hash(header.hash());
return self
.client
.runtime_api()
.get_keygen_jailed(&at, set.to_vec())
.get_keygen_jailed(header.hash(), set.to_vec())
.unwrap_or_default()
}

/// Get the best authorities for keygen
pub fn get_best_authorities(&self, header: &B::Header) -> Vec<(u16, AuthorityId)> {
let at: BlockId<B> = BlockId::hash(header.hash());
return self.client.runtime_api().get_best_authorities(&at).unwrap_or_default()
return self
.client
.runtime_api()
.get_best_authorities(header.hash())
.unwrap_or_default()
}

/// Get the next best authorities for keygen
pub fn get_next_best_authorities(&self, header: &B::Header) -> Vec<(u16, AuthorityId)> {
let at: BlockId<B> = BlockId::hash(header.hash());
return self.client.runtime_api().get_next_best_authorities(&at).unwrap_or_default()
return self
.client
.runtime_api()
.get_next_best_authorities(header.hash())
.unwrap_or_default()
}

/// Return the next and queued validator set at header `header`.
Expand All @@ -659,9 +664,9 @@ where
let new = if let Some((new, queued)) = find_authorities_change::<B>(header) {
Some((new, queued))
} else {
let at: BlockId<B> = BlockId::hash(header.hash());
let current_authority_set = client.runtime_api().authority_set(&at).ok();
let queued_authority_set = client.runtime_api().queued_authority_set(&at).ok();
let current_authority_set = client.runtime_api().authority_set(header.hash()).ok();
let queued_authority_set =
client.runtime_api().queued_authority_set(header.hash()).ok();
match (current_authority_set, queued_authority_set) {
(Some(current), Some(queued)) => Some((current, queued)),
_ => None,
Expand Down Expand Up @@ -1321,7 +1326,6 @@ where
let on_chain_dkg = self.get_dkg_pub_key(header);
let session_id = on_chain_dkg.0;
let dkg_pub_key = on_chain_dkg.1;
let at: BlockId<B> = BlockId::hash(header.hash());
// Check whether the worker is in the best set or return
let party_i = match self.get_party_index(header) {
Some(party_index) => {
Expand Down Expand Up @@ -1355,7 +1359,11 @@ where
self.currently_signing_proposals.write().clear();
}

let unsigned_proposals = match self.client.runtime_api().get_unsigned_proposals(&at) {
let unsigned_proposals = match self
.client
.runtime_api()
.get_unsigned_proposals(header.hash())
{
Ok(res) => {
let mut filtered_unsigned_proposals = Vec::new();
for proposal in res {
Expand Down Expand Up @@ -1526,11 +1534,10 @@ where
let now = self.latest_header.read().clone().ok_or_else(|| DKGError::CriticalError {
reason: "latest header does not exist!".to_string(),
})?;
let at: BlockId<B> = BlockId::hash(now.hash());
Ok(self
.client
.runtime_api()
.get_signing_jailed(&at, best_authorities.to_vec())
.get_signing_jailed(now.hash(), best_authorities.to_vec())
.unwrap_or_default())
}
fn get_unjailed_signers(&self, best_authorities: &[Public]) -> Result<Vec<u16>, DKGError> {
Expand All @@ -1556,8 +1563,10 @@ where

fn should_execute_new_keygen(&self, header: &B::Header) -> bool {
// query runtime api to check if we should execute new keygen.
let at: BlockId<B> = BlockId::hash(header.hash());
self.client.runtime_api().should_execute_new_keygen(&at).unwrap_or_default()
self.client
.runtime_api()
.should_execute_new_keygen(header.hash())
.unwrap_or_default()
}

/// Wait for initial finalized block
Expand Down
2 changes: 1 addition & 1 deletion launch/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
relaychain:
image: parity/polkadot:v0.9.36
image: parity/polkadot:v0.9.39
chain: rococo-local
runtimeGenesisConfig:
configuration:
Expand Down
8 changes: 7 additions & 1 deletion parachain/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ async fn start_node_impl(
block_announce_validator_builder: Some(Box::new(|_| {
Box::new(block_announce_validator)
})),
warp_sync: None,
warp_sync_params: None,
})?;

if parachain_config.offchain_worker.enabled {
Expand Down Expand Up @@ -259,6 +259,10 @@ async fn start_node_impl(
Arc::new(move |hash, data| network.announce_block(hash, data))
};

let overseer_handle = relay_chain_interface
.overseer_handle()
.map_err(|e| sc_service::Error::Application(Box::new(e)))?;

let relay_chain_slot_duration = Duration::from_secs(6);

if validator {
Expand Down Expand Up @@ -289,6 +293,7 @@ async fn start_node_impl(
import_queue: import_queue_service,
collator_key: collator_key.expect("Command line arguments do not allow this. qed"),
relay_chain_slot_duration,
recovery_handle: Box::new(overseer_handle),
};

start_collator(params).await?;
Expand All @@ -301,6 +306,7 @@ async fn start_node_impl(
relay_chain_interface,
relay_chain_slot_duration,
import_queue: import_queue_service,
recovery_handle: Box::new(overseer_handle),
};

start_full_node(params)?;
Expand Down
14 changes: 10 additions & 4 deletions parachain/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// We allow for 0.5 of a second of compute with a 12 second average block time.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64,
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);

parameter_types! {
Expand Down Expand Up @@ -433,9 +433,7 @@ parameter_types! {

impl pallet_authorship::Config for Runtime {
type EventHandler = (CollatorSelection,);
type FilterUncle = ();
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
type UncleGenerations = UncleGenerations;
}

parameter_types! {
Expand Down Expand Up @@ -684,6 +682,7 @@ impl pallet_democracy::Config for Runtime {
type CooloffPeriod = CooloffPeriod;
type Currency = Balances;
type EnactmentPeriod = EnactmentPeriod;
type SubmitOrigin = frame_system::EnsureSigned<AccountId>;
type RuntimeEvent = RuntimeEvent;
/// A unanimous council can have the next scheduled referendum be a straight
/// default-carries (NTB) vote.
Expand Down Expand Up @@ -739,6 +738,7 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
type MotionDuration = CouncilMotionDuration;
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
}

Expand Down Expand Up @@ -816,7 +816,7 @@ construct_runtime!(
Indices: pallet_indices::{Pallet, Call, Storage, Config<T>, Event<T>} = 25,

// Collator support. the order of these 4 are important and shall not change.
Authorship: pallet_authorship::{Pallet, Call, Storage} = 30,
Authorship: pallet_authorship::{Pallet, Storage} = 30,
CollatorSelection: pallet_collator_selection::{Pallet, Call, Storage, Event<T>, Config<T>} = 31,
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 32,
Aura: pallet_aura::{Pallet, Storage, Config<T>} = 33,
Expand Down Expand Up @@ -1045,6 +1045,12 @@ impl_runtime_apis! {
) -> pallet_transaction_payment::FeeDetails<Balance> {
TransactionPayment::query_fee_details(uxt, len)
}
fn query_weight_to_fee(weight: Weight) -> Balance {
TransactionPayment::weight_to_fee(weight)
}
fn query_length_to_fee(length: u32) -> Balance {
TransactionPayment::length_to_fee(length)
}
}

#[cfg(feature = "runtime-benchmarks")]
Expand Down
Loading