-
Notifications
You must be signed in to change notification settings - Fork 797
/
gas.go
28 lines (23 loc) · 936 Bytes
/
gas.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package ante
import (
sdk "github.com/cosmos/cosmos-sdk/types"
evmkeeper "github.com/sei-protocol/sei-chain/x/evm/keeper"
evmtypes "github.com/sei-protocol/sei-chain/x/evm/types"
)
type GasLimitDecorator struct {
evmKeeper *evmkeeper.Keeper
}
func NewGasLimitDecorator(evmKeeper *evmkeeper.Keeper) *GasLimitDecorator {
return &GasLimitDecorator{evmKeeper: evmKeeper}
}
// Called at the end of the ante chain to set gas limit properly
func (gl GasLimitDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
msg := evmtypes.MustGetEVMTransactionMessage(tx)
txData, err := evmtypes.UnpackTxData(msg.Data)
if err != nil {
return ctx, err
}
adjustedGasLimit := gl.evmKeeper.GetPriorityNormalizer(ctx).MulInt64(int64(txData.GetGas()))
ctx = ctx.WithGasMeter(sdk.NewGasMeterWithMultiplier(ctx, adjustedGasLimit.TruncateInt().Uint64()))
return next(ctx, tx, simulate)
}