Skip to content

Commit

Permalink
cmd/bench: Use "pseudo" implementation for Crypto module
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Fedorov committed Sep 19, 2022
1 parent e4b1fb4 commit 0732302
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cmd/bench/cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/filecoin-project/mir/pkg/availability/batchdb/fakebatchdb"
"github.com/filecoin-project/mir/pkg/availability/multisigcollector"
"github.com/filecoin-project/mir/pkg/batchfetcher"
mirCrypto "github.com/filecoin-project/mir/pkg/crypto"
"github.com/filecoin-project/mir/pkg/deploytest"
"github.com/filecoin-project/mir/pkg/iss"
"github.com/filecoin-project/mir/pkg/logging"
"github.com/filecoin-project/mir/pkg/membership"
Expand Down Expand Up @@ -163,17 +163,14 @@ func runNode() error {
// retrieves the corresponding transaction batches, and delivers them to the application.
batchFetcher := batchfetcher.NewModule(batchfetcher.DefaultModuleConfig())

// Use dummy crypto module that only produces signatures
// consisting of a single zero byte and treats those signatures as valid.
// TODO: Adjust once a default crypto implementation is provided by Mir.
crypto := mirCrypto.New(&mirCrypto.DummyCrypto{DummySig: []byte{0}})
cryptoSystem := deploytest.NewLocalCryptoSystem("pseudo", membership.GetIDs(initialMembership), logger)

stats := NewStats()
interceptor := NewStatInterceptor(stats, "app")

nodeModules, err := iss.DefaultModules(modules.Modules{
"net": transport,
"crypto": crypto,
"crypto": cryptoSystem.Module(ownID),
"iss": issProtocol,
"app": &App{Logger: logger, ProtocolModule: "iss", Membership: nodeAddrs},
"batchfetcher": batchFetcher,
Expand Down
8 changes: 8 additions & 0 deletions pkg/membership/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ func GetIPs(membership map[t.NodeID]t.NodeAddress) (map[t.NodeID]string, error)
return ips, nil
}

func GetIDs(membership map[t.NodeID]t.NodeAddress) []t.NodeID {
ids := make([]t.NodeID, 0, len(membership))
for nodeID := range membership {
ids = append(ids, nodeID)
}
return ids
}

// DummyMultiAddrs returns a set of libp2p multiaddresses based on the given membership,
// generating host keys deterministically based on node IDs.
// The node IDs must be convertable to numbers, otherwise DummyMultiAddrs returns an error.
Expand Down

0 comments on commit 0732302

Please sign in to comment.