Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CM-380] Identical Aggregator #771

Merged
merged 44 commits into from
Oct 10, 2024

Conversation

bolekk
Copy link
Contributor

@bolekk bolekk commented Sep 16, 2024

No description provided.

pkg/capabilities/consensus/ocr3/aggregators/identical.go Outdated Show resolved Hide resolved
outcome[fmt.Sprintf("%d", idx)] = highestObservation
}
}
valMap, err := values.NewMap(outcome)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like there needs to be a special case for a single observation to be just the object that's not keyed. This is our use case and I think most will be that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it too but unfortunately the return type of outcome is a Map, not a Value... hence the key overrides.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but if there's only one observation, the single observation's value should be a value.Value. That way the one observation can be unwrapped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant is that EncodableOutcome's type is values.Map so I can't assign Value to a Map... It needs at least one key.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I was thinking is that the outcome gets stored in a fixed struct:

struct EncoderOutcome {
   Value any
}

Then you send the Value to the encoder.

// If non-empty, must be of length ExpectedObservationsLen.
KeyOverrides []string
// If true, the encoder name and config will be overridden with the values
// provided under configured indices of the observations array (as long as consensus is reached).
Copy link
Contributor Author

@bolekk bolekk Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too happy with this approach... suggestions welcome.

@cedric-cordenier this is slightly different to what we discussed but I don't see how we can make a generic aggregator with only a single observation.

return nil, err
}
return &types.AggregationOutcome{
EncodableOutcome: values.ProtoMap(valMap),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, you can make this a value.Value. There's no reason someone can't encode a number, a list of numbers etc.

Copy link
Contributor

@cedric-cordenier cedric-cordenier Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually assume that it needs to be a map since we add metadata to it. Any objection to leaving this as is and revisiting at a future date?

dimkouv and others added 9 commits October 4, 2024 13:35
* [chore] Handle aliases in slices

* More aliasing tests

* Lint fix

* Fix test

---------

Co-authored-by: Sri Kidambi <1702865+kidambisrinivas@users.noreply.github.com>
* [CAPPL-58] Further cleanup

* [CAPPL-58] Add support for compression
* Generic case to handle both pointer type and raw type and simplify int unwrap

* Handling interface and default

* Small test fix

---------

Co-authored-by: Cedric Cordenier <cedric.cordenier@smartcontract.com>
* Fix alias typing and tests

* Fix ints

* errors.new instead of fmt

* Add array support to slice (#789)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the mock in ocr3cap mock might need to change for this to work with it. Should we expose another wrapper to get multiple consensus or just hide at that point? I'm good either way.

Also, if we're only returning one of the signed reports, but there's actually an array, then line 30 should be of type []SignedReport and you would need to wrap the capability in sdk.ToListDefinition and on line 31 use step.Index(0) instead of step.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if we're only returning one of the signed reports, but there's actually an array, then line 30 should be of type []SignedReport and you would need to wrap the capability in sdk.ToListDefinition and on line 31 use step.Index(0) instead of step.

We only output one report atm, unless I'm misunderstanding the question?

nolag
nolag previously approved these changes Oct 9, 2024
@cedric-cordenier cedric-cordenier merged commit 4637084 into main Oct 10, 2024
8 of 11 checks passed
@cedric-cordenier cedric-cordenier deleted the feature/CM-380-identical-aggregator branch October 10, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.