Skip to content

feat: messaging precompiles#584

Merged
Daanvdplas merged 90 commits intofungibles-precompilesfrom
messaging-precompiles
Aug 26, 2025
Merged

feat: messaging precompiles#584
Daanvdplas merged 90 commits intofungibles-precompilesfrom
messaging-precompiles

Conversation

@evilrobot-01
Copy link
Collaborator

@evilrobot-01 evilrobot-01 commented Jul 7, 2025

An adaptation of #528 to use precompiles for ISMP/XCM messaging.

NOTE: there is currently a single failing test, which is an integrity test added to the messaging pallet. It effectively highlights the fact that a max encoded XCM response is potentially prohibitively large. Most response are probably tiny in comparison, so a more practical approach might be to measure the largest xcm responses in practice and size accordingly. I have intentionally left this as a failing test as I feel it needs further consideration.

ISMP

The following diagram illustrates the flow of the ISMP implementation:

flowchart TB
    A["Contract"] -- Ismp::get/post --> B["messaging::ISMP Precompile"]
    B -- transports::ismp::get/post --> n4["Take Deposit"]
    n1["runtime::Router"] -- ISMPModule::on_response --> n2["messaging::ISMP Module"]
    n2 --> n3["Callback?"]
    D["Relayer"] -- "pallet-ismp::handle(messages)" --> n1
    n3 -- "<span style=padding-left:><span style=padding-left:>onGetResponse/onPostReponse</span></span>" --> A
    C["pallet-ismp::ISMP Dispatcher"] -.- D
    n4 -- IsmpDispatcher::dispatch_request --> C
    C --> n5["Persist Request/Message"]

    n4@{ shape: rounded}
    n1@{ shape: rect}
    n2@{ shape: rect}
    n3@{ shape: diam}
    D@{ shape: hex}
    n5@{ shape: rounded}
Loading

XCM

The following diagram illustrates the flow of the XCM implementation:

flowchart TB
    A["Contract"] -- Xcm::newQuery --> B["messaging::XCM Precompile"]
    B -- transports::xcm::new_query --> n4["Take Deposit"]
    n1["xcm_executor"] -- Pallet::xcm_response --> n2["messaging::Pallet"]
    n2 --> n3["Callback?"]
    D["XCM"] -- </br> --> n1
    n3 -- onQueryResponse --> A
    C["pallet-xcm"] -.- D
    n4 -- Xcm::new_notify_query --> C
    C --> n5["Persist Request/Message"]
    A -- Xcm::send --> B
    B -- Pallet::send --> C

    n4@{ shape: rounded}
    n1@{ shape: rect}
    n2@{ shape: rect}
    n3@{ shape: diam}
    D@{ shape: hex}
    n5@{ shape: rounded}
Loading

Outstanding Items

The following items remain as outstanding:

  • ensure callback has weight specified: the implementation of the new_query helpers in the ink api crate, as well as the precompile itself, should ensure that if a callback is specified, it specifies non-zero weight. This is just a simple check to avoid callbacks failing later, but is no means sufficiently robust as the developer will always need to ensure that sufficient weight is specified.
  • helper functions for converting from bytes to an expected ismp/xcm response type: a callback for an ISMP get is strongly typed as Vec<StorageValue> but a call to get_response simply returns an opaque blob of bytes.
  • get_response to include encoding specification: persisted responses are scale-encoded, meaning that if a contract uses get_reponse for an ISMP response, it will be scale-encoded bytes. This differs to the callback, which would be encoded as per the callback specification. Adding an encoding field to the get_response function should be sufficient to resolve this.
  • top up callback weight + tests: the top_up_callback_weight functionality was not ported due to time constraints. It should be an easy add to the existing precompile(s). Additional consideration should be given to the storage deposit limit which was omitted in the previous implementation.
  • consider implementing weigher function: https://github.com/paritytech/polkadot-sdk/blob/d9f451a6b94ab2cf39371ee5192130379eb6e199/polkadot/xcm/pallet-xcm/src/precompiles/IXcm.sol#L40

[sc-3823]

@codecov-commenter
Copy link

codecov-commenter commented Jul 8, 2025

Codecov Report

❌ Patch coverage is 88.21805% with 402 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.03%. Comparing base (181d1ef) to head (91b5312).

Files with missing lines Patch % Lines
...ets/api-vnext/src/messaging/precompiles/ismp/v0.rs 85.08% 52 Missing and 39 partials ⚠️
...lets/api-vnext/src/messaging/precompiles/xcm/v0.rs 87.82% 45 Missing and 25 partials ⚠️
pallets/api-vnext/src/messaging/weights.rs 50.00% 65 Missing ⚠️
pallets/api-vnext/src/messaging/transports/ismp.rs 92.95% 22 Missing and 14 partials ⚠️
runtime/devnet/src/config/api/mod.rs 0.00% 33 Missing ⚠️
pallets/api-vnext/src/messaging/precompiles/v0.rs 87.86% 19 Missing and 10 partials ⚠️
pallets/api-vnext/src/messaging.rs 93.39% 15 Missing and 6 partials ⚠️
pallets/api-vnext/src/messaging/tests.rs 96.72% 12 Missing and 6 partials ⚠️
runtime/devnet/src/config/ismp.rs 0.00% 11 Missing ⚠️
runtime/devnet/src/lib.rs 0.00% 10 Missing ⚠️
... and 4 more
@@                    Coverage Diff                    @@
##           fungibles-precompiles     #584      +/-   ##
=========================================================
+ Coverage                  69.47%   72.03%   +2.56%     
=========================================================
  Files                        134      144      +10     
  Lines                      21538    24940    +3402     
  Branches                   21538    24940    +3402     
=========================================================
+ Hits                       14963    17966    +3003     
- Misses                      6243     6541     +298     
- Partials                     332      433     +101     
Files with missing lines Coverage Δ
pallets/api-vnext/src/fungibles/precompiles/v0.rs 88.27% <ø> (+0.09%) ⬆️
pallets/api-vnext/src/messaging/deposits.rs 100.00% <100.00%> (ø)
runtime/devnet/src/config/contracts.rs 89.04% <ø> (ø)
pallets/api-vnext/src/lib.rs 95.79% <80.00%> (+0.07%) ⬆️
pallets/api-vnext/src/messaging/benchmarking.rs 98.41% <98.41%> (ø)
pallets/api-vnext/src/mock.rs 89.69% <93.26%> (+4.84%) ⬆️
pallets/api-vnext/src/messaging/transports/xcm.rs 95.96% <95.96%> (ø)
runtime/devnet/src/lib.rs 4.12% <0.00%> (-0.09%) ⬇️
runtime/devnet/src/config/ismp.rs 0.00% <0.00%> (ø)
pallets/api-vnext/src/messaging/tests.rs 96.72% <96.72%> (ø)
... and 7 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@evilrobot-01 evilrobot-01 force-pushed the messaging-precompiles branch from 486964c to 564f9ac Compare July 14, 2025 14:32
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

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

Damn, it really is a super cool feature. Well done on the conversion, I see you made several improvements along the way which were remaining todos, amazing!

I have not been able to dive into the details, as well as benchmarks, but the overall features and integration tests look very good. Next week I will make this my priority.

Curious, would it ever be possible to return the result of the destination chain when doing an xcm send?

And are there still big open standing issues unsolved, I remember something along the lines of child tries for ismp benchmarking (?). This is not a problem but I would like to have a look at this for the next review to get a better understanding.

The precompiles and contracts look super clean, that with the complexity of these protocols, incredible!

@evilrobot-01 evilrobot-01 force-pushed the fungibles-precompiles branch from c00106e to 0021908 Compare July 26, 2025 21:50
@evilrobot-01 evilrobot-01 force-pushed the messaging-precompiles branch from 0516545 to 76e8e85 Compare July 27, 2025 00:00
@evilrobot-01
Copy link
Collaborator Author

Curious, would it ever be possible to return the result of the destination chain when doing an xcm send?

Thats what the example already shows?

#[ink(message, payable)]
pub fn transact(&mut self, call: Vec<u8>, weight: Weight) {
let dest = Location::new(1, Parachain(self.para));
let call = DoubleEncoded::<()>::decode_all(&mut &call[..]).unwrap();
// Register a new query for receiving a response, used to report transact status.
let (id, query_id) = api::xcm::new_query(
VersionedLocation::V5(dest.clone()),
self.env().block_number().saturating_add(100),
Some(Callback::new(
self.env().address(),
ENCODING,
0x641b0b03,
Weight::from_parts(800_000_000, 500_000),
)),
);
// TODO: provide an api function for determining the local para id and max weight value
// for processing the reported transact status on the local chain.
let response = QueryResponseInfo {
// Route back to this parachain.
destination: Location::new(1, Parachain(4_001)),
query_id,
max_weight: Weight::from_parts(1_000_000, 5_000),
};
// Send transact message.
let fees: Asset =
(Location::parent(), u128::try_from(self.env().transferred_value()).unwrap())
.into();
let message: Xcm<()> = self._transact(call, weight, fees, response);
let mut hash = [0u8; 32];
Blake2x256::hash(&message.encode(), &mut hash);
let result = api::xcm::send(dest.into_versioned(), VersionedXcm::V5(message));
self.env().emit_event(XcmRequested { id, query_id, hash });
}

The _transact function adds an instruction to report the transact status back:

fn _transact(
&self,
call: DoubleEncoded<()>,
weight: Weight,
fees: Asset,
response: QueryResponseInfo,
) -> Xcm<()> {
let beneficiary = hashed_account(4_001, self.env().account_id()); // todo: para id getter
Xcm::builder_unsafe()
.withdraw_asset(fees.clone())
.buy_execution(fees, WeightLimit::Unlimited)
.set_appendix(
Xcm::builder_unsafe()
.refund_surplus()
.deposit_asset(
All,
Location::new(0, AccountId32 { network: None, id: beneficiary.0 }),
)
.build(),
)
.set_error_handler(Xcm::builder_unsafe().report_error(response.clone()).build())
.transact(OriginKind::SovereignAccount, weight, call)
.report_transact_status(response)
.build()
}
}

And are there still big open standing issues unsolved, I remember something along the lines of child tries for ismp benchmarking (?). This is not a problem but I would like to have a look at this for the next review to get a better understanding.

The ismp child trie benchmarking has been overcome using the same approach as pallet-contracts/revive:

// IMPORTANT NOTE: `skip_meta` and `pov_mode = Measured` currently used due to an issue with the
// usage of the `RequestCommitments` storage item within `pallet_ismp`'s child trie, which
// results in massive proof size values resulting from complexity parameters, preventing
// compilation of the resulting weights. Reducing max limits on pallet config also avoids the
// issue, but results in values which are too small to be useful. See `pallet-contracts` and
// `pallet-revive` benchmarks for similar usage with contract child tries.

@evilrobot-01 evilrobot-01 force-pushed the messaging-precompiles branch 2 times, most recently from 6ca0ba9 to d3bb37d Compare July 28, 2025 21:46
Comment on lines +48 to +51
/// The weight to be used for callback responses to this contract.
gas_limit: Weight,
/// The storage deposit limit for callback responses to this contract.
storage_deposit_limit: U256,
Copy link
Collaborator

@Daanvdplas Daanvdplas Jul 29, 2025

Choose a reason for hiding this comment

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

Could you explain why you set those values here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The contract must effectively specify the values required as limits when the response is dispatched back to the contract via

let mut output = Revive::bare_call(
.

The cost of the gas_limit specified at the time of request is reserved, with any unused weight/cost being refunded after callback execution. The storage deposit limit covers the max amount that should be reserved for any state that the receiving contract creates. Whilst this is typically the same contract, there is now the dest field on the callback which allows specification of a contract address other than the caller for a more powerful implementation.

@evilrobot-01 evilrobot-01 force-pushed the messaging-precompiles branch from 34bdfa5 to 28ab13e Compare July 31, 2025 06:47
@evilrobot-01 evilrobot-01 marked this pull request as ready for review July 31, 2025 11:55
@Daanvdplas Daanvdplas marked this pull request as draft August 11, 2025 11:01
@Daanvdplas Daanvdplas marked this pull request as ready for review August 11, 2025 11:01
@Daanvdplas Daanvdplas merged commit cdd8711 into fungibles-precompiles Aug 26, 2025
28 of 32 checks passed
@Daanvdplas Daanvdplas deleted the messaging-precompiles branch August 26, 2025 07:19
Daanvdplas pushed a commit that referenced this pull request Aug 26, 2025
* build(deps): disable default-features for serde

* feat(api-vnext): new 'pallet' to provide fungible api(s) via precompiles

* feat(devnet): add fungibles precompiles

* build(deps): propagate runtime-benchmarks feature

* build: disable doctest based on incompatible comments in .sol files

* fix(precompiles/interfaces): use calldata specifiers for string
parameters

* style(precompiles/interfaces): formatting

* refactor: use upcoming assetidextractor from pallet-assets

* refactor(api-vnext): resolve clippy warnings

* style: formatting

* feat(pop-api): add initial fungibles api and example

* chore: rename example directory

* docs: remove trailing slash in comment

* refactor(pop-api): improvements to implementation

* test(devnet): improvements to fungibles precompile contract test

* refactor(pop-api): remove redundant code for manual precompile calls

* refactor(fungibles): ensure feature parity with prior implementation

* refactor(pop-api): use explicit sol encoding for precompile contract
refs

* docs(examples): update parameter description based on review comment

* docs(api): add public function doc

* docs(example): update constructor parameter doc style to match messages

* docs(example): use account instead of address in doc comments

* docs(example): add todo prefix to comment

* docs(api): add public function doc

* test(api): remove additional check deemed unnecessary

* docs(api): add fungibles doc comments

* refactor(precompiles): add license and version requirement

* refactor(precompiles): update return types after rebase

* test(api): resolve breaking changes after rebase

* test(api): improve fungibles precompile tests after rebase

* test(api): improve erc20 precompile tests after rebase

* test(api): define precompile constants within mock runtime

* refactor(api): use asset id extractors from pallet-assets

* test(devnet): resolve breaking changes after rebase

* refactor(api): import soltype

* refactor(api): correct fungibles trait parameter names

* refactor(devnet): simplify selector implementations

* test(api): add initial integration tests

* ci: add job for pop-api-vnext integration tests

* test(api): minimal implementation of transfer test

Solidity error handling still unsupported.

* ci: set rustflags for pop-api-vnext integration tests

* test(runtime): disable precompiles with contract test

Disabled until it can be replaced completely by integration tests.

* test(api): add transfer_from test

* ci: exclude pop-api-integration-tests from test and coverage jobs

* test(api): add approve test

* test(api): add contract.account_id() helper

* test(api): add increase/decrease allowance tests

* refactor(api): separate out fungibles errors module

* feat(api): add fungibles events

* test(api): add create test

* test(api): add start_destroy test

* test(api): make contract instantiation origin explicit to simplify api

* test(api): add set_metadata test

* test(api): update expectation message to .polkavm

* test(api): add clear_metadata test

* test(api): reuse sol types to ease encoding

* test(api): add mint test

* test(api): add burn test

* test(api): add create with instantiation test

* feat(api): initial precompile benchmarking

* refactor(api): charge weight for increase/decrease allowance calls

* refactor(api): improve decrease allowance implementation

* feat(api): add clear_metadata benchmark

* feat(api): add set_metadata benchmark

Also adds a few additional improvements.

* feat(api): add start_destroy benchmark

* feat(api): add create benchmark

* refactor(api): move benchmark assertion into block

* refactor(api): use call_precompile helper

Provides decoding to ease assertions.

* feat(api): add mint benchmark

* feat(api): add burn benchmark

* feat(api): add transfer benchmark

* feat(api): add transfer_from benchmark

* refactor(api/fungibles/benchmarking): add copy trait bound to asset id
to eliminate manual clones

* refactor(api/fungibles): refund appropriate burn weight on failure

* style(api/fungibles): formatting

* refactor(api/fungibles/erc20): charge benchmarked weight

Uses benchmarks from the fungibles precompile which should be exactly
the same for these functions.

* chore(api): add cargo.lock

* test(devnet): set gas limit now that precompiles charge weight

* test(devnet): remove contract and selector integration tests as available elsewhere now

* test(api): add selectors test

* test(api): add initial tests

* test(api): remove unnecessary helper

* test(api): add increase/decrease tests

* test(api): add create test

* test(api): add start_destroy test

* test(api): add set_metadata test

* test(api): add clear_metadata test

* test(api): add mint test

* test(api): add burn test

* test(api): add exists test

* refactor(api): share total_supply implementation

* refactor(api): share balance implementation

* refactor(api): share allowance implementation

* refactor(api): share metadata implementation

* test(api): explicitly endow when more than ed required

* refactor(api): reorganize for versioning

* style: formatting

* build(deps): update ink after sol-abi improvements merged

* ci: explicitly cache pallet-revive-fixtures output

* test(api/integration-tests): fix imports after refactor

* ci: remove cached pallet-revive fixtures

* ci: only list if directory exists

* ci(init): make crate caching configurable

* ci(init): bump rust-cache version

* refactor(pallets/api): address clippy warning

* docs(api): add missing precompile index comment

* refactor(pallets/api): ensure weight charge updated on both approve success and
failure

* refactor(pallets-api): update event handling based on reference
implementation

* docs: remove todo comment

* test(api/integration-tests): constructor encoding

Uses `all` encoding to support multiple constructors after solidity
constructor support added.

* docs(api): fix transfer comment

* docs(api): port readmes

* refactor(pallets/api): simplify u256 conversion

* refactor(pallets/api): relocate benchmarking call setup and resolve
issues

* refactor(api): update ink, eliminating manual encoding/decoding

* fix(api): add missing imports after refactor

* refactor: implement initial precompile reverts

* test(api): add initial error checks

* refactor(api): improved fungibles error handling

* refactor(api): improved erc20 error handling

* build(deps): add missing base64 feature

* refactor: resolve missing imports/trait bounds for runtime-benchmarks

* refactor(pallets/api): resolve clippy warnings

* test(pallets/api): fix minimum balance consideration with transfer

* test(pallets/api): remove unnecessary println

* test(pallets/api): fix minimum balance consideration with transfer
benchmark

* fix(api): allow removal of approval with zero value allowance

* refactor(api): check set_metadata result after refactoring

* chore: update cargo.lock after rebase

* style: formatting after rebase

* chore(api): update cargo.lock for contracts

* docs(api): remove todos

* ci: enable global cache disabling

* ci: reenable crate caching

* docs(pallets/api): remove token id size todo after discussion

* test(api): relocate and reduce initial value, gas and storage limits

* refactor(pallets/api): ensure all errors apart from insufficient gas
result in revert

* refactor(api): ensure full error coverage

* test(api): update expected errors

* chore(api): update cargo.lock

* chore: update cargo.lock

* refactor(pallets/api): simplify origin

* refactor(pallets/api): fix imports

* refactor(api): reuse selectors

* feat: messaging precompiles (#584)

* feat(pallets/api): add messaging precompiles

* feat(devnet): add messaging pallet

* feat(api): add initial messaging apis

* feat(api): add messaging example

* refactor(api): update callback encoding

* build(pallets/api): add empty ismp feature

* refactor: port on_initialize hook implementation

* style: formatting

* build(pallets/api): adjust ismp feature

* feat(pallets/api): add messaging benchmarks

* refactor(ismp): use u64 height

Destination state machine could use larger type, so standardise on the
same type provided by ismp.

* refactor(api): update imports after rebase

* style: formatting after rebase

* fix: remove duplicate imports after rebase

* refactor(api): add initial messaging error handling

* test(api): add error tests

* test(pallets/api): add remove tests

* test(pallets/api): add new_query tests

* test(pallets/api): add call tests

* test(pallets/api): add process_callback_weight tests

* test(pallets/api): add deposit_callback_event tests

* test(pallets/api): add fee management test

* test(pallets/api): add xcm_response tests

* test(pallets/api): add ismp tests

* refactor: limit ismp_response helper to tests

* refactor(pallets/api): use try_convert

* refactor(pallets/api): update messaging weights

* refactor(pallets/api): use global message identifier

Stores contract address in message to ensure authorised removal.
Additional benefits beyond reduced storage requirements are that any
contract can poll and use responses until originator removes.

* refactor(pallets/api): update weights after benchmarking

* fix(pallets/api): replace bounded_vec! usage within benchmarks

* refactor(pallets/api): callback response interfaces and encoding

* refactor(api): precompile and callback trait and type encoding
improvements

* feat(devnet): add messaging precompiles

* test(api): add initial messaging integration tests

* test(api): update ink dependency

* refactor(api): update ink dependency

* test(api): restore onpostresponse handler

* test(pallets/api): fix tests after refactor

* test(api): add ismp post integration tests

* refactor(pallets/api): rename response handler functions due to selector
clashes

A workaround for ink which does not allow two traits to be implemented
with a message with the same resulting selector.

* refactor(api): rename response handler functions due to selector clashes

* test(api): add xcm messaging integration tests

* build(api): updating ink to master

* docs(pallets/api): remove unnecessary todos

* docs(api): remove unnecessary todos

* docs(api): add hashed_account function docs

* feat(pallets/api): add (para) id getter to messaging precompiles

* feat(api): add (para) id getter to apis

* test(api): add (para) id getter integration test

* refactor(api): update messaging example with improvements

* refactor(api): improve return types of xcm execute and send helpers

* refactor(api): use ink_abi cfg for callback encoding

* refactor(pallets/api): restore ismp deposits

* test(pallets/api): increase message deposit

* docs(pallets/api): update comments on necessary clones of bytes type
during abi encoding

Data needs to be encoded for persistence if callback fails and therefore
cannot be owned.

* refactor(pallets/api): better handling of invalid callback encoding

* test(api): apply reduced initial value, gas, storage limits

* fix(pallets/api): surface storage deposit limit into callback
specification

* fix(api): allow specification of storage deposit limit for callback

* test(api): ensure storage deposit limit works

Also adjusts gas limits based on contract changes.

* refactor(devnet): update callbackexecutor.execute implementation to use
storage deposit limit

* refactor(api): update messaging example contract with storage deposit
limit

* fix(pallets/api): allow caller to specify ismp post recipient
module/address

* fix(api): allow caller to specify ismp post recipient module/address

* test(api): specify ismp post recipient mpdule/address

* refactor(devnet): configure max ismp post module/address length as 32
bytes

* docs(pallets/api): remove messageid size todo

u64::MAX provides a sufficiently large number for message identifier and
aligns with the same type used by XCM for query identifiers.

* refactor(pallets/api): add simple on_accept benchmark for consistency,
along with supporting module weight tests

* refactor(devnet): name ismp module via import alias

* refactor(devnet): add ismp weight provider

* docs(pallets/api): remove todo after tests added

* test(pallets/api): add integrity test to ensure maxresponselen

* refactor(pallets/api): update integrity test to include values

* refactor(pallets/api): update tryconvert usages to dispatcherror after
rebase

* chore: update cargo.lock

* chore(api): update cargo.lock for messaging contract

* refactor(pallets/api): use improved origin

* refactor(pallets/api): wrap fallible calls in closure to map errors

* refactor(pallets/api): use try_convert to simplify safe conversion

* refactor(pallets/api): ensure all errors apart from insufficient gas
result in revert

* refactor(api): ensure full error coverage

* test(api): update callback gas limits

* docs(api): add readmes

* docs(api): relocate messaging within readme

* docs(pallet-api): add weights overview from original pr

* docs(pallets-api): relocate weights.md

* docs(pallet-api): add description to messaging module

* docs(pallet-api): add readme

* docs(pallet-api): add initial messaging readme

* docs(pallets/api): add diagrams to messaging readme

---------

Co-authored-by: Frank Bell <frank@r0gue.io>
Daanvdplas pushed a commit that referenced this pull request Aug 27, 2025
* chore: update to stable2506

* refactor(pallets): remove deprecated runtimeevent config item

* refactor(runtime/common): add missing weights after sdk uplift

* refactor(runtime/common): remove unused import

* refactor(devnet): update revive api implementation

* refactor(devnet): add relayparentoffset config item

* refactor(devnet): update assets config

* refactor(devnet): update revive config

* refactor(devnet): update api config

* refactor(devnet): remove unused imports

* refactor(testnet): add relayparentoffset config item

* refactor(testnet): update api config

* refactor(testnet): update revive config

* refactor(testnet): update governance config

* refactor(testnet): update revive api implementation

* refactor(mainnet): update revive api implementation

* refactor(mainnet): update governance config

* refactor(mainnet): update revive config

* refactor(mainnet): add relayparentoffset config item

* refactor(mainnet): replace fee_asset with worst_case_for_trader

* refactor(node): add shared trie cache parameter to storage benchmarking command

* refactor(node): silence clippy warning

* refactor(node): address service breaking changes

* chore: update cargo.lock

* chore(api): update cargo.lock

* refactor(pallets): remove deprecated runtimeevent config item

* test(fungibles): disambiguate allowance

* test(mainnet): update revive integrity tests

* build(deps): bump frame-metadata to resolve dependency clash

* ci: restore runtime-benchmarks checks

* test(mainnet): update metadata integrity test after
v16 stabilisation

* refactor(runtimes): use max_pov_size constant

* test(integration-tests): updated expected ref_time for xcm attempted event

* test(testnet): update metadata integrity test after
v16 stabilisation

* build(deps): update stable2506 revision

* chore: update cargo.lock

* refactor(runtime): update revive config after revision change

* chore: update toolchain to stable

* build(deps): update contract-build to branch supporting valid contract
builds on rust stable

* build(extension): add missing feature flag to contract

* chore: update cargo.lock

* build(deps): update to stable2506 release

Also bumps other deps in line with versions defined within the
stable2506 release.

* refactor(runtime): address breaking changes

* refactor(node): add notification metrics to service

* chore: update cargo.lock

* chore(api): update cargo.lock

* feat: fungibles precompiles (#573)

* build(deps): disable default-features for serde

* feat(api-vnext): new 'pallet' to provide fungible api(s) via precompiles

* feat(devnet): add fungibles precompiles

* build(deps): propagate runtime-benchmarks feature

* build: disable doctest based on incompatible comments in .sol files

* fix(precompiles/interfaces): use calldata specifiers for string
parameters

* style(precompiles/interfaces): formatting

* refactor: use upcoming assetidextractor from pallet-assets

* refactor(api-vnext): resolve clippy warnings

* style: formatting

* feat(pop-api): add initial fungibles api and example

* chore: rename example directory

* docs: remove trailing slash in comment

* refactor(pop-api): improvements to implementation

* test(devnet): improvements to fungibles precompile contract test

* refactor(pop-api): remove redundant code for manual precompile calls

* refactor(fungibles): ensure feature parity with prior implementation

* refactor(pop-api): use explicit sol encoding for precompile contract
refs

* docs(examples): update parameter description based on review comment

* docs(api): add public function doc

* docs(example): update constructor parameter doc style to match messages

* docs(example): use account instead of address in doc comments

* docs(example): add todo prefix to comment

* docs(api): add public function doc

* test(api): remove additional check deemed unnecessary

* docs(api): add fungibles doc comments

* refactor(precompiles): add license and version requirement

* refactor(precompiles): update return types after rebase

* test(api): resolve breaking changes after rebase

* test(api): improve fungibles precompile tests after rebase

* test(api): improve erc20 precompile tests after rebase

* test(api): define precompile constants within mock runtime

* refactor(api): use asset id extractors from pallet-assets

* test(devnet): resolve breaking changes after rebase

* refactor(api): import soltype

* refactor(api): correct fungibles trait parameter names

* refactor(devnet): simplify selector implementations

* test(api): add initial integration tests

* ci: add job for pop-api-vnext integration tests

* test(api): minimal implementation of transfer test

Solidity error handling still unsupported.

* ci: set rustflags for pop-api-vnext integration tests

* test(runtime): disable precompiles with contract test

Disabled until it can be replaced completely by integration tests.

* test(api): add transfer_from test

* ci: exclude pop-api-integration-tests from test and coverage jobs

* test(api): add approve test

* test(api): add contract.account_id() helper

* test(api): add increase/decrease allowance tests

* refactor(api): separate out fungibles errors module

* feat(api): add fungibles events

* test(api): add create test

* test(api): add start_destroy test

* test(api): make contract instantiation origin explicit to simplify api

* test(api): add set_metadata test

* test(api): update expectation message to .polkavm

* test(api): add clear_metadata test

* test(api): reuse sol types to ease encoding

* test(api): add mint test

* test(api): add burn test

* test(api): add create with instantiation test

* feat(api): initial precompile benchmarking

* refactor(api): charge weight for increase/decrease allowance calls

* refactor(api): improve decrease allowance implementation

* feat(api): add clear_metadata benchmark

* feat(api): add set_metadata benchmark

Also adds a few additional improvements.

* feat(api): add start_destroy benchmark

* feat(api): add create benchmark

* refactor(api): move benchmark assertion into block

* refactor(api): use call_precompile helper

Provides decoding to ease assertions.

* feat(api): add mint benchmark

* feat(api): add burn benchmark

* feat(api): add transfer benchmark

* feat(api): add transfer_from benchmark

* refactor(api/fungibles/benchmarking): add copy trait bound to asset id
to eliminate manual clones

* refactor(api/fungibles): refund appropriate burn weight on failure

* style(api/fungibles): formatting

* refactor(api/fungibles/erc20): charge benchmarked weight

Uses benchmarks from the fungibles precompile which should be exactly
the same for these functions.

* chore(api): add cargo.lock

* test(devnet): set gas limit now that precompiles charge weight

* test(devnet): remove contract and selector integration tests as available elsewhere now

* test(api): add selectors test

* test(api): add initial tests

* test(api): remove unnecessary helper

* test(api): add increase/decrease tests

* test(api): add create test

* test(api): add start_destroy test

* test(api): add set_metadata test

* test(api): add clear_metadata test

* test(api): add mint test

* test(api): add burn test

* test(api): add exists test

* refactor(api): share total_supply implementation

* refactor(api): share balance implementation

* refactor(api): share allowance implementation

* refactor(api): share metadata implementation

* test(api): explicitly endow when more than ed required

* refactor(api): reorganize for versioning

* style: formatting

* build(deps): update ink after sol-abi improvements merged

* ci: explicitly cache pallet-revive-fixtures output

* test(api/integration-tests): fix imports after refactor

* ci: remove cached pallet-revive fixtures

* ci: only list if directory exists

* ci(init): make crate caching configurable

* ci(init): bump rust-cache version

* refactor(pallets/api): address clippy warning

* docs(api): add missing precompile index comment

* refactor(pallets/api): ensure weight charge updated on both approve success and
failure

* refactor(pallets-api): update event handling based on reference
implementation

* docs: remove todo comment

* test(api/integration-tests): constructor encoding

Uses `all` encoding to support multiple constructors after solidity
constructor support added.

* docs(api): fix transfer comment

* docs(api): port readmes

* refactor(pallets/api): simplify u256 conversion

* refactor(pallets/api): relocate benchmarking call setup and resolve
issues

* refactor(api): update ink, eliminating manual encoding/decoding

* fix(api): add missing imports after refactor

* refactor: implement initial precompile reverts

* test(api): add initial error checks

* refactor(api): improved fungibles error handling

* refactor(api): improved erc20 error handling

* build(deps): add missing base64 feature

* refactor: resolve missing imports/trait bounds for runtime-benchmarks

* refactor(pallets/api): resolve clippy warnings

* test(pallets/api): fix minimum balance consideration with transfer

* test(pallets/api): remove unnecessary println

* test(pallets/api): fix minimum balance consideration with transfer
benchmark

* fix(api): allow removal of approval with zero value allowance

* refactor(api): check set_metadata result after refactoring

* chore: update cargo.lock after rebase

* style: formatting after rebase

* chore(api): update cargo.lock for contracts

* docs(api): remove todos

* ci: enable global cache disabling

* ci: reenable crate caching

* docs(pallets/api): remove token id size todo after discussion

* test(api): relocate and reduce initial value, gas and storage limits

* refactor(pallets/api): ensure all errors apart from insufficient gas
result in revert

* refactor(api): ensure full error coverage

* test(api): update expected errors

* chore(api): update cargo.lock

* chore: update cargo.lock

* refactor(pallets/api): simplify origin

* refactor(pallets/api): fix imports

* refactor(api): reuse selectors

* feat: messaging precompiles (#584)

* feat(pallets/api): add messaging precompiles

* feat(devnet): add messaging pallet

* feat(api): add initial messaging apis

* feat(api): add messaging example

* refactor(api): update callback encoding

* build(pallets/api): add empty ismp feature

* refactor: port on_initialize hook implementation

* style: formatting

* build(pallets/api): adjust ismp feature

* feat(pallets/api): add messaging benchmarks

* refactor(ismp): use u64 height

Destination state machine could use larger type, so standardise on the
same type provided by ismp.

* refactor(api): update imports after rebase

* style: formatting after rebase

* fix: remove duplicate imports after rebase

* refactor(api): add initial messaging error handling

* test(api): add error tests

* test(pallets/api): add remove tests

* test(pallets/api): add new_query tests

* test(pallets/api): add call tests

* test(pallets/api): add process_callback_weight tests

* test(pallets/api): add deposit_callback_event tests

* test(pallets/api): add fee management test

* test(pallets/api): add xcm_response tests

* test(pallets/api): add ismp tests

* refactor: limit ismp_response helper to tests

* refactor(pallets/api): use try_convert

* refactor(pallets/api): update messaging weights

* refactor(pallets/api): use global message identifier

Stores contract address in message to ensure authorised removal.
Additional benefits beyond reduced storage requirements are that any
contract can poll and use responses until originator removes.

* refactor(pallets/api): update weights after benchmarking

* fix(pallets/api): replace bounded_vec! usage within benchmarks

* refactor(pallets/api): callback response interfaces and encoding

* refactor(api): precompile and callback trait and type encoding
improvements

* feat(devnet): add messaging precompiles

* test(api): add initial messaging integration tests

* test(api): update ink dependency

* refactor(api): update ink dependency

* test(api): restore onpostresponse handler

* test(pallets/api): fix tests after refactor

* test(api): add ismp post integration tests

* refactor(pallets/api): rename response handler functions due to selector
clashes

A workaround for ink which does not allow two traits to be implemented
with a message with the same resulting selector.

* refactor(api): rename response handler functions due to selector clashes

* test(api): add xcm messaging integration tests

* build(api): updating ink to master

* docs(pallets/api): remove unnecessary todos

* docs(api): remove unnecessary todos

* docs(api): add hashed_account function docs

* feat(pallets/api): add (para) id getter to messaging precompiles

* feat(api): add (para) id getter to apis

* test(api): add (para) id getter integration test

* refactor(api): update messaging example with improvements

* refactor(api): improve return types of xcm execute and send helpers

* refactor(api): use ink_abi cfg for callback encoding

* refactor(pallets/api): restore ismp deposits

* test(pallets/api): increase message deposit

* docs(pallets/api): update comments on necessary clones of bytes type
during abi encoding

Data needs to be encoded for persistence if callback fails and therefore
cannot be owned.

* refactor(pallets/api): better handling of invalid callback encoding

* test(api): apply reduced initial value, gas, storage limits

* fix(pallets/api): surface storage deposit limit into callback
specification

* fix(api): allow specification of storage deposit limit for callback

* test(api): ensure storage deposit limit works

Also adjusts gas limits based on contract changes.

* refactor(devnet): update callbackexecutor.execute implementation to use
storage deposit limit

* refactor(api): update messaging example contract with storage deposit
limit

* fix(pallets/api): allow caller to specify ismp post recipient
module/address

* fix(api): allow caller to specify ismp post recipient module/address

* test(api): specify ismp post recipient mpdule/address

* refactor(devnet): configure max ismp post module/address length as 32
bytes

* docs(pallets/api): remove messageid size todo

u64::MAX provides a sufficiently large number for message identifier and
aligns with the same type used by XCM for query identifiers.

* refactor(pallets/api): add simple on_accept benchmark for consistency,
along with supporting module weight tests

* refactor(devnet): name ismp module via import alias

* refactor(devnet): add ismp weight provider

* docs(pallets/api): remove todo after tests added

* test(pallets/api): add integrity test to ensure maxresponselen

* refactor(pallets/api): update integrity test to include values

* refactor(pallets/api): update tryconvert usages to dispatcherror after
rebase

* chore: update cargo.lock

* chore(api): update cargo.lock for messaging contract

* refactor(pallets/api): use improved origin

* refactor(pallets/api): wrap fallible calls in closure to map errors

* refactor(pallets/api): use try_convert to simplify safe conversion

* refactor(pallets/api): ensure all errors apart from insufficient gas
result in revert

* refactor(api): ensure full error coverage

* test(api): update callback gas limits

* docs(api): add readmes

* docs(api): relocate messaging within readme

* docs(pallet-api): add weights overview from original pr

* docs(pallets-api): relocate weights.md

* docs(pallet-api): add description to messaging module

* docs(pallet-api): add readme

* docs(pallet-api): add initial messaging readme

* docs(pallets/api): add diagrams to messaging readme

---------

Co-authored-by: Frank Bell <frank@r0gue.io>

---------

Co-authored-by: Frank Bell <frank@r0gue.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants