Skip to content

Commit

Permalink
Merge #1333
Browse files Browse the repository at this point in the history
1333: Fixes some build issues when importing `flow-go` as a dependency r=jordanschalm a=jordanschalm

This fixes 2 build issues when using `flow-go` as a dependency.

1. The dkg controller factory mock did not have a relic build tag set, but made use of a relic-tagged interface. Solution: Move the interface to a non-relic-tagged file.
```
../flow-go/module/mock/dkg_controller_factory.go:18:108: undefined: module.DKGController
../flow-go/module/mock/dkg_controller_factory.go:21:9: undefined: module.DKGController
../flow-go/module/mock/dkg_controller_factory.go:22:67: undefined: module.DKGController
../flow-go/module/mock/dkg_controller_factory.go:26:21: undefined: module.DKGController
```
2. The networking layer imported a function which did not exist in the `crypto` version pinned by `flow-go`. For local development this worked, because we replace with the local `crypto` module, but failed when used as a dependency.
```
../flow-go/network/p2p/keyutils/keyTranslator.go:169:14: undefined: "github.com/onflow/flow-go/crypto".DecodePublicKeyCompressed
```

Co-authored-by: Jordan Schalm <jordan@dapperlabs.com>
  • Loading branch information
bors[bot] and jordanschalm committed Sep 22, 2021
2 parents 864fc75 + 607b0fe commit ee53c83
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 42 deletions.
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()
}

0 comments on commit ee53c83

Please sign in to comment.