From 1ff4796d5cb6ec9a83d4200a72990da94d262ad8 Mon Sep 17 00:00:00 2001 From: Matej Pavlovic Date: Thu, 4 Apr 2024 00:40:05 +0200 Subject: [PATCH 1/2] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5b410cfbe..d729abdb7 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,8 @@ The first intended use of Mir is as a scalable and efficient and, potentially, as a Byzantine fault-tolerant ordering service in Hyperledger Fabric. However, Mir hopes to be a building block of a next generation of distributed systems, being used by many applications. -Currently Mir includes an implementation of the [Trantor](/pkg/trantor) modular state machine replication system, -but work is under way to bring other protocols into Mir such as -[Granite](#515) and -[Alea-BFT](https://github.com/abread/mir/tree/alea/pkg/alea). +Currently Mir includes an implementation of the [Trantor](/pkg/trantor) modular state machine replication system. +It has also been used to implement and evaluate the [Alea-BFT protocol](https://github.com/abread/mir/tree/alea/pkg/alea). ## Nodes, Modules, and Events From 7dc28ff057295c146a795bce786aa96a477401a5 Mon Sep 17 00:00:00 2001 From: Matej Pavlovic Date: Thu, 4 Apr 2024 01:01:18 +0200 Subject: [PATCH 2/2] Rename unused parameters (for linter) Signed-off-by: Matej Pavlovic --- cmd/bench/cmd/client.go | 2 +- cmd/bench/cmd/node.go | 2 +- cmd/bench/cmd/params.go | 2 +- codegen/generators/dsl-gen/generator/events.go | 2 +- codegen/model/types/field.go | 6 +++--- node_test.go | 2 +- .../internal/parts/certverification/certverification.go | 2 +- pkg/batchfetcher/batchfetcher.go | 2 +- pkg/bcb/bcbmodule.go | 4 ++-- pkg/checkpoint/serializing_fuzz_test.go | 4 ++-- pkg/deploytest/localtransport.go | 2 +- pkg/dsl/test/dslmodule_test.go | 8 ++++---- pkg/eventlog/recorder.go | 2 +- pkg/iss/iss.go | 2 +- .../internal/parts/formbatchesint/formbatches.go | 4 ++-- pkg/orderers/internal/parts/catchup/catchup.go | 2 +- pkg/trantor/testing/smr_test.go | 2 +- pkg/util/indexedlist/indexedlist_test.go | 6 +++--- 18 files changed, 28 insertions(+), 28 deletions(-) diff --git a/cmd/bench/cmd/client.go b/cmd/bench/cmd/client.go index 53c4128e0..4bd16441b 100644 --- a/cmd/bench/cmd/client.go +++ b/cmd/bench/cmd/client.go @@ -39,7 +39,7 @@ var ( clientCmd = &cobra.Command{ Use: "client", Short: "Generate and submit transactions to a Mir cluster", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, _ []string) error { return runClient() }, } diff --git a/cmd/bench/cmd/node.go b/cmd/bench/cmd/node.go index 1207f85ee..964af57ff 100644 --- a/cmd/bench/cmd/node.go +++ b/cmd/bench/cmd/node.go @@ -49,7 +49,7 @@ var ( nodeCmd = &cobra.Command{ Use: "node", Short: "Start a Mir node", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, _ []string) error { if err := runNode(); !es.Is(err, mir.ErrStopped) { return err } diff --git a/cmd/bench/cmd/params.go b/cmd/bench/cmd/params.go index 8f464e2f9..9907b023f 100644 --- a/cmd/bench/cmd/params.go +++ b/cmd/bench/cmd/params.go @@ -34,7 +34,7 @@ var ( paramsCmd = &cobra.Command{ Use: "params", Short: "generate parameters", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { return generateParams(args) }, } diff --git a/codegen/generators/dsl-gen/generator/events.go b/codegen/generators/dsl-gen/generator/events.go index a8607f2ea..d66b06e5e 100644 --- a/codegen/generators/dsl-gen/generator/events.go +++ b/codegen/generators/dsl-gen/generator/events.go @@ -317,7 +317,7 @@ func generateDslFunctionForHandlingSimpleEvent(eventNode *events.EventNode, upon func GetDslOriginOption(origin *events.Origin) (*types.OneofOption, bool) { return sliceutil.Any( - sliceutil.Filter(origin.TypeOneof.Options, func(i int, opt *types.OneofOption) bool { + sliceutil.Filter(origin.TypeOneof.Options, func(_ int, opt *types.OneofOption) bool { return opt.Name() == "Dsl" }), ) diff --git a/codegen/model/types/field.go b/codegen/model/types/field.go index 591366201..a69887365 100644 --- a/codegen/model/types/field.go +++ b/codegen/model/types/field.go @@ -46,17 +46,17 @@ type Fields []*Field // FuncParamsPbTypes returns a list of field lowercase names followed by their pb types. func (fs Fields) FuncParamsPbTypes() []jen.Code { - return sliceutil.Transform(fs, func(i int, f *Field) jen.Code { return f.FuncParamPbType() }) + return sliceutil.Transform(fs, func(_ int, f *Field) jen.Code { return f.FuncParamPbType() }) } // FuncParamsMirTypes returns a list of field lowercase names followed by their mir types. func (fs Fields) FuncParamsMirTypes() []jen.Code { - return sliceutil.Transform(fs, func(i int, f *Field) jen.Code { return f.FuncParamMirType() }) + return sliceutil.Transform(fs, func(_ int, f *Field) jen.Code { return f.FuncParamMirType() }) } // FuncParamsIDs returns a list of fields lowercase names as identifiers, without the types. func (fs Fields) FuncParamsIDs() []jen.Code { - return sliceutil.Transform(fs, func(i int, f *Field) jen.Code { return jen.Id(f.LowercaseName()) }) + return sliceutil.Transform(fs, func(_ int, f *Field) jen.Code { return jen.Id(f.LowercaseName()) }) } // ByName returns the field with the given name (or nil if there is no such field). diff --git a/node_test.go b/node_test.go index ea393d060..e3a0850d7 100644 --- a/node_test.go +++ b/node_test.go @@ -273,7 +273,7 @@ func (c *consumer) ImplementsModule() {} // ApplyEvents increments a counter and sleeps for a given duration (set at module instantiation) // for each event in the given list. func (c *consumer) ApplyEvents(evts *stdtypes.EventList) (*stdtypes.EventList, error) { - evtsOut, err := modules.ApplyEventsSequentially(evts, func(event stdtypes.Event) (*stdtypes.EventList, error) { + evtsOut, err := modules.ApplyEventsSequentially(evts, func(_ stdtypes.Event) (*stdtypes.EventList, error) { atomic.AddUint64(&c.numProcessed, 1) time.Sleep(c.delay) return stdtypes.EmptyList(), nil diff --git a/pkg/availability/multisigcollector/internal/parts/certverification/certverification.go b/pkg/availability/multisigcollector/internal/parts/certverification/certverification.go index 2b22fbd7b..30009f57c 100644 --- a/pkg/availability/multisigcollector/internal/parts/certverification/certverification.go +++ b/pkg/availability/multisigcollector/internal/parts/certverification/certverification.go @@ -81,7 +81,7 @@ func IncludeVerificationOfCertificates( }) // When the signatures in a certificate are verified, output the result of certificate verification. - cryptopbdsl.UponSigsVerified(m, func(nodeIDs []t.NodeID, errs []error, allOK bool, context *verifySigsInCertContext) error { + cryptopbdsl.UponSigsVerified(m, func(_ []t.NodeID, _ []error, allOK bool, context *verifySigsInCertContext) error { reqID := context.reqID if _, ok := state.RequestState[reqID]; !ok { diff --git a/pkg/batchfetcher/batchfetcher.go b/pkg/batchfetcher/batchfetcher.go index 8277ebcb3..52a88c8c9 100644 --- a/pkg/batchfetcher/batchfetcher.go +++ b/pkg/batchfetcher/batchfetcher.go @@ -87,7 +87,7 @@ func NewModule(mc ModuleConfig, epochNr tt.EpochNr, clientProgress *clientprogre // The DeliverCert handler requests the transactions referenced by the received availability certificate // from the availability layer. - isspbdsl.UponDeliverCert(m, func(sn tt.SeqNr, cert *apbtypes.Cert, empty bool) error { + isspbdsl.UponDeliverCert(m, func(_ tt.SeqNr, cert *apbtypes.Cert, empty bool) error { // Create an empty output item and enqueue it immediately. // Actual output will be delayed until the transactions have been received. // This is necessary to preserve the order of incoming and outgoing events. diff --git a/pkg/bcb/bcbmodule.go b/pkg/bcb/bcbmodule.go index 54fce0bc0..e9b1dac8b 100644 --- a/pkg/bcb/bcbmodule.go +++ b/pkg/bcb/bcbmodule.go @@ -94,7 +94,7 @@ func NewModule(mc ModuleConfig, params *ModuleParams, nodeID stdtypes.NodeID) mo return nil }) - cryptopbdsl.UponSignResult(m, func(signature []byte, context *signStartMessageContext) error { + cryptopbdsl.UponSignResult(m, func(signature []byte, _ *signStartMessageContext) error { if !state.sentEcho { state.sentEcho = true transportpbdsl.SendMessage(m, mc.Net, bcbpbmsgs.EchoMessage(mc.Self, signature), []stdtypes.NodeID{params.Leader}) @@ -133,7 +133,7 @@ func NewModule(mc ModuleConfig, params *ModuleParams, nodeID stdtypes.NodeID) mo }) // upon event do - bcbpbdsl.UponFinalMessageReceived(m, func(from stdtypes.NodeID, data []byte, signers []stdtypes.NodeID, signatures [][]byte) error { + bcbpbdsl.UponFinalMessageReceived(m, func(_ stdtypes.NodeID, data []byte, signers []stdtypes.NodeID, signatures [][]byte) error { // if #({p ∈ Π | Σ[p] != ⊥ ∧ verifysig(p, bcb||p||ECHO||m, Σ[p])}) > (N+f)/2 and delivered = FALSE do if len(signers) == len(signatures) && len(signers) > (params.GetN()+params.GetF())/2 && !state.delivered { signedMessage := [][]byte{params.InstanceUID, []byte("ECHO"), data} diff --git a/pkg/checkpoint/serializing_fuzz_test.go b/pkg/checkpoint/serializing_fuzz_test.go index 65e602646..62211a7e1 100644 --- a/pkg/checkpoint/serializing_fuzz_test.go +++ b/pkg/checkpoint/serializing_fuzz_test.go @@ -15,7 +15,7 @@ import ( func FuzzCheckpointForSig(f *testing.F) { f.Add(uint64(0), uint64(0), []byte("13242342342342")) - f.Fuzz(func(t *testing.T, s, n uint64, data []byte) { + f.Fuzz(func(_ *testing.T, s, n uint64, data []byte) { serializeCheckpointForSig(tt.EpochNr(s), tt.SeqNr(n), data) }) } @@ -23,7 +23,7 @@ func FuzzCheckpointForSig(f *testing.F) { func FuzzSnapshotForHash(f *testing.F) { f.Add(100, uint64(0), "/ip4/7.7.7.7/tcp/1234/p2p/QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N", "127.0.0.1:3333", []byte("13242342342342")) - f.Fuzz(func(t *testing.T, n int, e uint64, k, v string, data []byte) { + f.Fuzz(func(_ *testing.T, n int, e uint64, k, v string, data []byte) { n = n % 5000 membership := trantorpbtypes.Membership{make(map[stdtypes.NodeID]*trantorpbtypes.NodeIdentity)} // nolint:govet diff --git a/pkg/deploytest/localtransport.go b/pkg/deploytest/localtransport.go index 894a70ab5..6fb0d7782 100644 --- a/pkg/deploytest/localtransport.go +++ b/pkg/deploytest/localtransport.go @@ -25,7 +25,7 @@ type LocalTransportLayer interface { func NewLocalTransportLayer(sim *Simulation, transportType string, nodeIDsWeight map[t.NodeID]types.VoteWeight, logger logging.Logger) (LocalTransportLayer, error) { switch transportType { case "sim": - messageDelayFn := func(from, to t.NodeID) time.Duration { + messageDelayFn := func(_, _ t.NodeID) time.Duration { // TODO: Make min and max message delay configurable return testsim.RandDuration(sim.Rand, 0, 10*time.Millisecond) } diff --git a/pkg/dsl/test/dslmodule_test.go b/pkg/dsl/test/dslmodule_test.go index f4f5193b0..dc0da97d0 100644 --- a/pkg/dsl/test/dslmodule_test.go +++ b/pkg/dsl/test/dslmodule_test.go @@ -283,7 +283,7 @@ func newContextTestingModule(mc *contextTestingModuleModuleConfig) dsl.Module { return nil }) - cryptopbdsl.UponSigsVerified(m, func(nodeIDs []stdtypes.NodeID, errs []error, allOK bool, context *uint64) error { + cryptopbdsl.UponSigsVerified(m, func(nodeIDs []stdtypes.NodeID, _ []error, allOK bool, context *uint64) error { if allOK { for _, nodeID := range nodeIDs { EmitTestingString(m, mc.Verified, fmt.Sprintf("%v: %v verified", *context, nodeID)) @@ -292,7 +292,7 @@ func newContextTestingModule(mc *contextTestingModuleModuleConfig) dsl.Module { return nil }) - cryptopbdsl.UponSigsVerified(m, func(nodeIDs []stdtypes.NodeID, errs []error, allOK bool, context *uint64) error { + cryptopbdsl.UponSigsVerified(m, func(_ []stdtypes.NodeID, _ []error, allOK bool, context *uint64) error { if allOK { EmitTestingUint(m, mc.Verified, *context) } @@ -304,7 +304,7 @@ func newContextTestingModule(mc *contextTestingModuleModuleConfig) dsl.Module { func TestDslModule_ContextRecoveryAndCleanup(t *testing.T) { testCases := map[string]func(mc *contextTestingModuleModuleConfig, m dsl.Module){ - "empty": func(mc *contextTestingModuleModuleConfig, m dsl.Module) {}, + "empty": func(_ *contextTestingModuleModuleConfig, _ dsl.Module) {}, "request response": func(mc *contextTestingModuleModuleConfig, m dsl.Module) { eventsOut, err := m.ApplyEvents(stdtypes.ListOf(stdevents.NewTestString(mc.Self, "hello"))) @@ -404,7 +404,7 @@ func TestDslModule_ContextRecoveryAndCleanup(t *testing.T) { for testName, tc := range testCases { tc := tc - t.Run(testName, func(t *testing.T) { + t.Run(testName, func(_ *testing.T) { mc := defaultContextTestingModuleConfig() m := newContextTestingModule(mc) tc(mc, m) diff --git a/pkg/eventlog/recorder.go b/pkg/eventlog/recorder.go index 351ea93da..46e7cfe36 100644 --- a/pkg/eventlog/recorder.go +++ b/pkg/eventlog/recorder.go @@ -91,7 +91,7 @@ func NewRecorder( fileCount: 1, newDests: OneFileLogger(), path: path, - filter: func(event stdtypes.Event) bool { + filter: func(_ stdtypes.Event) bool { // Record all events by default. return true }, diff --git a/pkg/iss/iss.go b/pkg/iss/iss.go index 83db6a1a6..c933043f8 100644 --- a/pkg/iss/iss.go +++ b/pkg/iss/iss.go @@ -429,7 +429,7 @@ func New( }) chkppbdsl.UponStableCheckpointReceived(iss.m, - func(sender stdtypes.NodeID, sn tt.SeqNr, snapshot *trantorpbtypes.StateSnapshot, cert map[stdtypes.NodeID][]byte) error { + func(_ stdtypes.NodeID, sn tt.SeqNr, snapshot *trantorpbtypes.StateSnapshot, cert map[stdtypes.NodeID][]byte) error { chkp := &checkpointpbtypes.StableCheckpoint{ Sn: sn, Snapshot: snapshot, diff --git a/pkg/mempool/simplemempool/internal/parts/formbatchesint/formbatches.go b/pkg/mempool/simplemempool/internal/parts/formbatchesint/formbatches.go index 08a52fccb..51dbb7c21 100644 --- a/pkg/mempool/simplemempool/internal/parts/formbatchesint/formbatches.go +++ b/pkg/mempool/simplemempool/internal/parts/formbatchesint/formbatches.go @@ -109,7 +109,7 @@ func IncludeBatchCreation( // nolint:gocognit batchSize := 0 txCount := 0 - txIDs, txs, _ := state.Iterator.NextWhile(func(txID tt.TxID, tx *trantorpbtypes.Transaction) bool { + txIDs, txs, _ := state.Iterator.NextWhile(func(_ tt.TxID, tx *trantorpbtypes.Transaction) bool { if txCount < params.MaxTransactionsInBatch && batchSize+len(tx.Data) <= params.MaxPayloadInBatch { txCount++ state.NumUnproposed-- @@ -176,7 +176,7 @@ func IncludeBatchCreation( // nolint:gocognit // ClientProgress - for each client, list of pending transactions sorted by TxNo - that // would make pruning significantly more efficient. state.ClientProgress.LoadPb(clientProgress.Pb()) - _, removedTXs := state.Transactions.RemoveSelected(func(txID tt.TxID, tx *trantorpbtypes.Transaction) bool { + _, removedTXs := state.Transactions.RemoveSelected(func(_ tt.TxID, tx *trantorpbtypes.Transaction) bool { return state.ClientProgress.Contains(tx.ClientId, tx.TxNo) }) for _, tx := range removedTXs { diff --git a/pkg/orderers/internal/parts/catchup/catchup.go b/pkg/orderers/internal/parts/catchup/catchup.go index 7e8783c65..48b00b7d8 100644 --- a/pkg/orderers/internal/parts/catchup/catchup.go +++ b/pkg/orderers/internal/parts/catchup/catchup.go @@ -268,7 +268,7 @@ func SendDoneMessages( // Collect the preprepare digests of all committed certificates. digests := make([][]byte, 0, state.Segment.Len()) - maputil.IterateSorted(state.Slots[state.View], func(sn tt.SeqNr, slot *common.PbftSlot) bool { + maputil.IterateSorted(state.Slots[state.View], func(_ tt.SeqNr, slot *common.PbftSlot) bool { digests = append(digests, slot.Digest) return true }) diff --git a/pkg/trantor/testing/smr_test.go b/pkg/trantor/testing/smr_test.go index 2d0c5883d..2819b4f39 100644 --- a/pkg/trantor/testing/smr_test.go +++ b/pkg/trantor/testing/smr_test.go @@ -427,7 +427,7 @@ func newDeployment(conf *TestConfig) (*deploytest.Deployment, error) { var simulation *deploytest.Simulation if conf.Transport == simTransportName { r := rand.New(rand.NewSource(conf.RandomSeed)) // nolint: gosec - eventDelayFn := func(e stdtypes.Event) time.Duration { + eventDelayFn := func(_ stdtypes.Event) time.Duration { // TODO: Make min and max event processing delay configurable return testsim.RandDuration(r, 0, time.Microsecond) } diff --git a/pkg/util/indexedlist/indexedlist_test.go b/pkg/util/indexedlist/indexedlist_test.go index 3707840e3..9b2f47384 100644 --- a/pkg/util/indexedlist/indexedlist_test.go +++ b/pkg/util/indexedlist/indexedlist_test.go @@ -80,7 +80,7 @@ func TestIndexedList_RemoveSelected(t *testing.T) { il.Append([]string{"a", "b", "c"}, []int{0, 1, 2}) assert.Equal(t, 3, il.Len()) - keys, vals := il.RemoveSelected(func(key string, val int) bool { + keys, vals := il.RemoveSelected(func(key string, _ int) bool { return key == "b" || key == "c" }) assert.Equal(t, []string{"b", "c"}, keys) @@ -149,7 +149,7 @@ func TestIterator_NextWhile(t *testing.T) { // Condition allowing all elements to be traversed. iter := il.Iterator(0) sum := 0 - keys, vals, ok := iter.NextWhile(func(key string, val int) bool { + keys, vals, ok := iter.NextWhile(func(_ string, val int) bool { if sum+val <= 10 { sum += val return true @@ -171,7 +171,7 @@ func TestIterator_NextWhile(t *testing.T) { // Condition allowing only part of the elements to be traversed. iter = il.Iterator(0) sum = 0 - keys, vals, ok = iter.NextWhile(func(key string, val int) bool { + keys, vals, ok = iter.NextWhile(func(_ string, val int) bool { if sum+val <= 1 { sum += val return true