Skip to content
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
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
215 changes: 215 additions & 0 deletions data/account/msgp_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions data/account/msgp_gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 26 additions & 13 deletions data/account/participation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
package account

import (
"bytes"
"context"
"database/sql"
"encoding/binary"
"fmt"

"github.com/algorand/go-algorand/config"
Expand All @@ -43,6 +41,7 @@ import (
// For correctness, all Roots should have no more than one Participation
// globally active at any time. If this condition is violated, the Root may
// equivocate. (Algorand tolerates a limited fraction of misbehaving accounts.)
//msgp:ignore Participation
type Participation struct {
Parent basics.Address

Expand All @@ -58,27 +57,41 @@ type Participation struct {
KeyDilution uint64
}

// participationIDData is for msgpack encoding the participation data.
type participationIDData struct {
_struct struct{} `codec:",omitempty,omitemptyarray"`

Parent basics.Address `codec:"addr"`
VRFSK crypto.VrfPrivkey `codec:"vrfsk"`
FirstValid basics.Round `codec:"fv"`
LastValid basics.Round `codec:"lv"`
KeyDilution uint64 `codec:"kd"`
}

// ToBeHashed implements the Hashable interface.
func (id *participationIDData) ToBeHashed() (protocol.HashID, []byte) {
return protocol.ParticipationKeys, protocol.Encode(id)
}

// ParticipationID computes a ParticipationID.
func (part Participation) ParticipationID() ParticipationID {
data := new(bytes.Buffer)

data.Write(part.Parent[:])
binary.Write(data, binary.LittleEndian, part.FirstValid)
binary.Write(data, binary.LittleEndian, part.LastValid)
binary.Write(data, binary.LittleEndian, part.KeyDilution)
idData := participationIDData{
Parent: part.Parent,
FirstValid: part.FirstValid,
LastValid: part.LastValid,
KeyDilution: part.KeyDilution,
}
if part.VRF != nil {
data.Write(part.VRF.PK[:])
copy(idData.VRFSK[:], part.VRF.SK[:])
}

// this too?
//part.Write(part.Voting.SubKeyPK[:])

return ParticipationID(crypto.Hash(data.Bytes()))
return ParticipationID(crypto.HashObj(&idData))
}

// PersistedParticipation encapsulates the static state of the participation
// for a single address at any given moment, while providing the ability
// to handle persistence and deletion of secrets.
//msgp:ignore PersistedParticipation
type PersistedParticipation struct {
Participation

Expand Down
Loading