Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A0-4213: Move aleph-runtime dependency in finality-aleph to dev-depen…
…dencies (#1665) # Description This PR moves `aleph-runtime` dependency to `dev-dependencies` in `finality-aleph`. The only reason we have normal dependency is that in `finality-aleph` we read storage `Session.QueuedKeys`, and that storage type is `SessionKeys` type from `aleph-runtime`. We move that type to `primitives`, which breaks normal dependency in `finality-aleph`. The reason this can be moved is that currently in `aleph-runtime`, `SessionKeys` are generated using `impl_opaque_keys` macro. You can use `cargo expand` too see that ``` use ::sp_runtime::serde as __opaque_keys_serde_import__SessionKeys; #[serde(crate = "__opaque_keys_serde_import__SessionKeys")] pub struct SessionKeys { pub aura: <Aura as ::sp_runtime::BoundToRuntimeAppPublic>::Public, pub aleph: <Aleph as ::sp_runtime::BoundToRuntimeAppPublic>::Public, } ``` So we see that `aura` and `aleph` fields are some public key types, retrieved from `pallet-aura` and `pallet-aleph`, that both implement `BoundToRuntimeAppPublic` trait, example for [Aura](https://github.com/Cardinal-Cryptography/polkadot-sdk/blob/aleph-v1.3.0/substrate/frame/aura/src/lib.rs#L312). `AuthorityId` is defined in `aleph-runtime` as ``` impl pallet_aura::Config for Runtime { type MaxAuthorities = MaxAuthorities; type AuthorityId = AuraId; ... } ``` and for `pallet-aleph` ``` impl pallet_aleph::Config for Runtime { type AuthorityId = AlephId; ... } ``` Where `AuraId` and `AlephId` are types from `primitives. So really what `cargo expand` tell us is `SessionKeys` is just a below struct ``` use ::sp_runtime::serde as __opaque_keys_serde_import__SessionKeys; #[serde(crate = "__opaque_keys_serde_import__SessionKeys")] pub struct SessionKeys { pub aura: AuraId, pub aleph: AlephId, } ``` In this PR, we propose to just implement session keys in `primites` as ``` impl_opaque_keys! { pub struct AlephNodeSessionKeys { pub aura: AuraId, pub aleph: AuthorityId, } } ``` This expands via `cargo expand` to ``` use ::sp_runtime::serde as __opaque_keys_serde_import__AlephNodeSessionKeys; #[serde(crate = "__opaque_keys_serde_import__AlephNodeSessionKeys")] pub struct AlephNodeSessionKeys { pub aura: <AuraId as ::sp_runtime::BoundToRuntimeAppPublic>::Public, pub aleph: <AuthorityId as ::sp_runtime::BoundToRuntimeAppPublic>::Public, } ``` Now this is not entirely the same implementation at the first glance, previously we had `<Aura as ::sp_runtime::BoundToRuntimeAppPublic>::Public` and now we have `<AuraId as ::sp_runtime::BoundToRuntimeAppPublic>::Public`, where `Aura` is `pallet-aura::pallet` and `AuraId` is `sp_consensus_aura::sr25519::AuthorityId`. This compiles successfully though and import from genesis test works. The reason it compiles is that there's a [default implementation](https://github.com/Cardinal-Cryptography/polkadot-sdk/blob/aleph-v1.3.0/substrate/primitives/application-crypto/src/traits.rs#L195-L197) of `BoundToRuntimeAppPublic` for all types that are `RuntimeAppPublic`, and both `AuraId` and `AlephId` must implement `RuntimeAppPublic`. ## Type of change Please delete options that are not relevant. - New feature (non-breaking change which adds functionality)
- Loading branch information