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

Participation Key Interface #3164

Merged
merged 31 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7954ddf
Create New Participation Key Interface REST endpoints (#2671)
AlgoStephenAkiki Aug 3, 2021
bfeba29
Merge branch 'master' into feature/partkey
winder Aug 5, 2021
6029629
Participation Metrics (#2677)
winder Aug 7, 2021
d24bf1e
Merge branch 'master' into feature/partkey
winder Aug 16, 2021
65feafd
ParticipationRegistry Cache (#2769)
winder Aug 25, 2021
5e16918
Merge remote-tracking branch 'upstream/master' into feature/partkey
winder Aug 26, 2021
0aec085
Register keys with ParticipationRegistry. (#2808)
winder Sep 13, 2021
e9fc89c
Merge branch 'master' into feature/partkey
winder Sep 22, 2021
504cbc8
Add ParticipationRegistry Insert/Delete usage in node. (#2810)
winder Sep 22, 2021
59b5f28
Merge branch 'master' into feature/partkey
winder Oct 9, 2021
0b371a3
Reduce blocking in partkey db (#3034)
brianolson Oct 13, 2021
ee51a98
Merge branch 'master' into feature/partkey
winder Oct 18, 2021
f86207e
Implemented New REST interfaces (#3099)
AlgoStephenAkiki Oct 21, 2021
5434456
.Register() complains only if the primary record fails (#3091)
brianolson Oct 21, 2021
5cb3b00
Test for optional registerUpdates. (#3122)
winder Oct 21, 2021
9fbca06
Install secrets in partkey registry (#3052)
winder Oct 22, 2021
25c8f26
Merge branch 'master' into feature/partkey
winder Oct 26, 2021
32efa83
Update key registry schema for state proof support (#3156)
winder Oct 29, 2021
f688227
Merge branch 'master' into feature/partkey
winder Oct 29, 2021
a6f70b7
PKI TODO comments + fix import order. (#3167)
winder Oct 29, 2021
3c391eb
Update participation key goal output (#3148)
winder Nov 3, 2021
afcf507
Add new participation key e2e test. (#3178)
winder Nov 3, 2021
4c69829
Rename CompactCertificate to StateProof. (#3182)
winder Nov 3, 2021
2321dc0
Merge branch 'master' into feature/partkey
winder Nov 3, 2021
41d5263
Remove unused lookup map.
winder Nov 3, 2021
08fbff6
Merge branch 'master' into feature/partkey
winder Nov 3, 2021
0ca20bd
Check part.LastVote instead of part.LastStateProof a second time.
winder Nov 4, 2021
28fd5db
PKI PR Feedback. (#3191)
winder Nov 12, 2021
25425d1
Add compatibility mode for listpartkeys goal command. (#3207)
winder Nov 12, 2021
ff01041
Merge branch 'master' into feature/partkey
winder Nov 12, 2021
0ab926c
Remove unused variable.
winder Nov 12, 2021
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GOLDFLAGS := $(GOLDFLAGS_BASE) \
UNIT_TEST_SOURCES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && go list ./... | grep -v /go-algorand/test/ ))
ALGOD_API_PACKAGES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && cd daemon/algod/api; go list ./... ))

MSGP_GENERATE := ./protocol ./protocol/test ./crypto ./crypto/compactcert ./data/basics ./data/transactions ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./node ./ledger ./ledger/ledgercore ./compactcert
MSGP_GENERATE := ./protocol ./protocol/test ./crypto ./crypto/compactcert ./data/basics ./data/transactions ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./node ./ledger ./ledger/ledgercore ./compactcert ./data/account

default: build

Expand Down
4 changes: 4 additions & 0 deletions agreement/abstractions.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ type KeyManager interface {
// valid for the provided votingRound, and were available at
// keysRound.
VotingKeys(votingRound, keysRound basics.Round) []account.Participation

// RecordAsync indicates that the given participation action has been taken.
// The operation needs to be asynchronous to avoid impacting agreement.
RecordAsync(account basics.Address, round basics.Round, participationType account.ParticipationAction)
}

// MessageHandle is an ID referring to a specific message.
Expand Down
9 changes: 5 additions & 4 deletions agreement/agreementtest/keyManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
)

// SimpleKeyManager provides a simple implementation of a KeyManager.
// SimpleKeyManager provides a simple implementation of a KeyManager for unit tests.
type SimpleKeyManager []account.Participation

// VotingKeys implements KeyManager.VotingKeys.
Expand All @@ -37,7 +37,8 @@ func (m SimpleKeyManager) VotingKeys(votingRound, _ basics.Round) []account.Part

// DeleteOldKeys implements KeyManager.DeleteOldKeys.
func (m SimpleKeyManager) DeleteOldKeys(r basics.Round) {
// for _, acc := range m {
// acc.DeleteOldKeys(r)
// }
}

// RecordAsync implements KeyManager.RecordAsync.
func (m SimpleKeyManager) RecordAsync(account basics.Address, round basics.Round, action account.ParticipationAction) {
}
2 changes: 1 addition & 1 deletion agreement/cryptoVerifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func BenchmarkCryptoVerifierProposalVertification(b *testing.B) {
pn := &asyncPseudonode{
factory: testBlockFactory{Owner: 0},
validator: testBlockValidator{},
keys: simpleKeyManager(participations),
keys: makeRecordingKeyManager(participations),
ledger: ledger,
log: serviceLogger{logging.Base()},
}
Expand Down
3 changes: 2 additions & 1 deletion agreement/fuzzer/fuzzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/algorand/go-deadlock"

"github.com/algorand/go-algorand/agreement"
"github.com/algorand/go-algorand/agreement/agreementtest"
"github.com/algorand/go-algorand/agreement/gossip"
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/crypto"
Expand Down Expand Up @@ -132,7 +133,7 @@ func (n *Fuzzer) initAgreementNode(nodeID int, filters ...NetworkFilterFactory)
Logger: logger,
Ledger: n.ledgers[nodeID],
Network: gossip.WrapNetwork(n.facades[nodeID], logger),
KeyManager: simpleKeyManager(n.accounts[nodeID : nodeID+1]),
KeyManager: agreementtest.SimpleKeyManager(n.accounts[nodeID : nodeID+1]),
BlockValidator: n.blockValidator,
BlockFactory: testBlockFactory{Owner: nodeID},
Clock: n.clocks[nodeID],
Expand Down
34 changes: 0 additions & 34 deletions agreement/fuzzer/keyManager_test.go

This file was deleted.

63 changes: 63 additions & 0 deletions agreement/keyManager_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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 (
"github.com/algorand/go-deadlock"

"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) RecordAsync(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
}
2 changes: 2 additions & 0 deletions agreement/pseudonode.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ func (t pseudonodeVotesTask) execute(verifier *AsyncVoteVerifier, quit chan stru
for _, r := range verifiedResults {
select {
case t.out <- messageEvent{T: voteVerified, Input: r.message, Err: makeSerErr(r.err)}:
t.node.keys.RecordAsync(r.v.R.Sender, r.v.R.Round, account.Vote)
case <-quit:
return
case <-t.context.Done():
Expand Down Expand Up @@ -528,6 +529,7 @@ func (t pseudonodeProposalsTask) execute(verifier *AsyncVoteVerifier, quit chan
for _, r := range verifiedVotes {
select {
case t.out <- messageEvent{T: voteVerified, Input: r.message, Err: makeSerErr(r.err)}:
t.node.keys.RecordAsync(r.v.R.Sender, r.v.R.Round, account.BlockProposal)
case <-quit:
return
case <-t.context.Done():
Expand Down
12 changes: 10 additions & 2 deletions agreement/pseudonode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestPseudonode(t *testing.T) {
sLogger := serviceLogger{logging.NewLogger()}
sLogger.SetLevel(logging.Warn)

keyManager := simpleKeyManager(accounts)
keyManager := makeRecordingKeyManager(accounts)
pb := makePseudonode(pseudonodeParams{
factory: testBlockFactory{Owner: 0},
validator: testBlockValidator{},
Expand Down Expand Up @@ -222,7 +222,12 @@ func TestPseudonode(t *testing.T) {
}
messageEvent, typeOk := ev.(messageEvent)
assert.True(t, true, typeOk)
// Verify votes are recorded - everyone is voting and proposing blocks.
keyManager.mutex.Lock()
assert.Equal(t, startRound, keyManager.recording[messageEvent.Input.Vote.R.Sender][account.Vote])
assert.Equal(t, startRound, keyManager.recording[messageEvent.Input.Vote.R.Sender][account.BlockProposal])
events[messageEvent.t()] = append(events[messageEvent.t()], messageEvent)
keyManager.mutex.Unlock()
}
assert.Subset(t, []int{5, 6, 7, 8, 9, 10}, []int{len(events[voteVerified])})
assert.Equal(t, 0, len(events[payloadVerified]))
Expand Down Expand Up @@ -390,6 +395,9 @@ func (k *KeyManagerProxy) VotingKeys(votingRound, balanceRound basics.Round) []a
return k.target(votingRound, balanceRound)
}

func (k *KeyManagerProxy) RecordAsync(account basics.Address, round basics.Round, action account.ParticipationAction) {
}

func TestPseudonodeLoadingOfParticipationKeys(t *testing.T) {
partitiontest.PartitionTest(t)

Expand All @@ -403,7 +411,7 @@ func TestPseudonodeLoadingOfParticipationKeys(t *testing.T) {
sLogger := serviceLogger{logging.NewLogger()}
sLogger.SetLevel(logging.Warn)

keyManager := simpleKeyManager(accounts)
keyManager := makeRecordingKeyManager(accounts)
pb := makePseudonode(pseudonodeParams{
factory: testBlockFactory{Owner: 0},
validator: testBlockValidator{},
Expand Down
18 changes: 1 addition & 17 deletions agreement/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,6 @@ func (c *testingClock) fire(d time.Duration) {
close(c.TA[d])
}

type simpleKeyManager []account.Participation

func (m simpleKeyManager) VotingKeys(votingRound, _ basics.Round) []account.Participation {
var km []account.Participation
for _, acc := range m {
if acc.OverlapsInterval(votingRound, votingRound) {
km = append(km, acc)
}
}
return km
}

func (m simpleKeyManager) DeleteOldKeys(basics.Round) {
// noop
}

type testingNetwork struct {
validator BlockValidator

Expand Down Expand Up @@ -743,7 +727,7 @@ func setupAgreementWithValidator(t *testing.T, numNodes int, traceLevel traceLev
m.coserviceListener = am.coserviceListener(nodeID(i))
clocks[i] = makeTestingClock(m)
ledgers[i] = ledgerFactory(balances)
keys := simpleKeyManager(accounts[i : i+1])
keys := makeRecordingKeyManager(accounts[i : i+1])
endpoint := baseNetwork.testingNetworkEndpoint(nodeID(i))
ilog := log.WithFields(logging.Fields{"Source": "service-" + strconv.Itoa(i)})

Expand Down
Loading