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

refactor: move executer to block package #638

Merged
merged 23 commits into from
Apr 16, 2024

Conversation

mtsitrin
Copy link
Contributor

@mtsitrin mtsitrin commented Apr 7, 2024

this PR handles few refactors:

  • move executor code from the state package to the block package
  • state related methods moved to separate file
  • using m.store.NextHeight() instead of m.store.Height()+1 throughout the code
  • add state.IsGenesis() to detect genesis run

besides,
fixed 2 bug. noted by comments

PR Standards

Opening a pull request should be able to meet the following requirements


Close #XXX

<-- Briefly describe the content of this pull request -->

For Author:

  • Targeted PR against correct branch
  • included the correct type prefix in the PR title
  • Linked to Github issue with discussion and accepted design
  • Targets only one github issue
  • Wrote unit and integration tests
  • All CI checks have passed
  • Added relevant godoc comments

For Reviewer:

  • confirmed the correct type prefix in the PR title
  • Reviewers assigned
  • confirmed all author checklist items have been addressed

After reviewer approval:

  • In case targets main branch, PR should be squashed and merged.
  • In case PR targets a release branch, PR should be rebased.

@mtsitrin mtsitrin linked an issue Apr 7, 2024 that may be closed by this pull request

err := m.applyBlock(ctx, prevCachedBlock, m.prevCommit[m.store.Height()+1], blockMetaData{source: gossipedBlock})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

bug fixed as commit cache not checked

@mtsitrin mtsitrin changed the base branch from main to mtsitrin/632-refactor-move-logger-interface-to-types April 7, 2024 11:59
if block.Header.Height != m.store.Height()+1 {
// We crashed after the commit and before updating the store height.
m.logger.Error("Block not applied. Wrong height", "block height", block.Header.Height, "store height", m.store.Height())
return nil
Copy link
Contributor Author

@mtsitrin mtsitrin Apr 7, 2024

Choose a reason for hiding this comment

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

fixed bug when applying cache, as no error is returned but expected

@mtsitrin mtsitrin marked this pull request as ready for review April 7, 2024 12:05
@mtsitrin mtsitrin requested a review from a team as a code owner April 7, 2024 12:05
Copy link
Contributor

@danwt danwt left a comment

Choose a reason for hiding this comment

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

nits
but nice work overall!

block/block.go Outdated Show resolved Hide resolved
block/block.go Outdated Show resolved Hide resolved
block/block.go Outdated Show resolved Hide resolved
block/block.go Outdated Show resolved Hide resolved
block/block.go Outdated Show resolved Hide resolved
block/manager.go Outdated Show resolved Hide resolved
block/produce.go Outdated Show resolved Hide resolved
block/retriever.go Outdated Show resolved Hide resolved
block/state.go Outdated Show resolved Hide resolved
types/errors.go Outdated Show resolved Hide resolved
Base automatically changed from mtsitrin/632-refactor-move-logger-interface-to-types to main April 8, 2024 14:49
@mtsitrin mtsitrin requested review from srene and zale144 April 15, 2024 08:04
@danwt danwt self-requested a review April 15, 2024 08:17
Copy link
Contributor

@danwt danwt left a comment

Choose a reason for hiding this comment

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

keen to get this one in
Just a couple nits

block/block.go Outdated Show resolved Hide resolved
block/manager.go Outdated
Comment on lines 42 to 43
executor *BlockExecutor

Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think @mtsitrin ?

store/store.go Outdated Show resolved Hide resolved
@mtsitrin mtsitrin requested a review from danwt April 15, 2024 10:30
danwt
danwt previously approved these changes Apr 15, 2024
Copy link
Contributor

@danwt danwt left a comment

Choose a reason for hiding this comment

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

great work!

danwt
danwt previously approved these changes Apr 15, 2024
@@ -38,13 +36,13 @@ type BlockExecutor struct {

// NewBlockExecutor creates new instance of BlockExecutor.
// Proposer address and namespace ID will be used in all newly created blocks.
func NewBlockExecutor(proposerAddress []byte, namespaceID string, chainID string, mempool mempool.Mempool, proxyApp proxy.AppConns, eventBus *tmtypes.EventBus, logger types.Logger) (*BlockExecutor, error) {
func NewBlockExecutor(proposerAddress []byte, namespaceID string, chainID string, mempool mempool.Mempool, proxyApp proxy.AppConns, eventBus *tmtypes.EventBus, logger types.Logger) (*Executor, 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
func NewBlockExecutor(proposerAddress []byte, namespaceID string, chainID string, mempool mempool.Mempool, proxyApp proxy.AppConns, eventBus *tmtypes.EventBus, logger types.Logger) (*Executor, error) {
func NewExecutor(proposerAddress []byte, namespaceID string, chainID string, mempool mempool.Mempool, proxyApp proxy.AppConns, eventBus *tmtypes.EventBus, logger types.Logger) (*Executor, error) {

block/produce.go Outdated Show resolved Hide resolved
block/produce.go Outdated Show resolved Hide resolved
@mtsitrin mtsitrin requested review from zale144 and danwt April 16, 2024 11:07
@mtsitrin mtsitrin merged commit df192a9 into main Apr 16, 2024
4 checks passed
@mtsitrin mtsitrin deleted the mtsitrin/635-refactor-move-executer-to-block-package branch April 16, 2024 11:31
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.

refactor: move executer to block package
3 participants