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

Merge messages submessages #961

Merged
merged 25 commits into from
Jun 18, 2021
Merged

Merge messages submessages #961

merged 25 commits into from
Jun 18, 2021

Conversation

ethanfrey
Copy link
Member

@ethanfrey ethanfrey commented Jun 16, 2021

Closes #953
Closes #948

This is a start now to show a new API, I will update some contracts to give a feel how easy/hard this is

  • Add ReplyOn::Never.
  • Add SubMsg helpers for easy transtion (BankMsg::Send{}.into() gives a SubMsg<T>)
  • Remove submessages field and make messages field use SubMsg not CosmosMsg
  • Tests pass in std
  • Update contracts
  • Tests pass in vm and other packages
  • Update docstrings
  • Update CHANGELOG
  • Update MIGRATION

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 start. I wonder if this is really helping if it requres us to set ID, reply on and gas limit for every message.

packages/std/src/results/subcall.rs Outdated Show resolved Hide resolved
packages/std/src/results/response.rs Outdated Show resolved Hide resolved
packages/std/src/results/subcall.rs Outdated Show resolved Hide resolved
@ethanfrey
Copy link
Member Author

I will fix a few compiler errors then leave this here for us to reflect on naming.

It seems the only real issue is the best naming/syntax to convert BankMsg or WasmMsg variants to a "fire-and-forget" type SubMsg, right?

@webmaster128
Copy link
Member

It seems the only real issue is the best naming/syntax to convert BankMsg or WasmMsg variants to a "fire-and-forget" type SubMsg, right?

Yes, but I think it is a conceptual question: how do we preserve the simplicity of messages if we integrate them into the fully featured submessages.

@ethanfrey
Copy link
Member Author

ethanfrey commented Jun 16, 2021

Yes, but I think it is a conceptual question: how do we preserve the simplicity of messages if we integrate them into the fully featured submessages.

That was my thinking to allow BankMsg::Send{}.into() to work like an old-style message and make this change transparent to the users.
If they want to use the power of SubMsg then they have some explicit constructors.

@ethanfrey
Copy link
Member Author

Making proposed changes from #953 (comment)

One thing that I realized was Response.add_message() and Response.add_submessage(). Shall I keep them both, but do an implicit SubMsg::new on the first? So we have:

let mut res = Response::new();
res.add_message(BankMsg::Send{...});
res.add_submessage(SubMsg::reply_on_error(WasmMsg::Execute{ .. }, 1234));

They both are pretty clear APIs. add_message maintains the same usage and semantics as before. add_submessage is the same as before as well, but with some nicer SubMsg constructors.

@webmaster128
Copy link
Member

One thing that I realized was Response.add_message() and Response.add_submessage(). Shall I keep them both, but do an implicit SubMsg::new on the first?

Good questions. Let'd do this for the first step and then see if/how we can improve from there.

@ethanfrey ethanfrey marked this pull request as ready for review June 17, 2021 13:14
@ethanfrey
Copy link
Member Author

Just missing the MIGRATING.md updates, but waiting for final review and any last API changes for that.

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.

Very cool.

Could you as part of this change also remove this?

impl Default for ReplyOn {
    fn default() -> Self {
        ReplyOn::Always
    }
}

I don't think ReplyOn should have a default anymore.

contracts/reflect/src/contract.rs Show resolved Hide resolved
@@ -8,6 +8,7 @@ while getopts c option; do
case "${option}" in

c) op="check" ;;
*) ;;
Copy link
Member

Choose a reason for hiding this comment

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

Ah, @uint could you install shellcheck on your system? It is executed automatically on all our scripts if available because of this line: command -v shellcheck >/dev/null && shellcheck "$0"

packages/std/src/ibc.rs Outdated Show resolved Hide resolved
packages/std/src/ibc.rs Show resolved Hide resolved
packages/std/src/results/response.rs Outdated Show resolved Hide resolved
packages/std/src/results/subcall.rs Outdated Show resolved Hide resolved
packages/std/src/results/subcall.rs Outdated Show resolved Hide resolved
@ethanfrey
Copy link
Member Author

Okay, made requested changes. Let's see if the CI catches anything

@ethanfrey
Copy link
Member Author

@webmaster128 from my view, this is done and ready to merge. Can I get a final approval, or last change requests?

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 solution 🏅 Added some minor text polishing as a commit. Good to merge.

@webmaster128 webmaster128 merged commit f275d78 into main Jun 18, 2021
@webmaster128 webmaster128 deleted the merge-messages-submessages branch June 18, 2021 12:50
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.

Merge messages and submessages Necessity for ReplyOn::Never
2 participants