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

Register keys with ParticipationRegistry. #2808

Merged
Prev Previous commit
Next Next commit
Fix node test and update benchmark.
winder committed Aug 31, 2021
commit f4dad58a3f56ad13673d34ed0f59f4bea792fa2c
4 changes: 3 additions & 1 deletion data/account/participationRegistry.go
Original file line number Diff line number Diff line change
@@ -54,9 +54,11 @@ type ParticipationRecord struct {
// OneTimeSignatureSecrets
}

var zeroParticipationRecord = ParticipationRecord{}

// IsZero returns true if the object contains zero values.
func (r ParticipationRecord) IsZero() bool {
return r == (ParticipationRecord{})
return r == zeroParticipationRecord
}

// Duplicate creates a copy of the current object. This is required once secrets are stored.
10 changes: 5 additions & 5 deletions data/account/participationRegistry_test.go
Original file line number Diff line number Diff line change
@@ -495,7 +495,7 @@ func benchmarkKeyRegistration(numKeys int, b *testing.B) {
}

// Insert records so that we can t
b.Run("KeyInsert", func(b *testing.B) {
b.Run(fmt.Sprintf("KeyInsert_%d", numKeys), func(b *testing.B) {
for n := 0; n < b.N; n++ {
for key := 0; key < numKeys; key++ {
p := makeTestParticipation(key, basics.Round(0), basics.Round(1000000), 3)
@@ -505,7 +505,7 @@ func benchmarkKeyRegistration(numKeys int, b *testing.B) {
})

// The first call to Register updates the DB.
b.Run("KeyRegistered", func(b *testing.B) {
b.Run(fmt.Sprintf("KeyRegistered_%d", numKeys), func(b *testing.B) {
for n := 0; n < b.N; n++ {
for key := 0; key < numKeys; key++ {
p := makeTestParticipation(key, basics.Round(0), basics.Round(1000000), 3)
@@ -522,7 +522,7 @@ func benchmarkKeyRegistration(numKeys int, b *testing.B) {
})

// The keys should now be updated, so Register is a no-op.
b.Run("NoOp", func(b *testing.B) {
b.Run(fmt.Sprintf("NoOp_%d", numKeys), func(b *testing.B) {
for n := 0; n < b.N; n++ {
for key := 0; key < numKeys; key++ {
p := makeTestParticipation(key, basics.Round(0), basics.Round(1000000), 3)
@@ -532,7 +532,7 @@ func benchmarkKeyRegistration(numKeys int, b *testing.B) {
})
}

func BenchmarkKeyRegistration1(b *testing.B) { benchmarkKeyRegistration(1, b) }
func BenchmarkKeyRegistration5(b *testing.B) { benchmarkKeyRegistration(5, b) }
func BenchmarkKeyRegistration1(b *testing.B) { benchmarkKeyRegistration(1, b) }
func BenchmarkKeyRegistration5(b *testing.B) { benchmarkKeyRegistration(5, b) }
func BenchmarkKeyRegistration10(b *testing.B) { benchmarkKeyRegistration(10, b) }
func BenchmarkKeyRegistration50(b *testing.B) { benchmarkKeyRegistration(50, b) }
3 changes: 1 addition & 2 deletions node/node_test.go
Original file line number Diff line number Diff line change
@@ -548,8 +548,7 @@ func TestAsyncRecord(t *testing.T) {
node.RecordAsync(addr, 20000, account.BlockProposal)

time.Sleep(5000 * time.Millisecond)
records, err := node.participationRegistry.GetAll()
require.NoError(t, err)
records := node.participationRegistry.GetAll()
require.Len(t, records, 1)
require.Equal(t, 10000, int(records[0].LastVote))
require.Equal(t, 20000, int(records[0].LastBlockProposal))