Skip to content

Commit

Permalink
dirty fix bug with memory backend not sending nil when it should be
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMct committed Jul 17, 2024
1 parent 92151e0 commit 3b6635e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,20 @@ func (node *Node) Run(ctx context.Context, app App, ip compute.InputProvider, up
setupSigs := setup.DescriptionToSignatureList(*app.SetupDescription)
sigList := make([]protocols.Signature, 0, len(setupSigs))
for _, sig := range setupSigs {
protoCompleted, _ := node.setup.GetCompletedDescriptor(ctx, sig)
protoCompleted, err := node.setup.GetCompletedDescriptor(ctx, sig)
// TODO: error checking against a keynotfoud type of error to distinguish real failure cases from the absence of a completed descriptor
if protoCompleted == nil {
if protoCompleted == nil || err != nil {
sigList = append(sigList, sig)
} else {
pd := *protoCompleted
if sig.Type == protocols.RKG {
rkg1Desc := *protoCompleted
rkg1Desc.Type = protocols.RKG1
sc.setupCoordinator.outgoing <- setup.Event{Event: protocols.Event{EventType: protocols.Started, Descriptor: rkg1Desc}}
sc.setupCoordinator.outgoing <- setup.Event{Event: protocols.Event{EventType: protocols.Completed, Descriptor: rkg1Desc}}
}
sc.setupCoordinator.outgoing <- setup.Event{Event: protocols.Event{EventType: protocols.Started, Descriptor: *protoCompleted}}
sc.setupCoordinator.outgoing <- setup.Event{Event: protocols.Event{EventType: protocols.Completed, Descriptor: *protoCompleted}}
sc.setupCoordinator.outgoing <- setup.Event{Event: protocols.Event{EventType: protocols.Started, Descriptor: pd}}
sc.setupCoordinator.outgoing <- setup.Event{Event: protocols.Event{EventType: protocols.Completed, Descriptor: pd}}
}
}

Expand Down
10 changes: 5 additions & 5 deletions services/setup/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func (s *Service) GetProtocolInput(ctx context.Context, pd protocols.Descriptor)
// If the output is not available locally, it queries the protocol's aggregator.
// If called at the aggregator, it runs the protocol and returns the output.
func (s *Service) GetAggregationOutput(ctx context.Context, pd protocols.Descriptor) (out *protocols.AggregationOutput, err error) {
// first checks if it has the share locally
// first checks if it has the share locally and if so returns it
out, err = s.getAggregationOutputFromBackend(ctx, pd)
if err == nil {
return out, nil
Expand All @@ -374,11 +374,11 @@ func (s *Service) GetAggregationOutput(ctx context.Context, pd protocols.Descrip
if out.Error != nil {
return nil, fmt.Errorf("aggregation error for %s: %w", pd.HID(), out.Error)
}
err = s.resBackend.Put(ctx, pd, out.Share)
if err != nil {
return nil, err
}
}

// store the output in the result backend
if err := s.resBackend.Put(ctx, pd, out.Share); err != nil {
return out, fmt.Errorf("error when storing aggregation output: %w", err)
}

return out, nil
Expand Down

0 comments on commit 3b6635e

Please sign in to comment.