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

Add xcm integration #1912

Merged
merged 57 commits into from
Apr 26, 2024
Merged

Add xcm integration #1912

merged 57 commits into from
Apr 26, 2024

Conversation

pgherveou
Copy link
Contributor

@pgherveou pgherveou commented Sep 14, 2023

Expose xcm_execute and xcm_send host functions to ink!

@pgherveou pgherveou marked this pull request as ready for review October 9, 2023 07:41
crates/env/Cargo.toml Outdated Show resolved Hide resolved
crates/ink/Cargo.toml Outdated Show resolved Hide resolved
@pgherveou pgherveou requested a review from a team as a code owner January 23, 2024 19:35
@pgherveou pgherveou changed the base branch from master to pg/uapi January 23, 2024 19:35
Base automatically changed from pg/uapi to master January 24, 2024 17:36
@pgherveou pgherveou force-pushed the pg/xcm branch 2 times, most recently from adef8b3 to 2baefa4 Compare February 1, 2024 14:47
@pgherveou pgherveou changed the base branch from master to pg/bump-deps February 1, 2024 14:47
@pgherveou pgherveou changed the base branch from pg/bump-deps to master February 19, 2024 15:09
pgherveou and others added 2 commits April 10, 2024 11:15
Co-authored-by: Michael Müller <michi@parity.io>
Co-authored-by: Michael Müller <michi@parity.io>
integration-tests/contract-xcm/lib.rs Outdated Show resolved Hide resolved
integration-tests/contract-xcm/lib.rs Outdated Show resolved Hide resolved
integration-tests/contract-xcm/lib.rs Outdated Show resolved Hide resolved
&parachain_account_sovereign_account_id(1, account_id)
),
vec![BalanceLock {
id: *b"py/xcmlk",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a comment that describes why this literal is used here and how to determine which ones to use in different scenarios.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment was marked resolved, but I don't see a comment in the Files Changed. I'm unresolving hence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my bad, mis-clicked it, will add comments here

integration-tests/contract-xcm/Cargo.toml Outdated Show resolved Hide resolved

// Double encoding the message as the host fn expects an encoded message.
let enc_msg = scope.take_encoded(&scale::Encode::encode(msg));
#[allow(deprecated)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the function already marked deprecated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unstable host api (which is still the case for this one as of this release of polkadot-sdk) are marked as deprecated so that they can trigger a warning if you try to use them without specifying allow(deprecated)

@codecov-commenter
Copy link

codecov-commenter commented Apr 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.30%. Comparing base (370a495) to head (70769af).

❗ Current head 70769af differs from pull request most recent head b83a535. Consider uploading reports for the commit b83a535 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1912      +/-   ##
==========================================
+ Coverage   60.56%   61.30%   +0.74%     
==========================================
  Files         140      139       -1     
  Lines        5779     5709      -70     
  Branches     2448     2421      -27     
==========================================
  Hits         3500     3500              
+ Misses       2279     2209      -70     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Apr 15, 2024

🦑 📈 ink! Example Contracts ‒ Changes Report 📉 🦑

These are the results when building the integration-tests/* contracts from this branch with cargo-contract and comparing them to ink! master:

Contract Upstream Size (kB) PR Size (kB) Diff (kB) Diff (%) Change
call-builder-return-value 9.249 9.249 0 0
e2e-runtime-only-backend 1.901 1.901 0 0
lang-err/call-builder-delegate 2.65 2.65 0 0
lang-err/call-builder 5.571 5.571 0 0
lang-err/constructors-return-value 1.997 1.997 0 0
lang-err/contract-ref 5.062 5.062 0 0
lang-err/integration-flipper 1.827 1.827 0 0
mother 12.753 12.753 0 0
sr25519-verification 1.154 1.154 0 0
call-runtime 2.071 2.071 0 0
combined-extension 2.149 2.149 0 0
conditional-compilation 1.502 1.502 0 0
contract-storage 7.58 7.58 0 0
contract-terminate 1.369 1.369 0 0
contract-transfer 1.731 1.731 0 0
contract-xcm 19.678 19.678 0 0
cross-contract-calls 7.732 7.732 0 0
cross-contract-calls/other-contract 1.595 1.595 0 0
custom-allocator 7.787 7.787 0 0
custom-environment 2.158 2.158 0 0
dns 7.355 7.355 0 0
e2e-call-runtime 1.32 1.32 0 0
erc1155 14.397 14.397 0 0
erc20 6.955 6.955 0 0
erc721 10.044 10.044 0 0
events 5.27 5.27 0 0
flipper 1.651 1.651 0 0
incrementer 1.516 1.516 0 0
lazyvec 4.66 4.66 0 0
mapping 8.036 8.036 0 0
multi-contract-caller 6.654 6.654 0 0
multi-contract-caller/accumulator 1.388 1.388 0 0
multi-contract-caller/adder 1.922 1.922 0 0
multi-contract-caller/subber 1.942 1.942 0 0
multisig 21.843 21.843 0 0
payment-channel 5.742 5.742 0 0
psp22-extension 7.083 7.083 0 0
rand-extension 2.977 2.977 0 0
runtime-call-contract 1.596 1.596 0 0
static-buffer 2.578 2.578 0 0
trait-dyn-cross-contract-calls 2.899 2.899 0 0
trait-dyn-cross-contract-calls/contracts/incrementer 1.557 1.557 0 0
trait-erc20 7.331 7.331 0 0
trait-flipper 1.502 1.502 0 0
trait-incrementer 1.626 1.626 0 0
upgradeable-contracts/delegator 3.96 3.96 0 0
upgradeable-contracts/delegator/delegatee 1.641 1.641 0 0
upgradeable-contracts/delegator/delegatee2 1.641 1.641 0 0
upgradeable-contracts/set-code-hash-migration 1.755 1.755 0 0
upgradeable-contracts/set-code-hash-migration/migration 1.462 1.462 0 0
upgradeable-contracts/set-code-hash-migration/updated-incrementer 1.909 1.909 0 0
upgradeable-contracts/set-code-hash 1.755 1.755 0 0
upgradeable-contracts/set-code-hash/updated-incrementer 1.733 1.733 0 0
wildcard-selector 2.858 2.858 0 0

Link to the run | Last update: Fri Apr 26 18:59:01 CEST 2024

Copy link
Collaborator

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

Looks good, happy to finally have xcm in ink! 🚀

Just the thing with the encoding of the message and I think we are good to go

crates/e2e/Cargo.toml Show resolved Hide resolved
@@ -622,7 +622,7 @@ jobs:
# - custom_allocator
# Pulls in sp-std which needlessly requires atomic pointers (TODO: Fix sp-std and enable this example)
# - call-runtime
scripts/for_all_contracts_exec.sh --path integration-tests --ignore public/custom-allocator --ignore public/call-runtime \
scripts/for_all_contracts_exec.sh --path integration-tests --ignore public/custom-allocator --ignore public/call-runtime --ignore public/contract-xcm \
Copy link
Collaborator

Choose a reason for hiding this comment

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

The tests look like they pass (on my machine anyway) so we can enable them now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for building the risc-v example, I did you try that as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah no sorry I did not see it was part of the riscv step

crates/env/src/engine/on_chain/impls.rs Show resolved Hide resolved
scope.append_encoded(&scale::Encode::encode(msg));
let enc_msg = scope.take_appended();
#[allow(deprecated)]
ext::xcm_send(enc_dest, enc_msg, output.try_into().unwrap())?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could possibly use array_mut_ref! for output here?

@pgherveou pgherveou enabled auto-merge (squash) April 26, 2024 16:01
@pgherveou pgherveou merged commit eeae6c9 into master Apr 26, 2024
30 checks passed
@pgherveou pgherveou deleted the pg/xcm branch April 26, 2024 16:26
TarekkMA pushed a commit to moonbeam-foundation/polkadot-sdk that referenced this pull request Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants