Skip to content

Commit e3e2e02

Browse files
committed
cre-1601: remove previous outcome, use outctx.SeqNr instead
1 parent 38db9f4 commit e3e2e02

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

pkg/workflows/shardorchestrator/plugin.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,6 @@ func (p *Plugin) ObservationQuorum(_ context.Context, _ ocr3types.OutcomeContext
100100
}
101101

102102
func (p *Plugin) Outcome(_ context.Context, outctx ocr3types.OutcomeContext, _ types.Query, aos []types.AttributedObservation) (ocr3types.Outcome, error) {
103-
prevOutcome := &pb.Outcome{}
104-
if err := proto.Unmarshal(outctx.PreviousOutcome, prevOutcome); err != nil || prevOutcome.State == nil {
105-
p.lggr.Warnf("failed to unmarshal previous outcome or state is nil")
106-
prevOutcome = &pb.Outcome{
107-
State: &pb.RoutingState{
108-
Id: 0,
109-
State: &pb.RoutingState_RoutableShards{
110-
RoutableShards: p.minShardCount,
111-
},
112-
},
113-
Routes: make(map[string]*pb.WorkflowRoute),
114-
}
115-
}
116-
117103
currentShardHealth := make(map[uint32]int)
118104
totalObservations := len(aos)
119105
allWorkflows := []string{}
@@ -177,7 +163,7 @@ func (p *Plugin) Outcome(_ context.Context, outctx ocr3types.OutcomeContext, _ t
177163
// Update routing state
178164
outcome := &pb.Outcome{
179165
State: &pb.RoutingState{
180-
Id: prevOutcome.State.Id + 1,
166+
Id: outctx.SeqNr,
181167
State: &pb.RoutingState_RoutableShards{
182168
RoutableShards: healthyShardCount,
183169
},

pkg/workflows/shardorchestrator/plugin_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestPlugin_OutcomeWithMultiNodeObservations(t *testing.T) {
3030
require.NoError(t, err)
3131

3232
ctx := t.Context()
33-
outcomeCtx := ocr3types.OutcomeContext{PreviousOutcome: []byte("")}
33+
outcomeCtx := ocr3types.OutcomeContext{SeqNr: 42}
3434

3535
// Observations from 4 NOPs reporting health and workflows
3636
observations := []struct {
@@ -87,6 +87,7 @@ func TestPlugin_OutcomeWithMultiNodeObservations(t *testing.T) {
8787
require.NoError(t, err)
8888

8989
// Check consensus results
90+
require.Equal(t, uint64(42), outcomeProto.State.Id, "ID should match SeqNr")
9091
t.Logf("Outcome - ID: %d, HealthyShards: %d", outcomeProto.State.Id, outcomeProto.State.GetRoutableShards())
9192
t.Logf("Workflows assigned: %d", len(outcomeProto.Routes))
9293

0 commit comments

Comments
 (0)