Skip to content

Commit

Permalink
Merge branch 'release/v1.8.x' into dwedul/merge-1.8.x-after-rc9
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/lint.yml
  • Loading branch information
dwedul-figure committed Mar 10, 2022
2 parents 498cf5c + 4426e10 commit 0246795
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ var handlers = map[string]appUpgrade{
return versionMap, nil
}, // upgrade for pio-testnet-1 from v1.8.0-rc8 to v1.8.0-rc9
},
"kahlua": {}, // upgrade for pio-testnet-1 from v1.8.0-rc9 to v1.8.0
// TODO - Add new upgrade definitions here.
}

Expand Down
2 changes: 1 addition & 1 deletion internal/antewrapper/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
// outermost AnteDecorator. SetUpContext must be called first
NewFeeMeterContextDecorator(), // NOTE : fee gas meter also has the functionality of GasTracerContextDecorator in previous versions
cosmosante.NewRejectExtensionOptionsDecorator(),
cosmosante.NewMempoolFeeDecorator(),
NewTxGasLimitDecorator(),
cosmosante.NewMempoolFeeDecorator(),
// Fee Decorator works to augment NewMempoolFeeDecorator and also check that enough fees are paid
NewMsgFeesDecorator(options.BankKeeper, options.AccountKeeper, options.FeegrantKeeper, options.MsgFeesKeeper),
cosmosante.NewValidateBasicDecorator(),
Expand Down
8 changes: 5 additions & 3 deletions internal/antewrapper/msg_fees_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package antewrapper
import (
"fmt"

"github.com/cosmos/cosmos-sdk/simapp/helpers"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
cosmosante "github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand Down Expand Up @@ -68,7 +70,7 @@ func (afd MsgFeesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool
}
// floor gas price should be checked for all Tx's ( i.e nodes cannot set min-gas-price < floor gas price)
// the chain id check is exclusively for not breaking all existing sim tests which freak out when denom is anything other than stake.
if ctx.IsCheckTx() && !simulate && shouldIgnoreFloorGasPriceCheck(ctx) && (additionalFees.IsZero() || additionalFees == nil) {
if ctx.IsCheckTx() && !simulate && shouldIgnoreChecksForTests(ctx) && (additionalFees.IsZero() || additionalFees == nil) {
err = checkFloorGasFees(gas, feeCoins, additionalFees, afd.msgFeeKeeper.GetFloorGasPrice(ctx))
if err != nil {
return ctx, err
Expand Down Expand Up @@ -120,8 +122,8 @@ func (afd MsgFeesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool
// This check for chain-id is exclusively for not breaking all existing sim tests which freak out when denom is anything other than stake.
// and some network tests won't work without a chain id being set(but they also setup everything with stake denom) so `simapp-unit-testing` chain id is skipped also.
// This only needs to work to pio-testnet and pio-mainnet, so this is safe.
func shouldIgnoreFloorGasPriceCheck(ctx sdk.Context) bool {
return len(ctx.ChainID()) != 0 && ctx.ChainID() != SimAppChainID
func shouldIgnoreChecksForTests(ctx sdk.Context) bool {
return len(ctx.ChainID()) != 0 && ctx.ChainID() != SimAppChainID && ctx.ChainID() != helpers.SimAppChainID
}

// getFeeGranterIfExists checks if fee granter exists and returns account to deduct fees from
Expand Down
10 changes: 2 additions & 8 deletions internal/antewrapper/tx_gas_limit_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import (
// CONTRACT: Tx must implement FeeTx to use TxGasLimitDecorator
type TxGasLimitDecorator struct{}

// MinTxPerBlock is used to determine the maximum amount of gas that any given transaction can use based on the block gas limit.
const MinTxPerBlock = 20

func NewTxGasLimitDecorator() TxGasLimitDecorator {
return TxGasLimitDecorator{}
}
Expand All @@ -27,10 +24,7 @@ func (mfd TxGasLimitDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b
}
// Ensure that the requested gas does not exceed the configured block maximum
gas := feeTx.GetGas()
gasTxLimit := uint64(0)
if ctx.BlockGasMeter() != nil {
gasTxLimit = ctx.BlockGasMeter().Limit() / MinTxPerBlock
}
gasTxLimit := uint64(4_000_000)

// Skip gas limit check for txs with MsgSubmitProposal
hasSubmitPropMsg := false
Expand All @@ -43,7 +37,7 @@ func (mfd TxGasLimitDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b
}

// TODO - remove "gasTxLimit > 0" with SDK 0.46 which fixes the infinite gas meter to use max int vs zero for the limit.
if gasTxLimit > 0 && gas > gasTxLimit && !hasSubmitPropMsg {
if shouldIgnoreChecksForTests(ctx) && gasTxLimit > 0 && gas > gasTxLimit && !hasSubmitPropMsg {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrTxTooLarge, "transaction gas exceeds maximum allowed; got: %d max allowed: %d", gas, gasTxLimit)
}
return next(ctx, tx, simulate)
Expand Down

0 comments on commit 0246795

Please sign in to comment.