From 242f3f549a30b18cc550eb75fb845a5151f029cf Mon Sep 17 00:00:00 2001 From: John Jannotti Date: Thu, 19 Dec 2024 09:11:22 -0800 Subject: [PATCH] Use `x.rnd` properly as the _previous_ round. --- config/consensus.go | 2 +- ledger/eval/eval.go | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config/consensus.go b/config/consensus.go index debecca244..b153848230 100644 --- a/config/consensus.go +++ b/config/consensus.go @@ -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: , BaseAmount: , DecayInterval: diff --git a/ledger/eval/eval.go b/ledger/eval/eval.go index 5537b5ed7b..876b3ad19b 100644 --- a/ledger/eval/eval.go +++ b/ledger/eval/eval.go @@ -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 @@ -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 }