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

Relay chain client pallet for AH Staking #6259

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gpestana
Copy link
Contributor

This PR introduces a new pallet (pallet-staking-rc-client) which abstracts the interfaces that staking needs to interact with but, in the context of AHM, will be in a different consensus system (i.e. in the relay chain). This new pallet acts as a session and on-offence handler broker and sits in "between" the staking pallet in AH and the relay chain, while being part of the AH runtime.

The main design goal of this pallet is twofold:

  1. Implement a façade of the trait SessionManager and other interfaces in Asset Hub in a way that is transparent to the pallet staking. The current staking logic should have no changes (minimal at most) and it doesn't really care whether the session manager implementors and others are part of the AH runtime or in an external consensus system.
  2. Handle the async message flow from staking > relay chain and abstract it as much as possible, implementing caching and other strategies to mimmic as much as possible a sync flow between staking and the relay chain.

This PR also adds an integration test module where the behaviour between staking and the relay-chain pallets, brokered by pallet-staking-rc-client, can be tested as close as possible to the real case scenario of multi-chain communication.

Closes #6166

@gpestana gpestana added the T2-pallets This PR/Issue is related to a particular pallet. label Oct 28, 2024
@gpestana gpestana requested review from kianenigma and Ank4n October 28, 2024 09:54
@gpestana gpestana self-assigned this Oct 28, 2024
@gpestana gpestana marked this pull request as draft October 28, 2024 09:54

assert_eq!(Outbound::get(), vec![MockMessages::SetSessionKeys((1, keys, vec![0, 0, 0]))]);
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks overall good, but it is hard to measure how correct this is, before seeing an e2e usage. I think this pallet should have very few unit tests, and many RC + Para tests based on XCM emulator.

Copy link
Contributor Author

@gpestana gpestana Oct 28, 2024

Choose a reason for hiding this comment

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

Yes that's a good point. That's why I ended up adding the integration-tests crate before completing these pallet unit tests, as the integration tests will be more useful.

//! termination, performs pre-checks and propagates that information to another pallet or consensus
//! system through the [`crate::Config::SessionKeysHandler`].
//!
//! Callers can request to 1) set validator keys and 2) purge validator keys. These actions *may
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this any different from calling pallet_xcm::send_xcm(transact { relay_chain_call })? I suggest consulting with @franciscoaguirre in the high level of design of RC <> AH interaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
Status: In progress
Status: Scheduled
Development

Successfully merging this pull request may close these issues.

Design and implement pallet-staking-rc-client
2 participants