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

ledger: add StateProofID to AccountData.ClearOnlineState() #3643

Merged
merged 3 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions data/basics/userBalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ func (u *AccountData) ClearOnlineState() {
u.VoteKeyDilution = 0
u.VoteID = crypto.OneTimeSignatureVerifier{}
u.SelectionID = crypto.VRFVerifier{}
u.StateProofID = merklesignature.Verifier{}
}

// Money returns the amount of MicroAlgos associated with the user's account
Expand Down
19 changes: 18 additions & 1 deletion ledger/internal/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/crypto/compactcert"
"github.com/algorand/go-algorand/crypto/merklesignature"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
Expand Down Expand Up @@ -759,6 +760,8 @@ func TestEvalFunctionForExpiredAccounts(t *testing.T) {
}
tmp := genesisInitState.Accounts[addr]
tmp.Status = basics.Online
crypto.RandBytes(tmp.StateProofID[:])
crypto.RandBytes(tmp.SelectionID[:])
id-ms marked this conversation as resolved.
Show resolved Hide resolved
genesisInitState.Accounts[addr] = tmp
}

Expand Down Expand Up @@ -819,6 +822,11 @@ func TestEvalFunctionForExpiredAccounts(t *testing.T) {
_, err = Eval(context.Background(), l, validatedBlock.Block(), false, nil, nil)
require.NoError(t, err)

acctData, _ := blkEval.state.lookup(recvAddr)

require.Equal(t, merklesignature.Verifier{}, acctData.StateProofID)
require.Equal(t, crypto.VRFVerifier{}, acctData.SelectionID)

badBlock := *validatedBlock

// First validate that bad block is fine if we dont touch it...
Expand Down Expand Up @@ -986,7 +994,16 @@ func TestExpiredAccountGeneration(t *testing.T) {
continue
}
tmp := genesisInitState.Accounts[addr]

// make up online account data
tmp.Status = basics.Online
tmp.VoteFirstValid = basics.Round(1)
tmp.VoteLastValid = basics.Round(100)
tmp.VoteKeyDilution = 0x1234123412341234
crypto.RandBytes(tmp.SelectionID[:])
crypto.RandBytes(tmp.VoteID[:])
crypto.RandBytes(tmp.StateProofID[:])

genesisInitState.Accounts[addr] = tmp
}

Expand Down Expand Up @@ -1057,5 +1074,5 @@ func TestExpiredAccountGeneration(t *testing.T) {
require.Equal(t, recvAcct.VoteKeyDilution, uint64(0))
require.Equal(t, recvAcct.VoteID, crypto.OneTimeSignatureVerifier{})
require.Equal(t, recvAcct.SelectionID, crypto.VRFVerifier{})

require.Equal(t, recvAcct.StateProofID, merklesignature.Verifier{})
}