From 3f15a11fc5f612d26c2ea0f4da71ab9593f79b14 Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Thu, 2 Nov 2023 18:14:44 -0400 Subject: [PATCH] fix(chain): Fake FinalizeBlock in PrepareProposal (#1272) ## 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. --- cosmos/miner/miner.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cosmos/miner/miner.go b/cosmos/miner/miner.go index 4d5b3daac..21346b4de 100644 --- a/cosmos/miner/miner.go +++ b/cosmos/miner/miner.go @@ -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 @@ -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