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

Implement dynamic gas fees for bridge transfers #784

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

0xmovses
Copy link
Contributor

Summary

  • RFCs: Link to RFC, Link to RFC, or $\emptyset$.
  • Categories: any of protocol-units, networks, scripts, util, cicd, or misc.

Changelog

Testing

Outstanding issues

@@ -650,11 +650,32 @@ impl GasMaster for EthClient {
}

async fn get_priority_gas_fee_estimate(&self) -> GasMasterResult<u64> {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's call priority gas estimate and you return the last block one. I thought you'll do a mean from the latest few blocks. If it's ok, perhaps it should better to call it get_last_block_priority_gas_fee for example.

let percentage_adjustment = 0.2; // 20% adjustment hardcoded for now

// Apply the percentage adjustment to base gas price
let adjusted_base_fee =
Copy link
Contributor

Choose a reason for hiding this comment

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

This part seem a little strange. You multiply an u64 by a U256 and the result is an u64. I think you use U256 because of the precision, but the U256 result is transformed to an u64. Not sure but you should convert the base_gas_price in a U256 and do the calculus on u256 for all and do the conversion to u64 at the end.
Here you let the compiler decide when to do the conversion.

Copy link
Contributor

Choose a reason for hiding this comment

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

More generally, we should use checked calculus functions like checked_mul or saturating_mul (if we don't care to detect overflow) for all our calculus.

@@ -650,11 +650,32 @@ impl GasMaster for EthClient {
}

async fn get_priority_gas_fee_estimate(&self) -> GasMasterResult<u64> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should use u128 for all gas and amount value because of the decimal use in Eth for example, you can exceed the u64 limit. I got the issue when calculating the transaction fee for Eth. The code: let transaction_fee_wei = estimate_gas * gas_price; has exceeded u64 during my test.

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

Successfully merging this pull request may close these issues.

2 participants