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

hpl-54: quote gas #66

Merged
merged 3 commits into from
Dec 12, 2023
Merged

hpl-54: quote gas #66

merged 3 commits into from
Dec 12, 2023

Conversation

byeongsu-hong
Copy link
Collaborator

@byeongsu-hong byeongsu-hong commented Nov 7, 2023

This has API breaking changes in mailbox contract.

  • added sender field to QuoteDispatch query msg

resolves HPL-54

Copy link

linear bot commented Nov 8, 2023

HPL-54 Aggregate hook does not consider alternate denominations

The quote_dispatch function in contracts/hooks/aggregate/src/lib.rs:147 does not account for the possibility of having gas coins of different denominations. It incorrectly assumes that all gas coins are of the same denomination, which cannot be guaranteed. Ultimately this will cause an error further in the execution of the dispatch when the necessary funds are not present.

Recommendation

We recommend ensuring that the gas denomination is the same as the denomination as the gas_total that is being calculated.

@byeongsu-hong byeongsu-hong changed the title fix: quote gas hpl-54: quote gas Nov 9, 2023
@yorhodes
Copy link
Contributor

@byeongsu-hong I think the linked linear issue is incorrect?

Comment on lines +74 to +75
MailboxHookQueryMsg::QuoteDispatch { sender, msg } => {
to_binary(quote_dispatch(deps, sender, msg))
Copy link
Contributor

@yorhodes yorhodes Nov 20, 2023

Choose a reason for hiding this comment

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

we do not want to special case the parameters here with a sender
in the solidity contracts we have a generic metadata param that the message sender can pass through

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks for your information, i'll update it after reviewing v3 solidity contract

Copy link
Collaborator Author

@byeongsu-hong byeongsu-hong Nov 23, 2023

Choose a reason for hiding this comment

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

after reviewing, so the reason why we decided to add sender to QueryMsg is msg.sender is needed to build a dispatch message according to here

Copy link
Contributor

Choose a reason for hiding this comment

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

isn't the sender here a subset of msg? we want to allow arbitrary metadata to be passed through
see https://docs.hyperlane.xyz/docs/reference/hooks/overview

Copy link
Collaborator Author

@byeongsu-hong byeongsu-hong Dec 3, 2023

Choose a reason for hiding this comment

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

Of course yes. msg has the type DispatchMsg which is grouped representation of argument dispatch / quote_dispatch in solidity - it has the optional metadata field for custom use cases.
+ It's impossible to construct the mailbox message in case of quoting dispatch due to there's no way to track msg.sender of QueryMsg.

Copy link
Contributor

Choose a reason for hiding this comment

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

this makes sense
let's make sure we are consistent everywhere we use info.sender in execute to pass through a sender in the corresponding query

@@ -69,7 +69,7 @@ pub struct MailboxResponse {

#[cw_serde]
pub struct QuoteDispatchResponse {
pub gas_amount: Option<Coin>,
pub gas_amount: Vec<Coin>,
Copy link
Contributor

Choose a reason for hiding this comment

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

can we rename this from gas_amount since it also includes the denomination? how about fees?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes i realized there's update on terms about gas fee to protocol fee. makes sense i'll change it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • how about consider using protocol_fee to make clear to understand

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nvm changed to fees

Comment on lines 137 to 143
let mut total_gas = required_gas.clone().into_iter().try_fold(
Coins::try_from(base_gas.clone())?,
|mut acc, gas| {
acc.add(gas)?;
StdResult::Ok(acc)
},
)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

if the denominations are not the same, we should return both rather than add them together

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cosmwasm_std::Coins's add method contains the logic that you mentioned.

@byeongsu-hong
Copy link
Collaborator Author

@yorhodes i think this update fully covers that issue because there's no need to check single denomination if we use multi denom protocol fee, so i linked it

@byeongsu-hong byeongsu-hong merged commit 77a1cc2 into develop Dec 12, 2023
@byeongsu-hong byeongsu-hong deleted the eddy/fix-mailbox-gas branch December 12, 2023 14:28
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.

2 participants