Skip to content

Commit

Permalink
Revert "feat!: add memo to IBC transfers of ICS rewards (#2290)"
Browse files Browse the repository at this point in the history
This reverts commit 9a1b02f.
  • Loading branch information
sainoe committed Sep 27, 2024
1 parent 9a1b02f commit f875cf4
Show file tree
Hide file tree
Showing 34 changed files with 32 additions and 5,998 deletions.

This file was deleted.

This file was deleted.

178 changes: 0 additions & 178 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,183 +1,5 @@
# Upgrading Replicated Security

<<<<<<< HEAD
=======
## Unreleased

### Consumer

Upgrading a consumer from v4.4.x to v4.5.x and from v5.x or v6.1.x to v6.2.x requires state migrations. The following migrators should be added to the upgrade handler of the consumer chain:


```go
// InitializeConsumerId sets the consumer Id parameter in the consumer module,
// to the consumer id for which the consumer is registered on the provider chain.
// The consumer id can be obtained in by querying the provider, e.g. by using the
// QueryConsumerIdFromClientId query.
func InitializeConsumerId(ctx sdk.Context, consumerKeeper consumerkeeper.Keeper) error {
params, err := consumerKeeper.GetParams(ctx)
if err != nil {
return err
}
params.ConsumerId = ConsumerId
return consumerKeeper.SetParams(ctx, params)
}
```

### Provider

Upgrading a provider from v5.1.x requires state migrations. The following migrators should be added to the upgrade handler of the provider chain:

```go
// InitializeMaxProviderConsensusParam initializes the MaxProviderConsensusValidators parameter.
// It is set to 180, which is the current number of validators participating in consensus on the Cosmos Hub.
// This parameter will be used to govern the number of validators participating in consensus on the Cosmos Hub,
// and takes over this role from the MaxValidators parameter in the staking module.
func InitializeMaxProviderConsensusParam(ctx sdk.Context, providerKeeper providerkeeper.Keeper) {
params := providerKeeper.GetParams(ctx)
params.MaxProviderConsensusValidators = NewMaxProviderConsensusValidators
providerKeeper.SetParams(ctx, params)
}
```

```go
// SetMaxValidators sets the MaxValidators parameter in the staking module to 200,
// which is the current number of 180 plus 20.
// This is done in concert with the introduction of the inactive-validators feature
// in Interchain Security, after which the number of validators
// participating in consensus on the Cosmos Hub will be governed by the
// MaxProviderConsensusValidators parameter in the provider module.
func SetMaxValidators(ctx sdk.Context, stakingKeeper stakingkeeper.Keeper) error {
params, err := stakingKeeper.GetParams(ctx)
if err != nil {
return err
}
params.MaxValidators = NewMaxValidators
return stakingKeeper.SetParams(ctx, params)
}
```

```go
// InitializeLastProviderConsensusValidatorSet initializes the last provider consensus validator set
// by setting it to the first 180 validators from the current validator set of the staking module.
func InitializeLastProviderConsensusValidatorSet(ctx sdk.Context, providerKeeper providerkeeper.Keeper, stakingKeeper stakingkeeper.Keeper) error {
vals, err := stakingKeeper.GetBondedValidatorsByPower(ctx)
if err != nil {
return err
}
// cut the validator set to the first 180 validators
if len(vals) > NewMaxProviderConsensusValidators {
vals = vals[:NewMaxProviderConsensusValidators]
}
// create consensus validators for the staking validators
lastValidators := []providertypes.ConsensusValidator{}
for _, val := range vals {
consensusVal, err := providerKeeper.CreateProviderConsensusValidator(ctx, val)
if err != nil {
return err
}

lastValidators = append(lastValidators, consensusVal)
}
return providerKeeper.SetLastProviderConsensusValSet(ctx, lastValidators)
}
```

```go
// SetICSConsumerMetadata sets the metadata for launched consumer chains
func SetICSConsumerMetadata(ctx sdk.Context, providerKeeper providerkeeper.Keeper) error {
for _, consumerID := range providerKeeper.GetAllActiveConsumerIds(ctx) {
phase := providerKeeper.GetConsumerPhase(ctx, consumerID)
if phase != providertypes.CONSUMER_PHASE_LAUNCHED {
continue
}
chainID, err := providerKeeper.GetConsumerChainId(ctx, consumerID)
if err != nil {
ctx.Logger().Error(
fmt.Sprintf("cannot get chain ID for consumer chain, consumerID(%s)", consumerID),
)
continue
}

// example of setting the metadata for Stride
if chainID == "stride-1" {
metadata := providertypes.ConsumerMetadata{
Name: "Stride",
Description: "Description",
Metadata: "Metadata",
}
err = providerKeeper.SetConsumerMetadata(ctx, consumerID, metadata)
if err != nil {
ctx.Logger().Error(
fmt.Sprintf("cannot set consumer metadata, consumerID(%s), chainID(%s): %s", consumerID, chainID, err.Error()),
)
continue
}
}
}
}
```

```go
// MigrateICSProposals migrates deprecated proposals
func MigrateICSProposals(ctx sdk.Context, msgServer providertypes.MsgServer, providerKeeper providerkeeper.Keeper, govKeeper govkeeper.Keeper) error {
proposals := []govtypesv1.Proposal{}
err := govKeeper.Proposals.Walk(ctx, nil, func(key uint64, proposal govtypesv1.Proposal) (stop bool, err error) {
proposals = append(proposals, proposal)
return false, nil // go through the entire collection
})
if err != nil {
return errorsmod.Wrapf(err, "iterating through proposals")
}
for _, proposal := range proposals {
err := MigrateICSLegacyProposal(ctx, msgServer, providerKeeper, govKeeper, proposal)
if err != nil {
return errorsmod.Wrapf(err, "migrating legacy proposal %d", proposal.Id)
}

err = MigrateICSProposal(ctx, msgServer, providerKeeper, govKeeper, proposal)
if err != nil {
return errorsmod.Wrapf(err, "migrating proposal %d", proposal.Id)
}
}
return nil
}

// MigrateICSLegacyProposal migrates the following proposals
// - ConsumerAdditionProposal
// - ConsumerRemovalProposal
// - ConsumerModificationProposal
// - ChangeRewardDenomsProposal

// MigrateICSProposal migrates the following proposals
// - MsgConsumerAddition
// - MsgConsumerRemoval
// - MsgConsumerModification
```

For an example, see the [Gaia v20 upgrade handler](https://github.com/cosmos/gaia/blob/e4656093955578b2efa6e8c2ea8dd8823008bba3/app/upgrades/v20/upgrades.go#L43).

### Consumer

Upgrading the consumer from `v5.0.0` or `v5.2.0` will not require state migration.

## [v5.1.x](https://github.com/cosmos/interchain-security/releases/tag/v5.1.0)

### Provider

***Note that providers using v5.0.0 cannot upgrade to v5.1.0 cleanly***

Providers using versions `v4.0.x`, `v4.1.x`, `v4.2.x`, `v4.3.x` and `v4.4.x` can upgrade to `v5.1.0`.

Upgrading from `v4.x` to `v5.1.0` will upgrade the provider `consensus version` to 7.

Upgrade code will be executed automatically during the upgrade procedure.

### Consumer

Upgrading the consumer from `v5.0.0` to `v5.1.0` will not require state migration.

>>>>>>> 0d782959 (feat!: add memo to IBC transfers of ICS rewards (#2290))
This guide provides instructions for upgrading to specific versions of Replicated Security.

## [v4.4.x](https://github.com/cosmos/interchain-security/releases/tag/v4.4.0)
Expand Down
4 changes: 0 additions & 4 deletions proto/interchain_security/ccv/v1/shared_consumer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ message ConsumerParams {
// The period after which a consumer can retry sending a throttled packet.
google.protobuf.Duration retry_delay_period = 13
[ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ];

// The consumer ID of this consumer chain. Used by the consumer module to send
// ICS rewards.
string consumer_id = 14;
}

// ConsumerGenesisState defines shared genesis information between provider and
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/action_rapid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func CreateSubmitChangeRewardDenomsProposalActionGen() *rapid.Generator[SubmitCh
return SubmitChangeRewardDenomsProposalAction{
From: GetValidatorIDGen().Draw(t, "From"),
Deposit: rapid.Uint().Draw(t, "Deposit"),
Denoms: rapid.SliceOf(rapid.String()).Draw(t, "Denoms"),
Denom: rapid.String().Draw(t, "Denom"),
}
})
}
Expand Down
Loading

0 comments on commit f875cf4

Please sign in to comment.