You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A0-4216: Does not depend on actual runtime API in aleph-node (#1668)
tl;dr
Goal of this PR is to have only chainspec generation as only
`aleph-runtime` dependency in `aleph-node`.
In aleph-node, we depend on aleph-runtimes RuntimeAPI type. This is not
required, as per
aleph-zero-foundation/polkadot-sdk@e53d15a
:
> These runtime api implementations are only used to make the compiler
think that we have implemented all required runtime apis. They will
notbe called as we switch the executor to WasmExecutor. In the
nearfuture we will not require these fake implementations anymore
afterSubstrate has shifted away from this compile time requirement.This
brings us the advantage that the polkadot-service doesn't need todepend
on the runtimes for getting the RuntimeApi also removes around 1min of
build time on my machine ;)
1. To achieve so we need to implement similar idea like
https://github.com/Cardinal-Cryptography/polkadot-sdk/blob/aleph-v1.4.0/polkadot/node/service/src/fake_runtime_api.rs
into our `aleph-node` binary
2. There’s an important remark on how this fake runtime must be
implemented - it does not need to have all the same entries like
[`impl_runtime_apis!`](https://github.com/Cardinal-Cryptography/aleph-node/blob/main/bin/runtime/src/lib.rs#L1001-L1259)
has - in particular, it does not need an implementation for
* `pallet_nomination_pools_runtime_api::NominationPoolsApi`
* `pallet_staking_runtime_api::StakingApi`
* `pallet_contracts::ContractsApi`
ie, code compiles without them, even though real runtime has those. Why?
Because this fake runtime API is only used only for sake of compilation:
* for explicit calls in aleph-node to runtime API, e.g. [this requires
primitives::AlephSessionApi to be implemented for
fake_runtime_api](https://github.com/Cardinal-Cryptography/aleph-node/blob/main/bin/node/src/service.rs#L200)
* [because of trait bounds when creating RPC client in
node](https://github.com/Cardinal-Cryptography/aleph-node/blob/main/bin/node/src/rpc.rs#L49-L51)
* [because of RPC modules to include in
node](https://github.com/Cardinal-Cryptography/aleph-node/blob/main/bin/node/src/rpc.rs#L69-L83)
3. We use runtime’s SessionKeys, not opaque::SessionKeys when impl
sp_session::SessionKeys<Block> for Runtime - this is because Polkadot
and other parachains do the same, and code compiles after the change.
4. Unifications of imports of primitives in aleph-node.
5. Use fake_runtime in `finality-aleph`'s tests - no more aleph-runtime
dependency!
6. Bumped `version` of `primitives` to be 0.14.0+dev - primitives needs
to be versioned the same as runtime
0 commit comments