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

all DKG packets are now gossiped throughout the network #1230

Merged
merged 31 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e7cf3e5
DKG messages between participants are now signed and verified
CluEleSsUK May 2, 2023
c49a965
all DKG packets are now gossiped throughout the network
CluEleSsUK May 5, 2023
608a84b
fixed a refactor bug
CluEleSsUK May 5, 2023
4226f5e
linter
CluEleSsUK May 5, 2023
3f7a30c
fixed race condition
CluEleSsUK May 5, 2023
d51d8e7
import reordering D:
CluEleSsUK May 5, 2023
bfbb0ed
wait for nodes to be alive in LargeDKG test before running DKG
CluEleSsUK May 9, 2023
ec9b320
ignore leaver errors in proposal
CluEleSsUK May 9, 2023
edf0f34
move packet dedupe to avoid races
CluEleSsUK May 9, 2023
06cb6af
test lower retries for large DKG
CluEleSsUK May 9, 2023
a4b2e60
added some more schemes from env
CluEleSsUK May 9, 2023
358ebd7
fixed bug where packets were being re-signed when gossiping them!
CluEleSsUK May 9, 2023
e7cc8af
remove the unnecessary (racy) brokenbroadcaster
CluEleSsUK May 9, 2023
29773a1
updated with the rebased signatures branch
CluEleSsUK May 15, 2023
8c24046
moved comment, removed sleep, regenerated proto
CluEleSsUK Jun 6, 2023
8ff54dc
addressed PR comments
CluEleSsUK Jun 13, 2023
cc28768
packet participant arrays checked to avoid malicious nulls taking things
CluEleSsUK Jun 23, 2023
6633058
additional nil checks
CluEleSsUK Jun 23, 2023
7179d25
added DKG failed state in for DKGs that don't hit threshold
CluEleSsUK Jun 23, 2023
67d198c
fixed linting complaints
CluEleSsUK Jun 23, 2023
f9efcc1
fixed some unit tests
CluEleSsUK Jun 23, 2023
5919617
use beaconID from metadata rather than passing it around
CluEleSsUK Jul 4, 2023
daada49
removed mysterious debug log setting
CluEleSsUK Jul 4, 2023
dc92fe5
removed unnecessary grpc call options
CluEleSsUK Jul 4, 2023
0965277
Update internal/dkg/actions.go
CluEleSsUK Jul 4, 2023
b92f25e
advance clock a bit before running failed DKG in test
CluEleSsUK Jul 6, 2023
a63094a
added clock to DKG runner instead of using system time
CluEleSsUK Jul 6, 2023
84b1c9f
use mock clock for determining all DKG timings
CluEleSsUK Jul 6, 2023
c045951
fixed some references to clocks
CluEleSsUK Jul 6, 2023
8b2dec2
fixed an old test where multiple clocks were being created
CluEleSsUK Jul 6, 2023
a44a01b
added a sleep in a test for science
CluEleSsUK Jul 6, 2023
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
1 change: 0 additions & 1 deletion client/grpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func TestClientClose(t *testing.T) {
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
//nolint:revive // we drain the channel
for range c.Watch(context.Background()) {
}
wg.Done()
Expand Down
3 changes: 1 addition & 2 deletions client/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func TestHTTPWatch(t *testing.T) {
if len(first.Randomness()) == 0 {
t.Fatal("should get randomness from watching")
}
//nolint:revive // draining channel until the context expires

for range result {
}
_ = httpClient.Close()
Expand Down Expand Up @@ -186,7 +186,6 @@ func TestHTTPClientClose(t *testing.T) {
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
//nolint:revive // draining channel
for range httpClient.Watch(context.Background()) {
}
wg.Done()
Expand Down
2 changes: 1 addition & 1 deletion client/lp2p/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (c *Client) Watch(ctx context.Context) <-chan client.Result {
c.log.Debugw("client.Watch done")
end()
// drain leftover on innerCh
for range innerCh { //nolint:revive
for range innerCh {
}
c.log.Debugw("client.Watch finished draining the innerCh")
return
Expand Down
1 change: 0 additions & 1 deletion client/optimizing.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ LOOP:
stats = append(stats, rr.stat)
res = rr.result
if rr.err != nil && !errors.Is(rr.err, common.ErrEmptyClientUnsupportedGet) {
//nolint:errorlint
err = fmt.Errorf("%v - %w", err, rr.err)
} else if rr.err == nil {
err = nil
Expand Down
2 changes: 1 addition & 1 deletion common/key/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (g *Group) FromTOML(i interface{}) error {
}

if g.Threshold < dkg.MinimumT(len(gt.Nodes)) {
return errors.New("group file have threshold 0")
return errors.New("group file has threshold 0")
} else if g.Threshold > g.Len() {
return errors.New("group file threshold greater than number of participants")
}
Expand Down
1 change: 1 addition & 0 deletions demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func main() {
if err != nil {
panic(err)
}

err = orch.RunDKG(1 * time.Minute)
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion demo/node/node_subprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (n *NodeProc) StartLeaderReshare(thr int, transitionTime time.Time, _ int,
"--threshold", strconv.Itoa(thr),
"--transition-time", durationUntilTransitionTime.String(),
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
proposeCmd := exec.CommandContext(ctx, n.binary, proposeArgs...)
_ = runCommand(proposeCmd)
Expand Down
8 changes: 6 additions & 2 deletions internal/chain/beacon/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ func (t *testBeaconServer) SyncChain(req *drand.SyncRequest, p drand.Protocol_Sy
return SyncChain(t.h.l, t.h.chain, req, p)
}

func (t *testBeaconServer) Migrate(context.Context, *drand.Empty) (*drand.Empty, error) {
return &drand.Empty{}, nil
func (t *testBeaconServer) Command(context.Context, *drand.DKGCommand) (*drand.EmptyDKGResponse, error) {
return &drand.EmptyDKGResponse{}, nil
}

func (t *testBeaconServer) Packet(context.Context, *drand.GossipPacket) (*drand.EmptyDKGResponse, error) {
return &drand.EmptyDKGResponse{}, nil
}

func dkgShares(t *testing.T, n, thr int, sch *crypto.Scheme) ([]*key.Share, []kyber.Point) {
Expand Down
107 changes: 19 additions & 88 deletions internal/core/drand_daemon_dkg_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,12 @@ package core

import (
"context"
"errors"
"fmt"

"github.com/drand/drand/protobuf/drand"
)

func (dd *DrandDaemon) StartNetwork(ctx context.Context, options *drand.FirstProposalOptions) (*drand.EmptyResponse, error) {
return dd.dkg.StartNetwork(ctx, options)
}

func (dd *DrandDaemon) StartProposal(ctx context.Context, options *drand.ProposalOptions) (*drand.EmptyResponse, error) {
return dd.dkg.StartProposal(ctx, options)
}

func (dd *DrandDaemon) StartAbort(ctx context.Context, options *drand.AbortOptions) (*drand.EmptyResponse, error) {
beaconID := options.BeaconID

if !dd.beaconExists(beaconID) {
return nil, fmt.Errorf("beacon with ID %s is not running on this daemon", beaconID)
}

return dd.dkg.StartAbort(ctx, options)
}

func (dd *DrandDaemon) StartExecute(ctx context.Context, options *drand.ExecutionOptions) (*drand.EmptyResponse, error) {
beaconID := options.BeaconID

if !dd.beaconExists(beaconID) {
return nil, fmt.Errorf("beacon with ID %s is not running on this daemon", beaconID)
}

return dd.dkg.StartExecute(ctx, options)
}

func (dd *DrandDaemon) StartJoin(ctx context.Context, options *drand.JoinOptions) (*drand.EmptyResponse, error) {
beaconID := options.BeaconID

if !dd.beaconExists(beaconID) {
return nil, fmt.Errorf("beacon with ID %s is not running on this daemon", beaconID)
}

return dd.dkg.StartJoin(ctx, options)
}

func (dd *DrandDaemon) StartAccept(ctx context.Context, options *drand.AcceptOptions) (*drand.EmptyResponse, error) {
beaconID := options.BeaconID

if !dd.beaconExists(beaconID) {
return nil, fmt.Errorf("beacon with ID %s is not running on this daemon", beaconID)
}

return dd.dkg.StartAccept(ctx, options)
}

func (dd *DrandDaemon) StartReject(ctx context.Context, options *drand.RejectOptions) (*drand.EmptyResponse, error) {
beaconID := options.BeaconID

if !dd.beaconExists(beaconID) {
return nil, fmt.Errorf("beacon with ID %s is not running on this daemon", beaconID)
}

return dd.dkg.StartReject(ctx, options)
}

func (dd *DrandDaemon) DKGStatus(ctx context.Context, request *drand.DKGStatusRequest) (*drand.DKGStatusResponse, error) {
beaconID := request.BeaconID

Expand All @@ -75,52 +18,40 @@ func (dd *DrandDaemon) DKGStatus(ctx context.Context, request *drand.DKGStatusRe
return dd.dkg.DKGStatus(ctx, request)
}

func (dd *DrandDaemon) Propose(ctx context.Context, terms *drand.ProposalTerms) (*drand.EmptyResponse, error) {
return dd.dkg.Propose(ctx, terms)
}

func (dd *DrandDaemon) Abort(ctx context.Context, abortDKG *drand.AbortDKG) (*drand.EmptyResponse, error) {
beaconID := abortDKG.Metadata.BeaconID

if !dd.beaconExists(beaconID) {
return nil, fmt.Errorf("beacon with ID %s is not running on this daemon", beaconID)
func (dd *DrandDaemon) Command(ctx context.Context, command *drand.DKGCommand) (*drand.EmptyDKGResponse, error) {
if command.Metadata == nil {
return nil, errors.New("could not find command metadata to read beaconID")
}

return dd.dkg.Abort(ctx, abortDKG)
}

func (dd *DrandDaemon) Execute(ctx context.Context, execution *drand.StartExecution) (*drand.EmptyResponse, error) {
beaconID := execution.Metadata.BeaconID
beaconID := command.Metadata.BeaconID

if !dd.beaconExists(beaconID) {
return nil, fmt.Errorf("beacon with ID %s is not running on this daemon", beaconID)
}

return dd.dkg.Execute(ctx, execution)
return dd.dkg.Command(ctx, command)
}

func (dd *DrandDaemon) Accept(ctx context.Context, proposal *drand.AcceptProposal) (*drand.EmptyResponse, error) {
beaconID := proposal.Metadata.BeaconID

if !dd.beaconExists(beaconID) {
return nil, fmt.Errorf("beacon with ID %s is not running on this daemon", beaconID)
func (dd *DrandDaemon) Packet(ctx context.Context, packet *drand.GossipPacket) (*drand.EmptyDKGResponse, error) {
if packet.Metadata == nil {
return nil, errors.New("could not find command metadata to read beaconID")
}

return dd.dkg.Accept(ctx, proposal)
}

func (dd *DrandDaemon) Reject(ctx context.Context, proposal *drand.RejectProposal) (*drand.EmptyResponse, error) {
beaconID := proposal.Metadata.BeaconID
beaconID := packet.Metadata.BeaconID

if !dd.beaconExists(beaconID) {
return nil, fmt.Errorf("beacon with ID %s is not running on this daemon", beaconID)
}

return dd.dkg.Reject(ctx, proposal)
return dd.dkg.Packet(ctx, packet)
}

func (dd *DrandDaemon) BroadcastDKG(ctx context.Context, packet *drand.DKGPacket) (*drand.EmptyResponse, error) {
beaconID := packet.Metadata.BeaconID
func (dd *DrandDaemon) BroadcastDKG(ctx context.Context, packet *drand.DKGPacket) (*drand.EmptyDKGResponse, error) {
if packet.GetDkg() == nil {
return nil, errors.New("DKG was missing from packet")
}
if packet.GetDkg().Metadata == nil {
return nil, errors.New("could not find packet metadata to read beaconID")
}
beaconID := packet.Dkg.Metadata.BeaconID
CluEleSsUK marked this conversation as resolved.
Show resolved Hide resolved

if !dd.beaconExists(beaconID) {
return nil, fmt.Errorf("beacon with ID %s is not running on this daemon", beaconID)
Expand Down
Loading
Loading