Skip to content

Commit

Permalink
Parametrize availability layer sub-certificate limit
Browse files Browse the repository at this point in the history
The limit on the number of sub-certificates is not hard-coded to 5 any more,
but is a proper parameter of the Trantor system.

Some tests were designed before the code was even generalized to support
more than one sub-certificate (the limit effectively being 1) and stopped
working after the code supported 5 sub-certificates by default.
Tests that should have failed were passing due to this.

This test makes this limit a proper parameter that can be higher by default,
but still set to 1 in tests.

Details:
* Remove obsolete Certs field from MSC params
* Use parameter template for availability module
* Remove unused field in dynamic availability params
* Re-generate protobufs
* Set default subcert limit to 5, but test with 1

Signed-off-by: Matej Pavlovic <[email protected]>
  • Loading branch information
matejpavlovic authored Jul 3, 2023
1 parent 9c453ed commit c18d0c4
Show file tree
Hide file tree
Showing 40 changed files with 155 additions and 209 deletions.
2 changes: 0 additions & 2 deletions pkg/availability/multisigcollector/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package common

import (
msctypes "github.com/filecoin-project/mir/pkg/availability/multisigcollector/types"
mscpbtypes "github.com/filecoin-project/mir/pkg/pb/availabilitypb/mscpb/types"
cryptopbtypes "github.com/filecoin-project/mir/pkg/pb/cryptopb/types"
trantorpbtypes "github.com/filecoin-project/mir/pkg/pb/trantorpb/types"
t "github.com/filecoin-project/mir/pkg/types"
Expand Down Expand Up @@ -32,7 +31,6 @@ type ModuleConfig struct {
type ModuleParams struct {
InstanceUID []byte // unique identifier for this instance used to prevent replay attacks
Membership *trantorpbtypes.Membership // the list of participating nodes
Certs []*mscpbtypes.Cert // the list of generated certificates
Limit int // the maximum number of certificates to generate before a request is completed
MaxRequests int // the maximum number of requests to be provided by this module
}
Expand Down
31 changes: 22 additions & 9 deletions pkg/availability/multisigcollector/multisigcollector.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package multisigcollector

import (
"math"

"github.com/filecoin-project/mir/pkg/availability/multisigcollector/internal/parts/batchreconstruction"
"github.com/filecoin-project/mir/pkg/availability/multisigcollector/internal/parts/certcreation"
"github.com/filecoin-project/mir/pkg/availability/multisigcollector/internal/parts/certverification"
Expand All @@ -21,6 +23,16 @@ type ModuleConfig = common.ModuleConfig
// All replicas are expected to use identical module parameters.
type ModuleParams = common.ModuleParams

// DefaultParamsTemplate returns the availability module parameters structure partially filled with default values.
// Fields without a meaningful default value (like InstanceUID and Membership)
// are left empty (zero values for their corresponding type).
func DefaultParamsTemplate() ModuleParams {
return ModuleParams{
Limit: 5, // Number of sub-certificates in one availability certificate.
MaxRequests: math.MaxInt, // By default, have the availability module run (basically) forever.
}
}

// NewModule creates a new instance of the multisig collector module.
// Multisig collector is the simplest implementation of the availability layer.
// Whenever an availability certificate is requested, it pulls a batch from the mempool module,
Expand All @@ -35,7 +47,7 @@ func NewModule(mc ModuleConfig, params *ModuleParams, logger logging.Logger) (mo
return m, nil
}

func NewReconfigurableModule(mc ModuleConfig, logger logging.Logger) modules.PassiveModule {
func NewReconfigurableModule(mc ModuleConfig, paramsTemplate ModuleParams, logger logging.Logger) modules.PassiveModule {
if logger == nil {
logger = logging.ConsoleErrorLogger
}
Expand All @@ -54,17 +66,18 @@ func NewReconfigurableModule(mc ModuleConfig, logger logging.Logger) modules.Pas
submc := mc
submc.Self = mscID

// Fill in instance-specific parameters.
moduleParams := paramsTemplate
moduleParams.InstanceUID = []byte(mscID)
moduleParams.Membership = mscParams.Membership
moduleParams.MaxRequests = int(mscParams.MaxRequests)
// TODO: Use InstanceUIDs properly.
// (E.g., concatenate this with the instantiating protocol's InstanceUID when introduced.)

// Create a new instance of the multisig collector.
multisigCollector, err := NewModule(
submc,
&ModuleParams{
// TODO: Use InstanceUIDs properly.
// (E.g., concatenate this with the instantiating protocol's InstanceUID when introduced.)
InstanceUID: []byte(mscID),
Membership: mscParams.Membership,
Limit: int(mscParams.Limit),
MaxRequests: int(mscParams.MaxRequests),
},
&moduleParams,
logger,
)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/iss/iss.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ func (iss *ISS) initAvailability() {
Type: &factorypbtypes.GeneratorParams_MultisigCollector{
MultisigCollector: &mscpbtypes.InstanceParams{
Membership: iss.memberships[0],
Limit: 5, // hardcoded right now
MaxRequests: uint64(iss.Params.SegmentLength)},
},
},
Expand Down
3 changes: 1 addition & 2 deletions pkg/modules/mockmodules/internal/mock_internal/impl.mock.go

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

8 changes: 3 additions & 5 deletions pkg/net/grpc/grpctransport.pb.go

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

1 change: 0 additions & 1 deletion pkg/net/grpc/grpctransport_grpc.pb.go

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

10 changes: 4 additions & 6 deletions pkg/pb/apppb/apppb.pb.go

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

10 changes: 4 additions & 6 deletions pkg/pb/availabilitypb/availabilitypb.pb.go

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

10 changes: 4 additions & 6 deletions pkg/pb/availabilitypb/batchdbpb/batchdbpb.pb.go

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

46 changes: 17 additions & 29 deletions pkg/pb/availabilitypb/mscpb/mscpb.pb.go

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

3 changes: 0 additions & 3 deletions pkg/pb/availabilitypb/mscpb/types/types.mir.go

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

10 changes: 4 additions & 6 deletions pkg/pb/batchfetcherpb/batchfetcherpb.pb.go

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

10 changes: 4 additions & 6 deletions pkg/pb/bcbpb/bcbpb.pb.go

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

10 changes: 4 additions & 6 deletions pkg/pb/checkpointpb/checkpointpb.pb.go

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

8 changes: 3 additions & 5 deletions pkg/pb/contextstorepb/contextstorepb.pb.go

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

10 changes: 4 additions & 6 deletions pkg/pb/cryptopb/cryptopb.pb.go

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

8 changes: 3 additions & 5 deletions pkg/pb/dslpb/dslpb.pb.go

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

Loading

0 comments on commit c18d0c4

Please sign in to comment.