Skip to content

Commit

Permalink
Use x.rnd properly as the _previous_ round.
Browse files Browse the repository at this point in the history
  • Loading branch information
jannotti committed Dec 19, 2024
1 parent 567780a commit 242f3f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ type ProposerPayoutRules struct {
//
// BaseAmount: 0, DecayInterval: XXX
//
// by using a zero baseAmount, the amount not affected.
// by using a zero baseAmount, the amount is not affected.
// For a bigger change, we'd use a plan like:
//
// BaseRound: <FUTURE round>, BaseAmount: <new amount>, DecayInterval: <new>
Expand Down
10 changes: 6 additions & 4 deletions ledger/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,16 @@ func (x *roundCowBase) lookup(addr basics.Address) (ledgercore.AccountData, erro
}

// balanceRound reproduces the way that the agreement package finds the round to
// consider for online accounts.
// consider for online accounts. It returns the round that would be considered
// while voting on the current round (which is x.rnd+1).
func (x *roundCowBase) balanceRound() (basics.Round, error) {
phdr, err := x.BlockHdr(agreement.ParamsRound(x.rnd))
current := x.rnd + 1
phdr, err := x.BlockHdr(agreement.ParamsRound(current))
if err != nil {
return 0, err
}
agreementParams := config.Consensus[phdr.CurrentProtocol]
return agreement.BalanceRound(x.rnd, agreementParams), nil
return agreement.BalanceRound(current, agreementParams), nil
}

// lookupAgreement returns the online accountdata for the provided account address. It uses an internal cache
Expand Down Expand Up @@ -248,7 +250,7 @@ func (x *roundCowBase) onlineStake() (basics.MicroAlgos, error) {
if err != nil {
return basics.MicroAlgos{}, err
}
total, err := x.l.OnlineCirculation(brnd, x.rnd)
total, err := x.l.OnlineCirculation(brnd, x.rnd+1) // x.rnd+1 is round being built
if err != nil {
return basics.MicroAlgos{}, err
}
Expand Down

0 comments on commit 242f3f5

Please sign in to comment.