Skip to content

Add XCM Precompile to Pallet Revive#8471

Closed
sphamjoli wants to merge 42 commits intomasterfrom
spha/xcm_precompile
Closed

Add XCM Precompile to Pallet Revive#8471
sphamjoli wants to merge 42 commits intomasterfrom
spha/xcm_precompile

Conversation

@sphamjoli
Copy link
Copy Markdown
Member

Create a unified precompile address that handles xcmExecute and xcmSend operations for devs to call via solidity using abi encodings.

See tracking parent issue

@sphamjoli sphamjoli requested review from a team and athei May 8, 2025 20:17
@sphamjoli sphamjoli requested a review from bkontur May 9, 2025 12:42
@franciscoaguirre franciscoaguirre added T6-XCM This PR/Issue is related to XCM. T7-smart_contracts This PR/Issue is related to smart contracts. labels May 9, 2025
@sphamjoli sphamjoli marked this pull request as ready for review May 9, 2025 15:19
//! Use `alloy` through our re-export in this module to implement Eth ABI.

mod builtin;
pub mod custom;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be either exist inside bultin or outside of pallet-revive. I would prefer the latter (for example implement Precompile on pallet_xcm. Then we can remove all the dependencies to xcm from pallet_revive.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think given the cutoff date for stable2506, it might be fine to leave it where it is and then move it

Copy link
Copy Markdown
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

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

high-level everything looks good, I would also like to see it integrated with asset-hub-westend-runtime too not just mock runtime from pallet-revive


match input {
IXcmCalls::xcmSend(IXcm::xcmSendCall { destination, message }) => {
let final_destination = xcm::VersionedLocation::decode_all(&mut &destination[..])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This precompile will be updated to only support the latest versions, since Versioned* types only support the latest 3 XCM versions. With this, XCMs crafted in SCs should always be upgradable. Probably the pattern here (for mad people) is to put XCMs in a storage item so you can update them when needed. We need another higher level precompile to make everyone's lives easier

@athei
Copy link
Copy Markdown
Member

athei commented May 14, 2025

You should get your editor under control. Or run fmt before pushing.

@athei
Copy link
Copy Markdown
Member

athei commented May 14, 2025

/cmd fmt

Comment on lines +270 to +272
/// The weigher used to calculate XCM execution costs
#[pallet::no_default_bounds]
type XcmWeigher: xcm_executor::traits::WeightBounds<<Self as frame_system::Config>::RuntimeCall>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't we add this bound to the existing Xcm associated type? I think its all implemented by pallet_xcm anyways.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Since we moving the precompile anyways would it make sense to make changes in pallet_xcm to achieve this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The right thing to do would be to define the pre-compile in pallet_xcm.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This pre-compile does not charge any weight whatsoever. Please look into the already existing xcm_execute and xcm_send functions in this pallet. It is just migrating existing logic to a pre-compile.

Comment on lines +270 to +274
/// The weigher used to calculate XCM execution costs
#[pallet::no_default_bounds]
type XcmWeigher: xcm_executor::traits::WeightBounds<
<Self as frame_system::Config>::RuntimeCall,
>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't we just add the bound to the Xcm associated type? It is all implemented by pallet_xcm anyways AFAIK.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, this is currently a runtime configuration object, also being set to the xcm-executor, not pallet-xcm. We should consolidate it somehow to not have to set it twice (pallet-revive and xcm-executor), but this is not trivial and “nice-to-have” at this point IMO

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When suggesting to move it to builtin I assumed you would add it to the Production type alias. As this is the way to expose Builtin pre-compiles. However, this won't be possible since builtin pre-compiles are forced to use a different address range.

And since we are planning to move it out of the pallet eventually we need to use an external address range. Otherwise we won't be able to migrate it.

Sorry for the confusion. Just move the xcm.rs as direct sub module of precompiles.rs.

@acatangiu
Copy link
Copy Markdown
Contributor

@Brianspha @franciscoaguirre I agree with @athei that the XCM precompiles should be implemented by pallet-xcm and not pallet-revive.
If we can achieve that by deadline (tomorrow), that would be great. But if not, I propose we go ahead with the current implementation as we can change it during qa period.
The important bit we need to agree on is the SC interface as that we don’t want to change.
The underlying rust code we can commit to move/improve quickly after deadline as fix PR.

@athei wdyt?

@tiagobndr
Copy link
Copy Markdown
Contributor

@Brianspha @franciscoaguirre I agree with @athei that the XCM precompiles should be implemented by pallet-xcm and not pallet-revive. If we can achieve that by deadline (tomorrow), that would be great. But if not, I propose we go ahead with the current implementation as we can change it during qa period. The important bit we need to agree on is the SC interface as that we don’t want to change. The underlying rust code we can commit to move/improve quickly after deadline as fix PR.

@athei wdyt?

Regarding the interface, I believe it is mature enough. There is some query-related functionality we might want to add to this precompile later but that's not part of this PR. As for tomorrow's deadline, I’d be cautious about migrating the precompile to pallet-xcm (even though I recognise its advantages) due to the limited time only. It's not just the implementation, it'd also require additional testing and review.

@paritytech-workflow-stopper
Copy link
Copy Markdown

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/15031907799
Failed job name: test-linux-stable

@athei
Copy link
Copy Markdown
Member

athei commented May 15, 2025

@Brianspha @franciscoaguirre I agree with @athei that the XCM precompiles should be implemented by pallet-xcm and not pallet-revive. If we can achieve that by deadline (tomorrow), that would be great. But if not, I propose we go ahead with the current implementation as we can change it during qa period. The important bit we need to agree on is the SC interface as that we don’t want to change. The underlying rust code we can commit to move/improve quickly after deadline as fix PR.

@athei wdyt?

I don't think it is realistic to have this pre-compile in a state that I feel comfortable to expose it until today anyways. And its value without query support is kinda non existent anyways. I don't get the rush.

@franciscoaguirre
Copy link
Copy Markdown
Contributor

@athei I agree this belongs in pallet-xcm (or some other XCM crate). We shouldn't rush it and do things properly. Especially to avoid breaking changes in the future

@sphamjoli
Copy link
Copy Markdown
Member Author

Closing the PR since we need to move all xcm related dependencies to pallet-xcm

@sphamjoli sphamjoli closed this May 15, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jun 11, 2025
This PR adds the XCM precompile (with `xcmSend`, `xcmExecute` and
`weightMessage` functionalities) to `pallet-xcm`.

This follows the discussion we had on the now closed
[PR](#8471), which
attempted to add the precompile to `pallet-revive`, but that approach
would have introduced unwanted cyclic dependencies. That's why we
decided to migrate the precompile to `pallet-xcm`, avoiding adding
unnecessary dependencies to `pallet-revive`.

This PR should also encapsulate unit tests in `precompiles.rs` as well
as integration tests under
`cumulus/parachains/integration-tests/emulated/tests`.

See tracking parent
[issue](#6718)

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Siphamandla Mjoli <brianm445@yahoo.com>
Co-authored-by: Siphamandla Mjoli <siphamandla@parity.io>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
Co-authored-by: PG Herveou <pgherveou@gmail.com>
@franciscoaguirre franciscoaguirre deleted the spha/xcm_precompile branch October 3, 2025 15:59
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
This PR adds the XCM precompile (with `xcmSend`, `xcmExecute` and
`weightMessage` functionalities) to `pallet-xcm`.

This follows the discussion we had on the now closed
[PR](#8471), which
attempted to add the precompile to `pallet-revive`, but that approach
would have introduced unwanted cyclic dependencies. That's why we
decided to migrate the precompile to `pallet-xcm`, avoiding adding
unnecessary dependencies to `pallet-revive`.

This PR should also encapsulate unit tests in `precompiles.rs` as well
as integration tests under
`cumulus/parachains/integration-tests/emulated/tests`.

See tracking parent
[issue](#6718)

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Siphamandla Mjoli <brianm445@yahoo.com>
Co-authored-by: Siphamandla Mjoli <siphamandla@parity.io>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
Co-authored-by: PG Herveou <pgherveou@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T6-XCM This PR/Issue is related to XCM. T7-smart_contracts This PR/Issue is related to smart contracts.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants