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!: SDK v0.47 & IBC v7 Base #2541

Merged
merged 60 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
96ff351
SDK & IBC Base
glnro May 20, 2023
b96afe6
revert GaiaApp AnteHandler, InitChainer, BeginBlock, EndBlocker sette…
sainoe Jun 5, 2023
14da315
fix linter: 2nd attempt
sainoe Jun 5, 2023
c943543
fix sims test
sainoe Jun 5, 2023
4b6a16c
Update app/params/proto.go
sainoe Jun 5, 2023
94c9377
deps: bump IBC to v4.4.1 (#2543)
mpoke May 25, 2023
fc81077
fix: debug upgrade tests in gh actions (#2531)
sainoe May 25, 2023
bde8e5e
docs: update changelog for v9.1.1 (#2546)
yaruwangway May 25, 2023
9ad9a81
run link checker once per day (#2525)
mpoke May 25, 2023
9efa732
run lint only on diff (#2526)
mpoke May 25, 2023
e18c5f6
chore: update module to gaia v11 (#2515)
yaruwangway May 26, 2023
f0a60fd
fix: upgrade test (#2550)
yaruwangway May 26, 2023
4b1acc5
ci: bump go to latest 1.20.x for vulncheck (#2520)
mpoke May 30, 2023
b868932
chore(deps): bump github.com/cosmos/ibc-go/v4 from 4.4.1 to 4.4.2 (#2…
dependabot[bot] May 30, 2023
4a1b19e
ci: improve codeql (#2523)
mpoke May 30, 2023
c6fdb61
fix!: revert to ICS v1.1.0-multiden (#2559)
mpoke May 31, 2023
b39b9a1
chore(deps): bump JamesIves/github-pages-deploy-action (#2551)
dependabot[bot] May 31, 2023
e10b890
chore(deps): bump slackapi/slack-github-action from 1.23.0 to 1.24.0 …
dependabot[bot] Jun 1, 2023
26cecb5
refactor: update comments on globalfee, genutil module init order (#2…
yaruwangway Jun 2, 2023
ac2baab
test: add e2e test for ibc bypass msg (#2532)
yaruwangway Jun 6, 2023
6cde214
docs: Updated atoms amount in governance process (#2566)
mmulji-ic Jun 8, 2023
3ded498
Updated Discord link (#2567)
mmulji-ic Jun 8, 2023
ec2323c
chore: add goreleaser, cleanup release process (#2549)
MSalopek Jun 9, 2023
94741f2
test: parsing result of query hermes pending packets (#2571)
yaruwangway Jun 9, 2023
1c939ae
chore: update workflow re. issues and PRs (#2573)
mpoke Jun 12, 2023
9701820
docs: Increase the validator set of cosmos hub to 180 from 175 (#2572)
mmulji-ic Jun 13, 2023
a60b9df
chore(deps): bump docker/login-action from 2.1.0 to 2.2.0 (#2576)
dependabot[bot] Jun 13, 2023
9bc705d
chore(deps): bump docker/metadata-action from 4.4.0 to 4.5.0 (#2577)
dependabot[bot] Jun 13, 2023
49f9fad
chore(deps): bump docker/build-push-action from 4.0.0 to 4.1.0 (#2578)
dependabot[bot] Jun 13, 2023
f89256f
chore(deps): bump github.com/spf13/viper from 1.15.0 to 1.16.0 (#2563)
dependabot[bot] Jun 13, 2023
efb8efc
chore(deps): bump github.com/stretchr/testify from 1.8.3 to 1.8.4 (#2…
dependabot[bot] Jun 13, 2023
8e1cb97
chore: update version for mergify and dependabot (#2582)
mpoke Jun 13, 2023
e769e53
Update CONTRIBUTING.md (#2580)
mpoke Jun 13, 2023
16107e7
docs: Updates for v9.1.1 and re-arranging roadmap docs (#2560)
mmulji-ic Jun 13, 2023
ba957f7
bump ICS to v2.0.0-rc2 (#2589)
sainoe Jun 14, 2023
71e75e1
refactor: errors module (#2471)
faddat Jun 14, 2023
2b56a32
go mod tidy (#2592)
mpoke Jun 15, 2023
9243c69
Feat : Removed SDK general error types (#2496)
ruthishvitwit Jun 16, 2023
ce8eae8
ci: migrate code quality tooling from Codecov to Sonar Cloud (#2598)
mpoke Jun 16, 2023
3fb679c
docs: Updating the quickstart, joining mainnet & upgrade docs for v10…
mmulji-ic Jun 16, 2023
9da90aa
Update README.md (#2602)
mpoke Jun 19, 2023
9019fba
fix broken link (#2585)
mpoke Jun 19, 2023
f5de546
docs: update globalfee.md according to the `bypass-msg-types` migrati…
yaruwangway Jun 19, 2023
7331475
chore(deps): bump docker/build-push-action from 4.1.0 to 4.1.1 (#2609)
dependabot[bot] Jun 19, 2023
c89980c
chore(deps): bump docker/metadata-action from 4.5.0 to 4.6.0 (#2610)
dependabot[bot] Jun 19, 2023
a390553
chore: update meaning of type-prefix! in production PRs (#2597)
mpoke Jun 19, 2023
4b7a6de
Update test.yml (#2615)
mpoke Jun 19, 2023
fe165b6
chore(deps): bump github.com/cosmos/interchain-security/v2 (#2612)
dependabot[bot] Jun 19, 2023
17ffe07
docs: Update docs for Comet BFT (#2493)
mmulji-ic Jun 20, 2023
937fb31
chore: Update CODEOWNERS (#2614)
mpoke Jun 20, 2023
3be9133
Updated release notes with v10.0.1 (#2618)
mmulji-ic Jun 21, 2023
a1cadd7
chore: start using unclog (#2605)
mpoke Jun 21, 2023
a0c65ef
docs: update changelog for unreleased (#2584)
yaruwangway Jun 21, 2023
ec6e7dd
deps: bump comet to v0.34.29 (#2594)
mpoke Jun 21, 2023
301cb3a
bump upgrades v7 and v8 to ibc-v7
sainoe Jun 23, 2023
382828f
bump ics to v3
sainoe Jun 23, 2023
d37c416
fix go tidy
sainoe Jun 23, 2023
e0822e0
docs: Update docs for Comet BFT (#2493)
mmulji-ic Jun 20, 2023
1d9b6a3
docs: update changelog for unreleased (#2584)
yaruwangway Jun 21, 2023
32e93b2
solve conflicts
sainoe Jun 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this test related to Glabal Fee?

Copy link
Contributor

Choose a reason for hiding this comment

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

i think for now, in sdk0.47 branch, globalfee and ics are not integrated. that is the second steps @sainoe

Copy link
Contributor

Choose a reason for hiding this comment

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

^ this is correct. All tets related to Global Fee will be enabled in a separate PR.

// 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