Skip to content

Commit

Permalink
some debugging output
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelrozanski committed Nov 20, 2018
1 parent 8b082e9 commit 3f8176b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
16 changes: 11 additions & 5 deletions cmd/gaia/app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {
if numInitiallyBonded > numAccs {
numInitiallyBonded = numAccs
}
fmt.Printf("Selected randomly generated parameters for simulated genesis: {amount of steak per account: %v, initially bonded validators: %v}\n", amount, numInitiallyBonded)
fmt.Printf("Selected randomly generated parameters for simulated genesis:\n"+
"\t{amount of steak per account: %v, initially bonded validators: %v}\n",
amount, numInitiallyBonded)

// Randomly generate some genesis accounts
for _, acc := range accs {
Expand All @@ -86,7 +88,8 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {
GovernancePenalty: sdk.NewDecWithPrec(1, 2),
},
}
fmt.Printf("Selected randomly generated governance parameters: %+v\n", govGenesis)
fmt.Printf("Selected randomly generated governance parameters:\n\t%+v\n", govGenesis)

stakeGenesis := stake.GenesisState{
Pool: stake.InitialPool(),
Params: stake.Params{
Expand All @@ -95,7 +98,8 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {
BondDenom: stakeTypes.DefaultBondDenom,
},
}
fmt.Printf("Selected randomly generated staking parameters: %+v\n", stakeGenesis)
fmt.Printf("Selected randomly generated staking parameters:\n\t%+v\n", stakeGenesis)

slashingGenesis := slashing.GenesisState{
Params: slashing.Params{
MaxEvidenceAge: stakeGenesis.Params.UnbondingTime,
Expand All @@ -107,7 +111,8 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {
SlashFractionDowntime: sdk.NewDec(1).Quo(sdk.NewDec(int64(r.Intn(200) + 1))),
},
}
fmt.Printf("Selected randomly generated slashing parameters: %+v\n", slashingGenesis)
fmt.Printf("Selected randomly generated slashing parameters:\n\t%+v\n", slashingGenesis)

mintGenesis := mint.GenesisState{
Minter: mint.InitialMinter(
sdk.NewDecWithPrec(int64(r.Intn(99)), 2)),
Expand All @@ -119,7 +124,8 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {
sdk.NewDecWithPrec(67, 2),
uint64(60*60*8766/5)),
}
fmt.Printf("Selected randomly generated minting parameters: %v\n", mintGenesis)
fmt.Printf("Selected randomly generated minting parameters:\n\t%+v\n", mintGenesis)

var validators []stake.Validator
var delegations []stake.Delegation

Expand Down
16 changes: 13 additions & 3 deletions x/distribution/types/delegator_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,21 @@ func (di DelegationDistInfo) WithdrawRewards(wc WithdrawContext, vi ValidatorDis
di.DelPoolWithdrawalHeight = wc.Height
withdrawalTokens := vi.DelPool.MulDec(accum).QuoDec(vi.DelAccum.Accum)

if di.ValOperatorAddr.String() == "cosmosvaloper1uqzxjhtvkyqpaprlg37kr8a7wwvjsul255r9uj" &&
di.DelegatorAddr.String() == "cosmos1kd0jlj0nwstqgthxx86grwzevfy8psehz0gs0w" {

fmt.Println("______________________")
fmt.Printf("debug Height: %v\n", wc.Height)
fmt.Printf("debug withdrawalTokens: %v\n", withdrawalTokens)
fmt.Printf("debug accum: %v\n", accum)
fmt.Printf("debug vi.DelAccum.Accum: %v\n", vi.DelAccum.Accum)
}

// defensive check for impossible accum ratios
if accum.GT(vi.DelAccum.Accum) {
panic(fmt.Sprintf("accum > vi.DelAccum.Accum:\n",
"\taccum\t\t%v\n"+
"\tvi.DelAccum.Accum\t%v\n",
panic(fmt.Sprintf("accum > vi.DelAccum.Accum:\n"+
"\taccum\t\t\t%v\n"+
"\tvi.DelAccum.Accum\t%v\n",
accum, vi.DelAccum.Accum))
}

Expand Down

0 comments on commit 3f8176b

Please sign in to comment.