-
Notifications
You must be signed in to change notification settings - Fork 3
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
power reduction as on-chain param #65
power reduction as on-chain param #65
Conversation
Oh wow. I didn't realize so many tests all over the repo are using it It seems it's because the tests all want to just provision validators by passing in their power as int64. I wonder if that's really that necessary, the could just pass in a coins amount... Regardless, lets not change that for now. But what we should do is that in mosts of the tests, the stakingkeeper is already created. So could we have it use the PowerReduction from params instead of the default one? So just as an example, in this spot: https://github.com/sikkatech/cosmos-sdk/pull/65/files#diff-ed4e03a1684493ef5faebd259fba6adbd95295a1e8e3cecd54c4f27e30de7da9R284 Instead of
it could be
|
Instead of
Used
|
Codecov Report
@@ Coverage Diff @@
## master #65 +/- ##
==========================================
+ Coverage 55.25% 61.41% +6.16%
==========================================
Files 593 657 +64
Lines 36990 37401 +411
==========================================
+ Hits 20437 22970 +2533
+ Misses 14442 12026 -2416
- Partials 2111 2405 +294
|
@@ -35,7 +35,7 @@ var ( | |||
multiPermAcc = authtypes.NewEmptyModuleAccount(multiPerm, authtypes.Burner, authtypes.Minter, authtypes.Staking) | |||
randomPermAcc = authtypes.NewEmptyModuleAccount(randomPerm, "random") | |||
|
|||
initTokens = sdk.TokensFromConsensusPower(initialPower) | |||
initTokens = sdk.TokensFromConsensusPower(initialPower, sdk.DefaultPowerReduction) |
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.
initTokens
variable is used in several places, to be secure, variable name should be defaultInitTokens
as it's derivated from sdk.DefaultPowerReduction
.
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 think that because these are in tests, I think it's okay as is. If this was in state machine codepaths, I'd agree. But this is just a variable name local to the test, and so like to the view of the test, it is the initTokens, not just a default InitTokens.
Ditto to the other similar comments.
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.
initTokens
is a global varible used in tests, it's not local function variable. It can be used in several tests where power reduction could be different.
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.
Hmm, ok, makes sense
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.
For my perspective, global var initTokens
can be initialized from DefaultPowerReduction and local initTokens
can be initialized from on-chain power reduction. If local test has different on-chain power reduction, it can initialize local initTokens
.
@@ -34,7 +34,7 @@ var ( | |||
sdk.ValAddress(pubkeys[2].Address()), | |||
} | |||
|
|||
initAmt = sdk.TokensFromConsensusPower(200) | |||
initAmt = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) | |||
initCoins = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) |
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.
Recommend updates to defaultInitAmt
and defaultInitCoins
.
@@ -5,5 +5,5 @@ import ( | |||
) | |||
|
|||
var ( | |||
InitTokens = sdk.TokensFromConsensusPower(200) | |||
InitTokens = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) |
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.
Recommend an update to DefaultInitTokens
@@ -3,5 +3,5 @@ package keeper_test | |||
import sdk "github.com/cosmos/cosmos-sdk/types" | |||
|
|||
var ( | |||
InitTokens = sdk.TokensFromConsensusPower(200) | |||
InitTokens = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) |
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.
Recommend an update to DefaultInitTokens
Why rosetta test is cancelled? Is it an expected behavior @sunnya97 @psaradev |
@antstalepresh I'm not sure. Maybe it ran out of resources? Going to try rerunning 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.
Nice work! I didn't realize the power reduction was used so statelessly throughout the SDK tests
Description
Turn staking Power Reduction into an on-chain param
closes: cosmos#8365
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes