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-4703: Adding check for ChainFeeUpdates field #410

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

b-gopalswami
Copy link
Collaborator

Added missing check for ChainFeeUpdates field.

The review comment asks to check for non-positive value on DataAvailableFee field but I believe that can be zero when it is EVM chain so keeping that check for only non-negative values. Only if it is L2 chain, it should be non-positive.

return fmt.Errorf("nil or non-positive %s", "execution fee price")
}

if update.ChainFee.DataAvFeePriceUSD == nil || update.ChainFee.DataAvFeePriceUSD.Cmp(zero) < 0 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe this DataAvFeePriceUSD might be zero for EVM chain and shouldn't be zero for L2 chains. Is that right? If at all we can know the given chain is L2, then we can add additional check here.

commit/chainfee/validate_observation.go Outdated Show resolved Hide resolved
commit/chainfee/validate_observation.go Show resolved Hide resolved
commit/chainfee/validate_observation.go Show resolved Hide resolved
commit/chainfee/validate_observation.go Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jan 7, 2025

Metric cl33-07 main
Coverage 76.5% 76.4%

for _, token := range obs.NativeTokenPrices {
if token.Int == nil || token.Int.Cmp(zero) <= 0 {
return fmt.Errorf("nil or non-positive %s", "execution fee")
func (p *processor) ValidateObservedChains(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function shouldn't be public since it'll only get called from the chainfee processor

if err != nil {
return fmt.Errorf("failed to get supported chains: %w", err)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We'll need to add extra checks here to make sure that all keys in all maps are exactly the same, otherwise we can end up with same lengths but for different chains on different maps.


for _, token := range obs.NativeTokenPrices {
if token.Int == nil || token.Int.Cmp(zero) <= 0 {
return fmt.Errorf("nil or non-positive %s", "execution fee")
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Add validation for timpestamps making sure they're not zero or more than current utc timestamp.

Copy link
Contributor

@asoliman92 asoliman92 left a comment

Choose a reason for hiding this comment

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

Please add validation for timestamps and for keys in maps as mentioned in the comments.

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.

3 participants