Skip to content

Commit

Permalink
change to track it at preblocker
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Oct 20, 2024
1 parent 6d427f9 commit e840fe6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import (
"github.com/initia-labs/minievm/app/posthandler"
evmindexer "github.com/initia-labs/minievm/indexer"
evmconfig "github.com/initia-labs/minievm/x/evm/config"
evmtypes "github.com/initia-labs/minievm/x/evm/types"

// kvindexer
kvindexermodule "github.com/initia-labs/kvindexer/x/kvindexer"
Expand Down Expand Up @@ -228,6 +229,7 @@ func NewMinitiaApp(
// NOTE: upgrade module is required to be prioritized
app.ModuleManager.SetOrderPreBlockers(
upgradetypes.ModuleName,
evmtypes.ModuleName,
)

// set order of module operations
Expand Down
6 changes: 3 additions & 3 deletions x/evm/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/initia-labs/minievm/x/evm/types"
)

// EndBlocker track latest 256 block hashes
func EndBlocker(ctx sdk.Context, k *keeper.Keeper) error {
// PreBlock track latest 256 block hashes
func PreBlock(ctx sdk.Context, k *keeper.Keeper) (sdk.ResponsePreBlock, error) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
return k.TrackBlockHash(ctx, uint64(ctx.BlockHeight()), common.BytesToHash(ctx.HeaderHash()))
return sdk.ResponsePreBlock{}, k.TrackBlockHash(ctx, uint64(ctx.BlockHeight()-1), common.BytesToHash(ctx.HeaderHash()))
}
6 changes: 3 additions & 3 deletions x/evm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
_ module.HasName = AppModule{}

_ appmodule.AppModule = AppModule{}
_ appmodule.HasEndBlocker = AppModule{}
_ appmodule.HasPreBlocker = AppModule{}
)

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -161,7 +161,7 @@ func (am AppModule) IsOnePerModuleType() {}

// EndBlock returns the end blocker for the evm module. It returns no validator
// updates.
func (am AppModule) EndBlock(ctx context.Context) error {
func (am AppModule) PreBlock(ctx context.Context) (appmodule.ResponsePreBlock, error) {
c := sdk.UnwrapSDKContext(ctx)
return EndBlocker(c, am.keeper)
return PreBlock(c, am.keeper)
}

0 comments on commit e840fe6

Please sign in to comment.