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

chore(CometBFTService): minor InitChain cleanup #2035

Merged
merged 7 commits into from
Oct 3, 2024
Merged

Conversation

abi87
Copy link
Collaborator

@abi87 abi87 commented Oct 2, 2024

unlike cosmos SDK BaseApp, initHeaderis not used across our codebase, so we can just remove it.
This is safe because:

  • None of the sdk.Context attributes filled by header are used in our codebase
  • None of the sdk.Context attributes filled by header are used in cometBFT

It is also weird that it is not reset by FinalizeBlock or Commit, and it is just set upon chain initialization.

Summary by CodeRabbit

  • New Features
    • Streamlined handling of block header context during the initialization phase of the application.
    • Enhanced mock functionality for the DepositStore type, including new methods for deposit management.
  • Bug Fixes
    • Improved management of the genesis block context, potentially enhancing state processing.
  • Chores
    • Updated mock generation tool version across various mock implementations to v2.46.2, ensuring consistency and stability.

@abi87 abi87 self-assigned this Oct 2, 2024
Copy link
Contributor

coderabbitai bot commented Oct 2, 2024

Walkthrough

The changes in this pull request involve modifications to the InitChain method within the Service struct of the cometbft package. A deferred function that previously set the block header context in finalizeBlockState has been removed, impacting how the block header is managed during initialization. Additionally, the import statement for cmtproto has been eliminated, indicating a possible refactor in block header handling. These adjustments streamline the initialization process while maintaining the overall control flow.

Changes

File Path Change Summary
mod/consensus/pkg/cometbft/service/abci.go Removed deferred function for setting block header context in InitChain and deleted cmtproto import.
mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-api/backend/mocks/availability_store.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-api/backend/mocks/beacon_block_header.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-api/backend/mocks/beacon_state.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-api/backend/mocks/block_store.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-api/backend/mocks/deposit_store.mock.go Added methods for DepositStore mock and updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-api/backend/mocks/node.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-api/backend/mocks/state_processor.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-api/backend/mocks/storage_backend.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-api/backend/mocks/validator.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-api/backend/mocks/withdrawal.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-api/backend/mocks/withdrawal_credentials.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-core/pkg/services/registry/mocks/basic.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/node-core/pkg/services/registry/mocks/registry_option.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/primitives/pkg/crypto/mocks/bls_signer.mock.go Updated mockery tool version from v2.46.1 to v2.46.2 and added nil checks in return value handling.
mod/storage/pkg/interfaces/mocks/db.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/storage/pkg/pruner/mocks/beacon_block.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/storage/pkg/pruner/mocks/block_event.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/storage/pkg/pruner/mocks/prunable.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.
mod/storage/pkg/pruner/mocks/pruner.mock.go Updated mockery tool version from v2.46.1 to v2.46.2.

Possibly related PRs

Suggested reviewers

  • ocnc
  • nidhi-singh02
  • itsdevbear

🐰 In the code where the headers lay,
A change was made to clear the way.
The context set, now gone from sight,
Simplifies the blocks, makes them light.
With hops of joy, we celebrate,
A cleaner path, oh, isn’t it great? 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@abi87 abi87 marked this pull request as ready for review October 2, 2024 12:47
Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 22.15%. Comparing base (455762b) to head (2fc7741).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2035      +/-   ##
==========================================
+ Coverage   22.13%   22.15%   +0.02%     
==========================================
  Files         357      357              
  Lines       16002    15987      -15     
  Branches       12       12              
==========================================
  Hits         3542     3542              
+ Misses      12313    12298      -15     
  Partials      147      147              
Files with missing lines Coverage Δ
mod/consensus/pkg/cometbft/service/abci.go 0.00% <ø> (ø)

@abi87 abi87 changed the base branch from main to update-mockery October 3, 2024 08:01
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post

Actionable comments posted: 3

🧹 Outside diff range comments (1)
mod/node-api/backend/mocks/deposit_store.mock.go (1)

Line range hint 104-148: LGTM with a minor suggestion: Prune method, NewDepositStore function, and helpers are well-implemented.

The Prune method, NewDepositStore function, and their associated helper types and methods are correctly implemented. The Prune method includes proper error handling, and the NewDepositStore function correctly sets up the mock for testing.

Consider adding a comment to the NewDepositStore function explaining that it returns a pointer to ensure that the mock can be modified in place during tests. For example:

// NewDepositStore creates a new instance of DepositStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
// It returns a pointer to allow in-place modifications of the mock during tests.
func NewDepositStore[DepositT any](t interface {
	mock.TestingT
	Cleanup(func())
}) *DepositStore[DepositT] {
	// ... (existing implementation)
}

This additional comment would provide clarity on the return type and its purpose.

🛑 Comments failed to post (3)
mod/node-core/pkg/services/registry/mocks/registry_option.mock.go (1)

1-1: 💡 Codebase verification

🔴 Unexpected Incomplete Function Signature Detected

The NewRegistryOption function appears to have an incomplete signature:

  • Line 71: func NewRegistryOption(t interface {

This may indicate a generation issue with the new mockery version.

🔗 Analysis chain

LGTM: Mockery version update.

The change from mockery v2.46.1 to v2.46.2 is a minor version update. This type of change typically doesn't introduce breaking changes or significant alterations to the generated code.

Let's verify that no unexpected changes were introduced:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any unexpected changes in the mock file structure or content.

# Test 1: Verify the file structure hasn't changed significantly
echo "Checking file structure..."
grep -n "type RegistryOption struct {" mod/node-core/pkg/services/registry/mocks/registry_option.mock.go
grep -n "func (_m \*RegistryOption) Execute(_a0 \*service.Registry) error {" mod/node-core/pkg/services/registry/mocks/registry_option.mock.go
grep -n "func NewRegistryOption(t interface {" mod/node-core/pkg/services/registry/mocks/registry_option.mock.go

# Test 2: Check for any unexpected imports
echo "Checking imports..."
grep -n "^import (" -A 5 mod/node-core/pkg/services/registry/mocks/registry_option.mock.go

# Test 3: Ensure no unexpected methods were added or removed
echo "Checking methods..."
grep -n "func (_m \*RegistryOption)" mod/node-core/pkg/services/registry/mocks/registry_option.mock.go

# Test 4: Verify the presence of key mock functionalities
echo "Checking mock functionalities..."
grep -n "mock.Mock" mod/node-core/pkg/services/registry/mocks/registry_option.mock.go
grep -n "EXPECT()" mod/node-core/pkg/services/registry/mocks/registry_option.mock.go
grep -n "AssertExpectations" mod/node-core/pkg/services/registry/mocks/registry_option.mock.go

Length of output: 1736

mod/node-api/backend/mocks/withdrawal.mock.go (1)

1-1: 🧹 Nitpick (assertive)

LGTM: Minor version update in generated file.

The change updates the version of the mockery tool used to generate this file from v2.46.1 to v2.46.2. This is a minor version update and doesn't affect the functionality of the mock.

Remember that this is a generated file and should not be manually edited, as indicated by the "DO NOT EDIT" comment. Any changes to the mock should be made through the source that generates this file.

mod/storage/pkg/pruner/mocks/block_event.mock.go (1)

1-1: 🧹 Nitpick (assertive)

LGTM: Mockery version update.

The change updates the version of mockery used to generate this file from v2.46.1 to v2.46.2. This is a minor version update and doesn't affect the functionality of the mock.

As a general practice, it's good to keep generated files up-to-date with the latest stable versions of the tools used to generate them. However, it's worth noting that changes to generated files should be reviewed carefully to ensure they don't introduce unexpected modifications to the mocked behavior.

Base automatically changed from update-mockery to main October 3, 2024 15:19
@abi87 abi87 enabled auto-merge (squash) October 3, 2024 18:15
@abi87 abi87 merged commit f767228 into main Oct 3, 2024
16 checks passed
@abi87 abi87 deleted the clear-init-header branch October 3, 2024 18:23
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.

2 participants