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

chore(app): Setup app better. #1224

Merged
merged 20 commits into from
Oct 13, 2023
Merged

chore(app): Setup app better. #1224

merged 20 commits into from
Oct 13, 2023

Conversation

itsdevbear
Copy link

@itsdevbear itsdevbear commented Oct 13, 2023

Summary by CodeRabbit

  • Refactor: The Polaris runtime setup has been streamlined for better performance and reliability. This includes the removal of deprecated methods and the addition of new ones for creating a new Polaris runtime.
  • New Feature: The EVM Keeper setup has been integrated into the application, enhancing the Ethereum Virtual Machine's functionality within the software.
  • Refactor: The configuration plugin has been removed from the Host struct and related functions, simplifying the codebase and improving maintainability.
  • Refactor: The EVM Keeper field has been removed from the Polaris struct, and the setup method has been updated, leading to a more efficient code structure.
  • New Feature: The Keeper struct now includes a setup function, which enhances the keeper's functionality by setting it up with the provided blockchain.
  • Refactor: The SimApp struct and its initialization process have been updated for better performance and reliability. This includes the addition of the Polaris field and the EVM Keeper field.
  • Refactor: The historical plugin has been updated to accept a new chain configuration parameter, improving its flexibility and adaptability to different chain configurations.

@coderabbitai
Copy link

coderabbitai bot commented Oct 13, 2023

Walkthrough

This changeset primarily focuses on refactoring and reorganizing the Polaris runtime and EVM Keeper setup. It includes the removal of deprecated methods, addition of new functions, and modifications to existing ones. The changes aim to improve the code's maintainability, modularity, and performance.

Changes

File Summary
cosmos/runtime/runtime.go Several changes including the removal of EVMKeeper field from Polaris struct, updates to Setup and RegisterServices functions, and addition of New function.
e2e/testapp/app.go Added imports for evmkeeper and enginep packages, updated SimApp struct to include a Polaris field, and modified NewPolarisApp function to initialize app.Polaris and setup the EVM keeper.
e2e/testapp/polard/cmd/root.go Removed import of polarruntime package and corresponding call to polarruntime.ProvidePolarisRuntime in the dependency injection setup.
cosmos/x/evm/keeper/host.go Removed configuration plugin and its associated code from the Host struct and related functions.
cosmos/x/evm/keeper/keeper.go Added import of the "github.com/cosmos/cosmos-sdk/client" package, added Setup, StartEnginePlugin, and Config functions to the Keeper struct.
cosmos/x/evm/plugins/historical/plugin.go Introduced a new import statement for the "pkg.berachain.dev/polaris/eth/params" package, modified the struct field "cp" to "chainConfig" of type "*params.ChainConfig", and updated the NewPlugin function.

"In the land of code, where logic is king, 🤴
A rabbit hopped by, making changes with a zing. 🐇💥
Removed some old, added some new, 🔄
Optimized the flow, for a performance breakthrough. 🚀
So here's to the devs, with their code so bright, 💻✨
May your bugs be few, and your tests always right!" 🐞🚫🧪✔️


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

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

Commits Files that changed from the base of the PR and between 85b7adc and 23ac500.
Files selected for processing (3)
  • cosmos/runtime/runtime.go (4 hunks)
  • e2e/testapp/app.go (7 hunks)
  • e2e/testapp/polard/cmd/root.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • e2e/testapp/polard/cmd/root.go
Additional comments (Suppressed): 12
cosmos/runtime/runtime.go (4)
  • 31-44: The import statements have been updated. The enginep package has been removed and the config, core, and ethlog packages have been added. Ensure that these changes do not break any dependencies and that the new packages are used correctly in the code.

  • 54-87: The New function has been introduced to create a new Polaris runtime. It creates a new Geth networking stack and initializes a new Polaris instance with this networking stack. The function also sets up a logger for the Polaris Geth module. Ensure that the New function is used correctly throughout the codebase and that the logger is functioning as expected.

  • 99-104: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [89-103]

The Setup function has been modified. The call to EVMKeeper.SetupPrecompiles has been removed, and the Polaris.Init method is now called to set up the Polaris struct. The WrappedMiner field is initialized with a new miner, and the PrepareProposal method of the WrappedMiner field is set as the prepare proposal function for the base app. Ensure that the removal of EVMKeeper.SetupPrecompiles does not affect the functionality of the application and that the new setup process works as expected.

  • 119-125: The RegisterServices function has been updated. The call to EVMKeeper.Host.GetEnginePlugin().(enginep.Plugin).Start(clientContext) has been removed, and the services are now registered with the Polaris struct directly. Ensure that the removal of the engine plugin start does not affect the functionality of the application and that the services are registered correctly.
e2e/testapp/app.go (8)
  • 57-62: The new import statements for evmkeeper and enginep packages are introduced. Ensure these packages are available and correctly imported.

  • 74-80: The SimApp struct now includes a Polaris field. This change might affect the usage of SimApp in other parts of the codebase. Please verify.

  • 95-99: The EVMKeeper field is added to the SimApp struct. Ensure that this field is correctly initialized and used.

  • 121-134: The app initialization has been modified. The polaris field is no longer initialized here. Ensure that this change does not affect the application's behavior.

  • 180-209: The app.Polaris field is now initialized using the polarruntime.New function. The app.EVMKeeper is also set up here. Ensure that these changes are correct and do not introduce any issues.

  • 224-230: The app.Polaris.LoadLastState function call has been updated to use the new app.Polaris field. Ensure that this change is correct.

  • 274-279: The app.EVMKeeper.Host.GetEnginePlugin().(enginep.Plugin).Start(apiSvr.ClientCtx) line starts the engine plugin. Also, the app.Polaris.Init function call has been updated to use the new app.Polaris field. Ensure that these changes are correct.

  • 282-287: The Close method now uses app.Polaris. Ensure that this change is correct and does not introduce any issues.

@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

Merging #1224 (cd99631) into main (85b7adc) will increase coverage by 0.21%.
The diff coverage is 19.04%.

❗ Current head cd99631 differs from pull request most recent head 58a20f3. Consider uploading reports for the commit 58a20f3 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1224      +/-   ##
==========================================
+ Coverage   48.68%   48.90%   +0.21%     
==========================================
  Files          78       78              
  Lines        4667     4644      -23     
==========================================
- Hits         2272     2271       -1     
+ Misses       2232     2210      -22     
  Partials      163      163              
Files Coverage Δ
cosmos/x/evm/depinject.go 18.18% <ø> (+0.79%) ⬆️
cosmos/x/evm/plugins/block/header.go 61.25% <ø> (-0.95%) ⬇️
cosmos/x/evm/plugins/block/plugin.go 100.00% <100.00%> (+65.00%) ⬆️
cosmos/x/evm/plugins/historical/historical_data.go 59.16% <100.00%> (ø)
cosmos/x/evm/plugins/historical/plugin.go 100.00% <100.00%> (ø)
eth/core/chain_resources.go 0.00% <ø> (ø)
cosmos/x/evm/keeper/genesis.go 0.00% <0.00%> (ø)
eth/core/chain_writer.go 0.00% <0.00%> (ø)
eth/core/chain.go 0.00% <0.00%> (ø)
cosmos/x/evm/plugins/state/plugin.go 72.86% <20.00%> (+0.64%) ⬆️
... and 3 more

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

Commits Files that changed from the base of the PR and between 23ac500 and ded94a6.
Files selected for processing (35)
  • contracts/bindings/cosmos/lib/cosmos_types.abigen.go (1 hunks)
  • contracts/bindings/testing/consume_gas.abigen.go (1 hunks)
  • contracts/bindings/testing/distribution_testing_helper.abigen.go (1 hunks)
  • contracts/bindings/testing/governance/governance_wrapper.abigen.go (1 hunks)
  • contracts/bindings/testing/liquid_staking.abigen.go (1 hunks)
  • contracts/bindings/testing/precompile_constructor.abigen.go (1 hunks)
  • contracts/bindings/testing/solmate_erc20.abigen.go (1 hunks)
  • cosmos/config/mocks/app_options.go (1 hunks)
  • cosmos/txpool/mocks/geth_tx_pool.go (1 hunks)
  • cosmos/txpool/mocks/lifecycle.go (1 hunks)
  • cosmos/txpool/mocks/sdk_tx.go (1 hunks)
  • cosmos/txpool/mocks/subscription.go (1 hunks)
  • cosmos/txpool/mocks/tx_broadcaster.go (1 hunks)
  • cosmos/txpool/mocks/tx_serializer.go (1 hunks)
  • cosmos/txpool/mocks/tx_sub_provider.go (1 hunks)
  • cosmos/x/evm/genesis_test.go (1 hunks)
  • cosmos/x/evm/keeper/genesis.go (1 hunks)
  • cosmos/x/evm/keeper/host.go (6 hunks)
  • cosmos/x/evm/plugins/historical/historical_data.go (1 hunks)
  • cosmos/x/evm/plugins/historical/plugin.go (3 hunks)
  • cosmos/x/evm/plugins/historical/plugin_test.go (2 hunks)
  • eth/core/chain.go (5 hunks)
  • eth/core/chain_writer.go (1 hunks)
  • eth/core/host.go (2 hunks)
  • eth/core/state/journal/mocks/accesslist.go (1 hunks)
  • eth/core/state/journal/mocks/log.go (1 hunks)
  • eth/core/state/journal/mocks/refund.go (1 hunks)
  • eth/core/state/journal/mocks/self_destruct_state_plugin.go (1 hunks)
  • eth/core/state/journal/mocks/self_destructs.go (1 hunks)
  • eth/core/state/journal/mocks/transient_storage.go (1 hunks)
  • eth/core/state/mocks/plugin.go (1 hunks)
  • eth/core/state/mocks/polar_state_db.go (1 hunks)
  • eth/core/state/mocks/precompile_plugin.go (1 hunks)
  • eth/core/types/transaction.rlpgen.go (1 hunks)
  • eth/polar/backend.go (2 hunks)
Files not summarized due to errors (2)
  • contracts/bindings/testing/governance/governance_wrapper.abigen.go: Error: Message exceeds token limit
  • contracts/bindings/testing/liquid_staking.abigen.go: Error: Message exceeds token limit
Files skipped from review due to trivial changes (27)
  • contracts/bindings/cosmos/lib/cosmos_types.abigen.go
  • contracts/bindings/testing/distribution_testing_helper.abigen.go
  • contracts/bindings/testing/precompile_constructor.abigen.go
  • contracts/bindings/testing/solmate_erc20.abigen.go
  • cosmos/config/mocks/app_options.go
  • cosmos/txpool/mocks/geth_tx_pool.go
  • cosmos/txpool/mocks/lifecycle.go
  • cosmos/txpool/mocks/sdk_tx.go
  • cosmos/txpool/mocks/subscription.go
  • cosmos/txpool/mocks/tx_broadcaster.go
  • cosmos/txpool/mocks/tx_serializer.go
  • cosmos/txpool/mocks/tx_sub_provider.go
  • eth/core/chain.go
  • eth/core/chain_writer.go
  • eth/core/host.go
  • eth/core/state/journal/mocks/accesslist.go
  • eth/core/state/journal/mocks/log.go
  • eth/core/state/journal/mocks/refund.go
  • eth/core/state/journal/mocks/self_destruct_state_plugin.go
  • eth/core/state/journal/mocks/self_destructs.go
  • eth/core/state/journal/mocks/transient_storage.go
  • eth/core/state/mocks/plugin.go
  • eth/core/state/mocks/polar_state_db.go
  • eth/core/state/mocks/precompile_plugin.go
  • eth/core/types/transaction.rlpgen.go
  • contracts/bindings/testing/governance/governance_wrapper.abigen.go (diff too large)
  • contracts/bindings/testing/liquid_staking.abigen.go (diff too large)
Additional comments (Suppressed): 16
cosmos/x/evm/genesis_test.go (1)
  • 93-97: The core.NewChain function now requires an additional argument params.DefaultChainConfig. Ensure that this change doesn't break any existing calls to this function and that the params.DefaultChainConfig is the correct configuration to use in this context.
cosmos/x/evm/plugins/historical/historical_data.go (1)
  • 188-188: The function DeriveReceiptsFromBlock now uses p.chainConfig instead of p.cp.ChainConfig(). Ensure that p.chainConfig is correctly initialized and updated whenever necessary, and that it is thread-safe if accessed concurrently.
contracts/bindings/testing/consume_gas.abigen.go (1)
  • 34-36: The Bin field, which represents the compiled bytecode of the contract, has been updated. This indicates that the contract's code has been modified. Ensure that these changes are intentional and that they have been thoroughly tested. Also, verify that the ABI (Application Binary Interface) still correctly describes the contract's interface after the changes.
cosmos/x/evm/keeper/genesis.go (1)
  • 30-35: The removal of the line genState.Config = k.Host.GetConfigurationPlugin().ChainConfig() suggests that the chain configuration is no longer being set in the InitGenesis function. Ensure that the chain configuration is being set elsewhere in the codebase to avoid potential issues.
- genState.Config = k.Host.GetConfigurationPlugin().ChainConfig()
cosmos/x/evm/plugins/historical/plugin_test.go (2)
  • 34-40: The import of the params package is new in this hunk. Ensure that this package is used in the subsequent code and that it is necessary for the new implementation.

  • 50-56: The NewPlugin function now takes params.DefaultChainConfig as the first argument instead of cp (ConfigurationPlugin). Make sure that this change is reflected in all calls to NewPlugin throughout the codebase. Also, verify that params.DefaultChainConfig provides the necessary configuration for the plugin.

- p = utils.MustGetAs[*plugin](NewPlugin(cp, bp, nil, testutil.EvmKey))
+ p = utils.MustGetAs[*plugin](NewPlugin(params.DefaultChainConfig, bp, nil, testutil.EvmKey))
cosmos/x/evm/plugins/historical/plugin.go (2)
  • 43-47: The cp field has been replaced with chainConfig of type *params.ChainConfig. Ensure that all references to cp in the codebase have been updated to chainConfig and that the type change does not introduce any issues.

  • 54-62: The NewPlugin function now requires a *params.ChainConfig argument instead of a core.ConfigurationPlugin. Ensure that all calls to NewPlugin have been updated to match the new signature.

- func NewPlugin(cp core.ConfigurationPlugin, bp core.BlockPlugin, _ storetypes.StoreKey, storekey storetypes.StoreKey) Plugin {
+ func NewPlugin(chainConfig *params.ChainConfig, bp core.BlockPlugin, _ storetypes.StoreKey, storekey storetypes.StoreKey) Plugin {
eth/polar/backend.go (2)
  • 109-115: The core.NewChain function now requires a ChainConfig argument. Ensure that the config.Chain field is properly initialized before this call. Also, verify that all calls to core.NewChain throughout the codebase have been updated to match the new signature.

  • 156-159: The miner.New function now uses pl.config.Chain instead of pl.host.GetConfigurationPlugin().ChainConfig(). Ensure that the pl.config.Chain field is equivalent to the previous ChainConfig obtained from the configuration plugin. If not, this could lead to unexpected behavior in the miner.

cosmos/x/evm/keeper/host.go (6)
  • 28-33: The import of the configuration plugin has been removed. Ensure that this plugin is no longer needed and that its functionality has been replaced or is no longer required.

  • 43-48: The configuration.Plugin has been removed from the Host struct. This change is consistent with the removal of the configuration plugin import. Ensure that this does not affect the functionality of the Host struct.

  • 70-75: The configuration.Plugin is no longer being initialized in the Host struct. This is consistent with the removal of the configuration plugin import and its removal from the Host struct. Ensure that this does not affect the functionality of the Host struct.

  • 78-84: The historical.Plugin is now being initialized with &cfg.Polar.Chain instead of h.cp. This change is consistent with the removal of the configuration plugin. Ensure that &cfg.Polar.Chain provides the same or equivalent functionality as h.cp.

  • 105-110: The GetConfigurationPlugin function has been removed. This is consistent with the removal of the configuration plugin. Ensure that this function is no longer needed and that its functionality has been replaced or is no longer required.

  • 125-129: The configuration.Plugin has been removed from the return value of the GetAllPlugins function. This is consistent with the removal of the configuration plugin. Ensure that this does not affect the functionality of the GetAllPlugins function.

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

Commits Files that changed from the base of the PR and between ded94a6 and da06723.
Files selected for processing (9)
  • cosmos/runtime/runtime.go (3 hunks)
  • cosmos/x/evm/keeper/host.go (5 hunks)
  • cosmos/x/evm/plugins/block/header.go (2 hunks)
  • cosmos/x/evm/plugins/block/header_test.go (1 hunks)
  • cosmos/x/evm/plugins/block/plugin.go (2 hunks)
  • eth/core/chain.go (6 hunks)
  • eth/core/chain_resources.go (2 hunks)
  • eth/crypto/imported.go (1 hunks)
  • eth/params/imported.go (1 hunks)
Files skipped from review due to trivial changes (3)
  • cosmos/x/evm/plugins/block/header.go
  • eth/core/chain.go
  • eth/params/imported.go
Additional comments (Suppressed): 16
eth/core/chain_resources.go (2)
  • 26-30: The import statement for "pkg.berachain.dev/polaris/eth/params" has been added. Ensure that this new import does not introduce any conflicts with existing code and is used appropriately in the subsequent code.

  • 35-39: A new method Config() *params.ChainConfig has been added to the ChainResources interface. Make sure all structs that implement this interface are updated to include this new method.

+ 	Config() *params.ChainConfig
cosmos/x/evm/plugins/block/plugin.go (2)
  • 37-41: The SetQueryContextFn method has been removed from the Plugin interface. Ensure that this change does not affect any other parts of the codebase that were using this method.

  • 53-62: The NewPlugin function now takes an additional parameter qfn which is a function that returns another function for querying block headers. This replaces the SetQueryContextFn method that was previously part of the Plugin interface. Ensure that all calls to NewPlugin have been updated to match the new signature.

- func NewPlugin(storekey storetypes.StoreKey, sk StakingKeeper) Plugin {
+ func NewPlugin(
+ 	storekey storetypes.StoreKey, sk StakingKeeper,
+ 	qfn func() func(height int64, prove bool) (sdk.Context, error),
+ ) Plugin {
cosmos/x/evm/plugins/block/header_test.go (1)
  • 52-53: The SetQueryContextFn function has been removed and replaced with a getQueryContext field in the plugin struct. Ensure that this change does not affect the functionality of the plugin and that all calls to SetQueryContextFn have been updated.
eth/crypto/imported.go (1)
  • 25-39: The new hunk removes several functions that were previously exposed by the crypto package. Ensure that these functions are not used elsewhere in the codebase, or that appropriate replacements have been provided. The removed functions are: SigToPub, Ecrecover, CreateAddress, UnmarshalPubkey, CompressPubkey, DecompressPubkey, DigestLength, EthSign, FromECDSA, ValidateSignatureValues, SignatureLength, ToECDSA, VerifySignature, FromECDSAPub.
cosmos/x/evm/keeper/host.go (5)
  • 29-33: The import statement for the configuration plugin has been removed. Ensure that this plugin is no longer needed in the codebase.

  • 43-55: The Host struct has been modified. The cp field (configuration plugin) and storeKey field have been removed. Ensure that these fields are not used elsewhere in the codebase.

  • 68-86: The NewHost function has been updated. The configuration plugin and storeKey are no longer used in the creation of the Host struct. The state plugin's SetQueryContextFn is now set here. Ensure that these changes do not affect the functionality of the Host struct.

  • 104-115: The GetConfigurationPlugin function has been removed. Ensure that this function is not called elsewhere in the codebase.

  • 126-130: The GetAllPlugins function no longer returns the configuration plugin. Ensure that this change does not affect the functionality of the Host struct.

cosmos/runtime/runtime.go (5)
  • 45-51: The EVMKeeper field has been removed from the Polaris struct. Ensure that all references to EVMKeeper in the codebase have been updated or removed accordingly.

  • 55-83: The New function has been introduced to create a new Polaris runtime. It seems to handle the creation of a new Polaris instance with a networking stack and logging. However, it doesn't handle the initialization of WrappedMiner and WrappedTxPool which were previously part of the Polaris struct. Make sure these components are initialized elsewhere in the codebase.

  • 86-88: The Setup function no longer calls SetupPrecompiles on the EVMKeeper. If this is intentional, ensure that precompiles are set up elsewhere in the codebase.

  • 95-98: The Setup function no longer sets the blockchain for the EVMKeeper. If this is intentional, ensure that the blockchain is set elsewhere in the codebase.

  • 118-121: The RegisterServices function no longer requires a clientContext argument and no longer starts the engine plugin. If this is intentional, ensure that the engine plugin is started elsewhere in the codebase and that the removal of the clientContext argument does not affect the registration of services.

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: 3

Commits Files that changed from the base of the PR and between da06723 and fde99c2.
Files selected for processing (4)
  • cosmos/runtime/runtime.go (2 hunks)
  • cosmos/x/evm/keeper/genesis.go (1 hunks)
  • cosmos/x/evm/keeper/keeper.go (3 hunks)
  • e2e/testapp/app.go (7 hunks)
Files skipped from review due to trivial changes (2)
  • cosmos/runtime/runtime.go
  • cosmos/x/evm/keeper/genesis.go
Additional comments (Suppressed): 7
cosmos/x/evm/keeper/keeper.go (2)
  • 35-46: The Blockchain interface has been updated to include a new method Config() *params.ChainConfig. Ensure that all implementations of this interface have been updated to include this method.

  • 84-87: The Setup method has been added to the Keeper struct. This method sets up the blockchain and precompiles. Ensure that this method is called before using the Keeper instance.

e2e/testapp/app.go (5)
  • 57-61: The import evmkeeper "pkg.berachain.dev/polaris/cosmos/x/evm/keeper" has been added. Ensure that this package is available and accessible.

  • 73-79: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [73-98]

The SimApp struct has been modified. The *polarruntime.Polaris field has been added and the polaris field has been replaced with EVMKeeper *evmkeeper.Keeper. Make sure that all references to these fields in the codebase are updated accordingly.

  • 120-133: The app initialization in NewPolarisApp() function has been changed. The polaris field is no longer initialized here. Also, the depinject.Provide() function no longer includes polarruntime.ProvidePolarisRuntime. Ensure that these changes do not affect the application's behavior.

  • 179-200: The app.Polaris and app.EVMKeeper fields are now being initialized and set up within the NewPolarisApp() function. The app.SetAnteHandler(nil) line has been removed. Make sure that the AnteHandler is set elsewhere if needed.

  • 212-218: The LoadLastState() method is now called on app.Polaris instead of app.polaris. Ensure that the Polaris field is correctly initialized before this call.

cosmos/x/evm/keeper/keeper.go Outdated Show resolved Hide resolved
cosmos/x/evm/keeper/keeper.go Show resolved Hide resolved
e2e/testapp/app.go Outdated Show resolved Hide resolved
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: 2

Commits Files that changed from the base of the PR and between fde99c2 and ec4a700.
Files selected for processing (3)
  • cosmos/runtime/runtime.go (2 hunks)
  • cosmos/x/evm/keeper/host.go (5 hunks)
  • eth/polar/backend.go (3 hunks)
Additional comments (Suppressed): 9
eth/polar/backend.go (2)
  • 109-115: The core.NewChain function now takes an additional parameter &config.Chain. Ensure that this change doesn't break the function's expected behavior and that the config.Chain is correctly initialized before this call.

  • 152-153: The miner.New function now takes &pl.config.Chain instead of pl.host.GetConfigurationPlugin().ChainConfig(). Ensure that pl.config.Chain is equivalent to pl.host.GetConfigurationPlugin().ChainConfig() and that this change doesn't affect the function's expected behavior.

cosmos/x/evm/keeper/host.go (5)
  • 28-33: The configuration plugin import has been removed. Ensure that this does not affect any dependencies or functionality that relied on it.

  • 43-55: The configuration.Plugin field has been removed from the Host struct. This change should be verified across the codebase to ensure that no other parts of the code are trying to access this field.

  • 65-85: The historical.NewPlugin function call has been updated to pass the &cfg.Polar.Chain parameter instead of h.cp. Ensure that this change is compatible with the function's signature and expected behavior.

  • 103-114: The GetConfigurationPlugin method has been removed from the Host struct. This change should be verified across the codebase to ensure that no other parts of the code are trying to access this method.

  • 125-129: The configuration plugin has been removed from the GetAllPlugins method. Ensure that this does not affect any dependencies or functionality that relied on it.

cosmos/runtime/runtime.go (2)
  • 90-106: The Setup method has been updated to initialize the WrappedTxPool and WrappedMiner fields and set them as the mempool and prepare proposal function for the base app respectively. It also calls the Setup method of the EVMKeeper interface. The EVMKeeper field has been removed from the Polaris struct and is now passed as a parameter to the Setup method. Ensure that all calls to this method throughout the codebase have been updated to match the new signature.

  • 125-128: The RegisterServices method no longer starts the engine plugin. Ensure that the engine plugin is started elsewhere in the codebase, or if it's no longer needed, that its removal doesn't cause any issues.

eth/polar/backend.go Show resolved Hide resolved
cosmos/runtime/runtime.go Outdated Show resolved Hide resolved
@itsdevbear itsdevbear requested review from ocnc and calbera October 13, 2023 18:40
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

Commits Files that changed from the base of the PR and between ec4a700 and 8b56cd3.
Files selected for processing (1)
  • cosmos/x/evm/keeper/processor.go (2 hunks)
Additional comments (Suppressed): 2
cosmos/x/evm/keeper/processor.go (2)
  • 35-45: The variable envelope has been moved from the old hunk's line 50 to the new hunk's line 41. This change is acceptable as it doesn't affect the logic of the code. However, it's important to ensure that the envelope variable is not used before its declaration and initialization.

  • 50-60: The error handling for the envelope.UnmarshalJSON(msg.Data) and engine.ExecutableDataToBlock(*envelope.ExecutionPayload, nil, nil) functions has been modified. In the new hunk, the error is directly checked in the if condition, which makes the code more concise and readable. This is a good practice as it reduces the number of lines of code and improves readability.

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

Commits Files that changed from the base of the PR and between 8b56cd3 and 614cb02.
Files selected for processing (13)
  • cosmos/runtime/logging.go (1 hunks)
  • cosmos/runtime/runtime.go (3 hunks)
  • cosmos/x/evm/keeper/host.go (5 hunks)
  • cosmos/x/evm/keeper/keeper.go (3 hunks)
  • cosmos/x/evm/plugins/block/plugin.go (2 hunks)
  • cosmos/x/evm/plugins/precompile/plugin_test.go (1 hunks)
  • cosmos/x/evm/plugins/state/genesis_test.go (1 hunks)
  • cosmos/x/evm/plugins/state/plugin.go (6 hunks)
  • cosmos/x/evm/plugins/state/plugin_benchmark_test.go (1 hunks)
  • cosmos/x/evm/plugins/state/plugin_test.go (1 hunks)
  • e2e/testapp/app.go (7 hunks)
  • eth/core/host.go (2 hunks)
  • eth/core/mock/block_plugin.mock.go (7 hunks)
Files skipped from review due to trivial changes (4)
  • cosmos/runtime/logging.go
  • cosmos/x/evm/keeper/host.go
  • eth/core/host.go
  • eth/core/mock/block_plugin.mock.go
Additional comments (Suppressed): 32
cosmos/x/evm/plugins/state/plugin_benchmark_test.go (1)
  • 41-46: The function signature of state.NewPlugin has changed. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the two nil arguments passed to state.NewPlugin in line 43 are intentional and won't cause any issues.
cosmos/x/evm/plugins/precompile/plugin_test.go (1)
  • 131-134: The state.NewPlugin function call has been updated with an additional nil argument. Ensure that this change is intentional and that the function signature has been updated to accept this additional argument. If the function signature has not been updated, this will cause a runtime error.
-    return state.NewPlugin(
-        nil, nil, nil,
-    )
+    return state.NewPlugin(
+        nil, nil, nil, nil,
+    )
cosmos/x/evm/plugins/state/genesis_test.go (1)
  • 47-53: The NewPlugin function call has been modified to pass nil instead of &mockPLF{}. Ensure that this change does not affect the functionality of the state.Plugin instance. If &mockPLF{} was providing any necessary setup or configuration for the plugin, this change could cause issues.
- sp = state.NewPlugin(ak, testutil.EvmKey, &mockPLF{})
+ sp = state.NewPlugin(ak, testutil.EvmKey, nil, &mockPLF{})
cosmos/x/evm/plugins/block/plugin.go (3)
  • 34-37: The SetQueryContextFn method has been removed from the Plugin interface. Ensure that this change does not break any existing functionality that relied on this method.

  • 50-58: The NewPlugin function now takes an additional parameter qfn which is a function that returns another function. This is a significant change and should be verified for correctness and compatibility with existing code. Also, ensure that the qfn function is properly defined and used in the codebase.

  • 47-48: The plugin struct now includes a getQueryContext field. This field seems to replace the SetQueryContextFn method that was removed from the Plugin interface. Ensure that this field is properly initialized and used in the codebase.

cosmos/x/evm/plugins/state/plugin_test.go (1)
  • 51-55: The NewPlugin function call has been modified to remove the SetQueryContextFn function and add a nil argument. Ensure that this change does not affect the functionality of the state plugin and that all calls to NewPlugin throughout the codebase have been updated to match the new signature.
- sp = state.NewPlugin(ak, testutil.EvmKey, &mockPLF{})
+ sp = state.NewPlugin(ak, testutil.EvmKey, nil, &mockPLF{})
cosmos/x/evm/keeper/keeper.go (4)
  • 35-39: The import statement for "pkg.berachain.dev/polaris/eth/params" has been added. Ensure that this package is available and accessible in the project's dependencies.

  • 43-43: The Config() method has been added to the Blockchain interface. Make sure all implementations of this interface have been updated to include this method.

  • 84-87: The Setup method has been added to the Keeper struct. This method sets up the Keeper instance with a given Blockchain instance and sets up precompiles. Ensure that error handling is properly done in the SetupPrecompiles method.

  • 89-91: The StartEnginePlugin method has been added to the Keeper struct. This method starts the engine plugin with a given context. Ensure that the Start method of the engine plugin handles errors properly and that the context passed is valid.

cosmos/x/evm/plugins/state/plugin.go (6)
  • 55-60: The SetQueryContextFn method has been removed from the Plugin interface. Ensure that this change does not affect any other parts of the codebase that rely on this method.

  • 105-112: The getQueryContext field has been renamed to qfn. This change should not affect the functionality of the code, but make sure to update any references to this field in the rest of the codebase.

  • 121-134: The NewPlugin function now takes an additional parameter qfn. This change will require updates to all calls to NewPlugin throughout the codebase to include this new parameter.

  • 524-535: The SetQueryContextFn method has been removed and its functionality has been integrated into the StateAtBlockNumber method. This change simplifies the code by removing the need for a separate method to set the query context function. However, ensure that this change does not affect any other parts of the codebase that rely on the SetQueryContextFn method.

  • 546-559: The StateAtBlockNumber method now calls NewPlugin with the qfn parameter. This change aligns with the updated signature of the NewPlugin function.

  • 567-573: The Clone method now calls NewPlugin with the qfn parameter. This change aligns with the updated signature of the NewPlugin function.

cosmos/runtime/runtime.go (8)
  • 34-43: The import statements have been updated to remove the enginep package and add the config and core packages. Ensure that these changes do not break any dependencies in the code.

  • 45-49: A new interface EVMKeeper has been defined. This interface is used in the Setup method of the Polaris struct. Ensure that the Setup method of the EVMKeeper interface is implemented wherever this interface is used.

  • 52-60: The Polaris struct has been updated. The EVMKeeper field has been removed and the WrappedMiner and WrappedTxPool fields have been added. Ensure that these changes do not break any dependencies in the code.

  • 64-76: A new function New has been added to create a new Polaris instance. This function takes a config.Config, a log.Logger, and a core.PolarisHostChain as arguments. It returns a pointer to a Polaris instance. Ensure that this function is used correctly throughout the codebase.

  • 82-97: The Setup method of the Polaris struct has been updated. The EVMKeeper field is no longer used in this method. Instead, an EVMKeeper interface is passed as an argument. The Setup method of the EVMKeeper interface is called in this method. Ensure that these changes do not break any dependencies in the code.

  • 102-104: The Init method of the Polaris struct has been updated. The EVMKeeper field is no longer used in this method. Ensure that these changes do not break any dependencies in the code.

  • 114-123: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [120-130]

The RegisterServices function has been modified. The EVMKeeper field is no longer used in this function. Ensure that these changes do not break any dependencies in the code.

  • 135-137: The LoadLastState method of the Polaris struct has not been changed. This method loads the last state of the Polaris blockchain.
e2e/testapp/app.go (7)
  • 83-87: The SimApp struct now includes a Polaris field. This change seems to be part of a larger refactoring effort to separate the Polaris EVM runtime from the rest of the application. Ensure that all references to the Polaris field in the SimApp struct have been updated accordingly.

  • 105-107: The SimApp struct now includes an EVMKeeper field. This field seems to be part of the effort to separate the Polaris EVM runtime from the rest of the application. Ensure that all references to the EVMKeeper field in the SimApp struct have been updated accordingly.

  • 121-132: The NewPolarisApp function has been modified. The app variable is now initialized without the polaris field. This change is likely part of the effort to separate the Polaris EVM runtime from the rest of the application. Ensure that all calls to the NewPolarisApp function have been updated accordingly.

  • 178-195: The NewPolarisApp function now initializes the Polaris field of the app struct and calls the Setup method of app.Polaris. This change is likely part of the effort to separate the Polaris EVM runtime from the rest of the application. Ensure that all calls to the NewPolarisApp function have been updated accordingly.

  • 213-217: The LoadLastState method is now called on the Polaris field of the app struct. This change is likely part of the effort to separate the Polaris EVM runtime from the rest of the application. Ensure that all calls to the LoadLastState method have been updated accordingly.

  • 262-266: The StartEnginePlugin method is now called on the EVMKeeper field of the app struct, and the Init method is now called on the Polaris field of the app struct. These changes are likely part of the effort to separate the Polaris EVM runtime from the rest of the application. Ensure that all calls to the StartEnginePlugin and Init methods have been updated accordingly.

  • 270-274: The Close method now checks if the Polaris field of the app struct is not nil before calling its Close method. This change is likely part of the effort to separate the Polaris EVM runtime from the rest of the application. Ensure that all calls to the Close method have been updated accordingly.

@itsdevbear itsdevbear merged commit f7e455f into main Oct 13, 2023
7 checks passed
@itsdevbear itsdevbear deleted the app-refact branch October 13, 2023 19:59
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

Commits Files that changed from the base of the PR and between 614cb02 and 24f163d.
Files selected for processing (10)
  • cosmos/runtime/runtime.go (3 hunks)
  • cosmos/x/evm/depinject.go (2 hunks)
  • cosmos/x/evm/genesis_test.go (5 hunks)
  • cosmos/x/evm/interfaces.go (2 hunks)
  • cosmos/x/evm/keeper/host.go (4 hunks)
  • cosmos/x/evm/keeper/keeper.go (4 hunks)
  • cosmos/x/evm/plugins/block/header_test.go (1 hunks)
  • cosmos/x/evm/plugins/block/plugin.go (2 hunks)
  • cosmos/x/evm/plugins/historical/plugin.go (3 hunks)
  • e2e/testapp/app.go (7 hunks)
Files skipped from review due to trivial changes (5)
  • cosmos/x/evm/depinject.go
  • cosmos/x/evm/genesis_test.go
  • cosmos/x/evm/interfaces.go
  • cosmos/x/evm/keeper/host.go
  • cosmos/x/evm/plugins/block/plugin.go
Additional comments (Suppressed): 21
cosmos/x/evm/plugins/historical/plugin.go (3)
  • 35-35: The comment "Plugin is the interface that must be implemented by the plugin." seems to be misplaced or outdated as there is no interface definition in the provided hunk. Please verify if this comment is still relevant or needs to be updated.

  • 42-49: The cp field (core.ConfigurationPlugin) has been replaced with chainConfig (*params.ChainConfig). Ensure that this change doesn't affect the functionality of the plugin, as the cp field was previously used to get the current chain configuration.

  • 53-63: The NewPlugin function signature has been updated. The cp parameter (core.ConfigurationPlugin) has been replaced with chainConfig (*params.ChainConfig). Ensure that all calls to NewPlugin have been updated to match the new signature.

cosmos/x/evm/plugins/block/header_test.go (1)
  • 45-54: The BeforeEach function has been modified. The SetupMinimalKeepers function call has been removed and replaced with a function that returns mockQueryContext. Ensure that this change does not affect the tests and that the mockQueryContext function provides the necessary context for the tests.
- _, _, _, sk := testutil.SetupMinimalKeepers(log.NewTestLogger(GinkgoT()))
- p = utils.MustGetAs[*plugin](NewPlugin(testutil.EvmKey, sk))
- p.SetQueryContextFn(
-     func() func(height int64, prove bool) (sdk.Context, error) { return mockQueryContext })
+ p = utils.MustGetAs[*plugin](NewPlugin(testutil.EvmKey,
+     func() func(height int64, prove bool) (sdk.Context, error) { return mockQueryContext }))
cosmos/x/evm/keeper/keeper.go (5)
  • 40-45: The Config() method has been added to the Blockchain interface. Ensure that all implementations of this interface have been updated to include this method.

  • 58-63: The sk block.StakingKeeper parameter has been removed from the NewKeeper function. Verify that this change does not affect any calls to this function and that the StakingKeeper is no longer needed.

  • 68-73: The sk parameter has been removed from the host.New function call. Ensure that the StakingKeeper is no longer needed in the host.New function.

  • 81-84: The Setup method has been added to the Keeper struct. This method sets up the keeper with the provided blockchain and calls SetupPrecompiles. Ensure that this method is called appropriately in the codebase.

  • 86-88: The StartEnginePlugin method has been added to the Keeper struct. This method starts the engine plugin. Ensure that this method is called appropriately in the codebase.

cosmos/runtime/runtime.go (5)
  • 67-80: The New function has been introduced to initialize the Polaris struct. It creates a new Polaris runtime from the provided dependencies. It's a good practice to have a separate function for initialization. However, ensure that all instances where the Polaris struct is being initialized have been updated to use this new function.

  • 82-100: The Setup function has been updated. It now takes an EVMKeeper as an argument and calls its Setup method. This change improves the modularity of the code by allowing different implementations of the EVMKeeper interface to be used. However, ensure that all calls to the Setup function have been updated to pass an EVMKeeper argument.

  • 114-129: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [106-120]

The Init function has been updated. It now takes an EVMKeeper as an argument and calls its StartEnginePlugin method. This change improves the modularity of the code by allowing different implementations of the EVMKeeper interface to be used. However, ensure that all calls to the Init function have been updated to pass an EVMKeeper argument.

  • 114-129: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [126-136]

The RegisterServices function has been updated. It no longer starts the engine plugin. This change improves the modularity of the code by allowing the engine plugin to be started elsewhere. However, ensure that the engine plugin is still being started somewhere in the code.

  • 138-143: No significant changes in the LoadLastState function. The function signature and implementation remain the same.
e2e/testapp/app.go (7)
  • 83-87: The SimApp struct now embeds the Polaris struct from the polarruntime package. This change allows direct access to the Polaris struct's methods and fields from a SimApp instance. Ensure that this change does not introduce any naming conflicts or unexpected behavior.

  • 102-107: The EVMKeeper field has been added to the SimApp struct. This field is a pointer to an evmkeeper.Keeper instance, which is used to interact with the EVM (Ethereum Virtual Machine). Ensure that this field is properly initialized before use to prevent nil pointer dereferences.

  • 119-132: The app variable in the NewPolarisApp function no longer initializes the Polaris field. This field is now initialized later in the function. Ensure that this change does not affect the order of operations or introduce any issues.

  • 178-199: The Polaris field of the SimApp struct is now initialized using the polarruntime.New function, which takes the application's configuration, logger, and EVM host as arguments. The Setup method of the Polaris instance is then called with the BaseApp and EVMKeeper as arguments. Ensure that these changes align with the intended setup process for the Polaris runtime.

  • 211-217: The LoadLastState method of the Polaris instance is now called with the application's commit multi-store and the last block height as arguments. Ensure that these changes align with the intended state loading process for the Polaris EVM.

  • 258-264: The Init method of the Polaris instance is now called with the application's client context, logger, and EVM keeper as arguments. Ensure that these changes align with the intended initialization process for the Polaris EVM.

  • 266-271: The Close method of the SimApp struct now checks if the Polaris field is not nil before calling its Close method. This change prevents a potential nil pointer dereference if the Polaris field is not initialized. Good practice for error handling.

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.

2 participants