diff --git a/cosmos/miner/miner.go b/cosmos/miner/miner.go index de78cf390..9ed4bd31b 100644 --- a/cosmos/miner/miner.go +++ b/cosmos/miner/miner.go @@ -61,15 +61,17 @@ type EVMKeeper interface { type Miner struct { eth.Miner app App + keeper EVMKeeper serializer EnvelopeSerializer currentPayload *miner.Payload } // New produces a cosmos miner from a geth miner. -func New(gm eth.Miner, app App) *Miner { +func New(gm eth.Miner, app App, keeper EVMKeeper) *Miner { return &Miner{ - Miner: gm, - app: app, + Miner: gm, + keeper: keeper, + app: app, } } @@ -82,9 +84,14 @@ func (m *Miner) Init(serializer EnvelopeSerializer) { func (m *Miner) PrepareProposal( ctx sdk.Context, _ *abci.RequestPrepareProposal, ) (*abci.ResponsePrepareProposal, error) { - var payloadEnvelopeBz []byte - var err error + var ( + payloadEnvelopeBz []byte + err error + ) + if err = m.keeper.PrepareCheckState(ctx); err != nil { + return nil, err + } // We have to run the BeginBlocker to get the chain into the state it'll // be in when the EVM transaction actually runs. if _, err = m.app.BeginBlocker(ctx); err != nil { diff --git a/cosmos/runtime/runtime.go b/cosmos/runtime/runtime.go index 3cfb2683b..6b30c8188 100644 --- a/cosmos/runtime/runtime.go +++ b/cosmos/runtime/runtime.go @@ -104,7 +104,7 @@ func New( func (p *Polaris) Build(app CosmosApp, ek EVMKeeper) error { // Wrap the geth miner and txpool with the cosmos miner and txpool. p.WrappedTxPool = txpool.New(p.Blockchain(), p.TxPool()) - p.WrappedMiner = miner.New(p.Miner(), app) + p.WrappedMiner = miner.New(p.Miner(), app, ek) app.SetMempool(p.WrappedTxPool) app.SetPrepareProposal(p.WrappedMiner.PrepareProposal)