-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary * new `ParticipationRegistry` interface designed to manage keys and collect usage metrics. * new REST endpoints for interacting with keys. * improved `goal account partkeyinfo` and `goal account listpartkeys` formatting. ## Test Plan New unit and integration tests.
- Loading branch information
Showing
44 changed files
with
4,939 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright (C) 2019-2021 Algorand, Inc. | ||
// This file is part of go-algorand | ||
// | ||
// go-algorand is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as | ||
// published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// | ||
// go-algorand is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package agreement | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/algorand/go-deadlock" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/algorand/go-algorand/data/account" | ||
"github.com/algorand/go-algorand/data/basics" | ||
) | ||
|
||
func makeRecordingKeyManager(accounts []account.Participation) *recordingKeyManager { | ||
return &recordingKeyManager{ | ||
keys: accounts, | ||
recording: make(map[basics.Address]map[account.ParticipationAction]basics.Round), | ||
} | ||
} | ||
|
||
// recordingKeyManager provides a simple implementation of a KeyManager for unit tests. | ||
type recordingKeyManager struct { | ||
keys []account.Participation | ||
recording map[basics.Address]map[account.ParticipationAction]basics.Round | ||
mutex deadlock.Mutex | ||
} | ||
|
||
// VotingKeys implements KeyManager.VotingKeys. | ||
func (m *recordingKeyManager) VotingKeys(votingRound, _ basics.Round) []account.Participation { | ||
var km []account.Participation | ||
for _, acc := range m.keys { | ||
if acc.OverlapsInterval(votingRound, votingRound) { | ||
km = append(km, acc) | ||
} | ||
} | ||
return km | ||
} | ||
|
||
// DeleteOldKeys implements KeyManager.DeleteOldKeys. | ||
func (m *recordingKeyManager) DeleteOldKeys(r basics.Round) { | ||
} | ||
|
||
// Record implements KeyManager.Record. | ||
func (m *recordingKeyManager) Record(acct basics.Address, round basics.Round, action account.ParticipationAction) { | ||
m.mutex.Lock() | ||
defer m.mutex.Unlock() | ||
if _, ok := m.recording[acct]; !ok { | ||
m.recording[acct] = make(map[account.ParticipationAction]basics.Round) | ||
} | ||
m.recording[acct][action] = round | ||
} | ||
|
||
// ValidateVoteRound requires that the given address voted on a particular round. | ||
func (m *recordingKeyManager) ValidateVoteRound(t *testing.T, address basics.Address, round basics.Round) { | ||
m.mutex.Lock() | ||
require.Equal(t, round, m.recording[address][account.Vote]) | ||
require.Equal(t, round, m.recording[address][account.BlockProposal]) | ||
m.mutex.Unlock() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.