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

R4R: distribution accum invariants #2597

Merged
merged 26 commits into from
Oct 26, 2018
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
076011a
add GetAccum for validator and fee pool
rigelrozanski Oct 23, 2018
6755ec7
refactor accum
rigelrozanski Oct 24, 2018
25cbbd5
refactoring working
rigelrozanski Oct 25, 2018
d93a44f
refactor WIP
rigelrozanski Oct 25, 2018
631215a
Estimate -> Current, wip refactor
rigelrozanski Oct 25, 2018
eda3463
core code compiling
rigelrozanski Oct 25, 2018
dc2e430
tests compiling/passing
rigelrozanski Oct 25, 2018
4b2c76e
wip val accum invar
rigelrozanski Oct 25, 2018
d4a1cf6
add header to dim iterator
rigelrozanski Oct 25, 2018
bad97f2
fix invarience output
rigelrozanski Oct 25, 2018
e23054f
Rename Pool -> DelRewards; PoolCommission -> ValCommision
jaekwon Oct 25, 2018
93d5437
FeePool.Pool -> FeePool.ValPool
jaekwon Oct 26, 2018
33521b0
WithdrawalHeight->DelPoolWithdrawalHeight
jaekwon Oct 26, 2018
1143c93
OnValidatorBeginUnbonding
jaekwon Oct 26, 2018
c17f425
Caught the bug's tail
jaekwon Oct 26, 2018
ce0528f
unbonding fix
rigelrozanski Oct 26, 2018
79be652
output cleanup
rigelrozanski Oct 26, 2018
b97a076
Update vi.FeePoolWithdrawalHeight upon bonding
jaekwon Oct 26, 2018
aba5c95
use jae fix instead
rigelrozanski Oct 26, 2018
99efde2
Fix staking slashUnbondingDelegation bug; fixes simulator failure #9
jaekwon Oct 26, 2018
19d5f28
Merge remote-tracking branch 'origin/jae/dist_refactor' into rigel/di…
rigelrozanski Oct 26, 2018
a62dcad
compile fixes for jae merge
rigelrozanski Oct 26, 2018
306d1b2
...
rigelrozanski Oct 26, 2018
78b8c2d
changelog
rigelrozanski Oct 26, 2018
0d1adfe
address @jawkwon comment
rigelrozanski Oct 26, 2018
9b477f4
Merge branch 'develop' into rigel/distr-accum-invar
cwgoes Oct 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
output cleanup
  • Loading branch information
rigelrozanski committed Oct 26, 2018
commit 79be65283e227227dbeefdc3361f097eacd8a0dd
23 changes: 14 additions & 9 deletions x/stake/simulation/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,25 @@ func SupplyInvariants(ck bank.Keeper, k stake.Keeper,
loose = loose.Add(feePool.Pool.AmountOf("steak"))

// add validator distribution commission and yet-to-be-withdrawn-by-delegators
d.IterateValidatorDistInfos(ctx, func(_ int64, distInfo distribution.ValidatorDistInfo) (stop bool) {
loose = loose.Add(distInfo.Pool.AmountOf("steak"))
loose = loose.Add(distInfo.PoolCommission.AmountOf("steak"))
return false
})

// Loose tokens should equal coin supply plus unbonding delegations plus tokens on unbonded validators
d.IterateValidatorDistInfos(ctx,
func(_ int64, distInfo distribution.ValidatorDistInfo) (stop bool) {
loose = loose.Add(distInfo.Pool.AmountOf("steak"))
loose = loose.Add(distInfo.PoolCommission.AmountOf("steak"))
return false
},
)

// Loose tokens should equal coin supply plus unbonding delegations
// plus tokens on unbonded validators
if !pool.LooseTokens.Equal(loose) {
return fmt.Errorf("expected loose tokens to equal total steak held by accounts - pool.LooseTokens: %v, sum of account tokens: %v", pool.LooseTokens, loose)
return fmt.Errorf("loose token invariance:\n\tpool.LooseTokens: %v"+
"\n\tsum of account tokens: %v", pool.LooseTokens, loose)
}

// Bonded tokens should equal sum of tokens with bonded validators
if !pool.BondedTokens.Equal(bonded) {
return fmt.Errorf("expected bonded tokens to equal total steak held by bonded validators - pool.BondedTokens: %v, sum of bonded validator tokens: %v", pool.BondedTokens, bonded)
return fmt.Errorf("bonded token invariance:\n\tpool.BondedTokens: %v"+
"\n\tsum of account tokens: %v", pool.BondedTokens, bonded)
}

return nil
Expand Down