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

feat(abci): Utilize geth miner to build blocks #1165

Merged
merged 119 commits into from
Oct 6, 2023
Merged

Conversation

itsdevbear
Copy link

@itsdevbear itsdevbear commented Oct 2, 2023

Summary by CodeRabbit

  • New Feature: Introduced a new "miner" package that implements Ethereum mining operations, enhancing the blockchain's functionality.
  • Refactor: Updated function calls within the Polaris struct to use the new spminer object, reflecting a change in the mining mechanism.
  • Refactor: Renamed the Broadcaster interface to TxBroadcaster and updated related functions and structures accordingly for better clarity.
  • New Feature: Added new functions to the Polaris struct including SPMiner(), MinerChain(), and IsLocalBlock() to enhance block management capabilities.
  • Bug Fix: Modified JSON responses for the eth_getBlockByNumber RPC call to correctly represent data size and withdrawals.
  • Refactor: Shifted from using a blockchain object to a miner object for operations in backend.go, improving code organization.
  • Refactor: Replaced references to app.InterfaceRegistry() with app.interfaceRegistry and ctx.KVStore with ctx.UnsafeFindStoreKey for improved code efficiency.

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

Commits Files that changed from the base of the PR and between 7c62453 and a963038.
Files ignored due to filter (1)
  • e2e/testapp/go.mod
Files selected for processing (5)
  • cosmos/miner/miner.go (1 hunks)
  • cosmos/txpool/handler.go (1 hunks)
  • cosmos/x/evm/keeper/keeper.go (1 hunks)
  • e2e/testapp/app.go (4 hunks)
  • eth/polar/polaris.go (7 hunks)
Files skipped from review due to trivial changes (1)
  • cosmos/x/evm/keeper/keeper.go
Additional comments (Suppressed): 13
e2e/testapp/app.go (4)
  • 59-67: The import "pkg.berachain.dev/polaris/cosmos/miner" is new and replaces the old "pkg.berachain.dev/polaris/cosmos/abci/prepare". Ensure that all dependencies are correctly managed and that this change does not break any existing functionality.

  • 103-109: The SimApp struct now includes a *miner.Miner field, replacing the previous *prepare.Handler field. Make sure that all references to these fields in the codebase have been updated accordingly.

  • 201-210: The NewPolarisApp function has been updated to initialize the Miner and Mempool instances and set them as the prepare proposal handler for the base app. This replaces the previous setup of the Prepare handler. Verify that this change aligns with the intended application logic and doesn't introduce any unexpected behavior.

  • 323-328: The initialization of services has been updated to include the Miner instance, replacing the previous Prepare handler. Ensure that this change is reflected throughout the codebase and doesn't cause any issues with service initialization.

cosmos/miner/miner.go (4)
  • 42-46: The Miner struct embeds miner.Miner and implements the baseapp.TxSelector interface. It includes a serializer for transactions and a payload that is currently being processed. Ensure that the serializer and payload are properly initialized before use to avoid nil pointer dereference errors.

  • 61-70: The PrepareProposal method builds a block of transactions and prepares it for proposal. The error handling here is good, but consider adding more context to the returned error using fmt.Errorf or errors.Wrap for easier debugging.

  • 75-80: The buildBlock method submits a payload for building and waits for the transactions to resolve from the underlying worker. The use of defer to reset m.currentPayload is a good practice to clean up after the function execution.

  • 82-100: The submitPayloadForBuilding method submits a payload for building. It logs the process and handles errors appropriately. However, the TODO comment on line 89 indicates that the payload needs to be properly filled in. Ensure this is addressed before merging.

eth/polar/polaris.go (5)
  • 30-44: The new hunk introduces additional imports, including github.com/ethereum/go-ethereum/miner and pkg.berachain.dev/polaris/eth/consensus. Ensure these packages are used in the code and that they are compatible with the existing codebase.

  • 76-98: The Polaris struct has been modified to include a new field beacon of type consensus.Engine, and the miner field has been changed from miner.Miner to *miner.Miner. The spminer field of type oldminer.Miner has also been added. Make sure all references to these fields in the codebase have been updated accordingly.

  • 132-138: The Init() function now initializes pl.spminer instead of pl.miner. This change should be reflected wherever Init() is called.

  • 152-157: The miner is now initialized with additional parameters including mux, pl.beacon, and pl.IsLocalBlock. Ensure these parameters are correctly set up before this call.

  • 215-238: New getter methods SPMiner(), MinerChain(), and IsLocalBlock() have been introduced. Verify their usage throughout the codebase.

cosmos/txpool/handler.go Outdated Show resolved Hide resolved
cosmos/miner/miner.go Show resolved Hide resolved
eth/polar/polaris.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: 6

Commits Files that changed from the base of the PR and between a963038 and a96cc8b.
Files ignored due to filter (10)
  • cosmos/go.mod
  • cosmos/go.sum
  • e2e/localnet/go.mod
  • e2e/localnet/go.sum
  • e2e/precompile/go.mod
  • e2e/precompile/go.sum
  • e2e/testapp/go.mod
  • e2e/testapp/go.sum
  • eth/go.mod
  • eth/go.sum
Files selected for processing (10)
  • cosmos/miner/miner.go (1 hunks)
  • cosmos/miner/miner_test.go (1 hunks)
  • cosmos/x/evm/keeper/processor.go (1 hunks)
  • e2e/testapp/app.go (4 hunks)
  • eth/core/chain_reader.go (3 hunks)
  • eth/core/chain_writer.go (1 hunks)
  • eth/miner/miner.go (1 hunks)
  • eth/polar/backend.go (4 hunks)
  • eth/polar/mining.go (2 hunks)
  • eth/polar/polaris.go (7 hunks)
Files skipped from review due to trivial changes (2)
  • eth/core/chain_reader.go
  • eth/miner/miner.go
Additional comments (Suppressed): 18
eth/core/chain_writer.go (2)
  • 30-35: The ChainWriter interface has been extended with a new method WriteBlockAndSetHead. Ensure that all implementations of this interface have been updated to include this new method.

  • 44-44: The InsertBlock function signature remains unchanged. No action required.

cosmos/miner/miner.go (1)
  • 42-46: The Miner struct is implementing the baseapp.TxSelector interface but it seems like the required methods for this interface are not implemented in the struct. Please ensure that all necessary methods are implemented.
eth/polar/mining.go (2)
  • 29-35: The Prepare method now uses the spminer object instead of the miner object. Ensure that the spminer.Prepare method has the same behavior as the miner.Prepare method to avoid unexpected results.

  • 40-49: The ProcessTransaction and Finalize methods have been updated to use the spminer object instead of the miner object. Verify that the spminer.ProcessTransaction and spminer.Finalize methods behave similarly to their counterparts in the miner object to maintain consistency.

e2e/testapp/app.go (4)
  • 56-64: The import of the package "pkg.berachain.dev/polaris/cosmos/miner" is new, while the package "pkg.berachain.dev/polaris/cosmos/abci/prepare" has been removed. Ensure that all dependencies on the prepare package have been properly refactored to use the miner package instead.

  • 98-105: The SimApp struct now includes a Miner object (mm) and no longer includes a Prepare handler (pp). This change aligns with the PR summary's mention of replacing calls from the miner object with those from the spminer object in the Prepare, ProcessTransaction, and Finalize functions. Make sure that this doesn't break any existing functionality that relied on the Prepare handler.

  • 198-204: The Miner object is being initialized and its PrepareProposal method is being set as the app's prepare proposal function. This replaces the previous Prepare handler. Ensure that the Miner's PrepareProposal method provides equivalent or improved functionality compared to the old Prepare handler.

  • 311-315: The Miner and Mempool objects are being initialized with a serializer. This replaces the initialization of the Prepare handler. As before, ensure that this change doesn't negatively impact any functionality that relied on the Prepare handler.

cosmos/x/evm/keeper/processor.go (1)
  • 46-46: The Miner().ProcessTransaction() function call has been replaced with SPMiner().ProcessTransaction(). Ensure that the new SPMiner object and its ProcessTransaction method are correctly implemented and tested. Also, verify that all instances of Miner().ProcessTransaction() in the codebase have been updated to SPMiner().ProcessTransaction().
eth/polar/backend.go (4)
  • 229-236: The new hunk has removed the handling of rpc.PendingBlockNumber case where it used to return the current block from the blockchain. This might be a breaking change if there are parts of the codebase that rely on this behavior. Please verify.

  • 293-303: Similar to the previous comment, the handling of rpc.PendingBlockNumber in StateAndHeaderByNumber function has been changed to return the pending state and header from the miner instead of resolving the block number and returning its state. Ensure that this change is propagated throughout the codebase.

  • 362-368: The method PendingBlockAndReceipts now retrieves the pending block and receipts from the miner instead of the blockchain. If other parts of the codebase expect this method to return the pending block and receipts from the blockchain, this could introduce bugs. Please confirm.

  • 546-548: The SubscribePendingLogsEvent method now subscribes to the miner's pending logs instead of the blockchain's. If there are subscribers expecting logs from the blockchain, this could lead to unexpected behavior. Please check.

eth/polar/polaris.go (4)
  • 30-44: The import paths have been updated to include new packages and rename the "miner" package to "oldminer". Ensure that these changes are reflected throughout the codebase and that all dependencies are correctly managed.

  • 85-100: The Polaris struct has been modified to include a new field spminer of type oldminer.Miner and the existing miner field's type has been changed from miner.Miner to *miner.Miner. Also, a new field beacon of type consensus.Engine has been added. Make sure that these changes do not break any existing functionality or introduce any null pointer dereferences.

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

The Init() function now initializes spminer with oldminer.New(pl) instead of miner.New(pl). The miner is also being initialized differently, with additional parameters passed to miner.New(). Ensure that these changes are compatible with the rest of the codebase and that the necessary updates have been made where these functions are called.

  • 214-240: New getter methods SPMiner(), MinerChain(), and IsLocalBlock() have been added to the Polaris struct. The return type of Miner() has been changed from miner.Miner to *miner.Miner. Verify that these changes are consistent with how these methods are used in the rest of the codebase.

cosmos/miner/miner.go Show resolved Hide resolved
cosmos/miner/miner.go Outdated Show resolved Hide resolved
cosmos/miner/miner.go Show resolved Hide resolved
cosmos/miner/miner_test.go 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: 7

Commits Files that changed from the base of the PR and between a96cc8b and 0d8e7d5.
Files ignored due to filter (2)
  • e2e/testapp/go.sum
  • go.work.sum
Files selected for processing (11)
  • cosmos/x/evm/keeper/host.go (1 hunks)
  • e2e/testapp/app.go (4 hunks)
  • eth/consensus/blank_engine.go (1 hunks)
  • eth/core/chain.go (2 hunks)
  • eth/core/chain_writer.go (1 hunks)
  • eth/core/state/imported.go (1 hunks)
  • eth/core/state/statedb.go (1 hunks)
  • eth/core/types/imported.go (1 hunks)
  • eth/miner/miner.go (2 hunks)
  • eth/polar/backend.go (4 hunks)
  • eth/polar/polaris.go (7 hunks)
Files skipped from review due to trivial changes (2)
  • eth/core/state/statedb.go
  • eth/core/types/imported.go
Additional comments (Suppressed): 24
eth/miner/miner.go (2)
  • 68-69: The comment suggests renaming the miner struct or deprecating it. Ensure that this TODO is addressed or tracked in your project management tool to avoid leaving loose ends in the codebase.

  • 125-131: The Prepare method has been modified to reset the state plugin before preparing other plugins. This change could potentially affect the behavior of the Prepare method, especially if any of the other plugins depend on the state of the sp plugin before it was reset. Verify that this change does not introduce any unintended side effects.

eth/core/chain_writer.go (1)
  • 30-35: The ChainWriter interface has been extended with a new method WriteBlockAndSetHead. Ensure that all implementations of this interface in the codebase have been updated to include this new method.
e2e/testapp/app.go (4)
  • 59-64: The import of the miner package and removal of the prepare package aligns with the PR summary. Ensure that all dependencies are correctly managed.

  • 98-105: The Miner struct is replacing the Handler struct from the prepare package. Make sure that the Miner struct implements all necessary methods and functionalities previously provided by the Handler struct.

  • 200-206: The PrepareProposal method of the Miner struct is now being used instead of the PrepareProposal method of the Handler struct from the prepare package. Verify that the new method provides the same functionality and doesn't introduce any breaking changes.

  • 313-317: Initialization of the Miner and Mempool structs has replaced the initialization of the Handler struct from the prepare package. Confirm that this change doesn't affect the application's behavior.

eth/core/chain.go (2)
  • 23-32: The import of "math/big" is new in this hunk. Ensure that it's used in the code not shown in these hunks.

  • 120-129: The currentBlock field of the blockchain struct is now being initialized with a new block having number and base fee as 0, instead of nil. This change could have implications on how the current block is handled elsewhere in the codebase. Make sure all such instances are properly handled to accommodate this change.

-	bc.currentBlock.Store(nil)
+	bc.currentBlock.Store(
+		types.NewBlock(&types.Header{Number: big.NewInt(0),
+			BaseFee: big.NewInt(0)}, nil, nil, nil, trie.NewStackTrie(nil)))
eth/consensus/blank_engine.go (4)
  • 38-41: The Author function is returning an empty address. If this is intentional, ensure that the calling code can handle an empty address without causing any issues.

  • 75-76: The Finalize function does nothing. If this is intentional, ensure that the calling code doesn't expect any side effects from this function.

  • 79-84: The FinalizeAndAssemble function creates a new block but doesn't use the withdrawals parameter. If this is intentional, ensure that the calling code doesn't expect the withdrawals to be included in the block.

  • 87-92: The Seal function doesn't actually seal the block (the .seal() call is commented out). If this is intentional, ensure that the calling code doesn't expect the block to be sealed.

cosmos/x/evm/keeper/host.go (1)
  • 106-116: The new hunk is identical to the old one, no changes have been made. Ensure this is intended.
eth/polar/backend.go (4)
  • 229-236: The new hunk has replaced the previous mechanism of handling pending blocks with a new one. The old code commented out the miner's handling of pending blocks and used the current block as a fallback. The new code directly uses the miner's pending block. Ensure that the miner.PendingBlock() function is implemented correctly and handles all edge cases.

  • 292-303: Similar to the previous comment, the new hunk has replaced the previous mechanism of handling pending states with a new one. The old code commented out the miner's handling of pending states. The new code directly uses the miner's pending state. Ensure that the miner.Pending() function is implemented correctly and handles all edge cases.

  • 364-368: The method PendingBlockAndReceipts() now retrieves the pending block and associated receipts from the miner instead of the blockchain. This change aligns with the overall shift towards using the miner for handling pending transactions and blocks. Ensure that the miner.PendingBlockAndReceipts() function is implemented correctly and handles all edge cases.

  • 546-548: The method SubscribePendingLogsEvent() now subscribes to the miner's pending logs event instead of the blockchain's. This change aligns with the overall shift towards using the miner for handling pending transactions and blocks. Ensure that the miner.SubscribePendingLogs(ch) function is implemented correctly and handles all edge cases.

eth/polar/polaris.go (6)
  • 30-44: The new hunk introduces additional imports, including the consensus package and the oldminer package. Ensure that these packages are correctly implemented and used in the codebase.

  • 85-100: The Polaris struct has been modified to include a new field beacon of type consensus.Engine and spminer of type oldminer.Miner. Make sure that these fields are properly initialized and used throughout the codebase.

  • 113-117: A new beacon field is being initialized with &consensus.DummyEngine{}. If this is a placeholder, ensure it's replaced with an actual consensus engine before production use.

  • 134-138: The Init() function now initializes spminer with oldminer.New(pl). Ensure that this change doesn't affect the functionality of the miner.

  • 153-156: The miner is now initialized with additional parameters mux and pl.beacon. Verify that these parameters are correctly passed and handled in the miner.New() function.

  • 217-240: New methods SPMiner(), MinerChain(), and IsLocalBlock() have been added to the Polaris struct. Ensure that they are correctly implemented and used.

eth/core/state/imported.go Outdated Show resolved Hide resolved
eth/core/chain_writer.go Outdated Show resolved Hide resolved
eth/core/chain_writer.go Outdated Show resolved Hide resolved
eth/core/chain.go Show resolved Hide resolved
eth/consensus/blank_engine.go Outdated Show resolved Hide resolved
eth/consensus/blank_engine.go Outdated Show resolved Hide resolved
eth/consensus/blank_engine.go Outdated Show resolved Hide resolved
@itsdevbear itsdevbear force-pushed the dev/miner-episode-1 branch from acb959b to 98a35ef Compare October 6, 2023 03:17
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 0d8e7d5 and acb959b.
Files selected for processing (1)
  • eth/miner/miner.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • eth/miner/miner.go

@itsdevbear
Copy link
Author

@ocnc @calbera @BrickBera let's get this guy on devnet by EOD if possible 😤😤😤

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

Commits Files that changed from the base of the PR and between 0d8e7d5 and 1dbbfd9.
Files ignored due to filter (2)
  • e2e/testapp/go.mod
  • go.work.sum
Files selected for processing (10)
  • e2e/testapp/app.go (6 hunks)
  • e2e/testapp/export.go (1 hunks)
  • e2e/testapp/helpers.go (1 hunks)
  • eth/consensus/dummy_eth_one.go (1 hunks)
  • eth/core/chain_writer.go (1 hunks)
  • eth/core/state/statedb.go (1 hunks)
  • eth/core/types/imported.go (1 hunks)
  • eth/miner/miner.go (1 hunks)
  • eth/polar/backend.go (4 hunks)
  • eth/polar/polaris.go (7 hunks)
Files skipped from review due to trivial changes (3)
  • eth/core/state/statedb.go
  • eth/core/types/imported.go
  • eth/miner/miner.go
Additional comments (Suppressed): 24
eth/core/chain_writer.go (3)
  • 30-35: The ChainWriter interface has been extended with a new method WriteBlockAndSetHead. Ensure that all implementations of this interface have been updated to include this new method.

  • 33-34: The function signature for WriteBlockAndSetHead has changed, adding two new parameters: state state.StateDB and emitHeadEvent bool. Make sure all calls to this function have been updated accordingly.

  • 44-44: The InsertBlock function remains unchanged in its functionality. However, ensure that the changes in import statements (line 26-27) do not affect its behavior.

eth/consensus/dummy_eth_one.go (3)
  • 44-47: The Author function returns a zero-value address. If this is intentional, ensure that the calling code can handle this value correctly.

  • 82-82: The Finalize function does nothing and has no return statement. If this is intentional, ensure that the calling code can handle this correctly.

  • 88-90: The FinalizeAndAssemble function creates a new block with a nil trie. If this is intentional, ensure that the calling code can handle this correctly.

e2e/testapp/export.go (1)
  • 223-227: The method to get the store key has been changed from GetKey() to UnsafeFindStoreKey(). Ensure that this change doesn't introduce any security vulnerabilities or data inconsistencies. The new method might not perform the same checks as the old one.
- 	store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey))
+ 	store := ctx.KVStore(app.UnsafeFindStoreKey(stakingtypes.StoreKey))
e2e/testapp/helpers.go (1)
  • 61-61: The method call app.interfaceRegistry has been changed to a property access app.InterfaceRegistry. Ensure that the InterfaceRegistry is now a public field in the app struct and not a method. If it's still a method, this change will cause a runtime error.
- app.InterfaceRegistry(),
+ app.interfaceRegistry,
e2e/testapp/app.go (6)
  • 56-64: The import statements have been updated to include the new miner package and remove the prepare package. Ensure that all dependencies are correctly managed and that there are no lingering references to the prepare package in the codebase.

  • 98-105: The SimApp struct has been updated to include a Miner object instead of a Prepare handler. This change aligns with the introduction of the new miner package. Make sure that all instances of SimApp are updated accordingly.

  • 200-215: The setup for the Miner and Mempool objects has been updated. The PrepareProposal method is now called from the Miner object instead of the Prepare handler. Ensure that this change does not affect the functionality of the application.

  • 252-257: Several methods (AppCodec, InterfaceRegistry, TxConfig, GetKey) have been removed from the SimApp struct. If these methods were used elsewhere in the codebase, ensure those references are updated or removed as necessary.

  • 283-289: The initialization of services has been updated to initialize the Miner object instead of the Prepare handler. Ensure that this change does not affect the functionality of the application.

  • 299-301: Several functions (GetMaccPerms, BlockedAddresses) have been removed from the file. If these functions were used elsewhere in the codebase, ensure those references are updated or removed as necessary.

eth/polar/backend.go (4)
  • 229-236: The new hunk has removed the call to b.polar.blockchain.GetBlock(header.Hash(), header.Number.Uint64()) in the case of rpc.PendingBlockNumber. Ensure that this change does not affect the expected behavior of the function. The old hunk used to return the current block when the pending block was requested, but now it returns the actual pending block from the miner.

  • 293-303: Similar to the previous comment, the new hunk has changed the behavior for rpc.PendingBlockNumber case. Previously, the function would resolve the block number and return its state regardless of whether the block number was pending or not. Now, it correctly returns the pending state from the miner if the block number is pending. Make sure all calls to this function are updated to handle this new behavior.

  • 362-368: The function PendingBlockAndReceipts() now retrieves the pending block and receipts from the miner instead of the blockchain. This change aligns with the introduction of the new miner package and seems appropriate given the function's purpose. However, ensure that the miner's PendingBlockAndReceipts() function behaves as expected and that any side effects are handled appropriately.

  • 546-548: The subscription method for pending logs events has been updated to use the miner instead of the blockchain. This change is consistent with the introduction of the new miner package. Ensure that the miner's SubscribePendingLogs function behaves as expected and that any side effects are handled appropriately.

eth/polar/polaris.go (6)
  • 30-44: The import statements have been updated to include new packages and reflect changes in the codebase. Ensure that these packages are available and correctly imported.

  • 85-100: The Polaris struct has been updated with a new field spminer of type oldminer.Miner and miner is now a pointer to miner.Miner. Also, a new field beacon of type consensus.Engine has been added. Make sure all references to these fields in the codebase are updated accordingly.

  • 113-117: A new field beacon is being initialized with &consensus.DummyEthOne{} in the NewWithNetworkingStack function. Verify if this dummy consensus engine is intended for testing or if it should be replaced with a real implementation in production.

  • 134-140: The Init method of the Polaris struct has been updated. The miner is now being initialized as oldminer.New(pl), stored in pl.spminer. Ensure that this change is reflected wherever Init is called.

  • 150-161: The miner field of the Polaris struct is now being initialized with miner.New(pl, &pl.cfg.Miner, pl.host.GetConfigurationPlugin().ChainConfig(), mux, pl.beacon, pl.IsLocalBlock). This is a significant change from the previous version and may affect how the miner operates. Ensure that this new initialization is correct and does not introduce any issues.

  • 214-240: New methods SPMiner(), MinerChain(), and IsLocalBlock(_ *types.Header) have been added to the Polaris struct. Also, the Miner() method now returns a pointer to miner.Miner. Make sure these changes are reflected wherever these methods are called.

eth/consensus/dummy_eth_one.go Show resolved Hide resolved
eth/consensus/dummy_eth_one.go Show resolved Hide resolved
eth/consensus/dummy_eth_one.go Show resolved Hide resolved
@itsdevbear itsdevbear force-pushed the dev/miner-episode-1 branch from 1dbbfd9 to 5d03e96 Compare October 6, 2023 14:30
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: 6

Commits Files that changed from the base of the PR and between 0d8e7d5 and 5d03e96.
Files ignored due to filter (2)
  • e2e/testapp/go.mod
  • go.work.sum
Files selected for processing (10)
  • e2e/testapp/app.go (6 hunks)
  • e2e/testapp/export.go (1 hunks)
  • e2e/testapp/helpers.go (1 hunks)
  • eth/consensus/dummy_eth_one.go (1 hunks)
  • eth/core/chain_writer.go (1 hunks)
  • eth/core/state/statedb.go (1 hunks)
  • eth/core/types/imported.go (1 hunks)
  • eth/miner/miner.go (1 hunks)
  • eth/polar/backend.go (4 hunks)
  • eth/polar/polaris.go (7 hunks)
Files skipped from review due to trivial changes (3)
  • eth/core/types/imported.go
  • eth/miner/miner.go
  • eth/polar/backend.go
Additional comments (Suppressed): 21
e2e/testapp/helpers.go (1)
  • 61-61: The method call app.interfaceRegistry has been changed to a property access app.InterfaceRegistry(). Ensure that the interfaceRegistry is correctly initialized and accessible at this point in the code. If it's not, consider reverting back to the method call.
- app.InterfaceRegistry(),
+ app.interfaceRegistry,
eth/core/state/statedb.go (2)
  • 64-64: The comment // to match geth naming has been updated to //nolint:revive // to match geth naming. This seems to be a directive for the linter to ignore this line. Ensure that this is the intended behavior and that it doesn't introduce any linting issues in other parts of your codebase.

  • 66-69: No significant changes have been made to the PolarStateDB interface. The comment has been slightly modified but the functionality remains the same.

eth/core/chain_writer.go (1)
  • 31-35: The ChainWriter interface has been extended with a new method WriteBlockAndSetHead. Ensure that all implementations of this interface have been updated to include this new method.
e2e/testapp/export.go (1)
  • 225-225: The method to get the store key has been changed from GetKey() to UnsafeFindStoreKey(). Ensure that this change does not introduce any security vulnerabilities or unexpected behavior, as the new method might bypass certain checks or validations present in the old method.
- 	store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey))
+ 	store := ctx.KVStore(app.UnsafeFindStoreKey(stakingtypes.StoreKey))
eth/consensus/dummy_eth_one.go (4)
  • 44-47: The Author function returns an empty address. If this is intentional, ensure that the calling code can handle an empty address without causing any issues.

  • 81-82: The Finalize function does nothing. If this is intentional, ensure that the calling code can handle this correctly.

  • 84-90: In the FinalizeAndAssemble function, a new block is created with a trie.NewStackTrie(nil). Ensure that the calling code can handle a block with a nil trie without causing any issues.

  • 92-98: In the Seal function, the block is "sealed" by simply assigning it to sealedBlock. If this is intentional, ensure that the calling code can handle this correctly.

e2e/testapp/app.go (6)
  • 57-64: The import statement for the "miner" package has been added, and the "prepare" package is no longer imported. Ensure that all dependencies are correctly managed and that there are no unused imports or missing packages.

  • 99-105: The pp field (of type *prepare.Handler) in the SimApp struct has been replaced with mm (of type *miner.Miner). Make sure that this change does not affect other parts of the codebase that rely on the pp field.

  • 200-215: The PrepareProposal method from the miner object is now being used instead of the one from the prepare object. Also, the txConfig.SignModeHandler() call has been changed to app.txConfig.SignModeHandler(). Verify that these changes are intended and do not introduce any unexpected behavior.

  • 252-257: Several methods (AppCodec, InterfaceRegistry, TxConfig, GetKey) have been removed from the SimApp struct. If these methods were used elsewhere in the codebase, those references will need to be updated or removed.

  • 283-289: The Init method is now called on the miner object instead of the prepare object. Ensure that this change is intentional and doesn't cause any issues.

  • 297-301: The Close method of the BaseApp is now being returned if the Polaris object is nil. Previously, nil was returned directly. This change could potentially alter the behavior of the application when closing, so it should be verified.

eth/polar/polaris.go (6)
  • 34-44: The import statements have been updated to include new packages and rename existing ones. Ensure that these changes do not break any dependencies or cause conflicts.

  • 85-100: The Polaris struct has been updated with a new field spminer of type oldminer.Miner and beacon of type consensus.Engine. Make sure these changes are reflected wherever this struct is used.

  • 113-117: A new consensus engine DummyEthOne from the consensus package is being used. Verify if this mock implementation is intended for testing purposes only or if it's meant for production use.

  • 134-140: The Init() function now initializes spminer instead of miner. This change should be reflected in all calls to this function.

  • 150-161: The miner is now initialized with additional parameters mux and pl.beacon. Ensure that these changes are compatible with the miner.New() function signature.

  • 214-240: New methods SPMiner(), MinerChain(), and IsLocalBlock() have been added. If these methods are part of an interface that Polaris implements, ensure that they are implemented correctly.

eth/core/chain_writer.go Show resolved Hide resolved
eth/core/chain_writer.go Show resolved Hide resolved
eth/consensus/dummy_eth_one.go Show resolved Hide resolved
eth/consensus/dummy_eth_one.go Show resolved Hide resolved
eth/consensus/dummy_eth_one.go Show resolved Hide resolved
eth/consensus/dummy_eth_one.go 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: 3

Commits Files that changed from the base of the PR and between 5d03e96 and 4ff3e98.
Files ignored due to filter (1)
  • go.work.sum
Files selected for processing (1)
  • cosmos/miner/miner.go (1 hunks)
Additional comments (Suppressed): 1
cosmos/miner/miner.go (1)
  • 104-105: These fields are marked as "todo". Ensure that these placeholders are replaced with actual values before merging the code.

cosmos/miner/miner.go Show resolved Hide resolved
cosmos/miner/miner.go Show resolved Hide resolved
cosmos/miner/miner.go Show resolved Hide resolved
@itsdevbear itsdevbear added the merge me daddy Trigger Beradozer to bulldoze the PR label Oct 6, 2023
@mergify mergify bot merged commit 5a93af9 into main Oct 6, 2023
@mergify mergify bot deleted the dev/miner-episode-1 branch October 6, 2023 18:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
merge me daddy Trigger Beradozer to bulldoze the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants