-
Notifications
You must be signed in to change notification settings - Fork 145
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: extend consumer chains query #2172
Conversation
* (partially) renamed chain ids to consumer ids * renamed proposal messages * removed global slash entry * fixed unit tests * added new messages * introduced new state * added functionality for the register and initialize messages * renamed (partially) chainIds to consumerIds * set consumerId to chainId association during registration * added extra check in the initialization so unknokwn, launched, or stopped chains cannot re-initialize * added initial work on traversing initialized chains that are to-be-launched * fixed rebase issues after bringing the VSCMaturedPackets work in * made it so we traverse initialization records instead of addition proposals (+ additional changes so the unit tests pass) * renamed more chainIDs to consumerIds * removed ClientIdToChainId state because chainId already resides on the registration record * nit fixes in go docs * removed MsgConsumerAddition * added CLI commands for new messages * removed consumer modification proposal * removed (partially) consumer removal proposal * rebased to pick up the inactive-validators work (PR #2079) * introduced consumerId in the equivocation messages (and a useful query for Hermes to get the consumerId) * added safeguard so that a validator cannot opt-in to two different chains with the same chain id * renamed some chainIDs to consumerIds * updated based on comments Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * fixed integration tests * rebased to pick up the removal of legacy proposals (#2130) and re-introduced old messages so that existing proposals can deserialize * changes messages to only have MsgCreateConsumer and MsgUpdateConsumer and modified protos so that we are backward-compatible * cleaned up slightly a few things (mostly committing & pushing) so people can pick up the latest changes * fixed the CreateConsumer and UpdateConsumer logic and made most of the fields optional * fixed hooks and the code around proposalId to consumerId * feat: extend consumer validator query to return commission rate (backport #2162) (#2165) * adapt #2162 changes for permissionless ICS * nits --------- Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * renamed some chainIds to consumerIds * took into account comments and also added safeguard to reject new proposals that still use deprecated messages (e.g., MsgConsumerAddition, etc.) * Update x/ccv/provider/types/msg.go Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * removed double-gas charge on MsgCreateConsumer and imroved the logic of MsgUpdateConsumer * added PopulateMinimumPowerInTopN tested * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * feat: add fields to consumer validators query (#2167) * extend consumer validators query * nit * nits * fix msg order * deprecate power for consumer_power * modified the way we verify the new owner address, as well as nit refactoring on the ConsumerIds * fixed some rebase issues and changed a proto to be backward-compatible --------- Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com>
Caution Review failedThe pull request is closed. WalkthroughWalkthroughThe changes involve enhancements to the querying mechanisms for consumer chains within the interchain security framework. New fields have been added to existing messages to facilitate parameterized queries based on the consumer chain phase. Additionally, methods for querying consumer chains have been refined, and new test cases have been implemented to validate the updated functionality. Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range, codebase verification and nitpick comments (1)
x/ccv/provider/keeper/permissionless.go (1)
567-597
: Consider renaming the function for clarity.The function name
GetInitializedConsumers
is somewhat misleading as it retrieves consumers ready to be launched. Consider renaming it toGetConsumersReadyToLaunch
.
x/ccv/provider/keeper/grpc_query.go
Outdated
chains := []*types.Chain{} | ||
for _, chainID := range k.GetAllRegisteredConsumerIds(ctx) { | ||
c, err := k.GetConsumerChain(ctx, chainID) | ||
lastCID, ok := k.GetConsumerId(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can call firstUnusedConsumerId
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need more pointers to firstUnusedConsumerId. Can't find it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meant that we can call lastCID
to firstUnusedConsumerId
.
x/ccv/provider/keeper/grpc_query.go
Outdated
|
||
consumerIDs := []string{} | ||
|
||
// return the consumer chains in the "Launched" phase by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't phase
be 0 by default? If so, why not simply make Registered
the default and get rid of the FilterByPhase
parameter?
x/ccv/provider/keeper/grpc_query.go
Outdated
|
||
switch { | ||
case phase == Launched: | ||
consumerIDs = append(consumerIDs, k.GetAllRegisteredConsumerIds(ctx)...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why append
here and below. Why not simply consumerIds = k.GetAllRegisteredConsumerIds...
x/ccv/provider/keeper/grpc_query.go
Outdated
for i := uint64(0); i <= lastCID; i++ { | ||
p, ok := k.GetConsumerPhase(ctx, strconv.FormatInt(int64(i), 10)) | ||
if !ok { | ||
// log something |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, just throw an error here altogether. Something would have been off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
x/ccv/provider/keeper/grpc_query.go
Outdated
if err != nil { | ||
// log something instead? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean up comment.
x/ccv/provider/keeper/grpc_query.go
Outdated
return types.Chain{}, fmt.Errorf("cannot get metadata for consumer (%s): %w", consumerId, err) | ||
} | ||
|
||
clientID, _ := k.GetConsumerClientId(ctx, consumerId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since those appear first in the types.Chain
, let's retrieve them in the same order (?)
@@ -322,22 +323,31 @@ func TestGetConsumerChain(t *testing.T) { | |||
{}, | |||
} | |||
|
|||
metadataLists := make([]types.ConsumerMetadata, len(chainIDs)) | |||
consumerIDs := make([]string, len(chainIDs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/consumerID/consumerId and s/chainID/chainId
metadataLists[i] = types.ConsumerMetadata{Name: chainID} | ||
pk.SetConsumerMetadata(ctx, consumerID, metadataLists[i]) | ||
|
||
phase := uint32(i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be mod (number of phases)
or something similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed since we have 5 phases for 4 chains iterated chains.
@@ -384,3 +402,105 @@ func TestQueryConsumerIdFromClientId(t *testing.T) { | |||
require.NoError(t, err) | |||
require.Equal(t, expectedConsumerId, res.ConsumerId) | |||
} | |||
|
|||
// TestGetConsumerChain tests GetConsumerChain behaviour correctness | |||
func TestGetConsumerChains(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we rename to TestQueryConsumerChains
and remove the comment because it seems redundant?
consumerIds := make([]string, consumerNum) | ||
consumers := make([]*types.Chain, consumerNum) | ||
|
||
// create four consumer chains all in the "Registered" phase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why four
when consumerNum == 5
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range, codebase verification and nitpick comments (1)
x/ccv/provider/keeper/permissionless.go (1)
579-581
: Improve error logging.The error logging can be improved to provide more context. Include the spawn time and the key in the log message.
Apply this diff to improve error logging:
- k.Logger(ctx).Error("failed to parse spawn time", - "error", err) + k.Logger(ctx).Error("failed to parse spawn time", + "key", iterator.Key(), + "error", err)
// TODO: @sainoe merge with func above | ||
func (k Keeper) GetInitializedConsumers(ctx sdk.Context) []string { | ||
store := ctx.KVStore(k.storeKey) | ||
|
||
spawnTimeToConsumerIdsKeyPrefix := types.SpawnTimeToConsumerIdsKeyPrefix() | ||
iterator := storetypes.KVStorePrefixIterator(store, []byte{spawnTimeToConsumerIdsKeyPrefix}) | ||
defer iterator.Close() | ||
|
||
result := []string{} | ||
for ; iterator.Valid(); iterator.Next() { | ||
spawnTime, err := types.ParseTime(types.SpawnTimeToConsumerIdsKeyPrefix(), iterator.Key()) | ||
if err != nil { | ||
k.Logger(ctx).Error("failed to parse spawn time", | ||
"error", err) | ||
continue | ||
} | ||
|
||
// if current block time is equal to or after spawnTime, and the chain is initialized, we can launch the chain | ||
consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime) | ||
if err != nil { | ||
k.Logger(ctx).Error("failed to retrieve consumers to launch", | ||
"spawn time", spawnTime, | ||
"error", err) | ||
continue | ||
} | ||
|
||
result = append(result, consumerIds.Ids...) | ||
} | ||
|
||
return result | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge with GetInitializedConsumersReadyToLaunch
.
The function is similar to GetInitializedConsumersReadyToLaunch
. Consider merging them to avoid code duplication.
Apply this diff to merge the functions:
-func (k Keeper) GetInitializedConsumers(ctx sdk.Context) []string {
- store := ctx.KVStore(k.storeKey)
-
- spawnTimeToConsumerIdsKeyPrefix := types.SpawnTimeToConsumerIdsKeyPrefix()
- iterator := storetypes.KVStorePrefixIterator(store, []byte{spawnTimeToConsumerIdsKeyPrefix})
- defer iterator.Close()
-
- result := []string{}
- for ; iterator.Valid(); iterator.Next() {
- spawnTime, err := types.ParseTime(types.SpawnTimeToConsumerIdsKeyPrefix(), iterator.Key())
- if err != nil {
- k.Logger(ctx).Error("failed to parse spawn time",
- "error", err)
- continue
- }
-
- // if current block time is equal to or after spawnTime, and the chain is initialized, we can launch the chain
- consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime)
- if err != nil {
- k.Logger(ctx).Error("failed to retrieve consumers to launch",
- "spawn time", spawnTime,
- "error", err)
- continue
- }
-
- result = append(result, consumerIds.Ids...)
- }
-
- return result
-}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// TODO: @sainoe merge with func above | |
func (k Keeper) GetInitializedConsumers(ctx sdk.Context) []string { | |
store := ctx.KVStore(k.storeKey) | |
spawnTimeToConsumerIdsKeyPrefix := types.SpawnTimeToConsumerIdsKeyPrefix() | |
iterator := storetypes.KVStorePrefixIterator(store, []byte{spawnTimeToConsumerIdsKeyPrefix}) | |
defer iterator.Close() | |
result := []string{} | |
for ; iterator.Valid(); iterator.Next() { | |
spawnTime, err := types.ParseTime(types.SpawnTimeToConsumerIdsKeyPrefix(), iterator.Key()) | |
if err != nil { | |
k.Logger(ctx).Error("failed to parse spawn time", | |
"error", err) | |
continue | |
} | |
// if current block time is equal to or after spawnTime, and the chain is initialized, we can launch the chain | |
consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime) | |
if err != nil { | |
k.Logger(ctx).Error("failed to retrieve consumers to launch", | |
"spawn time", spawnTime, | |
"error", err) | |
continue | |
} | |
result = append(result, consumerIds.Ids...) | |
} | |
return result | |
} |
consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime) | ||
if err != nil { | ||
k.Logger(ctx).Error("failed to retrieve consumers to launch", | ||
"spawn time", spawnTime, | ||
"error", err) | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optimize function by reducing calls to GetConsumersToBeLaunched
.
The function can be optimized by reducing the number of calls to GetConsumersToBeLaunched
. Store the result of GetConsumersToBeLaunched
in a variable and reuse it.
Apply this diff to optimize the function:
- consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime)
- if err != nil {
- k.Logger(ctx).Error("failed to retrieve consumers to launch",
- "spawn time", spawnTime,
- "error", err)
- continue
- }
-
- result = append(result, consumerIds.Ids...)
+ if consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime); err != nil {
+ k.Logger(ctx).Error("failed to retrieve consumers to launch",
+ "spawn time", spawnTime,
+ "error", err)
+ } else {
+ result = append(result, consumerIds.Ids...)
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime) | |
if err != nil { | |
k.Logger(ctx).Error("failed to retrieve consumers to launch", | |
"spawn time", spawnTime, | |
"error", err) | |
continue | |
} | |
if consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime); err != nil { | |
k.Logger(ctx).Error("failed to retrieve consumers to launch", | |
"spawn time", spawnTime, | |
"error", err) | |
} else { | |
result = append(result, consumerIds.Ids...) | |
} |
x/ccv/provider/keeper/grpc_query.go
Outdated
case phase == Launched: | ||
consumerIDs = append(consumerIDs, k.GetAllRegisteredConsumerIds(ctx)...) | ||
case phase == Initialized: | ||
consumerIDs = append(consumerIDs, k.GetInitializedConsumers(ctx)...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this new method if we traverse through all consumer ids below in any case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to follow. We iterate all cosnumer ids only if the phase is neither equal to Initialized or Launched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some remaining comments but otherwise LGTM
x/ccv/provider/keeper/grpc_query.go
Outdated
} | ||
|
||
consumerIds := []string{} | ||
phase := ConsumerPhase(byte(req.Phase)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Phase should be optional.
Desired behavior:
User sends a request with phase
- respond with chains in that particulat phase
user sends a request without phase:
- respond with all chains (up to the page limit, if applicable)
e86bddc
to
8fdfad9
Compare
x/ccv/provider/keeper/relay.go
Outdated
@@ -211,27 +211,27 @@ | |||
minPower, err := k.ComputeMinPowerInTopN(ctx, activeValidators, topN) | |||
if err != nil { | |||
// we panic, since the only way to proceed would be to opt in all validators, which is not the intended behavior | |||
panic(fmt.Errorf("failed to compute min power to opt in for chain %v: %w", chainID, err)) | |||
panic(fmt.Errorf("failed to compute min power to opt in for chain %v: %w", consumerId, err)) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
x/ccv/provider/client/cli/query.go (1)
Line range hint
79-105
: Fix integer conversion issues.The function correctly replaces
ChainId
withConsumerId
and enhances argument handling. However, the integer conversion fromstrconv.Atoi
touint32
should include an upper bound check to prevent potential issues.Apply this diff to fix the integer conversion issues:
- limit, err := strconv.Atoi(args[1]) - if err != nil { - return err - } - req.Limit = uint32(limit) + limit, err := strconv.Atoi(args[1]) + if err != nil || limit < 0 || limit > math.MaxUint32 { + return fmt.Errorf("invalid limit: %v", err) + } + req.Limit = uint32(limit)The code changes are approved with the suggested fixes.
Tools
GitHub Check: CodeQL
[failure] 97-97: Incorrect conversion between integer types
Incorrect conversion of an integer with architecture-dependent bit size from strconv.Atoi to a lower bit size type uint32 without an upper bound check.
[failure] 105-105: Incorrect conversion between integer types
Incorrect conversion of an integer with architecture-dependent bit size from strconv.Atoi to a lower bit size type uint32 without an upper bound check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the change request.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
if args[0] != "" { | ||
phase, err := strconv.ParseInt(args[0], 10, 32) | ||
if err != nil { | ||
return err | ||
} | ||
req.Phase = types.ConsumerPhase(phase) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix potential index out of range error.
Accessing args[0]
without checking its presence can lead to an index out of range error. Add a check to ensure the argument is present before accessing it.
- if args[0] != "" {
+ if len(args) > 0 && args[0] != "" {
Apply this diff to fix the issue.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if args[0] != "" { | |
phase, err := strconv.ParseInt(args[0], 10, 32) | |
if err != nil { | |
return err | |
} | |
req.Phase = types.ConsumerPhase(phase) | |
} | |
if len(args) > 0 && args[0] != "" { | |
phase, err := strconv.ParseInt(args[0], 10, 32) | |
if err != nil { | |
return err | |
} | |
req.Phase = types.ConsumerPhase(phase) | |
} |
if args[1] != "" { | ||
limit, err := strconv.ParseInt(args[1], 10, 32) | ||
if err != nil { | ||
return err | ||
} | ||
req.Limit = int32(limit) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix potential index out of range error.
Accessing args[1]
without checking its presence can lead to an index out of range error. Add a check to ensure the argument is present before accessing it.
- if args[1] != "" {
+ if len(args) > 1 && args[1] != "" {
Apply this diff to fix the issue.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if args[1] != "" { | |
limit, err := strconv.ParseInt(args[1], 10, 32) | |
if err != nil { | |
return err | |
} | |
req.Limit = int32(limit) | |
} | |
if len(args) > 1 && args[1] != "" { | |
limit, err := strconv.ParseInt(args[1], 10, 32) | |
if err != nil { | |
return err | |
} | |
req.Limit = int32(limit) | |
} |
@@ -233,11 +240,14 @@ message Chain { | |||
repeated string allowlist = 7; | |||
// Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. | |||
repeated string denylist = 8; | |||
// The phase the consumer chain (Registered=0|Initialized=1|FailedToLaunch=2|Launched=3|Stopped=4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// The phase the consumer chain (Registered=0|Initialized=1|FailedToLaunch=2|Launched=3|Stopped=4) | |
// The phase the consumer chain (Registered=1|Initialized=2|Launched=3|Stopped=4) |
* feat: first iteration on Permissionless ICS (#2117) * (partially) renamed chain ids to consumer ids * renamed proposal messages * removed global slash entry * fixed unit tests * added new messages * introduced new state * added functionality for the register and initialize messages * renamed (partially) chainIds to consumerIds * set consumerId to chainId association during registration * added extra check in the initialization so unknokwn, launched, or stopped chains cannot re-initialize * added initial work on traversing initialized chains that are to-be-launched * fixed rebase issues after bringing the VSCMaturedPackets work in * made it so we traverse initialization records instead of addition proposals (+ additional changes so the unit tests pass) * renamed more chainIDs to consumerIds * removed ClientIdToChainId state because chainId already resides on the registration record * nit fixes in go docs * removed MsgConsumerAddition * added CLI commands for new messages * removed consumer modification proposal * removed (partially) consumer removal proposal * rebased to pick up the inactive-validators work (PR #2079) * introduced consumerId in the equivocation messages (and a useful query for Hermes to get the consumerId) * added safeguard so that a validator cannot opt-in to two different chains with the same chain id * renamed some chainIDs to consumerIds * updated based on comments Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * fixed integration tests * rebased to pick up the removal of legacy proposals (#2130) and re-introduced old messages so that existing proposals can deserialize * changes messages to only have MsgCreateConsumer and MsgUpdateConsumer and modified protos so that we are backward-compatible * cleaned up slightly a few things (mostly committing & pushing) so people can pick up the latest changes * fixed the CreateConsumer and UpdateConsumer logic and made most of the fields optional * fixed hooks and the code around proposalId to consumerId * feat: extend consumer validator query to return commission rate (backport #2162) (#2165) * adapt #2162 changes for permissionless ICS * nits --------- Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * renamed some chainIds to consumerIds * took into account comments and also added safeguard to reject new proposals that still use deprecated messages (e.g., MsgConsumerAddition, etc.) * Update x/ccv/provider/types/msg.go Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * removed double-gas charge on MsgCreateConsumer and imroved the logic of MsgUpdateConsumer * added PopulateMinimumPowerInTopN tested * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * feat: add fields to consumer validators query (#2167) * extend consumer validators query * nit * nits * fix msg order * deprecate power for consumer_power * modified the way we verify the new owner address, as well as nit refactoring on the ConsumerIds * fixed some rebase issues and changed a proto to be backward-compatible --------- Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * fixed bug on removing previous spawn time & added tests * added some additional tests * added tests on the hooks * removed check that spawn time is in the future * feat: refactor consumer validator set computation (#2175) * add UT * nits * address comments * Update x/ccv/provider/keeper/partial_set_security.go Co-authored-by: insumity <karolos@informal.systems> * fix tests --------- Co-authored-by: insumity <karolos@informal.systems> * fix!: ConsumerModificationProposal is needed in Gaia upgrade handler (#2176) ConsumerModificationProposal is needed in Gaia upgrade handler * fix: allow the owner of a chain to remove the chain (#2178) fixed access in RemoveConsumer * refactor: add proto enum for ConsumerPhase (#2182) * feat: extend `consumer_validators` query to return consumer valset before launch (#2164) * (partially) renamed chain ids to consumer ids * renamed proposal messages * removed global slash entry * fixed unit tests * added new messages * introduced new state * added functionality for the register and initialize messages * renamed (partially) chainIds to consumerIds * set consumerId to chainId association during registration * added extra check in the initialization so unknokwn, launched, or stopped chains cannot re-initialize * added initial work on traversing initialized chains that are to-be-launched * fixed rebase issues after bringing the VSCMaturedPackets work in * made it so we traverse initialization records instead of addition proposals (+ additional changes so the unit tests pass) * renamed more chainIDs to consumerIds * removed ClientIdToChainId state because chainId already resides on the registration record * nit fixes in go docs * removed MsgConsumerAddition * added CLI commands for new messages * removed consumer modification proposal * removed (partially) consumer removal proposal * rebased to pick up the inactive-validators work (PR #2079) * introduced consumerId in the equivocation messages (and a useful query for Hermes to get the consumerId) * added safeguard so that a validator cannot opt-in to two different chains with the same chain id * renamed some chainIDs to consumerIds * updated based on comments Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * fixed integration tests * rebased to pick up the removal of legacy proposals (#2130) and re-introduced old messages so that existing proposals can deserialize * changes messages to only have MsgCreateConsumer and MsgUpdateConsumer and modified protos so that we are backward-compatible * cleaned up slightly a few things (mostly committing & pushing) so people can pick up the latest changes * fixed the CreateConsumer and UpdateConsumer logic and made most of the fields optional * fixed hooks and the code around proposalId to consumerId * pre-spawn query * rebase * nits * feat: extend consumer validator query to return commission rate (backport #2162) (#2165) * adapt #2162 changes for permissionless ICS * nits --------- Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * remove panics * renamed some chainIds to consumerIds * took into account comments and also added safeguard to reject new proposals that still use deprecated messages (e.g., MsgConsumerAddition, etc.) * Update x/ccv/provider/types/msg.go Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * removed double-gas charge on MsgCreateConsumer and imroved the logic of MsgUpdateConsumer * added PopulateMinimumPowerInTopN tested * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * update logic * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * feat: add fields to consumer validators query (#2167) * extend consumer validators query * nit * nits * fix msg order * deprecate power for consumer_power * nits * feat: first iteration on Permissionless ICS (#2117) * (partially) renamed chain ids to consumer ids * renamed proposal messages * removed global slash entry * fixed unit tests * added new messages * introduced new state * added functionality for the register and initialize messages * renamed (partially) chainIds to consumerIds * set consumerId to chainId association during registration * added extra check in the initialization so unknokwn, launched, or stopped chains cannot re-initialize * added initial work on traversing initialized chains that are to-be-launched * fixed rebase issues after bringing the VSCMaturedPackets work in * made it so we traverse initialization records instead of addition proposals (+ additional changes so the unit tests pass) * renamed more chainIDs to consumerIds * removed ClientIdToChainId state because chainId already resides on the registration record * nit fixes in go docs * removed MsgConsumerAddition * added CLI commands for new messages * removed consumer modification proposal * removed (partially) consumer removal proposal * rebased to pick up the inactive-validators work (PR #2079) * introduced consumerId in the equivocation messages (and a useful query for Hermes to get the consumerId) * added safeguard so that a validator cannot opt-in to two different chains with the same chain id * renamed some chainIDs to consumerIds * updated based on comments Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * fixed integration tests * rebased to pick up the removal of legacy proposals (#2130) and re-introduced old messages so that existing proposals can deserialize * changes messages to only have MsgCreateConsumer and MsgUpdateConsumer and modified protos so that we are backward-compatible * cleaned up slightly a few things (mostly committing & pushing) so people can pick up the latest changes * fixed the CreateConsumer and UpdateConsumer logic and made most of the fields optional * fixed hooks and the code around proposalId to consumerId * feat: extend consumer validator query to return commission rate (backport #2162) (#2165) * adapt #2162 changes for permissionless ICS * nits --------- Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * renamed some chainIds to consumerIds * took into account comments and also added safeguard to reject new proposals that still use deprecated messages (e.g., MsgConsumerAddition, etc.) * Update x/ccv/provider/types/msg.go Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * removed double-gas charge on MsgCreateConsumer and imroved the logic of MsgUpdateConsumer * added PopulateMinimumPowerInTopN tested * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * feat: add fields to consumer validators query (#2167) * extend consumer validators query * nit * nits * fix msg order * deprecate power for consumer_power * modified the way we verify the new owner address, as well as nit refactoring on the ConsumerIds * fixed some rebase issues and changed a proto to be backward-compatible --------- Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * cover stopped phase case * fixed bug on removing previous spawn time & added tests * added some additional tests * added tests on the hooks * removed check that spawn time is in the future * feat: refactor consumer validator set computation (#2175) * add UT * nits * address comments * Update x/ccv/provider/keeper/partial_set_security.go Co-authored-by: insumity <karolos@informal.systems> * fix tests --------- Co-authored-by: insumity <karolos@informal.systems> * nit * nits * nit --------- Co-authored-by: insumity <karolos@informal.systems> Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * fix build * tests: fix integration test setup (#2183) * fix integration test setup * fix integration tests * feat: add consumer chain query (#2179) * feat: first iteration on Permissionless ICS (#2117) * (partially) renamed chain ids to consumer ids * renamed proposal messages * removed global slash entry * fixed unit tests * added new messages * introduced new state * added functionality for the register and initialize messages * renamed (partially) chainIds to consumerIds * set consumerId to chainId association during registration * added extra check in the initialization so unknokwn, launched, or stopped chains cannot re-initialize * added initial work on traversing initialized chains that are to-be-launched * fixed rebase issues after bringing the VSCMaturedPackets work in * made it so we traverse initialization records instead of addition proposals (+ additional changes so the unit tests pass) * renamed more chainIDs to consumerIds * removed ClientIdToChainId state because chainId already resides on the registration record * nit fixes in go docs * removed MsgConsumerAddition * added CLI commands for new messages * removed consumer modification proposal * removed (partially) consumer removal proposal * rebased to pick up the inactive-validators work (PR #2079) * introduced consumerId in the equivocation messages (and a useful query for Hermes to get the consumerId) * added safeguard so that a validator cannot opt-in to two different chains with the same chain id * renamed some chainIDs to consumerIds * updated based on comments Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * fixed integration tests * rebased to pick up the removal of legacy proposals (#2130) and re-introduced old messages so that existing proposals can deserialize * changes messages to only have MsgCreateConsumer and MsgUpdateConsumer and modified protos so that we are backward-compatible * cleaned up slightly a few things (mostly committing & pushing) so people can pick up the latest changes * fixed the CreateConsumer and UpdateConsumer logic and made most of the fields optional * fixed hooks and the code around proposalId to consumerId * feat: extend consumer validator query to return commission rate (backport #2162) (#2165) * adapt #2162 changes for permissionless ICS * nits --------- Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * renamed some chainIds to consumerIds * took into account comments and also added safeguard to reject new proposals that still use deprecated messages (e.g., MsgConsumerAddition, etc.) * Update x/ccv/provider/types/msg.go Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * removed double-gas charge on MsgCreateConsumer and imroved the logic of MsgUpdateConsumer * added PopulateMinimumPowerInTopN tested * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * feat: add fields to consumer validators query (#2167) * extend consumer validators query * nit * nits * fix msg order * deprecate power for consumer_power * modified the way we verify the new owner address, as well as nit refactoring on the ConsumerIds * fixed some rebase issues and changed a proto to be backward-compatible --------- Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * fixed bug on removing previous spawn time & added tests * added some additional tests * added tests on the hooks * removed check that spawn time is in the future * feat: refactor consumer validator set computation (#2175) * add UT * nits * address comments * Update x/ccv/provider/keeper/partial_set_security.go Co-authored-by: insumity <karolos@informal.systems> * fix tests --------- Co-authored-by: insumity <karolos@informal.systems> * add UT * nits * nits * revert legacy prop funcs * fix UT --------- Co-authored-by: insumity <karolos@informal.systems> Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * feat: extend consumer chains query (#2172) * feat: first iteration on Permissionless ICS (#2117) * (partially) renamed chain ids to consumer ids * renamed proposal messages * removed global slash entry * fixed unit tests * added new messages * introduced new state * added functionality for the register and initialize messages * renamed (partially) chainIds to consumerIds * set consumerId to chainId association during registration * added extra check in the initialization so unknokwn, launched, or stopped chains cannot re-initialize * added initial work on traversing initialized chains that are to-be-launched * fixed rebase issues after bringing the VSCMaturedPackets work in * made it so we traverse initialization records instead of addition proposals (+ additional changes so the unit tests pass) * renamed more chainIDs to consumerIds * removed ClientIdToChainId state because chainId already resides on the registration record * nit fixes in go docs * removed MsgConsumerAddition * added CLI commands for new messages * removed consumer modification proposal * removed (partially) consumer removal proposal * rebased to pick up the inactive-validators work (PR #2079) * introduced consumerId in the equivocation messages (and a useful query for Hermes to get the consumerId) * added safeguard so that a validator cannot opt-in to two different chains with the same chain id * renamed some chainIDs to consumerIds * updated based on comments Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * fixed integration tests * rebased to pick up the removal of legacy proposals (#2130) and re-introduced old messages so that existing proposals can deserialize * changes messages to only have MsgCreateConsumer and MsgUpdateConsumer and modified protos so that we are backward-compatible * cleaned up slightly a few things (mostly committing & pushing) so people can pick up the latest changes * fixed the CreateConsumer and UpdateConsumer logic and made most of the fields optional * fixed hooks and the code around proposalId to consumerId * feat: extend consumer validator query to return commission rate (backport #2162) (#2165) * adapt #2162 changes for permissionless ICS * nits --------- Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * renamed some chainIds to consumerIds * took into account comments and also added safeguard to reject new proposals that still use deprecated messages (e.g., MsgConsumerAddition, etc.) * Update x/ccv/provider/types/msg.go Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * removed double-gas charge on MsgCreateConsumer and imroved the logic of MsgUpdateConsumer * added PopulateMinimumPowerInTopN tested * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * feat: add fields to consumer validators query (#2167) * extend consumer validators query * nit * nits * fix msg order * deprecate power for consumer_power * modified the way we verify the new owner address, as well as nit refactoring on the ConsumerIds * fixed some rebase issues and changed a proto to be backward-compatible --------- Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * add phase + metadata * first logic draft * add filter * reformat test * nits * nit * address comments * update tests * nits * update logic * update CLI * revert unwanted changes * remove filter field * nit * fix bad int conversion * update cli --------- Co-authored-by: insumity <karolos@informal.systems> Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * feat!: migrations for permissionless (#2174) * migrations for permissionless -- wip * feat!: migrations for permissionless (#2177) * initial commit * took into account comments * removed deprecated queries * fix error due to rebase * remove fields from provider genesis * remove commented code --------- Co-authored-by: insumity <karolos@informal.systems> * feat: update `consumer_chains` REST endpoint (#2188) update consumer chains REST endpoint * fix: permissionless added event + cli changes (#2185) * add consumer registration event * fix some queries, CLI and permissionless logic * cli changes * addressed review comments * fix!: several permissionless changes (#2189) * minor fixes in tests * replace IsConsumerProposedOrRegistered with IsConsumerActive * remove param from createStakingValidator * handle error in GetTopN * remove aux methods for getting PowerShapingParameters * remove default PowerShapingParameters * fix tests * handle error messages * fix: fix consumer chain query CLI (#2190) * fix consumer chains query cli * add consumer-chain cli command * fix consumer chains cli bug * fix!: fix store.set nil values (#2193) fix store.set nil values * fix!: msgs validation (#2195) * add testing for ValidateStringField * ValidateInitializationParameters * ValidatePowerShapingParameters * validate NewOwnerAddress * apply review suggestions * fix: fix queries' API REST endpoint path (#2196) * clean uw files * doc * Revert "doc" This reverts commit efc2718. * Revert "clean uw files" This reverts commit 5773cf3. * remove deprecated REST endpoints * update REST endpoint * fix broken UT by previous PR (#2195) * fix: permissionless query (#2191) * fix implementation * addressed comments * cleanup * keep metadata and powershaping data for stopped consumer chains * addressed comments * adapt unit-tests * refactor: mostly refactors (#2194) * handle errors * set the reverse index in SetConsumerClientId * rename method * create consumer_lifecycle.go with launch/stop logic * move methods around * move methods around * handle ChangeRewardDenoms * add TODOs * remove proposal_test * remove todos * apply review suggestions * apply review suggestions * fix UTs * fix!: provider msg validation (#2197) * validate MsgAssignConsumerKey * validate MsgSubmitConsumerMisbehaviour and MsgSubmitConsumerDoubleVoting * move RemoveConsumer * refactor: rearrange messages in msg.go * validate MsgOptIn and MsgOptOut * validate MsgSetConsumerCommissionRate * remove ValidateBasic for deprecated msgs * remove deprecated GetSigners * remove deprecated GetSignBytes * remove deprecated govv1beta1 validation * remove Route and Type * Update x/ccv/provider/keeper/msg_server.go Co-authored-by: insumity <karolos@informal.systems> * apply review suggestions * apply review suggestions --------- Co-authored-by: insumity <karolos@informal.systems> * test: fix e2e tests + PSS e2e tests use permissionless (#2192) Fix e2e tests + make PSS e2e tests use Permissionless ICS * refactor: power shaping (#2207) * update allowlist and denylist power shaping update * fix tests * refactor: move power shaping params to power_shaping.go * rename record to parameters * fix merge conflicts * feat: fix queries (#2209) * remove chain ID from all-pairs-valconsensus-address * add consumer_id to Chain * add GetAllLaunchedConsumerIds * fix UT * apply review suggestions * fix!: remove `stopTime` from `MsgRemoveConsumer` (#2208) * init commit * renamed stop time to removal time * fix errors in tests * add GetAllConsumerWithIBCClients * use GetAllConsumerWithIBCClients for efficiency * fix UTs * remove GetAllLaunchedConsumerIds as not needed * typo in GetAllConsumersWithIBCClients * improve comment * Apply suggestions from code review Co-authored-by: Marius Poke <marius.poke@posteo.de> * took into account comments --------- Co-authored-by: mpoke <marius.poke@posteo.de> * feat: remove provider migration for CV 3 to 6 (#2211) * remove migrations to CV < 7 * add changelog entry * fix version name * fix!: fix migration issue (#2214) * init commit * took into account comments * fix!: register `ConsumerModificationProposal` and others (#2215) init commit * fix: fix misbehaviour and equivocation evidence CLI commands (#2213) * silent errors in MBT driver * fix misbehaviour and double-signing CLI cmds + few nits * revert changes * nit: remove type prefix from consumer phase enum (#2220) remove type prefix in consumer phase enum * refactor: stop using signer field in messages (#2219) * remove error check * stop using signer field in messages * expand TODO comment * replace signer with submitter * fix UTs * chore: update TX CLI help (#2222) * update CLI help * apply review suggestions * feat!: add events for provider messages (#2221) * add events for CreateConsumer * add events for UpdateConsumer * add events for RemoveConsumer * add events for the rest of the messages * apply review suggestions * Id instead of ID * fix events * fix UT * remove duplicate AttributeSubmitterAddress * fix: fix queries' API endpoints (#2226) * endpoint fixes * Update proto/interchain_security/ccv/provider/v1/query.proto Co-authored-by: MSalopek <matija.salopek994@gmail.com> * Update proto/interchain_security/ccv/provider/v1/query.proto Co-authored-by: MSalopek <matija.salopek994@gmail.com> * generate proto --------- Co-authored-by: MSalopek <matija.salopek994@gmail.com> * fix!: replace CanLaunch with InitializeConsumer (#2224) replace CanLaunch with InitializeConsumer * fix: improve commands' description (#2227) init commit --------- Co-authored-by: insumity <karolos@informal.systems> Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> Co-authored-by: MSalopek <matija.salopek994@gmail.com>
Description
partially closes: #2160
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if the change is state-machine breakingCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
the type prefix if the change is state-machine breakingSummary by CodeRabbit
New Features
Bug Fixes
Tests