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

tests: fix broken sovereign app.go (backport #1068) #1075

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions app/consumer-democracy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ import (
consumer "github.com/cosmos/interchain-security/v3/x/ccv/consumer"
consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper"
consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)

const (
Expand Down
2 changes: 0 additions & 2 deletions app/consumer/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ import (
ibcconsumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper"
ibcconsumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
testutil "github.com/cosmos/interchain-security/v3/testutil/integration"
)

Expand Down
3 changes: 0 additions & 3 deletions app/provider/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ import (
providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"

testutil "github.com/cosmos/interchain-security/v3/testutil/integration"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)

const (
Expand Down
28 changes: 23 additions & 5 deletions app/sovereign/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"os"
"path/filepath"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
appparams "github.com/cosmos/interchain-security/v3/app/params"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand All @@ -27,8 +30,12 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"

"github.com/cosmos/cosmos-sdk/x/consensus"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"

"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
Expand All @@ -44,7 +51,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/capability"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
Expand Down Expand Up @@ -108,6 +114,7 @@ import (
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"

paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
)

const (
Expand All @@ -125,7 +132,7 @@ var (
// and genesis verification.
ModuleBasics = module.NewBasicManager(
auth.AppModuleBasic{},
genutil.AppModuleBasic{},
genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
bank.AppModuleBasic{},
capability.AppModuleBasic{},
sdkstaking.AppModuleBasic{},
Expand All @@ -148,6 +155,8 @@ var (
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
tendermint.AppModuleBasic{},
consensus.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -246,11 +255,11 @@ func New(
bApp.SetInterfaceRegistry(interfaceRegistry)

keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey,
capabilitytypes.StoreKey, authzkeeper.StoreKey,
capabilitytypes.StoreKey, authzkeeper.StoreKey, consensusparamtypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand All @@ -263,6 +272,7 @@ func New(
keys: keys,
tkeys: tkeys,
memKeys: memKeys,
txConfig: encodingConfig.TxConfig,
}

app.ParamsKeeper = initParamsKeeper(
Expand Down Expand Up @@ -623,6 +633,14 @@ func New(
app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper

autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.MM.Modules))

reflectionSvc, err := runtimeservices.NewReflectionService()
if err != nil {
panic(err)
}
reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc)

return app
}

Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs=
github.com/tyler-smith/go-bip39 v1.0.2/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ func (tr TestRun) delegateTokens(
}

// wait for inclusion in a block -> '--broadcast-mode block' is deprecated
tr.waitBlocks(action.chain, 1, 10*time.Second)
tr.waitBlocks(action.chain, 2, 10*time.Second)
}

type unbondTokensAction struct {
Expand Down Expand Up @@ -1760,7 +1760,6 @@ func (tr TestRun) registerConsumerRewardDenom(action registerConsumerRewardDenom
`--node`, tr.getValidatorNode(action.chain, action.from),
`--gas`, "9000000",
`--keyring-backend`, `test`,
`-b`, `block`,
`-y`,
).CombinedOutput()

Expand All @@ -1771,6 +1770,8 @@ func (tr TestRun) registerConsumerRewardDenom(action registerConsumerRewardDenom
if err != nil {
log.Fatal(err, "\n", string(bz))
}

tr.waitBlocks(action.chain, 2, 10*time.Second)
}

// Creates an additional node on selected chain
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e/actions_sovereign_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ func (tr TestRun) startSovereignChain(
}, verbose)
}

type UpgradeProposalAction struct {
type LegacyUpgradeProposalAction struct {
chainID chainID
upgradeTitle string
proposer validatorID
upgradeHeight uint64
}

func (tr *TestRun) submitUpgradeProposal(action UpgradeProposalAction, verbose bool) {
func (tr *TestRun) submitLegacyUpgradeProposal(action LegacyUpgradeProposalAction, verbose bool) {
submit := fmt.Sprintf(
`%s tx gov submit-proposal software-upgrade %s \
`%s tx gov submit-legacy-proposal software-upgrade %s \
--title %s \
--deposit 10000000stake \
--upgrade-height %s \
Expand All @@ -126,7 +126,7 @@ func (tr *TestRun) submitUpgradeProposal(action UpgradeProposalAction, verbose b
--chain-id %s \
--home %s \
--node %s \
-b block \
--no-validate \
-y`,
tr.chainConfigs[chainID("sover")].binaryName,
action.upgradeTitle,
Expand All @@ -152,6 +152,8 @@ func (tr *TestRun) submitUpgradeProposal(action UpgradeProposalAction, verbose b
if err != nil {
log.Fatal(err, "\n", string(bz))
}

tr.waitBlocks(action.chainID, 1, 15*time.Second)
}

type waitUntilBlockAction struct {
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,12 @@ func ChangeoverTestRun() TestRun {
binaryName: "interchain-security-pd",
ipPrefix: "7.7.7",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.voting_params.voting_period = \"20s\" | " +
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"2s\" | " +
".app_state.slashing.params.downtime_jail_duration = \"60s\" | " +
".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\" | " +
".app_state.provider.params.slash_meter_replenish_fraction = \"1.0\" | " + // This disables slash packet throttling
".app_state.provider.params.slash_meter_replenish_period = \"3s\"",
Expand All @@ -380,10 +380,10 @@ func ChangeoverTestRun() TestRun {
upgradeBinary: "interchain-security-cdd",
ipPrefix: "7.7.8",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.voting_params.voting_period = \"20s\" | " +
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.slashing.params.signed_blocks_window = \"15\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"2s\" | " +
".app_state.slashing.params.downtime_jail_duration = \"60s\" | " +
".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\" | " +
".app_state.staking.params.unbonding_time = \"1728000s\"", // making the genesis unbonding time equal to unbonding time in the consumer addition proposal
},
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ func (tr *TestRun) runStep(step Step, verbose bool) {
tr.startChain(action, verbose)
case StartSovereignChainAction:
tr.startSovereignChain(action, verbose)
case UpgradeProposalAction:
tr.submitUpgradeProposal(action, verbose)
case LegacyUpgradeProposalAction:
tr.submitLegacyUpgradeProposal(action, verbose)
case waitUntilBlockAction:
tr.waitUntilBlockOnChain(action)
case ChangeoverChainAction:
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ func (tr TestRun) getProposal(chain chainID, proposal uint) Proposal {
},
}
case "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal":
height := gjson.Get(string(bz), `content.plan.height`).Uint()
title := gjson.Get(string(bz), `content.plan.name`).String()
height := gjson.Get(string(bz), `messages.0.content.plan.height`).Uint()
title := gjson.Get(string(bz), `messages.0.content.plan.name`).String()
return UpgradeProposal{
Deposit: uint(deposit),
Status: status,
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/steps_democracy.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func stepsDemocracy(consumerName string) []Step {
state: State{
chainID(consumerName): ChainState{
ValBalances: &map[validatorID]uint{
validatorID("alice"): 9899999999,
validatorID("alice"): 9889999998,
validatorID("bob"): 9960000001,
},
// Check that the parameter is changed on gov-consumer chain
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/steps_reward_denom.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func stepsRewardDenomConsumer(consumerName string) []Step {
state: State{
chainID(consumerName): ChainState{
ValBalances: &map[validatorID]uint{
validatorID("alice"): 9899999999,
validatorID("alice"): 9889999998,
validatorID("bob"): 9960000001,
},
// Check that the parameter is changed on gov-consumer chain
Params: &([]Param{{Subspace: "staking", Key: "MaxValidators", Value: "105"}}),
Params: &([]Param{{Subspace: "transfer", Key: "SendEnabled", Value: "true"}}),
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/steps_sovereign_changeover.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func stepRunSovereignChain() []Step {
func stepsUpgradeChain() []Step {
return []Step{
{
action: UpgradeProposalAction{
action: LegacyUpgradeProposalAction{
chainID: chainID("sover"),
upgradeTitle: "sovereign-changeover",
proposer: validatorID("alice"),
Expand Down
24 changes: 19 additions & 5 deletions tests/e2e/testnet-scripts/sovereign-genesis.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"genesis_time": "2023-06-19T21:06:09.696739416Z",
"genesis_time": "2023-06-22T15:55:00.982713586Z",
"chain_id": "sover",
"initial_height": "1",
"consensus_params": {
Expand Down Expand Up @@ -35,13 +35,16 @@
"accounts": [
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la",
"address": "cosmos19pe9pg5dv9k5fzgzmsrgnw9rl9asf7ddwhu7lm",
"pub_key": null,
"account_number": "0",
"sequence": "0"
}
]
},
"authz": {
"authorization": []
},
"bank": {
"params": {
"send_enabled": [],
Expand Down Expand Up @@ -99,6 +102,9 @@
"evidence": {
"evidence": []
},
"feegrant": {
"allowances": []
},
"genutil": {
"gen_txs": [
{
Expand Down Expand Up @@ -160,7 +166,7 @@
"tip": null
},
"signatures": [
"D06i2qqq2HathlT7cy+PDLTDuYKAmzw5Ne+Ehvzr9bVy3jpm2h8deDGeSXTSrhdP04UpFXerSn+zIPth5TKNrg=="
"c7aD9dWzb85fn+Aq0ijMdhyJNJSOsOcFLvJt8ctvdxAAbwdrzKPVFbq9IYf1qCwKmfmQUrlFy40qiuQeXaZ8pg=="
]
}
]
Expand Down Expand Up @@ -199,7 +205,8 @@
"params": {
"allowed_clients": [
"06-solomachine",
"07-tendermint"
"07-tendermint",
"09-localhost"
]
},
"create_localhost": false,
Expand Down Expand Up @@ -239,6 +246,12 @@
}
},
"params": null,
"provider": {
"params": {
"slash_meter_replenish_fraction": "1.0",
"slash_meter_replenish_period": "3s"
}
},
"slashing": {
"params": {
"signed_blocks_window": "10",
Expand Down Expand Up @@ -273,7 +286,8 @@
"params": {
"send_enabled": true,
"receive_enabled": true
}
},
"total_escrowed": []
},
"upgrade": {},
"vesting": {}
Expand Down
Loading