forked from cerc-io/laconicd-deprecated
261f86fdf2
* bump sdk version to v0.39.0 candidate * updates * update evm * bump commit * more changes * build * genesis * fix tests * fix tests * bump commit * bump commit * bump commit * add keygen func * bump version to 0.39.0-rc0 * update AnteHandler * fix TxDecoder * lint * fix test * update statedb * changelog * fixes * remove extra files * update make test-import * rename test * bump SDK version to final release * update to 0.39.1-rc1 * fix evm tests * update RPC * minor fixes * update to rc2 * bump to v0.39.1 * fix personal API * fix string type cast ambiguity (#449) * init * fix estimate gas test * minor genesis change * remove comments from unstable commit (stargate release) Co-authored-by: Alessio Treglia <quadrispro@ubuntu.com>
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package evm
|
|
|
|
import (
|
|
"math/big"
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
|
)
|
|
|
|
// BeginBlock sets the block hash -> block height map and resets the Bloom filter and
|
|
// the transaction count to 0.
|
|
func BeginBlock(k Keeper, ctx sdk.Context, req abci.RequestBeginBlock) {
|
|
if req.Header.LastBlockId.GetHash() == nil || req.Header.GetHeight() < 1 {
|
|
return
|
|
}
|
|
|
|
k.SetBlockHash(ctx, req.Header.LastBlockId.GetHash(), req.Header.GetHeight()-1)
|
|
|
|
// reset counters
|
|
k.Bloom = big.NewInt(0)
|
|
k.TxCount = 0
|
|
}
|
|
|
|
// EndBlock updates the accounts and commits states objects to the KV Store.
|
|
//
|
|
func EndBlock(k Keeper, ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
|
|
// Gas costs are handled within msg handler so costs should be ignored
|
|
ctx = ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter())
|
|
|
|
// Update account balances before committing other parts of state
|
|
k.UpdateAccounts(ctx)
|
|
|
|
// Commit state objects to KV store
|
|
_, err := k.Commit(ctx, true)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
// Clear accounts cache after account data has been committed
|
|
k.ClearStateObjects(ctx)
|
|
|
|
bloom := ethtypes.BytesToBloom(k.Bloom.Bytes())
|
|
k.SetBlockBloom(ctx, ctx.BlockHeight(), bloom)
|
|
|
|
return []abci.ValidatorUpdate{}
|
|
}
|