-
Notifications
You must be signed in to change notification settings - Fork 122
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!: allow consumer chains to change their PSS parameters #1932
Changes from 5 commits
9f36adc
30c015b
464ae0a
04011e4
831e1e1
e0775d9
1c62d65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -517,6 +517,55 @@ func TestHandleConsumerRemovalProposal(t *testing.T) { | |
} | ||
} | ||
|
||
func TestHandleConsumerModificationProposal(t *testing.T) { | ||
providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) | ||
defer ctrl.Finish() | ||
|
||
chainID := "chainID" | ||
|
||
// set up a consumer client, so it seems that "chainID" is running | ||
providerKeeper.SetConsumerClientId(ctx, "chainID", "clientID") | ||
|
||
// set PSS-related fields to update them later on | ||
providerKeeper.SetTopN(ctx, chainID, 50) | ||
providerKeeper.SetValidatorSetCap(ctx, chainID, 10) | ||
providerKeeper.SetValidatorsPowerCap(ctx, chainID, 34) | ||
providerKeeper.SetAllowlist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("allowlistedAddr1"))) | ||
providerKeeper.SetAllowlist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("allowlistedAddr2"))) | ||
providerKeeper.SetDenylist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("denylistedAddr1"))) | ||
|
||
expectedTopN := uint32(75) | ||
expectedValidatorsPowerCap := uint32(67) | ||
expectedValidatorSetCap := uint32(20) | ||
expectedAllowlistedValidator := "cosmosvalcons1wpex7anfv3jhystyv3eq20r35a" | ||
expectedDenylistedValidator := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" | ||
proposal := providertypes.NewConsumerModificationProposal("title", "description", chainID, | ||
expectedTopN, | ||
expectedValidatorsPowerCap, | ||
expectedValidatorSetCap, | ||
[]string{expectedAllowlistedValidator}, | ||
[]string{expectedDenylistedValidator}, | ||
).(*providertypes.ConsumerModificationProposal) | ||
|
||
err := providerKeeper.HandleConsumerModificationProposal(ctx, proposal) | ||
require.NoError(t, err) | ||
|
||
actualTopN, _ := providerKeeper.GetTopN(ctx, chainID) | ||
require.Equal(t, expectedTopN, actualTopN) | ||
actualValidatorsPowerCap, _ := providerKeeper.GetValidatorsPowerCap(ctx, chainID) | ||
require.Equal(t, expectedValidatorsPowerCap, actualValidatorsPowerCap) | ||
actualValidatorSetCap, _ := providerKeeper.GetValidatorSetCap(ctx, chainID) | ||
require.Equal(t, expectedValidatorSetCap, actualValidatorSetCap) | ||
|
||
allowlistedValidator, err := sdk.ConsAddressFromBech32(expectedAllowlistedValidator) | ||
require.Equal(t, 1, len(providerKeeper.GetAllowList(ctx, chainID))) | ||
require.Equal(t, providertypes.NewProviderConsAddress(allowlistedValidator), providerKeeper.GetAllowList(ctx, chainID)[0]) | ||
|
||
denylistedValidator, err := sdk.ConsAddressFromBech32(expectedDenylistedValidator) | ||
require.Equal(t, 1, len(providerKeeper.GetDenyList(ctx, chainID))) | ||
require.Equal(t, providertypes.NewProviderConsAddress(denylistedValidator), providerKeeper.GetDenyList(ctx, chainID)[0]) | ||
} | ||
Comment on lines
+520
to
+567
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider enhancing the test coverage for Currently, the test primarily checks the happy path. It would be beneficial to include tests for error scenarios and edge cases, such as invalid inputs or when the chain ID does not exist. This will ensure the robustness of the implementation under various conditions. |
||
|
||
// Tests the StopConsumerChain method against the spec, | ||
// with more granularity than what's covered in TestHandleConsumerRemovalProposal, or integration tests. | ||
// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-stcc1 | ||
|
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.
Ensure error handling when setting
Allowlist
andDenylist
inHandleConsumerModificationProposal
. Currently, errors during address conversion are silently ignored.