-
Notifications
You must be signed in to change notification settings - Fork 39
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
Perf fixes #1678
Perf fixes #1678
Conversation
- add canonical condition to sql to hit the index
WalkthroughThe changes involve a shift in the method for retrieving the head block within the enclave's logic, moving from a storage-based approach to one that utilizes a block processor. Additionally, there's an update to SQL queries to filter for canonical batches when fetching transaction lists and counts, ensuring that only data associated with canonical batches is considered. Changes
TipsChat with CodeRabbit Bot (
|
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.
LGTM
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- go/enclave/enclave.go (2 hunks)
- go/enclave/storage/enclavedb/batch.go (1 hunks)
Additional comments: 2
go/enclave/enclave.go (1)
- 322-328: The change from
storage.FetchHeadBlock()
tol1BlockProcessor.GetHead()
in theStatus
method is consistent with the PR's performance objectives. However, ensure that the error handling is robust, especially since the comment on line 327 suggests that failing to fetch the L1 head block might be normal during startup.go/enclave/storage/enclavedb/batch.go (1)
- 47-48: The changes to the SQL queries
queryTxList
andqueryTxCountList
correctly implement the performance improvement by adding thewhere batch.is_canonical=true
condition. This should leverage the [height, is_canonical] index more effectively as intended in the PR objectives. Ensure that the rest of the system expects and correctly handles the now potentially reduced result set due to this new filter.
var hash common.L1BlockHash | ||
l1Head, err := e.storage.FetchHeadBlock() | ||
l1Head, err := e.l1BlockProcessor.GetHead() | ||
// todo - handle error | ||
if err == nil { | ||
hash = l1Head.Hash() |
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.
The rejectBlockErr
method has been updated to use l1BlockProcessor.GetHead()
instead of storage.FetchHeadBlock()
. It is important to handle the potential error from GetHead()
call properly. Currently, there is a todo
comment indicating that error handling needs to be addressed. This should be resolved to ensure that errors are handled correctly and do not lead to unexpected behavior.
l1Head, err := e.l1BlockProcessor.GetHead()
- // todo - handle error
+ if err != nil {
+ // Handle the error appropriately
+ }
if err == nil {
Committable suggestion
❗ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
var hash common.L1BlockHash | |
l1Head, err := e.storage.FetchHeadBlock() | |
l1Head, err := e.l1BlockProcessor.GetHead() | |
// todo - handle error | |
if err == nil { | |
hash = l1Head.Hash() | |
var hash common.L1BlockHash | |
l1Head, err := e.l1BlockProcessor.GetHead() | |
if err != nil { | |
// Handle the error appropriately | |
} | |
if err == nil { | |
hash = l1Head.Hash() |
- add canonical condition to sql to hit the index (cherry picked from commit fb50c7b)
Why this change is needed
to improve performance
What changes were made as part of this PR
PR checks pre-merging
Please indicate below by ticking the checkbox that you have read and performed the required
PR checks