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

[CCIP-3376] Add component into CCIP price estimators to account for c… #1446

Merged

Conversation

valerii-kabisov-cll
Copy link
Contributor

@valerii-kabisov-cll valerii-kabisov-cll commented Sep 18, 2024

https://smartcontract-it.atlassian.net/browse/CCIP-3376

The CCIP gas limit is set by customers. This cannot be changed because this limit is directly used within the contracts (which expect limits in terms of ETH). Also, the L2 gas price returned from our current estimators for Mantle is in MNT. Therefore, the final formula needed for CCIP to calculate L2 transaction fees is the following:
gasLimit_EVM * (gasPrice_Mantle * TokenRatio)
Therefore, we need to multiply the gas price returned from our gas estimators by tokenRatio for CCIP. This should happen in the CCIP price estimator. Currently, we have no component here for chain-specific logic, so we will need to add this functionality.

core/services/relay/evm/evm.go Outdated Show resolved Hide resolved
core/services/relay/evm/evm.go Outdated Show resolved Hide resolved
core/services/relay/evm/evm.go Show resolved Hide resolved
// ModifyGasPriceComponents returns modified gasPrice.
func (i *Interceptor) ModifyGasPriceComponents(ctx context.Context, execGasPrice, daGasPrice *big.Int) (*big.Int, *big.Int, error) {
if time.Since(i.tokenRatioLastUpdate) > tokenRatioUpdateInterval {
mantleTokenRatio, err := i.getMantleTokenRatio(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we can't just call contracts directly from the plugin logic, can we @dimkouv . I think it should belong to some reader to stay compliant with loops

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this logic is hidden behind the custom provider interface it should still be compliant with loops.

@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
70.7% Coverage on New Code (required ≥ 75%)
29.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube

@valerii-kabisov-cll valerii-kabisov-cll merged commit ebc7094 into ccip-develop Sep 24, 2024
116 of 117 checks passed
@valerii-kabisov-cll valerii-kabisov-cll deleted the CCIP-3376-custom-mantle-price-estimator branch September 24, 2024 15:31
valerii-kabisov-cll added a commit that referenced this pull request Oct 3, 2024
#1446)

[https://smartcontract-it.atlassian.net/browse/CCIP-3376](https://smartcontract-it.atlassian.net/browse/CCIP-3376)

The CCIP gas limit is set by customers. This cannot be changed because
this limit is directly used within the contracts (which expect limits in
terms of ETH). Also, the L2 gas price returned from our current
estimators for Mantle is in MNT. Therefore, the final formula needed for
CCIP to calculate L2 transaction fees is the following:
gasLimit_EVM * (gasPrice_Mantle * TokenRatio)
Therefore, we need to multiply the gas price returned from our gas
estimators by tokenRatio for CCIP. This should happen in the CCIP price
estimator. Currently, we have no component here for chain-specific
logic, so we will need to add this functionality.

---------

Co-authored-by: Matt Yang <[email protected]>
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.

5 participants