Skip to content

Commit

Permalink
feat!: SDK v0.47 & IBC v7 Base (#2541)
Browse files Browse the repository at this point in the history
* SDK & IBC Base

Signed-off-by: lg <lauren@informal.systems>

* revert GaiaApp AnteHandler, InitChainer, BeginBlock, EndBlocker setters and fix linter

* fix linter: 2nd attempt

* fix sims test

* Update app/params/proto.go

* deps: bump IBC to v4.4.1 (#2543)

* bump IBC to v4.4.1

* update changelog

* fix: debug upgrade tests in gh actions (#2531)

* Fix upgrade test in gh actions

* update testnet link

* fix links

* docs: update changelog for v9.1.1 (#2546)

* run link checker once per day (#2525)

* run lint only on diff (#2526)

Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com>

* chore: update module to gaia v11 (#2515)

* update module to gaia v11

* update go.mod

* update globalfee.md

* fix: provider keeper

* fix: upgrade test in CI

* revert to ics v1.1.1

* tidy CI upgrade test scripts

* chore: add v10 upgrades

* fix: lint

* fix: version in app.go

* test: improve test

* fix: upgrade test (#2550)

* ci: bump go to latest 1.20.x for vulncheck (#2520)

* bump go to 1.20.4 for vulncheck

* use latest version of go

* run at 3am UTC

* Updated go version

* Revert "Updated go version"

This reverts commit effe7b7.

---------

Co-authored-by: Yaru Wang <yaru@informal.systems>
Co-authored-by: Milan Mulji <98309852+mmulji-ic@users.noreply.github.com>
Co-authored-by: yaruwangway <69694322+yaruwangway@users.noreply.github.com>

* chore(deps): bump github.com/cosmos/ibc-go/v4 from 4.4.1 to 4.4.2 (#2554)

* chore(deps): bump github.com/cosmos/ibc-go/v4 from 4.4.1 to 4.4.2

Bumps [github.com/cosmos/ibc-go/v4](https://github.com/cosmos/ibc-go) from 4.4.1 to 4.4.2.
- [Release notes](https://github.com/cosmos/ibc-go/releases)
- [Changelog](https://github.com/cosmos/ibc-go/blob/main/CHANGELOG.md)
- [Commits](cosmos/ibc-go@v4.4.1...v4.4.2)

---
updated-dependencies:
- dependency-name: github.com/cosmos/ibc-go/v4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* update changelog

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mpoke <marius.poke@posteo.de>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* ci: improve codeql (#2523)

* improve codeql

* update release/v* pattern

---------

Co-authored-by: yaruwangway <69694322+yaruwangway@users.noreply.github.com>

* fix!: revert to ICS v1.1.0-multiden (#2559)

* use ICS v1.1.0-multiden

* multisig + distribution fix

* chore(deps): bump JamesIves/github-pages-deploy-action (#2551)

Bumps [JamesIves/github-pages-deploy-action](https://github.com/JamesIves/github-pages-deploy-action) from 4.4.0 to 4.4.2.
- [Release notes](https://github.com/JamesIves/github-pages-deploy-action/releases)
- [Commits](JamesIves/github-pages-deploy-action@v4.4.0...v4.4.2)

---
updated-dependencies:
- dependency-name: JamesIves/github-pages-deploy-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump slackapi/slack-github-action from 1.23.0 to 1.24.0 (#2511)

Bumps [slackapi/slack-github-action](https://github.com/slackapi/slack-github-action) from 1.23.0 to 1.24.0.
- [Release notes](https://github.com/slackapi/slack-github-action/releases)
- [Commits](slackapi/slack-github-action@v1.23.0...v1.24.0)

---
updated-dependencies:
- dependency-name: slackapi/slack-github-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* refactor: update comments on globalfee, genutil module init order (#2494)

* docs: update comments on globalfee, genutil module init order

* rename GlobalMinFee GlobalMinFeeParamSource in FeeDecorator

* fix: deadlink

* test: add e2e test for ibc bypass msg (#2532)

* test: setup a new hermes instance

* test: add executeHermesCommand

* test: add hermesTransfer

* test: add ibc-bypass-msg test

* test: add hermes config

* test: enable all e2e test

* fix: tearDownSuite in e2e test

* Apply suggestions from code review

Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com>

* update according to comments

* chore: add comments to code

* chore: correct typo

* refactor bypass msg test

* fix: parse query pending packet result

* fix: format print error

* fix: pending packets parsing

* Apply suggestions from code review

Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com>

* docs: fix dead link

* chore: fix lint

* chore: lint fix

* chore: lint fix1

* chore: remove nolint

* Update tests/e2e/e2e_ibc_test.go

---------

Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com>
Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com>

* docs: Updated atoms amount in governance process (#2566)

* Updated atoms amount in governance process

* Missed some references

* Updated Discord link (#2567)

* chore: add goreleaser, cleanup release process (#2549)

* chore: add goreleaser, cleanup release process

* chore: update RELEASING.md

* chore: add RELEASE_NOTES.md; add make create-release

* chore: rm old release file

* update release process

* fix: apply review comments

* chore: update RELEASE_PROCESS.md with PR comments

* chore: add install step for goreleaser dry-run

---------

Co-authored-by: mpoke <marius.poke@posteo.de>

* test: parsing result of query hermes pending packets (#2571)

* fix: e2e test

* fix: parsing hermes pending packet query result

* fix: rename response RelayerPacketsOutput

* chore: update workflow re. issues and PRs (#2573)

* update PR workflow

* update issue workflow

* docs: Increase the validator set of cosmos hub to 180 from 175 (#2572)

* Updated references 175 validators

* Updated some missing references

* chore(deps): bump docker/login-action from 2.1.0 to 2.2.0 (#2576)

Bumps [docker/login-action](https://github.com/docker/login-action) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](docker/login-action@v2.1.0...v2.2.0)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump docker/metadata-action from 4.4.0 to 4.5.0 (#2577)

Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4.4.0 to 4.5.0.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](docker/metadata-action@v4.4.0...v4.5.0)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump docker/build-push-action from 4.0.0 to 4.1.0 (#2578)

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](docker/build-push-action@v4.0.0...v4.1.0)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump github.com/spf13/viper from 1.15.0 to 1.16.0 (#2563)

Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.15.0 to 1.16.0.
- [Release notes](https://github.com/spf13/viper/releases)
- [Commits](spf13/viper@v1.15.0...v1.16.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/viper
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Milan Mulji <98309852+mmulji-ic@users.noreply.github.com>

* chore(deps): bump github.com/stretchr/testify from 1.8.3 to 1.8.4 (#2564)

Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.3 to 1.8.4.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](stretchr/testify@v1.8.3...v1.8.4)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Milan Mulji <98309852+mmulji-ic@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* chore: update version for mergify and dependabot (#2582)

* update mergify

* update dependabot

* Update CONTRIBUTING.md (#2580)

* docs: Updates for v9.1.1 and re-arranging roadmap docs (#2560)

* Updates for v9.1.1 and re-arranging roadmap docs

* Updated SDK release for Lambda as being an ICS variant

* Added living roadmap link to google docs

* Updated changelog

* bump ICS to v2.0.0-rc2 (#2589)

* refactor: errors module (#2471)

* use the errors module to ease 47 transition

* golangci-lint run ./... --fix

---------

Co-authored-by: Marius Poke <marius.poke@posteo.de>

* go mod tidy (#2592)

* Feat : Removed SDK general error types (#2496)

* Feat : Removed SDK general error types

* Changed  unnecessary wrapf to wrap

* made some required changes

* changed version 10 to 11

* ran go mod tidy

---------

Co-authored-by: Marius Poke <marius.poke@posteo.de>

* ci: migrate code quality tooling from Codecov to Sonar Cloud  (#2598)

* remove codecov and add sonarcloud

* remove /tools folder

* add sonarcloud properties

* update README.md

* docs: Updating the quickstart, joining mainnet & upgrade docs for v10 (#2599)

* Updating the quickstart, joining & upgrade docs

* Updated the changelog

* Updated halt-heights

* Updated the banner for the upgrade, on the initial page

* Updates for pr comments

* Added upgrade doc

* Updated incorrect version number

* Apply suggestions from code review

Co-authored-by: Dante Sanchez <dante.a.sanchez@gmail.com>

---------

Co-authored-by: Dante Sanchez <dante.a.sanchez@gmail.com>

* Update README.md (#2602)

* fix broken link (#2585)

* docs: update globalfee.md according to the `bypass-msg-types` migration (#2463)

* update globalfee.md according to the bypass-msg-types migration

* update test cases in globalfee.md

* update test cases

* improve the docs: globalfee.md

* docs: formatting

* docs: update globalfee.md

* Apply suggestions from code review

Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com>

* docs: update globalfee.md

* docs: improve globalfee.md

* Update docs/modules/globalfee.md

Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com>

* Apply suggestions from code review

Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com>

* docs: update globalfee.md according to comments

* docs: tidy globalfee or global fees

* docs: update globalfee.md

* docs: update globalfee.md

* docs: update docs

---------

Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com>

* chore(deps): bump docker/build-push-action from 4.1.0 to 4.1.1 (#2609)

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](docker/build-push-action@v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump docker/metadata-action from 4.5.0 to 4.6.0 (#2610)

Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](docker/metadata-action@v4.5.0...v4.6.0)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: update meaning of type-prefix! in production PRs (#2597)

* update meaning of type-prefix! in PRs

* apply review suggestions

* Update test.yml (#2615)

* chore(deps): bump github.com/cosmos/interchain-security/v2 (#2612)

Bumps [github.com/cosmos/interchain-security/v2](https://github.com/cosmos/interchain-security) from 2.0.0-rc2 to 2.0.0-rc3.
- [Release notes](https://github.com/cosmos/interchain-security/releases)
- [Changelog](https://github.com/cosmos/interchain-security/blob/main/CHANGELOG.md)
- [Commits](cosmos/interchain-security@v2.0.0-rc2...v2.0.0-rc3)

---
updated-dependencies:
- dependency-name: github.com/cosmos/interchain-security/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* docs: Update docs for Comet BFT (#2493)

* initial pass-thru replace of tendermint for cometbft

* Updated comet links

* Updated vuepress-theme package

* Updated based on comments

* Update docs/zh/validators/security.md

Co-authored-by: yaruwangway <69694322+yaruwangway@users.noreply.github.com>

* Updated CometBFT reference

* Updated CometBFT references

---------

Co-authored-by: yaruwangway <69694322+yaruwangway@users.noreply.github.com>

* chore: Update CODEOWNERS (#2614)

* Update CODEOWNERS

* update codeowners

* Updated release notes with v10.0.1 (#2618)

* chore: start using unclog (#2605)

* add unrelease changelog entries to .changelog

* run unclog build -a

* rename changelog categories

* add tests as a component

* update workflow doc

* docs: update changelog for unreleased (#2584)

* docs: update changelog for v11

* unclog build

---------

Co-authored-by: mpoke <marius.poke@posteo.de>

* deps: bump comet to v0.34.29 (#2594)

* bump comet to v0.34.29

* update changelog

* add entry to .changelog

* bump upgrades v7 and v8 to ibc-v7

* bump ics to v3

* fix go tidy

* docs: Update docs for Comet BFT (#2493)

* initial pass-thru replace of tendermint for cometbft

* Updated comet links

* Updated vuepress-theme package

* Updated based on comments

* Update docs/zh/validators/security.md

Co-authored-by: yaruwangway <69694322+yaruwangway@users.noreply.github.com>

* Updated CometBFT reference

* Updated CometBFT references

---------

Co-authored-by: yaruwangway <69694322+yaruwangway@users.noreply.github.com>

* docs: update changelog for unreleased (#2584)

* docs: update changelog for v11

* unclog build

---------

Co-authored-by: mpoke <marius.poke@posteo.de>

---------

Signed-off-by: lg <lauren@informal.systems>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com>
Co-authored-by: Marius Poke <marius.poke@posteo.de>
Co-authored-by: yaruwangway <69694322+yaruwangway@users.noreply.github.com>
Co-authored-by: Yaru Wang <yaru@informal.systems>
Co-authored-by: Milan Mulji <98309852+mmulji-ic@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com>
Co-authored-by: MSalopek <matija.salopek994@gmail.com>
Co-authored-by: Jacob Gadikian <jacobgadikian@gmail.com>
Co-authored-by: ruthishvitwit <122080147+ruthishvitwit@users.noreply.github.com>
Co-authored-by: Dante Sanchez <dante.a.sanchez@gmail.com>
  • Loading branch information
13 people authored Jul 4, 2023
1 parent a8f0e87 commit ec7c870
Show file tree
Hide file tree
Showing 170 changed files with 9,978 additions and 16,269 deletions.
35 changes: 25 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ start-localnet-ci: build
./build/gaiad config chain-id liveness --home ~/.gaiad-liveness
./build/gaiad config keyring-backend test --home ~/.gaiad-liveness
./build/gaiad keys add val --home ~/.gaiad-liveness
./build/gaiad add-genesis-account val 10000000000000000000000000stake --home ~/.gaiad-liveness --keyring-backend test
./build/gaiad gentx val 1000000000stake --home ~/.gaiad-liveness --chain-id liveness
./build/gaiad collect-gentxs --home ~/.gaiad-liveness
./build/gaiad genesis add-genesis-account val 10000000000000000000000000stake --home ~/.gaiad-liveness --keyring-backend test
./build/gaiad genesis gentx val 1000000000stake --home ~/.gaiad-liveness --chain-id liveness
./build/gaiad genesis collect-gentxs --home ~/.gaiad-liveness
sed -i.bak'' 's/minimum-gas-prices = ""/minimum-gas-prices = "0uatom"/' ~/.gaiad-liveness/config/app.toml
./build/gaiad start --home ~/.gaiad-liveness --x-crisis-skip-assert-invariants

Expand All @@ -300,16 +300,31 @@ test-docker-push: test-docker
###############################################################################
### Protobuf ###
###############################################################################
protoVer=0.13.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

proto-all: proto-format proto-lint proto-gen

proto-gen:
@echo "Generating Protobuf files"
@sh ./proto/scripts/protocgen.sh

proto-doc:
@echo "Generating Protoc docs"
@sh ./proto/scripts/protoc-doc-gen.sh
@$(protoImage) sh ./proto/scripts/protocgen.sh

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
@sh ./proto/scripts/protoc-swagger-gen.sh
@$(protoImage) sh ./proto/scripts/protoc-swagger-gen.sh

proto-format:
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;

proto-lint:
@$(protoImage) buf lint --error-format=json

proto-check-breaking:
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main

proto-update-deps:
@echo "Updating Protobuf dependencies"
$(DOCKER) run --rm -v $(CURDIR)/proto:/workspace --workdir /workspace $(protoImageName) buf mod update

.PHONY: proto-gen proto-doc proto-swagger-gen
.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps
24 changes: 13 additions & 11 deletions ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/ante"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
gaiaerrors "github.com/cosmos/gaia/v11/types/errors"
ibcante "github.com/cosmos/ibc-go/v4/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

gaiafeeante "github.com/cosmos/gaia/v11/x/globalfee/ante"
gaiaerrors "github.com/cosmos/gaia/v11/types/errors"
// gaiafeeante "github.com/cosmos/gaia/v11/x/globalfee/ante"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
Expand All @@ -38,9 +38,10 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
if opts.IBCkeeper == nil {
return nil, errorsmod.Wrap(gaiaerrors.ErrLogic, "IBC keeper is required for AnteHandler")
}
if opts.GlobalFeeSubspace.Name() == "" {
return nil, errorsmod.Wrap(gaiaerrors.ErrNotFound, "globalfee param store is required for AnteHandler")
}
// TODO: Enable with Globalfee
// if opts.GlobalFeeSubspace.Name() == "" {
// return nil, errorsmod.Wrap(gaiaerrors.ErrNotFound, "globalfee param store is required for AnteHandler")
// }
if opts.StakingSubspace.Name() == "" {
return nil, errorsmod.Wrap(gaiaerrors.ErrNotFound, "staking param store is required for AnteHandler")
}
Expand All @@ -55,20 +56,21 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewRejectExtensionOptionsDecorator(),
ante.NewExtensionOptionsDecorator(opts.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(opts.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper),
NewGovPreventSpamDecorator(opts.Codec, opts.GovKeeper),
gaiafeeante.NewFeeDecorator(opts.GlobalFeeSubspace, opts.StakingSubspace),
ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper),
// TODO: Enable with GlobalFee
// gaiafeeante.NewFeeDecorator(opts.GlobalFeeSubspace, opts.StakingSubspace),
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),
ibcante.NewAnteDecorator(opts.IBCkeeper),
ibcante.NewRedundantRelayDecorator(opts.IBCkeeper),
}

return sdk.ChainAnteDecorators(anteDecorators...), nil
Expand Down
9 changes: 5 additions & 4 deletions ante/gov_ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"

gaiaerrors "github.com/cosmos/gaia/v11/types/errors"

"github.com/cosmos/cosmos-sdk/x/authz"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

// initial deposit must be greater than or equal to 10% of the minimum deposit
Expand Down Expand Up @@ -46,10 +47,10 @@ func (g GovPreventSpamDecorator) AnteHandle(
// validateGovMsgs checks if the InitialDeposit amounts are greater than the minimum initial deposit amount
func (g GovPreventSpamDecorator) ValidateGovMsgs(ctx sdk.Context, msgs []sdk.Msg) error {
validMsg := func(m sdk.Msg) error {
if msg, ok := m.(*govtypes.MsgSubmitProposal); ok {
if msg, ok := m.(*govv1beta1.MsgSubmitProposal); ok {
// prevent messages with insufficient initial deposit amount
depositParams := g.govKeeper.GetDepositParams(ctx)
minInitialDeposit := g.calcMinInitialDeposit(depositParams.MinDeposit)
params := g.govKeeper.GetParams(ctx)
minInitialDeposit := g.calcMinInitialDeposit(params.MinDeposit)
if msg.InitialDeposit.IsAllLT(minInitialDeposit) {
return errorsmod.Wrapf(gaiaerrors.ErrInsufficientFunds, "insufficient initial deposit amount - required: %v", minInitialDeposit)
}
Expand Down
102 changes: 51 additions & 51 deletions ante/gov_ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@ import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/stretchr/testify/suite"

tmrand "github.com/cometbft/cometbft/libs/rand"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/cosmos/gaia/v11/ante"
// "github.com/cosmos/gaia/v11/ante"
gaiahelpers "github.com/cosmos/gaia/v11/app/helpers"

gaiaapp "github.com/cosmos/gaia/v11/app"
)

var (
insufficientCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100))
minCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000))
moreThanMinCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 2500000))
testAddr = sdk.AccAddress("test1")
)
// var (
// insufficientCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100))
// minCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000))
// moreThanMinCoins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 2500000))
// testAddr = sdk.AccAddress("test1")
// )

type GovAnteHandlerTestSuite struct {
suite.Suite
Expand All @@ -41,53 +40,54 @@ func (s *GovAnteHandlerTestSuite) SetupTest() {
Height: 1,
})

encodingConfig := gaiaapp.MakeTestEncodingConfig()
encodingConfig.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil)
testdata.RegisterInterfaces(encodingConfig.InterfaceRegistry)
legacyAmino := app.LegacyAmino()
legacyAmino.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil)
testdata.RegisterInterfaces(app.InterfaceRegistry())

s.app = app
s.ctx = ctx
s.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig)
s.clientCtx = client.Context{}.WithTxConfig(app.GetTxConfig())
}

func TestGovSpamPreventionSuite(t *testing.T) {
suite.Run(t, new(GovAnteHandlerTestSuite))
}

func (s *GovAnteHandlerTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() {
// setup test
s.SetupTest()
tests := []struct {
title, description string
proposalType string
proposerAddr sdk.AccAddress
initialDeposit sdk.Coins
expectPass bool
}{
{"Passing proposal 1", "the purpose of this proposal is to pass", govtypes.ProposalTypeText, testAddr, minCoins, true},
{"Passing proposal 2", "the purpose of this proposal is to pass with more coins than minimum", govtypes.ProposalTypeText, testAddr, moreThanMinCoins, true},
{"Failing proposal", "the purpose of this proposal is to fail", govtypes.ProposalTypeText, testAddr, insufficientCoins, false},
}

decorator := ante.NewGovPreventSpamDecorator(s.app.AppCodec(), &s.app.GovKeeper)

for _, tc := range tests {
content := govtypes.ContentFromProposalType(tc.title, tc.description, tc.proposalType)
s.Require().NotNil(content)

msg, err := govtypes.NewMsgSubmitProposal(
content,
tc.initialDeposit,
tc.proposerAddr,
)

s.Require().NoError(err)

err = decorator.ValidateGovMsgs(s.ctx, []sdk.Msg{msg})
if tc.expectPass {
s.Require().NoError(err, "expected %v to pass", tc.title)
} else {
s.Require().Error(err, "expected %v to fail", tc.title)
}
}
}
// TODO: Enable with Global Fee
// func (s *GovAnteHandlerTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() {
// // setup test
// s.SetupTest()
// tests := []struct {
// title, description string
// proposalType string
// proposerAddr sdk.AccAddress
// initialDeposit sdk.Coins
// expectPass bool
// }{
// {"Passing proposal 1", "the purpose of this proposal is to pass", govv1beta1.ProposalTypeText, testAddr, minCoins, true},
// {"Passing proposal 2", "the purpose of this proposal is to pass with more coins than minimum", govv1beta1.ProposalTypeText, testAddr, moreThanMinCoins, true},
// {"Failing proposal", "the purpose of this proposal is to fail", govv1beta1.ProposalTypeText, testAddr, insufficientCoins, false},
// }
//
// decorator := ante.NewGovPreventSpamDecorator(s.app.AppCodec(), &s.app.GovKeeper)
//
// for _, tc := range tests {
// content, _ := govv1beta1.ContentFromProposalType(tc.title, tc.description, tc.proposalType)
// s.Require().NotNil(content)
//
// msg, err := govv1beta1.NewMsgSubmitProposal(
// content,
// tc.initialDeposit,
// tc.proposerAddr,
// )
//
// s.Require().NoError(err)
//
// err = decorator.ValidateGovMsgs(s.ctx, []sdk.Msg{msg})
// if tc.expectPass {
// s.Require().NoError(err, "expected %v to pass", tc.title)
// } else {
// s.Require().Error(err, "expected %v to fail", tc.title)
// }
// }
//}
Loading

0 comments on commit ec7c870

Please sign in to comment.