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

Commit

Permalink
run begin blocker in miner
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Nov 1, 2023
1 parent 57ff739 commit ed2fd90
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions cosmos/miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cosmos/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ed2fd90

Please sign in to comment.