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

Fixes some build issues when importing flow-go as a dependency #1333

Merged
merged 7 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions engine/consensus/dkg/reactor_engine_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dkg
package dkg_test

import (
"math/rand"
Expand All @@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/onflow/flow-go/engine/consensus/dkg"
dkgmodel "github.com/onflow/flow-go/model/dkg"
"github.com/onflow/flow-go/model/flow"
dkgmodule "github.com/onflow/flow-go/module/dkg"
Expand Down Expand Up @@ -52,7 +53,7 @@ func TestEpochSetup(t *testing.T) {
// create a block for each view of interest
blocks := make(map[uint64]*flow.Header)
var view uint64
for view = 100; view <= 250; view += DefaultPollStep {
for view = 100; view <= 250; view += dkg.DefaultPollStep {
header := unittest.BlockHeaderFixture()
header.View = view
blocks[view] = &header
Expand Down Expand Up @@ -116,7 +117,7 @@ func TestEpochSetup(t *testing.T) {
).Return(controller, nil)

viewEvents := gadgets.NewViews()
engine := NewReactorEngine(
engine := dkg.NewReactorEngine(
unittest.Logger(),
me,
state,
Expand All @@ -127,7 +128,7 @@ func TestEpochSetup(t *testing.T) {

engine.EpochSetupPhaseStarted(currentCounter, firstBlock)

for view = 100; view <= 250; view += DefaultPollStep {
for view = 100; view <= 250; view += dkg.DefaultPollStep {
viewEvents.BlockFinalized(blocks[view])
}

Expand Down Expand Up @@ -192,7 +193,7 @@ func TestReactorEngine_EpochCommittedPhaseStarted(t *testing.T) {
})
logger := zerolog.New(os.Stdout).Level(zerolog.WarnLevel).Hook(hook)

engine := NewReactorEngine(
engine := dkg.NewReactorEngine(
logger,
me,
state,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ require (
github.com/onflow/flow-core-contracts/lib/go/templates v0.7.9
github.com/onflow/flow-emulator v0.20.3
github.com/onflow/flow-go-sdk v0.21.0
github.com/onflow/flow-go/crypto v0.18.0
github.com/onflow/flow-go/crypto v0.21.3
github.com/onflow/flow/protobuf/go/flow v0.2.2
github.com/opentracing/opentracing-go v1.2.0
github.com/pelletier/go-toml v1.9.4 // indirect
Expand Down
2 changes: 1 addition & 1 deletion integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/onflow/flow-emulator v0.20.3
github.com/onflow/flow-go v0.18.0 // replaced by version on-disk
github.com/onflow/flow-go-sdk v0.21.0
github.com/onflow/flow-go/crypto v0.18.0 // replaced by version on-disk
github.com/onflow/flow-go/crypto v0.21.3 // replaced by version on-disk
github.com/onflow/flow/protobuf/go/flow v0.2.2
github.com/plus3it/gorecurcopy v0.0.1
github.com/prometheus/common v0.20.0 // indirect
Expand Down
37 changes: 2 additions & 35 deletions module/dkg.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build relic

package module

import (
Expand Down Expand Up @@ -49,10 +47,10 @@ type DKGController interface {
// encountered in one of the protocol phases.
Run() error

// EndPhase0 notifies the controller to end phase 1, and start phase 2.
// EndPhase1 notifies the controller to end phase 1, and start phase 2.
EndPhase1() error

// EndPhase1 notifies the controller to end phase 2, and start phase 3.
// EndPhase2 notifies the controller to end phase 2, and start phase 3.
EndPhase2() error

// End terminates the DKG state machine and records the artifacts.
Expand Down Expand Up @@ -85,34 +83,3 @@ type DKGControllerFactory interface {
// Create instantiates a new DKGController.
Create(dkgInstanceID string, participants flow.IdentityList, seed []byte) (DKGController, error)
}

// DKGBroker extends the crypto.DKGProcessor interface with methods that enable
// a controller to access the channel of incoming messages, and actively fetch
// new DKG broadcast messages.
type DKGBroker interface {
crypto.DKGProcessor

// GetIndex returns the index of this node in the DKG committee list.
GetIndex() int

// GetPrivateMsgCh returns the channel through which a user can receive
// incoming private DKGMessages.
GetPrivateMsgCh() <-chan messages.DKGMessage

// GetBroadcastMsgCh returns the channel through which a user can receive
// incoming broadcast DKGMessages.
GetBroadcastMsgCh() <-chan messages.DKGMessage

// Poll instructs the broker to actively fetch broadcast messages (ex. read
// from DKG smart contract). The messages will be forwarded through the
// broker's message channel (cf. GetMsgCh). The method does not return until
// all received messages are processed by the consumer.
Poll(referenceBlock flow.Identifier) error

// SubmitResult instructs the broker to publish the results of the DKG run
// (ex. publish to DKG smart contract).
SubmitResult(crypto.PublicKey, []crypto.PublicKey) error

// Shutdown causes the broker to stop listening and forwarding messages.
Shutdown()
}
40 changes: 40 additions & 0 deletions module/dkg_broker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// +build relic

package module

import (
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/model/messages"
)

// DKGBroker extends the crypto.DKGProcessor interface with methods that enable
// a controller to access the channel of incoming messages, and actively fetch
// new DKG broadcast messages.
type DKGBroker interface {
crypto.DKGProcessor

// GetIndex returns the index of this node in the DKG committee list.
GetIndex() int

// GetPrivateMsgCh returns the channel through which a user can receive
// incoming private DKGMessages.
GetPrivateMsgCh() <-chan messages.DKGMessage

// GetBroadcastMsgCh returns the channel through which a user can receive
// incoming broadcast DKGMessages.
GetBroadcastMsgCh() <-chan messages.DKGMessage

// Poll instructs the broker to actively fetch broadcast messages (ex. read
// from DKG smart contract). The messages will be forwarded through the
// broker's message channel (cf. GetMsgCh). The method does not return until
// all received messages are processed by the consumer.
Poll(referenceBlock flow.Identifier) error

// SubmitResult instructs the broker to publish the results of the DKG run
// (ex. publish to DKG smart contract).
SubmitResult(crypto.PublicKey, []crypto.PublicKey) error

// Shutdown causes the broker to stop listening and forwarding messages.
Shutdown()
}