Skip to content

Commit 3318101

Browse files
authored
update to polkadot-stable2509, without backporting AURA authorities tracker (#1046)
1 parent e2d72cb commit 3318101

File tree

13 files changed

+784
-684
lines changed

13 files changed

+784
-684
lines changed

Cargo.lock

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

Cargo.toml

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
:chains: Toolkit for maintaining and securing [Substrate](https://polkadot.com/) based blockchains with the Cardano ecosystem
44

5-
![polkadot-sdk](https://img.shields.io/badge/polkadot--sdk-stable2506-blue)
5+
![polkadot-sdk](https://img.shields.io/badge/polkadot--sdk-stable2509-blue)
66
[![language](https://img.shields.io/badge/language-Rust-239120)]()
77
[![OS](https://img.shields.io/badge/OS-linux%2C%20macOS-0078D4)]()
88
[![CPU](https://img.shields.io/badge/CPU-x64%2C%20ARM64-FF8C00)]()

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ This changelog is based on [Keep A Changelog](https://keepachangelog.com/en/1.1.
66

77
## Changed
88

9+
* Updated polkadot-sdk dependency to polkadot-stable2509.
10+
Partner Chains Aura modification follows changes regarding checking inherents that are also present in the new polkadot-sdk release.
11+
Pallet Session new parameters should be: `type KeyDeposit = ();` and `type Currency = Balances;`.
912
* Updated partner-chains-smart-contracts (raw-scripts) dependency to v8.2.0. Not breaking.
1013
* `SessionManager` and `ShouldEndSession` implementations of `pallet-session-validator-management` rotate one additional
1114
session in order to make `pallet_session` use authorities with less delay.

demo/runtime/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ impl pallet_session::Config for Runtime {
314314
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
315315
type Keys = SessionKeys;
316316
type DisablingStrategy = pallet_session::disabling::UpToLimitWithReEnablingDisablingStrategy;
317+
type Currency = Balances;
318+
type KeyDeposit = ();
317319

318320
type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
319321
}

demo/runtime/src/mock.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl pallet_balances::Config for Test {
9898
type WeightInfo = pallet_balances::weights::SubstrateWeight<Test>;
9999
type FreezeIdentifier = ();
100100
type MaxFreezes = ();
101-
type RuntimeHoldReason = ();
101+
type RuntimeHoldReason = RuntimeHoldReason;
102102
type RuntimeFreezeReason = RuntimeFreezeReason;
103103
type DoneSlashHandler = ();
104104
}
@@ -149,6 +149,8 @@ impl pallet_session::Config for Test {
149149
type Keys = TestSessionKeys;
150150
type DisablingStrategy = pallet_session::disabling::UpToLimitWithReEnablingDisablingStrategy;
151151
type WeightInfo = pallet_session::weights::SubstrateWeight<Test>;
152+
type Currency = Balances;
153+
type KeyDeposit = ();
152154
}
153155

154156
impl pallet_sidechain::Config for Test {

substrate-extensions/aura/consensus/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ workspace = true
1818
[dependencies]
1919
async-trait = { workspace = true }
2020
parity-scale-codec = { workspace = true, default-features = true }
21+
fork-tree = { workspace = true, default-features = true }
2122
futures = { workspace = true }
2223
log = { workspace = true, default-features = true }
24+
parking_lot = { workspace = true, default-features = true }
2325
sc-client-api = { workspace = true, default-features = true }
2426
sc-consensus = { workspace = true, default-features = true }
2527
sc-consensus-aura = { workspace = true, default-features = true }

substrate-extensions/aura/consensus/src/import_queue.rs

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use sc_consensus_slots::{CheckedHeader, check_equivocation};
3535
use sc_telemetry::{CONSENSUS_DEBUG, CONSENSUS_TRACE, TelemetryHandle, telemetry};
3636
use sp_api::{ApiExt, ProvideRuntimeApi};
3737
use sp_block_builder::BlockBuilder as BlockBuilderApi;
38-
use sp_blockchain::HeaderBackend;
38+
use sp_blockchain::{HeaderBackend, HeaderMetadata};
3939
use sp_consensus::Error as ConsensusError;
4040
use sp_consensus_aura::AuraApi;
4141
use sp_consensus_slots::Slot;
@@ -107,25 +107,25 @@ where
107107
}
108108

109109
/// A verifier for Aura blocks, with added ID phantom type.
110-
pub struct AuraVerifier<C, P, CIDP, N, ID> {
110+
pub struct AuraVerifier<C, P: Pair, CIDP, B: BlockT, ID> {
111111
client: Arc<C>,
112112
create_inherent_data_providers: CIDP,
113113
check_for_equivocation: CheckForEquivocation,
114114
telemetry: Option<TelemetryHandle>,
115-
compatibility_mode: CompatibilityMode<N>,
115+
compatibility_mode: CompatibilityMode<NumberFor<B>>,
116116
_phantom: PhantomData<(fn() -> P, ID)>,
117117
}
118118

119-
impl<C, P, CIDP, N, ID> AuraVerifier<C, P, CIDP, N, ID> {
119+
impl<C, P: Pair, CIDP, B: BlockT, ID> AuraVerifier<C, P, CIDP, B, ID> {
120120
pub(crate) fn new(
121121
client: Arc<C>,
122122
create_inherent_data_providers: CIDP,
123123
check_for_equivocation: CheckForEquivocation,
124124
telemetry: Option<TelemetryHandle>,
125-
compatibility_mode: CompatibilityMode<N>,
125+
compatibility_mode: CompatibilityMode<NumberFor<B>>,
126126
) -> Self {
127127
Self {
128-
client,
128+
client: client.clone(),
129129
create_inherent_data_providers,
130130
check_for_equivocation,
131131
telemetry,
@@ -135,47 +135,16 @@ impl<C, P, CIDP, N, ID> AuraVerifier<C, P, CIDP, N, ID> {
135135
}
136136
}
137137

138-
impl<C, P, CIDP, N, ID> AuraVerifier<C, P, CIDP, N, ID>
139-
where
140-
CIDP: Send,
141-
{
142-
async fn check_inherents<B: BlockT>(
143-
&self,
144-
block: B,
145-
at_hash: B::Hash,
146-
inherent_data_providers: CIDP::InherentDataProviders,
147-
) -> Result<(), Error<B>>
148-
where
149-
C: ProvideRuntimeApi<B>,
150-
C::Api: BlockBuilderApi<B>,
151-
CIDP: CreateInherentDataProviders<B, (Slot, <ID as InherentDigest>::Value)>,
152-
ID: InherentDigest,
153-
{
154-
let inherent_data = create_inherent_data::<B>(&inherent_data_providers).await?;
155-
156-
let inherent_res = self
157-
.client
158-
.runtime_api()
159-
.check_inherents(at_hash, block, inherent_data)
160-
.map_err(|e| Error::Client(e.into()))?;
161-
162-
if !inherent_res.ok() {
163-
for (i, e) in inherent_res.into_errors() {
164-
match inherent_data_providers.try_handle_error(&i, &e).await {
165-
Some(res) => res.map_err(Error::Inherent)?,
166-
None => return Err(Error::UnknownInherentError(i)),
167-
}
168-
}
169-
}
170-
171-
Ok(())
172-
}
173-
}
174-
175138
#[async_trait::async_trait]
176-
impl<B: BlockT, C, P, CIDP, ID> Verifier<B> for AuraVerifier<C, P, CIDP, NumberFor<B>, ID>
139+
impl<B, C, P, CIDP, ID> Verifier<B> for AuraVerifier<C, P, CIDP, B, ID>
177140
where
178-
C: ProvideRuntimeApi<B> + Send + Sync + AuxStore,
141+
B: BlockT,
142+
C: HeaderBackend<B>
143+
+ HeaderMetadata<B, Error = sp_blockchain::Error>
144+
+ ProvideRuntimeApi<B>
145+
+ Send
146+
+ Sync
147+
+ sc_client_api::backend::AuxStore,
179148
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>> + ApiExt<B>,
180149
P: Pair,
181150
P::Public: Codec + Debug,
@@ -255,13 +224,17 @@ where
255224
.has_api_with::<dyn BlockBuilderApi<B>, _>(parent_hash, |v| v >= 2)
256225
.map_err(|e| e.to_string())?
257226
{
258-
self.check_inherents(
259-
new_block.clone(),
227+
let inherent_data =
228+
create_inherent_data::<B>(&inherent_data_providers).await?;
229+
sp_block_builder::check_inherents_with_data(
230+
self.client.clone(),
260231
parent_hash,
261-
inherent_data_providers,
232+
new_block.clone(),
233+
&inherent_data_providers,
234+
inherent_data,
262235
)
263236
.await
264-
.map_err(|e| e.to_string())?;
237+
.map_err(|e| format!("Error checking block inherents {:?}", e))?;
265238
}
266239

267240
let (_, inner_body) = new_block.deconstruct();
@@ -323,7 +296,8 @@ where
323296
+ Sync
324297
+ AuxStore
325298
+ UsageProvider<Block>
326-
+ HeaderBackend<Block>,
299+
+ HeaderBackend<Block>
300+
+ HeaderMetadata<Block, Error = sp_blockchain::Error>,
327301
I: BlockImport<Block, Error = ConsensusError> + Send + Sync + 'static,
328302
P: Pair + 'static,
329303
P::Public: Codec + Debug,

substrate-extensions/aura/consensus/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ mod tests {
449449
}
450450

451451
type AuraVerifier =
452-
import_queue::AuraVerifier<PeersFullClient, AuthorityPair, TestCIDP, u64, ()>;
452+
import_queue::AuraVerifier<PeersFullClient, AuthorityPair, TestCIDP, TestBlock, ()>;
453453
type AuraPeer = Peer<(), PeersClient>;
454454

455455
#[derive(Default)]

toolkit/committee-selection/pallet/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ frame-benchmarking = { workspace = true, optional = true }
3333

3434
[dev-dependencies]
3535
sp-io = { workspace = true }
36+
pallet-balances = { workspace = true }
3637

3738
[features]
3839
default = ["std"]

0 commit comments

Comments
 (0)