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

[KS-196] ReportCodec implementation for Streams trigger #13218

Merged
merged 1 commit into from
May 21, 2024
Merged

Conversation

bolekk
Copy link
Contributor

@bolekk bolekk commented May 16, 2024

  1. Implement Codec, which validates report signatures and decodes needed fields.
  2. Pass report context from Merucry Transmitter, which is needed to validate signatures.
  3. Update fake Syncer to run successful e2e tests.

@bolekk bolekk requested review from a team as code owners May 16, 2024 02:11
@bolekk bolekk requested a review from a team May 16, 2024 15:18
@bolekk bolekk force-pushed the deploy_staging branch 2 times, most recently from 49d7904 to db12eea Compare May 21, 2024 01:30
func (c Codec) Unwrap(raw values.Value) ([]datastreams.FeedReport, error) {
var _ datastreams.ReportCodec = &codec{}

func (c *codec) UnwrapValid(wrapped values.Value, allowedSigners [][]byte, minRequiredSignatures int) ([]datastreams.FeedReport, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

May I ask, why is the list of reports passed as a wrapped values.Value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

values.Value is a universal wrapper for all data passed around during workflow execution. Trigger Service will wrap it and then the receiver DON will unwrap it here.

Comment on lines +65 to +67
s.wg.Add(1)
go s.launch(ctx)
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Worth implementing a StateMachine here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This Syncer implementation will soon be replaced with a real one reading stuff from the chain. Right now it's here just to allow easy local and staging tests. Please ignore all shortcomings ;)

}
s.subServices = append(s.subServices, triggerCap)
}
if slices.Contains(triggerDONPeers, myId) {
s.lggr.Info("member of a capability DON - starting remote publishers")

{
/*{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean to delete this?

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 want to leave it for easier local tests - will be replaced within 2 weeks.

count++
if count > maxRetrySeconds {
s.lggr.Error("failed to get Streams Trigger from the Registry")
return
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a permanent failure that leaves the node in a broken state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

broken meaning unable to send trigger events but otherwise functional.

count := 0
for {
count++
if count > maxRetrySeconds {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems confusingly named, count doesn't appear to be a timer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, will remove the "seconds" thanks

return
}
s.subServices = append(s.subServices, triggerCap)
break
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this be cleaner using a backoff.Backoff with permanent retry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes but probably not worth it - again this Syncer won't be used in prod.

Comment on lines +91 to +97
"0x9CcE7293a4Cc2621b61193135A95928735e4795F",
"0x3c775F20bCB2108C1A818741Ce332Bb5fe0dB925",
"0x50314239e2CF05555ceeD53E7F47eB2A8Eab0dbB",
"0xd76A4f98898c3b9A72b244476d7337b50D54BCd8",
"0x656A873f6895b8a03Fb112dE927d43FA54B2c92A",
"0x5d1e87d87bF2e0cD4Ea64F381a2dbF45e5f0a553",
"0x91d9b0062265514f012Eb8fABA59372fD9520f56",
Copy link
Collaborator

@DeividasK DeividasK May 21, 2024

Choose a reason for hiding this comment

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

Heads up, that this will change to be bytes32 onchain (https://github.com/smartcontractkit/chainlink/pull/13183/files#diff-d94c1796b3544ef8780af7e16b5361c8fb9e4d63f492faeda6a3362a8363f51bR45-R51). We can do decoding once the Syncer is up, but not sure the best place to do that, thread: https://chainlink-core.slack.com/archives/C064418MJHE/p1716308390423929

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fine. As long as the Syncer passes correct binary addresses to all services, we're good.

if err2 != nil {
// NOTE: it's possible that the jobs are not launched yet at this moment.
// If not found yet, Syncer won't add to Registry but retry on the next tick.
s.lggr.Infow("trigger not found yet ...", "capabilityId", capId, "error", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
s.lggr.Infow("trigger not found yet ...", "capabilityId", capId, "error", err)
s.lggr.Infow("trigger not found yet ...", "capabilityId", capId, "error", err2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixing, thanks

workflowDONs := map[string]capabilities.DON{
workflowDonInfo.ID: workflowDonInfo,
}
triggerCap := remote.NewTriggerPublisher(config, underlying, triggerInfo, triggerCapabilityDonInfo, workflowDONs, s.dispatcher, s.lggr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the future, this should only happen when DON isPublic, right? Currently, this assumes that the capability is always remote without actually checking for local existence, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct!

@@ -388,15 +388,22 @@ func (mt *mercuryTransmitter) HealthReport() map[string]error {
return report
}

func (mt *mercuryTransmitter) sendToTrigger(report ocrtypes.Report, signatures []ocrtypes.AttributedOnchainSignature) error {
func (mt *mercuryTransmitter) sendToTrigger(report ocrtypes.Report, rawReportCtx [3][32]byte, signatures []ocrtypes.AttributedOnchainSignature) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this rawReportCtx [3][32]byte, be based on a workflow spec config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How so? The context encodes OCR round and epoch in which the report was produced.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess it's not clear what this context is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be pretty clear in the context of the Transmitter because it already uses it elsewhere.

DeividasK
DeividasK previously approved these changes May 21, 2024
1. Implement Codec, which validates report signatures and decodes needed fields.
2. Pass report context from Merucry Transmitter, which is needed to validate signatures.
3. Update fake Syncer to run successful e2e tests.
@bolekk bolekk added this pull request to the merge queue May 21, 2024
Merged via the queue into develop with commit 4938ef3 May 21, 2024
107 checks passed
@bolekk bolekk deleted the deploy_staging branch May 21, 2024 18:11
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.

3 participants