Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): Make post price txs gasless #817

Merged
merged 36 commits into from
Aug 15, 2022

Conversation

matthiasmatt
Copy link
Contributor

No description provided.

@matthiasmatt matthiasmatt changed the title Mat/make oracle liquidate gasless feat(app): Make post price txs gasless Aug 10, 2022
@matthiasmatt matthiasmatt marked this pull request as ready for review August 10, 2022 15:13
@matthiasmatt matthiasmatt requested a review from a team as a code owner August 10, 2022 15:13
app/ante.go Outdated Show resolved Hide resolved
@AgentSmithMatrix AgentSmithMatrix marked this pull request as draft August 10, 2022 17:11
@AgentSmithMatrix AgentSmithMatrix marked this pull request as ready for review August 11, 2022 07:56
x/pricefeed/client/cli/cli_test.go Outdated Show resolved Hide resolved
app/antedecorators/types/gas.go Show resolved Hide resolved
x/vpool/keeper/keeper.go Show resolved Hide resolved
app/antedecorators/gasless/gasless_test.go Show resolved Hide resolved
@@ -43,7 +53,8 @@ func NewAnteHandler(options AnteHandlerOptions) (sdk.AnteHandler, error) {
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
gaslessante.NewGaslessDecorator(*options.PricefeedKeeper),
feeante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper), // Replace fee ante from cosmos auth with a custom one.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating our own custom DeductFeeDecorator, what if we over-write the t.AuthInfo.Fee.Amount inside of GaslessDecorator so that the default DeductFeeDecorator takes zero coins away from the oracle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of that behavior in the fee.go ante:

	// Ensure that the provided fees meet a minimum threshold for the validator,
	// if this is a CheckTx. This is only for local mempool purposes, and thus
	// is only ran on check tx.
	if ctx.IsCheckTx() && !simulate {
		minGasPrices := ctx.MinGasPrices()
		if !minGasPrices.IsZero() {
			requiredFees := make(sdk.Coins, len(minGasPrices))

			// Determine the required fees by multiplying each required minimum gas
			// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
			glDec := sdk.NewDec(int64(gas))
			for i, gp := range minGasPrices {
				fee := gp.Amount.Mul(glDec)
				requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt())
			}

			if !feeCoins.IsAnyGTE(requiredFees) {
				return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
			}
		}
	}

if you provide 0 coins for required fees, it will fail with: insufficient fees; got: 0 required: 0

@matthiasmatt matthiasmatt enabled auto-merge (squash) August 15, 2022 12:02
@matthiasmatt matthiasmatt merged commit 701b27f into master Aug 15, 2022
@matthiasmatt matthiasmatt deleted the mat/make-oracle-liquidate-gasless branch August 15, 2022 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants