Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridges: Making relayer compatible with runtime upgrades #4256

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

svyatonik
Copy link
Contributor

See paritytech/parity-bridges-common#2956 for details
Relayer PR: paritytech/parity-bridges-common#2969
Would be better to have paritytech/parity-bridges-common#2947 implemented before

Main changes here:

  1. added RelayerVersion struct with two fields: auto is H256, computed with a tests. When it changes, it means that existing relayer is no longer compatible with new runtime. manual should be bumped in that case. manual can also be bumped if there are breaking changes, not covered by the tests;
  2. every bridge pallet now has this RelayerVersion as a constant in a pallet configuration;
  3. every relayer (finality, parachains, messages) has the RelayerVersion as a constant in a pipeline configuration;
  4. before submitting a transaction, relayer checks that its constant matches the constant in runtime. If it matches, tx is submitted. Otherwise, relayer aborts if offchain.manual <= onchain.manual and keep working otherwise.

…pallet_bridge_grandpa + tests to ensure GRANDPA relayer compatibility
…f filters to generate signed extension identifier + renamed refund extensions to "ComplexRefund" - we will change it in upcoming upgrade
… + tests to ensure parachains relayer compatibility
… tests to ensure messages relayer compatibility
… are upgraded to metadata v15, we will be able to fetch that using regural state_metadata call (given that we will be able to parse metadata from rust code)
@svyatonik svyatonik added the T15-bridges This PR/Issue is related to bridges. label Apr 23, 2024
@svyatonik svyatonik requested a review from a team April 23, 2024 11:01
@svyatonik svyatonik changed the title Sv bridge relayer compatibility tests Bridges: Making relayer compatible with runtime upgrades Apr 23, 2024
@svyatonik
Copy link
Contributor Author

Latest commit introduces some important changes:

  • BridgeRejectObsoleteHeadersAndMessages::IDENTIFIER is now generated as BridgeReject_ ++ hash of stringified filter types, passed to the generate_bridge_reject_obsolete_headers_and_messages macro. It means that the IDENTIFIER may change even if e.g. type alias, used in some filter is changed. That's why the second change;
  • now relayer only checks the RelayerVersion::manual field and ignores the RelayerVersion::auto field. So even if IDENTIFIER is changed ^^^, but semantically extensions stays the same, relayer won't break;

github-merge-queue bot pushed a commit that referenced this pull request May 3, 2024
Due to recent bump of Rococo/Westend versions + the fact that
paritytech/parity-bridges-common#2894 has
finally reached this repo, tests now fail, because we've started
checking all client versions (even source) unless we specify
`--source-version-mode Auto` in CLI arguments. This looks like an
overkill, but all those version checks will be fixed by
#4256, so now it makes
sense just to add this CLI option. We also need to propagate it to
running relays eventually.
@@ -403,9 +403,9 @@ impl<C: Chain> Client<C> {
}

/// Return runtime version.
pub async fn runtime_version(&self) -> Result<RuntimeVersion> {
pub async fn runtime_version(&self, at: HeaderIdOf<C>) -> Result<RuntimeVersion> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we only need the hash here and also looks like sometimes we want to query the runtime version at the latest block. So could we do at: Option<C::Hash> ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to HashOf. All places where the latest block is used (version guards) shall be removed once this update is applied, so no Option<_>

bridges/relays/lib-substrate-relay/src/finality/mod.rs Outdated Show resolved Hide resolved
//! version every time one of chains is upgraded. Recently we have "eased" our
//! requirements and now only watch for bridge hub versions (2 chains).
//!
//! What we are trying to solve with that:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems quite complex to me. I think my personal preference would be to keep only the manual version for simplicity. I'm not totally sure. I'll spend some more time thinking about it. Also I'm curious what others think as well.

@paritytech-review-bot paritytech-review-bot bot requested a review from a team May 6, 2024 13:10
svyatonik added a commit that referenced this pull request May 8, 2024
Due to recent bump of Rococo/Westend versions + the fact that
paritytech/parity-bridges-common#2894 has
finally reached this repo, tests now fail, because we've started
checking all client versions (even source) unless we specify
`--source-version-mode Auto` in CLI arguments. This looks like an
overkill, but all those version checks will be fixed by
#4256, so now it makes
sense just to add this CLI option. We also need to propagate it to
running relays eventually.
@bkontur
Copy link
Contributor

bkontur commented Jul 3, 2024

I think this RFC with transaction/signed extension version: polkadot-fellows/RFCs#99 could also simplify/avoid lots of these code probably

TarekkMA pushed a commit to moonbeam-foundation/polkadot-sdk that referenced this pull request Aug 2, 2024
Due to recent bump of Rococo/Westend versions + the fact that
paritytech/parity-bridges-common#2894 has
finally reached this repo, tests now fail, because we've started
checking all client versions (even source) unless we specify
`--source-version-mode Auto` in CLI arguments. This looks like an
overkill, but all those version checks will be fixed by
paritytech#4256, so now it makes
sense just to add this CLI option. We also need to propagate it to
running relays eventually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T15-bridges This PR/Issue is related to bridges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants