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

[Execution] Refactor Checker Engine #5184

Merged
merged 7 commits into from
Jan 8, 2024
Merged

Conversation

zhangchiqing
Copy link
Member

Close #5173

This PR refactors the checker engine to close #5173

@codecov-commenter
Copy link

codecov-commenter commented Dec 22, 2023

Codecov Report

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

Comparison is base (6459232) 56.63% compared to head (836c81c) 56.62%.

Files Patch % Lines
engine/execution/checker/core.go 52.87% 29 Missing and 12 partials ⚠️
engine/execution/checker/engine.go 0.00% 23 Missing ⚠️
cmd/execution_builder.go 0.00% 8 Missing ⚠️
cmd/execution_config.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5184      +/-   ##
==========================================
- Coverage   56.63%   56.62%   -0.02%     
==========================================
  Files         985      987       +2     
  Lines       94333    94448     +115     
==========================================
+ Hits        53427    53480      +53     
- Misses      36935    36986      +51     
- Partials     3971     3982      +11     
Flag Coverage Δ
unittests 56.62% <38.65%> (-0.02%) ⬇️

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.


// TODO: better to query seals from protocol state,
// switch to state.Final().LastSealed() when available
sealedExecuted, seal, err := c.findLatestSealedAtHeight(lastExecutedHeight)

This comment was marked as resolved.


// findLatestSealedAtHeight finds the latest sealed block at the given height
func (c *Core) findLatestSealedAtHeight(finalizedHeight uint64) (*flow.Header, *flow.Seal, error) {
_, seal, err := c.state.AtHeight(finalizedHeight).SealedResult()

This comment was marked as resolved.

return nil, nil, nil, fmt.Errorf("could not get the last sealed block: %w", err)
}

return lastSealed, lastFinal, lastSeal, err
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
return lastSealed, lastFinal, lastSeal, err
return lastSealed, lastFinal, lastSeal, nil

Copy link
Contributor

@janezpodhostnik janezpodhostnik left a comment

Choose a reason for hiding this comment

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

Looks good. Just left comments about some cosmetic issues

engine/execution/checker/core.go Outdated Show resolved Hide resolved
engine/execution/checker/core.go Outdated Show resolved Hide resolved
engine/execution/checker/core.go Outdated Show resolved Hide resolved
Comment on lines 68 to 80
ticker := time.NewTicker(tickInterval)
defer ticker.Stop() // critical for ticker to be garbage collected
for {
select {
case <-ticker.C:
err := c.runCheck()
if err != nil {
return err
}
case <-ctx.Done():
return nil
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be cleaner to do this part in the engine.go

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point

Comment on lines 83 to 84
// it skips when the last sealed has not been executed, and last executed has not been finalized.
func (c *Core) runCheck() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// it skips when the last sealed has not been executed, and last executed has not been finalized.
func (c *Core) runCheck() error {
// RunCheck skips when the last sealed has not been executed, and last executed has not been finalized.
func (c *Core) RunCheck() error {

Copy link
Member Author

@zhangchiqing zhangchiqing Jan 5, 2024

Choose a reason for hiding this comment

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

Any particular reason to make this method public?

nvm, saw your comments

return err
}

mycommitAtLastSealed, err := c.execState.StateCommitmentByBlockID(lastSealedBlock.ID())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mycommitAtLastSealed, err := c.execState.StateCommitmentByBlockID(lastSealedBlock.ID())
myCommitAtLastSealed, err := c.execState.StateCommitmentByBlockID(lastSealedBlock.ID())