Skip to content
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
1,110 changes: 575 additions & 535 deletions Cargo.lock

Large diffs are not rendered by default.

238 changes: 119 additions & 119 deletions Cargo.toml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ polkadot-bulletin-chain-runtime = { workspace = true }
# Polkadot production
bulletin-polkadot-runtime = { workspace = true }

# TODO: remove when bulletin-polkadot is upgraded live with TX storage runtime API
pallet-transaction-storage = { workspace = true }

[build-dependencies]
substrate-build-script-utils = { workspace = true }

Expand Down
8 changes: 7 additions & 1 deletion node/src/fake_runtime_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ sp_api::impl_runtime_apis! {
}

impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(_: Option<Vec<u8>>) -> Vec<u8> {
fn generate_session_keys(_owner: Vec<u8>, _seed: Option<Vec<u8>>) -> sp_session::OpaqueGeneratedSessionKeys {
unimplemented!()
}

Expand Down Expand Up @@ -210,6 +210,12 @@ sp_api::impl_runtime_apis! {
}
}

impl sp_transaction_storage_proof::runtime_api::TransactionStorageApi<Block> for Runtime {
fn retention_period() -> sp_runtime::traits::NumberFor<Block> {
unimplemented!()
}
}

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(_: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
Expand Down
19 changes: 19 additions & 0 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use sc_consensus_grandpa::SharedVoterState;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_consensus_babe::inherents::BabeCreateInherentDataProviders;
use sp_transaction_storage_proof::runtime_api::TransactionStorageApi;
use std::{sync::Arc, time::Duration};

pub(crate) type FullClient = sc_service::TFullClient<
Expand Down Expand Up @@ -306,10 +308,27 @@ pub fn new_full<
slot_duration,
);

// Get the retention period for a proof.
let retention_period = {
let has_tx_storage_api = client_clone
.runtime_api()
.has_api::<dyn TransactionStorageApi<Block>>(parent)
.unwrap_or(false);
if has_tx_storage_api {
client_clone.runtime_api().retention_period(parent)?
} else {
// Fallback for solochain runtimes that do not yet have the transaction
// storage API. TODO: remove once bulletin-polkadot is upgraded
// with the TX storage runtime API. TODO: also remove the
// pallet_transaction_storage dependency.
pallet_transaction_storage::DEFAULT_RETENTION_PERIOD
}
};
let storage_proof =
sp_transaction_storage_proof::registration::new_data_provider(
&*client_clone,
&parent,
retention_period,
)?;

Ok((slot, timestamp, storage_proof))
Expand Down
17 changes: 13 additions & 4 deletions pallets/validator-set/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
#![cfg(test)]

use super::mock::{
new_test_ext, next_block, next_session, AccountId, RuntimeOrigin, Session, System, Test,
ValidatorSet,
new_test_ext, next_block, next_session, AccountId, MockSessionKeys, RuntimeOrigin, Session,
System, Test, ValidatorSet,
};
use polkadot_sdk_frame::{
deps::sp_runtime::Perbill, prelude::*, testing_prelude::*, traits::ValidatorRegistration,
deps::sp_runtime::{testing::UintAuthorityId, Perbill},
prelude::*,
testing_prelude::*,
traits::ValidatorRegistration,
};
use sp_staking::offence::{OffenceDetails, OnOffenceHandler};
use std::collections::HashSet;
Expand Down Expand Up @@ -55,7 +58,13 @@ fn add_validator_updates_validators_list() {

// add_validator should take effect in the session after next, provided the keys have been
// set
assert_ok!(Session::set_keys(RuntimeOrigin::signed(4), 4.into(), vec![]));
let val = 4;
let mut key = MockSessionKeys { mock: UintAuthorityId(val) };
assert_ok!(Session::set_keys(
RuntimeOrigin::signed(val),
key.clone(),
key.create_ownership_proof(&val.encode()).unwrap().encode(),
));
assert_eq!(active_validators(), HashSet::from([1, 2, 3]));
next_session();
assert_eq!(active_validators(), HashSet::from([1, 2, 3]));
Expand Down
12 changes: 9 additions & 3 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ fn validate_purge_keys(who: &AccountId) -> TransactionValidity {
Clone,
PartialEq,
Eq,
sp_runtime::RuntimeDebug,
Debug,
codec::Encode,
codec::Decode,
codec::DecodeWithMemTracking,
Expand Down Expand Up @@ -752,8 +752,8 @@ impl_runtime_apis! {
}

impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
opaque::SessionKeys::generate(seed)
fn generate_session_keys(owner: Vec<u8>, seed: Option<Vec<u8>>) -> sp_session::OpaqueGeneratedSessionKeys {
opaque::SessionKeys::generate(&owner, seed).into()
}

fn decode_session_keys(
Expand Down Expand Up @@ -917,6 +917,12 @@ impl_runtime_apis! {
}
}

impl sp_transaction_storage_proof::runtime_api::TransactionStorageApi<Block> for Runtime {
fn retention_period() -> NumberFor<Block> {
TransactionStorage::retention_period()
}
}

#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn benchmark_metadata(extra: bool) -> (
Expand Down
14 changes: 10 additions & 4 deletions runtimes/bulletin-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ impl pallet_sudo::Config for Runtime {
codec::Encode,
codec::Decode,
codec::DecodeWithMemTracking,
sp_runtime::RuntimeDebug,
Debug,
codec::MaxEncodedLen,
scale_info::TypeInfo,
)]
Expand Down Expand Up @@ -496,7 +496,7 @@ fn validate_purge_keys(who: &AccountId) -> TransactionValidity {
Clone,
PartialEq,
Eq,
sp_runtime::RuntimeDebug,
Debug,
codec::Encode,
codec::Decode,
codec::DecodeWithMemTracking,
Expand Down Expand Up @@ -940,8 +940,8 @@ impl_runtime_apis! {
}

impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
opaque::SessionKeys::generate(seed)
fn generate_session_keys(owner: Vec<u8>, seed: Option<Vec<u8>>) -> sp_session::OpaqueGeneratedSessionKeys {
opaque::SessionKeys::generate(&owner, seed).into()
}

fn decode_session_keys(
Expand Down Expand Up @@ -1105,6 +1105,12 @@ impl_runtime_apis! {
}
}

impl sp_transaction_storage_proof::runtime_api::TransactionStorageApi<Block> for Runtime {
fn retention_period() -> NumberFor<Block> {
TransactionStorage::retention_period()
}
}

#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn benchmark_metadata(extra: bool) -> (
Expand Down
4 changes: 2 additions & 2 deletions runtimes/bulletin-polkadot/src/polkadot_bridge_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ pub mod bp_people_polkadot {
Parachain,
};
use frame_support::{dispatch::DispatchClass, weights::Weight};
use sp_runtime::{RuntimeDebug, StateVersion};
use sp_runtime::StateVersion;

/// PeoplePolkadot parachain.
#[derive(RuntimeDebug)]
#[derive(Debug)]
pub struct PeoplePolkadot;

impl Chain for PeoplePolkadot {
Expand Down
23 changes: 18 additions & 5 deletions runtimes/bulletin-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ pub use sp_runtime::BuildStorage;
use sp_runtime::{
generic, impl_opaque_keys,
traits::{
AsSystemOriginSigner, Block as BlockT, DispatchInfoOf, Implication, PostDispatchInfoOf,
AsSystemOriginSigner, Block as BlockT, DispatchInfoOf, Implication, NumberFor,
PostDispatchInfoOf,
},
transaction_validity::{
TransactionSource, TransactionValidity, TransactionValidityError, ValidTransaction,
Expand Down Expand Up @@ -267,7 +268,7 @@ impl pallet_timestamp::Config for Runtime {
Clone,
PartialEq,
Eq,
sp_runtime::RuntimeDebug,
Debug,
codec::Encode,
codec::Decode,
codec::DecodeWithMemTracking,
Expand Down Expand Up @@ -709,8 +710,8 @@ impl_runtime_apis! {
}

impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
SessionKeys::generate(seed)
fn generate_session_keys(owner: Vec<u8>, seed: Option<Vec<u8>>) -> sp_session::OpaqueGeneratedSessionKeys {
SessionKeys::generate(&owner, seed).into()
}

fn decode_session_keys(
Expand Down Expand Up @@ -846,6 +847,12 @@ impl_runtime_apis! {
}
}

impl sp_transaction_storage_proof::runtime_api::TransactionStorageApi<Block> for Runtime {
fn retention_period() -> NumberFor<Block> {
TransactionStorage::retention_period()
}
}

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
Expand Down Expand Up @@ -896,6 +903,7 @@ impl_runtime_apis! {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;
use codec::Encode;

use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {
Expand All @@ -910,7 +918,12 @@ impl_runtime_apis! {
}

use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
impl cumulus_pallet_session_benchmarking::Config for Runtime {
fn generate_session_keys_and_proof(owner: Self::AccountId) -> (Self::Keys, Vec<u8>) {
let keys = SessionKeys::generate(&owner.encode(), None);
(keys.keys, keys.proof.encode())
}
}

use xcm::latest::prelude::*;
use xcm_config::TokenRelayLocation;
Expand Down