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-sdk/release-polkadot-v1.1.0 #726

Merged
merged 5 commits into from
Dec 7, 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
6,278 changes: 3,465 additions & 2,813 deletions Cargo.lock

Large diffs are not rendered by default.

247 changes: 124 additions & 123 deletions Cargo.toml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dkg-runtime-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ use codec::{Codec, Decode, Encode, MaxEncodedLen};
use crypto::AuthorityId;
pub use ethereum::*;
pub use ethereum_types::*;
use frame_support::{pallet_prelude::Get, BoundedVec, RuntimeDebug};
use frame_support::{pallet_prelude::Get, BoundedVec};
pub use proposal::*;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{IdentifyAccount, Verify},
MultiSignature,
MultiSignature, RuntimeDebug,
};
use sp_std::{fmt::Debug, prelude::*, vec::Vec};
use tiny_keccak::{Hasher, Keccak};
Expand Down
3 changes: 2 additions & 1 deletion dkg-runtime-primitives/src/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
//
use frame_support::{
pallet_prelude::{ConstU32, Get},
BoundedVec, RuntimeDebug,
BoundedVec,
};
use sp_runtime::RuntimeDebug;
use sp_std::hash::{Hash, Hasher};

use codec::{Decode, Encode, EncodeLike, MaxEncodedLen};
Expand Down
25 changes: 7 additions & 18 deletions dkg-test-orchestrator/src/dummy_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use parking_lot::RwLock;
use sp_api::{ApiExt, AsTrieBackend, BlockT, StateBackend, *};
use sp_core::bounded_vec::BoundedVec;
use sp_runtime::{testing::H256, traits::BlakeTwo256, Permill};
use sp_state_machine::{backend::Consolidate, *};
use sp_state_machine::*;
use sp_trie::HashDBT;
use std::{collections::HashMap, sync::Arc};

Expand Down Expand Up @@ -164,8 +164,6 @@ impl sp_state_machine::StorageIterator<BlakeTwo256> for DummyRawIterator {
impl StateBackend<BlakeTwo256> for DummyStateBackend {
type Error = DummyError;

type Transaction = DummyOverlay;

type TrieBackendStorage = DummyStateBackend;

type RawIter = DummyRawIterator;
Expand Down Expand Up @@ -217,7 +215,7 @@ impl StateBackend<BlakeTwo256> for DummyStateBackend {
&self,
_delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
_state_version: sp_api::StateVersion,
) -> (<BlakeTwo256 as sp_api::Hasher>::Out, Self::Transaction)
) -> (<BlakeTwo256 as sp_api::Hasher>::Out, BackendTransaction<BlakeTwo256>)
where
<BlakeTwo256 as sp_api::Hasher>::Out: Ord,
{
Expand All @@ -229,7 +227,7 @@ impl StateBackend<BlakeTwo256> for DummyStateBackend {
_child_info: &sc_client_api::ChildInfo,
_delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
_state_version: sp_api::StateVersion,
) -> (<BlakeTwo256 as sp_api::Hasher>::Out, bool, Self::Transaction)
) -> (<BlakeTwo256 as sp_api::Hasher>::Out, bool, BackendTransaction<BlakeTwo256>)
where
<BlakeTwo256 as sp_api::Hasher>::Out: Ord,
{
Expand All @@ -253,8 +251,6 @@ impl StateBackend<BlakeTwo256> for DummyStateBackend {
}

impl ApiExt<TestBlock> for DummyApi {
type StateBackend = DummyStateBackend;

fn execute_in_transaction<F: FnOnce(&Self) -> sp_api::TransactionOutcome<R>, R>(
&self,
_call: F,
Expand Down Expand Up @@ -308,11 +304,11 @@ impl ApiExt<TestBlock> for DummyApi {
todo!()
}

fn into_storage_changes(
fn into_storage_changes<B: StateBackend<HashingFor<TestBlock>>>(
&self,
_backend: &Self::StateBackend,
_backend: &B,
_parent_hash: <TestBlock as BlockT>::Hash,
) -> Result<sp_api::StorageChanges<Self::StateBackend, TestBlock>, String>
) -> Result<sp_api::StorageChanges<TestBlock>, String>
where
Self: Sized,
{
Expand Down Expand Up @@ -388,14 +384,7 @@ impl hash_db::AsHashDB<BlakeTwo256, Vec<u8>> for DummyOverlay {
}
}

impl Consolidate for DummyOverlay {
fn consolidate(&mut self, _: Self) {
todo!()
}
}

impl sp_state_machine::TrieBackendStorage<BlakeTwo256> for DummyStateBackend {
type Overlay = DummyOverlay;
fn get(
&self,
_: &<BlakeTwo256 as sp_core::Hasher>::Out,
Expand Down Expand Up @@ -425,7 +414,7 @@ impl sc_client_api::BlockImportOperation<TestBlock> for DummyStateBackend {

fn update_db_storage(
&mut self,
_update: sc_client_api::TransactionForSB<Self::State, TestBlock>,
_update: BackendTransaction<HashingFor<TestBlock>>,
) -> sp_blockchain::Result<()> {
todo!()
}
Expand Down
10 changes: 1 addition & 9 deletions pallets/bridge-registry/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,7 @@ pub struct BridgeInfo<FieldLimit: Get<u32>> {
}

#[derive(
Clone,
Eq,
PartialEq,
frame_support::RuntimeDebug,
MaxEncodedLen,
Encode,
TypeInfo,
Decode,
Default,
Clone, Eq, PartialEq, sp_runtime::RuntimeDebug, MaxEncodedLen, Encode, TypeInfo, Decode, Default,
)]
pub struct SerdeData(Data);

Expand Down
8 changes: 4 additions & 4 deletions pallets/dkg-metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ pub mod pallet {
<NextUnsignedAt<T>>::put(current_block + T::UnsignedInterval::get());
// Reset `RefreshInProgress` to false, so that we submit a new refresh.
RefreshInProgress::<T>::put(false);
frame_support::log::debug!(
log::debug!(
target: "runtime::dkg_metadata",
"Next DKG Public Key: {}, Authority Set ID: {}",
hex::encode(key),
Expand Down Expand Up @@ -1437,7 +1437,7 @@ pub mod pallet {
let current_block = <frame_system::Pallet<T>>::block_number();
let next_unsigned_at = <NextUnsignedAt<T>>::get();
if next_unsigned_at > current_block {
frame_support::log::debug!(
log::debug!(
target: "runtime::dkg_metadata",
"validate unsigned: early block: current: {:?}, next_unsigned_at: {:?}",
current_block,
Expand All @@ -1461,14 +1461,14 @@ pub mod pallet {
Call::submit_misbehaviour_reports { .. }
};
if !is_valid_call {
frame_support::log::warn!(
log::warn!(
target: "runtime::dkg_metadata",
"validate unsigned: invalid call: {:?}",
call,
);
InvalidTransaction::Call.into()
} else {
frame_support::log::debug!(
log::debug!(
target: "runtime::dkg_metadata",
"validate unsigned: valid call: {:?}",
call,
Expand Down
8 changes: 5 additions & 3 deletions pallets/dkg-proposal-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ use dkg_runtime_primitives::{
TypedChainId,
};
use frame_support::{
dispatch::fmt::Debug,
pallet_prelude::*,
traits::{ValidatorSet, ValidatorSetWithIdentification},
};
use sp_runtime::RuntimeDebug;

use core::fmt::Debug;
use frame_system::{
offchain::{AppCrypto, SendSignedTransaction, SignMessage, Signer},
pallet_prelude::BlockNumberFor,
Expand All @@ -136,6 +137,7 @@ use sp_staking::{
};
use sp_std::{convert::TryInto, vec::Vec};
use webb_proposals::Proposal;

pub use weights::WeightInfo;

mod impls;
Expand Down Expand Up @@ -692,14 +694,14 @@ pub mod pallet {
Call::submit_signed_proposals { .. }
};
if !is_valid_call {
frame_support::log::warn!(
log::warn!(
target: "runtime::dkg_metadata",
"validate unsigned: invalid call: {:?}",
call,
);
InvalidTransaction::Call.into()
} else {
frame_support::log::debug!(
log::debug!(
target: "runtime::dkg_metadata",
"validate unsigned: valid call: {:?}",
call,
Expand Down
6 changes: 2 additions & 4 deletions pallets/dkg-proposals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ use frame_support::{
};
use frame_system::pallet_prelude::BlockNumberFor;

use core::fmt::Debug;
use sp_runtime::{traits::Convert, RuntimeAppPublic};
use sp_std::prelude::*;
use types::{ProposalStatus, ProposalVotes};
Expand All @@ -130,10 +131,7 @@ pub mod pallet {
proposal::{Proposal, ProposalKind},
ProposalNonce,
};
use frame_support::{
dispatch::{fmt::Debug, DispatchResultWithPostInfo},
pallet_prelude::*,
};
use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*};
use frame_system::pallet_prelude::*;

pub type ProposalOf<T> = Proposal<<T as Config>::MaxProposalLength>;
Expand Down
10 changes: 5 additions & 5 deletions relayer-gadget/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ sp-keystore = { workspace = true }
sc-keystore = { workspace = true }

# Relayer
webb-relayer = { git = "https://github.com/webb-tools/relayer", tag = "v0.5.12-dev" }
webb-relayer-context = { git = "https://github.com/webb-tools/relayer", tag = "v0.5.12-dev" }
webb-relayer-config = { git = "https://github.com/webb-tools/relayer", tag = "v0.5.12-dev" }
webb-relayer-store = { git = "https://github.com/webb-tools/relayer", tag = "v0.5.12-dev" }
webb-relayer-types = { git = "https://github.com/webb-tools/relayer", tag = "v0.5.12-dev" }
webb-relayer = { git = "https://github.com/webb-tools/relayer", branch = "fix-ethers-version-2.0.10" }
webb-relayer-context = { git = "https://github.com/webb-tools/relayer", branch = "fix-ethers-version-2.0.10" }
webb-relayer-config = { git = "https://github.com/webb-tools/relayer", branch = "fix-ethers-version-2.0.10" }
webb-relayer-store = { git = "https://github.com/webb-tools/relayer", branch = "fix-ethers-version-2.0.10" }
webb-relayer-types = { git = "https://github.com/webb-tools/relayer", branch = "fix-ethers-version-2.0.10" }

# DKG
dkg-runtime-primitives = { workspace = true }
4 changes: 3 additions & 1 deletion relayer-gadget/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ pub async fn start_relayer_gadget(relayer_params: WebbRelayerParams) {
.expect("failed to post process relayer config");

let store = create_store(relayer_params.database_path).expect("failed to create relayer store");
let ctx = RelayerContext::new(config, store.clone()).expect("failed to build relayer context");
let ctx = RelayerContext::new(config, store.clone())
.await
.expect("failed to build relayer context");

// Start the web server:
service::build_web_services(ctx.clone())
Expand Down
11 changes: 8 additions & 3 deletions standalone/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ use std::{sync::Arc, time::Duration};
// Our native executor instance.
pub struct ExecutorDispatch;

/// The minimum period of blocks on which justifications will be
/// imported and generated.
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;

impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
/// Only enable the benchmarking host functions when we actually want to benchmark.
#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -61,7 +65,7 @@ pub fn new_partial(
FullClient,
FullBackend,
FullSelectChain,
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_consensus_grandpa::GrandpaBlockImport<
Expand Down Expand Up @@ -115,7 +119,8 @@ pub fn new_partial(
#[allow(clippy::redundant_clone)]
let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import(
client.clone(),
&(client.clone() as Arc<_>),
GRANDPA_JUSTIFICATION_PERIOD,
&client,
select_chain.clone(),
telemetry.as_ref().map(|x| x.handle()),
)?;
Expand Down Expand Up @@ -379,7 +384,7 @@ pub fn new_full(
let grandpa_config = sc_consensus_grandpa::Config {
// FIXME #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333),
justification_period: 512,
justification_generation_period: GRANDPA_JUSTIFICATION_PERIOD,
name: Some(name),
observer_enabled: false,
keystore,
Expand Down
1 change: 1 addition & 0 deletions standalone/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
# Local dependencies
log = { workspace = true }
dkg-runtime-primitives = { workspace = true, default-features = false }
pallet-dkg-metadata = { workspace = true }
pallet-dkg-proposals = { workspace = true }
Expand Down
30 changes: 20 additions & 10 deletions standalone/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ use codec::{Decode, Encode, MaxEncodedLen};
use dkg_runtime_primitives::{
MaxAuthorities, MaxKeyLength, MaxProposalLength, MaxReporters, MaxSignatureLength, TypedChainId,
};
use frame_election_provider_support::{
bounds::{ElectionBounds, ElectionBoundsBuilder},
ElectionDataProvider,
};

use frame_election_provider_support::{onchain, SequentialPhragmen, VoteWeight};
use frame_support::{
traits::{ConstBool, ConstU16, ConstU32, Everything},
Expand Down Expand Up @@ -274,6 +279,7 @@ impl pallet_grandpa::Config for Runtime {
type EquivocationReportSystem = ();
type KeyOwnerProof = sp_core::Void;
type WeightInfo = ();
type MaxNominators = MaxNominatorRewardedPerValidator;
}

parameter_types! {
Expand Down Expand Up @@ -349,8 +355,10 @@ impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
type MaxValidators = ConstU32<1000>;
}

/// Upper limit on the number of NPOS nominations.
const MAX_QUOTA_NOMINATIONS: u32 = 16;

impl pallet_staking::Config for Runtime {
type MaxNominations = MaxNominations;
type Currency = Balances;
type CurrencyBalance = Balance;
type UnixTime = Timestamp;
Expand All @@ -377,6 +385,7 @@ impl pallet_staking::Config for Runtime {
type HistoryDepth = HistoryDepth;
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
type BenchmarkingConfig = StakingBenchmarkingConfig;
type NominationsQuota = pallet_staking::FixedNominationsQuota<MAX_QUOTA_NOMINATIONS>;
}

parameter_types! {
Expand Down Expand Up @@ -420,6 +429,10 @@ parameter_types! {
pub MaxActiveValidators: u32 = 1000;
pub MaxOnChainElectingVoters: u32 = 5000;
pub MaxOnChainElectableTargets: u16 = 1250;
pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default()
.voters_count(5_000.into()).targets_count(1_250.into()).build();
pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::default()
.voters_count(10_000.into()).targets_count(1_500.into()).build();
}

/// The numbers configured here could always be more than the the maximum limits of staking pallet
Expand Down Expand Up @@ -450,16 +463,14 @@ impl onchain::Config for OnChainSeqPhragmen {
type DataProvider = <Runtime as pallet_election_provider_multi_phase::Config>::DataProvider;
type WeightInfo = frame_election_provider_support::weights::SubstrateWeight<Runtime>;
type MaxWinners = <Runtime as pallet_election_provider_multi_phase::Config>::MaxWinners;
type VotersBound = MaxOnChainElectingVoters;
type TargetsBound = MaxOnChainElectableTargets;
type Bounds = ElectionBoundsOnChain;
}

pub struct WebbMinerConfig;
impl pallet_election_provider_multi_phase::MinerConfig for WebbMinerConfig {
impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
type AccountId = AccountId;
type MaxLength = MinerMaxLength;
type MaxWeight = MinerMaxWeight;
type MaxVotesPerVoter = MaxNominations;
type MaxVotesPerVoter = <<Self as pallet_election_provider_multi_phase::Config>::DataProvider as ElectionDataProvider>::MaxVotesPerVoter;
type Solution = NposSolution16;
type MaxWinners = <Runtime as pallet_election_provider_multi_phase::Config>::MaxWinners;

Expand All @@ -477,7 +488,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type UnsignedPhase = UnsignedPhase;
type BetterUnsignedThreshold = BetterUnsignedThreshold;
type BetterSignedThreshold = ();
type MinerConfig = WebbMinerConfig;
type MinerConfig = Self;
type OffchainRepeat = OffchainRepeat;
type MinerTxPriority = MultiPhaseUnsignedPriority;
type SignedMaxSubmissions = ConstU32<10>;
Expand All @@ -494,11 +505,10 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type GovernanceFallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
type Solver = SequentialPhragmen<AccountId, SolutionAccuracyOf<Self>, ()>;
type ForceOrigin = EnsureRoot<AccountId>;
type MaxElectableTargets = ConstU16<{ u16::MAX }>;
type MaxElectingVoters = MaxElectingVoters;
type MaxWinners = MaxActiveValidators;
type BenchmarkingConfig = ElectionProviderBenchmarkConfig;
type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Self>;
type ElectionBounds = ElectionBoundsMultiPhase;
}

impl pallet_bags_list::Config for Runtime {
Expand Down Expand Up @@ -720,7 +730,7 @@ where

let raw_payload = SignedPayload::new(call, extra)
.map_err(|e| {
frame_support::log::warn!("Unable to create signed payload: {:?}", e);
log::warn!("Unable to create signed payload: {:?}", e);
})
.ok()?;
let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
Expand Down
Loading