diff --git a/app/app.go b/app/app.go index ffc156f..eba427d 100644 --- a/app/app.go +++ b/app/app.go @@ -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" @@ -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 diff --git a/x/evm/abci.go b/x/evm/abci.go index e23c261..f3a58ea 100644 --- a/x/evm/abci.go +++ b/x/evm/abci.go @@ -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())) } diff --git a/x/evm/module.go b/x/evm/module.go index aa1eb15..40b3545 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -30,7 +30,7 @@ var ( _ module.HasName = AppModule{} _ appmodule.AppModule = AppModule{} - _ appmodule.HasEndBlocker = AppModule{} + _ appmodule.HasPreBlocker = AppModule{} ) // ---------------------------------------------------------------------------- @@ -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) }