2020-10-20 17:53:13 +00:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
2021-05-14 21:44:58 +00:00
|
|
|
"time"
|
2020-10-20 17:53:13 +00:00
|
|
|
|
2021-04-18 15:54:18 +00:00
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
2021-05-14 21:44:58 +00:00
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/telemetry"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
|
2021-06-30 07:37:03 +00:00
|
|
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
2021-06-22 10:49:18 +00:00
|
|
|
"github.com/tharsis/ethermint/x/evm/types"
|
2020-10-20 17:53:13 +00:00
|
|
|
)
|
|
|
|
|
2021-04-18 15:54:18 +00:00
|
|
|
// BeginBlock sets the block hash -> block height map for the previous block height
|
2020-10-20 17:53:13 +00:00
|
|
|
// and resets the Bloom filter and the transaction count to 0.
|
|
|
|
func (k *Keeper) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
|
2021-05-14 21:44:58 +00:00
|
|
|
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
|
2021-05-31 14:54:59 +00:00
|
|
|
k.WithContext(ctx)
|
2021-06-15 11:53:19 +00:00
|
|
|
k.WithChainID(ctx)
|
2020-10-20 17:53:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// EndBlock updates the accounts and commits state objects to the KV Store, while
|
|
|
|
// deleting the empty ones. It also sets the bloom filers for the request block to
|
2020-12-07 20:09:09 +00:00
|
|
|
// the store. The EVM end block logic doesn't update the validator set, thus it returns
|
2020-10-20 17:53:13 +00:00
|
|
|
// an empty slice.
|
2021-06-08 17:10:29 +00:00
|
|
|
func (k *Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
|
2021-05-14 21:44:58 +00:00
|
|
|
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
|
|
|
|
|
2020-10-20 17:53:13 +00:00
|
|
|
// Gas costs are handled within msg handler so costs should be ignored
|
2021-06-08 17:10:29 +00:00
|
|
|
infCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
|
2021-07-21 11:57:30 +00:00
|
|
|
k.WithContext(infCtx)
|
2020-10-20 17:53:13 +00:00
|
|
|
|
2021-06-30 07:37:03 +00:00
|
|
|
k.SetBlockBloom(infCtx, req.Height, ethtypes.BytesToBloom(k.GetBlockBloomTransient().Bytes()))
|
2021-06-08 17:10:29 +00:00
|
|
|
k.WithContext(ctx)
|
2020-10-20 17:53:13 +00:00
|
|
|
|
|
|
|
return []abci.ValidatorUpdate{}
|
|
|
|
}
|