Skip to content

Commit

Permalink
fix: antehandler to fit sdk v0.45 (cosmos#1918)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
yaruwangway and okwme authored Dec 2, 2022
1 parent 11c8a39 commit 824d80f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 22 deletions.
8 changes: 3 additions & 5 deletions ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Empty file added docs/modules/gov.md
Empty file.
7 changes: 2 additions & 5 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 824d80f

Please sign in to comment.