Skip to content

Commit

Permalink
rebase issues and a hidden compilation prob
Browse files Browse the repository at this point in the history
  • Loading branch information
CluEleSsUK committed Jan 9, 2024
1 parent 18cdb35 commit 34a02df
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
2 changes: 0 additions & 2 deletions demo/lib/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,6 @@ func (e *Orchestrator) RunResharing(resharingGroup *ResharingGroup, timeout time
leader := e.reshareNodes[0]

// if the transition time is in the past, the DKG will fail, so it needs to be long enough to complete the DKG
roundInOneMinute := common.CurrentRound(time.Now().Add(1*time.Minute).Unix(), e.periodD, e.genesis)
transitionTime := common.TimeOfRound(e.periodD, e.genesis, roundInOneMinute)
catchupPeriod := 0
err := leader.StartLeaderReshare(e.newThr, catchupPeriod, resharingGroup.joining, resharingGroup.remaining, resharingGroup.leaving)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion demo/node/node_inprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (l *LocalNode) ExecuteLeaderDKG() error {
}

func (l *LocalNode) WaitDKGComplete(epoch uint32, timeout time.Duration) (*key.Group, error) {
err := l.dkgRunner.WaitForDKG(l.log, l.beaconID, epoch, int(timeout.Seconds()))
err := l.dkgRunner.WaitForDKG(l.log, epoch, int(timeout.Seconds()))
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions internal/core/drand_daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ type DrandDaemon struct {
}

type DKGProcess interface {
DKGStatus(context context.Context, request *drand.DKGStatusRequest) (*drand.DKGStatusResponse, error)
Command(context context.Context, command *drand.DKGCommand) (*drand.EmptyDKGResponse, error)
Packet(context context.Context, packet *drand.GossipPacket) (*drand.EmptyDKGResponse, error)
DKGStatus(context context.Context, request *pdkg.DKGStatusRequest) (*pdkg.DKGStatusResponse, error)
Command(context context.Context, command *pdkg.DKGCommand) (*pdkg.EmptyDKGResponse, error)
Packet(context context.Context, packet *pdkg.GossipPacket) (*pdkg.EmptyDKGResponse, error)
Migrate(beaconID string, group *key.Group, share *key.Share) error
BroadcastDKG(context context.Context, packet *drand.DKGPacket) (*drand.EmptyDKGResponse, error)
BroadcastDKG(context context.Context, packet *pdkg.DKGPacket) (*pdkg.EmptyDKGResponse, error)
Close()
}

Expand Down
46 changes: 23 additions & 23 deletions internal/dkg/dkg_error_recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/drand/drand/crypto"
"github.com/drand/drand/internal/net"
"github.com/drand/drand/internal/util"
"github.com/drand/drand/protobuf/drand"
"github.com/drand/drand/protobuf/dkg"

clock "github.com/jonboulle/clockwork"
"github.com/stretchr/testify/require"
Expand All @@ -27,7 +27,7 @@ func TestDKGFailedAtProtocol(t *testing.T) {
mb := newMessageBus()

nodes := make([]*stubbedDKGProcess, nodeCount)
identities := make([]*drand.Participant, nodeCount)
identities := make([]*dkg.Participant, nodeCount)
for i := 0; i < nodeCount; i++ {
stub, err := newStubbedDKGProcess(t, fmt.Sprintf("a:888%d", i), mb)
require.NoError(t, err)
Expand Down Expand Up @@ -59,7 +59,7 @@ func TestDKGFailedAtProtocol(t *testing.T) {
require.Error(t, ErrDKGFailed, err)

// we then check there are still no 'completed' DKGs
failedStatus, err := leader.DKGStatus(context.Background(), &drand.DKGStatusRequest{BeaconID: beaconID})
failedStatus, err := leader.DKGStatus(context.Background(), &dkg.DKGStatusRequest{BeaconID: beaconID})
require.NoError(t, err)
require.Equal(t, Failed.String(), Status(failedStatus.Current.State).String())
require.Nil(t, failedStatus.Complete)
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestDKGFailedAtProtocol(t *testing.T) {
require.NoError(t, err)

// the leader reports the DKG is complete
successfulStatus, err := leader.DKGStatus(context.Background(), &drand.DKGStatusRequest{BeaconID: beaconID})
successfulStatus, err := leader.DKGStatus(context.Background(), &dkg.DKGStatusRequest{BeaconID: beaconID})
require.NoError(t, err)
require.Equal(t, Complete.String(), Status(successfulStatus.Current.State).String())
require.Equal(t, Complete.String(), Status(successfulStatus.Complete.State).String())
Expand All @@ -101,7 +101,7 @@ func TestFailedReshare(t *testing.T) {
mb := newMessageBus()

nodes := make([]*stubbedDKGProcess, nodeCount)
identities := make([]*drand.Participant, nodeCount)
identities := make([]*dkg.Participant, nodeCount)
for i := 0; i < nodeCount; i++ {
stub, err := newStubbedDKGProcess(t, fmt.Sprintf("a:888%d", i), mb)
require.NoError(t, err)
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestFailedReshare(t *testing.T) {

err = leader.runner.WaitForDKG(log.DefaultLogger(), 2, 60)
require.Error(t, ErrDKGFailed, err)
status, err := leader.delegate.DKGStatus(context.Background(), &drand.DKGStatusRequest{BeaconID: beaconID})
status, err := leader.delegate.DKGStatus(context.Background(), &dkg.DKGStatusRequest{BeaconID: beaconID})
require.NoError(t, err)
require.Equal(t, uint32(1), status.Complete.Epoch)
}
Expand All @@ -162,25 +162,25 @@ func (s stubbedBeacon) KeypairFor(_ string) (*key.Pair, error) {

// messageBus manages messaging between DKG processes without having to actually use gRPC
type messageBus struct {
listeners map[string]drand.DKGControlClient
listeners map[string]dkg.DKGControlClient
}

func newMessageBus() *messageBus {
return &messageBus{
listeners: make(map[string]drand.DKGControlClient),
listeners: make(map[string]dkg.DKGControlClient),
}
}

func (m *messageBus) Add(address string, process drand.DKGControlClient) {
func (m *messageBus) Add(address string, process dkg.DKGControlClient) {
m.listeners[address] = process
}

func (m *messageBus) Packet(
_ context.Context,
p net.Peer,
packet *drand.GossipPacket,
packet *dkg.GossipPacket,
_ ...grpc.CallOption,
) (*drand.EmptyDKGResponse, error) {
) (*dkg.EmptyDKGResponse, error) {
listener := m.listeners[p.Address()]
if listener == nil {
return nil, errors.New("no such address")
Expand All @@ -191,9 +191,9 @@ func (m *messageBus) Packet(
func (m *messageBus) BroadcastDKG(
_ context.Context,
p net.Peer,
in *drand.DKGPacket,
in *dkg.DKGPacket,
_ ...grpc.CallOption,
) (*drand.EmptyDKGResponse, error) {
) (*dkg.EmptyDKGResponse, error) {
listener := m.listeners[p.Address()]
if listener == nil {
return nil, errors.New("no such address")
Expand All @@ -212,11 +212,11 @@ type stubbedDKGProcess struct {
}

type RealProcess interface {
DKGStatus(context context.Context, request *drand.DKGStatusRequest) (*drand.DKGStatusResponse, error)
Command(context context.Context, command *drand.DKGCommand) (*drand.EmptyDKGResponse, error)
Packet(context context.Context, packet *drand.GossipPacket) (*drand.EmptyDKGResponse, error)
DKGStatus(context context.Context, request *dkg.DKGStatusRequest) (*dkg.DKGStatusResponse, error)
Command(context context.Context, command *dkg.DKGCommand) (*dkg.EmptyDKGResponse, error)
Packet(context context.Context, packet *dkg.GossipPacket) (*dkg.EmptyDKGResponse, error)
Migrate(beaconID string, group *key.Group, share *key.Share) error
BroadcastDKG(context context.Context, packet *drand.DKGPacket) (*drand.EmptyDKGResponse, error)
BroadcastDKG(context context.Context, packet *dkg.DKGPacket) (*dkg.EmptyDKGResponse, error)
Close()
}

Expand Down Expand Up @@ -269,21 +269,21 @@ func (p *stubbedDKGProcess) Fix() {

func (p *stubbedDKGProcess) DKGStatus(
ctx context.Context,
request *drand.DKGStatusRequest,
request *dkg.DKGStatusRequest,
_ ...grpc.CallOption,
) (*drand.DKGStatusResponse, error) {
) (*dkg.DKGStatusResponse, error) {
p.lock.Lock()
defer p.lock.Unlock()
return p.delegate.DKGStatus(ctx, request)
}

func (p *stubbedDKGProcess) Command(ctx context.Context, command *drand.DKGCommand, _ ...grpc.CallOption) (*drand.EmptyDKGResponse, error) {
func (p *stubbedDKGProcess) Command(ctx context.Context, command *dkg.DKGCommand, _ ...grpc.CallOption) (*dkg.EmptyDKGResponse, error) {
p.lock.Lock()
defer p.lock.Unlock()
return p.delegate.Command(ctx, command)
}

func (p *stubbedDKGProcess) Packet(ctx context.Context, packet *drand.GossipPacket, _ ...grpc.CallOption) (*drand.EmptyDKGResponse, error) {
func (p *stubbedDKGProcess) Packet(ctx context.Context, packet *dkg.GossipPacket, _ ...grpc.CallOption) (*dkg.EmptyDKGResponse, error) {
p.lock.Lock()
defer p.lock.Unlock()
if p.broken {
Expand All @@ -299,9 +299,9 @@ func (p *stubbedDKGProcess) Migrate(beaconID string, group *key.Group, share *ke

func (p *stubbedDKGProcess) BroadcastDKG(
ctx context.Context,
packet *drand.DKGPacket,
packet *dkg.DKGPacket,
_ ...grpc.CallOption,
) (*drand.EmptyDKGResponse, error) {
) (*dkg.EmptyDKGResponse, error) {
p.lock.Lock()
defer p.lock.Unlock()
if p.broken {
Expand Down

0 comments on commit 34a02df

Please sign in to comment.