-
Notifications
You must be signed in to change notification settings - Fork 53
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
offchain - commit store updates fetching optimization #195
Conversation
core/services/ocr2/plugins/ccip/commit_price_updates_cache_test.go
Outdated
Show resolved
Hide resolved
core/services/ocr2/plugins/ccip/commit_price_updates_cache_test.go
Outdated
Show resolved
Hide resolved
core/services/ocr2/plugins/ccip/commit_price_updates_cache_test.go
Outdated
Show resolved
Hide resolved
core/services/ocr2/plugins/ccip/commit_reporting_plugin_test.go
Outdated
Show resolved
Hide resolved
core/services/ocr2/plugins/ccip/commit_reporting_plugin_test.go
Outdated
Show resolved
Hide resolved
CCIP-1147 - Cache last update
func (c *priceUpdatesCache) updateTokenPriceIfMoreRecent(ts time.Time, tk common.Address, val *big.Int) bool { | ||
c.mu.RLock() | ||
v, exists := c.tokenPriceUpdates[tk] | ||
c.mu.RUnlock() |
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.
Shouldn't we keep the lock over the entire method?
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.
If we keep the lock over the entire method we will have a deadlock.
If we use only a Lock()
over the entire method, instead of both RLock()
for read and Lock()
for updates then it's slightly less efficient.
Closing, seems that we are not going with this approach atm. |
So far the commit plugin keeps fetching multiple logs/events that were already fetched on the previous ocr2 round
But this is not efficient for the performance of the db and the plugin.
A better approach would be to only get the new token price updates since the last time this call was made.