Skip to content

Commit

Permalink
[BFT Testing] Adds orchestrator interface and attack network (#2109)
Browse files Browse the repository at this point in the history
* adds attack orchestrator interface

* adds attack network interface

* adds attack orchestrator

* adds mocks
  • Loading branch information
yhassanzadeh13 committed Mar 8, 2022
1 parent 879ae0a commit a3a7ad8
Show file tree
Hide file tree
Showing 5 changed files with 291 additions and 0 deletions.
21 changes: 21 additions & 0 deletions insecure/attackNetwork.go
@@ -0,0 +1,21 @@
package insecure

import (
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/component"
"github.com/onflow/flow-go/network"
)

// AttackNetwork represents the networking interface that is available to the attacker for sending messages "through" corrupted nodes
// "to" the rest of the network.
type AttackNetwork interface {
component.Component
// RpcUnicastOnChannel enforces unicast-dissemination on the specified channel through a corrupted node.
RpcUnicastOnChannel(flow.Identifier, network.Channel, interface{}, flow.Identifier) error

// RpcPublishOnChannel enforces a publish-dissemination on the specified channel through a corrupted node.
RpcPublishOnChannel(flow.Identifier, network.Channel, interface{}, ...flow.Identifier) error

// RpcMulticastOnChannel enforces a multicast-dissemination on the specified channel through a corrupted node.
RpcMulticastOnChannel(flow.Identifier, network.Channel, interface{}, uint32, ...flow.Identifier) error
}
18 changes: 18 additions & 0 deletions insecure/attackOrchestrator.go
@@ -0,0 +1,18 @@
package insecure

import (
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/component"
"github.com/onflow/flow-go/network"
)

// AttackOrchestrator represents the stateful interface that implements a certain type of attack, e.g., wintermute attack.
type AttackOrchestrator interface {
component.Component

// HandleEventFromCorruptedNode implements logic of processing the events received from a corrupted node.
//
// In Corruptible Conduit Framework for BFT testing, corrupted nodes relay their outgoing events to
// the attacker instead of dispatching them to the network.
HandleEventFromCorruptedNode(flow.Identifier, network.Channel, interface{}, Protocol, uint32, ...flow.Identifier) error
}
111 changes: 111 additions & 0 deletions insecure/mock/attack_network.go

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

77 changes: 77 additions & 0 deletions insecure/mock/attack_orchestrator.go

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

64 changes: 64 additions & 0 deletions insecure/wintermute/attackOrchestrator.go
@@ -0,0 +1,64 @@
package wintermute

import (
"github.com/rs/zerolog"

"github.com/onflow/flow-go/insecure"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/component"
"github.com/onflow/flow-go/module/irrecoverable"
"github.com/onflow/flow-go/network"
)

// Orchestrator encapsulates a stateful implementation of wintermute attack orchestrator logic.
type Orchestrator struct {
component.Component
logger zerolog.Logger
network insecure.AttackNetwork
corruptedIds flow.IdentityList
allIds flow.IdentityList // identity of all nodes in the network (including non-corrupted ones)
}

var _ insecure.AttackOrchestrator = &Orchestrator{}

func NewOrchestrator(allIds flow.IdentityList, corruptedIds flow.IdentityList, attackNetwork insecure.AttackNetwork, logger zerolog.Logger) *Orchestrator {
o := &Orchestrator{
logger: logger,
network: attackNetwork,
corruptedIds: corruptedIds,
allIds: allIds,
}

cm := component.NewComponentManagerBuilder().
AddWorker(func(ctx irrecoverable.SignalerContext, ready component.ReadyFunc) {
o.start(ctx)

ready()

<-ctx.Done()
}).Build()

o.Component = cm

return o
}

// start performs the startup of orchestrator components.
func (o *Orchestrator) start(ctx irrecoverable.SignalerContext) {
o.network.Start(ctx)
}

// HandleEventFromCorruptedNode implements logic of processing the events received from a corrupted node.
//
// In Corruptible Conduit Framework for BFT testing, corrupted nodes relay their outgoing events to
// the attacker instead of dispatching them to the network.
func (o *Orchestrator) HandleEventFromCorruptedNode(corruptedId flow.Identifier,
channel network.Channel,
event interface{},
protocol insecure.Protocol,
num uint32,
targetIds ...flow.Identifier) error {

// TODO: implement wintermute attack logic.
panic("implement me")
}

0 comments on commit a3a7ad8

Please sign in to comment.