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

Properly test callbacks to contracts #14

Merged
merged 19 commits into from
Oct 1, 2022
Merged

Conversation

ethanfrey
Copy link
Member

@ethanfrey ethanfrey commented Aug 19, 2022

Extends #13

Main goal is to add a contract we can use to ensure callbacks work properly.
We also open up the IbcQuery to use QueryRequest not just WasmQuery.

We add a new callback-capturer contract that can call the simple_ica_controller with a callback and then stores it locally. This is not so interesting for production, but a great way to test and query on a full-stack integration test.

Add some TS tests that have the contract call the controller with callbacks enabled and store the result upon ack callback. It works properly now and found some issues in the existing Rust code interactions.

(When reviewing, you can skip all callback-capturer first and look at changes to the other contracts. That shows changes to the core logic. This is a test contract and probably just needs a basic review, but other changes deserve more attention)

@ethanfrey ethanfrey mentioned this pull request Aug 19, 2022
1 task
Base automatically changed from improve-callbacks to main August 19, 2022 15:44
@ethanfrey ethanfrey marked this pull request as ready for review August 19, 2022 20:08
@ethanfrey
Copy link
Member Author

This is completed. Proper full stack tests with the callback contract receiving and storing the result properly.

@ethanfrey ethanfrey changed the title Add capturer contracts Properly test callbacks to contracts Aug 19, 2022
@ethanfrey
Copy link
Member Author

@webmaster128 or @JakeHartnell I'd like a review here so I can merge it in.

Maybe comments on how to improve the implementation as well

Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

Nice!

I guess the example would be better to understand if the callback capturer had an identity of its own and not only pass requests one step further. But this is just some feeling imagening a newcomer trying to understand all this wiring.

I think we should find a better name for "IBC query" because IBC queries are something different that do not require the data source chain to perform any writes. Maybe something like "foreign query" (i.e. a query executed on the other chain, not only reading the other chain). But I don't think I have a great solution here.

contracts/callback-capturer/NOTICE Outdated Show resolved Hide resolved
contracts/callback-capturer/README.md Outdated Show resolved Hide resolved
contracts/callback-capturer/Cargo.toml Outdated Show resolved Hide resolved
contracts/simple-ica-controller/src/contract.rs Outdated Show resolved Hide resolved
msg: to_binary(&ReceiveIbcResponseMsg { id, msg })?,
funds: vec![],
});
.add_message(ReceiveIbcResponseMsg { id, msg }.into_cosmos_msg(sender)?);
Copy link
Member

Choose a reason for hiding this comment

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

Should this be a sub-message with gas limit? Because simple-ica-controller has no control over what the callback capturer executes. I guess we don't want the relayer to be responsible for paying all the gas of something heavy.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a very good design question. So far this is a "sample", but it would be good to raise such an issue as to be useful in production, we would need some limit

Copy link
Member

Choose a reason for hiding this comment

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

For me the motivation would be to tell the reader: Hey, look, this is something you need to think about!

Copy link
Contributor

Choose a reason for hiding this comment

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

Can add a comment. Something like:

Suggested change
.add_message(ReceiveIbcResponseMsg { id, msg }.into_cosmos_msg(sender)?);
// In production, you may want to think about gas limits for this callback.
.add_message(ReceiveIbcResponseMsg { id, msg }.into_cosmos_msg(sender)?);

Copy link
Member Author

@ethanfrey ethanfrey Oct 1, 2022

Choose a reason for hiding this comment

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

Leaving this unresolved, as this is something important to revisit.
Made issue #17 for it

packages/simple-ica/src/callback.rs Outdated Show resolved Hide resolved
@ethanfrey ethanfrey merged commit dca9dea into main Oct 1, 2022
@ethanfrey ethanfrey deleted the add-capturer-contracts branch October 1, 2022 19:45
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.

None yet

3 participants