Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [\#467](https://github.com/cosmos/evm/pull/467) Replace GlobalEVMMempool by passing to JSONRPC on initiate.
- [\#352](https://github.com/cosmos/evm/pull/352) Remove the creation of a Geth EVM instance, stateDB during the AnteHandler balance check.
- [\#496](https://github.com/cosmos/evm/pull/496) Simplify mempool instantiation by using configs instead of objects.
- [\#568](https://github.com/cosmos/evm/pull/568) Avoid unnecessary block notifications when the event bus is already set up.
- [\#511](https://github.com/cosmos/evm/pull/511) Minor code cleanup for `AddPrecompileFn`.

### FEATURES
Expand Down
5 changes: 5 additions & 0 deletions mempool/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func (b Blockchain) CurrentBlock() *types.Header {
}

blockHeight := ctx.BlockHeight()
// prevent the reorg from triggering after a restart since previousHeaderHash is stored as an in-memory variable
if blockHeight > 1 && b.previousHeaderHash == (common.Hash{}) {
return b.zeroHeader
}

blockTime := ctx.BlockTime().Unix()
gasUsed := b.feeMarketKeeper.GetBlockGasWanted(ctx)
appHash := common.BytesToHash(ctx.BlockHeader().AppHash)
Expand Down
7 changes: 6 additions & 1 deletion mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (m *ExperimentalEVMMempool) SelectBy(goCtx context.Context, i [][]byte, f f

// SetEventBus sets CometBFT event bus to listen for new block header event.
func (m *ExperimentalEVMMempool) SetEventBus(eventBus *cmttypes.EventBus) {
if m.eventBus != nil {
if m.HasEventBus() {
m.eventBus.Unsubscribe(context.Background(), SubscriberName, stream.NewBlockHeaderEvents) //nolint: errcheck
}
m.eventBus = eventBus
Expand All @@ -396,6 +396,11 @@ func (m *ExperimentalEVMMempool) SetEventBus(eventBus *cmttypes.EventBus) {
}()
}

// HasEventBus returns true if the blockchain is configured to use an event bus for block notifications.
func (m *ExperimentalEVMMempool) HasEventBus() bool {
return m.eventBus != nil
}

// Close unsubscribes from the CometBFT event bus and shuts down the mempool.
func (m *ExperimentalEVMMempool) Close() error {
var errs []error
Expand Down
2 changes: 1 addition & 1 deletion x/vm/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context) error {
// Gas costs are handled within msg handler so costs should be ignored
infCtx := ctx.WithGasMeter(storetypes.NewInfiniteGasMeter())

if k.evmMempool != nil {
if k.evmMempool != nil && !k.evmMempool.HasEventBus() {
k.evmMempool.GetBlockchain().NotifyNewBlock()
}

Expand Down
Loading