Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 40 additions & 13 deletions pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import (
"context"
"encoding"
"fmt"
"math"
"time"

Expand All @@ -12,10 +14,10 @@
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"
libocr "github.com/smartcontractkit/libocr/offchainreporting2plus/types"

"github.com/smartcontractkit/chainlink-common/pkg/loop/internal/goplugin"
"github.com/smartcontractkit/chainlink-common/pkg/loop/internal/net"
"github.com/smartcontractkit/chainlink-common/pkg/loop/internal/pb"
ocr3 "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/pb/ocr3"
"github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/goplugin"

Check failure on line 17 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / build-test

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/goplugin; to add it:

Check failure on line 17 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / build-race-tests

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/goplugin; to add it:

Check failure on line 17 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / benchmark

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/goplugin; to add it:

Check failure on line 17 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / benchmark

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/goplugin; to add it:

Check failure on line 17 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / benchmark

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/goplugin; to add it:

Check failure on line 17 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / benchmark

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/goplugin; to add it:
"github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/net"

Check failure on line 18 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / build-test

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/net; to add it:

Check failure on line 18 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / build-race-tests

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/net; to add it:

Check failure on line 18 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / benchmark

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/net; to add it:

Check failure on line 18 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / benchmark

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/net; to add it:
"github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/pb"

Check failure on line 19 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / build-test

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/pb; to add it:

Check failure on line 19 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / build-race-tests

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/pb; to add it:

Check failure on line 19 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / benchmark

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/pb; to add it:

Check failure on line 19 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / benchmark

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/pb; to add it:
ocr3 "github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/pb/ocr3"

Check failure on line 20 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / build-test

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/pb/ocr3; to add it:

Check failure on line 20 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / build-race-tests

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/pb/ocr3; to add it:

Check failure on line 20 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / benchmark

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/pb/ocr3; to add it:

Check failure on line 20 in pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go

View workflow job for this annotation

GitHub Actions / benchmark

no required module provides package github.com/smartcontractkit/tmp-sm-plugin-loopp/v2/internal/pb/ocr3; to add it:
)

type reportingPluginFactoryClient struct {
Expand Down Expand Up @@ -65,15 +67,23 @@

var _ ocr3.ReportingPluginFactoryServer = (*reportingPluginFactoryServer)(nil)

// var _ encoding.BinaryMarshaler = (BinaryRI)(nil)
// var _ encoding.BinaryUnmarshaler = (BinaryRI)(nil)

type BinaryRI interface {
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
}

type reportingPluginFactoryServer struct {
ocr3.UnimplementedReportingPluginFactoryServer

*net.BrokerExt

impl ocr3types.ReportingPluginFactory[[]byte]
impl ocr3types.ReportingPluginFactory[BinaryRI]
}

func NewReportingPluginFactoryServer(impl ocr3types.ReportingPluginFactory[[]byte], b *net.BrokerExt) *reportingPluginFactoryServer {
func NewReportingPluginFactoryServer(impl ocr3types.ReportingPluginFactory[BinaryRI], b *net.BrokerExt) *reportingPluginFactoryServer {
return &reportingPluginFactoryServer{impl: impl, BrokerExt: b.WithName("OCR3ReportingPluginFactoryServer")}
}

Expand Down Expand Up @@ -233,7 +243,7 @@
type reportingPluginServer struct {
ocr3.UnimplementedReportingPluginServer

impl ocr3types.ReportingPlugin[[]byte]
impl ocr3types.ReportingPlugin[BinaryRI]
}

func (o *reportingPluginServer) Query(ctx context.Context, request *ocr3.QueryRequest) (*ocr3.QueryReply, error) {
Expand Down Expand Up @@ -299,9 +309,15 @@
}

func (o *reportingPluginServer) ShouldAcceptAttestedReport(ctx context.Context, request *ocr3.ShouldAcceptAttestedReportRequest) (*ocr3.ShouldAcceptAttestedReportReply, error) {
sa, err := o.impl.ShouldAcceptAttestedReport(ctx, request.SegNr, ocr3types.ReportWithInfo[[]byte]{
var b BinaryRI
err := b.UnmarshalBinary(request.Ri.Info)
if err != nil {
return nil, err
}

sa, err := o.impl.ShouldAcceptAttestedReport(ctx, request.SegNr, ocr3types.ReportWithInfo[BinaryRI]{
Report: request.Ri.Report,
Info: request.Ri.Info,
Info: b,
})
if err != nil {
return nil, err
Expand All @@ -312,13 +328,20 @@
}

func (o *reportingPluginServer) ShouldTransmitAcceptedReport(ctx context.Context, request *ocr3.ShouldTransmitAcceptedReportRequest) (*ocr3.ShouldTransmitAcceptedReportReply, error) {
st, err := o.impl.ShouldTransmitAcceptedReport(ctx, request.SegNr, ocr3types.ReportWithInfo[[]byte]{
var b BinaryRI
err := b.UnmarshalBinary(request.Ri.Info)
if err != nil {
return nil, err
}

st, err := o.impl.ShouldTransmitAcceptedReport(ctx, request.SegNr, ocr3types.ReportWithInfo[BinaryRI]{
Report: request.Ri.Report,
Info: request.Ri.Info,
Info: b,
})
if err != nil {
return nil, err
}

return &ocr3.ShouldTransmitAcceptedReportReply{
ShouldTransmit: st,
}, nil
Expand All @@ -344,12 +367,16 @@
}
}

func pbReportsPlus(rwi []ocr3types.ReportPlus[[]byte]) (ri []*ocr3.ReportPlus) {
func pbReportsPlus(rwi []ocr3types.ReportPlus[BinaryRI]) (ri []*ocr3.ReportPlus) {
for _, r := range rwi {
info, err := r.ReportWithInfo.Info.MarshalBinary()
if err != nil {
panic(fmt.Sprintf("can't marshal %v to bytes: %v", r.ReportWithInfo.Info, err))
}
ri = append(ri, &ocr3.ReportPlus{
ReportWithInfo: &ocr3.ReportWithInfo{
Report: r.ReportWithInfo.Report,
Info: r.ReportWithInfo.Info,
Info: info,
},
TransmissionScheduleOverride: pbTransmissionSchedule(r.TransmissionScheduleOverride),
})
Expand Down
Loading