-
Notifications
You must be signed in to change notification settings - Fork 134
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!: Add a parameter that determines whether consumer chains allow inactive validators to validate them #2066
feat!: Add a parameter that determines whether consumer chains allow inactive validators to validate them #2066
Conversation
WalkthroughWalkthroughThis update introduces the Changes
Sequence Diagram(s)sequenceDiagram
participant Chain
participant Validator
participant Proposal
Chain->>Proposal: Submit consumer addition proposal
Proposal->>Validator: Check if inactive validators allowed
alt Inactive validators allowed
Validator->>Chain: Validate transaction
else Inactive validators not allowed
Validator->>Chain: Validation failed
end
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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: 4
Outside diff range, codebase verification and nitpick comments (10)
x/ccv/provider/keeper/legacy_proposal_test.go (1)
67-67
: Verify the function usage in the codebase.The code changes are approved. However, ensure that all function calls to
providertypes.NewConsumerAdditionProposal
match the new signature.
x/ccv/provider/proposal_handler_test.go
: The instances here do not show theallowInactiveValidators
parameter.x/ccv/provider/keeper/proposal_test.go
: Multiple instances here do not show theallowInactiveValidators
parameter.x/ccv/provider/keeper/legacy_proposal_test.go
: Instances here do not show theallowInactiveValidators
parameter.testutil/keeper/unit_test_helpers.go
: The instance here does not show theallowInactiveValidators
parameter.Please update these instances to match the new function signature.
Analysis chain
LGTM! But verify the function usage in the codebase.
The code changes are approved.
However, ensure that all function calls to
providertypes.NewConsumerAdditionProposal
match the new signature.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `providertypes.NewConsumerAdditionProposal` match the new signature. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type go -A 5 $'providertypes.NewConsumerAdditionProposal'Length of output: 5177
docs/docs/adrs/adr-017-allowing-inactive-validators.md (2)
65-65
: Remove trailing spaces.There are trailing spaces at the end of the line.
- * Introduce extra per-consumer-chain parameters: + * Introduce extra per-consumer-chain parameters:Tools
Markdownlint
65-65: Expected: 0 or 2; Actual: 1
Trailing spaces(MD009, no-trailing-spaces)
66-66
: Remove trailing spaces.There are trailing spaces at the end of the line.
- * `MinStake`: is the minimum amount of stake a validator must have to be considered for validation on the consumer chain. + * `MinStake`: is the minimum amount of stake a validator must have to be considered for validation on the consumer chain.Tools
Markdownlint
66-66: Expected: 0 or 2; Actual: 1
Trailing spaces(MD009, no-trailing-spaces)
x/ccv/provider/types/legacy_proposal.go (2)
63-63
: Update all function calls to include the new parameterallowInactiveVals
.The following instances of
NewConsumerAdditionProposal
do not include the new parameterallowInactiveVals
:
testutil/keeper/unit_test_helpers.go
x/ccv/provider/proposal_handler_test.go
x/ccv/provider/types/legacy_proposal_test.go
x/ccv/provider/keeper/legacy_proposal_test.go
x/ccv/provider/keeper/proposal_test.go
x/ccv/provider/client/legacy_proposal_handler.go
Please update these instances to include the new parameter.
Analysis chain
LGTM! Verify the new parameter usage.
The addition of the
allowInactiveVals
parameter looks correct.However, ensure that all calls to
NewConsumerAdditionProposal
are updated to include the new parameter.Also applies to: 87-87
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `NewConsumerAdditionProposal` include the new parameter. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type go -A 5 $'NewConsumerAdditionProposal'Length of output: 15462
254-254
: Some calls toNewConsumerModificationProposal
need to be updated to include the new parameterallowInactiveVals
.The following locations need attention:
x/ccv/provider/types/legacy_proposal_test.go
x/ccv/provider/keeper/legacy_proposal_test.go
Please update these calls to include the new parameter.
Analysis chain
LGTM! Verify the new parameter usage.
The addition of the
allowInactiveVals
parameter looks correct.However, ensure that all calls to
NewConsumerModificationProposal
are updated to include the new parameter.Also applies to: 267-267
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `NewConsumerModificationProposal` include the new parameter. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type go -A 5 $'NewConsumerModificationProposal'Length of output: 3750
x/ccv/provider/keeper/keeper_test.go (2)
811-812
: Add a description for the new test case.Consider adding a comment to describe the purpose of the new test case for
allow_inactive_vals
.// Test setting and getting the AllowInactiveValidators parameter
870-882
: Ensure consistent formatting and improve readability.The new test case is correctly implemented but could benefit from consistent formatting and improved readability.
{ name: "Allow Inactive Validators", settingFunc: func(ctx sdk.Context, id string, val int64) { k.SetAllowInactiveValidators(ctx, id, val == 1) }, getFunc: func(ctx sdk.Context, id string) (int64, bool) { val, found := k.GetAllowInactiveValidators(ctx, id) res := int64(0) // default value if val { res = 1 } return res, found }, initialValue: 1, updatedValue: 0, },x/ccv/provider/keeper/partial_set_security_test.go (2)
826-876
: Add a description for the new test case.Consider adding a comment to describe the purpose of the new test case for disallowing inactive validators.
// Test if inactive validators are disallowed and ensure the number of validators does not exceed MaxProviderConsensusValidators
859-874
: Add sanity check description.Consider adding a comment to describe the purpose of the sanity check.
// Sanity check: Ensure that we only get 0 next validators if either maxProviderConsensusVals is 0 or the maximal validator power is less than the min stake
tests/e2e/actions.go (1)
266-268
: Ensure new struct fields are documented.The new fields
MaxValidatorRank
,MinStake
, andAllowInactiveVals
enhance the struct's functionality. Ensure these fields are documented for clarity.
b5ced5f
to
4f42e54
Compare
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: 3
Outside diff range, codebase verification and nitpick comments (2)
x/ccv/provider/keeper/keeper.go (2)
1668-1685
: Consider adding validation forchainID
parameter.The
chainID
parameter is not validated. Consider adding validation to ensure it is not empty or invalid.if chainID == "" { return }
1701-1709
: Consider adding validation forchainID
parameter.The
chainID
parameter is not validated. Consider adding validation to ensure it is not empty or invalid.if chainID == "" { return }
* Start adding e2e test for governance * Debug gov with inactive vals test * Outline for test scenarios where they are tested * Add MaxRank steps * Add e2e tests for min stake and max rank * Revert formatting change * Refactor stepsOptIn * Use adjusted config for e2e tests * Write for more scenarios where they are tested * Add test for mint * Add docstrings for e2e steps
814c79a
into
ph/fix-min-power-calculation
* Add test for inactive vals with top N * Add test case to predefined tests * Fix bonded/active validator distinction * Fix relay test to set max provider consensus vals correctly * feat!: Add a parameter that determines whether consumer chains allow inactive validators to validate them (#2066) * Introduce new AllowInactiveValidators param for consumer chains * Add AllowInactiveValidators param to tests * Set MaxProviderConsensusValidators in tests * Add migration to initialize inactive vals * Add changelog entries for inactive vals param * Add property-based test for inactive vals * Add docs for inactive vals param * Set AllowInactiveVals parameter in e2e test * test: Add e2e tests for inactive vals (#2064) * Start adding e2e test for governance * Debug gov with inactive vals test * Outline for test scenarios where they are tested * Add MaxRank steps * Add e2e tests for min stake and max rank * Revert formatting change * Refactor stepsOptIn * Use adjusted config for e2e tests * Write for more scenarios where they are tested * Add test for mint * Add docstrings for e2e steps
* Add test for inactive vals with top N * Add test case to predefined tests * Fix bonded/active validator distinction * Fix relay test to set max provider consensus vals correctly * feat!: Add a parameter that determines whether consumer chains allow inactive validators to validate them (#2066) * Introduce new AllowInactiveValidators param for consumer chains * Add AllowInactiveValidators param to tests * Set MaxProviderConsensusValidators in tests * Add migration to initialize inactive vals * Add changelog entries for inactive vals param * Add property-based test for inactive vals * Add docs for inactive vals param * Set AllowInactiveVals parameter in e2e test * test: Add e2e tests for inactive vals (#2064) * Start adding e2e test for governance * Debug gov with inactive vals test * Outline for test scenarios where they are tested * Add MaxRank steps * Add e2e tests for min stake and max rank * Revert formatting change * Refactor stepsOptIn * Use adjusted config for e2e tests * Write for more scenarios where they are tested * Add test for mint * Add docstrings for e2e steps
…er chains (#2079) * refactor!: Refactor the validator set storage and add provider consensus validator storage (#1990) * Refactor validator set storage * Add comment for getTotalPower * Add provider consensus validator set storage * Add key to key test * Add unit test for LastTotalProviderConsensusPower * Address comments * feat!: Introduce the MaxProviderConsensusValidators param (#1992) * Refactor validator set storage * Add comment for getTotalPower * Add provider consensus validator set storage * Add new MaxProviderConsensusValidators param * Add validation for MaxProviderConsensusValidators * Add function to get MaxProviderConsensusValidators param * refactor!: Refactor the validator set storage and add provider consensus validator storage (#1990) * Refactor validator set storage * Add comment for getTotalPower * Add provider consensus validator set storage * Add key to key test * Add unit test for LastTotalProviderConsensusPower * Address comments * feat!: Wire the provider module to return ValidatorUpdates, instead of the staking module (#1993) * Refactor validator set storage * Add comment for getTotalPower * Add provider consensus validator set storage * Add new MaxProviderConsensusValidators param * Add validation for MaxProviderConsensusValidators * Add no_valupdates_staking module * Add function to get MaxProviderConsensusValidators param * Start returning validators in EndBlock * Fix tests * Revert cosmetic change * Revert cosmetic changes * Revert formatting * Add genutil replacer module * Revert formatting * Revert formatting in tests/integration * Revert minor formatting * Fix type * Change wrapped staking to conform to EndBlocker interface * Fix typo * Revert "Fix typo" This reverts commit 62dfd1e. * Add e2e test for inactive vals * Start fixing e2e test * Revert formatting changes * Remove more formatting * Revert extra formatting * Re-wire provider/app.go to use wrapped modules * Remove consumer rewards check * Add inactive provider vals testcase to nightly * Adjust comment * Address comments * Fix nightly test name * feat: Initialize the max validators parameter for existing consumers (#2012) * Add initialization for validator cap * Remove migration test * Fix inconsistent naming * test: enable the simulator for the provider module (#2005) * Refactor validator set storage * Add comment for getTotalPower * Add provider consensus validator set storage * Add new MaxProviderConsensusValidators param * Add validation for MaxProviderConsensusValidators * Add no_valupdates_staking module * Add function to get MaxProviderConsensusValidators param * Start returning validators in EndBlock * Fix tests * Revert cosmetic change * Revert cosmetic changes * Revert formatting * Add genutil replacer module * Revert formatting * Revert formatting in tests/integration * Revert minor formatting * Fix type * Change wrapped staking to conform to EndBlocker interface * Fix typo * Revert "Fix typo" This reverts commit 62dfd1e. * Add e2e test for inactive vals * Start fixing e2e test * Revert formatting changes * Remove more formatting * Revert extra formatting * Re-wire provider/app.go to use wrapped modules * Remove consumer rewards check * Add simulator test * Add randomly generated parameters for provider in sim * Add invariant * Add simulation to Makefile and github workflow * Use simcli instead of just passing true * feat!: Let consumer chains choose a minimum stake and validator rank (#2035) * Add minimum stake key * Add MinValidatorRank prefix * Add keeper and tests for new parameters * Utilize MinStake and MaxRank parameters in computing next validators * Mention MinStake and MaxRank in adr * Add test for FulfillsMinStake * Handle multiple validators with same power * Add min stake and max rank to docs * Add minStake and maxRank to proposals * Check for untyped equality * Handle minStake and maxRank in Msgs * Add integration test for min stake and max rank * Rename test and testfile * Update docs/docs/adrs/adr-017-allowing-inactive-validators.md * Add changelog entries for maxrank and minstake * Address comments * Clarify which feature is disabled by setting maxrank * Test validator powers cap and validator set cap into int param testing function * feat!: Rewire dependencies on the staking module (#2056) * Change wiring for mint and gov to use ProviderKeeper instead of StakingKeeper * Add test for IterateBondedValidatorsByPower * Rewire GovKeeper * Fix docstrings * Test other modified functions * Start writing some testing scenarios * Add TotalBondedTokens to expected staking keeper interface * feat: Calculate Top N based on active validators only (#2070) * Add test for inactive vals with top N * Add test case to predefined tests * Fix bonded/active validator distinction * Fix relay test to set max provider consensus vals correctly * feat!: Add a parameter that determines whether consumer chains allow inactive validators to validate them (#2066) * Introduce new AllowInactiveValidators param for consumer chains * Add AllowInactiveValidators param to tests * Set MaxProviderConsensusValidators in tests * Add migration to initialize inactive vals * Add changelog entries for inactive vals param * Add property-based test for inactive vals * Add docs for inactive vals param * Set AllowInactiveVals parameter in e2e test * test: Add e2e tests for inactive vals (#2064) * Start adding e2e test for governance * Debug gov with inactive vals test * Outline for test scenarios where they are tested * Add MaxRank steps * Add e2e tests for min stake and max rank * Revert formatting change * Refactor stepsOptIn * Use adjusted config for e2e tests * Write for more scenarios where they are tested * Add test for mint * Add docstrings for e2e steps * Delete hanging changelog entry * Address comments * Address more comments * Add migration for param * Fix allow inactive validators param test * Fix tests * Add LastProviderConsensusValidatorKey to fully defined keys * Fix key for validator set updates * Add info about genesis/endblock ordering * Add unit test for ProviderValidatorUpdates * Add example to proto definition of max_rank * Remove max rank * Remove references to max rank * Start adding an extension to the simulator * Make invariant fail early when param is 0 * Reorder InitGenesis to put Crisis last * Remove canary * Swap equals for not equals * Disable invariant check when max validators != max provider consensus validators * Make the simulator use a random seed * Remove TODO * Remove decoder * Run go mod tidy * Add migration in UPGRADING.md * Fix tests * Put random seed generation into golang code * Rename simulation jobs * Update UPGRADING.md Co-authored-by: Marius Poke <[email protected]> * Update UPGRADING.md Co-authored-by: Marius Poke <[email protected]> * Update x/ccv/provider/keeper/genesis.go Co-authored-by: Marius Poke <[email protected]> * Mention simulation tests in testing.md * Address some comments * Remake protos * Panic when LastActiveBondedValidators fails * Address some comments * Address comments * Reorder tests * Adjust stake_multiplier to stakeMultiplier * Address comments * Add error logging * Fix reference to bank blocked addrs in simulation * Change hasToValidate to only take into account active validators * Update docs/docs/adrs/adr-017-allowing-inactive-validators.md Co-authored-by: insumity <[email protected]> * Clarify: Slash happens on provider Co-authored-by: insumity <[email protected]> --------- Co-authored-by: Marius Poke <[email protected]> Co-authored-by: insumity <[email protected]>
Description
Closes: #1951
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
allow_inactive_vals
parameter for consumer chains, allowing greater flexibility in validator management.MaxValidatorRank
andMinStake
parameters.Documentation
Tests
allow_inactive_vals
functionality in consumer proposals.