-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[XCM Precompile] Rename functions and improve docs in the Solidity interface #9023
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e8afceb
refactor: rename functions and improve docs in the Solidity interface
tiagobndr 4bc4644
chore: format the Solidity interface and add the XCM precompile address
tiagobndr a08114a
doc: add prdoc
tiagobndr 745f92a
Merge branch 'master' into tb/xcm_precompile_docs
tiagobndr 0a4fb3e
Update from github-actions[bot] running command 'fmt'
github-actions[bot] 45b9b26
fmt
tiagobndr a6c8ef2
doc: rm prdoc
tiagobndr 3d35356
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] 2fd7b28
Merge branch 'master' into tb/xcm_precompile_docs
sphamjoli d8b2054
Merge branch 'master' into tb/xcm_precompile_docs
tiagobndr 659fcfb
doc(interface): improve docs
tiagobndr 03d69c1
doc: update prdoc
tiagobndr d19db10
Merge branch 'master' into tb/xcm_precompile_docs
tiagobndr 04b699a
doc: fix natspec format
tiagobndr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,49 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.20; | ||
|
|
||
| /// @title Defines all functions that can be used to interact with XCM | ||
| /// @dev Parameters MUST use SCALE codec serialisation | ||
|
tiagobndr marked this conversation as resolved.
|
||
| /// @dev The on-chain address of the XCM (Cross-Consensus Messaging) precompile. | ||
| address constant XCM_PRECOMPILE_ADDRESS = address(0xA0000); | ||
|
|
||
| /// @title XCM Precompile Interface | ||
| /// @notice A low-level interface for interacting with `pallet_xcm`. | ||
| /// It forwards calls directly to the corresponding dispatchable functions, | ||
| /// providing access to XCM execution and message passing. | ||
| /// Learn more about XCM: https://docs.polkadot.com/develop/interoperability | ||
| /// @dev All parameters must be encoded using the SCALE codec. See https://docs.polkadot.com/polkadot-protocol/parachain-basics/data-encoding | ||
| interface IXcm { | ||
| /// Weight v2 | ||
| /// @notice Weight v2 | ||
|
tiagobndr marked this conversation as resolved.
|
||
| /// @dev See https://docs.polkadot.com/polkadot-protocol/parachain-basics/blocks-transactions-fees/fees/#transactions-weights-and-fees | ||
| struct Weight { | ||
| /// The computational time used to execute some logic based on reference hardware | ||
| /// @custom:property The computational time used to execute some logic based on reference hardware. | ||
|
tiagobndr marked this conversation as resolved.
|
||
| uint64 refTime; | ||
| /// The size of the proof needed to execute some logic | ||
| /// @custom:property The size of the proof needed to execute some logic. | ||
|
tiagobndr marked this conversation as resolved.
|
||
| uint64 proofSize; | ||
| } | ||
|
|
||
| /// @notice Execute a Versioned XCM message locally with the caller's origin | ||
| /// @param message The Versioned XCM message to send | ||
| /// @param weight The maximum amount of weight to be used to execute the message | ||
| function xcmExecute(bytes calldata message, Weight calldata weight) external; | ||
| /// @notice Executes an XCM message locally on the current chain with the caller's origin. | ||
| /// @dev Internally calls `pallet_xcm::execute`. | ||
| /// @param message A SCALE-encoded Versioned XCM message. | ||
| /// @param weight The maximum allowed `Weight` for execution. | ||
| /// @dev Call @custom:function weighMessage(message) to ensure sufficient weight allocation. | ||
| /// @return Raw SCALE-encoded `DispatchResultWithPostInfo`. See https://paritytech.github.io/polkadot-sdk/master/frame_support/dispatch/type.DispatchResultWithPostInfo | ||
|
sphamjoli marked this conversation as resolved.
|
||
| function execute(bytes calldata message, Weight calldata weight) | ||
| external | ||
| returns (bytes memory); | ||
|
|
||
| /// @notice Send an Versioned XCM message to a destination chain | ||
| /// @param destination The destination location, encoded according to the XCM format | ||
| /// @param message The Versioned XCM message to send | ||
| function xcmSend(bytes calldata destination, bytes calldata message) external; | ||
| /// @notice Sends an XCM message to another parachain or consensus system. | ||
| /// @dev Internally calls `pallet_xcm::send`. | ||
| /// @param destination SCALE-encoded destination MultiLocation. | ||
| /// @param message SCALE-encoded Versioned XCM message. | ||
| /// @return Raw SCALE-encoded `DispatchResult`. See https://paritytech.github.io/polkadot-sdk/master/frame_support/dispatch/type.DispatchResult | ||
| function send(bytes calldata destination, bytes calldata message) | ||
| external | ||
| returns (bytes memory); | ||
|
|
||
| /// @notice Given a message estimate the weight cost | ||
| /// @param message The XCM message to send | ||
| /// @returns weight estimated for sending the message | ||
| function weighMessage(bytes calldata message) external view returns (Weight memory weight); | ||
| /// @notice Estimates the `Weight` required to execute a given XCM message. | ||
| /// @param message SCALE-encoded Versioned XCM message to analyze. | ||
| /// @return weight Struct containing estimated `refTime` and `proofSize`. | ||
| function weighMessage(bytes calldata message) | ||
| external | ||
| view | ||
| returns (Weight memory weight); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| title: '[XCM Precompile] Rename functions and improve docs in the Solidity interface' | ||
| doc: | ||
| - audience: Runtime User | ||
| description: |- | ||
| This PR changes the function names on the XCM Precompile from `xcmExecute` and `xcmSend` to `execute` and `send`, respectively. This is a breaking change because it modifies the ABI-encoded function selectors, which are calculated using `bytes4(keccak256(FUNCTION_SIGNATURE))`. | ||
|
|
||
| `bytes4(keccak256("xcmSend(bytes,bytes)"))` -> `0xc0addb55` | ||
| is going to be now | ||
| `bytes4(keccak256("send(bytes,bytes)"))` -> `0x7f0a3bf9` | ||
|
|
||
| `bytes4(keccak256("xcmExecute(bytes,(uint64,uint64)))"))` => `0x377df829` | ||
| is going to be now | ||
| `bytes4(keccak256("execute(bytes,(uint64,uint64)))"))` => `0xd3b7e04d` | ||
|
|
||
| It also adds new documentation to the precompile, directing developers to the official Polkadot XCM documentation. Additionally, it explicitly sets return values for both functions to clarify that the return value matches what is returned by `pallet_xcm::send()` and `pallet_xcm::execute()`. | ||
| crates: | ||
| - name: pallet-xcm | ||
| bump: major |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.