-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
WIP: Altered RNG / vesting debugging #3712
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #3712 +/- ##
===========================================
- Coverage 61.18% 61.17% -0.02%
===========================================
Files 190 190
Lines 14008 14008
===========================================
- Hits 8571 8569 -2
- Misses 4901 4903 +2
Partials 536 536 |
... if you undelegate fractional shares, tokens are truncated, so the exchange rate can exceed 1. ( |
Why do we allow fractional share withdrawals? Would preventing them fix this? Could there still be a case when a validator is slashed and withdrawal-truncations result in a > 1 exchange rate? |
For the exchange rate to be
|
@cwgoes we need fractional share withdrawals if you're to be allowed to fully withdraw your shares from a validator. Let's say I delegate 100 atoms to a validator with a non-integer exchange rate and I receive 123.457 shares in return. If I am only able to withdraw 123 shares then I can only ever get back 99 atoms |
I see, that makes sense. |
Let's donate to the community pool (credit to @alexanderbez / @rigelrozanski). |
func RandomDecAmount(r *rand.Rand, max sdk.Dec) sdk.Dec { | ||
randInt := big.NewInt(0).Rand(r, max.Int) | ||
return sdk.NewDecFromBigIntWithPrec(randInt, sdk.Precision) | ||
// randInt := big.NewInt(0).Rand(r, max.Int) |
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.
Make this call RandomAmount so that we can tweak that one function...
in the future we could make RandomAmount's probability to include bias for 0 and small numbers as well.
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.e. keeps the code dry in a good way.
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.
Do we actually want to keep said changes as it's biased?
} | ||
result := sdk.NewIntFromBigInt(randInt) | ||
// Sanity | ||
if result.GT(max) { |
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.
result should be exclusive of max, so this is incorrect... will add pseudocode 1 min...
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 everywhere RandomAmount and RandomDecAmount are used, it makes sense to include the upper bound. (Though, I agree that leaving out the upper bound is more common and intuitive.)
@@ -37,14 +38,37 @@ func RandStringOfLength(r *rand.Rand, n int) string { | |||
} | |||
|
|||
// Generate a random amount | |||
// Note: The range of RandomAmount includes max, and is, in fact, biased to return max. |
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.
it shouldn't include max, it should be exclusive.
func RandomAmount(r *rand.Rand, max sdk.Int) sdk.Int { | ||
return sdk.NewInt(int64(r.Intn(int(max.Int64())))) | ||
// return sdk.NewInt(int64(r.Intn(int(max.Int64())))) |
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.
var randInt = big.NewInt(0)
switch r.Intn(3) {
case 0:
// randInt = big.NewInt(0)
case 1:
randInt = max.BigInt() - 1 // max - 1
case 2:
randInt = big.NewInt(0).Rand(r, max) // up to max - 1
}
return randInt
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.
This makes the various cases laid out better, is easier to extend and tweak.
everything incorporated here: #3717 |
Closing in favor of #3717. |
cc @rigelrozanski
Reproduce with:
go test ./cmd/gaia/app -run TestFullGaiaSimulation -SimulationEnabled=true -SimulationNumBlocks=400 -SimulationVerbose=true -SimulationCommit=true -SimulationSeed=20 -v -timeout 24h
docs/
)PENDING.md
with issue #Files changed
in the github PR explorerFor Admin Use: