Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jannotti committed Dec 18, 2024
1 parent 6e93262 commit 39cf79e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
26 changes: 13 additions & 13 deletions data/transactions/logic/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,6 @@ func (l *Ledger) NewAccount(addr basics.Address, balance uint64) {
l.balances[addr] = newBalanceRecord(addr, balance)
}

// NewVoting sets VoteID on the account. Could expand to set other voting data
// if that became useful in tests.
func (l *Ledger) NewVoting(addr basics.Address, voteID crypto.OneTimeSignatureVerifier) {
br, ok := l.balances[addr]
if !ok {
br = newBalanceRecord(addr, 0)
}
br.voting.VoteID = voteID
br.voting.VoteKeyDilution = 10_000
l.balances[addr] = br
}

// NewApp add a new AVM app to the Ledger. In most uses, it only sets up the id
// and schema but no code, as testing will want to try many different code
// sequences.
Expand Down Expand Up @@ -350,6 +338,9 @@ func (l *Ledger) AgreementData(addr basics.Address) (basics.OnlineAccountData, e
// paid. Here, we ignore that for simple tests.
return basics.OnlineAccountData{
MicroAlgosWithRewards: ad.MicroAlgos,
// VotingData is not exposed to `voter_params_get`, the thinking is that
// we don't want them used as "free" storage. And thus far, we don't
// have compelling reasons to examine them in AVM.
VotingData: basics.VotingData{
VoteID: ad.VoteID,
SelectionID: ad.SelectionID,
Expand Down Expand Up @@ -961,7 +952,7 @@ func (l *Ledger) Perform(gi int, ep *EvalParams) error {
}

// Get returns the AccountData of an address. This test ledger does
// not handle rewards, so the pening rewards flag is ignored.
// not handle rewards, so withPendingRewards is ignored.
func (l *Ledger) Get(addr basics.Address, withPendingRewards bool) (basics.AccountData, error) {
br, ok := l.balances[addr]
if !ok {
Expand All @@ -975,6 +966,15 @@ func (l *Ledger) Get(addr basics.Address, withPendingRewards bool) (basics.Accou
AppParams: map[basics.AppIndex]basics.AppParams{},
LastProposed: br.proposed,
LastHeartbeat: br.heartbeat,
// The fields below are not exposed to `acct_params_get`, the thinking
// is that we don't want them used as "free" storage. And thus far, we
// don't have compelling reasons to examine them in AVM.
VoteID: br.voting.VoteID,
SelectionID: br.voting.SelectionID,
StateProofID: br.voting.StateProofID,
VoteFirstValid: br.voting.VoteFirstValid,
VoteLastValid: br.voting.VoteLastValid,
VoteKeyDilution: br.voting.VoteKeyDilution,
}, nil
}

Expand Down
11 changes: 6 additions & 5 deletions ledger/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1781,12 +1781,13 @@ func isAbsent(totalOnlineStake basics.MicroAlgos, acctStake basics.MicroAlgos, l
}
// See if the account has exceeded their expected observation interval.
allowableLag, o := basics.Muldiv(absentFactor, totalOnlineStake.Raw, acctStake.Raw)
if o {
// This can't happen with 10B total possible stake and a reasonable
// absentFactor, but if we imagine another algorand network with huge
// possible stake, this seems reasonable.
allowableLag = math.MaxInt64 / acctStake.Raw
// just return false for overflow or a huge allowableLag. It implies the lag
// is longer that any network could be around, and computing with wraparound
// is annoying.
if o || allowableLag > math.MaxUint32 {
return false
}

return lastSeen+basics.Round(allowableLag) < current
}

Expand Down
1 change: 0 additions & 1 deletion ledger/eval/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,6 @@ func TestEvalFunctionForExpiredAccounts(t *testing.T) {
for i := uint64(0); i < uint64(targetRound); i++ {
vb := l.endBlock(t, blkEval, recvAddr)
blkEval = l.nextBlock(t)
//require.Empty(t, vb.Block().ExpiredParticipationAccounts)
for _, acct := range vb.Block().ExpiredParticipationAccounts {
if acct == recvAddr {
// won't happen, because recvAddr was proposer
Expand Down

0 comments on commit 39cf79e

Please sign in to comment.