Skip to content

Commit

Permalink
Re-send messages in critical path to other nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ranchalp committed Aug 7, 2023
1 parent eafd4e5 commit 7c4e481
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 23 deletions.
1 change: 1 addition & 0 deletions pkg/accountability/simpleacc/accountability.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 7 additions & 2 deletions pkg/accountability/simpleacc/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/accountability/simpleacc/internal/poms/poms.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 21 additions & 8 deletions pkg/accountability/simpleacc/internal/predecisions/predecisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
})

Expand Down Expand Up @@ -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(
Expand Down
27 changes: 21 additions & 6 deletions pkg/pb/accountabilitypb/accountabilitypb.pb.go

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

14 changes: 9 additions & 5 deletions pkg/pb/accountabilitypb/types/types.mir.go

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

3 changes: 2 additions & 1 deletion protos/accountabilitypb/accountabilitypb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}


Expand Down

0 comments on commit 7c4e481

Please sign in to comment.