-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix(simulation): fix the problem of validator set is empty after InitGenesis
in simulation test
#18196
fix(simulation): fix the problem of validator set is empty after InitGenesis
in simulation test
#18196
Conversation
WalkthroughThis pull request (#18196) introduces a fix for the simulation test issue where the validator set is empty after InitGenesis. It includes changes to the Changes
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 0
Files selected for processing (2)
- CHANGELOG.md (1 hunks)
- testutil/sims/state_helpers.go (1 hunks)
Additional comments (Suppressed): 3
CHANGELOG.md (1)
- 73-76: The changes in the changelog accurately reflect the fixes made in the pull request. The links to the pull requests provide a good reference for further details.
testutil/sims/state_helpers.go (2)
208-216: The changes in these lines ensure that
initialStake
is always greater than or equal tosdk.DefaultPowerReduction
andnumInitiallyBonded
is always greater than or equal to 1. This is a good approach to prevent the simulation test from failing due to an empty validator set. The use ofsdk.DefaultPowerReduction.AddRaw(r.Int63n(1e12))
andint64(r.Intn(299) + 1)
ensures that the values are randomized while still meeting the minimum requirements.218-218: The check
if numInitiallyBonded > numAccs
is still necessary to ensure that the number of initially bonded validators does not exceed the total number of accounts. However, the change in the random number generation fornumInitiallyBonded
(fromr.Intn(300)
tor.Intn(299) + 1
) means that the maximum possible value fornumInitiallyBonded
is now 299 instead of 300. This change is likely to have a negligible impact on the overall behavior of the simulation, but it's worth noting.
@julienrbrt Could we get this fix in the next CosmosSDK 0.50.x version? |
@Mergifyio backport release/v0.50.x |
✅ Backports have been created
|
* build(deps): Bump github.com/cosmos/gogoproto from 1.4.12 to 1.5.0 (cosmos#20567) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * refactor(x/authz,x/feegrant): provide updated keeper in depinject (cosmos#20590) * docs: Update high level overview and introduction (backport cosmos#20535) (cosmos#20627) Co-authored-by: samricotta <37125168+samricotta@users.noreply.github.com> Co-authored-by: marbar3778 <marbar3778@yahoo.com> * fix: Properly parse json in the wait-tx command. (backport cosmos#20631) (cosmos#20660) Co-authored-by: Daniel Wedul <github@wedul.com> Co-authored-by: marbar3778 <marbar3778@yahoo.com> * docs: remove Ineffective code block (backport cosmos#20703) (cosmos#20711) * feat(client): Add flag & reading mnemonic from file (backport cosmos#20690) (cosmos#20712) Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Co-authored-by: marbar3778 <marbar3778@yahoo.com> * fix: nested multisig signatures using CLI (backport cosmos#20438) (cosmos#20692) Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Co-authored-by: marbar3778 <marbar3778@yahoo.com> Co-authored-by: Facundo <facundomedica@gmail.com> * feat(client/v2): get keyring from context (backport cosmos#19646) (cosmos#20727) Co-authored-by: Julien Robert <julien@rbrt.fr> * docs(x/group): orm codespace comment (backport cosmos#20749) (cosmos#20751) * feat: parse home flag earlier (backport cosmos#20771) (cosmos#20777) Co-authored-by: Julien Robert <julien@rbrt.fr> * build(deps): Bump github.com/cometbft/cometbft from 0.38.7 to 0.38.8 (cosmos#20805) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * build(deps): Bump github.com/cometbft/cometbft from 0.38.8 to 0.38.9 (cosmos#20836) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * fix(simulation): fix the problem of `validator set is empty after InitGenesis` in simulation test (backport cosmos#18196) (cosmos#20897) Co-authored-by: Chenqun Lu <luchenqun@qq.com> Co-authored-by: Julien Robert <julien@rbrt.fr> * fix(simulation): Fix all problems `make test-sim-custom-genesis-fast` for simulation test. (backport cosmos#17911) (cosmos#20909) Co-authored-by: Chenqun Lu <luchenqun@qq.com> Co-authored-by: Julien Robert <julien@rbrt.fr> * chore: prepare v0.50.8 (cosmos#20910) --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: samricotta <37125168+samricotta@users.noreply.github.com> Co-authored-by: marbar3778 <marbar3778@yahoo.com> Co-authored-by: Daniel Wedul <github@wedul.com> Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Co-authored-by: Facundo <facundomedica@gmail.com> Co-authored-by: Chenqun Lu <luchenqun@qq.com>
Description
When I execute
make test-sim-nondeterminism
for simulation testing, there is a certain probability that validator set is empty after InitGenesis, please ensure at least one validator is initialized with a delegation greater than or equal to the Problem with DefaultPowerReduction ({1374391948096}). The place forpanic
is:https://github.com/cosmos/cosmos-sdk/blob/2fbc547ce9/x/simulation/simulate.go#L50
The actual error occurs at:
https://github.com/cosmos/cosmos-sdk/blob/2fbc547/types/module/module.go#L517
After analysis, there are two reasons that trigger this error.
Reason 1: When
AppStateRandomizedFn
is a random parameter, wheninitialStake < DefaultPowerReduction
, theConsensusPower
of each validator is equal to 0, resulting in no validator.Reason 2: When
AppStateRandomizedFn
is a random parameter, whennumInitiallyBonded
is 0, there is no validator.So we must ensure that
initialStake >= DefaultPowerReduction
andnumInitiallyBonded >= 1
when usingAppStateRandomizedFn
random parametersCloses: #XXXX
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 API or client breaking changeCHANGELOG.md
make lint
andmake test
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...
!
in the type prefix if API or client breaking changeSummary by CodeRabbit
AppStateRandomizedFn
function to generate random values forinitialStake
andnumInitiallyBonded
parameters. This change introduces an element of randomness to our simulations, making them more robust and representative of real-world scenarios.