-
Notifications
You must be signed in to change notification settings - Fork 43
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
Conversation
if err != nil { | ||
return nil, fmt.Errorf("error while on ramp contract. Error: %v", err) | ||
} | ||
iterator, err := onRampContract.FilterCCIPSendRequested(&bind.FilterOpts{ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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