Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
insumity committed Jun 13, 2024
1 parent 42a60bf commit ff06a9b
Show file tree
Hide file tree
Showing 31 changed files with 192 additions and 860 deletions.
1 change: 0 additions & 1 deletion app/consumer-democracy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ func New(
// CanWithdrawInvariant invariant.
// NOTE: staking module is required if HistoricalEntries param > 0
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
// NOTE: the soft opt-out requires that the consumer module's beginblocker comes after the slashing module's beginblocker
app.MM.SetOrderBeginBlockers(
// upgrades should be run first
upgradetypes.ModuleName,
Expand Down
1 change: 0 additions & 1 deletion app/consumer/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ func New(
// NOTE: Capability module must occur first so that it can initialize any capabilities
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
// NOTE: the soft opt-out requires that the consumer module's beginblocker comes after the slashing module's beginblocker
app.MM.SetOrderInitGenesis(
capabilitytypes.ModuleName,
authtypes.ModuleName,
Expand Down
3 changes: 3 additions & 0 deletions app/consumer/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func transformToNew(jsonRaw []byte, ctx client.Context) (json.RawMessage, error)
oldConsumerGenesis.Params.RetryDelayPeriod = types.DefaultRetryDelayPeriod
}

// `SoftOptThreshold` is deprecated in the current consumer implementation, so set to empty
oldConsumerGenesis.Params.SoftOptOutThreshold = ""

// Versions before v3.3.x of provider genesis data fills up deprecated fields
// ProviderClientState, ConsensusState and InitialValSet in type GenesisState
newGenesis := types.ConsumerGenesisState{
Expand Down
9 changes: 7 additions & 2 deletions app/consumer/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,9 @@ func TestConsumerGenesisTransformationFromV2ToCurrent(t *testing.T) {
require.EqualValues(t, srcGenesis.Params.ConsumerRedistributionFraction, resultGenesis.Params.ConsumerRedistributionFraction)
require.EqualValues(t, srcGenesis.Params.HistoricalEntries, resultGenesis.Params.HistoricalEntries)
require.EqualValues(t, srcGenesis.Params.UnbondingPeriod, resultGenesis.Params.UnbondingPeriod)
require.EqualValues(t, srcGenesis.Params.SoftOptOutThreshold, resultGenesis.Params.SoftOptOutThreshold)

// `SoftOptOutThreshold` is deprecated, so it should not be set in the current version
require.EqualValues(t, "", resultGenesis.Params.SoftOptOutThreshold)
require.EqualValues(t, srcGenesis.Params.RewardDenoms, resultGenesis.Params.RewardDenoms)
require.EqualValues(t, srcGenesis.Params.ProviderRewardDenoms, resultGenesis.Params.ProviderRewardDenoms)

Expand Down Expand Up @@ -565,7 +567,10 @@ func TestConsumerGenesisTransformationV330ToCurrent(t *testing.T) {
require.Equal(t, srcGenesis.Params.ConsumerRedistributionFraction, resultGenesis.Params.ConsumerRedistributionFraction)
require.Equal(t, srcGenesis.Params.HistoricalEntries, resultGenesis.Params.HistoricalEntries)
require.Equal(t, srcGenesis.Params.UnbondingPeriod, resultGenesis.Params.UnbondingPeriod)
require.Equal(t, srcGenesis.Params.SoftOptOutThreshold, resultGenesis.Params.SoftOptOutThreshold)

// `SoftOptOutThreshold` is deprecated, so it should not be set in the current version
require.Equal(t, "", resultGenesis.Params.SoftOptOutThreshold)

require.Equal(t, srcGenesis.Params.RewardDenoms, resultGenesis.Params.RewardDenoms)
require.Equal(t, srcGenesis.Params.ProviderRewardDenoms, resultGenesis.Params.ProviderRewardDenoms)

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/adrs/adr-009-soft-opt-out.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ title: Soft Opt-Out

## Status

Accepted
Deprecated

## Context

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/adrs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ To suggest an ADR, please make use of the [ADR template](./adr-template.md) prov
- [ADR 004: Denom DOS fixes](./adr-004-denom-dos-fixes.md)
- [ADR 005: Cryptographic verification of equivocation evidence](./adr-005-cryptographic-equivocation-verification.md)
- [ADR 008: Throttle with retries](./adr-008-throttle-retries.md)
- [ADR 009: Soft Opt-Out](./adr-009-soft-opt-out.md)
- [ADR 010: Standalone to Consumer Changeover](./adr-010-standalone-changeover.md)
- [ADR 013: Slashing on the provider for consumer equivocation](./adr-013-equivocation-slashing.md)
- [ADR 014: Epochs](./adr-014-epochs.md)
Expand All @@ -57,3 +56,4 @@ To suggest an ADR, please make use of the [ADR template](./adr-template.md) prov
### Deprecated

- [ADR 003: Equivocation governance proposal](./adr-003-equivocation-gov-proposal.md)
- [ADR 009: Soft Opt-Out](./adr-009-soft-opt-out.md)
7 changes: 0 additions & 7 deletions docs/docs/features/proposals.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ Minimal example:
}
```

:::warning
Before the introduction of Partial Set Security, consumer chains typically included a "soft opt-out mechanism"
which allows the bottom N% of the provider's validators to not validate the consumer chain, without being jailed for downtime on the provider.
After the introduction of Partial Set Security, the use of the soft opt-out mechanism is discouraged, and consumer chains are
encouraged to use the topN parameter to not force validators with little stake to validate the chain.
:::

## ChangeRewardDenomProposal

Proposal type used to mutate the set of denoms accepted by the provider as rewards.
Expand Down
7 changes: 2 additions & 5 deletions proto/interchain_security/ccv/v1/shared_consumer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ message ConsumerParams {
google.protobuf.Duration unbonding_period = 9
[ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ];

// The threshold for the percentage of validators at the bottom of the set who
// can opt out of running the consumer chain without being punished. For
// example, a value of 0.05 means that the validators in the bottom 5% of the
// set can opt out
string soft_opt_out_threshold = 10;
// !!! DEPRECATED !!! soft_opt_out_threshold is deprecated.
string soft_opt_out_threshold = 10 [deprecated = true];

// Reward denoms. These are the denominations which are allowed to be sent to
// the provider as rewards.
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@ func (tr TestConfig) invokeDoublesignSlash(
if err != nil {
log.Fatal(err, "\n", string(bz))
}
tr.waitBlocks("provi", 10, 2*time.Minute)
tr.waitBlocks("provi", 20, 4*time.Minute)
} else { // tr.useCometMock
validatorPrivateKeyAddress := tr.GetValidatorPrivateKeyAddress(action.Chain, action.Validator)

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/state_rapid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func GetRegisteredConsumerRewardDenomsGen() *rapid.Generator[[]string] {
})
}

func GetConsumerChainQueueSizesGen() *rapid.Generator[uint] {
func bGetConsumerChainQueueSizesGen() *rapid.Generator[uint] {
return rapid.Custom(func(t *rapid.T) uint {
return rapid.Uint().Draw(t, "ConsumerChainQueueSizes")
})
Expand Down
72 changes: 10 additions & 62 deletions tests/e2e/step_delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,58 +220,6 @@ func stepsCancelUnbond(consumerName string) []Step {
}
}

// stepsRedelegateForOptOut tests redelegation, and sets up voting powers s.t
// alice will have less than 5% of the total voting power. This is needed to
// test opt-out functionality.
func stepsRedelegateForOptOut(consumerName string) []Step {
return []Step{
{
Action: RedelegateTokensAction{
Chain: ChainID("provi"),
Src: ValidatorID("alice"),
Dst: ValidatorID("carol"),
TxSender: ValidatorID("alice"),
Amount: 450000000,
},
State: State{
ChainID("provi"): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 60,
ValidatorID("bob"): 500,
ValidatorID("carol"): 950,
},
},
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
// Voting power changes not seen by consumer yet
ValidatorID("alice"): 510,
ValidatorID("bob"): 500,
ValidatorID("carol"): 500,
},
},
},
},
{
Action: RelayPacketsAction{
ChainA: ChainID("provi"),
ChainB: ChainID(consumerName),
Port: "provider",
Channel: 0,
},
State: State{
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
// Now power changes are seen by consumer
ValidatorID("alice"): 60,
ValidatorID("bob"): 500,
ValidatorID("carol"): 950,
},
},
},
},
}
}

// stepsRedelegate tests redelegation and resulting validator power changes.
func stepsRedelegate(consumerName string) []Step {
return []Step{
Expand All @@ -283,23 +231,23 @@ func stepsRedelegate(consumerName string) []Step {
TxSender: ValidatorID("carol"),
// redelegate s.t. alice has majority stake so non-faulty validators maintain more than
// 2/3 voting power during downtime tests below, avoiding chain halt
Amount: 449000000,
Amount: 400000000,
},
State: State{
ChainID("provi"): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 509,
ValidatorID("alice"): 910,
ValidatorID("bob"): 500,
// carol always uses a consumer assigned key
ValidatorID("carol"): 501,
ValidatorID("carol"): 100,
},
},
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
// Voting power changes not seen by consumer yet
ValidatorID("alice"): 60,
ValidatorID("alice"): 510,
ValidatorID("bob"): 500,
ValidatorID("carol"): 950,
ValidatorID("carol"): 500,
},
},
},
Expand All @@ -315,9 +263,9 @@ func stepsRedelegate(consumerName string) []Step {
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
// Now power changes are seen by consumer
ValidatorID("alice"): 509,
ValidatorID("alice"): 910,
ValidatorID("bob"): 500,
ValidatorID("carol"): 501,
ValidatorID("carol"): 100,
},
},
},
Expand All @@ -336,15 +284,15 @@ func stepsRedelegateShort(consumerName string) []Step {
TxSender: ValidatorID("alice"),
// Leave alice with majority stake so non-faulty validators maintain more than
// 2/3 voting power during downtime tests below, avoiding chain halt
Amount: 1000000,
Amount: 400000000,
},
State: State{
ChainID("provi"): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 509,
ValidatorID("alice"): 110,
ValidatorID("bob"): 500,
// carol always uses a consumer assigned key
ValidatorID("carol"): 501,
ValidatorID("carol"): 900,
},
},
ChainID(consumerName): ChainState{
Expand Down
14 changes: 6 additions & 8 deletions tests/e2e/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var compatibilitySteps = concatSteps(
compstepsStartChains([]string{"consu"}, false),
stepsDelegate("consu"),
stepsUnbond("consu"),
stepsRedelegateShort("consu"),
stepsRedelegate("consu"),
stepsDowntime("consu"),
stepsDoubleSignOnProvider("consu"), // carol double signs on provider
stepsStartRelayer(),
Expand All @@ -32,8 +32,6 @@ var happyPathSteps = concatSteps(
stepsAssignConsumerKeyOnStartedChain("consu", "bob"),
stepsUnbond("consu"),
stepsCancelUnbond("consu"),
stepsRedelegateForOptOut("consu"),
stepsDowntimeWithOptOut("consu"),
stepsRedelegate("consu"),
stepsDowntime("consu"),
stepsDoubleSignOnProvider("consu"), // carol double signs on provider
Expand All @@ -46,7 +44,7 @@ var shortHappyPathSteps = concatSteps(
stepsStartChains([]string{"consu"}, false),
stepsDelegate("consu"),
stepsUnbond("consu"),
stepsRedelegateShort("consu"),
stepsRedelegate("consu"),
stepsDowntime("consu"),
stepsDoubleSignOnProvider("consu"), // carol double signs on provider
stepsStartRelayer(),
Expand All @@ -58,12 +56,12 @@ var lightClientAttackSteps = concatSteps(
stepsStartChains([]string{"consu"}, false),
stepsDelegate("consu"),
stepsUnbond("consu"),
stepsRedelegateShort("consu"),
stepsRedelegate("consu"),
stepsDowntime("consu"),
stepsLightClientAttackOnProviderAndConsumer("consu"), // carol double signs on provider, bob double signs on consumer
stepsStartRelayer(),
stepsConsumerRemovalPropNotPassing("consu", 3), // submit removal prop but vote no on it - chain should stay
stepsStopChain("consu", 4), // stop chain
stepsConsumerRemovalPropNotPassing("consu", 2), // submit removal prop but vote no on it - chain should stay
stepsStopChain("consu", 3), // stop chain
)

var slashThrottleSteps = concatSteps(
Expand Down Expand Up @@ -137,6 +135,6 @@ var consumerDoubleDowntimeSteps = concatSteps(
stepsStartChains([]string{"consu"}, false),
stepsDelegate("consu"),
stepsUnbond("consu"),
stepsRedelegateShort("consu"),
stepsRedelegate("consu"),
stepsDoubleDowntime("consu"),
)
17 changes: 12 additions & 5 deletions tests/e2e/steps_consumer_misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func stepsStartChainsWithSoftOptOut(consumerName string) []Step {
ConsumerChain: ChainID(consumerName),
SpawnTime: 0,
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1},
TopN: 100,
TopN: 0,
},
State: State{
ChainID("provi"): ChainState{
Expand Down Expand Up @@ -79,6 +79,13 @@ func stepsStartChainsWithSoftOptOut(consumerName string) []Step {
},
},
},
{
Action: OptInAction{
Chain: ChainID(consumerName),
Validator: ValidatorID("alice"),
},
State: State{},
},
{
Action: VoteGovProposalAction{
Chain: ChainID("provi"),
Expand Down Expand Up @@ -173,7 +180,7 @@ func stepsStartChainsWithSoftOptOut(consumerName string) []Step {
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 500,
ValidatorID("bob"): 20,
ValidatorID("bob"): 0,
},
},
},
Expand All @@ -189,7 +196,7 @@ func stepsStartChainsWithSoftOptOut(consumerName string) []Step {
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
ValidatorID("bob"): 20,
ValidatorID("bob"): 0,
},
},
},
Expand Down Expand Up @@ -239,7 +246,7 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step {
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
ValidatorID("bob"): 20,
ValidatorID("bob"): 0,
},
},
},
Expand Down Expand Up @@ -279,7 +286,7 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step {
// since its light client is frozen on the provider
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
ValidatorID("bob"): 20,
ValidatorID("bob"): 0,
},
},
},
Expand Down
12 changes: 6 additions & 6 deletions tests/e2e/steps_double_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ func stepsDoubleSignOnProvider(consumerName string) []Step {
// slash on provider
ChainID("provi"): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 509,
ValidatorID("alice"): 910,
ValidatorID("bob"): 500,
ValidatorID("carol"): 0, // from 500 to 0
ValidatorID("carol"): 0, // from 99 to 0
},
},
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 509,
ValidatorID("alice"): 910,
ValidatorID("bob"): 500,
ValidatorID("carol"): 495, // not tombstoned on consumerName yet
ValidatorID("carol"): 99, // not tombstoned on consumerName yet
},
},
},
Expand All @@ -38,14 +38,14 @@ func stepsDoubleSignOnProvider(consumerName string) []Step {
State: State{
ChainID("provi"): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 509,
ValidatorID("alice"): 910,
ValidatorID("bob"): 500,
ValidatorID("carol"): 0,
},
},
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 509,
ValidatorID("alice"): 910,
ValidatorID("bob"): 500,
ValidatorID("carol"): 0, // tombstoning visible on consumerName
},
Expand Down
Loading

0 comments on commit ff06a9b

Please sign in to comment.