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-3420: Fix IsRequestTriggeredWithinTimeframe #1445

Merged
merged 7 commits into from
Sep 18, 2024
Merged

Conversation

b-gopalswami
Copy link
Collaborator

@b-gopalswami b-gopalswami commented Sep 16, 2024

Motivation

The prior approach to find if there is traffic in a lane was not detecting the transactions properly. It could be due to the CCIPSendRequestedWatcher captures the event after it is initiated not any transaction before that.

Solution

The revised approach is to use the FilterCCIPSendRequested by a past derived block number and see if there is any traffic. The block number is derived by this formula:
filterFromBlock = latestBlockNumber - (SkipRequestIfAnotherRequestTriggeredWithin/avgBlockTime)
By this approach, we will be able to find traffic better.

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

if err != nil {
return nil, fmt.Errorf("error while on ramp contract. Error: %v", err)
}
iterator, err := onRampContract.FilterCCIPSendRequested(&bind.FilterOpts{
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for additional filtering you can just set the start block in existing watchEvents

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 tried that approach, but it appears that the filter is effective for retrieving historical events, while the watcher captures live events. As discussed, I have added a new function: it uses the filter approach for the first message to handle historical events and the watcher approach for subsequent messages to handle live events.

@b-gopalswami b-gopalswami marked this pull request as ready for review September 17, 2024 19:23
@b-gopalswami b-gopalswami requested review from a team as code owners September 17, 2024 19:23
@b-gopalswami b-gopalswami enabled auto-merge (squash) September 18, 2024 17:27
@b-gopalswami b-gopalswami merged commit f1adcc2 into ccip-develop Sep 18, 2024
109 checks passed
@b-gopalswami b-gopalswami deleted the ccip-3420 branch September 18, 2024 17:35
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