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

[Storehouse] Optimize finalized reader to use block id index #5175

Merged
merged 7 commits into from
Dec 22, 2023

Conversation

zhangchiqing
Copy link
Member

This PR optimizes the FinalizedBlockIDAtHeight method of the FinalizedReader used by Storehouse

@zhangchiqing zhangchiqing force-pushed the leo/optimize-finalized-reader branch from 28959f5 to e24c7d3 Compare December 21, 2023 16:48
@@ -231,8 +231,8 @@ func (e *UnexecutedLoader) pendingUnexecutedBlocks(ctx context.Context, finalize
// if the EN is dynamically bootstrapped, the finalized blocks at height range:
// [ sealedRoot.Height, finalizedRoot.Height - 1] can not be retrieved from
// protocol state, but only from headers
func (e *UnexecutedLoader) getHeaderByHeight(height uint64) (*flow.Header, error) {
func (e *UnexecutedLoader) getHeaderByHeight(height uint64) (flow.Identifier, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (e *UnexecutedLoader) getHeaderByHeight(height uint64) (flow.Identifier, error) {
func (e *UnexecutedLoader) getBlockIDByHeight(height uint64) (flow.Identifier, error) {

Copy link
Contributor

Choose a reason for hiding this comment

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

same question here about not using e.headers.BlockIDByHeight(height) directly

@@ -89,8 +89,8 @@ func (e *UnfinalizedLoader) LoadUnexecuted(ctx context.Context) ([]flow.Identifi
// if the EN is dynamically bootstrapped, the finalized blocks at height range:
// [ sealedRoot.Height, finalizedRoot.Height - 1] can not be retrieved from
// protocol state, but only from headers
func (e *UnfinalizedLoader) getHeaderByHeight(height uint64) (*flow.Header, error) {
func (e *UnfinalizedLoader) getHeaderByHeight(height uint64) (flow.Identifier, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (e *UnfinalizedLoader) getHeaderByHeight(height uint64) (flow.Identifier, error) {
func (e *UnfinalizedLoader) getBlockIDByHeight(height uint64) (flow.Identifier, error) {

@@ -60,12 +60,12 @@ func (e *UnfinalizedLoader) LoadUnexecuted(ctx context.Context) ([]flow.Identifi
// reload its block to execution queues
// loading finalized blocks
for height := lastExecuted + 1; height <= final.Height; height++ {
header, err := e.getHeaderByHeight(height)
finalizedID, err := e.getHeaderByHeight(height)
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use e.headers.BlockIDByHeight directly?

@codecov-commenter
Copy link

codecov-commenter commented Dec 21, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (3d8d907) 56.43% compared to head (17b28f4) 56.49%.
Report is 86 commits behind head on master.

Files Patch % Lines
engine/consensus/approvals/testutil.go 70.00% 2 Missing and 1 partial ⚠️
...ne/execution/ingestion/loader/unexecuted_loader.go 50.00% 2 Missing ⚠️
engine/execution/state/state.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5175      +/-   ##
==========================================
+ Coverage   56.43%   56.49%   +0.06%     
==========================================
  Files         981      979       -2     
  Lines       93113    93149      +36     
==========================================
+ Hits        52551    52629      +78     
+ Misses      36673    36618      -55     
- Partials     3889     3902      +13     
Flag Coverage Δ
unittests 56.49% <76.66%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -231,8 +231,8 @@ func (e *UnexecutedLoader) pendingUnexecutedBlocks(ctx context.Context, finalize
// if the EN is dynamically bootstrapped, the finalized blocks at height range:
// [ sealedRoot.Height, finalizedRoot.Height - 1] can not be retrieved from
// protocol state, but only from headers
func (e *UnexecutedLoader) getHeaderByHeight(height uint64) (*flow.Header, error) {
func (e *UnexecutedLoader) getHeaderByHeight(height uint64) (flow.Identifier, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same question here about not using e.headers.BlockIDByHeight(height) directly

@zhangchiqing zhangchiqing added this pull request to the merge queue Dec 22, 2023
Merged via the queue into master with commit 7fc5f15 Dec 22, 2023
51 checks passed
@zhangchiqing zhangchiqing deleted the leo/optimize-finalized-reader branch December 22, 2023 20:32
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.

4 participants