Skip to content
Closed
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
6 changes: 3 additions & 3 deletions daemon/algod/api/algod.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@
],
"responses": {
"200": {
"description": "An empty JSON object is returned if the generation process was started. Currently no status is available.",
"description": "The participation ID. Currently no status is available.",
"schema": {
"type": "string"
}
Expand Down Expand Up @@ -1858,8 +1858,8 @@
"get": {
"description": "Get ledger deltas for a round.",
"tags": [
"public",
"nonparticipating"
"public",
"nonparticipating"
],
"produces": [
"application/json",
Expand Down
19 changes: 17 additions & 2 deletions daemon/algod/api/server/v2/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ func (v2 *Handlers) generateKeyHandler(address string, params model.GeneratePart
// GenerateParticipationKeys generates and installs participation keys to the node.
// (POST /v2/participation/generate/{address})
func (v2 *Handlers) GenerateParticipationKeys(ctx echo.Context, address string, params model.GenerateParticipationKeysParams) error {
addr, err := basics.UnmarshalChecksumAddress(address)
if err != nil {
return badRequest(ctx, err, err.Error(), v2.Log)
}
if !v2.KeygenLimiter.TryAcquire(1) {
err := fmt.Errorf("participation key generation already in progress")
return badRequest(ctx, err, err.Error(), v2.Log)
Expand All @@ -301,8 +305,19 @@ func (v2 *Handlers) GenerateParticipationKeys(ctx echo.Context, address string,
}
}()

// Empty object. In the future we may want to add a field for the participation ID.
return ctx.String(http.StatusOK, "{}")
firstRound := basics.Round(params.First)
lastRound := basics.Round(params.Last)
keyDilution := nilToZero(params.Dilution)
if keyDilution == 0 {
keyDilution = account.DefaultKeyDilution(firstRound, lastRound)
}
identity := account.ParticipationKeyIdentity{
Parent: addr,
FirstValid: firstRound,
LastValid: lastRound,
KeyDilution: keyDilution,
}
return ctx.JSON(http.StatusOK, identity.ID().String())
}

// AddParticipationKey Add a participation key to the node
Expand Down
57 changes: 5 additions & 52 deletions data/account/msgp_gen.go

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

16 changes: 4 additions & 12 deletions data/account/participation.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ type Participation struct {
type ParticipationKeyIdentity struct {
_struct struct{} `codec:",omitempty,omitemptyarray"`

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

// ToBeHashed implements the Hashable interface.
Expand All @@ -92,12 +90,6 @@ func (part Participation) ID() ParticipationID {
LastValid: part.LastValid,
KeyDilution: part.KeyDilution,
}
if part.VRF != nil {
copy(idData.VRFSK[:], part.VRF.SK[:])
}
if part.Voting != nil {
copy(idData.VoteID[:], part.Voting.OneTimeSignatureVerifier[:])
}

return idData.ID()
}
Expand Down
2 changes: 0 additions & 2 deletions data/accountManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ func (manager *AccountManager) AddParticipation(participation account.PersistedP
Parent: address,
FirstValid: first,
LastValid: last,
VRFSK: participation.VRF.SK,
VoteID: participation.Voting.OneTimeSignatureVerifier,
KeyDilution: participation.KeyDilution,
}

Expand Down