diff --git a/pkg/accountability/simpleacc/accountability.go b/pkg/accountability/simpleacc/accountability.go index 01afd78fb..a44627201 100644 --- a/pkg/accountability/simpleacc/accountability.go +++ b/pkg/accountability/simpleacc/accountability.go @@ -125,6 +125,7 @@ func NewReconfigurableModule(mc ModuleConfig, paramsTemplate ModuleParams, logge // Fill in instance-specific parameters. moduleParams := paramsTemplate moduleParams.Membership = accParams.Membership + moduleParams.RetentionIndex = accParams.RetentionIndex // Create a new instance of the multisig collector. accountabilityModule, err := NewModule( diff --git a/pkg/accountability/simpleacc/common/common.go b/pkg/accountability/simpleacc/common/common.go index acb8507e8..97a71db74 100644 --- a/pkg/accountability/simpleacc/common/common.go +++ b/pkg/accountability/simpleacc/common/common.go @@ -6,6 +6,8 @@ import ( "github.com/filecoin-project/mir/pkg/logging" accpbtypes "github.com/filecoin-project/mir/pkg/pb/accountabilitypb/types" trantorpbtypes "github.com/filecoin-project/mir/pkg/pb/trantorpb/types" + timertypes "github.com/filecoin-project/mir/pkg/timer/types" + tt "github.com/filecoin-project/mir/pkg/trantor/types" t "github.com/filecoin-project/mir/pkg/types" ) @@ -17,15 +19,18 @@ type ModuleConfig struct { Ordering t.ModuleID // provides Predecisions App t.ModuleID // receives Decisions and/or PoMs Crypto t.ModuleID // provides cryptographic primitives + Timer t.ModuleID // provides Timing primitives Net t.ModuleID // provides network primitives } // ModuleParams sets the values for the parameters of an instance of the protocol. // All replicas are expected to use identical module parameters. type ModuleParams struct { - Membership *trantorpbtypes.Membership // the list of participating nodes + Membership *trantorpbtypes.Membership // The list of participating nodes. LightCertificates bool - PomsHandler func(m dsl.Module, // function to be called when PoMs detected + ResendFrequency timertypes.Duration // Frequency with which messages in the critical path are re-sent + RetentionIndex tt.RetentionIndex + PoMsHandler func(m dsl.Module, // Function to be called when PoMs detected. mc *ModuleConfig, params *ModuleParams, state *incommon.State, diff --git a/pkg/accountability/simpleacc/internal/poms/poms.go b/pkg/accountability/simpleacc/internal/poms/poms.go index 1cd8c4162..63636ebee 100644 --- a/pkg/accountability/simpleacc/internal/poms/poms.go +++ b/pkg/accountability/simpleacc/internal/poms/poms.go @@ -93,7 +93,7 @@ func HandlePoMs( logger.Log(logging.LevelWarn, "Found valid PoMs! sending...") // Handle PoMs according to the application's logic defined when creating the accountability factory - params.PomsHandler(m, mc, params, state, state.UnhandledPoMs, logger) + params.PoMsHandler(m, mc, params, state, state.UnhandledPoMs, logger) for _, pom := range state.UnhandledPoMs { state.HandledPoMs[pom.NodeId] = pom diff --git a/pkg/accountability/simpleacc/internal/predecisions/predecisions.go b/pkg/accountability/simpleacc/internal/predecisions/predecisions.go index d6e64b5bc..b062f69ee 100644 --- a/pkg/accountability/simpleacc/internal/predecisions/predecisions.go +++ b/pkg/accountability/simpleacc/internal/predecisions/predecisions.go @@ -3,6 +3,9 @@ package predecisions import ( "reflect" + eventpbdsl "github.com/filecoin-project/mir/pkg/pb/eventpb/dsl" + eventpbtypes "github.com/filecoin-project/mir/pkg/pb/eventpb/types" + "github.com/filecoin-project/mir/pkg/accountability/simpleacc/internal/certificates/lightcertificates" isspbdsl "github.com/filecoin-project/mir/pkg/pb/isspb/dsl" isspbtypes "github.com/filecoin-project/mir/pkg/pb/isspb/types" @@ -19,6 +22,7 @@ import ( cryptopbdsl "github.com/filecoin-project/mir/pkg/pb/cryptopb/dsl" cryptopbtypes "github.com/filecoin-project/mir/pkg/pb/cryptopb/types" transportpbdsl "github.com/filecoin-project/mir/pkg/pb/transportpb/dsl" + transportpbevents "github.com/filecoin-project/mir/pkg/pb/transportpb/events" t "github.com/filecoin-project/mir/pkg/types" "github.com/filecoin-project/mir/pkg/util/maputil" "github.com/filecoin-project/mir/pkg/util/membutil" @@ -79,7 +83,13 @@ func IncludePredecisions( state.LocalPredecision.SignedPredecision.Signature = signature // Broadcast signed predecision to all participants (including oneself). - transportpbdsl.SendMessage(m, mc.Net, accpbmsgs.SignedPredecision(mc.Self, sr.data, signature), maputil.GetKeys(params.Membership.Nodes)) + eventpbdsl.TimerRepeat(m, + mc.Timer, + []*eventpbtypes.Event{transportpbevents.SendMessage(mc.Net, accpbmsgs.SignedPredecision(mc.Self, sr.data, signature), maputil.GetKeys(params.Membership.Nodes))}, + params.ResendFrequency, + params.RetentionIndex, + ) + return nil }) @@ -230,13 +240,16 @@ func decide(m dsl.Module, mc *common.ModuleConfig, params *common.ModuleParams, } // Find the actual predecision from other nodes - transportpbdsl.SendMessage( - m, - mc.Net, - accpbmsgs.RequestSBMessage(mc.Self, - predecision), - state.PredecisionNodeIDs[string(predecision)]) - + eventpbdsl.TimerRepeat(m, + mc.Timer, + []*eventpbtypes.Event{transportpbevents.SendMessage( + mc.Net, + accpbmsgs.RequestSBMessage(mc.Self, + predecision), + state.PredecisionNodeIDs[string(predecision)])}, + params.ResendFrequency, + params.RetentionIndex, + ) } func finishWithDecision( diff --git a/pkg/pb/accountabilitypb/accountabilitypb.pb.go b/pkg/pb/accountabilitypb/accountabilitypb.pb.go index 735e03b89..acbe9e463 100644 --- a/pkg/pb/accountabilitypb/accountabilitypb.pb.go +++ b/pkg/pb/accountabilitypb/accountabilitypb.pb.go @@ -434,7 +434,8 @@ type InstanceParams struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Membership *trantorpb.Membership `protobuf:"bytes,3,opt,name=membership,proto3" json:"membership,omitempty"` + Membership *trantorpb.Membership `protobuf:"bytes,1,opt,name=membership,proto3" json:"membership,omitempty"` + RetentionIndex uint64 `protobuf:"varint,2,opt,name=retention_index,json=retentionIndex,proto3" json:"retention_index,omitempty"` } func (x *InstanceParams) Reset() { @@ -476,6 +477,13 @@ func (x *InstanceParams) GetMembership() *trantorpb.Membership { return nil } +func (x *InstanceParams) GetRetentionIndex() uint64 { + if x != nil { + return x.RetentionIndex + } + return 0 +} + type RequestSBMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -658,11 +666,18 @@ var file_accountabilitypb_accountabilitypb_proto_rawDesc = []byte{ 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x3a, 0x04, 0xd0, 0xe4, 0x1d, 0x01, 0x22, - 0x4d, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x12, 0x35, 0x0a, 0x0a, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x74, 0x6f, 0x72, 0x70, - 0x62, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x0a, 0x6d, 0x65, - 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x3a, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x22, 0x3a, + 0xbc, 0x01, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x12, 0x35, 0x0a, 0x0a, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x74, 0x6f, 0x72, + 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x0a, 0x6d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x12, 0x6d, 0x0a, 0x0f, 0x72, 0x65, 0x74, + 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x42, 0x44, 0x82, 0xa6, 0x1d, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x69, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x72, 0x61, 0x6e, + 0x74, 0x6f, 0x72, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x74, 0x65, 0x6e, 0x74, + 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0e, 0x72, 0x65, 0x74, 0x65, 0x6e, 0x74, + 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x3a, 0x04, 0x80, 0xa6, 0x1d, 0x01, 0x22, 0x3a, 0x0a, 0x10, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x42, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x64, 0x65, 0x63, 0x69, diff --git a/pkg/pb/accountabilitypb/types/types.mir.go b/pkg/pb/accountabilitypb/types/types.mir.go index 8ff7e79eb..828f69e24 100644 --- a/pkg/pb/accountabilitypb/types/types.mir.go +++ b/pkg/pb/accountabilitypb/types/types.mir.go @@ -6,8 +6,9 @@ import ( mirreflect "github.com/filecoin-project/mir/codegen/mirreflect" types1 "github.com/filecoin-project/mir/codegen/model/types" accountabilitypb "github.com/filecoin-project/mir/pkg/pb/accountabilitypb" - types3 "github.com/filecoin-project/mir/pkg/pb/isspb/types" + types4 "github.com/filecoin-project/mir/pkg/pb/isspb/types" types2 "github.com/filecoin-project/mir/pkg/pb/trantorpb/types" + types3 "github.com/filecoin-project/mir/pkg/trantor/types" types "github.com/filecoin-project/mir/pkg/types" reflectutil "github.com/filecoin-project/mir/pkg/util/reflectutil" ) @@ -389,7 +390,8 @@ func (*FullCertificate) MirReflect() mirreflect.Type { } type InstanceParams struct { - Membership *types2.Membership + Membership *types2.Membership + RetentionIndex types3.RetentionIndex } func InstanceParamsFromPb(pb *accountabilitypb.InstanceParams) *InstanceParams { @@ -397,7 +399,8 @@ func InstanceParamsFromPb(pb *accountabilitypb.InstanceParams) *InstanceParams { return nil } return &InstanceParams{ - Membership: types2.MembershipFromPb(pb.Membership), + Membership: types2.MembershipFromPb(pb.Membership), + RetentionIndex: (types3.RetentionIndex)(pb.RetentionIndex), } } @@ -410,6 +413,7 @@ func (m *InstanceParams) Pb() *accountabilitypb.InstanceParams { if m.Membership != nil { pbMessage.Membership = (m.Membership).Pb() } + pbMessage.RetentionIndex = (uint64)(m.RetentionIndex) } return pbMessage @@ -449,7 +453,7 @@ func (*RequestSBMessage) MirReflect() mirreflect.Type { } type ProvideSBMessage struct { - SbDeliver *types3.SBDeliver + SbDeliver *types4.SBDeliver } func ProvideSBMessageFromPb(pb *accountabilitypb.ProvideSBMessage) *ProvideSBMessage { @@ -457,7 +461,7 @@ func ProvideSBMessageFromPb(pb *accountabilitypb.ProvideSBMessage) *ProvideSBMes return nil } return &ProvideSBMessage{ - SbDeliver: types3.SBDeliverFromPb(pb.SbDeliver), + SbDeliver: types4.SBDeliverFromPb(pb.SbDeliver), } } diff --git a/protos/accountabilitypb/accountabilitypb.proto b/protos/accountabilitypb/accountabilitypb.proto index 7229b7d9f..929ffefea 100644 --- a/protos/accountabilitypb/accountabilitypb.proto +++ b/protos/accountabilitypb/accountabilitypb.proto @@ -63,7 +63,8 @@ message FullCertificate { message InstanceParams { option (mir.struct) = true; - trantorpb.Membership membership = 3; + trantorpb.Membership membership = 1; + uint64 retention_index = 2 [(mir.type) = "github.com/filecoin-project/mir/pkg/trantor/types.RetentionIndex"]; }