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!: Wire the provider module to return ValidatorUpdates, instead of the staking module #1993

Merged
merged 33 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
39e5060
Refactor validator set storage
p-offtermatt Jun 25, 2024
7441fe0
Add comment for getTotalPower
p-offtermatt Jun 25, 2024
d9a51fb
Add provider consensus validator set storage
p-offtermatt Jun 25, 2024
96a47d7
Add new MaxProviderConsensusValidators param
p-offtermatt Jun 25, 2024
884a356
Add validation for MaxProviderConsensusValidators
p-offtermatt Jun 25, 2024
356e6e8
Add no_valupdates_staking module
p-offtermatt Jun 25, 2024
b0d3ce0
Add function to get MaxProviderConsensusValidators param
p-offtermatt Jun 26, 2024
5f53dc3
Start returning validators in EndBlock
p-offtermatt Jun 26, 2024
463e370
Fix tests
p-offtermatt Jun 26, 2024
23b4c46
Revert cosmetic change
p-offtermatt Jun 26, 2024
8b57495
Revert cosmetic changes
p-offtermatt Jun 26, 2024
b4ed21a
Revert formatting
p-offtermatt Jun 26, 2024
bc69f20
Add genutil replacer module
p-offtermatt Jun 26, 2024
ca84368
Revert formatting
p-offtermatt Jun 26, 2024
eb6f00f
Revert formatting in tests/integration
p-offtermatt Jun 26, 2024
8f8ff96
Revert minor formatting
p-offtermatt Jun 26, 2024
4e8b917
Fix type
p-offtermatt Jun 27, 2024
af1b7d4
Change wrapped staking to conform to EndBlocker interface
p-offtermatt Jun 27, 2024
62dfd1e
Fix typo
p-offtermatt Jun 27, 2024
49a6e04
Revert "Fix typo"
p-offtermatt Jun 27, 2024
cc1185d
Add e2e test for inactive vals
p-offtermatt Jun 27, 2024
732e35d
Start fixing e2e test
p-offtermatt Jun 27, 2024
c07a765
Revert formatting changes
p-offtermatt Jul 2, 2024
1cf874d
Remove more formatting
p-offtermatt Jul 2, 2024
9d0c9b7
Revert extra formatting
p-offtermatt Jul 2, 2024
4a5b80c
Re-wire provider/app.go to use wrapped modules
p-offtermatt Jul 2, 2024
96fbd4e
Remove consumer rewards check
p-offtermatt Jul 2, 2024
0f30ca1
Merge branch 'feat/inactive-vals-v50' into ph/inactive-vals-endblocker
p-offtermatt Jul 2, 2024
2ee5c6d
Add inactive provider vals testcase to nightly
p-offtermatt Jul 3, 2024
ed93ba0
Adjust comment
p-offtermatt Jul 3, 2024
5ff56e8
Address comments
p-offtermatt Jul 3, 2024
9c5028b
Fix nightly test name
p-offtermatt Jul 3, 2024
60e9e7f
feat: Initialize the max validators parameter for existing consumers …
p-offtermatt Jul 15, 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
17 changes: 17 additions & 0 deletions .github/workflows/nightly-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,23 @@ jobs:
- name: E2E active set changes
run: go run ./tests/e2e/... --tc active-set-changes

inactive-provider-validators-on-consumer-test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- uses: actions/checkout@v4
- name: Checkout LFS objects
run: git lfs checkout
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22" # The Go version to download (if necessary) and use.
- name: E2E inactive provider validators on consumer
run: go run ./tests/e2e/... --tc inactive-provider-validators-on-consumer

nightly-test-fail:
needs:
- happy-path-test
Expand Down
2 changes: 1 addition & 1 deletion app/consumer-democracy/proposals_whitelisting.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type legacyParamChangeKey struct {
// these parameters don't exist in the consumer app -- keeping them as an
var LegacyWhitelistedParams = map[legacyParamChangeKey]struct{}{
// add whitlisted legacy parameters here [cosmos-sdk <= 0.47]
// commented parameters are just an example - most params have been moved to their respecitve modules
// commented parameters are just an example - most params have been moved to their respective modules
// and they cannot be changed through legacy governance proposals
{Subspace: banktypes.ModuleName, Key: "SendEnabled"}: {},
}
Expand Down
28 changes: 14 additions & 14 deletions app/provider/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import (
"os"
"path/filepath"

dbm "github.com/cosmos/cosmos-db"
p-offtermatt marked this conversation as resolved.
Show resolved Hide resolved
"github.com/cosmos/gogoproto/proto"
"github.com/cosmos/ibc-go/modules/capability"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
Expand All @@ -26,7 +30,7 @@ import (
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"

"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/evidence"
evidencekeeper "cosmossdk.io/x/evidence/keeper"
Expand All @@ -35,6 +39,7 @@ import (
"cosmossdk.io/x/upgrade"
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
Expand All @@ -50,16 +55,19 @@ import (
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/testutil/testdata/testpb"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/types/msgservice"
sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/posthandler"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
Expand Down Expand Up @@ -93,29 +101,21 @@ import (
"github.com/cosmos/cosmos-sdk/x/slashing"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/ibc-go/modules/capability"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
tmos "github.com/cometbft/cometbft/libs/os"
dbm "github.com/cosmos/cosmos-db"

appencoding "github.com/cosmos/interchain-security/v5/app/encoding"
testutil "github.com/cosmos/interchain-security/v5/testutil/integration"
no_valupdates_genutil "github.com/cosmos/interchain-security/v5/x/ccv/no_valupdates_genutil"
no_valupdates_staking "github.com/cosmos/interchain-security/v5/x/ccv/no_valupdates_staking"
ibcprovider "github.com/cosmos/interchain-security/v5/x/ccv/provider"
ibcproviderclient "github.com/cosmos/interchain-security/v5/x/ccv/provider/client"
ibcproviderkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"

"github.com/cosmos/cosmos-sdk/testutil/testdata/testpb"
sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
)

const (
Expand Down Expand Up @@ -152,7 +152,7 @@ var (
mint.AppModuleBasic{},
slashing.AppModuleBasic{},
distr.AppModuleBasic{},
staking.AppModuleBasic{},
no_valupdates_staking.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},

Expand Down Expand Up @@ -536,7 +536,7 @@ func New(
// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
app.MM = module.NewManager(
genutil.NewAppModule(
no_valupdates_genutil.NewAppModule(
app.AccountKeeper,
app.StakingKeeper,
app,
Expand All @@ -552,7 +552,7 @@ func New(
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
no_valupdates_staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
upgrade.NewAppModule(&app.UpgradeKeeper, app.AccountKeeper.AddressCodec()),
evidence.NewAppModule(app.EvidenceKeeper),

Expand Down
1 change: 0 additions & 1 deletion app/sovereign/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
// withdraw all validator commission
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())

if err != nil {
panic(err)
}
Expand Down
3 changes: 3 additions & 0 deletions proto/interchain_security/ccv/provider/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ message GenesisState {

repeated interchain_security.ccv.provider.v1.ExportedVscSendTimestamp exported_vsc_send_timestamps = 13
[ (gogoproto.nullable) = false ];

repeated ConsensusValidator last_provider_consensus_validators = 14
[ (gogoproto.nullable) = false ];
}

// The provider CCV module's knowledge of consumer state.
Expand Down
13 changes: 8 additions & 5 deletions proto/interchain_security/ccv/provider/v1/provider.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
syntax = "proto3";

Check failure on line 1 in proto/interchain_security/ccv/provider/v1/provider.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present message "ConsumerValidator" was deleted from file.

package interchain_security.ccv.provider.v1;

Expand Down Expand Up @@ -363,15 +363,18 @@
AddressList consumer_addrs = 3;
}

// ConsumerValidator is used to facilitate epoch-based transitions. It contains relevant info for
// a validator that is expected to validate on a consumer chain during an epoch.
message ConsumerValidator {
// ConsensusValidator is used to express a validator that
// should be validating on a chain.
// It contains relevant info for
// a validator that is expected to validate on
// either the provider or a consumer chain.
message ConsensusValidator {
p-offtermatt marked this conversation as resolved.
Show resolved Hide resolved
// validator's consensus address on the provider chain
bytes provider_cons_addr = 1;
// voting power the validator has during this epoch
int64 power = 2;
// public key the validator uses on the consumer chain during this epoch
tendermint.crypto.PublicKey consumer_public_key = 3;
// public key the validator uses on the chain it is validating on
tendermint.crypto.PublicKey public_key = 3;
}
// ConsumerRewardsAllocation stores the rewards allocated by a consumer chain
// to the consumer rewards pool. It is used to allocate the tokens to the consumer
Expand Down
26 changes: 25 additions & 1 deletion tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const (
ConsumerMisbehaviourTestCfg TestConfigType = "consumer-misbehaviour"
CompatibilityTestCfg TestConfigType = "compatibility"
SmallMaxValidatorsTestCfg TestConfigType = "small-max-validators"
InactiveProviderValsTestCfg TestConfigType = "inactive-provider-vals"
)

type TestConfig struct {
Expand Down Expand Up @@ -180,6 +181,8 @@ func GetTestConfig(cfgType TestConfigType, providerVersion, consumerVersion stri
testCfg = CompatibilityTestConfig(pv, cv)
case SmallMaxValidatorsTestCfg:
testCfg = SmallMaxValidatorsTestConfig()
case InactiveProviderValsTestCfg:
testCfg = InactiveProviderValsTestConfig()
default:
panic(fmt.Sprintf("Invalid test config: %s", cfgType))
}
Expand Down Expand Up @@ -417,7 +420,7 @@ func CompatibilityTestConfig(providerVersion, consumerVersion string) TestConfig
".app_state.provider.params.slash_meter_replenish_fraction = \"1.0\" | " + // This disables slash packet throttling
".app_state.provider.params.slash_meter_replenish_period = \"3s\"",
}
} else if semver.Compare(providerVersion, "v5.0.0-alpha1") < 0 { //TODO: MOV THIS BACK TO "v5.0.0"
} else if semver.Compare(providerVersion, "v5.0.0-alpha1") < 0 { // TODO: MOV THIS BACK TO "v5.0.0"
fmt.Println("Using provider chain config for v4.1.x")
providerConfig = ChainConfig{
ChainId: ChainID("provi"),
Expand Down Expand Up @@ -557,6 +560,27 @@ func DemocracyTestConfig(allowReward bool) TestConfig {
return tr
}

func InactiveProviderValsTestConfig() TestConfig {
tr := DefaultTestConfig()
tr.name = "InactiveValsConfig"
// set the MaxProviderConsensusValidators param to 2
proviConfig := tr.chainConfigs[ChainID("provi")]
proviConfig.GenesisChanges += " | .app_state.provider.params.max_provider_consensus_validators = \"2\""

consuConfig := tr.chainConfigs[ChainID("consu")]
// set the soft_opt_out threshold to 0% to make sure all validators are slashed for downtime
consuConfig.GenesisChanges += " | .app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.0\""
tr.chainConfigs[ChainID("provi")] = proviConfig
tr.chainConfigs[ChainID("consu")] = consuConfig

// make is to that carol does not use a consumer key
carolConfig := tr.validatorConfigs[ValidatorID("carol")]
carolConfig.UseConsumerKey = false
tr.validatorConfigs[ValidatorID("carol")] = carolConfig

return tr
}

func SmallMaxValidatorsTestConfig() TestConfig {
cfg := DefaultTestConfig()

Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ var stepChoices = map[string]StepChoice{
description: "This is a regression test related to the issue discussed here: https://forum.cosmos.network/t/cosmos-hub-v17-1-chain-halt-post-mortem/13899. The test ensures that the protocol works as expected when MaxValidators is smaller than the number of potential validators.",
testConfig: SmallMaxValidatorsTestCfg,
},
"inactive-provider-validators-on-consumer": {
p-offtermatt marked this conversation as resolved.
Show resolved Hide resolved
name: "inactive-provider-validators-on-consumer",
steps: stepsInactiveProviderValidators(),
description: "test inactive validators on consumer",
testConfig: InactiveProviderValsTestCfg,
},
}

func getTestCaseUsageString() string {
Expand Down
12 changes: 8 additions & 4 deletions tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,19 @@ func (tr Commands) GetReward(chain ChainID, validator ValidatorID, blockHeight u

binaryName := tr.chainConfigs[chain].BinaryName
cmd := tr.target.ExecCommand(binaryName,
"query", "distribution", "delegation-total-rewards",
"--delegator-address", delAddresss,
"query", "distribution", "rewards",
delAddresss,
`--height`, fmt.Sprint(blockHeight),
`--node`, tr.GetQueryNode(chain),
`-o`, `json`,
)

bz, err := cmd.CombinedOutput()
if *verbose {
log.Println("getting rewards for chain: ", chain, " validator: ", validator, " blockHeight: ", blockHeight)
log.Println(cmd)
}

bz, err := cmd.CombinedOutput()
if err != nil {
log.Fatal("failed getting rewards: ", err, "\n", string(bz))
}
Expand All @@ -380,7 +384,7 @@ func (tr Commands) GetReward(chain ChainID, validator ValidatorID, blockHeight u

// interchain-securityd query gov proposals
func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal {
var noProposalRegex = regexp.MustCompile(`doesn't exist: key not found`)
noProposalRegex := regexp.MustCompile(`doesn't exist: key not found`)

binaryName := tr.chainConfigs[chain].BinaryName
bz, err := tr.target.ExecCommand(binaryName,
Expand Down
Loading
Loading