Skip to content

Commit

Permalink
deps: bump ics to v3.1; chore: update e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalopek committed Jul 24, 2023
1 parent f5fc4ba commit 6850007
Show file tree
Hide file tree
Showing 13 changed files with 207 additions and 175 deletions.
1 change: 1 addition & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ func NewAppKeeper(
// Set legacy router for backwards compatibility with gov v1beta1
govKeeper.SetLegacyRouter(govRouter)

// appKeepers.GovKeeper = *govKeeper
appKeepers.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// register the governance hooks
Expand Down
12 changes: 6 additions & 6 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ import (
ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
ibcprovider "github.com/cosmos/interchain-security/v3/x/ccv/provider"
ibcproviderclient "github.com/cosmos/interchain-security/v3/x/ccv/provider/client"
icsprovider "github.com/cosmos/interchain-security/v3/x/ccv/provider"
icsproviderclient "github.com/cosmos/interchain-security/v3/x/ccv/provider/client"
providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"

"github.com/strangelove-ventures/packet-forward-middleware/v7/router"
Expand Down Expand Up @@ -90,9 +90,9 @@ var ModuleBasics = module.NewBasicManager(
upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
ibcproviderclient.ConsumerAdditionProposalHandler,
ibcproviderclient.ConsumerRemovalProposalHandler,
ibcproviderclient.EquivocationProposalHandler,
icsproviderclient.ConsumerAdditionProposalHandler,
icsproviderclient.ConsumerRemovalProposalHandler,
icsproviderclient.EquivocationProposalHandler,
},
),
sdkparams.AppModuleBasic{},
Expand All @@ -110,7 +110,7 @@ var ModuleBasics = module.NewBasicManager(
ica.AppModuleBasic{},
// TODO: Enable with Global Fee
// globalfee.AppModule{},
ibcprovider.AppModuleBasic{},
icsprovider.AppModuleBasic{},
consensus.AppModuleBasic{},
)

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ require (
cosmossdk.io/math v1.0.1
cosmossdk.io/simapp v0.0.0-20230602123434-616841b9704d
cosmossdk.io/tools/rosetta v0.2.1
github.com/cometbft/cometbft v0.37.1
github.com/cometbft/cometbft v0.37.2
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-sdk v0.47.3
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/ibc-go/v7 v7.1.0
github.com/cosmos/interchain-security/v3 v3.0.0-rc0
github.com/cosmos/interchain-security/v3 v3.1.0
github.com/gorilla/mux v1.8.0
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,8 @@ github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE
github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI=
github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA=
github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M=
github.com/cometbft/cometbft v0.37.1 h1:KLxkQTK2hICXYq21U2hn1W5hOVYUdQgDQ1uB+90xPIg=
github.com/cometbft/cometbft v0.37.1/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc=
github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AKVZpjo=
github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0=
github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4=
Expand Down Expand Up @@ -609,8 +609,8 @@ github.com/cosmos/ibc-go/v7 v7.1.0 h1:SCLgs7tqVnzdIDO5MRLgovAnc696vTTKl+8qsTu8IM
github.com/cosmos/ibc-go/v7 v7.1.0/go.mod h1:7MptlWeIyqmDiuJeRAFqBvXKY8Hybd+rF8vMSmGd2zg=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0=
github.com/cosmos/interchain-security/v3 v3.0.0-rc0 h1:Rm2oMSCod27YkEHFZu5BqjkN3HYtxOrcuHDKMYJBDtw=
github.com/cosmos/interchain-security/v3 v3.0.0-rc0/go.mod h1:HKHw9u4xMm5QJV76A03ORAXB2zisgpcunXZSca8TBdg=
github.com/cosmos/interchain-security/v3 v3.1.0 h1:EKDJCIKIDLG45tvKwfoANrRPgqvqfUt/f1TNKx3b7Uo=
github.com/cosmos/interchain-security/v3 v3.1.0/go.mod h1:2fILBgypEZcwR3BSzKDw+EsYtMKv9Z6cYXfouh4xTYU=
github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo=
github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA=
github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA=
Expand Down
5 changes: 5 additions & 0 deletions proto/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ deps:
repository: ics23
commit: 55085f7c710a45f58fa09947208eb70b
digest: shake256:9bf0bc495b5a11c88d163d39ef521bc4b00bc1374a05758c91d82821bdc61f09e8c2c51dda8452529bf80137f34d852561eacbe9550a59015d51cecb0dacb628
- remote: buf.build
owner: cosmos
repository: interchain-security
commit: 4fcaba68958648a180fdc72c487018b5
digest: shake256:a699ee174513d757cbd2f7a5827f9622b15c0204fe850bdeedbeb4e141f6c33a0e3e341e7aaf6cdd2e05f3deaf6932282805a090b0624759a2418ed7aceb3bc7
- remote: buf.build
owner: googleapis
repository: googleapis
Expand Down
1 change: 1 addition & 0 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ deps:
- buf.build/cosmos/ibc:fbb44f5ad3194450af479a615fa715d9
- buf.build/googleapis/googleapis
- buf.build/cosmos/ics23:b1abd8678aab07165efd453c96796a179eb3131f
- buf.build/cosmos/interchain-security:064c601231b85066bfaf734efec2751a672528a7

breaking:
use:
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
govv1beta1types "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"

gaiaparams "github.com/cosmos/gaia/v11/app/params"
)
Expand All @@ -42,9 +43,9 @@ func init() {
cryptocodec.RegisterInterfaces(encodingConfig.InterfaceRegistry)
govv1types.RegisterInterfaces(encodingConfig.InterfaceRegistry)
govv1beta1types.RegisterInterfaces(encodingConfig.InterfaceRegistry)

upgradetypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
distribtypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
providertypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)

cdc = encodingConfig.Marshaler
txConfig = encodingConfig.TxConfig
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/e2e_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ func (s *IntegrationTestSuite) runGovExec(c *chain, valIdx int, submitterAddr, g
}

gaiaCommand = concatFlags(gaiaCommand, proposalFlags, generalFlags)

s.T().Logf("Executing gaiad tx gov %s on chain %s", govCommand, c.id)
s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx))
s.T().Logf("Successfully executed %s", govCommand)
Expand Down
63 changes: 4 additions & 59 deletions tests/e2e/e2e_gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,64 +147,8 @@ func (s *IntegrationTestSuite) GovCommunityPoolSpend() {
)
}

/*
AddRemoveConsumerChain tests adding and subsequently removing a new consumer chain to Gaia.
Test Benchmarks:
1. Submit and pass proposal to add consumer chain
2. Validation that consumer chain was added
3. Submit and pass proposal to remove consumer chain
4. Validation that consumer chain was removed
*/
// func (s *IntegrationTestSuite) AddRemoveConsumerChain() {
// s.fundCommunityPool()
// chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))
// proposerAddress, _ := s.chainA.validators[0].keyInfo.GetAddress()
// sender := proposerAddress.String()
// consumerChainID := "consumer"
// s.writeAddRemoveConsumerProposals(s.chainA, consumerChainID)

// // Gov tests may be run in arbitrary order, each test must increment proposalCounter to have the correct proposal id to submit and query
// // Add Consumer Chain
// proposalCounter++
// submitGovFlags := []string{"consumer-addition", configFile(proposalAddConsumerChainFilename)}
// depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()}
// voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"}
// s.runGovProcess(chainAAPIEndpoint, sender, proposalCounter, ccvtypes.ProposalTypeConsumerAddition, submitGovFlags, depositGovFlags, voteGovFlags, "vote", false)

// // Query and assert consumer has been added
// s.execQueryConsumerChains(s.chainA, 0, gaiaHomePath, validateConsumerAddition, consumerChainID)

// // Remove Consumer Chain
// proposalCounter++
// submitGovFlags = []string{"consumer-removal", configFile(proposalRemoveConsumerChainFilename)}
// depositGovFlags = []string{strconv.Itoa(proposalCounter), depositAmount.String()}
// voteGovFlags = []string{strconv.Itoa(proposalCounter), "yes"}
// s.runGovProcess(chainAAPIEndpoint, sender, proposalCounter, ccvtypes.ProposalTypeConsumerRemoval, submitGovFlags, depositGovFlags, voteGovFlags, "vote", false)
// // Query and assert consumer has been removed
// s.execQueryConsumerChains(s.chainA, 0, gaiaHomePath, validateConsumerRemoval, consumerChainID)
// }

// func validateConsumerAddition(res ccvtypes.QueryConsumerChainsResponse, consumerChainID string) bool {
// if res.Size() == 0 {
// return false
// }
// for _, chain := range res.GetChains() {
// return strings.Compare(chain.ChainId, consumerChainID) == 0
// }
// return false
// }

// func validateConsumerRemoval(res ccvtypes.QueryConsumerChainsResponse, consumerChainID string) bool {
// if res.Size() > 0 {
// for _, chain := range res.GetChains() {
// if strings.Compare(chain.ChainId, consumerChainID) == 0 {
// return false
// }
// }
// }
// return true
// }

// NOTE: @MSalopek
// rename to runGovLegacyProcess or submitLegacyGovProposal
func (s *IntegrationTestSuite) runGovProcess(chainAAPIEndpoint, sender string, proposalID int, proposalType string, submitFlags []string, depositFlags []string, voteFlags []string, voteCommand string, withDeposit bool) {
s.T().Logf("Submitting Gov Proposal: %s", proposalType)
// min deposit of 1000uatom is required in e2e tests, otherwise the gov antehandler causes the proposal to be dropped
Expand All @@ -219,6 +163,8 @@ func (s *IntegrationTestSuite) runGovProcess(chainAAPIEndpoint, sender string, p
s.submitGovCommand(chainAAPIEndpoint, sender, proposalID, voteCommand, voteFlags, govtypesv1beta1.StatusPassed)
}

// NOTE: @MSalopek
// rename to runGovProcess or submitGovProposal
func (s *IntegrationTestSuite) runGovProcessV1(chainAAPIEndpoint, sender string, proposalID int, proposalType string, submitFlags []string, depositFlags []string, voteFlags []string, voteCommand string, withDeposit bool) {
s.T().Logf("Submitting Gov Proposal: %s", proposalType)
// min deposit of 1000uatom is required in e2e tests, otherwise the gov antehandler causes the proposal to be dropped
Expand Down Expand Up @@ -282,7 +228,6 @@ func (s *IntegrationTestSuite) submitGovCommand(chainAAPIEndpoint, sender string
func() bool {
proposal, err := queryGovProposal(chainAAPIEndpoint, proposalID)
s.Require().NoError(err)

return proposal.GetProposal().Status == expectedSuccessStatus
},
15*time.Second,
Expand Down
139 changes: 139 additions & 0 deletions tests/e2e/e2e_ics_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package e2e

import (
"encoding/json"
"fmt"
"path/filepath"
"strconv"
"strings"
"time"

ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
)

const (
proposalAddConsumerChainFilename = "proposal_add_consumer.json"
proposalRemoveConsumerChainFilename = "proposal_remove_consumer.json"
)

type ConsumerAdditionProposalWithDeposit struct {
providertypes.ConsumerAdditionProposal
Deposit string `json:"deposit"`
Summary string `json:"summary"` // required on legacy proposals
}

type ConsumerRemovalProposalWithDeposit struct {
providertypes.ConsumerRemovalProposal
Deposit string `json:"deposit"`
Summary string `json:"summary"` // required on legacy proposals
}

func (s *IntegrationTestSuite) writeAddRemoveConsumerProposals(c *chain, consumerChainID string) {
hash, _ := json.Marshal("Z2VuX2hhc2g=")
addProp := &providertypes.ConsumerAdditionProposal{
Title: "Create consumer chain",
Description: "First consumer chain",
ChainId: consumerChainID,
InitialHeight: ibcclienttypes.Height{
RevisionHeight: 1,
},
GenesisHash: hash,
BinaryHash: hash,
SpawnTime: time.Now(),
UnbondingPeriod: time.Duration(100000000000),
CcvTimeoutPeriod: time.Duration(100000000000),
TransferTimeoutPeriod: time.Duration(100000000000),
ConsumerRedistributionFraction: "0.75",
BlocksPerDistributionTransmission: 10,
HistoricalEntries: 10000,
}
addPropWithDeposit := ConsumerAdditionProposalWithDeposit{
ConsumerAdditionProposal: *addProp,
Deposit: "1000uatom",
// Summary is
Summary: "Summary for the First consumer chain addition proposal",
}

removeProp := &providertypes.ConsumerRemovalProposal{
Title: "Remove consumer chain",
Description: "Removing consumer chain",
ChainId: consumerChainID,
StopTime: time.Now(),
}

removePropWithDeposit := ConsumerRemovalProposalWithDeposit{
ConsumerRemovalProposal: *removeProp,
Summary: "Summary for the First consumer chain removal proposal",
Deposit: "1000uatom",
}

consumerAddBody, err := json.MarshalIndent(addPropWithDeposit, "", " ")
s.Require().NoError(err)

consumerRemoveBody, err := json.MarshalIndent(removePropWithDeposit, "", " ")
s.Require().NoError(err)

err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalAddConsumerChainFilename), consumerAddBody)
s.Require().NoError(err)
err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalRemoveConsumerChainFilename), consumerRemoveBody)
s.Require().NoError(err)
}

/*
AddRemoveConsumerChain tests adding and subsequently removing a new consumer chain to Gaia.
Test Benchmarks:
1. Submit and pass proposal to add consumer chain
2. Validation that consumer chain was added
3. Submit and pass proposal to remove consumer chain
4. Validation that consumer chain was removed
*/
func (s *IntegrationTestSuite) AddRemoveConsumerChain() {
s.fundCommunityPool()
chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))
proposerAddress, _ := s.chainA.validators[0].keyInfo.GetAddress()
sender := proposerAddress.String()
consumerChainID := "consumer"
s.writeAddRemoveConsumerProposals(s.chainA, consumerChainID)

// Gov tests may be run in arbitrary order, each test must increment proposalCounter to have the correct proposal id to submit and query
// Add Consumer Chain
proposalCounter++
submitGovFlags := []string{"consumer-addition", configFile(proposalAddConsumerChainFilename)}
depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()}
voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"}
s.runGovProcess(chainAAPIEndpoint, sender, proposalCounter, providertypes.ProposalTypeConsumerAddition, submitGovFlags, depositGovFlags, voteGovFlags, "vote", false)

// Query and assert consumer has been added
s.execQueryConsumerChains(s.chainA, 0, gaiaHomePath, validateConsumerAddition, consumerChainID)

// Remove Consumer Chain
proposalCounter++
submitGovFlags = []string{"consumer-removal", configFile(proposalRemoveConsumerChainFilename)}
depositGovFlags = []string{strconv.Itoa(proposalCounter), depositAmount.String()}
voteGovFlags = []string{strconv.Itoa(proposalCounter), "yes"}
s.runGovProcess(chainAAPIEndpoint, sender, proposalCounter, providertypes.ProposalTypeConsumerRemoval, submitGovFlags, depositGovFlags, voteGovFlags, "vote", false)
// Query and assert consumer has been removed
s.execQueryConsumerChains(s.chainA, 0, gaiaHomePath, validateConsumerRemoval, consumerChainID)
}

func validateConsumerAddition(res providertypes.QueryConsumerChainsResponse, consumerChainID string) bool {
if res.Size() == 0 {
return false
}
for _, chain := range res.GetChains() {
return strings.Compare(chain.ChainId, consumerChainID) == 0
}
return false
}

func validateConsumerRemoval(res providertypes.QueryConsumerChainsResponse, consumerChainID string) bool {
if res.Size() > 0 {
for _, chain := range res.GetChains() {
if strings.Compare(chain.ChainId, consumerChainID) == 0 {
return false
}
}
}
return true
}
Loading

0 comments on commit 6850007

Please sign in to comment.