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

Commit

Permalink
fix(chain): Fake FinalizeBlock in PrepareProposal (#1272)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

Refactor:
- Removed the "statedb" field from the "blockchain" struct in
`eth/core/chain.go`, indicating a refactoring of state management
functionality.
- Updated `eth/core/chain_writer.go` to create a new `state.StateDB`
object within `WriteGenesisBlock` and `InsertBlockAndSetHead` functions,
enhancing the modularity of state management.
- Modified `WriteBlockAndSetHead` and `writeBlockWithState` functions to
accept a `state.StateDB` parameter, improving the flexibility of state
changes commitment.

These changes streamline the state management process, potentially
improving the performance and maintainability of the code.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
itsdevbear authored Nov 2, 2023
1 parent a097397 commit 3f15a11
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cosmos/miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (m *Miner) Init(serializer EnvelopeSerializer) {

// PrepareProposal implements baseapp.PrepareProposal.
func (m *Miner) PrepareProposal(
ctx sdk.Context, _ *abci.RequestPrepareProposal,
ctx sdk.Context, req *abci.RequestPrepareProposal,
) (*abci.ResponsePrepareProposal, error) {
var (
payloadEnvelopeBz []byte
Expand All @@ -94,7 +94,14 @@ func (m *Miner) PrepareProposal(

// We have to run the PreBlocker && BeginBlocker to get the chain into the state
// it'll be in when the EVM transaction actually runs.
if _, err = m.app.PreBlocker(ctx, nil); err != nil {
if _, err = m.app.PreBlocker(ctx, &abci.RequestFinalizeBlock{
Txs: req.Txs,
Time: req.Time,
Misbehavior: req.Misbehavior,
Height: req.Height,
NextValidatorsHash: req.NextValidatorsHash,
ProposerAddress: req.ProposerAddress,
}); err != nil {
return nil, err
} else if _, err = m.app.BeginBlocker(ctx); err != nil {
return nil, err
Expand Down

0 comments on commit 3f15a11

Please sign in to comment.