Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BFT Testing] Adds orchestrator interface and attack network (#2109)
* adds attack orchestrator interface * adds attack network interface * adds attack orchestrator * adds mocks
- Loading branch information
1 parent
879ae0a
commit a3a7ad8
Showing
5 changed files
with
291 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |