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

fix(hyperlane-ethereum): only apply gas overrides when submitting #5062

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

daniel-savu
Copy link
Contributor

@daniel-savu daniel-savu commented Dec 20, 2024

Description

We want gas overrides (and the gas buffer) to be added to a tx just before submitting, to increase its chances of landing. However we want these to be excluded in the prepare step when just checking that the sender's gas payment is enough to approximately cover the estimated gas_limit returned by the destination chain RPC

Drive-by changes

Related issues

Backward compatibility

Yes

Testing

will rely on e2e and will first release this to the RC context

Copy link

changeset-bot bot commented Dec 20, 2024

⚠️ No Changeset found

Latest commit: 02c74ee

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -315,6 +315,7 @@ where
&self,
message: &HyperlaneMessage,
metadata: &[u8],
apply_gas_overrides: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: maybe we can have a ContractCallOptions struct that holds different parameters. I think this makes the code a bit easier to read compared to a boolean function parameter.
But I also see some places that don't have tx_gas_estimate, so not sure.

#[derive(Clone, Debug)]
pub struct ContractCallOptions {
    pub apply_gas_overrides: bool,
    pub tx_gas_estimate: Option<U256>,
}

async fn process_contract_call(
    &self,
    message: &HyperlaneMessage,
    metadata: &[u8],
    options: &ContractCallOptions,
) -> ChainResult<ContractCall<M, ()>> {
    ...
}

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.53%. Comparing base (5467c65) to head (02c74ee).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5062   +/-   ##
=======================================
  Coverage   77.53%   77.53%           
=======================================
  Files         103      103           
  Lines        2110     2110           
  Branches      190      190           
=======================================
  Hits         1636     1636           
  Misses        453      453           
  Partials       21       21           
Components Coverage Δ
core 87.80% <ø> (ø)
hooks 79.39% <ø> (ø)
isms 83.68% <ø> (ø)
token 91.27% <ø> (ø)
middlewares 79.80% <ø> (ø)

Copy link
Contributor

@cmcewen cmcewen left a comment

Choose a reason for hiding this comment

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

Tests not all passing

@@ -355,7 +355,7 @@ impl PendingOperation for PendingMessage {
if self
.ctx
.destination_mailbox
.process_estimate_costs(&self.message, metadata)
.process_estimate_costs(&self.message, metadata, true)
Copy link
Collaborator

@tkporter tkporter Dec 21, 2024

Choose a reason for hiding this comment

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

any reason why this needs to be true?

iiuc this being true or false doesn't change the behavior we care about, which is just that an eth_estimateGas is successful. We don't care about the buffer being applied or anything here

I think if it doesn't matter, then we can keep the process_estimate_costs interface the same as before, and just have process_contract_call be the one with the interface change, and have process_estimate_costs always pass false as this param to process_contract_call. I think this would be kinda nice because it'd keep the Mailbox trait impl more self explanatory / simple, and the whole gas buffer application stuff feels like it's an EVM detail that maybe shouldn't be mentioned on the VM-agnostic interface

) -> ChainResult<TxCostEstimate> {
let contract_call = self.process_contract_call(message, metadata, None).await?;
let contract_call = self
.process_contract_call(message, metadata, apply_gas_overrides, None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think if apply_gas_overrides is false, when we call process_contract_call we end up never calling eth_estimateGas, and we'd hit the .ok_or(HyperlaneProtocolError::ProcessGasLimitRequired)?; - I assume this is why e2e is failing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Don't apply gas buffer twice
4 participants