Skip to content
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

epoching/checkpointing: fuzz test for validators with zero voting power #276

Merged
merged 5 commits into from
Jan 16, 2023

Conversation

SebastianElvis
Copy link
Member

Fixes #275

This PR provides a fuzz test ensuring validators with zero voting power are unbonded and are not included in the validator set. In the reported issue, the validator has only 100000 tokens, while 1 voting power takes at least sdk.DefaultPowerReduction (1000000) tokens. Thus the behaviour is in fact expected.

During debugging, I also fixed some TODOs on moving stuff from epoching to checkpointing.

Copy link
Contributor

@gitferry gitferry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@@ -19,6 +20,82 @@ import (
"github.com/tendermint/tendermint/crypto/ed25519"
)

// FuzzWrappedCreateValidator_InsufficientTokens tests adding new validators with zero voting power
// It ensures that validators with zero voting power (i.e., with tokens fewer than sdk.DefaultPowerReduction)
// are unbonded, thus are not included in the validator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// are unbonded, thus are not included in the validator
// are unbonded, thus are not included in the validator set

require.Equal(t, uint64(1), epoch.EpochNumber)

n := rand.Intn(3) + 1
addrs := app.AddTestAddrs(helper.App, helper.Ctx, n, sdk.NewInt(100000000))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we specify sdk.DefaultPowerReduction here instead of the literal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the amount of tokens for each genesis account rather than that for each validator, so it should be some large values.

@SebastianElvis SebastianElvis merged commit 4be8fd2 into dev Jan 16, 2023
@SebastianElvis SebastianElvis deleted the epoching-debug-create-val branch January 16, 2023 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants