From 824d80fa71fc22847d7ac2f02a59970b5c03ed05 Mon Sep 17 00:00:00 2001 From: yaruwangway <69694322+yaruwangway@users.noreply.github.com> Date: Fri, 2 Dec 2022 12:14:55 +0100 Subject: [PATCH] fix: antehandler to fit sdk v0.45 (#1918) * pause * no vscode errors * rewrite go.sum, go.work.sum and fix amino import * remove mauth docs * gofumpt * fix find * cant get docker to build locally * debug ibc test * fix ibc test * passing e2e * clean up commented out tests * remove more mauth * forgot to save * add back middleware test * fix upgrade * fix test setup * add TODO note * remove multihop test * fix: antehandler in sdkv0.45 * test: add back globalfee e2e test * fix: failure of verifying sending token amount * chore: remove comments * feat: simplify fee logic Co-authored-by: billy rennekamp --- ante/ante.go | 8 +++----- app/app.go | 12 ------------ docs/modules/gov.md | 0 tests/e2e/e2e_test.go | 7 ++----- 4 files changed, 5 insertions(+), 22 deletions(-) create mode 100644 docs/modules/gov.md diff --git a/ante/ante.go b/ante/ante.go index 19a63231111..0128cf4b744 100644 --- a/ante/ante.go +++ b/ante/ante.go @@ -5,6 +5,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/ante" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante" ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" gaiafeeante "github.com/cosmos/gaia/v8/x/globalfee/ante" @@ -47,22 +48,19 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) { anteDecorators := []sdk.AnteDecorator{ ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first - // ante.NewExtensionOptionsDecorator(opts.ExtensionOptionChecker), + ante.NewRejectExtensionOptionsDecorator(), ante.NewValidateBasicDecorator(), ante.NewTxTimeoutHeightDecorator(), ante.NewValidateMemoDecorator(opts.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper), gaiafeeante.NewFeeDecorator(opts.BypassMinFeeMsgTypes, opts.GlobalFeeSubspace, opts.StakingSubspace), - // if opts.TxFeeCheck is nil, it is the default fee check ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper), - // ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper, opts.TxFeeChecker), ante.NewSetPubKeyDecorator(opts.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators ante.NewValidateSigCountDecorator(opts.AccountKeeper), ante.NewSigGasConsumeDecorator(opts.AccountKeeper, sigGasConsumer), ante.NewSigVerificationDecorator(opts.AccountKeeper, opts.SignModeHandler), ante.NewIncrementSequenceDecorator(opts.AccountKeeper), - // TODO: check what this is - // ibcante.NewRedundantRelayDecorator(opts.IBCkeeper), + ibcante.NewAnteDecorator(opts.IBCkeeper), } return sdk.ChainAnteDecorators(anteDecorators...), nil diff --git a/app/app.go b/app/app.go index b6c4f162e37..8cb5a76bb19 100644 --- a/app/app.go +++ b/app/app.go @@ -197,18 +197,6 @@ func NewGaiaApp( FeegrantKeeper: app.FeeGrantKeeper, SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), SigGasConsumer: ante.DefaultSigVerificationGasConsumer, - // TxFeeChecker is not the default fee check, it will not check if the fee meets min_gas_price, this is checked in NewFeeWithBypassDecorator already. - // TxFeeChecker: func(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) { - // feeTx, ok := tx.(sdk.FeeTx) - // if !ok { - // return nil, 0, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") - // } - - // feeCoins := feeTx.GetFee() - // priority := gaiafeeante.GetTxPriority(feeCoins) - - // return feeCoins, priority, nil - // }, }, IBCkeeper: app.IBCKeeper, BypassMinFeeMsgTypes: bypassMinFeeMsgTypes, diff --git a/docs/modules/gov.md b/docs/modules/gov.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 16f471c6ef8..76ed74a0e64 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -18,8 +18,6 @@ func (s *IntegrationTestSuite) TestGov() { // globalfee in genesis is set to be "0.00001uatom" func (s *IntegrationTestSuite) TestQueryGlobalFeesInGenesis() { - // TODO: Fix and add back this test - s.T().Skip() chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) feeInGenesis, err := sdk.ParseDecCoins(initialGlobalFeeAmt + uatomDenom) s.Require().NoError(err) @@ -66,9 +64,7 @@ test4: gov propose globalfee = 0.000001uatom (lower than min_gas_price), 0photo test5: check balance correct: all the successful bank sent tokens are received test6: gov propose change back to initial globalfee = 0.00001photon, This is for not influence other e2e tests. */ -// TODO: add back global fee tests func (s *IntegrationTestSuite) TestGlobalFees() { - s.T().Skip() chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() @@ -79,7 +75,8 @@ func (s *IntegrationTestSuite) TestGlobalFees() { var beforeRecipientPhotonBalance sdk.Coin s.Require().Eventually( func() bool { - beforeRecipientPhotonBalance, err := getSpecificBalance(chainAAPIEndpoint, recipient, photonDenom) + var err error + beforeRecipientPhotonBalance, err = getSpecificBalance(chainAAPIEndpoint, recipient, photonDenom) s.Require().NoError(err) return beforeRecipientPhotonBalance.IsValid()