Skip to content

Commit

Permalink
[async_backing] Bump ParachainHost to api version 10 on polkadot (#222)
Browse files Browse the repository at this point in the history
This will enable async-backing subsystems on polkadot, the relaychain
would work in legacy mode where only candiddates built on top of
pervious relay chain are activated.

## Notes
- Had to bring an unrelated change as well `minimum_backing_votes`
because that was the v6, we can't skip versions, the value of that
configuration on polkadot is 2, so that's what is going to be used after
this runtime update. Changes have been running on kusama.
- `disabled_validators`, `node_features`, `approval_voting_params` are
not related with async-backing, but given they are low risk, we decided
to include them as well, see comments.

## Known risks

Async backing subsytems is a major change in the way collator-protocol
and the backing work, so there are still some unknowns if this is
completely bug free. It has been running on kusama for a month already,
but not without issues:
- Validators that did not upgrade to compatible versions will not be
able to participate in backing, so if enough of those are randomly
picked that group won't be able to back anything. With
backing_group_size = 5 and minimum_backing_votes = 2, 10% validator not
upgraded, that chance is about 2.5%.

- Additionally, same un-upgraded groups won't be able to include the
backing votes on chain when they author blocks, so 10% of the blocks
won't back any candidates.

- We are still not sure if item 2) from here
paritytech/polkadot-sdk#3314 (comment)
is caused by async backing, the observable issue is sometimes after
restart/upgrade some validators are getting 0 rewards and apparently
they are not backing anything.


<!-- Remember that you can run `/merge` to enable auto-merge in the PR
-->

<!-- Remember to modify the changelog. If you don't need to modify it,
you can check the following box.
Instead, if you have already modified it, simply delete the following
line. -->

---------

Signed-off-by: Alexandru Gheorghe <[email protected]>
Co-authored-by: fellowship-merge-bot[bot] <151052383+fellowship-merge-bot[bot]@users.noreply.github.com>
  • Loading branch information
alexggh and fellowship-merge-bot[bot] authored Mar 13, 2024
1 parent 9566967 commit 845da76
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Bump parachains runtime API to v9 in Kusama to enable the `node_features` function [polkadot-fellows/runtimes#194](https://github.com/polkadot-fellows/runtimes/pull/194)
- Bump parachains runtime API to v10 in Kusama to enable the `approval-voting-params` function [polkadot-fellows/runtimes#204](https://github.com/polkadot-fellows/runtimes/pull/204)
- Use Relay Chain's Treasury Pallet account as a destination for XCM fees on System Parachain ([polkadot-fellows/runtimes#191](https://github.com/polkadot-fellows/runtimes/pull/191))
- Bump parachains runtime API to v10 in Polkadot to enable async-backing subsystems(still in backwards compatible mode) [polkadot-fellows/runtimes#222](https://github.com/polkadot-fellows/runtimes/pull/222)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use emulated_integration_tests_common::{
impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain,
xcm_emulator::decl_test_relay_chains,
};
use polkadot_primitives::runtime_api::runtime_decl_for_parachain_host::ParachainHostV5;

// Polkadot declaration
decl_test_relay_chains! {
Expand Down
33 changes: 31 additions & 2 deletions relay/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ use runtime_parachains::{
inclusion::{AggregateMessageOrigin, UmpQueueId},
initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras,
paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points,
runtime_api_impl::v7 as parachains_runtime_api_impl,
runtime_api_impl::{
v7 as parachains_runtime_api_impl, vstaging as parachains_vstaging_api_impl,
},
scheduler as parachains_scheduler, session_info as parachains_session_info,
shared as parachains_shared,
};
Expand Down Expand Up @@ -70,7 +72,9 @@ use pallet_session::historical as session_historical;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use primitives::{
slashing, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
slashing,
vstaging::{ApprovalVotingParams, NodeFeatures},
AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash,
Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce,
OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature,
Expand Down Expand Up @@ -1971,6 +1975,7 @@ sp_api::impl_runtime_apis! {
}
}

#[api_version(10)]
impl primitives::runtime_api::ParachainHost<Block> for Runtime {
fn validators() -> Vec<ValidatorId> {
parachains_runtime_api_impl::validators::<Runtime>()
Expand Down Expand Up @@ -2101,6 +2106,30 @@ sp_api::impl_runtime_apis! {
key_ownership_proof,
)
}

fn minimum_backing_votes() -> u32 {
parachains_runtime_api_impl::minimum_backing_votes::<Runtime>()
}

fn para_backing_state(para_id: ParaId) -> Option<primitives::async_backing::BackingState> {
parachains_runtime_api_impl::backing_state::<Runtime>(para_id)
}

fn async_backing_params() -> primitives::AsyncBackingParams {
parachains_runtime_api_impl::async_backing_params::<Runtime>()
}

fn disabled_validators() -> Vec<ValidatorIndex> {
parachains_vstaging_api_impl::disabled_validators::<Runtime>()
}

fn node_features() -> NodeFeatures {
parachains_vstaging_api_impl::node_features::<Runtime>()
}

fn approval_voting_params() -> ApprovalVotingParams {
parachains_vstaging_api_impl::approval_voting_params::<Runtime>()
}
}

impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {
Expand Down

0 comments on commit 845da76

Please sign in to comment.