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!: use cosmos-sdk v50 and IBC v8.1 #1698

Merged
merged 72 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
3aaebae
proto: update proto files and deps
MSalopek Feb 28, 2024
5c15fd8
proto: run buf mode update
MSalopek Feb 28, 2024
7f55f9b
deps!: use cosmos-sdk/v0.50 and ibc-go/v8
MSalopek Feb 28, 2024
3ffc5cd
s&r: replace ibc-go imports
MSalopek Feb 28, 2024
95b9418
s&r: replace cosmos-sdk imports
MSalopek Feb 28, 2024
15a44d5
cosmos-sdk: rm legacy upgrade prop handlers
MSalopek Feb 28, 2024
c29e9b0
cosmos-sdk: get cosmossdk.io modules
MSalopek Feb 28, 2024
78a250b
docs: add upgrade reference doc WIP
MSalopek Feb 28, 2024
3f5c326
s&r: replace sdk math with math and legacydec
MSalopek Feb 28, 2024
23b3920
s&r: replace capability
MSalopek Feb 28, 2024
b3d3a45
deps: update modfile after merging main
MSalopek Mar 1, 2024
511b5aa
interface changes: update expected_keepers.go
MSalopek Mar 2, 2024
7eaee93
interface changes: update provider modules, legacy prop handlers
MSalopek Mar 2, 2024
49f217f
provider: update types directory
MSalopek Mar 2, 2024
fd9c4e4
provider: update consumer equivocation
MSalopek Mar 2, 2024
7391c0e
provider: update keeper.go
MSalopek Mar 2, 2024
2c8ea53
provider: update distribution.go
MSalopek Mar 2, 2024
fd13039
provider: update hooks (staking, governance)
MSalopek Mar 2, 2024
9c5f059
provider: update params, add legacy params accessors
MSalopek Mar 2, 2024
1886fb3
provider: update add/remove proposal handling; mv legacy to separate …
MSalopek Mar 2, 2024
12132f7
provider: add missing Tx types, update Msg server
MSalopek Mar 2, 2024
5d8efc2
provider: throttle, throttle_legacy, gov proposal handler (router)
MSalopek Mar 2, 2024
d6cd506
provider: minor update to handler_test
MSalopek Mar 2, 2024
bdb5782
provider: add cons version v4 migration - possibly broken
MSalopek Mar 2, 2024
fa78d1c
provider: client handling - legacy_proposals
MSalopek Mar 2, 2024
8d9929f
provider: update key assignment
MSalopek Mar 2, 2024
1d2c782
provider, testutil: partially fix tests
MSalopek Mar 2, 2024
8b1744c
consumer: migrate consumer module
MSalopek Mar 2, 2024
96e48a6
democracy: update module overrides
MSalopek Mar 2, 2024
8dc5852
testutil: upgrade simibc files
MSalopek Mar 2, 2024
02818d5
testutil: upgrade ibc_testing setups
MSalopek Mar 2, 2024
7c449ee
testutil: upgrade ibc_testing setups
MSalopek Mar 2, 2024
af8b2f2
testutil: update consumerkeeper mocks
MSalopek Mar 2, 2024
768ac23
tests: update provider consumer_equivocation tests
MSalopek Mar 2, 2024
643e98b
tests: fix most provider UTs
MSalopek Mar 2, 2024
ab3637e
provider: fix key assignment and tests
MSalopek Mar 3, 2024
991bf8e
provider: fix throttle and relay tests
MSalopek Mar 3, 2024
47e3b23
provider: update app
MSalopek Mar 4, 2024
61eba9a
provider: update app wiring and cmd
MSalopek Mar 4, 2024
3e2c179
consumer: update consumer app
MSalopek Mar 4, 2024
3d0c853
democracy: update democracy app
MSalopek Mar 4, 2024
545a093
sovereign: update sovereign app
MSalopek Mar 4, 2024
e14209a
integration test: update integration tests
MSalopek Mar 4, 2024
cc81810
mbt: update mbt tests setup
MSalopek Mar 4, 2024
08ff58e
sovereign: add readme file
MSalopek Mar 4, 2024
5a13210
tests: update test setup; refactor key_assignment addr parser
MSalopek Mar 4, 2024
9c47af0
e2e: make initial e2e migration to v50
MSalopek Mar 5, 2024
a19f0e6
provider: update wiring to enable e2e
MSalopek Mar 5, 2024
4fe9ce1
provider: allow nil govkeeper in tests
MSalopek Mar 5, 2024
207ce4a
provider: fix app wiring
MSalopek Mar 5, 2024
76999af
tests: update unittest helpers
MSalopek Mar 5, 2024
c9fbc79
e2e tests: fix errors in provider relay
MSalopek Mar 6, 2024
029770b
sovereign: fix root.go
MSalopek Mar 8, 2024
ede2def
consumer: add prefix registration to consumer main.go
MSalopek Mar 8, 2024
19ccc02
democracy: update democracy app and root init
MSalopek Mar 8, 2024
72ee9fa
apps: refactor apps wiring
MSalopek Mar 8, 2024
158a8e4
democ: refactor root.go wiring
MSalopek Mar 8, 2024
e731e82
democ: correctly override staking InitGenesis
MSalopek Mar 8, 2024
3b25ec7
democracy: update democracy distribution AllocateTokens
MSalopek Mar 11, 2024
f228171
democracy: update staking and gov
MSalopek Mar 11, 2024
fcebdce
democracy: update gov proposal whitelist (add legacy test props)
MSalopek Mar 11, 2024
4a2a951
democracy: update staking interface overrides
MSalopek Mar 11, 2024
8fdf5cf
e2e: refactor democracy tests and related actions
MSalopek Mar 11, 2024
0a34bb6
docs: v50 update reference
MSalopek Mar 12, 2024
98c5e7a
Merge branch 'release/v5.x' into v50-from-v4-main
MSalopek Mar 13, 2024
eab3a0f
conclude merging release/v5
MSalopek Mar 13, 2024
fd8b815
e2e democ: fix democracy consumer IBC transfer tests; update whitelists
MSalopek Mar 13, 2024
aa05492
proto: update evidence messages submitters
MSalopek Mar 13, 2024
d73cee0
tests: update deprecated tests
MSalopek Mar 13, 2024
d624bdd
review: address comments
MSalopek Mar 14, 2024
23caee2
chore: use interchain-security/v5 module name
MSalopek Mar 14, 2024
ceb706b
e2e: update e2e; use v5
MSalopek Mar 14, 2024
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN make install
FROM --platform=linux/amd64 ghcr.io/informalsystems/hermes:v1.8.0 AS hermes-builder

# Get CometMock
FROM ghcr.io/informalsystems/cometmock:v0.37.x as cometmock-builder
FROM ghcr.io/informalsystems/cometmock:v0.38.x as cometmock-builder

# Get GoRelayer
FROM ghcr.io/informalsystems/relayer-no-gas-sim:v2.3.0-rc4-no-gas-sim AS gorelayer-builder
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ $(BUILDDIR)/:
DOCKER := $(shell which docker)
HTTPS_GIT := https://github.com/cosmos/interchain-security.git

containerProtoVer=0.13.0
containerProtoVer=0.14.0
containerProtoImage=ghcr.io/cosmos/proto-builder:$(containerProtoVer)

protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage)
Expand Down
84 changes: 84 additions & 0 deletions app/consumer-democracy/abci.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package app

import (
"bytes"
"crypto/rand"
"encoding/json"
"fmt"

abci "github.com/cometbft/cometbft/abci/types"

"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type (
// VoteExtensionHandler defines a dummy vote extension handler for SimApp.
//
// NOTE: This implementation is solely used for testing purposes. DO NOT use
// in a production application!
VoteExtensionHandler struct{}

// VoteExtension defines the structure used to create a dummy vote extension.
VoteExtension struct {
Hash []byte
Height int64
Data []byte
}
)

func NewVoteExtensionHandler() *VoteExtensionHandler {
return &VoteExtensionHandler{}
}

func (h *VoteExtensionHandler) SetHandlers(bApp *baseapp.BaseApp) {
bApp.SetExtendVoteHandler(h.ExtendVote())
bApp.SetVerifyVoteExtensionHandler(h.VerifyVoteExtension())
}

func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler {
return func(_ sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) {
buf := make([]byte, 1024)

_, err := rand.Read(buf)
if err != nil {
return nil, fmt.Errorf("failed to generate random vote extension data: %w", err)
}

ve := VoteExtension{
Hash: req.Hash,
Height: req.Height,
Data: buf,
}

bz, err := json.Marshal(ve)
if err != nil {
return nil, fmt.Errorf("failed to encode vote extension: %w", err)
}

return &abci.ResponseExtendVote{VoteExtension: bz}, nil
}
}

func (h *VoteExtensionHandler) VerifyVoteExtension() sdk.VerifyVoteExtensionHandler {
return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) {
var ve VoteExtension

if err := json.Unmarshal(req.VoteExtension, &ve); err != nil {
return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil
}

switch {
case req.Height != ve.Height:
return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil

case !bytes.Equal(req.Hash, ve.Hash):
return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil

case len(ve.Data) != 1024:
return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil
}

return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil
}
}
46 changes: 9 additions & 37 deletions app/consumer-democracy/ante/forbidden_proposals_ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ package ante_test
import (
"testing"

ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/stretchr/testify/require"

sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"

app "github.com/cosmos/interchain-security/v4/app/consumer-democracy"
"github.com/cosmos/interchain-security/v4/app/consumer-democracy/ante"
app "github.com/cosmos/interchain-security/v5/app/consumer-democracy"
"github.com/cosmos/interchain-security/v5/app/consumer-democracy/ante"
)

// in SDKv47 parameter updates full params object is required
Expand Down Expand Up @@ -98,8 +97,9 @@ func TestForbiddenProposalsDecorator(t *testing.T) {
}
}

// Only ibctransfertypes.SendEnabled/ReceiveEnabled support legacy proposals for changing params
// Note: see LegacyWhitelistedParams in proposals_whitelisting.go
// Legacy parameter proposals are not supported in cosmos-sdk v0.50
// since modules parameters were moved to their respective modules
// this test is to ensure that legacy parameter proposals are not allowed
func TestForbiddenLegacyProposalsDecorator(t *testing.T) {
txCfg := app.MakeTestEncodingConfig().TxConfig

Expand All @@ -109,17 +109,6 @@ func TestForbiddenLegacyProposalsDecorator(t *testing.T) {
msgs []sdk.Msg
expectErr bool
}{
{
name: "Allowed legacy param change -- only for ibctransfertypes.SendEnabled/ReceiveEnabled",
ctx: sdk.Context{},
msgs: []sdk.Msg{
newLegacyParamChangeProposalMsg([]proposal.ParamChange{
// only subspace and key are relevant for testing
{Subspace: ibctransfertypes.ModuleName, Key: "SendEnabled", Value: "true"},
}),
},
expectErr: false,
},
{
name: "Forbidden param change",
ctx: sdk.Context{},
Expand All @@ -131,33 +120,16 @@ func TestForbiddenLegacyProposalsDecorator(t *testing.T) {
expectErr: true,
},
{
name: "Allowed and forbidden param changes in the same msg",
name: "Multiple forbidden param changes in the same msg",
ctx: sdk.Context{},
msgs: []sdk.Msg{
newLegacyParamChangeProposalMsg([]proposal.ParamChange{
// allowed
{Subspace: ibctransfertypes.ModuleName, Key: "SendEnabled", Value: "true"},
// disallowed
{Subspace: authtypes.ModuleName, Key: "MaxMemoCharacters", Value: ""},
}),
},
expectErr: true,
},
{
name: "Allowed and forbidden param changes in different msg",
ctx: sdk.Context{},
msgs: []sdk.Msg{
newLegacyParamChangeProposalMsg([]proposal.ParamChange{
// disallowed
{Subspace: banktypes.ModuleName, Key: "SendEnabled", Value: ""},
}),
newLegacyParamChangeProposalMsg([]proposal.ParamChange{
// allowed
{Subspace: ibctransfertypes.ModuleName, Key: "SendEnabled", Value: "true"},
}),
},
expectErr: true,
},
}

for _, tc := range testCases {
Expand Down Expand Up @@ -187,11 +159,11 @@ func newLegacyParamChangeProposalMsg(changes []proposal.ParamChange) *govv1.MsgS
if err != nil {
return nil
}
msg, _ := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "")
msg, _ := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "", false)
return msg
}

func newParamChangeProposalMsg(msgs []sdk.Msg) *govv1.MsgSubmitProposal {
msg, _ := govv1.NewMsgSubmitProposal(msgs, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "")
msg, _ := govv1.NewMsgSubmitProposal(msgs, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "", false)
return msg
}
10 changes: 5 additions & 5 deletions app/consumer-democracy/ante_handler.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package app

import (
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"

democracyante "github.com/cosmos/interchain-security/v4/app/consumer-democracy/ante"
consumerante "github.com/cosmos/interchain-security/v4/app/consumer/ante"
ibcconsumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper"
democracyante "github.com/cosmos/interchain-security/v5/app/consumer-democracy/ante"
consumerante "github.com/cosmos/interchain-security/v5/app/consumer/ante"
ibcconsumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
Expand Down
Loading
Loading