Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

fix(miner): Improve StateAt... #1254

Closed
wants to merge 1 commit into from
Closed

fix(miner): Improve StateAt... #1254

wants to merge 1 commit into from

Conversation

itsdevbear
Copy link
Contributor

@itsdevbear itsdevbear commented Oct 27, 2023

Summary by CodeRabbit

  • New Feature: Enhanced the EVMKeeper's functionality by enabling it to use the commit store provided by the app. This update improves the overall consistency and reliability of the application.
  • New Feature: Implemented sticky sessions in the load balancing algorithm. This ensures that subsequent requests from the same client are routed to the same server, enhancing user experience by providing more consistent server responses.
  • Refactor: Updated the StateAtBlockNumber method to use the new SetCommitStore method, improving the efficiency of state management in the application.

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2023

Walkthrough

This update introduces the SetCommitStore method in the Keeper and Plugin structures, enabling the setting of the commit store for the EVMKeeper. It also modifies the StateAtBlockNumber method to use this new function. Additionally, it introduces sticky sessions in the nginx configuration for better load balancing.

Changes

File Summary
cosmos/x/evm/keeper/keeper.go Added SetCommitStore method to Keeper struct and modified Setup method to accept a Blockchain parameter.
cosmos/x/evm/plugins/state/plugin.go Added SetCommitStore method to Plugin interface and implemented it in plugin struct. Modified StateAtBlockNumber method to use SetCommitStore. Added NullCommiter and NullCacher types.
e2e/testapp/app.go Added code to set the commit store for the EVMKeeper in the Polaris app.
e2e/testapp/docker/nginx.conf Added sticky directive to nodes upstream block in http configuration for sticky sessions.

🐇

In the land of code, changes are afoot,

With SetCommitStore, the commit store takes root.

Sticky sessions in nginx, a clever trick,

Ensuring load balancing, smooth and slick.

So here's to the devs, their efforts we salute,

In the world of software, they contribute and contribute! 🎉


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.json

Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d34a732 and 562929a.
Files ignored due to filter (7)
  • cosmos/go.mod
  • cosmos/go.sum
  • e2e/testapp/go.mod
  • e2e/testapp/go.sum
  • eth/go.mod
  • eth/go.sum
  • go.work.sum
Files selected for processing (4)
  • cosmos/x/evm/keeper/keeper.go (1 hunks)
  • cosmos/x/evm/plugins/state/plugin.go (5 hunks)
  • e2e/testapp/app.go (1 hunks)
  • e2e/testapp/docker/nginx.conf (1 hunks)
Files skipped from review due to trivial changes (1)
  • e2e/testapp/app.go
Additional comments: 8
e2e/testapp/docker/nginx.conf (1)
  • 2-4: The addition of the sticky directive in the upstream block is a good move for load balancing. This ensures that subsequent requests from the same client are routed to the same server, which can help maintain session consistency. However, please verify that all servers can handle the potential increase in load due to this change.
cosmos/x/evm/keeper/keeper.go (1)
  • 74-76: The new SetCommitStore method sets the commit store of the host. This is a good addition as it allows the commit store to be set externally, providing more flexibility. However, it's important to ensure that the commit store is set before it's used elsewhere in the code to avoid nil pointer dereferences. Also, consider adding error handling in case the SetCommitStore method is called with a nil argument.
func (k *Keeper) SetCommitStore(s storetypes.CommitMultiStore) {
+   if s == nil {
+       return errors.New("commit store cannot be nil")
+   }
    k.Host.sp.SetCommitStore(s)
}
cosmos/x/evm/plugins/state/plugin.go (6)
  • 24-27: The errors package seems to be removed from the import list. Ensure that this package is not used anywhere in the code or replace it with an equivalent error handling package if necessary.

  • 65-65: The SetCommitStore method is added to the Plugin interface. Ensure that all implementations of this interface have been updated to include this method.

  • 118-118: The rms field of type NullCommiter is added to the plugin struct. This field is used to store the commit store of the host. Ensure that this field is properly initialized and used throughout the code.

  • 521-523: The SetCommitStore method is implemented for the plugin struct. This method sets the commit store of the host. Ensure that this method is called with the correct commit store.

  • 529-543: The StateAtBlockNumber method is updated to use the SetCommitStore method and the NullCommiter and NullCacher types. This method retrieves the state at a specific block number. Ensure that the changes do not affect the functionality of the method.

  • 567-583: The NullCommiter and NullCacher types are added. These types provide null implementations of the CommitMultiStore and CacheMultiStore interfaces. Ensure that these types are used correctly throughout the code.

@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #1254 (562929a) into main (d34a732) will increase coverage by 0.07%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1254      +/-   ##
==========================================
+ Coverage   49.22%   49.29%   +0.07%     
==========================================
  Files          77       77              
  Lines        4642     4635       -7     
==========================================
  Hits         2285     2285              
+ Misses       2195     2188       -7     
  Partials      162      162              
Files Coverage Δ
cosmos/x/evm/keeper/keeper.go 0.00% <0.00%> (ø)
cosmos/x/evm/plugins/state/plugin.go 75.58% <0.00%> (+2.54%) ⬆️

@itsdevbear itsdevbear closed this Oct 27, 2023
@calbera calbera deleted the run-it-back-fix branch November 8, 2023 18:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant