Skip to content

Commit

Permalink
Fix tax2gas logic and e2e-test
Browse files Browse the repository at this point in the history
  • Loading branch information
phamminh0811 committed Sep 16, 2024
1 parent d9eb90f commit 458984a
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 79 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

ARG source=./
ARG GO_VERSION="1.20"
ARG GO_VERSION="1.21"
ARG BUILDPLATFORM=linux/amd64
ARG BASE_IMAGE="golang:${GO_VERSION}-alpine3.18"
FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} as base
Expand Down
2 changes: 1 addition & 1 deletion contrib/updates/Dockerfile.old
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

ARG source=./
ARG GO_VERSION="1.20"
ARG GO_VERSION="1.21"
ARG BUILDPLATFORM=linux/amd64
ARG BASE_IMAGE="golang:${GO_VERSION}-alpine3.18"
FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} as base
Expand Down
4 changes: 0 additions & 4 deletions custom/auth/ante/min_initial_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ func HandleCheckMinInitialDeposit(ctx sdk.Context, msg sdk.Msg, govKeeper govkee

// AnteHandle handles checking MsgSubmitProposal
func (midd MinInitialDepositDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
if simulate {
return next(ctx, tx, simulate)
}

msgs := tx.GetMsgs()
for _, msg := range msgs {
if !IsMsgSubmitProposal(msg) {
Expand Down
59 changes: 0 additions & 59 deletions custom/auth/ante/spamming_memo_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion custom/wasm/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func GetTxCmd() *cobra.Command {
txCmd.AddCommand(
cli.StoreCodeCmd(),
InstantiateContractCmd(),
cli.InstantiateContract2Cmd(),
InstantiateContract2Cmd(),
ExecuteContractCmd(),
cli.MigrateContractCmd(),
cli.UpdateContractAdminCmd(),
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ replace (
// use cometbft
github.com/cometbft/cometbft => github.com/classic-terra/cometbft v0.37.4-terra1
github.com/cometbft/cometbft-db => github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-sdk => github.com/classic-terra/cosmos-sdk v0.47.10-terra.1.0.20240910225558-386d57c2a1ee
github.com/cosmos/ibc-go/v7 => github.com/classic-terra/ibc-go/v7 v7.4.0-terra
github.com/cosmos/cosmos-sdk => github.com/classic-terra/cosmos-sdk v0.47.10-terra.2
github.com/cosmos/ibc-go/v7 => github.com/classic-terra/ibc-go/v7 v7.4.0-terra.1
github.com/cosmos/ledger-cosmos-go => github.com/terra-money/ledger-terra-go v0.11.2
// replace goleveldb to optimized one
github.com/syndtr/goleveldb => github.com/classic-terra/goleveldb v0.0.0-20230914223247-2b28f6655121
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,12 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/classic-terra/cometbft v0.37.4-terra1 h1:eT5B2n5KKi5WVW+3ZNOVTmtfKKaZrXOLX9G80m9mhZo=
github.com/classic-terra/cometbft v0.37.4-terra1/go.mod h1:vFqj7Qe3uFFJvHZleTJPQDmJ/WscXHi4rKWqiCAaNZk=
github.com/classic-terra/cosmos-sdk v0.47.10-terra.1.0.20240910225558-386d57c2a1ee h1:wj2pi3ceQsNEHCYLOfny/MWX9f95R1IvIuMSeZMRiUo=
github.com/classic-terra/cosmos-sdk v0.47.10-terra.1.0.20240910225558-386d57c2a1ee/go.mod h1:Qgm2WbKtqHgE1v9eAra7Fos/zAcB7F4ikwwbDm9SV+o=
github.com/classic-terra/cosmos-sdk v0.47.10-terra.2 h1:f54DHwGuOcyrWToTYKpFLy1i5qUz9GAtc6DOg7rF6zI=
github.com/classic-terra/cosmos-sdk v0.47.10-terra.2/go.mod h1:Qgm2WbKtqHgE1v9eAra7Fos/zAcB7F4ikwwbDm9SV+o=
github.com/classic-terra/goleveldb v0.0.0-20230914223247-2b28f6655121 h1:fjpWDB0hm225wYg9vunyDyTH8ftd5xEUgINJKidj+Tw=
github.com/classic-terra/goleveldb v0.0.0-20230914223247-2b28f6655121/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/classic-terra/ibc-go/v7 v7.4.0-terra h1:hawaq62XKlxyc8xLyIcc6IujDDEbqDBU+2U15SF+hj8=
github.com/classic-terra/ibc-go/v7 v7.4.0-terra/go.mod h1:s0lxNkjVIqsb8AVltL0qhzxeLgOKvWZrknPuvgjlEQ8=
github.com/classic-terra/ibc-go/v7 v7.4.0-terra.1 h1:xPT04cguu/Tt//x8eOKQVZP3RfYh/JDaBS4jPexK/OM=
github.com/classic-terra/ibc-go/v7 v7.4.0-terra.1/go.mod h1:viXPCzJXEM2fmtaShW+WD3nm3QGUG/6U+fw44UbnB2I=
github.com/classic-terra/wasmd v0.46.0-classic.1 h1:+EHlqAD8r8Q2jOpjJoKGOTQFW9iD5cV8fKc0XxkZ5O0=
github.com/classic-terra/wasmd v0.46.0-classic.1/go.mod h1:dF31qSPGrHgGPreCCIbAtw/YnJT0Gi997sAA5ZllPSI=
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
Expand Down
2 changes: 1 addition & 1 deletion ictest.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

ARG source=./
ARG GO_VERSION="1.20"
ARG GO_VERSION="1.21"
ARG BUILDPLATFORM=linux/amd64
ARG BASE_IMAGE="golang:${GO_VERSION}-alpine3.18"
FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} as base
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/configurer/chain/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func (n *NodeConfig) InstantiateWasmContract(codeID, initMsg, amount, from strin
}
if len(fees) == 0 {
gasPrices := feeDenomsToGasPrices(feeDenoms)
cmd = append(cmd, "--gas", "auto", "--gas-adjustment=1.2", fmt.Sprintf("--gas-prices=%s", gasPrices))
cmd = append(cmd, "--gas", "auto", "--gas-adjustment=1.5", fmt.Sprintf("--gas-prices=%s", gasPrices))
} else {
feeCoins := sdk.NewCoins(fees...)
cmd = append(cmd, "--fees", feeCoins.String(), "--gas", "auto", "--gas-adjustment=1.2")
cmd = append(cmd, "--fees", feeCoins.String(), "--gas", "auto", "--gas-adjustment=1.5")
}
n.LogActionF(strings.Join(cmd, " "))
_, _, err := n.containerManager.ExecTxCmd(n.t, n.chainID, n.Name, cmd)
Expand Down Expand Up @@ -253,10 +253,10 @@ func (n *NodeConfig) BankSendWithWallet(amount string, sendAddress string, recei
cmd := []string{"terrad", "tx", "bank", "send", sendAddress, receiveAddress, amount, fmt.Sprintf("--from=%s", walletName)}
gasPrices := feeDenomsToGasPrices(feeDenoms)
if len(fees) == 0 {
cmd = append(cmd, "--gas", "auto", "--gas-adjustment=1.2", fmt.Sprintf("--gas-prices=%s", gasPrices))
cmd = append(cmd, "--gas", "auto", "--gas-adjustment=1.5", fmt.Sprintf("--gas-prices=%s", gasPrices))
} else {
feeCoins := sdk.NewCoins(fees...)
cmd = append(cmd, "--fees", feeCoins.String(), "--gas", "auto", "--gas-adjustment=1.2")
cmd = append(cmd, "--fees", feeCoins.String(), "--gas", "auto", "--gas-adjustment=1.5")
}
_, _, err := n.containerManager.ExecTxCmd(n.t, n.chainID, n.Name, cmd)
require.NoError(n.t, err)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

ARG source=./
ARG GO_VERSION="1.20"
ARG GO_VERSION="1.21"
ARG BUILDPLATFORM=linux/amd64
ARG BASE_IMAGE="golang:${GO_VERSION}-alpine3.18"
FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} as base
Expand Down
5 changes: 5 additions & 0 deletions x/tax2gas/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ func (fd FeeDecorator) tryDeductFee(ctx sdk.Context, feeTx sdk.FeeTx, taxes sdk.
return "", nil
}

// Try to simulate using taxes
if foundCoins.IsZero() && simulate {
foundCoins = taxes
}

// if feegranter set deduct fee from feegranter account.
// this works with only when feegrant enabled.
if feeGranter != nil {
Expand Down
11 changes: 10 additions & 1 deletion x/tax2gas/post/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ func (tgd Tax2gasPostDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simulate
return ctx, errorsmod.Wrapf(err, "%s does not allow to pay fees for %s", feeGranter, feePayer)
}

// Try to simulate using paid denom
if feeCoins.IsZero() && simulate {
fees, err := tax2gasutils.ComputeFeesOnGasConsumed(tx, sdk.DecCoins{sdk.NewDecCoinFromDec(paidDenom, paidDenomGasPrice)}, totalGasRemaining)
if err != nil {
return ctx, err
}
feeCoins = fees
}

// First, we will deduct the fees covered taxGas and handle BurnTaxSplit
taxes, payableFees, gasRemaining := tax2gasutils.CalculateTaxesAndPayableFee(gasPrices, feeCoins, taxGas, totalGasRemaining)
if !simulate && !ctx.IsCheckTx() && gasRemaining.IsPositive() {
Expand All @@ -159,7 +168,7 @@ func (tgd Tax2gasPostDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simulate
}
feePayerAccount := tgd.accountKeeper.GetAccount(ctx, feePayer)

if !simulate && taxes.IsZero() {
if taxes.IsZero() && !simulate {
payableFees = feeCoins
}
err := tgd.bankKeeper.SendCoinsFromAccountToModule(ctx, feePayerAccount.GetAddress(), authtypes.FeeCollectorName, payableFees)
Expand Down

0 comments on commit 458984a

Please sign in to comment.