Skip to content

Commit 81e1c23

Browse files
authored
Bump PolakotSDK to the latest (#155)
* Bump latest Polkadot-SDK * Compile fixes - part 1 * More compile * More compile * fmt * CI change order and add zombienet log to artifacts * fmt * Nit * Get the logs from the last failed * Nit * Nit * Just logs * Nit * Nit * Let's not use tmp for sharing between steps * Nit * Nit * Fix test for session keys * Fix benchmarks * Fix for retention period * Nit * Add TransactionStorageApi runtime API to all runtimes * clippy
1 parent e1b9cb0 commit 81e1c23

File tree

10 files changed

+775
-673
lines changed

10 files changed

+775
-673
lines changed

Cargo.lock

Lines changed: 575 additions & 535 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 119 additions & 119 deletions
Large diffs are not rendered by default.

node/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ polkadot-bulletin-chain-runtime = { workspace = true }
7979
# Polkadot production
8080
bulletin-polkadot-runtime = { workspace = true }
8181

82+
# TODO: remove when bulletin-polkadot is upgraded live with TX storage runtime API
83+
pallet-transaction-storage = { workspace = true }
84+
8285
[build-dependencies]
8386
substrate-build-script-utils = { workspace = true }
8487

node/src/fake_runtime_api.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ sp_api::impl_runtime_apis! {
102102
}
103103

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

@@ -210,6 +210,12 @@ sp_api::impl_runtime_apis! {
210210
}
211211
}
212212

213+
impl sp_transaction_storage_proof::runtime_api::TransactionStorageApi<Block> for Runtime {
214+
fn retention_period() -> sp_runtime::traits::NumberFor<Block> {
215+
unimplemented!()
216+
}
217+
}
218+
213219
#[cfg(feature = "try-runtime")]
214220
impl frame_try_runtime::TryRuntime<Block> for Runtime {
215221
fn on_runtime_upgrade(_: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {

node/src/service.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use sc_consensus_grandpa::SharedVoterState;
77
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
88
use sc_telemetry::{Telemetry, TelemetryWorker};
99
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
10+
use sp_api::{ApiExt, ProvideRuntimeApi};
1011
use sp_consensus_babe::inherents::BabeCreateInherentDataProviders;
12+
use sp_transaction_storage_proof::runtime_api::TransactionStorageApi;
1113
use std::{sync::Arc, time::Duration};
1214

1315
pub(crate) type FullClient = sc_service::TFullClient<
@@ -306,10 +308,27 @@ pub fn new_full<
306308
slot_duration,
307309
);
308310

311+
// Get the retention period for a proof.
312+
let retention_period = {
313+
let has_tx_storage_api = client_clone
314+
.runtime_api()
315+
.has_api::<dyn TransactionStorageApi<Block>>(parent)
316+
.unwrap_or(false);
317+
if has_tx_storage_api {
318+
client_clone.runtime_api().retention_period(parent)?
319+
} else {
320+
// Fallback for solochain runtimes that do not yet have the transaction
321+
// storage API. TODO: remove once bulletin-polkadot is upgraded
322+
// with the TX storage runtime API. TODO: also remove the
323+
// pallet_transaction_storage dependency.
324+
pallet_transaction_storage::DEFAULT_RETENTION_PERIOD
325+
}
326+
};
309327
let storage_proof =
310328
sp_transaction_storage_proof::registration::new_data_provider(
311329
&*client_clone,
312330
&parent,
331+
retention_period,
313332
)?;
314333

315334
Ok((slot, timestamp, storage_proof))

pallets/validator-set/src/tests.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
#![cfg(test)]
2020

2121
use super::mock::{
22-
new_test_ext, next_block, next_session, AccountId, RuntimeOrigin, Session, System, Test,
23-
ValidatorSet,
22+
new_test_ext, next_block, next_session, AccountId, MockSessionKeys, RuntimeOrigin, Session,
23+
System, Test, ValidatorSet,
2424
};
2525
use polkadot_sdk_frame::{
26-
deps::sp_runtime::Perbill, prelude::*, testing_prelude::*, traits::ValidatorRegistration,
26+
deps::sp_runtime::{testing::UintAuthorityId, Perbill},
27+
prelude::*,
28+
testing_prelude::*,
29+
traits::ValidatorRegistration,
2730
};
2831
use sp_staking::offence::{OffenceDetails, OnOffenceHandler};
2932
use std::collections::HashSet;
@@ -55,7 +58,13 @@ fn add_validator_updates_validators_list() {
5558

5659
// add_validator should take effect in the session after next, provided the keys have been
5760
// set
58-
assert_ok!(Session::set_keys(RuntimeOrigin::signed(4), 4.into(), vec![]));
61+
let val = 4;
62+
let mut key = MockSessionKeys { mock: UintAuthorityId(val) };
63+
assert_ok!(Session::set_keys(
64+
RuntimeOrigin::signed(val),
65+
key.clone(),
66+
key.create_ownership_proof(&val.encode()).unwrap().encode(),
67+
));
5968
assert_eq!(active_validators(), HashSet::from([1, 2, 3]));
6069
next_session();
6170
assert_eq!(active_validators(), HashSet::from([1, 2, 3]));

runtime/src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ fn validate_purge_keys(who: &AccountId) -> TransactionValidity {
452452
Clone,
453453
PartialEq,
454454
Eq,
455-
sp_runtime::RuntimeDebug,
455+
Debug,
456456
codec::Encode,
457457
codec::Decode,
458458
codec::DecodeWithMemTracking,
@@ -752,8 +752,8 @@ impl_runtime_apis! {
752752
}
753753

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

759759
fn decode_session_keys(
@@ -917,6 +917,12 @@ impl_runtime_apis! {
917917
}
918918
}
919919

920+
impl sp_transaction_storage_proof::runtime_api::TransactionStorageApi<Block> for Runtime {
921+
fn retention_period() -> NumberFor<Block> {
922+
TransactionStorage::retention_period()
923+
}
924+
}
925+
920926
#[cfg(feature = "runtime-benchmarks")]
921927
impl frame_benchmarking::Benchmark<Block> for Runtime {
922928
fn benchmark_metadata(extra: bool) -> (

runtimes/bulletin-polkadot/src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl pallet_sudo::Config for Runtime {
383383
codec::Encode,
384384
codec::Decode,
385385
codec::DecodeWithMemTracking,
386-
sp_runtime::RuntimeDebug,
386+
Debug,
387387
codec::MaxEncodedLen,
388388
scale_info::TypeInfo,
389389
)]
@@ -496,7 +496,7 @@ fn validate_purge_keys(who: &AccountId) -> TransactionValidity {
496496
Clone,
497497
PartialEq,
498498
Eq,
499-
sp_runtime::RuntimeDebug,
499+
Debug,
500500
codec::Encode,
501501
codec::Decode,
502502
codec::DecodeWithMemTracking,
@@ -940,8 +940,8 @@ impl_runtime_apis! {
940940
}
941941

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

947947
fn decode_session_keys(
@@ -1105,6 +1105,12 @@ impl_runtime_apis! {
11051105
}
11061106
}
11071107

1108+
impl sp_transaction_storage_proof::runtime_api::TransactionStorageApi<Block> for Runtime {
1109+
fn retention_period() -> NumberFor<Block> {
1110+
TransactionStorage::retention_period()
1111+
}
1112+
}
1113+
11081114
#[cfg(feature = "runtime-benchmarks")]
11091115
impl frame_benchmarking::Benchmark<Block> for Runtime {
11101116
fn benchmark_metadata(extra: bool) -> (

runtimes/bulletin-polkadot/src/polkadot_bridge_config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ pub mod bp_people_polkadot {
9191
Parachain,
9292
};
9393
use frame_support::{dispatch::DispatchClass, weights::Weight};
94-
use sp_runtime::{RuntimeDebug, StateVersion};
94+
use sp_runtime::StateVersion;
9595

9696
/// PeoplePolkadot parachain.
97-
#[derive(RuntimeDebug)]
97+
#[derive(Debug)]
9898
pub struct PeoplePolkadot;
9999

100100
impl Chain for PeoplePolkadot {

runtimes/bulletin-westend/src/lib.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ pub use sp_runtime::BuildStorage;
6767
use sp_runtime::{
6868
generic, impl_opaque_keys,
6969
traits::{
70-
AsSystemOriginSigner, Block as BlockT, DispatchInfoOf, Implication, PostDispatchInfoOf,
70+
AsSystemOriginSigner, Block as BlockT, DispatchInfoOf, Implication, NumberFor,
71+
PostDispatchInfoOf,
7172
},
7273
transaction_validity::{
7374
TransactionSource, TransactionValidity, TransactionValidityError, ValidTransaction,
@@ -267,7 +268,7 @@ impl pallet_timestamp::Config for Runtime {
267268
Clone,
268269
PartialEq,
269270
Eq,
270-
sp_runtime::RuntimeDebug,
271+
Debug,
271272
codec::Encode,
272273
codec::Decode,
273274
codec::DecodeWithMemTracking,
@@ -709,8 +710,8 @@ impl_runtime_apis! {
709710
}
710711

711712
impl sp_session::SessionKeys<Block> for Runtime {
712-
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
713-
SessionKeys::generate(seed)
713+
fn generate_session_keys(owner: Vec<u8>, seed: Option<Vec<u8>>) -> sp_session::OpaqueGeneratedSessionKeys {
714+
SessionKeys::generate(&owner, seed).into()
714715
}
715716

716717
fn decode_session_keys(
@@ -846,6 +847,12 @@ impl_runtime_apis! {
846847
}
847848
}
848849

850+
impl sp_transaction_storage_proof::runtime_api::TransactionStorageApi<Block> for Runtime {
851+
fn retention_period() -> NumberFor<Block> {
852+
TransactionStorage::retention_period()
853+
}
854+
}
855+
849856
#[cfg(feature = "try-runtime")]
850857
impl frame_try_runtime::TryRuntime<Block> for Runtime {
851858
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
@@ -896,6 +903,7 @@ impl_runtime_apis! {
896903
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
897904
use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
898905
use sp_storage::TrackedStorageKey;
906+
use codec::Encode;
899907

900908
use frame_system_benchmarking::Pallet as SystemBench;
901909
impl frame_system_benchmarking::Config for Runtime {
@@ -910,7 +918,12 @@ impl_runtime_apis! {
910918
}
911919

912920
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
913-
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
921+
impl cumulus_pallet_session_benchmarking::Config for Runtime {
922+
fn generate_session_keys_and_proof(owner: Self::AccountId) -> (Self::Keys, Vec<u8>) {
923+
let keys = SessionKeys::generate(&owner.encode(), None);
924+
(keys.keys, keys.proof.encode())
925+
}
926+
}
914927

915928
use xcm::latest::prelude::*;
916929
use xcm_config::TokenRelayLocation;

0 commit comments

Comments
 (0)