Skip to content

Conversation

@f-gate
Copy link
Contributor

@f-gate f-gate commented Apr 25, 2025

TODO:

  • include integration tests
  • complete + link docs
  • update pop-api
  • Runtime config and review
  • regenerate weights
  • signed ISMP

[sc-3644]

f-gate and others added 30 commits February 26, 2025 19:12
* messaging mock impl

* query status refactor, fix stuck deposits, write first test

* remove tests 1

* refactor remove extrinsic for better testing

* second refactor, much better

* fmt

* fmt, fixes, test, benchmark

* refactor storage deposits

* check warnings

* fmt

* Off chain and on chain byte fees

* fmt

* comments

* remove useless test

* fmt

* fix

* moar tests

* xcm-new-query benchmark

* fmt

* refactor response status

* xcm timeouts

* refactor to original format

* fix tests

* tests

* moar tests, hooks, xcm_response

* fmt

* xcm_response benchmark

* fmt

* fix

* fmt

* lock

* comments

* fmt
* messaging mock impl

* query status refactor, fix stuck deposits, write first test

* remove tests 1

* refactor remove extrinsic for better testing

* second refactor, much better

* fmt

* fmt, fixes, test, benchmark

* refactor storage deposits

* check warnings

* fmt

* Off chain and on chain byte fees

* fmt

* comments

* remove useless test

* fmt

* fix

* moar tests

* xcm-new-query benchmark

* fmt

* refactor response status

* xcm timeouts

* refactor to original format

* fix tests

* tests

* moar tests, hooks, xcm_response

* fmt

* xcm_response benchmark

* fmt

* fix

* fmt

* lock

* make callback events unit testable

* failing test for imbalance handler

* call tests

* comments

* fmt

* add the new weight to fee config, config test

* fmt

* fmt

* lock

* comments
* messaging mock impl

* query status refactor, fix stuck deposits, write first test

* remove tests 1

* refactor remove extrinsic for better testing

* second refactor, much better

* fmt

* fmt, fixes, test, benchmark

* refactor storage deposits

* check warnings

* fmt

* Off chain and on chain byte fees

* fmt

* comments

* remove useless test

* fmt

* fix

* moar tests

* xcm-new-query benchmark

* fmt

* refactor response status

* xcm timeouts

* refactor to original format

* fix tests

* tests

* moar tests, hooks, xcm_response

* fmt

* xcm_response benchmark

* fmt

* fix

* fmt

* lock

* make callback events unit testable

* failing test for imbalance handler

* call tests

* comments

* fmt

* add the new weight to fee config, config test

* fmt

* response benchmark finallyl

* benchmarks, tests, mock ismp impl for commitments

* fmt

* another test

* fmt

* ismp post tests

* process response refactor

* p2

* basic tests 1

* fmt

* tests-2

* fixes, signed ismp, fee comments

* finale benchmark

* fmt

* handle resposne timeout

* fmt

* ismp relayer fee as config item

* fmt

* benchmarks 2

* fmt

* Update pallets/api/src/messaging/benchmarking.rs

Co-authored-by: Peter White <petras9789@gmail.com>

* comments, utils refactor

* fmt lock

---------

Co-authored-by: Peter White <petras9789@gmail.com>
f-gate and others added 8 commits April 7, 2025 14:52
* impl

* refunds :)

* fmt

* takes deposit update

* fmt

* fix

* fmt

* comments

* fmt
* dependancy wild goose chase

* marathon

* fix

* emit and test timeout events

* fix

* dummy

* benchmarking

* fix

* fix commitments, errs on callbacks, fix replay vuln

* fmt

* no errors, callbacks executre

* finally some annotations

* ismp hook weight annotations

* timeout tests

* fix tests

* fix benchmark tests

* fmt

* documentation and formatting

* fix

* implements new benchmarks into devnet

* clippy

* fix

* fmt

* more warnings

* fmt

* pop-bench remove

* comments
* dependancy wild goose chase

* marathon

* fix

* stash

* xcm_query test improvement, transfer response fee

* imsp-get tests 1

* fmt

* imsp_post tests, ismp-get fix, xcm-fix

* fmt

* emit and test timeout events

* fix

* dummy

* benchmarking

* fix

* fix commitments, errs on callbacks, fix replay vuln

* fmt

* no errors, callbacks executre

* finally some annotations

* ismp hook weight annotations

* timeout tests

* fix tests

* fix benchmark tests

* fmt

* documentation and formatting

* fix

* implements new benchmarks into devnet

* clippy

* fix

* fmt

* more warnings

* fmt

* pop-bench remove

* refactor response fee

* comments

* refactor 2, fix tests

* fmt

* remove takes fee for ismp

* fmt
* dependancy wild goose chase

* marathon

* fix

* stash

* xcm_query test improvement, transfer response fee

* imsp-get tests 1

* fmt

* imsp_post tests, ismp-get fix, xcm-fix

* fmt

* emit and test timeout events

* fix

* dummy

* benchmarking

* fix

* fix commitments, errs on callbacks, fix replay vuln

* fmt

* no errors, callbacks executre

* finally some annotations

* ismp hook weight annotations

* timeout tests

* fix tests

* fix benchmark tests

* fmt

* documentation and formatting

* fix

* implements new benchmarks into devnet

* clippy

* fix

* fmt

* more warnings

* fmt

* pop-bench remove

* refactor response fee

* comments

* refactor 2, fix tests

* fmt

* release cb deposit and refactor

* add tests

* benchmarks

* warnings

* fmt

* remove takes fee for ismp

* fmt
* implementation

* tests 1

* fmt

* tests 2

* benchmark

* fmt

* weights

* fmt

* comments

* fmt

* clippy

* fix tests
* manually adjust weight of callback

* fmt

* fix

* refactor for ease of testing

* fmt

* docs

* process callback weight tests

* final tests and review

* fmt

* fixes

* fix

* comments

* fmt

* one more

* fixes, warning

* fmt
@f-gate f-gate requested review from evilrobot-01 and peterwht April 25, 2025 09:30
@f-gate f-gate marked this pull request as ready for review April 25, 2025 09:37
f-gate and others added 4 commits April 25, 2025 13:54
…#548)

* progress

* use credit and balanced

* sort

* fmt

* fix-runtimes

* fmt

* use proper dealwithfees on devnet

* fmt
…tion (#549)

* impl

* fmt

* regression-test

* fmt

* defensive blockspace

* fmt
@peterwht peterwht requested a review from Copilot May 7, 2025 15:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements messaging v1 by integrating messaging logic into various pallets and updating tests, configuration, and documentation. Key changes include updated ISMP router behavior, enhancements to messaging query and callback handling, and additional integration tests and weight documentation.

Reviewed Changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated no comments.

Show a summary per file
File Description
runtime/devnet/src/config/ismp.rs Updated ISMP router to use a new error variant and handler.
runtime/devnet/src/config/api/mod.rs Added messaging read queries and weights to the API config.
pop-api/integration-tests/src/messaging.rs Modified event assertions and updated contract instantiation in tests.
pop-api/examples/messaging/lib.rs Minor formatting update in the contract module.
pop-api/Cargo.toml Updated feature flags with messaging support.
pallets/api/src/nonfungibles/benchmarking.rs Adjusted imports to include new traits.
pallets/api/src/mock.rs Updated mock runtime to integrate messaging and ISMP modules.
pallets/api/src/messaging/transports/ismp.rs Refactored ISMP transport: added max encoded length derives and improved deposit handling.
pallets/api/src/messaging/weights.rs Added a new weights trait implementation for messaging calls.
pallets/api/src/messaging/deposits.rs Introduced functions to calculate protocol and message deposits.
extension/src/lib.rs Updated Extension type to include explicit generic specification.
Cargo.toml Adjusted workspace members and dependency configurations.
Comments suppressed due to low confidence (2)

pop-api/integration-tests/src/messaging.rs:414

  • The Contract::new function contains unreachable code after returning the struct instance. Consider removing the redundant instantiation that follows the initial return.
fn new() -> Self { ... let (address, account_id) = instantiate(CONTRACT, INIT_VALUE, function_selector("new"), vec![]); Self { address, id: account_id }

pallets/api/src/messaging/transports/ismp.rs:118

  • [nitpick] Consider renaming 'Handler' to a more descriptive name like 'IsmpHandler' to improve code clarity regarding its role in processing ISMP messages.
pub struct Handler<T>(PhantomData<T>);

Copy link
Collaborator

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

Apologies for the avalanche of comments. Tests, benchmarks and runtime config not yet reviewed as a result.

Great work on the callback deposits and use of Unbalanced, very elegant solution. Commented out integration tests and benchmarks that do not compile is disappointing.

"extension/contract",
"pop-api",
"tests/contracts",
"integration-tests",
Copy link
Collaborator

Choose a reason for hiding this comment

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

PR description shows integration tests as a 'completed' todo, yet they are excluded?

"node",
"pallets/*",
"pop-api/integration-tests",
#"pop-api/integration-tests",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Obviously cant merge into main until this is resolved. There is no corresponding todo in the PR description.

pallet-ismp-rpc = { git = "https://github.com/r0gue-io/ismp", branch = "polkadot-stable2412", default-features = false }
pallet-ismp-runtime-api = { git = "https://github.com/r0gue-io/ismp", branch = "polkadot-stable2412", default-features = false }

# Revive
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be removed after a rebase please?

IsmpRequests::<T>::get(commitment).ok_or(Error::Custom("request not found".into()))?;
ensure!(
response_data.encoded_size() <= T::MaxResponseLen::get() as usize,
Error::Custom("Response length exceeds maximum allowed length.".into())
Copy link
Collaborator

Choose a reason for hiding this comment

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

How will the contract know about this? Should it be emitted as an event instead for offchain workflow rather than error? Perhaps messages should transition to errored as well as timed out?

return Err(Error::Custom("Message must be an ismp request.".into()).into());
};

// Deposit that the message has been recieved before a potential callback execution.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Deposit that the message has been recieved before a potential callback execution.
// Deposit that the message has been received before a potential callback execution.

Pallet::<T>::deposit_event(event(origin, id));
if Pallet::<T>::call(&initiating_origin, callback, &id, response_data).is_ok() {
// Clean storage, return deposit
Messages::<T>::remove(&initiating_origin, id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shared be a shared remove function to ensure that all cleanup is done consistently across the pallet, otherwise maintainers need to know to update cleanup handling in x different places.

Ok(())
})?;

crate::messaging::Pallet::<T>::deposit_event(Event::<T>::IsmpTimedOut {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
crate::messaging::Pallet::<T>::deposit_event(Event::<T>::IsmpTimedOut {
Pallet::<T>::deposit_event(Event::<T>::IsmpTimedOut {

Unnecessary prefix

else {
return Err(Error::Custom("Invalid message".into()));
};
let callback_deposit = callback.map(|cb| T::WeightToFee::weight_to_fee(&cb.weight));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would prefer this is only calculated at time of deposit taken, as mentioned elsewhere.

@evilrobot-01 evilrobot-01 mentioned this pull request Jul 7, 2025
5 tasks
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.

3 participants