Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b7c4c7a
Add CI test
cmichi Oct 20, 2025
cfb1a98
Revert "Add CI test"
cmichi Oct 22, 2025
578aaa1
Stabilize XCM behind feature flag
cmichi Oct 10, 2025
31c1676
Update changelog
cmichi Oct 22, 2025
d4ba2dd
Rever me: Ignore `contract-xcm` in CI
cmichi Oct 22, 2025
b6df93a
Add comment on `sleep`
cmichi Oct 22, 2025
a9c7457
Improve comments
cmichi Oct 22, 2025
26499fe
Update lockfile
cmichi Oct 22, 2025
792b2b3
Merge remote-tracking branch 'origin/master' into cmichi-stabilize-xc…
cmichi Oct 23, 2025
649ad61
Make `clippy` happy
cmichi Oct 23, 2025
4afdf96
Fix slice length
cmichi Oct 23, 2025
dc43413
Fix calculation
cmichi Oct 24, 2025
94083ff
Merge remote-tracking branch 'origin/master' into cmichi-stabilize-xc…
cmichi Oct 24, 2025
8b55a44
Fix CI
cmichi Oct 25, 2025
e53bf1a
Simplify `solidity_encode_bytes()`
cmichi Oct 28, 2025
679064b
Fix `offset` type
cmichi Oct 28, 2025
1f543a0
Merge remote-tracking branch 'origin/master' into cmichi-stabilize-xc…
cmichi Oct 28, 2025
3756f21
Fix file name error from `master`
cmichi Oct 28, 2025
8d41a14
Fix file name error from `master`
cmichi Oct 28, 2025
9ef140b
Improve comment
cmichi Oct 29, 2025
405f6e0
Write `Weight` bytes directly to buffer
cmichi Oct 29, 2025
ca834a9
Update crates/env/src/engine/on_chain/pallet_revive.rs
cmichi Oct 29, 2025
7607bc2
Revert "Write `Weight` bytes directly to buffer"
cmichi Oct 29, 2025
4be63db
Merge remote-tracking branch 'origin/master' into cmichi-stabilize-xc…
cmichi Oct 29, 2025
1bdc136
Apply `cargo fmt`
cmichi Oct 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -617,12 +617,15 @@ jobs:
QUICKCHECK_TESTS: 2
with:
# Run all tests with --all-features, which will run the `e2e-tests` feature if present.
# todo @cmichi: We ignore `contract-xcm` until we can run a relaychain + parachain
# setup with `ink-node`. This is required for testing XCM.
command: |
cat ./all-contracts | \
grep integration-tests | \
scripts/for_all_contracts_exec.sh \
--ignore internal/static-buffer \
--ignore internal/mapping \
--ignore public/contract-xcm \
--partition ${{ matrix.partition }}/4 -- \
cargo contract test --all-features --manifest-path {}

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `#[ink::contract_ref]` attribute - [#2648](https://github.com/use-ink/ink/pull/2648)
- Add `ink_revive_types` (and remove `pallet-revive` dependency from `ink_e2e`) - [#2657](https://github.com/use-ink/ink/pull/2657)
- non-allocating Solidity ABI encoder - [#2655](https://github.com/use-ink/ink/pull/2655)
- Implement XCM precompile, stabilize XCM API - [#2687](https://github.com/use-ink/ink/pull/2687)

### Changed
- Marks the `pallet-revive` host function `account_id` stable - [#2578](https://github.com/use-ink/ink/pull/2578)
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/e2e/src/subxt_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ where

let best_block = self.api.best_block().await;

let account = self
let account_info = self
.api
.client
.storage()
Expand All @@ -425,7 +425,7 @@ where
panic!("unable to decode account info: {err:?}");
});

let account_data = get_composite_field_value(&account, "data")?;
let account_data = get_composite_field_value(&account_info, "data")?;
let balance = get_composite_field_value(account_data, "free")?;
let balance = balance.as_u128().ok_or_else(|| {
Error::Balance(format!("{balance:?} should convert to u128"))
Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/src/xts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ use subxt::{
pub struct Weight {
#[codec(compact)]
/// The weight of computational time used based on some reference hardware.
ref_time: u64,
pub ref_time: u64,
#[codec(compact)]
/// The weight of storage space used by proof of validity.
proof_size: u64,
pub proof_size: u64,
}

impl From<sp_weights::Weight> for Weight {
Expand Down
53 changes: 38 additions & 15 deletions crates/env/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

//! The public raw interface towards the host engine.

#[cfg(feature = "xcm")]
use ink_primitives::Weight;
use ink_primitives::{
Address,
CodeHashErr,
Expand Down Expand Up @@ -874,27 +876,49 @@ where
<EnvInstance as OnInstance>::on_instance(|instance| instance.set_code_hash(code_hash))
}

/// Estimates the [`Weight`] required to execute a given XCM message.
///
/// This is done by invoking [the XCM precompile](https://paritytech.github.io/polkadot-sdk/master/pallet_xcm/precompiles/struct.XcmPrecompile.html).
/// For more details consult the [precompile interface](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/xcm/pallet-xcm/precompiles/src/interface/IXcm.sol).
///
/// # Errors
///
/// - If the message cannot be properly decoded in the XCM precompile.
/// - If the XCM execution fails because of the runtime's XCM configuration.
///
/// # Panics
///
/// Panics in the off-chain environment.
#[cfg(feature = "xcm")]
pub fn xcm_weigh<Call>(msg: &xcm::VersionedXcm<Call>) -> Result<Weight>
where
Call: scale::Encode,
{
<EnvInstance as OnInstance>::on_instance(|instance| {
TypedEnvBackend::xcm_weigh(instance, msg)
})
}

/// Execute an XCM message locally, using the contract's address as the origin.
///
/// For more details consult the
/// [host function documentation](https://paritytech.github.io/polkadot-sdk/master/pallet_contracts/api_doc/trait.Current.html#tymethod.xcm_execute).
/// This is done by invoking [the XCM precompile](https://paritytech.github.io/polkadot-sdk/master/pallet_xcm/precompiles/struct.XcmPrecompile.html).
/// For more details consult the [precompile interface](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/xcm/pallet-xcm/precompiles/src/interface/IXcm.sol).
///
/// # Errors
///
/// - If the message cannot be properly decoded on the `pallet-revive` side.
/// - If the message cannot be properly decoded in the XCM precompile.
/// - If the XCM execution fails because of the runtime's XCM configuration.
///
/// # Panics
///
/// Panics in the off-chain environment.
#[cfg(all(feature = "xcm", feature = "unstable-hostfn"))]
pub fn xcm_execute<E, Call>(msg: &xcm::VersionedXcm<Call>) -> Result<()>
#[cfg(feature = "xcm")]
pub fn xcm_execute<Call>(msg: &xcm::VersionedXcm<Call>, weight: Weight) -> Result<()>
where
E: Environment,
Call: scale::Encode,
{
<EnvInstance as OnInstance>::on_instance(|instance| {
TypedEnvBackend::xcm_execute::<E, _>(instance, msg)
TypedEnvBackend::xcm_execute(instance, msg, weight)
})
}

Expand All @@ -903,27 +927,26 @@ where
/// The `msg` argument has to be SCALE encoded, it needs to be decodable to a valid
/// instance of the `RuntimeCall` enum.
///
/// For more details consult
/// [host function documentation](https://paritytech.github.io/polkadot-sdk/master/pallet_contracts/api_doc/trait.Current.html#tymethod.xcm_send).
/// This is done by invoking [the XCM precompile](https://paritytech.github.io/polkadot-sdk/master/pallet_xcm/precompiles/struct.XcmPrecompile.html).
/// For more details consult the [precompile interface](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/xcm/pallet-xcm/precompiles/src/interface/IXcm.sol).
///
/// # Errors
///
/// - If the message cannot be properly decoded on the `pallet-revive` side.
/// - If the message cannot be properly decoded in the XCM precompile.
///
/// # Panics
///
/// Panics in the off-chain environment.
#[cfg(all(feature = "xcm", feature = "unstable-hostfn"))]
pub fn xcm_send<E, Call>(
#[cfg(feature = "xcm")]
pub fn xcm_send<Call>(
dest: &xcm::VersionedLocation,
msg: &xcm::VersionedXcm<Call>,
) -> Result<xcm::v4::XcmHash>
) -> Result<()>
where
E: Environment,
Call: scale::Encode,
{
<EnvInstance as OnInstance>::on_instance(|instance| {
TypedEnvBackend::xcm_send::<E, _>(instance, dest, msg)
TypedEnvBackend::xcm_send(instance, dest, msg)
})
}

Expand Down
28 changes: 21 additions & 7 deletions crates/env/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "xcm")]
use ink_primitives::Weight;
use ink_primitives::{
Address,
CodeHashErr,
Expand Down Expand Up @@ -415,29 +417,41 @@ pub trait TypedEnvBackend: EnvBackend {
/// For more details visit: [`own_code_hash`][`crate::own_code_hash`]
fn own_code_hash(&mut self) -> H256;

/// Estimates the [`Weight`] required to execute a given XCM message.
///
/// # Note
///
/// For more details visit: [`xcm`][`crate::xcm_weigh`].
#[cfg(feature = "xcm")]
fn xcm_weigh<Call>(&mut self, msg: &xcm::VersionedXcm<Call>) -> Result<Weight>
where
Call: scale::Encode;

/// Execute an XCM message locally, using the contract's address as the origin.
///
/// # Note
///
/// For more details visit: [`xcm`][`crate::xcm_execute`].
#[cfg(all(feature = "xcm", feature = "unstable-hostfn"))]
fn xcm_execute<E, Call>(&mut self, msg: &xcm::VersionedXcm<Call>) -> Result<()>
#[cfg(feature = "xcm")]
fn xcm_execute<Call>(
&mut self,
msg: &xcm::VersionedXcm<Call>,
weight: Weight,
) -> Result<()>
where
E: Environment,
Call: scale::Encode;

/// Send an XCM message, using the contract's address as the origin.
///
/// # Note
///
/// For more details visit: [`xcm`][`crate::xcm_send`].
#[cfg(all(feature = "xcm", feature = "unstable-hostfn"))]
fn xcm_send<E, Call>(
#[cfg(feature = "xcm")]
fn xcm_send<Call>(
&mut self,
dest: &xcm::VersionedLocation,
msg: &xcm::VersionedXcm<Call>,
) -> Result<xcm::v4::XcmHash>
) -> Result<()>
where
E: Environment,
Call: scale::Encode;
}
27 changes: 16 additions & 11 deletions crates/env/src/engine/off_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.

use ink_engine::ext::Engine;
#[cfg(feature = "xcm")]
use ink_primitives::Weight;
use ink_primitives::{
Address,
CodeHashErr,
Expand Down Expand Up @@ -799,23 +801,26 @@ impl TypedEnvBackend for EnvInstance {
.expect("own code hash not found")
}

#[cfg(all(feature = "xcm", feature = "unstable-hostfn"))]
fn xcm_execute<E, Call>(&mut self, _msg: &xcm::VersionedXcm<Call>) -> Result<()>
where
E: Environment,
{
#[cfg(feature = "xcm")]
fn xcm_weigh<Call>(&mut self, _msg: &xcm::VersionedXcm<Call>) -> Result<Weight> {
unimplemented!("off-chain environment does not support `xcm_execute`")
}

#[cfg(all(feature = "xcm", feature = "unstable-hostfn"))]
fn xcm_send<E, Call>(
#[cfg(feature = "xcm")]
fn xcm_execute<Call>(
&mut self,
_msg: &xcm::VersionedXcm<Call>,
_weight: Weight,
) -> Result<()> {
unimplemented!("off-chain environment does not support `xcm_execute`")
}

#[cfg(feature = "xcm")]
fn xcm_send<Call>(
&mut self,
_dest: &xcm::VersionedLocation,
_msg: &xcm::VersionedXcm<Call>,
) -> Result<xcm::v4::XcmHash>
where
E: Environment,
{
) -> Result<()> {
unimplemented!("off-chain environment does not support `xcm_send`")
}
}
Loading
Loading