From 8166e6555b2330ba0abfc747a6a78d0685394d89 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Wed, 9 Oct 2024 07:48:09 -0500 Subject: [PATCH 1/9] bump libocr; add context (#490) --- go.mod | 2 +- go.sum | 4 +- pkg/capabilities/consensus/ocr3/factory.go | 2 +- .../consensus/ocr3/reporting_plugin.go | 27 +- .../consensus/ocr3/reporting_plugin_test.go | 37 +- .../consensus/ocr3/transmitter.go | 2 +- pkg/codec/modifier_codec_test.go | 3 +- pkg/loop/adapters/relay/adapter.go | 94 --- pkg/loop/adapters/relay/relay.go | 43 -- pkg/loop/adapters/relay/relay_test.go | 218 ------- pkg/loop/ccip_commit.go | 4 +- pkg/loop/ccip_commit_test.go | 4 +- pkg/loop/ccip_execution.go | 4 +- pkg/loop/ccip_execution_test.go | 4 +- .../core/services/keyvalue/store_test.go | 11 +- .../services/pipeline/pipeline_runner_test.go | 7 +- .../reportingplugin/ocr2/reporting.go | 6 +- .../reportingplugin/ocr3/reporting.go | 100 ++-- .../reportingplugin/ocr3/test/factory.go | 4 +- .../ocr3/test/reporting_plugin.go | 59 +- .../core/services/telemetry/test/telemetry.go | 8 +- .../internal/pb/ocr3/ocr3_reporting.pb.go | 559 ++++++++++++------ .../internal/pb/ocr3/ocr3_reporting.proto | 15 +- .../ext/ccip/commit_provider.go | 6 +- .../pluginprovider/ext/ccip/commit_store.go | 4 +- .../ext/ccip/execution_provider.go | 6 +- .../pluginprovider/ext/ccip/gas_estimator.go | 36 +- .../pluginprovider/ext/ccip/offramp.go | 4 +- .../ext/ccip/test/commit_factory_server.go | 3 +- .../ext/ccip/test/commit_gas_estimator.go | 12 +- .../ccip/test/commit_gas_estimator_test.go | 15 +- .../ext/ccip/test/commit_store_test.go | 18 +- .../ext/ccip/test/exec_factory_server.go | 2 +- .../ext/ccip/test/exec_gas_estimator.go | 12 +- .../ext/ccip/test/exec_gas_estimator_test.go | 16 +- .../pluginprovider/ext/ccip/test/offramp.go | 10 +- .../ext/ccip/test/offramp_test.go | 3 +- .../pluginprovider/ext/median/median.go | 74 ++- .../pluginprovider/ext/median/test/median.go | 24 +- .../ext/mercury/onchainconfig.go | 12 +- .../pluginprovider/ext/mercury/reportcodec.go | 48 +- .../ext/mercury/test/mercury.go | 4 +- .../ext/mercury/test/ocr_plugin.go | 4 +- .../ext/mercury/test/onchainconfig.go | 8 +- .../ext/mercury/v1/reportcodec.go | 18 +- .../ext/mercury/v1/test/reportcodec.go | 12 +- .../ext/mercury/v2/reportcodec.go | 18 +- .../ext/mercury/v2/test/reportcodec.go | 12 +- .../ext/mercury/v3/reportcodec.go | 18 +- .../ext/mercury/v3/test/reportcodec.go | 12 +- .../ext/mercury/v4/reportcodec.go | 18 +- .../ext/mercury/v4/test/reportcodec.go | 12 +- .../relayer/pluginprovider/ocr2/config.go | 12 +- .../ocr2/contract_transmitter.go | 6 +- .../ocr2/test/contract_transmitter.go | 4 +- .../ocr2/test/offchain_config_digester.go | 8 +- .../ocr3/contract_transmitter.go | 6 +- .../ocr3/test/contract_transmitter.go | 4 +- pkg/loop/internal/relayer/relayer.go | 8 +- .../grpc_provider_server_test.go | 18 +- pkg/loop/internal/relayerset/relayer.go | 6 +- .../internal/reportingplugin/median/median.go | 1 + .../mercury/mercury_reporting.go | 12 +- .../internal/reportingplugin/test/factory.go | 4 +- pkg/loop/median_service.go | 4 +- pkg/loop/mercury_service.go | 20 +- pkg/loop/plugin_median_test.go | 4 +- pkg/loop/plugin_mercury_test.go | 4 +- pkg/loop/relayer_adapter.go | 6 - pkg/loop/reportingplugins/loopp_service.go | 4 +- .../reportingplugins/ocr3/loopp_service.go | 4 +- pkg/loop/standard_capabilities_test.go | 12 +- pkg/monitoring/testutils.go | 2 +- pkg/types/ccip/gaspriceestimator.go | 8 +- pkg/types/mercury/types.go | 4 +- pkg/types/mercury/v1/types.go | 6 +- pkg/types/mercury/v2/types.go | 6 +- pkg/types/mercury/v3/types.go | 6 +- pkg/types/mercury/v4/types.go | 6 +- pkg/types/relayer.go | 30 +- 80 files changed, 864 insertions(+), 1009 deletions(-) delete mode 100644 pkg/loop/adapters/relay/adapter.go delete mode 100644 pkg/loop/adapters/relay/relay.go delete mode 100644 pkg/loop/adapters/relay/relay_test.go delete mode 100644 pkg/loop/relayer_adapter.go diff --git a/go.mod b/go.mod index 104666560..062c250d4 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( github.com/santhosh-tekuri/jsonschema/v5 v5.2.0 github.com/shopspring/decimal v1.4.0 github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 - github.com/smartcontractkit/libocr v0.0.0-20240717100443-f6226e09bee7 + github.com/smartcontractkit/libocr v0.0.0-20241007185508-adbe57025f12 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 go.opentelemetry.io/otel v1.28.0 diff --git a/go.sum b/go.sum index 84d8f6989..aa0c53162 100644 --- a/go.sum +++ b/go.sum @@ -223,8 +223,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA= -github.com/smartcontractkit/libocr v0.0.0-20240717100443-f6226e09bee7 h1:e38V5FYE7DA1JfKXeD5Buo/7lczALuVXlJ8YNTAUxcw= -github.com/smartcontractkit/libocr v0.0.0-20240717100443-f6226e09bee7/go.mod h1:fb1ZDVXACvu4frX3APHZaEBp0xi1DIm34DcA0CwTsZM= +github.com/smartcontractkit/libocr v0.0.0-20241007185508-adbe57025f12 h1:NzZGjaqez21I3DU7objl3xExTH4fxYvzTqar8DC6360= +github.com/smartcontractkit/libocr v0.0.0-20241007185508-adbe57025f12/go.mod h1:fb1ZDVXACvu4frX3APHZaEBp0xi1DIm34DcA0CwTsZM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= diff --git a/pkg/capabilities/consensus/ocr3/factory.go b/pkg/capabilities/consensus/ocr3/factory.go index 11fc18aa4..d634121b7 100644 --- a/pkg/capabilities/consensus/ocr3/factory.go +++ b/pkg/capabilities/consensus/ocr3/factory.go @@ -36,7 +36,7 @@ func newFactory(s *requests.Store, c *capability, batchSize int, outcomePruningT }, nil } -func (o *factory) NewReportingPlugin(config ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[[]byte], ocr3types.ReportingPluginInfo, error) { +func (o *factory) NewReportingPlugin(ctx context.Context, config ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[[]byte], ocr3types.ReportingPluginInfo, error) { rp, err := newReportingPlugin(o.store, o.capability, o.batchSize, config, o.outcomePruningThreshold, o.lggr) info := ocr3types.ReportingPluginInfo{ Name: "OCR3 Capability Plugin", diff --git a/pkg/capabilities/consensus/ocr3/reporting_plugin.go b/pkg/capabilities/consensus/ocr3/reporting_plugin.go index 015cc2964..60b900fad 100644 --- a/pkg/capabilities/consensus/ocr3/reporting_plugin.go +++ b/pkg/capabilities/consensus/ocr3/reporting_plugin.go @@ -7,6 +7,7 @@ import ( "slices" "time" + "github.com/smartcontractkit/libocr/quorumhelper" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/timestamppb" @@ -149,15 +150,15 @@ func (r *reportingPlugin) Observation(ctx context.Context, outctx ocr3types.Outc return proto.MarshalOptions{Deterministic: true}.Marshal(obs) } -func (r *reportingPlugin) ValidateObservation(outctx ocr3types.OutcomeContext, query types.Query, ao types.AttributedObservation) error { +func (r *reportingPlugin) ValidateObservation(ctx context.Context, outctx ocr3types.OutcomeContext, query types.Query, ao types.AttributedObservation) error { return nil } -func (r *reportingPlugin) ObservationQuorum(outctx ocr3types.OutcomeContext, query types.Query) (ocr3types.Quorum, error) { - return ocr3types.QuorumTwoFPlusOne, nil +func (r *reportingPlugin) ObservationQuorum(ctx context.Context, outctx ocr3types.OutcomeContext, query types.Query, aos []types.AttributedObservation) (bool, error) { + return quorumhelper.ObservationCountReachesObservationQuorum(quorumhelper.QuorumTwoFPlusOne, r.config.N, r.config.F, aos), nil } -func (r *reportingPlugin) Outcome(outctx ocr3types.OutcomeContext, query types.Query, attributedObservations []types.AttributedObservation) (ocr3types.Outcome, error) { +func (r *reportingPlugin) Outcome(ctx context.Context, outctx ocr3types.OutcomeContext, query types.Query, attributedObservations []types.AttributedObservation) (ocr3types.Outcome, error) { // execution ID -> oracle ID -> list of observations execIDToOracleObservations := map[string]map[ocrcommon.OracleID][]values.Value{} seenWorkflowIDs := map[string]int{} @@ -350,14 +351,14 @@ func marshalReportInfo(info *pbtypes.ReportInfo, keyID string) ([]byte, error) { return ip, nil } -func (r *reportingPlugin) Reports(seqNr uint64, outcome ocr3types.Outcome) ([]ocr3types.ReportWithInfo[[]byte], error) { +func (r *reportingPlugin) Reports(ctx context.Context, seqNr uint64, outcome ocr3types.Outcome) ([]ocr3types.ReportPlus[[]byte], error) { o := &pbtypes.Outcome{} err := proto.Unmarshal(outcome, o) if err != nil { return nil, err } - reports := []ocr3types.ReportWithInfo[[]byte]{} + reports := []ocr3types.ReportPlus[[]byte]{} for _, report := range o.CurrentReports { if report == nil { @@ -438,8 +439,12 @@ func (r *reportingPlugin) Reports(seqNr uint64, outcome ocr3types.Outcome) ([]oc continue } - rawReport, err = encoder.Encode(context.Background(), *mv) + rawReport, err = encoder.Encode(ctx, *mv) if err != nil { + if cerr := ctx.Err(); cerr != nil { + r.lggr.Errorw("report encoding cancelled", "err", cerr) + return nil, cerr + } r.lggr.Errorw("could not encode report for workflow", "error", err) continue } @@ -452,9 +457,11 @@ func (r *reportingPlugin) Reports(seqNr uint64, outcome ocr3types.Outcome) ([]oc } // Append every report, even if shouldReport = false, to let the transmitter mark the step as complete. - reports = append(reports, ocr3types.ReportWithInfo[[]byte]{ - Report: rawReport, - Info: infob, + reports = append(reports, ocr3types.ReportPlus[[]byte]{ + ReportWithInfo: ocr3types.ReportWithInfo[[]byte]{ + Report: rawReport, + Info: infob, + }, }) } diff --git a/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go b/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go index 61acd4011..04be58609 100644 --- a/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go +++ b/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go @@ -17,7 +17,6 @@ import ( "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3/requests" - pbtypes "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3/types" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" @@ -300,7 +299,7 @@ func TestReportingPlugin_Outcome(t *testing.T) { }, } - outcome, err := rp.Outcome(ocr3types.OutcomeContext{}, qb, aos) + outcome, err := rp.Outcome(tests.Context(t), ocr3types.OutcomeContext{}, qb, aos) require.NoError(t, err) opb := &pbtypes.Outcome{} @@ -316,6 +315,7 @@ func TestReportingPlugin_Outcome(t *testing.T) { } func TestReportingPlugin_Outcome_NilDerefs(t *testing.T) { + ctx := tests.Context(t) lggr := logger.Test(t) s := requests.NewStore() mcap := &mockCapability{ @@ -349,7 +349,7 @@ func TestReportingPlugin_Outcome_NilDerefs(t *testing.T) { {}, } - _, err = rp.Outcome(ocr3types.OutcomeContext{}, qb, aos) + _, err = rp.Outcome(ctx, ocr3types.OutcomeContext{}, qb, aos) require.NoError(t, err) obs := &pbtypes.Observations{ @@ -368,7 +368,7 @@ func TestReportingPlugin_Outcome_NilDerefs(t *testing.T) { Observer: commontypes.OracleID(1), }, } - _, err = rp.Outcome(ocr3types.OutcomeContext{}, qb, aos) + _, err = rp.Outcome(ctx, ocr3types.OutcomeContext{}, qb, aos) require.NoError(t, err) } @@ -408,22 +408,25 @@ func TestReportingPlugin_Reports_ShouldReportFalse(t *testing.T) { } pl, err := proto.Marshal(outcome) require.NoError(t, err) - reports, err := rp.Reports(sqNr, pl) + reports, err := rp.Reports(tests.Context(t), sqNr, pl) require.NoError(t, err) assert.Len(t, reports, 1) gotRep := reports[0] - assert.Len(t, gotRep.Report, 0) + assert.Len(t, gotRep.ReportWithInfo.Report, 0) - ib := gotRep.Info + ib := gotRep.ReportWithInfo.Info info, err := extractReportInfo(ib) require.NoError(t, err) - assert.EqualExportedValues(t, info.Id, id) + assert.EqualExportedValues(t, id, info.Id) assert.False(t, info.ShouldReport) + + require.Nil(t, gotRep.TransmissionScheduleOverride) } func TestReportingPlugin_Reports_NilDerefs(t *testing.T) { + ctx := tests.Context(t) lggr := logger.Test(t) s := requests.NewStore() mcap := &mockCapability{ @@ -461,7 +464,7 @@ func TestReportingPlugin_Reports_NilDerefs(t *testing.T) { } pl, err := proto.Marshal(outcome) require.NoError(t, err) - _, err = rp.Reports(sqNr, pl) + _, err = rp.Reports(ctx, sqNr, pl) require.NoError(t, err) } @@ -511,14 +514,14 @@ func TestReportingPlugin_Reports_ShouldReportTrue(t *testing.T) { } pl, err := proto.Marshal(outcome) require.NoError(t, err) - reports, err := rp.Reports(sqNr, pl) + reports, err := rp.Reports(tests.Context(t), sqNr, pl) require.NoError(t, err) assert.Len(t, reports, 1) gotRep := reports[0] rep := &pb.Value{} - err = proto.Unmarshal(gotRep.Report, rep) + err = proto.Unmarshal(gotRep.ReportWithInfo.Report, rep) require.NoError(t, err) // The workflow ID and execution ID get added to the report. @@ -538,15 +541,18 @@ func TestReportingPlugin_Reports_ShouldReportTrue(t *testing.T) { require.NoError(t, err) require.Equal(t, nm, fp) - ib := gotRep.Info + ib := gotRep.ReportWithInfo.Info info, err := extractReportInfo(ib) require.NoError(t, err) assert.EqualExportedValues(t, info.Id, id) assert.True(t, info.ShouldReport) + + require.Nil(t, gotRep.TransmissionScheduleOverride) } func TestReportingPlugin_Outcome_ShouldPruneOldOutcomes(t *testing.T) { + ctx := tests.Context(t) lggr := logger.Test(t) s := requests.NewStore() mcap := &mockCapability{ @@ -642,13 +648,13 @@ func TestReportingPlugin_Outcome_ShouldPruneOldOutcomes(t *testing.T) { }, } - outcome1, err := rp.Outcome(ocr3types.OutcomeContext{SeqNr: 100}, qb, aos) + outcome1, err := rp.Outcome(ctx, ocr3types.OutcomeContext{SeqNr: 100}, qb, aos) require.NoError(t, err) opb1 := &pbtypes.Outcome{} err = proto.Unmarshal(outcome1, opb1) require.NoError(t, err) - outcome2, err := rp.Outcome(ocr3types.OutcomeContext{SeqNr: defaultOutcomePruningThreshold + 100, PreviousOutcome: outcome1}, qb, aos2) + outcome2, err := rp.Outcome(ctx, ocr3types.OutcomeContext{SeqNr: defaultOutcomePruningThreshold + 100, PreviousOutcome: outcome1}, qb, aos2) require.NoError(t, err) opb2 := &pbtypes.Outcome{} err = proto.Unmarshal(outcome2, opb2) @@ -663,6 +669,7 @@ func TestReportingPlugin_Outcome_ShouldPruneOldOutcomes(t *testing.T) { } func TestReportPlugin_Outcome_ShouldReturnMedianTimestamp(t *testing.T) { + ctx := tests.Context(t) lggr := logger.Test(t) s := requests.NewStore() mcap := &mockCapability{ @@ -785,7 +792,7 @@ func TestReportPlugin_Outcome_ShouldReturnMedianTimestamp(t *testing.T) { }, } - outcome, err := rp.Outcome(ocr3types.OutcomeContext{SeqNr: 100}, qb, aos) + outcome, err := rp.Outcome(ctx, ocr3types.OutcomeContext{SeqNr: 100}, qb, aos) require.NoError(t, err) opb1 := &pbtypes.Outcome{} err = proto.Unmarshal(outcome, opb1) diff --git a/pkg/capabilities/consensus/ocr3/transmitter.go b/pkg/capabilities/consensus/ocr3/transmitter.go index 1595a3955..2c8d1d6fc 100644 --- a/pkg/capabilities/consensus/ocr3/transmitter.go +++ b/pkg/capabilities/consensus/ocr3/transmitter.go @@ -131,7 +131,7 @@ func (c *ContractTransmitter) Transmit(ctx context.Context, configDigest types.C return err } -func (c *ContractTransmitter) FromAccount() (types.Account, error) { +func (c *ContractTransmitter) FromAccount(ctx context.Context) (types.Account, error) { return types.Account(c.fromAccount), nil } diff --git a/pkg/codec/modifier_codec_test.go b/pkg/codec/modifier_codec_test.go index d3ca14c00..8b6d5153e 100644 --- a/pkg/codec/modifier_codec_test.go +++ b/pkg/codec/modifier_codec_test.go @@ -13,6 +13,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/codec" "github.com/smartcontractkit/chainlink-common/pkg/types" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" ) var anyTestBytes = []byte("any test bytes") @@ -29,7 +30,7 @@ const anyForEncoding = true func TestModifierCodec(t *testing.T) { t.Parallel() - ctx := context.Background() + ctx := tests.Context(t) mod, err := codec.NewModifierCodec(&testCodec{}, testModifier{}) require.NoError(t, err) diff --git a/pkg/loop/adapters/relay/adapter.go b/pkg/loop/adapters/relay/adapter.go deleted file mode 100644 index defcf9f29..000000000 --- a/pkg/loop/adapters/relay/adapter.go +++ /dev/null @@ -1,94 +0,0 @@ -package relay - -import ( - "context" - - looptypes "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/types" - "github.com/smartcontractkit/chainlink-common/pkg/services" - "github.com/smartcontractkit/chainlink-common/pkg/types" -) - -// RelayerExt is a subset of [loop.Relayer] for adapting [types.Relayer], typically with a Chain. See [RelayerAdapter]. -type RelayerExt interface { - types.ChainService - ID() string -} - -var _ looptypes.Relayer = (*RelayerAdapter)(nil) - -// RelayerAdapter adapts a [types.Relayer] and [RelayerExt] to implement [Relayer]. -type RelayerAdapter struct { - types.Relayer - RelayerExt -} - -func (r *RelayerAdapter) NewChainWriter(ctx context.Context, contractWriterConfig []byte) (types.ChainWriter, error) { - return r.Relayer.NewChainWriter(ctx, contractWriterConfig) -} - -func (r *RelayerAdapter) NewContractReader(_ context.Context, contractReaderConfig []byte) (types.ContractReader, error) { - return r.Relayer.NewContractReader(contractReaderConfig) -} - -func (r *RelayerAdapter) NewConfigProvider(ctx context.Context, rargs types.RelayArgs) (types.ConfigProvider, error) { - return r.Relayer.NewConfigProvider(rargs) -} - -func (r *RelayerAdapter) NewMedianProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.MedianProvider, error) { - return r.Relayer.NewMedianProvider(rargs, pargs) -} - -func (r *RelayerAdapter) NewMercuryProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.MercuryProvider, error) { - return r.Relayer.NewMercuryProvider(rargs, pargs) -} - -func (r *RelayerAdapter) NewFunctionsProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.FunctionsProvider, error) { - return r.Relayer.NewFunctionsProvider(rargs, pargs) -} - -func (r *RelayerAdapter) NewAutomationProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.AutomationProvider, error) { - return r.Relayer.NewAutomationProvider(rargs, pargs) -} - -func (r *RelayerAdapter) NewLLOProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.LLOProvider, error) { - return r.Relayer.NewLLOProvider(rargs, pargs) -} - -func (r *RelayerAdapter) NewCCIPCommitProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.CCIPCommitProvider, error) { - return r.Relayer.NewCCIPCommitProvider(rargs, pargs) -} - -func (r *RelayerAdapter) NewCCIPExecProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.CCIPExecProvider, error) { - return r.Relayer.NewCCIPExecProvider(rargs, pargs) -} - -func (r *RelayerAdapter) NewPluginProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.PluginProvider, error) { - return r.Relayer.NewPluginProvider(rargs, pargs) -} - -func (r *RelayerAdapter) NewOCR3CapabilityProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.OCR3CapabilityProvider, error) { - return r.Relayer.NewOCR3CapabilityProvider(rargs, pargs) -} - -func (r *RelayerAdapter) Start(ctx context.Context) error { - var ms services.MultiStart - return ms.Start(ctx, r.RelayerExt, r.Relayer) -} - -func (r *RelayerAdapter) Close() error { - return services.CloseAll(r.Relayer, r.RelayerExt) -} - -func (r *RelayerAdapter) Name() string { - return r.Relayer.Name() -} - -func (r *RelayerAdapter) Ready() (err error) { - return r.Relayer.Ready() -} - -func (r *RelayerAdapter) HealthReport() map[string]error { - hr := make(map[string]error) - services.CopyHealth(hr, r.Relayer.HealthReport()) - return hr -} diff --git a/pkg/loop/adapters/relay/relay.go b/pkg/loop/adapters/relay/relay.go deleted file mode 100644 index c2772f855..000000000 --- a/pkg/loop/adapters/relay/relay.go +++ /dev/null @@ -1,43 +0,0 @@ -package relay - -import ( - "context" - "fmt" - - "github.com/smartcontractkit/chainlink-common/pkg/types" -) - -// ServerAdapter extends [loop.RelayerAdapter] by overriding NewPluginProvider to dispatches calls according to `RelayArgs.ProviderType`. -// This should only be used to adapt relayers not running via GRPC in a LOOPP. -type ServerAdapter struct { - RelayerAdapter -} - -// NewServerAdapter returns a new ServerAdapter. -func NewServerAdapter(r types.Relayer, e RelayerExt) *ServerAdapter { //nolint:staticcheck - return &ServerAdapter{RelayerAdapter: RelayerAdapter{Relayer: r, RelayerExt: e}} -} - -func (r *ServerAdapter) NewPluginProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.PluginProvider, error) { - switch types.OCR2PluginType(rargs.ProviderType) { - case types.Median: - return r.NewMedianProvider(ctx, rargs, pargs) - case types.Functions: - return r.NewFunctionsProvider(ctx, rargs, pargs) - case types.Mercury: - return r.NewMercuryProvider(ctx, rargs, pargs) - case types.OCR2Keeper: - return r.NewAutomationProvider(ctx, rargs, pargs) - case types.OCR3Capability: - return r.NewOCR3CapabilityProvider(ctx, rargs, pargs) - case types.CCIPCommit: - return r.NewCCIPCommitProvider(ctx, rargs, pargs) - case types.CCIPExecution: - return r.NewCCIPExecProvider(ctx, rargs, pargs) - case types.DKG, types.OCR2VRF, types.GenericPlugin: - return r.RelayerAdapter.NewPluginProvider(ctx, rargs, pargs) - case types.LLO: - return nil, fmt.Errorf("provider type not supported: %s", rargs.ProviderType) - } - return nil, fmt.Errorf("provider type not recognized: %s", rargs.ProviderType) -} diff --git a/pkg/loop/adapters/relay/relay_test.go b/pkg/loop/adapters/relay/relay_test.go deleted file mode 100644 index 8b8420066..000000000 --- a/pkg/loop/adapters/relay/relay_test.go +++ /dev/null @@ -1,218 +0,0 @@ -package relay - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" - ocr2types "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - - "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" - - "github.com/smartcontractkit/chainlink-common/pkg/types" -) - -type staticMedianProvider struct { -} - -var _ types.MedianProvider = staticMedianProvider{} - -// ContractConfigTracker implements types.MedianProvider. -func (s staticMedianProvider) ContractConfigTracker() ocr2types.ContractConfigTracker { - return nil -} - -// ContractTransmitter implements types.MedianProvider. -func (s staticMedianProvider) ContractTransmitter() ocr2types.ContractTransmitter { - return nil -} - -// MedianContract implements types.MedianProvider. -func (s staticMedianProvider) MedianContract() median.MedianContract { - return nil -} - -// OffchainConfigDigester implements types.MedianProvider. -func (s staticMedianProvider) OffchainConfigDigester() ocr2types.OffchainConfigDigester { - return nil -} - -// OnchainConfigCodec implements types.MedianProvider. -func (s staticMedianProvider) OnchainConfigCodec() median.OnchainConfigCodec { - return nil -} - -// ReportCodec implements types.MedianProvider. -func (s staticMedianProvider) ReportCodec() median.ReportCodec { - return nil -} - -// ContractReader implements types.MedianProvider. -func (s staticMedianProvider) ContractReader() types.ContractReader { - return nil -} - -// Close implements types.MedianProvider. -func (s staticMedianProvider) Close() error { - return nil -} - -// Codec implements types.MedianProvider. -func (s staticMedianProvider) Codec() types.Codec { - return nil -} - -// HealthReport implements types.MedianProvider. -func (s staticMedianProvider) HealthReport() map[string]error { - return nil -} - -// Name implements types.MedianProvider. -func (s staticMedianProvider) Name() string { - return "" -} - -// Ready implements types.MedianProvider. -func (s staticMedianProvider) Ready() error { - return nil -} - -// Start implements types.MedianProvider. -func (s staticMedianProvider) Start(context.Context) error { - return nil -} - -type staticFunctionsProvider struct { - types.FunctionsProvider -} - -type staticMercuryProvider struct { - types.MercuryProvider -} - -type staticAutomationProvider struct { - types.AutomationProvider -} - -type staticPluginProvider struct { - types.PluginProvider -} - -type staticOCR3CapabilityProvider struct { - types.OCR3CapabilityProvider -} - -type staticCCIPCommitProvider struct { - types.CCIPCommitProvider -} - -type staticCCIPExecProvider struct { - types.CCIPExecProvider -} - -type mockRelayer struct { - types.Relayer -} - -func (m *mockRelayer) NewMedianProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.MedianProvider, error) { - return staticMedianProvider{}, nil -} - -func (m *mockRelayer) NewFunctionsProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.FunctionsProvider, error) { - return staticFunctionsProvider{}, nil -} - -func (m *mockRelayer) NewMercuryProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.MercuryProvider, error) { - return staticMercuryProvider{}, nil -} - -func (m *mockRelayer) NewAutomationProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.AutomationProvider, error) { - return staticAutomationProvider{}, nil -} - -func (m *mockRelayer) NewPluginProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.PluginProvider, error) { - return staticPluginProvider{}, nil -} - -func (m *mockRelayer) NewOCR3CapabilityProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.OCR3CapabilityProvider, error) { - return staticOCR3CapabilityProvider{}, nil -} - -func (m *mockRelayer) NewCCIPCommitProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.CCIPCommitProvider, error) { - return staticCCIPCommitProvider{}, nil -} - -func (m *mockRelayer) NewCCIPExecProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.CCIPExecProvider, error) { - return staticCCIPExecProvider{}, nil -} - -type mockRelayerExt struct { - RelayerExt -} - -func isType[T any](p any) bool { - _, ok := p.(T) - return ok -} - -func TestRelayerServerAdapter(t *testing.T) { - r := &mockRelayer{} - sa := NewServerAdapter(r, mockRelayerExt{}) - - testCases := []struct { - ProviderType string - Test func(p any) bool - Error string - }{ - { - ProviderType: string(types.Median), - Test: isType[types.MedianProvider], - }, - { - ProviderType: string(types.Functions), - Test: isType[types.FunctionsProvider], - }, - { - ProviderType: string(types.Mercury), - Test: isType[types.MercuryProvider], - }, - { - ProviderType: string(types.CCIPCommit), - Test: isType[types.CCIPCommitProvider], - }, - { - ProviderType: string(types.CCIPExecution), - Test: isType[types.CCIPExecProvider], - }, - { - ProviderType: "unknown", - Error: "provider type not recognized", - }, - { - ProviderType: string(types.GenericPlugin), - Test: isType[types.PluginProvider], - }, - { - ProviderType: string(types.OCR3Capability), - Test: isType[types.OCR3CapabilityProvider], - }, - } - - ctx := tests.Context(t) - for _, tc := range testCases { - pp, err := sa.NewPluginProvider( - ctx, - types.RelayArgs{ProviderType: tc.ProviderType}, - types.PluginArgs{}, - ) - - if tc.Error != "" { - assert.ErrorContains(t, err, tc.Error) - } else { - assert.NoError(t, err) - assert.True(t, tc.Test(pp), tc.ProviderType) - } - } -} diff --git a/pkg/loop/ccip_commit.go b/pkg/loop/ccip_commit.go index b73c31921..119de6128 100644 --- a/pkg/loop/ccip_commit.go +++ b/pkg/loop/ccip_commit.go @@ -84,9 +84,9 @@ func NewCommitService(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec.Cm return &cfs } -func (m *CommitFactoryService) NewReportingPlugin(config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { +func (m *CommitFactoryService) NewReportingPlugin(ctx context.Context, config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { if err := m.Wait(); err != nil { return nil, ocrtypes.ReportingPluginInfo{}, err } - return m.Service.NewReportingPlugin(config) + return m.Service.NewReportingPlugin(ctx, config) } diff --git a/pkg/loop/ccip_commit_test.go b/pkg/loop/ccip_commit_test.go index f17f27cb1..c3956ffd8 100644 --- a/pkg/loop/ccip_commit_test.go +++ b/pkg/loop/ccip_commit_test.go @@ -1,7 +1,6 @@ package loop_test import ( - "context" "os/exec" "sync/atomic" "testing" @@ -21,6 +20,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/test" "github.com/smartcontractkit/chainlink-common/pkg/services/servicetest" "github.com/smartcontractkit/chainlink-common/pkg/types" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" ) func TestCommitService(t *testing.T) { @@ -110,7 +110,7 @@ func TestCommitLOOP(t *testing.T) { } func newCommitProvider(t *testing.T, pr loop.PluginRelayer) (types.CCIPCommitProvider, error) { - ctx := context.Background() + ctx := tests.Context(t) r, err := pr.NewRelayer(ctx, test.ConfigTOML, keystoretest.Keystore, nil) require.NoError(t, err) servicetest.Run(t, r) diff --git a/pkg/loop/ccip_execution.go b/pkg/loop/ccip_execution.go index c78382bd4..099580c74 100644 --- a/pkg/loop/ccip_execution.go +++ b/pkg/loop/ccip_execution.go @@ -84,9 +84,9 @@ func NewExecutionService(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec return &efs } -func (m *ExecutionFactoryService) NewReportingPlugin(config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { +func (m *ExecutionFactoryService) NewReportingPlugin(ctx context.Context, config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { if err := m.Wait(); err != nil { return nil, ocrtypes.ReportingPluginInfo{}, err } - return m.Service.NewReportingPlugin(config) + return m.Service.NewReportingPlugin(ctx, config) } diff --git a/pkg/loop/ccip_execution_test.go b/pkg/loop/ccip_execution_test.go index 2e7fd45ce..b26f44bdf 100644 --- a/pkg/loop/ccip_execution_test.go +++ b/pkg/loop/ccip_execution_test.go @@ -1,7 +1,6 @@ package loop_test import ( - "context" "os/exec" "sync/atomic" "testing" @@ -21,6 +20,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/test" "github.com/smartcontractkit/chainlink-common/pkg/services/servicetest" "github.com/smartcontractkit/chainlink-common/pkg/types" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" ) func TestExecService(t *testing.T) { @@ -111,7 +111,7 @@ func TestExecLOOP(t *testing.T) { } func newExecutionProvider(t *testing.T, pr loop.PluginRelayer) (types.CCIPExecProvider, error) { - ctx := context.Background() + ctx := tests.Context(t) r, err := pr.NewRelayer(ctx, test.ConfigTOML, keystoretest.Keystore, nil) require.NoError(t, err) servicetest.Run(t, r) diff --git a/pkg/loop/internal/core/services/keyvalue/store_test.go b/pkg/loop/internal/core/services/keyvalue/store_test.go index c9d6fd628..70dca6a58 100644 --- a/pkg/loop/internal/core/services/keyvalue/store_test.go +++ b/pkg/loop/internal/core/services/keyvalue/store_test.go @@ -9,29 +9,32 @@ import ( "google.golang.org/protobuf/types/known/emptypb" "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/pb" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" ) func Test_KeyValueStoreClient(t *testing.T) { + ctx := tests.Context(t) // Setup client := Client{grpc: &testGrpcClient{store: make(map[string][]byte)}} key := "key" insertedVal := "aval" - err := client.Store(context.Background(), key, []byte(insertedVal)) + err := client.Store(ctx, key, []byte(insertedVal)) assert.NoError(t, err) - retrievedVal, err := client.Get(context.Background(), key) + retrievedVal, err := client.Get(ctx, key) assert.NoError(t, err) assert.Equal(t, insertedVal, string(retrievedVal)) } func Test_KeyValueStoreServer(t *testing.T) { + ctx := tests.Context(t) // Setup server := Server{impl: &testKeyValueStore{store: make(map[string][]byte)}} - _, err := server.StoreKeyValue(context.Background(), &pb.StoreKeyValueRequest{Key: "key", Value: []byte(`{"A":"a","B":1}`)}) + _, err := server.StoreKeyValue(ctx, &pb.StoreKeyValueRequest{Key: "key", Value: []byte(`{"A":"a","B":1}`)}) assert.NoError(t, err) - resp, err := server.GetValueForKey(context.Background(), &pb.GetValueForKeyRequest{Key: "key"}) + resp, err := server.GetValueForKey(ctx, &pb.GetValueForKeyRequest{Key: "key"}) assert.NoError(t, err) assert.Equal(t, []byte(`{"A":"a","B":1}`), resp.Value) } diff --git a/pkg/loop/internal/core/services/pipeline/pipeline_runner_test.go b/pkg/loop/internal/core/services/pipeline/pipeline_runner_test.go index d1ed65209..b404ce0a7 100644 --- a/pkg/loop/internal/core/services/pipeline/pipeline_runner_test.go +++ b/pkg/loop/internal/core/services/pipeline/pipeline_runner_test.go @@ -13,6 +13,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/pb" "github.com/smartcontractkit/chainlink-common/pkg/types/core" "github.com/smartcontractkit/chainlink-common/pkg/utils/jsonserializable" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" ) type mockPipelineRunner struct { @@ -37,6 +38,7 @@ func (c *clientAdapter) ExecuteRun(ctx context.Context, in *pb.RunRequest, opts } func TestPipelineRunnerService(t *testing.T) { + ctx := tests.Context(t) originalResults := []core.TaskResult{ { ID: "1", @@ -64,7 +66,7 @@ func TestPipelineRunnerService(t *testing.T) { client := &pipelineRunnerServiceClient{grpc: &clientAdapter{srv: srv}} trs, err := client.ExecuteRun( - context.Background(), + ctx, "my-spec", core.Vars{Vars: map[string]interface{}{"my-vars": true}}, core.Options{MaxTaskDuration: 10 * time.Second}, @@ -74,6 +76,7 @@ func TestPipelineRunnerService(t *testing.T) { } func TestPipelineRunnerService_CallArgs(t *testing.T) { + ctx := tests.Context(t) mpr := &mockPipelineRunner{} srv := &RunnerServer{impl: mpr} client := &pipelineRunnerServiceClient{grpc: &clientAdapter{srv: srv}} @@ -85,7 +88,7 @@ func TestPipelineRunnerService_CallArgs(t *testing.T) { options := core.Options{ MaxTaskDuration: 10 * time.Second, } - _, err := client.ExecuteRun(context.Background(), spec, vars, options) + _, err := client.ExecuteRun(ctx, spec, vars, options) require.NoError(t, err) assert.Equal(t, spec, mpr.spec) assert.Equal(t, vars, mpr.vars) diff --git a/pkg/loop/internal/core/services/reportingplugin/ocr2/reporting.go b/pkg/loop/internal/core/services/reportingplugin/ocr2/reporting.go index fa95f2e80..fa4603e3b 100644 --- a/pkg/loop/internal/core/services/reportingplugin/ocr2/reporting.go +++ b/pkg/loop/internal/core/services/reportingplugin/ocr2/reporting.go @@ -29,9 +29,7 @@ func NewReportingPluginFactoryClient(b *net.BrokerExt, cc grpc.ClientConnInterfa } } -func (r *ReportingPluginFactoryClient) NewReportingPlugin(config libocr.ReportingPluginConfig) (libocr.ReportingPlugin, libocr.ReportingPluginInfo, error) { - ctx, cancel := r.StopCtx() - defer cancel() +func (r *ReportingPluginFactoryClient) NewReportingPlugin(ctx context.Context, config libocr.ReportingPluginConfig) (libocr.ReportingPlugin, libocr.ReportingPluginInfo, error) { reply, err := r.grpc.NewReportingPlugin(ctx, &pb.NewReportingPluginRequest{ReportingPluginConfig: &pb.ReportingPluginConfig{ ConfigDigest: config.ConfigDigest[:], OracleID: uint32(config.OracleID), @@ -98,7 +96,7 @@ func (r *ReportingPluginFactoryServer) NewReportingPlugin(ctx context.Context, r } copy(cfg.ConfigDigest[:], request.ReportingPluginConfig.ConfigDigest) - rp, rpi, err := r.impl.NewReportingPlugin(cfg) + rp, rpi, err := r.impl.NewReportingPlugin(ctx, cfg) if err != nil { return nil, err } diff --git a/pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go b/pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go index 62796c6e0..e373c42c4 100644 --- a/pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go +++ b/pkg/loop/internal/core/services/reportingplugin/ocr3/reporting.go @@ -5,11 +5,12 @@ import ( "math" "time" + "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/emptypb" + "github.com/smartcontractkit/libocr/commontypes" "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" libocr "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - "google.golang.org/grpc" - "google.golang.org/protobuf/types/known/emptypb" "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/goplugin" "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/net" @@ -27,9 +28,7 @@ func NewReportingPluginFactoryClient(b *net.BrokerExt, cc grpc.ClientConnInterfa return &reportingPluginFactoryClient{b.WithName("OCR3ReportingPluginProviderClient"), goplugin.NewServiceClient(b, cc), ocr3.NewReportingPluginFactoryClient(cc)} } -func (r *reportingPluginFactoryClient) NewReportingPlugin(config ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[[]byte], ocr3types.ReportingPluginInfo, error) { - ctx, cancel := r.StopCtx() - defer cancel() +func (r *reportingPluginFactoryClient) NewReportingPlugin(ctx context.Context, config ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[[]byte], ocr3types.ReportingPluginInfo, error) { reply, err := r.grpc.NewReportingPlugin(ctx, &ocr3.NewReportingPluginRequest{ReportingPluginConfig: &ocr3.ReportingPluginConfig{ ConfigDigest: config.ConfigDigest[:], OracleID: uint32(config.OracleID), @@ -96,7 +95,7 @@ func (r *reportingPluginFactoryServer) NewReportingPlugin(ctx context.Context, r } copy(cfg.ConfigDigest[:], request.ReportingPluginConfig.ConfigDigest) - rp, rpi, err := r.impl.NewReportingPlugin(cfg) + rp, rpi, err := r.impl.NewReportingPlugin(ctx, cfg) if err != nil { return nil, err } @@ -150,9 +149,7 @@ func (o *reportingPluginClient) Observation(ctx context.Context, outctx ocr3type return reply.Observation, nil } -func (o *reportingPluginClient) ValidateObservation(outctx ocr3types.OutcomeContext, query libocr.Query, ao libocr.AttributedObservation) error { - ctx, cancel := o.StopCtx() - defer cancel() +func (o *reportingPluginClient) ValidateObservation(ctx context.Context, outctx ocr3types.OutcomeContext, query libocr.Query, ao libocr.AttributedObservation) error { _, err := o.grpc.ValidateObservation(ctx, &ocr3.ValidateObservationRequest{ OutcomeContext: pbOutcomeContext(outctx), Query: query, @@ -161,22 +158,19 @@ func (o *reportingPluginClient) ValidateObservation(outctx ocr3types.OutcomeCont return err } -func (o *reportingPluginClient) ObservationQuorum(outctx ocr3types.OutcomeContext, query libocr.Query) (ocr3types.Quorum, error) { - ctx, cancel := o.StopCtx() - defer cancel() +func (o *reportingPluginClient) ObservationQuorum(ctx context.Context, outctx ocr3types.OutcomeContext, query libocr.Query, aos []libocr.AttributedObservation) (bool, error) { reply, err := o.grpc.ObservationQuorum(ctx, &ocr3.ObservationQuorumRequest{ OutcomeContext: pbOutcomeContext(outctx), Query: query, + Ao: pbAttributedObservations(aos), }) if err != nil { - return 0, err + return false, err } - return ocr3types.Quorum(reply.Quorum), nil + return reply.QuorumReached, nil } -func (o *reportingPluginClient) Outcome(outctx ocr3types.OutcomeContext, query libocr.Query, aos []libocr.AttributedObservation) (ocr3types.Outcome, error) { - ctx, cancel := o.StopCtx() - defer cancel() +func (o *reportingPluginClient) Outcome(ctx context.Context, outctx ocr3types.OutcomeContext, query libocr.Query, aos []libocr.AttributedObservation) (ocr3types.Outcome, error) { reply, err := o.grpc.Outcome(ctx, &ocr3.OutcomeRequest{ OutcomeContext: pbOutcomeContext(outctx), Query: query, @@ -188,9 +182,7 @@ func (o *reportingPluginClient) Outcome(outctx ocr3types.OutcomeContext, query l return reply.Outcome, nil } -func (o *reportingPluginClient) Reports(seqNr uint64, outcome ocr3types.Outcome) ([]ocr3types.ReportWithInfo[[]byte], error) { - ctx, cancel := o.StopCtx() - defer cancel() +func (o *reportingPluginClient) Reports(ctx context.Context, seqNr uint64, outcome ocr3types.Outcome) ([]ocr3types.ReportPlus[[]byte], error) { reply, err := o.grpc.Reports(ctx, &ocr3.ReportsRequest{ SeqNr: seqNr, Outcome: outcome, @@ -198,7 +190,7 @@ func (o *reportingPluginClient) Reports(seqNr uint64, outcome ocr3types.Outcome) if err != nil { return nil, err } - return reportsWithInfo(reply.ReportWithInfo), nil + return reportsPlus(reply.ReportPlus), nil } func (o *reportingPluginClient) ShouldAcceptAttestedReport(ctx context.Context, u uint64, ri ocr3types.ReportWithInfo[[]byte]) (bool, error) { @@ -265,16 +257,20 @@ func (o *reportingPluginServer) ValidateObservation(ctx context.Context, request if err != nil { return nil, err } - err = o.impl.ValidateObservation(outcomeContext(request.OutcomeContext), request.Query, ao) + err = o.impl.ValidateObservation(ctx, outcomeContext(request.OutcomeContext), request.Query, ao) return new(emptypb.Empty), err } func (o *reportingPluginServer) ObservationQuorum(ctx context.Context, request *ocr3.ObservationQuorumRequest) (*ocr3.ObservationQuorumReply, error) { - oq, err := o.impl.ObservationQuorum(outcomeContext(request.OutcomeContext), request.Query) + aos, err := attributedObservations(request.Ao) + if err != nil { + return nil, err + } + oq, err := o.impl.ObservationQuorum(ctx, outcomeContext(request.OutcomeContext), request.Query, aos) if err != nil { return nil, err } - return &ocr3.ObservationQuorumReply{Quorum: int32(oq)}, nil + return &ocr3.ObservationQuorumReply{QuorumReached: oq}, nil } func (o *reportingPluginServer) Outcome(ctx context.Context, request *ocr3.OutcomeRequest) (*ocr3.OutcomeReply, error) { @@ -282,7 +278,7 @@ func (o *reportingPluginServer) Outcome(ctx context.Context, request *ocr3.Outco if err != nil { return nil, err } - out, err := o.impl.Outcome(outcomeContext(request.OutcomeContext), request.Query, aos) + out, err := o.impl.Outcome(ctx, outcomeContext(request.OutcomeContext), request.Query, aos) if err != nil { return nil, err } @@ -292,12 +288,12 @@ func (o *reportingPluginServer) Outcome(ctx context.Context, request *ocr3.Outco } func (o *reportingPluginServer) Reports(ctx context.Context, request *ocr3.ReportsRequest) (*ocr3.ReportsReply, error) { - ri, err := o.impl.Reports(request.SeqNr, request.Outcome) + rp, err := o.impl.Reports(ctx, request.SeqNr, request.Outcome) if err != nil { return nil, err } return &ocr3.ReportsReply{ - ReportWithInfo: pbReportsWithInfo(ri), + ReportPlus: pbReportsPlus(rp), }, nil } @@ -347,16 +343,33 @@ func pbAttributedObservation(ao libocr.AttributedObservation) *ocr3.AttributedOb } } -func pbReportsWithInfo(rwi []ocr3types.ReportWithInfo[[]byte]) (ri []*ocr3.ReportWithInfo) { +func pbReportsPlus(rwi []ocr3types.ReportPlus[[]byte]) (ri []*ocr3.ReportPlus) { for _, r := range rwi { - ri = append(ri, &ocr3.ReportWithInfo{ - Report: r.Report, - Info: r.Info, + ri = append(ri, &ocr3.ReportPlus{ + ReportWithInfo: &ocr3.ReportWithInfo{ + Report: r.ReportWithInfo.Report, + Info: r.ReportWithInfo.Info, + }, + TransmissionScheduleOverride: pbTransmissionSchedule(r.TransmissionScheduleOverride), }) } return } +func pbTransmissionSchedule(s *ocr3types.TransmissionSchedule) *ocr3.TransmissionSchedule { + if s == nil { + return nil + } + var pb ocr3.TransmissionSchedule + for _, t := range s.Transmitters { + pb.Transmitters = append(pb.Transmitters, uint32(t)) + } + for _, td := range s.TransmissionDelays { + pb.TransmissionDelays = append(pb.TransmissionDelays, int64(td)) + } + return &pb +} + func pbAttributedObservations(aos []libocr.AttributedObservation) (pbaos []*ocr3.AttributedObservation) { for _, ao := range aos { pbaos = append(pbaos, pbAttributedObservation(ao)) @@ -395,12 +408,29 @@ func attributedObservations(pbo []*ocr3.AttributedObservation) (o []libocr.Attri return } -func reportsWithInfo(ri []*ocr3.ReportWithInfo) (rwi []ocr3types.ReportWithInfo[[]byte]) { +func reportsPlus(ri []*ocr3.ReportPlus) (rwi []ocr3types.ReportPlus[[]byte]) { for _, r := range ri { - rwi = append(rwi, ocr3types.ReportWithInfo[[]byte]{ - Report: r.Report, - Info: r.Info, + rwi = append(rwi, ocr3types.ReportPlus[[]byte]{ + ReportWithInfo: ocr3types.ReportWithInfo[[]byte]{ + Report: r.ReportWithInfo.Report, + Info: r.ReportWithInfo.Info, + }, + TransmissionScheduleOverride: transmissionSchedule(r.TransmissionScheduleOverride), }) } return } + +func transmissionSchedule(pb *ocr3.TransmissionSchedule) *ocr3types.TransmissionSchedule { + if pb == nil { + return nil + } + var ts ocr3types.TransmissionSchedule + for _, t := range pb.Transmitters { + ts.Transmitters = append(ts.Transmitters, commontypes.OracleID(t)) + } + for _, td := range pb.TransmissionDelays { + ts.TransmissionDelays = append(ts.TransmissionDelays, time.Duration(td)) + } + return &ts +} diff --git a/pkg/loop/internal/core/services/reportingplugin/ocr3/test/factory.go b/pkg/loop/internal/core/services/reportingplugin/ocr3/test/factory.go index e36fc9227..df93d7812 100644 --- a/pkg/loop/internal/core/services/reportingplugin/ocr3/test/factory.go +++ b/pkg/loop/internal/core/services/reportingplugin/ocr3/test/factory.go @@ -40,7 +40,7 @@ func (o ocr3staticPluginFactory) Ready() error { panic("implement me") } func (o ocr3staticPluginFactory) HealthReport() map[string]error { panic("implement me") } -func (o ocr3staticPluginFactory) NewReportingPlugin(config ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[[]byte], ocr3types.ReportingPluginInfo, error) { +func (o ocr3staticPluginFactory) NewReportingPlugin(ctx context.Context, config ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[[]byte], ocr3types.ReportingPluginInfo, error) { err := o.equalConfig(config) if err != nil { return nil, ocr3types.ReportingPluginInfo{}, fmt.Errorf("config mismatch: %w", err) @@ -89,7 +89,7 @@ func OCR3ReportingPluginFactory(t *testing.T, factory core.OCR3ReportingPluginFa expectedFactory := Factory t.Run("OCR3ReportingPluginFactory", func(t *testing.T) { ctx := tests.Context(t) - rp, gotRPI, err := factory.NewReportingPlugin(ocr3reportingPluginConfig) + rp, gotRPI, err := factory.NewReportingPlugin(ctx, ocr3reportingPluginConfig) require.NoError(t, err) assert.Equal(t, ocr3rpi, gotRPI) t.Cleanup(func() { assert.NoError(t, rp.Close()) }) diff --git a/pkg/loop/internal/core/services/reportingplugin/ocr3/test/reporting_plugin.go b/pkg/loop/internal/core/services/reportingplugin/ocr3/test/reporting_plugin.go index e6b42f197..d52954d64 100644 --- a/pkg/loop/internal/core/services/reportingplugin/ocr3/test/reporting_plugin.go +++ b/pkg/loop/internal/core/services/reportingplugin/ocr3/test/reporting_plugin.go @@ -5,7 +5,9 @@ import ( "context" "fmt" "testing" + "time" + "github.com/smartcontractkit/libocr/commontypes" "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" libocr "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/stretchr/testify/assert" @@ -33,11 +35,12 @@ var ReportingPlugin = ocr3staticReportingPlugin{ observation: libocr.Observation{1, 2, 3}, }, observationQuorumRequest: observationQuorumRequest{ - outcomeCtx: outcomeCtx, - query: query, + outcomeCtx: outcomeCtx, + query: query, + observations: []libocr.AttributedObservation{{Observer: 1, Observation: []byte{1, 2, 3}}}, }, observationQuorumResponse: observationQuorumResponse{ - quorum: 1, + quorumReached: true, }, validateObservationRequest: validateObservationRequest{ outcomeCtx: outcomeCtx, @@ -57,8 +60,14 @@ var ReportingPlugin = ocr3staticReportingPlugin{ outcome: ocr3types.Outcome{1, 2, 3}, }, reportsResponse: reportsResponse{ - reportWithInfo: []ocr3types.ReportWithInfo[[]byte]{ - {Report: []byte{1, 2, 3}, Info: []byte{1, 2, 3}}, + reportPlus: []ocr3types.ReportPlus[[]byte]{ + { + ReportWithInfo: ocr3types.ReportWithInfo[[]byte]{Report: []byte{1, 2, 3}, Info: []byte{1, 2, 3}}, + TransmissionScheduleOverride: &ocr3types.TransmissionSchedule{ + Transmitters: []commontypes.OracleID{1, 2, 3}, + TransmissionDelays: []time.Duration{time.Second, time.Millisecond}, + }, + }, }, }, shouldAcceptAttestedReportRequest: shouldAcceptAttestedReportRequest{ @@ -97,12 +106,13 @@ type observationResponse struct { } type observationQuorumRequest struct { - outcomeCtx ocr3types.OutcomeContext - query libocr.Query + outcomeCtx ocr3types.OutcomeContext + query libocr.Query + observations []libocr.AttributedObservation } type observationQuorumResponse struct { - quorum ocr3types.Quorum + quorumReached bool } type validateObservationRequest struct { @@ -127,7 +137,7 @@ type reportsRequest struct { } type reportsResponse struct { - reportWithInfo []ocr3types.ReportWithInfo[[]byte] + reportPlus []ocr3types.ReportPlus[[]byte] } type shouldAcceptAttestedReportRequest struct { @@ -200,7 +210,7 @@ func (s ocr3staticReportingPlugin) Observation(ctx context.Context, outcomeCtx o return s.observationResponse.observation, nil } -func (s ocr3staticReportingPlugin) ValidateObservation(outcomeCtx ocr3types.OutcomeContext, q libocr.Query, a libocr.AttributedObservation) error { +func (s ocr3staticReportingPlugin) ValidateObservation(ctx context.Context, outcomeCtx ocr3types.OutcomeContext, q libocr.Query, a libocr.AttributedObservation) error { err := s.checkOutCtx(outcomeCtx) if err != nil { return err @@ -220,19 +230,22 @@ func (s ocr3staticReportingPlugin) ValidateObservation(outcomeCtx ocr3types.Outc return nil } -func (s ocr3staticReportingPlugin) ObservationQuorum(outcomeCtx ocr3types.OutcomeContext, q libocr.Query) (ocr3types.Quorum, error) { +func (s ocr3staticReportingPlugin) ObservationQuorum(ctx context.Context, outcomeCtx ocr3types.OutcomeContext, q libocr.Query, aos []libocr.AttributedObservation) (bool, error) { err := s.checkOutCtx(outcomeCtx) if err != nil { - return ocr3types.Quorum(0), err + return false, err } if !bytes.Equal(q, s.observationQuorumRequest.query) { - return ocr3types.Quorum(0), fmt.Errorf("expected %x but got %x", s.observationQuorumRequest.query, q) + return false, fmt.Errorf("expected %x but got %x", s.observationQuorumRequest.query, q) + } + if !assert.ObjectsAreEqual(aos, s.observationQuorumRequest.observations) { + return false, fmt.Errorf("expected %v but got %v", s.observationQuorumRequest.observations, aos) } - return s.observationQuorumResponse.quorum, nil + return s.observationQuorumResponse.quorumReached, nil } -func (s ocr3staticReportingPlugin) Outcome(outcomeCtx ocr3types.OutcomeContext, q libocr.Query, aos []libocr.AttributedObservation) (ocr3types.Outcome, error) { +func (s ocr3staticReportingPlugin) Outcome(ctx context.Context, outcomeCtx ocr3types.OutcomeContext, q libocr.Query, aos []libocr.AttributedObservation) (ocr3types.Outcome, error) { err := s.checkOutCtx(outcomeCtx) if err != nil { return nil, err @@ -247,7 +260,7 @@ func (s ocr3staticReportingPlugin) Outcome(outcomeCtx ocr3types.OutcomeContext, return s.outcomeResponse.outcome, nil } -func (s ocr3staticReportingPlugin) Reports(seq uint64, o ocr3types.Outcome) ([]ocr3types.ReportWithInfo[[]byte], error) { +func (s ocr3staticReportingPlugin) Reports(ctx context.Context, seq uint64, o ocr3types.Outcome) ([]ocr3types.ReportPlus[[]byte], error) { if seq != s.reportsRequest.seq { return nil, fmt.Errorf("expected %x but got %x", s.reportsRequest.seq, seq) } @@ -256,7 +269,7 @@ func (s ocr3staticReportingPlugin) Reports(seq uint64, o ocr3types.Outcome) ([]o return nil, fmt.Errorf("expected %x but got %x", s.reportsRequest.outcome, o) } - return s.reportsResponse.reportWithInfo, nil + return s.reportsResponse.reportPlus, nil } func (s ocr3staticReportingPlugin) ShouldAcceptAttestedReport(ctx context.Context, u uint64, r ocr3types.ReportWithInfo[[]byte]) (bool, error) { @@ -300,20 +313,20 @@ func (s ocr3staticReportingPlugin) AssertEqual(ctx context.Context, t *testing.T require.NoError(t, err) assert.Equal(t, s.observationResponse.observation, gotObs) - err = rp.ValidateObservation(s.validateObservationRequest.outcomeCtx, s.validateObservationRequest.query, s.validateObservationRequest.attributedObservation) + err = rp.ValidateObservation(ctx, s.validateObservationRequest.outcomeCtx, s.validateObservationRequest.query, s.validateObservationRequest.attributedObservation) require.NoError(t, err) - gotQuorum, err := rp.ObservationQuorum(s.observationQuorumRequest.outcomeCtx, s.observationQuorumRequest.query) + gotQuorum, err := rp.ObservationQuorum(ctx, s.observationQuorumRequest.outcomeCtx, s.observationQuorumRequest.query, s.observationQuorumRequest.observations) require.NoError(t, err) - assert.Equal(t, s.observationQuorumResponse.quorum, gotQuorum) + assert.Equal(t, s.observationQuorumResponse.quorumReached, gotQuorum) - gotOutcome, err := rp.Outcome(s.outcomeRequest.outcomeCtx, s.outcomeRequest.query, s.outcomeRequest.observations) + gotOutcome, err := rp.Outcome(ctx, s.outcomeRequest.outcomeCtx, s.outcomeRequest.query, s.outcomeRequest.observations) require.NoError(t, err) assert.Equal(t, s.outcomeResponse.outcome, gotOutcome) - gotRI, err := rp.Reports(s.reportsRequest.seq, s.reportsRequest.outcome) + gotRI, err := rp.Reports(ctx, s.reportsRequest.seq, s.reportsRequest.outcome) require.NoError(t, err) - assert.Equal(t, s.reportsResponse.reportWithInfo, gotRI) + assert.Equal(t, s.reportsResponse.reportPlus, gotRI) gotShouldAccept, err := rp.ShouldAcceptAttestedReport(ctx, s.shouldAcceptAttestedReportRequest.seq, s.shouldAcceptAttestedReportRequest.r) require.NoError(t, err) diff --git a/pkg/loop/internal/core/services/telemetry/test/telemetry.go b/pkg/loop/internal/core/services/telemetry/test/telemetry.go index 5aa60cdba..33d30f9d7 100644 --- a/pkg/loop/internal/core/services/telemetry/test/telemetry.go +++ b/pkg/loop/internal/core/services/telemetry/test/telemetry.go @@ -12,6 +12,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/core/services/telemetry" testtypes "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/test/types" "github.com/smartcontractkit/chainlink-common/pkg/types/core" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" ) var Telemetry = staticTelemetry{ @@ -113,6 +114,7 @@ func (m mockClientConn) NewStream(ctx context.Context, desc *grpc.StreamDesc, me } func TestTelemetry(t *testing.T) { + ctx := tests.Context(t) tsc := telemetry.NewTelemetryServiceClient(mockClientConn{}) c := telemetry.NewTelemetryClient(tsc) @@ -184,7 +186,7 @@ func TestTelemetry(t *testing.T) { } for _, test := range sendTests { - err := c.Send(context.Background(), test.network, test.chainID, test.contractID, test.telemetryType, test.payload) + err := c.Send(ctx, test.network, test.chainID, test.contractID, test.telemetryType, test.payload) if test.shouldError { require.ErrorContains(t, err, test.error) } else { @@ -245,14 +247,14 @@ func TestTelemetry(t *testing.T) { } for _, test := range genMonitoringEndpointTests { - e, err := c.NewEndpoint(context.Background(), test.network, test.chainID, test.contractID, test.telemetryType) + e, err := c.NewEndpoint(ctx, test.network, test.chainID, test.contractID, test.telemetryType) if test.shouldError { require.Nil(t, e) require.ErrorContains(t, err, test.error) } else { require.NotNil(t, e) require.Nil(t, err) - require.Nil(t, e.SendLog(context.Background(), []byte("some-data"))) + require.Nil(t, e.SendLog(ctx, []byte("some-data"))) } } } diff --git a/pkg/loop/internal/pb/ocr3/ocr3_reporting.pb.go b/pkg/loop/internal/pb/ocr3/ocr3_reporting.pb.go index 9481f0350..cf9e80a81 100644 --- a/pkg/loop/internal/pb/ocr3/ocr3_reporting.pb.go +++ b/pkg/loop/internal/pb/ocr3/ocr3_reporting.pb.go @@ -774,8 +774,9 @@ type ObservationQuorumRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - OutcomeContext *OutcomeContext `protobuf:"bytes,1,opt,name=outcomeContext,proto3" json:"outcomeContext,omitempty"` - Query []byte `protobuf:"bytes,2,opt,name=query,proto3" json:"query,omitempty"` + OutcomeContext *OutcomeContext `protobuf:"bytes,1,opt,name=outcomeContext,proto3" json:"outcomeContext,omitempty"` + Query []byte `protobuf:"bytes,2,opt,name=query,proto3" json:"query,omitempty"` + Ao []*AttributedObservation `protobuf:"bytes,3,rep,name=ao,proto3" json:"ao,omitempty"` } func (x *ObservationQuorumRequest) Reset() { @@ -824,12 +825,19 @@ func (x *ObservationQuorumRequest) GetQuery() []byte { return nil } +func (x *ObservationQuorumRequest) GetAo() []*AttributedObservation { + if x != nil { + return x.Ao + } + return nil +} + type ObservationQuorumReply struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Quorum int32 `protobuf:"varint,1,opt,name=quorum,proto3" json:"quorum,omitempty"` + QuorumReached bool `protobuf:"varint,1,opt,name=quorumReached,proto3" json:"quorumReached,omitempty"` } func (x *ObservationQuorumReply) Reset() { @@ -864,11 +872,11 @@ func (*ObservationQuorumReply) Descriptor() ([]byte, []int) { return file_ocr3_reporting_proto_rawDescGZIP(), []int{13} } -func (x *ObservationQuorumReply) GetQuorum() int32 { +func (x *ObservationQuorumReply) GetQuorumReached() bool { if x != nil { - return x.Quorum + return x.QuorumReached } - return 0 + return false } type OutcomeRequest struct { @@ -1041,7 +1049,7 @@ type ReportsReply struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ReportWithInfo []*ReportWithInfo `protobuf:"bytes,1,rep,name=ReportWithInfo,proto3" json:"ReportWithInfo,omitempty"` + ReportPlus []*ReportPlus `protobuf:"bytes,1,rep,name=reportPlus,proto3" json:"reportPlus,omitempty"` } func (x *ReportsReply) Reset() { @@ -1076,13 +1084,68 @@ func (*ReportsReply) Descriptor() ([]byte, []int) { return file_ocr3_reporting_proto_rawDescGZIP(), []int{17} } -func (x *ReportsReply) GetReportWithInfo() []*ReportWithInfo { +func (x *ReportsReply) GetReportPlus() []*ReportPlus { + if x != nil { + return x.ReportPlus + } + return nil +} + +type ReportPlus struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ReportWithInfo *ReportWithInfo `protobuf:"bytes,1,opt,name=reportWithInfo,proto3" json:"reportWithInfo,omitempty"` + TransmissionScheduleOverride *TransmissionSchedule `protobuf:"bytes,2,opt,name=transmissionScheduleOverride,proto3" json:"transmissionScheduleOverride,omitempty"` +} + +func (x *ReportPlus) Reset() { + *x = ReportPlus{} + if protoimpl.UnsafeEnabled { + mi := &file_ocr3_reporting_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReportPlus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReportPlus) ProtoMessage() {} + +func (x *ReportPlus) ProtoReflect() protoreflect.Message { + mi := &file_ocr3_reporting_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReportPlus.ProtoReflect.Descriptor instead. +func (*ReportPlus) Descriptor() ([]byte, []int) { + return file_ocr3_reporting_proto_rawDescGZIP(), []int{18} +} + +func (x *ReportPlus) GetReportWithInfo() *ReportWithInfo { if x != nil { return x.ReportWithInfo } return nil } +func (x *ReportPlus) GetTransmissionScheduleOverride() *TransmissionSchedule { + if x != nil { + return x.TransmissionScheduleOverride + } + return nil +} + type ReportWithInfo struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1095,7 +1158,7 @@ type ReportWithInfo struct { func (x *ReportWithInfo) Reset() { *x = ReportWithInfo{} if protoimpl.UnsafeEnabled { - mi := &file_ocr3_reporting_proto_msgTypes[18] + mi := &file_ocr3_reporting_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1108,7 +1171,7 @@ func (x *ReportWithInfo) String() string { func (*ReportWithInfo) ProtoMessage() {} func (x *ReportWithInfo) ProtoReflect() protoreflect.Message { - mi := &file_ocr3_reporting_proto_msgTypes[18] + mi := &file_ocr3_reporting_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1121,7 +1184,7 @@ func (x *ReportWithInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use ReportWithInfo.ProtoReflect.Descriptor instead. func (*ReportWithInfo) Descriptor() ([]byte, []int) { - return file_ocr3_reporting_proto_rawDescGZIP(), []int{18} + return file_ocr3_reporting_proto_rawDescGZIP(), []int{19} } func (x *ReportWithInfo) GetReport() []byte { @@ -1138,6 +1201,61 @@ func (x *ReportWithInfo) GetInfo() []byte { return nil } +type TransmissionSchedule struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Transmitters []uint32 `protobuf:"varint,1,rep,packed,name=transmitters,proto3" json:"transmitters,omitempty"` // OracleID + TransmissionDelays []int64 `protobuf:"varint,2,rep,packed,name=transmissionDelays,proto3" json:"transmissionDelays,omitempty"` +} + +func (x *TransmissionSchedule) Reset() { + *x = TransmissionSchedule{} + if protoimpl.UnsafeEnabled { + mi := &file_ocr3_reporting_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TransmissionSchedule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TransmissionSchedule) ProtoMessage() {} + +func (x *TransmissionSchedule) ProtoReflect() protoreflect.Message { + mi := &file_ocr3_reporting_proto_msgTypes[20] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TransmissionSchedule.ProtoReflect.Descriptor instead. +func (*TransmissionSchedule) Descriptor() ([]byte, []int) { + return file_ocr3_reporting_proto_rawDescGZIP(), []int{20} +} + +func (x *TransmissionSchedule) GetTransmitters() []uint32 { + if x != nil { + return x.Transmitters + } + return nil +} + +func (x *TransmissionSchedule) GetTransmissionDelays() []int64 { + if x != nil { + return x.TransmissionDelays + } + return nil +} + type ShouldAcceptAttestedReportRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1150,7 +1268,7 @@ type ShouldAcceptAttestedReportRequest struct { func (x *ShouldAcceptAttestedReportRequest) Reset() { *x = ShouldAcceptAttestedReportRequest{} if protoimpl.UnsafeEnabled { - mi := &file_ocr3_reporting_proto_msgTypes[19] + mi := &file_ocr3_reporting_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1163,7 +1281,7 @@ func (x *ShouldAcceptAttestedReportRequest) String() string { func (*ShouldAcceptAttestedReportRequest) ProtoMessage() {} func (x *ShouldAcceptAttestedReportRequest) ProtoReflect() protoreflect.Message { - mi := &file_ocr3_reporting_proto_msgTypes[19] + mi := &file_ocr3_reporting_proto_msgTypes[21] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1176,7 +1294,7 @@ func (x *ShouldAcceptAttestedReportRequest) ProtoReflect() protoreflect.Message // Deprecated: Use ShouldAcceptAttestedReportRequest.ProtoReflect.Descriptor instead. func (*ShouldAcceptAttestedReportRequest) Descriptor() ([]byte, []int) { - return file_ocr3_reporting_proto_rawDescGZIP(), []int{19} + return file_ocr3_reporting_proto_rawDescGZIP(), []int{21} } func (x *ShouldAcceptAttestedReportRequest) GetSegNr() uint64 { @@ -1204,7 +1322,7 @@ type ShouldAcceptAttestedReportReply struct { func (x *ShouldAcceptAttestedReportReply) Reset() { *x = ShouldAcceptAttestedReportReply{} if protoimpl.UnsafeEnabled { - mi := &file_ocr3_reporting_proto_msgTypes[20] + mi := &file_ocr3_reporting_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1217,7 +1335,7 @@ func (x *ShouldAcceptAttestedReportReply) String() string { func (*ShouldAcceptAttestedReportReply) ProtoMessage() {} func (x *ShouldAcceptAttestedReportReply) ProtoReflect() protoreflect.Message { - mi := &file_ocr3_reporting_proto_msgTypes[20] + mi := &file_ocr3_reporting_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1230,7 +1348,7 @@ func (x *ShouldAcceptAttestedReportReply) ProtoReflect() protoreflect.Message { // Deprecated: Use ShouldAcceptAttestedReportReply.ProtoReflect.Descriptor instead. func (*ShouldAcceptAttestedReportReply) Descriptor() ([]byte, []int) { - return file_ocr3_reporting_proto_rawDescGZIP(), []int{20} + return file_ocr3_reporting_proto_rawDescGZIP(), []int{22} } func (x *ShouldAcceptAttestedReportReply) GetShouldAccept() bool { @@ -1252,7 +1370,7 @@ type ShouldTransmitAcceptedReportRequest struct { func (x *ShouldTransmitAcceptedReportRequest) Reset() { *x = ShouldTransmitAcceptedReportRequest{} if protoimpl.UnsafeEnabled { - mi := &file_ocr3_reporting_proto_msgTypes[21] + mi := &file_ocr3_reporting_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1265,7 +1383,7 @@ func (x *ShouldTransmitAcceptedReportRequest) String() string { func (*ShouldTransmitAcceptedReportRequest) ProtoMessage() {} func (x *ShouldTransmitAcceptedReportRequest) ProtoReflect() protoreflect.Message { - mi := &file_ocr3_reporting_proto_msgTypes[21] + mi := &file_ocr3_reporting_proto_msgTypes[23] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1278,7 +1396,7 @@ func (x *ShouldTransmitAcceptedReportRequest) ProtoReflect() protoreflect.Messag // Deprecated: Use ShouldTransmitAcceptedReportRequest.ProtoReflect.Descriptor instead. func (*ShouldTransmitAcceptedReportRequest) Descriptor() ([]byte, []int) { - return file_ocr3_reporting_proto_rawDescGZIP(), []int{21} + return file_ocr3_reporting_proto_rawDescGZIP(), []int{23} } func (x *ShouldTransmitAcceptedReportRequest) GetSegNr() uint64 { @@ -1306,7 +1424,7 @@ type ShouldTransmitAcceptedReportReply struct { func (x *ShouldTransmitAcceptedReportReply) Reset() { *x = ShouldTransmitAcceptedReportReply{} if protoimpl.UnsafeEnabled { - mi := &file_ocr3_reporting_proto_msgTypes[22] + mi := &file_ocr3_reporting_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1319,7 +1437,7 @@ func (x *ShouldTransmitAcceptedReportReply) String() string { func (*ShouldTransmitAcceptedReportReply) ProtoMessage() {} func (x *ShouldTransmitAcceptedReportReply) ProtoReflect() protoreflect.Message { - mi := &file_ocr3_reporting_proto_msgTypes[22] + mi := &file_ocr3_reporting_proto_msgTypes[24] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1332,7 +1450,7 @@ func (x *ShouldTransmitAcceptedReportReply) ProtoReflect() protoreflect.Message // Deprecated: Use ShouldTransmitAcceptedReportReply.ProtoReflect.Descriptor instead. func (*ShouldTransmitAcceptedReportReply) Descriptor() ([]byte, []int) { - return file_ocr3_reporting_proto_rawDescGZIP(), []int{22} + return file_ocr3_reporting_proto_rawDescGZIP(), []int{24} } func (x *ShouldTransmitAcceptedReportReply) GetShouldTransmit() bool { @@ -1470,144 +1588,168 @@ var file_ocr3_reporting_proto_rawDesc = []byte{ 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x22, 0x7f, 0x0a, 0x18, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4d, - 0x0a, 0x0e, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4f, - 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x0e, 0x6f, - 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x14, 0x0a, - 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x71, 0x75, - 0x65, 0x72, 0x79, 0x22, 0x30, 0x0a, 0x16, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x16, 0x0a, - 0x06, 0x71, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x71, - 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x22, 0xb3, 0x01, 0x0a, 0x0e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4d, 0x0a, 0x0e, 0x6f, 0x75, 0x74, 0x63, - 0x6f, 0x6d, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x25, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, - 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, - 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x0e, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, - 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x3c, 0x0a, - 0x02, 0x61, 0x6f, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, - 0x33, 0x2e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64, 0x4f, 0x62, 0x73, 0x65, - 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x02, 0x61, 0x6f, 0x22, 0x28, 0x0a, 0x0c, 0x4f, - 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6f, - 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x75, - 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x22, 0x40, 0x0a, 0x0e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x65, 0x71, 0x4e, 0x72, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x73, 0x65, 0x71, 0x4e, 0x72, 0x12, 0x18, 0x0a, - 0x07, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, - 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x22, 0x5d, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, - 0x74, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x4d, 0x0a, 0x0e, 0x52, 0x65, 0x70, 0x6f, 0x72, - 0x74, 0x57, 0x69, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x25, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, - 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x69, - 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x69, - 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x3c, 0x0a, 0x0e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x65, 0x72, 0x22, 0xbd, 0x01, 0x0a, 0x18, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x4d, 0x0a, 0x0e, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, + 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x0e, + 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x14, + 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x71, + 0x75, 0x65, 0x72, 0x79, 0x12, 0x3c, 0x0a, 0x02, 0x61, 0x6f, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x2c, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, + 0x74, 0x65, 0x64, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x02, + 0x61, 0x6f, 0x22, 0x3e, 0x0a, 0x16, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x24, 0x0a, 0x0d, + 0x71, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x52, 0x65, 0x61, 0x63, 0x68, 0x65, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x0d, 0x71, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x52, 0x65, 0x61, 0x63, 0x68, + 0x65, 0x64, 0x22, 0xb3, 0x01, 0x0a, 0x0e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4d, 0x0a, 0x0e, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, + 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, + 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, + 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x43, 0x6f, 0x6e, + 0x74, 0x65, 0x78, 0x74, 0x52, 0x0e, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x43, 0x6f, 0x6e, + 0x74, 0x65, 0x78, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x3c, 0x0a, 0x02, 0x61, 0x6f, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x41, + 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x02, 0x61, 0x6f, 0x22, 0x28, 0x0a, 0x0c, 0x4f, 0x75, 0x74, 0x63, + 0x6f, 0x6d, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x75, 0x74, 0x63, + 0x6f, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x75, 0x74, 0x63, 0x6f, + 0x6d, 0x65, 0x22, 0x40, 0x0a, 0x0e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x65, 0x71, 0x4e, 0x72, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x05, 0x73, 0x65, 0x71, 0x4e, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x75, + 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x75, 0x74, + 0x63, 0x6f, 0x6d, 0x65, 0x22, 0x51, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x12, 0x41, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x6c, + 0x75, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, + 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x6c, 0x75, 0x73, 0x52, 0x0a, 0x72, 0x65, 0x70, + 0x6f, 0x72, 0x74, 0x50, 0x6c, 0x75, 0x73, 0x22, 0xcc, 0x01, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x50, 0x6c, 0x75, 0x73, 0x12, 0x4d, 0x0a, 0x0e, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x57, 0x69, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, + 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, + 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x69, 0x74, + 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0e, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x69, 0x74, + 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x6f, 0x0a, 0x1c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x4f, 0x76, 0x65, + 0x72, 0x72, 0x69, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x6c, 0x6f, + 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, + 0x63, 0x72, 0x33, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x1c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, + 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x4f, 0x76, + 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x22, 0x3c, 0x0a, 0x0e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x69, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, - 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x70, 0x0a, 0x21, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x41, 0x63, - 0x63, 0x65, 0x70, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, - 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x65, 0x67, - 0x4e, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x73, 0x65, 0x67, 0x4e, 0x72, 0x12, - 0x35, 0x0a, 0x02, 0x72, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6c, 0x6f, + 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x6a, 0x0a, 0x14, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x22, 0x0a, 0x0c, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0d, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x72, 0x73, + 0x12, 0x2e, 0x0a, 0x12, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x44, 0x65, 0x6c, 0x61, 0x79, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x03, 0x52, 0x12, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x73, + 0x22, 0x70, 0x0a, 0x21, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, + 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x65, 0x67, 0x4e, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x73, 0x65, 0x67, 0x4e, 0x72, 0x12, 0x35, 0x0a, 0x02, 0x72, + 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, + 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x69, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x02, + 0x72, 0x69, 0x22, 0x45, 0x0a, 0x1f, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x41, 0x63, 0x63, 0x65, + 0x70, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x41, + 0x63, 0x63, 0x65, 0x70, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x73, 0x68, 0x6f, + 0x75, 0x6c, 0x64, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x22, 0x72, 0x0a, 0x23, 0x53, 0x68, 0x6f, + 0x75, 0x6c, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, + 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x73, 0x65, 0x67, 0x4e, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x05, 0x73, 0x65, 0x67, 0x4e, 0x72, 0x12, 0x35, 0x0a, 0x02, 0x72, 0x69, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x57, 0x69, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x02, 0x72, 0x69, 0x22, 0x4b, 0x0a, + 0x21, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x41, + 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x70, + 0x6c, 0x79, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x73, 0x68, 0x6f, 0x75, + 0x6c, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x32, 0x92, 0x01, 0x0a, 0x16, 0x52, + 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x46, 0x61, + 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x78, 0x0a, 0x12, 0x4e, 0x65, 0x77, 0x52, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x30, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, - 0x63, 0x72, 0x33, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x69, 0x74, 0x68, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x02, 0x72, 0x69, 0x22, 0x45, 0x0a, 0x1f, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, - 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x65, - 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x68, 0x6f, - 0x75, 0x6c, 0x64, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0c, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x22, 0x72, 0x0a, - 0x23, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x41, - 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x65, 0x67, 0x4e, 0x72, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x05, 0x73, 0x65, 0x67, 0x4e, 0x72, 0x12, 0x35, 0x0a, 0x02, 0x72, 0x69, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x52, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x57, 0x69, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x02, 0x72, - 0x69, 0x22, 0x4b, 0x0a, 0x21, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x6d, 0x69, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, - 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, - 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x32, 0x92, - 0x01, 0x0a, 0x16, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x78, 0x0a, 0x12, 0x4e, 0x65, 0x77, - 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, - 0x30, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, - 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4e, 0x65, 0x77, 0x52, 0x65, 0x70, 0x6f, 0x72, - 0x74, 0x69, 0x6e, 0x67, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x2e, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, - 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4e, 0x65, 0x77, 0x52, 0x65, 0x70, - 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, - 0x79, 0x22, 0x00, 0x32, 0xbd, 0x07, 0x0a, 0x0f, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, - 0x67, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x51, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x12, 0x23, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, - 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x63, 0x0a, 0x0b, 0x4f, 0x62, - 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, - 0x33, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4f, 0x62, 0x73, - 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, - 0x62, 0x0a, 0x13, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x62, 0x73, 0x65, 0x72, - 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x31, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x56, + 0x63, 0x72, 0x33, 0x2e, 0x4e, 0x65, 0x77, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, + 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, + 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, + 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4e, 0x65, 0x77, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, + 0x6e, 0x67, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x32, + 0xbd, 0x07, 0x0a, 0x0f, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x12, 0x51, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x23, 0x2e, 0x6c, + 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, + 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x21, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x63, 0x0a, 0x0b, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4f, 0x62, + 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x27, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x62, 0x0a, 0x13, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x22, 0x00, 0x12, 0x75, 0x0a, 0x11, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x12, 0x2f, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, + 0x6f, 0x6e, 0x12, 0x31, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x65, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, + 0x75, 0x0a, 0x11, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x51, 0x75, + 0x6f, 0x72, 0x75, 0x6d, 0x12, 0x2f, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4f, 0x62, 0x73, + 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4f, 0x62, + 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x07, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, + 0x65, 0x12, 0x25, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, - 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x51, 0x75, 0x6f, 0x72, - 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, - 0x33, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x51, 0x75, 0x6f, - 0x72, 0x75, 0x6d, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x07, 0x4f, 0x75, - 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x12, 0x25, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4f, 0x75, - 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x6c, - 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, - 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x52, 0x65, 0x70, 0x6c, - 0x79, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x07, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x25, - 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, - 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x52, 0x65, - 0x70, 0x6f, 0x72, 0x74, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x90, 0x01, 0x0a, - 0x1a, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x41, 0x74, 0x74, - 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x38, 0x2e, 0x6c, 0x6f, - 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, - 0x63, 0x72, 0x33, 0x2e, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, - 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x53, 0x68, - 0x6f, 0x75, 0x6c, 0x64, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, - 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, - 0x96, 0x01, 0x0a, 0x1c, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, - 0x69, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, - 0x12, 0x3a, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, - 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x54, - 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x52, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, 0x6c, + 0x2e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, + 0x57, 0x0a, 0x07, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x25, 0x2e, 0x6c, 0x6f, 0x6f, + 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, + 0x72, 0x33, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x23, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x90, 0x01, 0x0a, 0x1a, 0x53, 0x68, 0x6f, + 0x75, 0x6c, 0x64, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, + 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x38, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, + 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x41, 0x74, 0x74, 0x65, + 0x73, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x36, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, + 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x65, + 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x96, 0x01, 0x0a, 0x1c, + 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x41, 0x63, + 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x3a, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x2e, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, - 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x05, 0x43, 0x6c, 0x6f, 0x73, - 0x65, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x22, 0x00, 0x42, 0x4f, 0x5a, 0x4d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x73, 0x6d, 0x61, 0x72, 0x74, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x6b, - 0x69, 0x74, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x2d, 0x63, 0x6f, 0x6d, - 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x62, 0x2f, 0x6f, 0x63, 0x72, 0x33, 0x3b, 0x6f, 0x63, - 0x72, 0x33, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x2e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x6f, 0x63, 0x72, 0x33, + 0x2e, 0x53, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x74, 0x41, + 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x70, + 0x6c, 0x79, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x05, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x12, 0x16, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, + 0x4f, 0x5a, 0x4d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x6d, + 0x61, 0x72, 0x74, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x6b, 0x69, 0x74, 0x2f, 0x63, + 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, + 0x70, 0x6b, 0x67, 0x2f, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x2f, 0x70, 0x62, 0x2f, 0x6f, 0x63, 0x72, 0x33, 0x3b, 0x6f, 0x63, 0x72, 0x33, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1622,7 +1764,7 @@ func file_ocr3_reporting_proto_rawDescGZIP() []byte { return file_ocr3_reporting_proto_rawDescData } -var file_ocr3_reporting_proto_msgTypes = make([]protoimpl.MessageInfo, 23) +var file_ocr3_reporting_proto_msgTypes = make([]protoimpl.MessageInfo, 25) var file_ocr3_reporting_proto_goTypes = []interface{}{ (*NewReportingPluginRequest)(nil), // 0: loop.internal.pb.ocr3.NewReportingPluginRequest (*NewReportingPluginReply)(nil), // 1: loop.internal.pb.ocr3.NewReportingPluginReply @@ -1642,12 +1784,14 @@ var file_ocr3_reporting_proto_goTypes = []interface{}{ (*OutcomeReply)(nil), // 15: loop.internal.pb.ocr3.OutcomeReply (*ReportsRequest)(nil), // 16: loop.internal.pb.ocr3.ReportsRequest (*ReportsReply)(nil), // 17: loop.internal.pb.ocr3.ReportsReply - (*ReportWithInfo)(nil), // 18: loop.internal.pb.ocr3.ReportWithInfo - (*ShouldAcceptAttestedReportRequest)(nil), // 19: loop.internal.pb.ocr3.ShouldAcceptAttestedReportRequest - (*ShouldAcceptAttestedReportReply)(nil), // 20: loop.internal.pb.ocr3.ShouldAcceptAttestedReportReply - (*ShouldTransmitAcceptedReportRequest)(nil), // 21: loop.internal.pb.ocr3.ShouldTransmitAcceptedReportRequest - (*ShouldTransmitAcceptedReportReply)(nil), // 22: loop.internal.pb.ocr3.ShouldTransmitAcceptedReportReply - (*emptypb.Empty)(nil), // 23: google.protobuf.Empty + (*ReportPlus)(nil), // 18: loop.internal.pb.ocr3.ReportPlus + (*ReportWithInfo)(nil), // 19: loop.internal.pb.ocr3.ReportWithInfo + (*TransmissionSchedule)(nil), // 20: loop.internal.pb.ocr3.TransmissionSchedule + (*ShouldAcceptAttestedReportRequest)(nil), // 21: loop.internal.pb.ocr3.ShouldAcceptAttestedReportRequest + (*ShouldAcceptAttestedReportReply)(nil), // 22: loop.internal.pb.ocr3.ShouldAcceptAttestedReportReply + (*ShouldTransmitAcceptedReportRequest)(nil), // 23: loop.internal.pb.ocr3.ShouldTransmitAcceptedReportRequest + (*ShouldTransmitAcceptedReportReply)(nil), // 24: loop.internal.pb.ocr3.ShouldTransmitAcceptedReportReply + (*emptypb.Empty)(nil), // 25: google.protobuf.Empty } var file_ocr3_reporting_proto_depIdxs = []int32{ 2, // 0: loop.internal.pb.ocr3.NewReportingPluginRequest.reportingPluginConfig:type_name -> loop.internal.pb.ocr3.ReportingPluginConfig @@ -1658,36 +1802,39 @@ var file_ocr3_reporting_proto_depIdxs = []int32{ 6, // 5: loop.internal.pb.ocr3.ValidateObservationRequest.outcomeContext:type_name -> loop.internal.pb.ocr3.OutcomeContext 11, // 6: loop.internal.pb.ocr3.ValidateObservationRequest.ao:type_name -> loop.internal.pb.ocr3.AttributedObservation 6, // 7: loop.internal.pb.ocr3.ObservationQuorumRequest.outcomeContext:type_name -> loop.internal.pb.ocr3.OutcomeContext - 6, // 8: loop.internal.pb.ocr3.OutcomeRequest.outcomeContext:type_name -> loop.internal.pb.ocr3.OutcomeContext - 11, // 9: loop.internal.pb.ocr3.OutcomeRequest.ao:type_name -> loop.internal.pb.ocr3.AttributedObservation - 18, // 10: loop.internal.pb.ocr3.ReportsReply.ReportWithInfo:type_name -> loop.internal.pb.ocr3.ReportWithInfo - 18, // 11: loop.internal.pb.ocr3.ShouldAcceptAttestedReportRequest.ri:type_name -> loop.internal.pb.ocr3.ReportWithInfo - 18, // 12: loop.internal.pb.ocr3.ShouldTransmitAcceptedReportRequest.ri:type_name -> loop.internal.pb.ocr3.ReportWithInfo - 0, // 13: loop.internal.pb.ocr3.ReportingPluginFactory.NewReportingPlugin:input_type -> loop.internal.pb.ocr3.NewReportingPluginRequest - 5, // 14: loop.internal.pb.ocr3.ReportingPlugin.Query:input_type -> loop.internal.pb.ocr3.QueryRequest - 8, // 15: loop.internal.pb.ocr3.ReportingPlugin.Observation:input_type -> loop.internal.pb.ocr3.ObservationRequest - 10, // 16: loop.internal.pb.ocr3.ReportingPlugin.ValidateObservation:input_type -> loop.internal.pb.ocr3.ValidateObservationRequest - 12, // 17: loop.internal.pb.ocr3.ReportingPlugin.ObservationQuorum:input_type -> loop.internal.pb.ocr3.ObservationQuorumRequest - 14, // 18: loop.internal.pb.ocr3.ReportingPlugin.Outcome:input_type -> loop.internal.pb.ocr3.OutcomeRequest - 16, // 19: loop.internal.pb.ocr3.ReportingPlugin.Reports:input_type -> loop.internal.pb.ocr3.ReportsRequest - 19, // 20: loop.internal.pb.ocr3.ReportingPlugin.ShouldAcceptAttestedReport:input_type -> loop.internal.pb.ocr3.ShouldAcceptAttestedReportRequest - 21, // 21: loop.internal.pb.ocr3.ReportingPlugin.ShouldTransmitAcceptedReport:input_type -> loop.internal.pb.ocr3.ShouldTransmitAcceptedReportRequest - 23, // 22: loop.internal.pb.ocr3.ReportingPlugin.Close:input_type -> google.protobuf.Empty - 1, // 23: loop.internal.pb.ocr3.ReportingPluginFactory.NewReportingPlugin:output_type -> loop.internal.pb.ocr3.NewReportingPluginReply - 7, // 24: loop.internal.pb.ocr3.ReportingPlugin.Query:output_type -> loop.internal.pb.ocr3.QueryReply - 9, // 25: loop.internal.pb.ocr3.ReportingPlugin.Observation:output_type -> loop.internal.pb.ocr3.ObservationReply - 23, // 26: loop.internal.pb.ocr3.ReportingPlugin.ValidateObservation:output_type -> google.protobuf.Empty - 13, // 27: loop.internal.pb.ocr3.ReportingPlugin.ObservationQuorum:output_type -> loop.internal.pb.ocr3.ObservationQuorumReply - 15, // 28: loop.internal.pb.ocr3.ReportingPlugin.Outcome:output_type -> loop.internal.pb.ocr3.OutcomeReply - 17, // 29: loop.internal.pb.ocr3.ReportingPlugin.Reports:output_type -> loop.internal.pb.ocr3.ReportsReply - 20, // 30: loop.internal.pb.ocr3.ReportingPlugin.ShouldAcceptAttestedReport:output_type -> loop.internal.pb.ocr3.ShouldAcceptAttestedReportReply - 22, // 31: loop.internal.pb.ocr3.ReportingPlugin.ShouldTransmitAcceptedReport:output_type -> loop.internal.pb.ocr3.ShouldTransmitAcceptedReportReply - 23, // 32: loop.internal.pb.ocr3.ReportingPlugin.Close:output_type -> google.protobuf.Empty - 23, // [23:33] is the sub-list for method output_type - 13, // [13:23] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 11, // 8: loop.internal.pb.ocr3.ObservationQuorumRequest.ao:type_name -> loop.internal.pb.ocr3.AttributedObservation + 6, // 9: loop.internal.pb.ocr3.OutcomeRequest.outcomeContext:type_name -> loop.internal.pb.ocr3.OutcomeContext + 11, // 10: loop.internal.pb.ocr3.OutcomeRequest.ao:type_name -> loop.internal.pb.ocr3.AttributedObservation + 18, // 11: loop.internal.pb.ocr3.ReportsReply.reportPlus:type_name -> loop.internal.pb.ocr3.ReportPlus + 19, // 12: loop.internal.pb.ocr3.ReportPlus.reportWithInfo:type_name -> loop.internal.pb.ocr3.ReportWithInfo + 20, // 13: loop.internal.pb.ocr3.ReportPlus.transmissionScheduleOverride:type_name -> loop.internal.pb.ocr3.TransmissionSchedule + 19, // 14: loop.internal.pb.ocr3.ShouldAcceptAttestedReportRequest.ri:type_name -> loop.internal.pb.ocr3.ReportWithInfo + 19, // 15: loop.internal.pb.ocr3.ShouldTransmitAcceptedReportRequest.ri:type_name -> loop.internal.pb.ocr3.ReportWithInfo + 0, // 16: loop.internal.pb.ocr3.ReportingPluginFactory.NewReportingPlugin:input_type -> loop.internal.pb.ocr3.NewReportingPluginRequest + 5, // 17: loop.internal.pb.ocr3.ReportingPlugin.Query:input_type -> loop.internal.pb.ocr3.QueryRequest + 8, // 18: loop.internal.pb.ocr3.ReportingPlugin.Observation:input_type -> loop.internal.pb.ocr3.ObservationRequest + 10, // 19: loop.internal.pb.ocr3.ReportingPlugin.ValidateObservation:input_type -> loop.internal.pb.ocr3.ValidateObservationRequest + 12, // 20: loop.internal.pb.ocr3.ReportingPlugin.ObservationQuorum:input_type -> loop.internal.pb.ocr3.ObservationQuorumRequest + 14, // 21: loop.internal.pb.ocr3.ReportingPlugin.Outcome:input_type -> loop.internal.pb.ocr3.OutcomeRequest + 16, // 22: loop.internal.pb.ocr3.ReportingPlugin.Reports:input_type -> loop.internal.pb.ocr3.ReportsRequest + 21, // 23: loop.internal.pb.ocr3.ReportingPlugin.ShouldAcceptAttestedReport:input_type -> loop.internal.pb.ocr3.ShouldAcceptAttestedReportRequest + 23, // 24: loop.internal.pb.ocr3.ReportingPlugin.ShouldTransmitAcceptedReport:input_type -> loop.internal.pb.ocr3.ShouldTransmitAcceptedReportRequest + 25, // 25: loop.internal.pb.ocr3.ReportingPlugin.Close:input_type -> google.protobuf.Empty + 1, // 26: loop.internal.pb.ocr3.ReportingPluginFactory.NewReportingPlugin:output_type -> loop.internal.pb.ocr3.NewReportingPluginReply + 7, // 27: loop.internal.pb.ocr3.ReportingPlugin.Query:output_type -> loop.internal.pb.ocr3.QueryReply + 9, // 28: loop.internal.pb.ocr3.ReportingPlugin.Observation:output_type -> loop.internal.pb.ocr3.ObservationReply + 25, // 29: loop.internal.pb.ocr3.ReportingPlugin.ValidateObservation:output_type -> google.protobuf.Empty + 13, // 30: loop.internal.pb.ocr3.ReportingPlugin.ObservationQuorum:output_type -> loop.internal.pb.ocr3.ObservationQuorumReply + 15, // 31: loop.internal.pb.ocr3.ReportingPlugin.Outcome:output_type -> loop.internal.pb.ocr3.OutcomeReply + 17, // 32: loop.internal.pb.ocr3.ReportingPlugin.Reports:output_type -> loop.internal.pb.ocr3.ReportsReply + 22, // 33: loop.internal.pb.ocr3.ReportingPlugin.ShouldAcceptAttestedReport:output_type -> loop.internal.pb.ocr3.ShouldAcceptAttestedReportReply + 24, // 34: loop.internal.pb.ocr3.ReportingPlugin.ShouldTransmitAcceptedReport:output_type -> loop.internal.pb.ocr3.ShouldTransmitAcceptedReportReply + 25, // 35: loop.internal.pb.ocr3.ReportingPlugin.Close:output_type -> google.protobuf.Empty + 26, // [26:36] is the sub-list for method output_type + 16, // [16:26] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name } func init() { file_ocr3_reporting_proto_init() } @@ -1913,7 +2060,7 @@ func file_ocr3_reporting_proto_init() { } } file_ocr3_reporting_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReportWithInfo); i { + switch v := v.(*ReportPlus); i { case 0: return &v.state case 1: @@ -1925,7 +2072,7 @@ func file_ocr3_reporting_proto_init() { } } file_ocr3_reporting_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ShouldAcceptAttestedReportRequest); i { + switch v := v.(*ReportWithInfo); i { case 0: return &v.state case 1: @@ -1937,7 +2084,7 @@ func file_ocr3_reporting_proto_init() { } } file_ocr3_reporting_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ShouldAcceptAttestedReportReply); i { + switch v := v.(*TransmissionSchedule); i { case 0: return &v.state case 1: @@ -1949,7 +2096,7 @@ func file_ocr3_reporting_proto_init() { } } file_ocr3_reporting_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ShouldTransmitAcceptedReportRequest); i { + switch v := v.(*ShouldAcceptAttestedReportRequest); i { case 0: return &v.state case 1: @@ -1961,6 +2108,30 @@ func file_ocr3_reporting_proto_init() { } } file_ocr3_reporting_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ShouldAcceptAttestedReportReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ocr3_reporting_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ShouldTransmitAcceptedReportRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ocr3_reporting_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ShouldTransmitAcceptedReportReply); i { case 0: return &v.state @@ -1979,7 +2150,7 @@ func file_ocr3_reporting_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_ocr3_reporting_proto_rawDesc, NumEnums: 0, - NumMessages: 23, + NumMessages: 25, NumExtensions: 0, NumServices: 2, }, diff --git a/pkg/loop/internal/pb/ocr3/ocr3_reporting.proto b/pkg/loop/internal/pb/ocr3/ocr3_reporting.proto index 444fbe050..dd2c31c5f 100644 --- a/pkg/loop/internal/pb/ocr3/ocr3_reporting.proto +++ b/pkg/loop/internal/pb/ocr3/ocr3_reporting.proto @@ -98,10 +98,11 @@ message AttributedObservation{ message ObservationQuorumRequest { OutcomeContext outcomeContext=1; bytes query=2; + repeated AttributedObservation ao=3; } message ObservationQuorumReply { - int32 quorum =1; + bool quorumReached=1; } message OutcomeRequest{ @@ -120,7 +121,12 @@ message ReportsRequest{ } message ReportsReply{ - repeated ReportWithInfo ReportWithInfo=1; + repeated ReportPlus reportPlus=1; +} + +message ReportPlus{ + ReportWithInfo reportWithInfo=1; + TransmissionSchedule transmissionScheduleOverride=2; } message ReportWithInfo{ @@ -128,6 +134,11 @@ message ReportWithInfo{ bytes info=2; } +message TransmissionSchedule{ + repeated uint32 transmitters=1; // OracleID + repeated int64 transmissionDelays=2; +} + message ShouldAcceptAttestedReportRequest{ uint64 segNr=1; ReportWithInfo ri=2; diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/commit_provider.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/commit_provider.go index 5865eaf7f..4f9cd5294 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/commit_provider.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/commit_provider.go @@ -165,12 +165,12 @@ func (e *CommitProviderServer) Close(context.Context, *emptypb.Empty) (*emptypb. // NewCommitStoreReader implements ccippb.CommitCustomHandlersServer. func (e *CommitProviderServer) NewCommitStoreReader(ctx context.Context, req *ccippb.NewCommitStoreReaderRequest) (*ccippb.NewCommitStoreReaderResponse, error) { - reader, err := e.impl.NewCommitStoreReader(context.Background(), ccip.Address(req.Address)) + reader, err := e.impl.NewCommitStoreReader(ctx, ccip.Address(req.Address)) if err != nil { return nil, err } // wrap the reader in a grpc server and serve it - commitStoreHandler, err := NewCommitStoreReaderGRPCServer(reader, e.BrokerExt) + commitStoreHandler, err := NewCommitStoreReaderGRPCServer(ctx, reader, e.BrokerExt) if err != nil { return nil, fmt.Errorf("failed to create offramp reader grpc server: %w", err) } @@ -198,7 +198,7 @@ func (e *CommitProviderServer) NewOffRampReader(ctx context.Context, req *ccippb return nil, err } // wrap the reader in a grpc server and serve it - offRampHandler, err := NewOffRampReaderGRPCServer(reader, e.BrokerExt) + offRampHandler, err := NewOffRampReaderGRPCServer(ctx, reader, e.BrokerExt) if err != nil { return nil, fmt.Errorf("failed to create offramp reader grpc server: %w", err) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/commit_store.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/commit_store.go index c99d3fcca..4b821417b 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/commit_store.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/commit_store.go @@ -57,8 +57,8 @@ type CommitStoreGRPCServer struct { deps []io.Closer } -func NewCommitStoreReaderGRPCServer(impl ccip.CommitStoreReader, brokerExt *net.BrokerExt) (*CommitStoreGRPCServer, error) { - estimator, err := impl.GasPriceEstimator(context.Background()) +func NewCommitStoreReaderGRPCServer(ctx context.Context, impl ccip.CommitStoreReader, brokerExt *net.BrokerExt) (*CommitStoreGRPCServer, error) { + estimator, err := impl.GasPriceEstimator(ctx) if err != nil { return nil, err } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/execution_provider.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/execution_provider.go index a8a6db7d8..7e862c99c 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/execution_provider.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/execution_provider.go @@ -203,12 +203,12 @@ func (e *ExecProviderServer) Close(context.Context, *emptypb.Empty) (*emptypb.Em // NewCommitStoreReader implements ccippb.ExecutionCustomHandlersServer. func (e *ExecProviderServer) NewCommitStoreReader(ctx context.Context, req *ccippb.NewCommitStoreReaderRequest) (*ccippb.NewCommitStoreReaderResponse, error) { - reader, err := e.impl.NewCommitStoreReader(context.Background(), ccip.Address(req.Address)) + reader, err := e.impl.NewCommitStoreReader(ctx, ccip.Address(req.Address)) if err != nil { return nil, err } // wrap the reader in a grpc server and serve it - commitStoreHandler, err := NewCommitStoreReaderGRPCServer(reader, e.BrokerExt) + commitStoreHandler, err := NewCommitStoreReaderGRPCServer(ctx, reader, e.BrokerExt) if err != nil { return nil, fmt.Errorf("failed to create offramp reader grpc server: %w", err) } @@ -244,7 +244,7 @@ func (e *ExecProviderServer) NewOffRampReader(ctx context.Context, req *ccippb.N return nil, err } // wrap the reader in a grpc server and serve it - offRampHandler, err := NewOffRampReaderGRPCServer(reader, e.BrokerExt) + offRampHandler, err := NewOffRampReaderGRPCServer(ctx, reader, e.BrokerExt) if err != nil { return nil, fmt.Errorf("failed to create offramp reader grpc server: %w", err) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/gas_estimator.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/gas_estimator.go index 5288b209a..a839525ef 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/gas_estimator.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/gas_estimator.go @@ -53,8 +53,8 @@ func (c *CommitGasEstimatorGRPCClient) Close() error { } // DenoteInUSD implements ccip.GasPriceEstimatorCommit. -func (c *CommitGasEstimatorGRPCClient) DenoteInUSD(p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error) { - resp, err := c.client.DenoteInUSD(context.Background(), &ccippb.DenoteInUSDRequest{ +func (c *CommitGasEstimatorGRPCClient) DenoteInUSD(ctx context.Context, p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error) { + resp, err := c.client.DenoteInUSD(ctx, &ccippb.DenoteInUSDRequest{ P: pb.NewBigIntFromInt(p), WrappedNativePrice: pb.NewBigIntFromInt(wrappedNativePrice), }) @@ -65,8 +65,8 @@ func (c *CommitGasEstimatorGRPCClient) DenoteInUSD(p *big.Int, wrappedNativePric } // Deviates implements ccip.GasPriceEstimatorCommit. -func (c *CommitGasEstimatorGRPCClient) Deviates(p1 *big.Int, p2 *big.Int) (bool, error) { - resp, err := c.client.Deviates(context.Background(), &ccippb.DeviatesRequest{ +func (c *CommitGasEstimatorGRPCClient) Deviates(ctx context.Context, p1 *big.Int, p2 *big.Int) (bool, error) { + resp, err := c.client.Deviates(ctx, &ccippb.DeviatesRequest{ P1: pb.NewBigIntFromInt(p1), P2: pb.NewBigIntFromInt(p2), }) @@ -86,8 +86,8 @@ func (c *CommitGasEstimatorGRPCClient) GetGasPrice(ctx context.Context) (*big.In } // Median implements ccip.GasPriceEstimatorCommit. -func (c *CommitGasEstimatorGRPCClient) Median(gasPrices []*big.Int) (*big.Int, error) { - resp, err := c.client.Median(context.Background(), &ccippb.MedianRequest{ +func (c *CommitGasEstimatorGRPCClient) Median(ctx context.Context, gasPrices []*big.Int) (*big.Int, error) { + resp, err := c.client.Median(ctx, &ccippb.MedianRequest{ GasPrices: bigIntSlicePB(gasPrices), }) if err != nil { @@ -100,7 +100,7 @@ func (c *CommitGasEstimatorGRPCClient) Median(gasPrices []*big.Int) (*big.Int, e // DenoteInUSD implements ccippb.GasPriceEstimatorCommitServer. func (c *CommitGasEstimatorGRPCServer) DenoteInUSD(ctx context.Context, req *ccippb.DenoteInUSDRequest) (*ccippb.DenoteInUSDResponse, error) { - usd, err := c.impl.DenoteInUSD(req.P.Int(), req.WrappedNativePrice.Int()) + usd, err := c.impl.DenoteInUSD(ctx, req.P.Int(), req.WrappedNativePrice.Int()) if err != nil { return nil, err } @@ -109,7 +109,7 @@ func (c *CommitGasEstimatorGRPCServer) DenoteInUSD(ctx context.Context, req *cci // Deviates implements ccippb.GasPriceEstimatorCommitServer. func (c *CommitGasEstimatorGRPCServer) Deviates(ctx context.Context, req *ccippb.DeviatesRequest) (*ccippb.DeviatesResponse, error) { - deviates, err := c.impl.Deviates(req.P1.Int(), req.P2.Int()) + deviates, err := c.impl.Deviates(ctx, req.P1.Int(), req.P2.Int()) if err != nil { return nil, err } @@ -127,7 +127,7 @@ func (c *CommitGasEstimatorGRPCServer) GetGasPrice(ctx context.Context, req *emp // Median implements ccippb.GasPriceEstimatorCommitServer. func (c *CommitGasEstimatorGRPCServer) Median(ctx context.Context, req *ccippb.MedianRequest) (*ccippb.MedianResponse, error) { - gasPrice, err := c.impl.Median(bigIntSlice(req.GasPrices)) + gasPrice, err := c.impl.Median(ctx, bigIntSlice(req.GasPrices)) if err != nil { return nil, err } @@ -174,8 +174,8 @@ func (e *ExecGasEstimatorGRPCClient) Close() error { } // DenoteInUSD implements ccip.GasPriceEstimatorExec. -func (e *ExecGasEstimatorGRPCClient) DenoteInUSD(p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error) { - resp, err := e.client.DenoteInUSD(context.Background(), &ccippb.DenoteInUSDRequest{ +func (e *ExecGasEstimatorGRPCClient) DenoteInUSD(ctx context.Context, p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error) { + resp, err := e.client.DenoteInUSD(ctx, &ccippb.DenoteInUSDRequest{ P: pb.NewBigIntFromInt(p), WrappedNativePrice: pb.NewBigIntFromInt(wrappedNativePrice), }) @@ -186,9 +186,9 @@ func (e *ExecGasEstimatorGRPCClient) DenoteInUSD(p *big.Int, wrappedNativePrice } // EstimateMsgCostUSD implements ccip.GasPriceEstimatorExec. -func (e *ExecGasEstimatorGRPCClient) EstimateMsgCostUSD(p *big.Int, wrappedNativePrice *big.Int, msg cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error) { +func (e *ExecGasEstimatorGRPCClient) EstimateMsgCostUSD(ctx context.Context, p *big.Int, wrappedNativePrice *big.Int, msg cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error) { msgPB := evm2EVMOnRampCCIPSendRequestedWithMeta(&msg) - resp, err := e.client.EstimateMsgCostUSD(context.Background(), &ccippb.EstimateMsgCostUSDRequest{ + resp, err := e.client.EstimateMsgCostUSD(ctx, &ccippb.EstimateMsgCostUSDRequest{ P: pb.NewBigIntFromInt(p), WrappedNativePrice: pb.NewBigIntFromInt(wrappedNativePrice), Msg: msgPB, @@ -209,8 +209,8 @@ func (e *ExecGasEstimatorGRPCClient) GetGasPrice(ctx context.Context) (*big.Int, } // Median implements ccip.GasPriceEstimatorExec. -func (e *ExecGasEstimatorGRPCClient) Median(gasPrices []*big.Int) (*big.Int, error) { - resp, err := e.client.Median(context.Background(), &ccippb.MedianRequest{ +func (e *ExecGasEstimatorGRPCClient) Median(ctx context.Context, gasPrices []*big.Int) (*big.Int, error) { + resp, err := e.client.Median(ctx, &ccippb.MedianRequest{ GasPrices: bigIntSlicePB(gasPrices), }) if err != nil { @@ -221,7 +221,7 @@ func (e *ExecGasEstimatorGRPCClient) Median(gasPrices []*big.Int) (*big.Int, err // DenoteInUSD implements ccippb.GasPriceEstimatorExecServer. func (e *ExecGasEstimatorGRPCServer) DenoteInUSD(ctx context.Context, req *ccippb.DenoteInUSDRequest) (*ccippb.DenoteInUSDResponse, error) { - usd, err := e.impl.DenoteInUSD(req.P.Int(), req.WrappedNativePrice.Int()) + usd, err := e.impl.DenoteInUSD(ctx, req.P.Int(), req.WrappedNativePrice.Int()) if err != nil { return nil, err } @@ -234,7 +234,7 @@ func (e *ExecGasEstimatorGRPCServer) EstimateMsgCostUSD(ctx context.Context, req if err != nil { return nil, fmt.Errorf("failed to convert evm2evm msg: %w", err) } - cost, err := e.impl.EstimateMsgCostUSD(req.P.Int(), req.WrappedNativePrice.Int(), *msg) + cost, err := e.impl.EstimateMsgCostUSD(ctx, req.P.Int(), req.WrappedNativePrice.Int(), *msg) if err != nil { return nil, err } @@ -252,7 +252,7 @@ func (e *ExecGasEstimatorGRPCServer) GetGasPrice(ctx context.Context, req *empty // Median implements ccippb.GasPriceEstimatorExecServer. func (e *ExecGasEstimatorGRPCServer) Median(ctx context.Context, req *ccippb.MedianRequest) (*ccippb.MedianResponse, error) { - median, err := e.impl.Median(bigIntSlice(req.GasPrices)) + median, err := e.impl.Median(ctx, bigIntSlice(req.GasPrices)) if err != nil { return nil, err } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/offramp.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/offramp.go index c23b39582..e6f834bef 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/offramp.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/offramp.go @@ -60,9 +60,9 @@ type OffRampReaderGRPCServer struct { // NewOffRampReaderGRPCServer creates a new OffRampReaderGRPCServer. It is used by the relayer to serve the offramp reader service. // The server is created by wrapping a [cciptypes.OffRampReader] implementation. It requires a brokerExt to allocate and serve the gas estimator server. // *must* be the same broker used by the client. BCF-3061 -func NewOffRampReaderGRPCServer(impl cciptypes.OffRampReader, brokerExt *net.BrokerExt) (*OffRampReaderGRPCServer, error) { +func NewOffRampReaderGRPCServer(ctx context.Context, impl cciptypes.OffRampReader, brokerExt *net.BrokerExt) (*OffRampReaderGRPCServer, error) { // offramp reader server needs to serve the gas estimator server - estimator, err := impl.GasPriceEstimator(context.Background()) + estimator, err := impl.GasPriceEstimator(ctx) if err != nil { return nil, err } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_factory_server.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_factory_server.go index 2c9dc0e7f..265e31627 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_factory_server.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_factory_server.go @@ -69,12 +69,13 @@ func runCommitReportingPluginFactory(t *testing.T, factory types.ReportingPlugin } t.Run("ReportingPluginFactory", func(t *testing.T) { + ctx := tests.Context(t) // we expect the static implementation to be used under the covers // we can't compare the types directly because the returned reporting plugin may be a grpc client // that wraps the static implementation var expectedReportingPlugin = reportingplugintest.ReportingPlugin - rp, gotRPI, err := factory.NewReportingPlugin(reportingplugintest.Factory.ReportingPluginConfig) + rp, gotRPI, err := factory.NewReportingPlugin(ctx, reportingplugintest.Factory.ReportingPluginConfig) require.NoError(t, err) assert.Equal(t, rpi, gotRPI) t.Cleanup(func() { assert.NoError(t, rp.Close()) }) diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_gas_estimator.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_gas_estimator.go index 49eaf30c7..a1000c57f 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_gas_estimator.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_gas_estimator.go @@ -38,7 +38,7 @@ type staticGasPriceEstimatorCommit struct { var _ GasPriceEstimatorCommitEvaluator = staticGasPriceEstimatorCommit{} // DenoteInUSD implements GasPriceEstimatorCommitEvaluator. -func (s staticGasPriceEstimatorCommit) DenoteInUSD(p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error) { +func (s staticGasPriceEstimatorCommit) DenoteInUSD(ctx context.Context, p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error) { if s.denoteInUSDRequest.p.Cmp(p) != 0 { return nil, fmt.Errorf("expected p %v, got %v", s.denoteInUSDRequest.p, p) } @@ -49,7 +49,7 @@ func (s staticGasPriceEstimatorCommit) DenoteInUSD(p *big.Int, wrappedNativePric } // Deviates implements GasPriceEstimatorCommitEvaluator. -func (s staticGasPriceEstimatorCommit) Deviates(p1 *big.Int, p2 *big.Int) (bool, error) { +func (s staticGasPriceEstimatorCommit) Deviates(ctx context.Context, p1 *big.Int, p2 *big.Int) (bool, error) { if s.deviatesRequest.p1.Cmp(p1) != 0 { return false, fmt.Errorf("expected p1 %v, got %v", s.deviatesRequest.p1, p1) } @@ -69,7 +69,7 @@ func (s staticGasPriceEstimatorCommit) Evaluate(ctx context.Context, other ccipt return fmt.Errorf("expected other.GetGasPrice %v, got %v", s.getGasPriceResponse, gotGas) } - gotMedian, err := other.Median(s.medianRequest.gasPrices) + gotMedian, err := other.Median(ctx, s.medianRequest.gasPrices) if err != nil { return fmt.Errorf("failed to other.Median: %w", err) } @@ -77,7 +77,7 @@ func (s staticGasPriceEstimatorCommit) Evaluate(ctx context.Context, other ccipt return fmt.Errorf("expected other.Median %v, got %v", s.medianResponse, gotMedian) } - gotDeviates, err := other.Deviates(s.deviatesRequest.p1, s.deviatesRequest.p2) + gotDeviates, err := other.Deviates(ctx, s.deviatesRequest.p1, s.deviatesRequest.p2) if err != nil { return fmt.Errorf("failed to other.Deviates: %w", err) } @@ -85,7 +85,7 @@ func (s staticGasPriceEstimatorCommit) Evaluate(ctx context.Context, other ccipt return fmt.Errorf("expected other.Deviates %v, got %v", s.deviatesResponse, gotDeviates) } - gotDenoteInUSD, err := other.DenoteInUSD(s.denoteInUSDRequest.p, s.denoteInUSDRequest.wrappedNativePrice) + gotDenoteInUSD, err := other.DenoteInUSD(ctx, s.denoteInUSDRequest.p, s.denoteInUSDRequest.wrappedNativePrice) if err != nil { return fmt.Errorf("failed to other.DenoteInUSD: %w", err) } @@ -102,7 +102,7 @@ func (s staticGasPriceEstimatorCommit) GetGasPrice(ctx context.Context) (*big.In } // Median implements GasPriceEstimatorCommitEvaluator. -func (s staticGasPriceEstimatorCommit) Median(gasPrices []*big.Int) (*big.Int, error) { +func (s staticGasPriceEstimatorCommit) Median(ctx context.Context, gasPrices []*big.Int) (*big.Int, error) { if len(gasPrices) != len(s.medianRequest.gasPrices) { return nil, fmt.Errorf("expected gas prices len %d, got %d", len(s.medianRequest.gasPrices), len(gasPrices)) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_gas_estimator_test.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_gas_estimator_test.go index 606088788..c49157dd6 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_gas_estimator_test.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_gas_estimator_test.go @@ -47,25 +47,22 @@ func roundTripGasPriceEstimatorCommitTests(t *testing.T, client *ccip.CommitGasE }) t.Run("DenoteInUSD", func(t *testing.T) { - usd, err := client.DenoteInUSD( - GasPriceEstimatorCommit.denoteInUSDRequest.p, - GasPriceEstimatorCommit.denoteInUSDRequest.wrappedNativePrice, - ) + ctx := tests.Context(t) + usd, err := client.DenoteInUSD(ctx, GasPriceEstimatorCommit.denoteInUSDRequest.p, GasPriceEstimatorCommit.denoteInUSDRequest.wrappedNativePrice) require.NoError(t, err) assert.Equal(t, GasPriceEstimatorCommit.denoteInUSDResponse.result, usd) }) t.Run("Deviates", func(t *testing.T) { - isDeviant, err := client.Deviates( - GasPriceEstimatorCommit.deviatesRequest.p1, - GasPriceEstimatorCommit.deviatesRequest.p2, - ) + ctx := tests.Context(t) + isDeviant, err := client.Deviates(ctx, GasPriceEstimatorCommit.deviatesRequest.p1, GasPriceEstimatorCommit.deviatesRequest.p2) require.NoError(t, err) assert.Equal(t, GasPriceEstimatorCommit.deviatesResponse, isDeviant) }) t.Run("Median", func(t *testing.T) { - median, err := client.Median(GasPriceEstimatorCommit.medianRequest.gasPrices) + ctx := tests.Context(t) + median, err := client.Median(ctx, GasPriceEstimatorCommit.medianRequest.gasPrices) require.NoError(t, err) assert.Equal(t, GasPriceEstimatorCommit.medianResponse, median) }) diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_store_test.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_store_test.go index 89bb99763..246be2d75 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_store_test.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/commit_store_test.go @@ -84,25 +84,22 @@ func roundTripCommitStoreTests(t *testing.T, client cciptypes.CommitStoreReader) }) t.Run("DenoteInUSD", func(t *testing.T) { - usd, err := estimator.DenoteInUSD( - GasPriceEstimatorCommit.denoteInUSDRequest.p, - GasPriceEstimatorCommit.denoteInUSDRequest.wrappedNativePrice, - ) + ctx := tests.Context(t) + usd, err := estimator.DenoteInUSD(ctx, GasPriceEstimatorCommit.denoteInUSDRequest.p, GasPriceEstimatorCommit.denoteInUSDRequest.wrappedNativePrice) require.NoError(t, err) assert.Equal(t, GasPriceEstimatorCommit.denoteInUSDResponse.result, usd) }) t.Run("Deviates", func(t *testing.T) { - deviates, err := estimator.Deviates( - GasPriceEstimatorCommit.deviatesRequest.p1, - GasPriceEstimatorCommit.deviatesRequest.p2, - ) + ctx := tests.Context(t) + deviates, err := estimator.Deviates(ctx, GasPriceEstimatorCommit.deviatesRequest.p1, GasPriceEstimatorCommit.deviatesRequest.p2) require.NoError(t, err) assert.Equal(t, GasPriceEstimatorCommit.deviatesResponse, deviates) }) t.Run("Median", func(t *testing.T) { - median, err := estimator.Median(GasPriceEstimatorCommit.medianRequest.gasPrices) + ctx := tests.Context(t) + median, err := estimator.Median(ctx, GasPriceEstimatorCommit.medianRequest.gasPrices) require.NoError(t, err) assert.Equal(t, GasPriceEstimatorCommit.medianResponse, median) }) @@ -179,7 +176,8 @@ func roundTripCommitStoreTests(t *testing.T, client cciptypes.CommitStoreReader) } func setupCommitStoreServer(t *testing.T, s *grpc.Server, b *loopnet.BrokerExt) *ccip.CommitStoreGRPCServer { - commitProvider, err := ccip.NewCommitStoreReaderGRPCServer(CommitStoreReader, b) + ctx := tests.Context(t) + commitProvider, err := ccip.NewCommitStoreReaderGRPCServer(ctx, CommitStoreReader, b) require.NoError(t, err) ccippb.RegisterCommitStoreReaderServer(s, commitProvider) return commitProvider diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_factory_server.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_factory_server.go index de99c07e0..4c748d82a 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_factory_server.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_factory_server.go @@ -83,7 +83,7 @@ func runExecReportingPluginFactory(t *testing.T, factory types.ReportingPluginFa // that wraps the static implementation var expectedReportingPlugin = reportingplugintest.ReportingPlugin - rp, gotRPI, err := factory.NewReportingPlugin(reportingplugintest.Factory.ReportingPluginConfig) + rp, gotRPI, err := factory.NewReportingPlugin(tests.Context(t), reportingplugintest.Factory.ReportingPluginConfig) require.NoError(t, err) assert.Equal(t, rpi, gotRPI) t.Cleanup(func() { assert.NoError(t, rp.Close()) }) diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_gas_estimator.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_gas_estimator.go index 633e18c78..453b30b31 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_gas_estimator.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_gas_estimator.go @@ -53,7 +53,7 @@ type staticGasPriceEstimatorExec struct { } // EstimateMsgCostUSD implements GasPriceEstimatorExecEvaluator. -func (s staticGasPriceEstimatorExec) EstimateMsgCostUSD(p *big.Int, wrappedNativePrice *big.Int, msg cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error) { +func (s staticGasPriceEstimatorExec) EstimateMsgCostUSD(ctx context.Context, p *big.Int, wrappedNativePrice *big.Int, msg cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error) { if s.estimateMsgCostUSDRequest.p.Cmp(p) != 0 { return nil, fmt.Errorf("expected p %v, got %v", s.estimateMsgCostUSDRequest.p, p) } @@ -69,7 +69,7 @@ func (s staticGasPriceEstimatorExec) EstimateMsgCostUSD(p *big.Int, wrappedNativ var _ GasPriceEstimatorExecEvaluator = staticGasPriceEstimatorExec{} // DenoteInUSD implements GasPriceEstimatorExecEvaluator. -func (s staticGasPriceEstimatorExec) DenoteInUSD(p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error) { +func (s staticGasPriceEstimatorExec) DenoteInUSD(ctx context.Context, p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error) { if s.denoteInUSDRequest.p.Cmp(p) != 0 { return nil, fmt.Errorf("expected p %v, got %v", s.denoteInUSDRequest.p, p) } @@ -91,7 +91,7 @@ func (s staticGasPriceEstimatorExec) Evaluate(ctx context.Context, other cciptyp } // Median test case - gotMedian, err := other.Median(s.medianRequest.gasPrices) + gotMedian, err := other.Median(ctx, s.medianRequest.gasPrices) if err != nil { return fmt.Errorf("failed to other.Median: %w", err) } @@ -100,7 +100,7 @@ func (s staticGasPriceEstimatorExec) Evaluate(ctx context.Context, other cciptyp } // EstimateMsgCostUSD test case - gotEstimate, err := other.EstimateMsgCostUSD(s.estimateMsgCostUSDRequest.p, s.estimateMsgCostUSDRequest.wrappedNativePrice, s.estimateMsgCostUSDRequest.msg) + gotEstimate, err := other.EstimateMsgCostUSD(ctx, s.estimateMsgCostUSDRequest.p, s.estimateMsgCostUSDRequest.wrappedNativePrice, s.estimateMsgCostUSDRequest.msg) if err != nil { return fmt.Errorf("failed to other.EstimateMsgCostUSD: %w", err) } @@ -108,7 +108,7 @@ func (s staticGasPriceEstimatorExec) Evaluate(ctx context.Context, other cciptyp return fmt.Errorf("expected other.EstimateMsgCostUSD %v, got %v", s.estimateMsgCostUSDResponse, gotEstimate) } - gotDenoteInUSD, err := other.DenoteInUSD(s.denoteInUSDRequest.p, s.denoteInUSDRequest.wrappedNativePrice) + gotDenoteInUSD, err := other.DenoteInUSD(ctx, s.denoteInUSDRequest.p, s.denoteInUSDRequest.wrappedNativePrice) if err != nil { return fmt.Errorf("failed to other.DenoteInUSD: %w", err) } @@ -125,7 +125,7 @@ func (s staticGasPriceEstimatorExec) GetGasPrice(ctx context.Context) (*big.Int, } // Median implements GasPriceEstimatorExecEvaluator. -func (s staticGasPriceEstimatorExec) Median(gasPrices []*big.Int) (*big.Int, error) { +func (s staticGasPriceEstimatorExec) Median(ctx context.Context, gasPrices []*big.Int) (*big.Int, error) { if len(gasPrices) != len(s.medianRequest.gasPrices) { return nil, fmt.Errorf("expected gas prices len %d, got %d", len(s.medianRequest.gasPrices), len(gasPrices)) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_gas_estimator_test.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_gas_estimator_test.go index a5e1c8ec1..00de54459 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_gas_estimator_test.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/exec_gas_estimator_test.go @@ -47,26 +47,22 @@ func roundTripGasPriceEstimatorExecTests(t *testing.T, client *ccip.ExecGasEstim }) t.Run("DenoteInUSD", func(t *testing.T) { - usd, err := client.DenoteInUSD( - GasPriceEstimatorExec.denoteInUSDRequest.p, - GasPriceEstimatorExec.denoteInUSDRequest.wrappedNativePrice, - ) + ctx := tests.Context(t) + usd, err := client.DenoteInUSD(ctx, GasPriceEstimatorExec.denoteInUSDRequest.p, GasPriceEstimatorExec.denoteInUSDRequest.wrappedNativePrice) require.NoError(t, err) assert.Equal(t, GasPriceEstimatorExec.denoteInUSDResponse.result, usd) }) t.Run("EstimateMsgCostUSD", func(t *testing.T) { - cost, err := client.EstimateMsgCostUSD( - GasPriceEstimatorExec.estimateMsgCostUSDRequest.p, - GasPriceEstimatorExec.estimateMsgCostUSDRequest.wrappedNativePrice, - GasPriceEstimatorExec.estimateMsgCostUSDRequest.msg, - ) + ctx := tests.Context(t) + cost, err := client.EstimateMsgCostUSD(ctx, GasPriceEstimatorExec.estimateMsgCostUSDRequest.p, GasPriceEstimatorExec.estimateMsgCostUSDRequest.wrappedNativePrice, GasPriceEstimatorExec.estimateMsgCostUSDRequest.msg) require.NoError(t, err) assert.Equal(t, GasPriceEstimatorExec.estimateMsgCostUSDResponse, cost) }) t.Run("Median", func(t *testing.T) { - median, err := client.Median(GasPriceEstimatorExec.medianRequest.gasPrices) + ctx := tests.Context(t) + median, err := client.Median(ctx, GasPriceEstimatorExec.medianRequest.gasPrices) require.NoError(t, err) assert.Equal(t, GasPriceEstimatorExec.medianResponse, median) }) diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/offramp.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/offramp.go index 580f21e8e..ff85e7af1 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/offramp.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/offramp.go @@ -375,7 +375,7 @@ func (s staticOffRamp) Evaluate(ctx context.Context, other ccip.OffRampReader) e return fmt.Errorf("expected gasPrice %v but got %v", GasPriceEstimatorExec.getGasPriceResponse, price) } // DenoteInUSD test case - gotUsd, err := gasPriceEstimator.DenoteInUSD(GasPriceEstimatorExec.denoteInUSDRequest.p, GasPriceEstimatorExec.denoteInUSDRequest.wrappedNativePrice) + gotUsd, err := gasPriceEstimator.DenoteInUSD(ctx, GasPriceEstimatorExec.denoteInUSDRequest.p, GasPriceEstimatorExec.denoteInUSDRequest.wrappedNativePrice) if err != nil { return fmt.Errorf("failed to get other usd: %w", err) } @@ -383,11 +383,7 @@ func (s staticOffRamp) Evaluate(ctx context.Context, other ccip.OffRampReader) e return fmt.Errorf("expected usd %v but got %v", GasPriceEstimatorExec.denoteInUSDResponse.result, gotUsd) } // EstimateMsgCostUSD test case - cost, err := gasPriceEstimator.EstimateMsgCostUSD( - GasPriceEstimatorExec.estimateMsgCostUSDRequest.p, - GasPriceEstimatorExec.estimateMsgCostUSDRequest.wrappedNativePrice, - GasPriceEstimatorExec.estimateMsgCostUSDRequest.msg, - ) + cost, err := gasPriceEstimator.EstimateMsgCostUSD(ctx, GasPriceEstimatorExec.estimateMsgCostUSDRequest.p, GasPriceEstimatorExec.estimateMsgCostUSDRequest.wrappedNativePrice, GasPriceEstimatorExec.estimateMsgCostUSDRequest.msg) if err != nil { return fmt.Errorf("failed to get other cost: %w", err) } @@ -395,7 +391,7 @@ func (s staticOffRamp) Evaluate(ctx context.Context, other ccip.OffRampReader) e return fmt.Errorf("expected cost %v but got %v", GasPriceEstimatorExec.estimateMsgCostUSDResponse, cost) } // Median test case - median, err := gasPriceEstimator.Median(GasPriceEstimatorExec.medianRequest.gasPrices) + median, err := gasPriceEstimator.Median(ctx, GasPriceEstimatorExec.medianRequest.gasPrices) if err != nil { return fmt.Errorf("failed to get other median: %w", err) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/offramp_test.go b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/offramp_test.go index 2390cd619..b18041940 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/offramp_test.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/ccip/test/offramp_test.go @@ -153,7 +153,8 @@ func roundTripOffRampTests(t *testing.T, client cciptypes.OffRampReader) { } func setupOffRampServer(t *testing.T, s *grpc.Server, b *loopnet.BrokerExt) *ccip.OffRampReaderGRPCServer { - offRampProvider, err := ccip.NewOffRampReaderGRPCServer(OffRampReader, b) + ctx := tests.Context(t) + offRampProvider, err := ccip.NewOffRampReaderGRPCServer(ctx, OffRampReader, b) require.NoError(t, err) ccippb.RegisterOffRampReaderServer(s, offRampProvider) return offRampProvider diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/median/median.go b/pkg/loop/internal/relayer/pluginprovider/ext/median/median.go index 35f6c68d3..9282a48fd 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/median/median.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/median/median.go @@ -43,43 +43,43 @@ func NewProviderClient(b *net.BrokerExt, cc grpc.ClientConnInterface) *ProviderC m.reportCodec = &reportCodecClient{b, pb.NewReportCodecClient(cc)} m.medianContract = &medianContractClient{pb.NewMedianContractClient(cc)} m.onchainConfigCodec = &onchainConfigCodecClient{b, pb.NewOnchainConfigCodecClient(cc)} + m.contractReader = contractreader.NewClient(b, cc) + m.codec = contractreader.NewCodecClient(b, cc) + return m +} - maybeCr := contractreader.NewClient(b, cc) +// RmUnimplemented sets the ContractReader and Codec clients to nil, if they are not implemented. +func (p *ProviderClient) RmUnimplemented(ctx context.Context) { var anyRetVal int - - err := maybeCr.GetLatestValue(context.Background(), "", primitives.Unconfirmed, nil, &anyRetVal) - - if status.Convert(err).Code() != codes.Unimplemented { - m.contractReader = maybeCr + err := p.contractReader.GetLatestValue(ctx, "", primitives.Unconfirmed, nil, &anyRetVal) + if status.Convert(err).Code() == codes.Unimplemented { + p.contractReader = nil } - maybeCodec := contractreader.NewCodecClient(b, cc) - err = maybeCodec.Decode(context.Background(), []byte{}, &anyRetVal, "") - if status.Convert(err).Code() != codes.Unimplemented { - m.codec = maybeCodec + err = p.codec.Decode(ctx, []byte{}, &anyRetVal, "") + if status.Convert(err).Code() == codes.Unimplemented { + p.codec = nil } - - return m } -func (m *ProviderClient) ReportCodec() median.ReportCodec { - return m.reportCodec +func (p *ProviderClient) ReportCodec() median.ReportCodec { + return p.reportCodec } -func (m *ProviderClient) MedianContract() median.MedianContract { - return m.medianContract +func (p *ProviderClient) MedianContract() median.MedianContract { + return p.medianContract } -func (m *ProviderClient) OnchainConfigCodec() median.OnchainConfigCodec { - return m.onchainConfigCodec +func (p *ProviderClient) OnchainConfigCodec() median.OnchainConfigCodec { + return p.onchainConfigCodec } func (m *ProviderClient) ContractReader() types.ContractReader { return m.contractReader } -func (m *ProviderClient) Codec() types.Codec { - return m.codec +func (p *ProviderClient) Codec() types.Codec { + return p.codec } var _ median.ReportCodec = (*reportCodecClient)(nil) @@ -89,9 +89,7 @@ type reportCodecClient struct { grpc pb.ReportCodecClient } -func (r *reportCodecClient) BuildReport(observations []median.ParsedAttributedObservation) (report libocr.Report, err error) { - ctx, cancel := r.StopCtx() - defer cancel() +func (r *reportCodecClient) BuildReport(ctx context.Context, observations []median.ParsedAttributedObservation) (report libocr.Report, err error) { var req pb.BuildReportRequest for _, o := range observations { req.Observations = append(req.Observations, &pb.ParsedAttributedObservation{ @@ -111,9 +109,7 @@ func (r *reportCodecClient) BuildReport(observations []median.ParsedAttributedOb return } -func (r *reportCodecClient) MedianFromReport(report libocr.Report) (*big.Int, error) { - ctx, cancel := r.StopCtx() - defer cancel() +func (r *reportCodecClient) MedianFromReport(ctx context.Context, report libocr.Report) (*big.Int, error) { reply, err := r.grpc.MedianFromReport(ctx, &pb.MedianFromReportRequest{Report: report}) if err != nil { return nil, err @@ -121,9 +117,7 @@ func (r *reportCodecClient) MedianFromReport(report libocr.Report) (*big.Int, er return reply.Median.Int(), nil } -func (r *reportCodecClient) MaxReportLength(n int) (int, error) { - ctx, cancel := r.StopCtx() - defer cancel() +func (r *reportCodecClient) MaxReportLength(ctx context.Context, n int) (int, error) { reply, err := r.grpc.MaxReportLength(ctx, &pb.MaxReportLengthRequest{N: int64(n)}) if err != nil { return -1, err @@ -153,7 +147,7 @@ func (r *reportCodecServer) BuildReport(ctx context.Context, request *pb.BuildRe Observer: commontypes.OracleID(o.Observer), }) } - report, err := r.impl.BuildReport(obs) + report, err := r.impl.BuildReport(ctx, obs) if err != nil { return nil, err } @@ -161,7 +155,7 @@ func (r *reportCodecServer) BuildReport(ctx context.Context, request *pb.BuildRe } func (r *reportCodecServer) MedianFromReport(ctx context.Context, request *pb.MedianFromReportRequest) (*pb.MedianFromReportReply, error) { - m, err := r.impl.MedianFromReport(request.Report) + m, err := r.impl.MedianFromReport(ctx, request.Report) if err != nil { return nil, err } @@ -169,7 +163,7 @@ func (r *reportCodecServer) MedianFromReport(ctx context.Context, request *pb.Me } func (r *reportCodecServer) MaxReportLength(ctx context.Context, request *pb.MaxReportLengthRequest) (*pb.MaxReportLengthReply, error) { - l, err := r.impl.MaxReportLength(int(request.N)) + l, err := r.impl.MaxReportLength(ctx, int(request.N)) if err != nil { return nil, err } @@ -265,9 +259,7 @@ type onchainConfigCodecClient struct { grpc pb.OnchainConfigCodecClient } -func (o *onchainConfigCodecClient) Encode(config median.OnchainConfig) ([]byte, error) { - ctx, cancel := o.StopCtx() - defer cancel() +func (o *onchainConfigCodecClient) Encode(ctx context.Context, config median.OnchainConfig) ([]byte, error) { req := &pb.EncodeRequest{OnchainConfig: &pb.OnchainConfig{ Min: pb.NewBigIntFromInt(config.Min), Max: pb.NewBigIntFromInt(config.Max), @@ -279,9 +271,7 @@ func (o *onchainConfigCodecClient) Encode(config median.OnchainConfig) ([]byte, return reply.Encoded, nil } -func (o *onchainConfigCodecClient) Decode(bytes []byte) (oc median.OnchainConfig, err error) { - ctx, cancel := o.StopCtx() - defer cancel() +func (o *onchainConfigCodecClient) Decode(ctx context.Context, bytes []byte) (oc median.OnchainConfig, err error) { var reply *pb.DecodeReply reply, err = o.grpc.Decode(ctx, &pb.DecodeRequest{Encoded: bytes}) if err != nil { @@ -300,7 +290,7 @@ type onchainConfigCodecServer struct { func (o *onchainConfigCodecServer) Encode(ctx context.Context, request *pb.EncodeRequest) (*pb.EncodeReply, error) { min, max := request.OnchainConfig.Min.Int(), request.OnchainConfig.Max.Int() - b, err := o.impl.Encode(median.OnchainConfig{Max: max, Min: min}) + b, err := o.impl.Encode(ctx, median.OnchainConfig{Max: max, Min: min}) if err != nil { return nil, err } @@ -308,7 +298,7 @@ func (o *onchainConfigCodecServer) Encode(ctx context.Context, request *pb.Encod } func (o *onchainConfigCodecServer) Decode(ctx context.Context, request *pb.DecodeRequest) (*pb.DecodeReply, error) { - oc, err := o.impl.Decode(request.Encoded) + oc, err := o.impl.Decode(ctx, request.Encoded) if err != nil { return nil, err } @@ -322,7 +312,9 @@ type ProviderServer struct{} func (m ProviderServer) ConnToProvider(conn grpc.ClientConnInterface, broker net.Broker, brokerCfg net.BrokerConfig) types.MedianProvider { be := &net.BrokerExt{Broker: broker, BrokerConfig: brokerCfg} - return NewProviderClient(be, conn) + pc := NewProviderClient(be, conn) + pc.RmUnimplemented(context.Background()) + return pc } func RegisterProviderServices(s *grpc.Server, provider types.MedianProvider) { diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/median/test/median.go b/pkg/loop/internal/relayer/pluginprovider/ext/median/test/median.go index dd7623d2a..2c210d564 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/median/test/median.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/median/test/median.go @@ -58,7 +58,7 @@ func ReportingPluginFactory(t *testing.T, factory types.ReportingPluginFactory) // that wraps the static implementation var expectedReportingPlugin = reportingplugintest.ReportingPlugin - rp, gotRPI, err := factory.NewReportingPlugin(reportingPluginConfig) + rp, gotRPI, err := factory.NewReportingPlugin(tests.Context(t), reportingPluginConfig) require.NoError(t, err) assert.Equal(t, rpi, gotRPI) t.Cleanup(func() { assert.NoError(t, rp.Close()) }) @@ -142,7 +142,7 @@ func (s staticReportingPluginFactory) Ready() error { panic("implement me") } func (s staticReportingPluginFactory) HealthReport() map[string]error { panic("implement me") } -func (s staticReportingPluginFactory) NewReportingPlugin(config libocr.ReportingPluginConfig) (libocr.ReportingPlugin, libocr.ReportingPluginInfo, error) { +func (s staticReportingPluginFactory) NewReportingPlugin(ctx context.Context, config libocr.ReportingPluginConfig) (libocr.ReportingPlugin, libocr.ReportingPluginInfo, error) { if config.ConfigDigest != s.ConfigDigest { return nil, libocr.ReportingPluginInfo{}, fmt.Errorf("expected ConfigDigest %x but got %x", s.ConfigDigest, config.ConfigDigest) } @@ -329,21 +329,21 @@ var _ testtypes.Evaluator[median.ReportCodec] = staticReportCodec{} var _ median.ReportCodec = staticReportCodec{} // TODO BCF-3068 remove hard coded values, use the staticXXXConfig pattern elsewhere in the test framework -func (s staticReportCodec) BuildReport(os []median.ParsedAttributedObservation) (libocr.Report, error) { +func (s staticReportCodec) BuildReport(ctx context.Context, os []median.ParsedAttributedObservation) (libocr.Report, error) { if !assert.ObjectsAreEqual(pobs, os) { return nil, fmt.Errorf("expected observations %v but got %v", pobs, os) } return report, nil } -func (s staticReportCodec) MedianFromReport(r libocr.Report) (*big.Int, error) { +func (s staticReportCodec) MedianFromReport(ctx context.Context, r libocr.Report) (*big.Int, error) { if !bytes.Equal(report, r) { return nil, fmt.Errorf("expected report %x but got %x", report, r) } return medianValue, nil } -func (s staticReportCodec) MaxReportLength(n2 int) (int, error) { +func (s staticReportCodec) MaxReportLength(ctx context.Context, n2 int) (int, error) { if n != n2 { return -1, fmt.Errorf("expected n %d but got %d", n, n2) } @@ -351,21 +351,21 @@ func (s staticReportCodec) MaxReportLength(n2 int) (int, error) { } func (s staticReportCodec) Evaluate(ctx context.Context, rc median.ReportCodec) error { - gotReport, err := rc.BuildReport(pobs) + gotReport, err := rc.BuildReport(ctx, pobs) if err != nil { return fmt.Errorf("failed to BuildReport: %w", err) } if !bytes.Equal(gotReport, report) { return fmt.Errorf("expected Report %x but got %x", report, gotReport) } - gotMedianValue, err := rc.MedianFromReport(report) + gotMedianValue, err := rc.MedianFromReport(ctx, report) if err != nil { return fmt.Errorf("failed to get MedianFromReport: %w", err) } if medianValue.Cmp(gotMedianValue) != 0 { return fmt.Errorf("expected MedianValue %s but got %s", medianValue, gotMedianValue) } - gotMax, err := rc.MaxReportLength(n) + gotMax, err := rc.MaxReportLength(ctx, n) if err != nil { return fmt.Errorf("failed to get MaxReportLength: %w", err) } @@ -446,7 +446,7 @@ type staticOnchainConfigCodec struct{} var _ testtypes.Evaluator[median.OnchainConfigCodec] = staticOnchainConfigCodec{} var _ median.OnchainConfigCodec = staticOnchainConfigCodec{} -func (s staticOnchainConfigCodec) Encode(c median.OnchainConfig) ([]byte, error) { +func (s staticOnchainConfigCodec) Encode(ctx context.Context, c median.OnchainConfig) ([]byte, error) { if !assert.ObjectsAreEqual(onchainConfig.Max, c.Max) { return nil, fmt.Errorf("expected max %s but got %s", onchainConfig.Max, c.Max) } @@ -456,7 +456,7 @@ func (s staticOnchainConfigCodec) Encode(c median.OnchainConfig) ([]byte, error) return encodedOnchainConfig, nil } -func (s staticOnchainConfigCodec) Decode(b []byte) (median.OnchainConfig, error) { +func (s staticOnchainConfigCodec) Decode(ctx context.Context, b []byte) (median.OnchainConfig, error) { if !bytes.Equal(encodedOnchainConfig, b) { return median.OnchainConfig{}, fmt.Errorf("expected encoded %x but got %x", encodedOnchainConfig, b) } @@ -464,14 +464,14 @@ func (s staticOnchainConfigCodec) Decode(b []byte) (median.OnchainConfig, error) } func (s staticOnchainConfigCodec) Evaluate(ctx context.Context, occ median.OnchainConfigCodec) error { - gotEncoded, err := occ.Encode(onchainConfig) + gotEncoded, err := occ.Encode(ctx, onchainConfig) if err != nil { return fmt.Errorf("failed to Encode: %w", err) } if !bytes.Equal(gotEncoded, encodedOnchainConfig) { return fmt.Errorf("expected Encoded %s but got %s", encodedOnchainConfig, gotEncoded) } - gotDecoded, err := occ.Decode(encodedOnchainConfig) + gotDecoded, err := occ.Decode(ctx, encodedOnchainConfig) if err != nil { return fmt.Errorf("failed to Decode: %w", err) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/onchainconfig.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/onchainconfig.go index ad8a70fa2..a660d1a56 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/onchainconfig.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/onchainconfig.go @@ -20,8 +20,8 @@ func newOnchainConfigCodecClient(cc grpc.ClientConnInterface) *onchainConfigCode return &onchainConfigCodecClient{grpc: mercury_pb.NewOnchainConfigCodecClient(cc)} } -func (o *onchainConfigCodecClient) Encode(config mercury_types.OnchainConfig) ([]byte, error) { - reply, err := o.grpc.Encode(context.TODO(), &mercury_pb.EncodeOnchainConfigRequest{ +func (o *onchainConfigCodecClient) Encode(ctx context.Context, config mercury_types.OnchainConfig) ([]byte, error) { + reply, err := o.grpc.Encode(ctx, &mercury_pb.EncodeOnchainConfigRequest{ OnchainConfig: pbOnchainConfig(config), }) if err != nil { @@ -30,8 +30,8 @@ func (o *onchainConfigCodecClient) Encode(config mercury_types.OnchainConfig) ([ return reply.OnchainConfig, nil } -func (o *onchainConfigCodecClient) Decode(data []byte) (mercury_types.OnchainConfig, error) { - reply, err := o.grpc.Decode(context.TODO(), &mercury_pb.DecodeOnchainConfigRequest{ +func (o *onchainConfigCodecClient) Decode(ctx context.Context, data []byte) (mercury_types.OnchainConfig, error) { + reply, err := o.grpc.Decode(ctx, &mercury_pb.DecodeOnchainConfigRequest{ OnchainConfig: data, }) if err != nil { @@ -67,7 +67,7 @@ func newOnchainConfigCodecServer(impl mercury_types.OnchainConfigCodec) *onchain } func (o *onchainConfigCodecServer) Encode(ctx context.Context, request *mercury_pb.EncodeOnchainConfigRequest) (*mercury_pb.EncodeOnchainConfigReply, error) { - val, err := o.impl.Encode(onchainConfig(request.OnchainConfig)) + val, err := o.impl.Encode(ctx, onchainConfig(request.OnchainConfig)) if err != nil { return nil, err } @@ -75,7 +75,7 @@ func (o *onchainConfigCodecServer) Encode(ctx context.Context, request *mercury_ } func (o *onchainConfigCodecServer) Decode(ctx context.Context, request *mercury_pb.DecodeOnchainConfigRequest) (*mercury_pb.DecodeOnchainConfigReply, error) { - val, err := o.impl.Decode(request.OnchainConfig) + val, err := o.impl.Decode(ctx, request.OnchainConfig) if err != nil { return nil, err } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/reportcodec.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/reportcodec.go index 77ae71c5e..f8fe12cb9 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/reportcodec.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/reportcodec.go @@ -64,16 +64,16 @@ func newReportCodecV4Client(impl *mercury_v4_internal.ReportCodecClient) mercury return &reportCodecV4Client{impl: impl} } -func (r *reportCodecV4Client) BuildReport(fields mercury_v4_types.ReportFields) (ocr2plus_types.Report, error) { - return r.impl.BuildReport(fields) +func (r *reportCodecV4Client) BuildReport(ctx context.Context, fields mercury_v4_types.ReportFields) (ocr2plus_types.Report, error) { + return r.impl.BuildReport(ctx, fields) } -func (r *reportCodecV4Client) MaxReportLength(n int) (int, error) { - return r.impl.MaxReportLength(n) +func (r *reportCodecV4Client) MaxReportLength(ctx context.Context, n int) (int, error) { + return r.impl.MaxReportLength(ctx, n) } -func (r *reportCodecV4Client) ObservationTimestampFromReport(report ocr2plus_types.Report) (uint32, error) { - return r.impl.ObservationTimestampFromReport(report) +func (r *reportCodecV4Client) ObservationTimestampFromReport(ctx context.Context, report ocr2plus_types.Report) (uint32, error) { + return r.impl.ObservationTimestampFromReport(ctx, report) } // reportCodecV3Server implements mercury_pb.ReportCodecV3Server by wrapping [mercury_v3_internal.ReportCodecServer] @@ -116,16 +116,16 @@ func newReportCodecV3Client(impl *mercury_v3_internal.ReportCodecClient) mercury return &reportCodecV3Client{impl: impl} } -func (r *reportCodecV3Client) BuildReport(fields mercury_v3_types.ReportFields) (ocr2plus_types.Report, error) { - return r.impl.BuildReport(fields) +func (r *reportCodecV3Client) BuildReport(ctx context.Context, fields mercury_v3_types.ReportFields) (ocr2plus_types.Report, error) { + return r.impl.BuildReport(ctx, fields) } -func (r *reportCodecV3Client) MaxReportLength(n int) (int, error) { - return r.impl.MaxReportLength(n) +func (r *reportCodecV3Client) MaxReportLength(ctx context.Context, n int) (int, error) { + return r.impl.MaxReportLength(ctx, n) } -func (r *reportCodecV3Client) ObservationTimestampFromReport(report ocr2plus_types.Report) (uint32, error) { - return r.impl.ObservationTimestampFromReport(report) +func (r *reportCodecV3Client) ObservationTimestampFromReport(ctx context.Context, report ocr2plus_types.Report) (uint32, error) { + return r.impl.ObservationTimestampFromReport(ctx, report) } // reportCodecV2Server implements mercury_pb.ReportCodecV2Server by wrapping [mercury_v2_internal.ReportCodecServer] @@ -166,16 +166,16 @@ func newReportCodecV2Client(impl *mercury_v2_internal.ReportCodecClient) mercury return &reportCodecV2Client{impl: impl} } -func (r *reportCodecV2Client) BuildReport(fields mercury_v2_types.ReportFields) (ocr2plus_types.Report, error) { - return r.impl.BuildReport(fields) +func (r *reportCodecV2Client) BuildReport(ctx context.Context, fields mercury_v2_types.ReportFields) (ocr2plus_types.Report, error) { + return r.impl.BuildReport(ctx, fields) } -func (r *reportCodecV2Client) MaxReportLength(n int) (int, error) { - return r.impl.MaxReportLength(n) +func (r *reportCodecV2Client) MaxReportLength(ctx context.Context, n int) (int, error) { + return r.impl.MaxReportLength(ctx, n) } -func (r *reportCodecV2Client) ObservationTimestampFromReport(report ocr2plus_types.Report) (uint32, error) { - return r.impl.ObservationTimestampFromReport(report) +func (r *reportCodecV2Client) ObservationTimestampFromReport(ctx context.Context, report ocr2plus_types.Report) (uint32, error) { + return r.impl.ObservationTimestampFromReport(ctx, report) } // reportCodecV1Server implements mercury_pb.ReportCodecV1Server by wrapping [mercury_v1_internal.ReportCodecServer] @@ -216,14 +216,14 @@ func newReportCodecV1Client(impl *mercury_v1_internal.ReportCodecClient) mercury return &reportCodecV1Client{impl: impl} } -func (r *reportCodecV1Client) BuildReport(fields mercury_v1_types.ReportFields) (ocr2plus_types.Report, error) { - return r.impl.BuildReport(fields) +func (r *reportCodecV1Client) BuildReport(ctx context.Context, fields mercury_v1_types.ReportFields) (ocr2plus_types.Report, error) { + return r.impl.BuildReport(ctx, fields) } -func (r *reportCodecV1Client) MaxReportLength(n int) (int, error) { - return r.impl.MaxReportLength(n) +func (r *reportCodecV1Client) MaxReportLength(ctx context.Context, n int) (int, error) { + return r.impl.MaxReportLength(ctx, n) } -func (r *reportCodecV1Client) CurrentBlockNumFromReport(report ocr2plus_types.Report) (int64, error) { - return r.impl.CurrentBlockNumFromReport(report) +func (r *reportCodecV1Client) CurrentBlockNumFromReport(ctx context.Context, report ocr2plus_types.Report) (int64, error) { + return r.impl.CurrentBlockNumFromReport(ctx, report) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/mercury.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/mercury.go index dd95594da..da65e12a5 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/mercury.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/mercury.go @@ -232,7 +232,7 @@ func (s staticMercuryPluginFactory) Ready() error { panic("implement me") } func (s staticMercuryPluginFactory) HealthReport() map[string]error { panic("implement me") } -func (s staticMercuryPluginFactory) NewMercuryPlugin(config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { +func (s staticMercuryPluginFactory) NewMercuryPlugin(ctx context.Context, config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { if config.ConfigDigest != mercuryPluginConfig.ConfigDigest { return nil, ocr3types.MercuryPluginInfo{}, fmt.Errorf("expected ConfigDigest %x but got %x", mercuryPluginConfig.ConfigDigest, config.ConfigDigest) } @@ -266,7 +266,7 @@ func MercuryPluginFactory(t *testing.T, factory types.MercuryPluginFactory) { expectedMercuryPlugin := OCR3Plugin t.Run("ReportingPluginFactory", func(t *testing.T) { ctx := tests.Context(t) - rp, gotRPI, err := factory.NewMercuryPlugin(mercuryPluginConfig) + rp, gotRPI, err := factory.NewMercuryPlugin(ctx, mercuryPluginConfig) require.NoError(t, err) assert.Equal(t, mercuryPluginInfo, gotRPI) t.Cleanup(func() { assert.NoError(t, rp.Close()) }) diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/ocr_plugin.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/ocr_plugin.go index 6aa7983a2..9ef835e10 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/ocr_plugin.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/ocr_plugin.go @@ -80,7 +80,7 @@ func (s staticMercuryPlugin) Observation(ctx context.Context, timestamp libocr.R return s.observationResponse.observation, nil } -func (s staticMercuryPlugin) Report(timestamp libocr.ReportTimestamp, previousReport libocr.Report, observations []libocr.AttributedObservation) (bool, libocr.Report, error) { +func (s staticMercuryPlugin) Report(ctx context.Context, timestamp libocr.ReportTimestamp, previousReport libocr.Report, observations []libocr.AttributedObservation) (bool, libocr.Report, error) { if timestamp != s.reportRequest.reportTimestamp { return false, nil, fmt.Errorf("expected report timestamp %v but got %v", s.reportRequest.reportTimestamp, timestamp) } @@ -99,7 +99,7 @@ func (s staticMercuryPlugin) AssertEqual(ctx context.Context, t *testing.T, othe gotObs, err := other.Observation(ctx, s.observationRequest.reportTimestamp, s.observationRequest.previousReport) require.NoError(t, err) assert.Equal(t, s.observationResponse.observation, gotObs) - gotOk, gotReport, err := other.Report(s.reportRequest.reportTimestamp, s.reportRequest.previousReport, s.reportRequest.observations) + gotOk, gotReport, err := other.Report(ctx, s.reportRequest.reportTimestamp, s.reportRequest.previousReport, s.reportRequest.observations) require.NoError(t, err) assert.Equal(t, s.reportResponse.shouldReport, gotOk) assert.Equal(t, s.reportResponse.report, gotReport) diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/onchainconfig.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/onchainconfig.go index 3ceba9ef7..1769d4705 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/onchainconfig.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/test/onchainconfig.go @@ -39,7 +39,7 @@ type staticOnchainConfigCodec struct { var _ OnchainConfigCodecEvaluator = staticOnchainConfigCodec{} -func (staticOnchainConfigCodec) Encode(c mercury_types.OnchainConfig) ([]byte, error) { +func (staticOnchainConfigCodec) Encode(ctx context.Context, c mercury_types.OnchainConfig) ([]byte, error) { if !reflect.DeepEqual(c, StaticOnChainConfigCodecFixtures.Decoded) { return nil, fmt.Errorf("expected OnchainConfig %v but got %v", StaticOnChainConfigCodecFixtures.Decoded, c) } @@ -47,12 +47,12 @@ func (staticOnchainConfigCodec) Encode(c mercury_types.OnchainConfig) ([]byte, e return StaticOnChainConfigCodecFixtures.Encoded, nil } -func (staticOnchainConfigCodec) Decode([]byte) (mercury_types.OnchainConfig, error) { +func (staticOnchainConfigCodec) Decode(context.Context, []byte) (mercury_types.OnchainConfig, error) { return StaticOnChainConfigCodecFixtures.Decoded, nil } func (staticOnchainConfigCodec) Evaluate(ctx context.Context, other mercury_types.OnchainConfigCodec) error { - encoded, err := other.Encode(StaticOnChainConfigCodecFixtures.Decoded) + encoded, err := other.Encode(ctx, StaticOnChainConfigCodecFixtures.Decoded) if err != nil { return fmt.Errorf("failed to encode: %w", err) } @@ -60,7 +60,7 @@ func (staticOnchainConfigCodec) Evaluate(ctx context.Context, other mercury_type return fmt.Errorf("expected encoded %x but got %x", StaticOnChainConfigCodecFixtures.Encoded, encoded) } - decoded, err := other.Decode(StaticOnChainConfigCodecFixtures.Encoded) + decoded, err := other.Decode(ctx, StaticOnChainConfigCodecFixtures.Encoded) if err != nil { return fmt.Errorf("failed to decode: %w", err) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v1/reportcodec.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v1/reportcodec.go index b46220847..7fd67c37f 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v1/reportcodec.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v1/reportcodec.go @@ -23,8 +23,8 @@ func NewReportCodecClient(cc grpc.ClientConnInterface) *ReportCodecClient { return &ReportCodecClient{grpc: mercury_v1_pb.NewReportCodecClient(cc)} } -func (r *ReportCodecClient) BuildReport(fields mercury_v1_types.ReportFields) (ocr2plus_types.Report, error) { - reply, err := r.grpc.BuildReport(context.TODO(), &mercury_v1_pb.BuildReportRequest{ +func (r *ReportCodecClient) BuildReport(ctx context.Context, fields mercury_v1_types.ReportFields) (ocr2plus_types.Report, error) { + reply, err := r.grpc.BuildReport(ctx, &mercury_v1_pb.BuildReportRequest{ ReportFields: pbReportFields(fields), }) if err != nil { @@ -33,16 +33,16 @@ func (r *ReportCodecClient) BuildReport(fields mercury_v1_types.ReportFields) (o return reply.Report, nil } -func (r *ReportCodecClient) MaxReportLength(n int) (int, error) { - reply, err := r.grpc.MaxReportLength(context.TODO(), &mercury_v1_pb.MaxReportLengthRequest{}) +func (r *ReportCodecClient) MaxReportLength(ctx context.Context, n int) (int, error) { + reply, err := r.grpc.MaxReportLength(ctx, &mercury_v1_pb.MaxReportLengthRequest{}) if err != nil { return 0, err } return int(reply.MaxReportLength), nil } -func (r *ReportCodecClient) CurrentBlockNumFromReport(report ocr2plus_types.Report) (int64, error) { - reply, err := r.grpc.CurrentBlockNumFromReport(context.TODO(), &mercury_v1_pb.CurrentBlockNumFromReportRequest{ +func (r *ReportCodecClient) CurrentBlockNumFromReport(ctx context.Context, report ocr2plus_types.Report) (int64, error) { + reply, err := r.grpc.CurrentBlockNumFromReport(ctx, &mercury_v1_pb.CurrentBlockNumFromReportRequest{ Report: report, }) if err != nil { @@ -76,7 +76,7 @@ func NewReportCodecServer(impl mercury_v1_types.ReportCodec) *ReportCodecServer } func (r *ReportCodecServer) BuildReport(ctx context.Context, request *mercury_v1_pb.BuildReportRequest) (*mercury_v1_pb.BuildReportReply, error) { - report, err := r.impl.BuildReport(reportFields(request.ReportFields)) + report, err := r.impl.BuildReport(ctx, reportFields(request.ReportFields)) if err != nil { return nil, err } @@ -84,7 +84,7 @@ func (r *ReportCodecServer) BuildReport(ctx context.Context, request *mercury_v1 } func (r *ReportCodecServer) MaxReportLength(ctx context.Context, request *mercury_v1_pb.MaxReportLengthRequest) (*mercury_v1_pb.MaxReportLengthReply, error) { - n, err := r.impl.MaxReportLength(int(request.NumOracles)) + n, err := r.impl.MaxReportLength(ctx, int(request.NumOracles)) if err != nil { return nil, err } @@ -92,7 +92,7 @@ func (r *ReportCodecServer) MaxReportLength(ctx context.Context, request *mercur } func (r *ReportCodecServer) CurrentBlockNumFromReport(ctx context.Context, request *mercury_v1_pb.CurrentBlockNumFromReportRequest) (*mercury_v1_pb.CurrentBlockNumFromReportResponse, error) { - n, err := r.impl.CurrentBlockNumFromReport(request.Report) + n, err := r.impl.CurrentBlockNumFromReport(ctx, request.Report) if err != nil { return nil, err } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v1/test/reportcodec.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v1/test/reportcodec.go index 8449c4214..e95326962 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v1/test/reportcodec.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v1/test/reportcodec.go @@ -22,37 +22,37 @@ type staticReportCodec struct{} var _ mercury_v1_types.ReportCodec = staticReportCodec{} -func (s staticReportCodec) BuildReport(fields mercury_v1_types.ReportFields) (types.Report, error) { +func (s staticReportCodec) BuildReport(ctx context.Context, fields mercury_v1_types.ReportFields) (types.Report, error) { return Fixtures.Report, nil } // MaxReportLength Returns the maximum length of a report based on n, the number of oracles. // The output of BuildReport must respect this maximum length. -func (s staticReportCodec) MaxReportLength(n int) (int, error) { +func (s staticReportCodec) MaxReportLength(ctx context.Context, n int) (int, error) { return Fixtures.MaxReportLength, nil } // CurrentBlockNumFromReport returns the median current block number from a report -func (s staticReportCodec) CurrentBlockNumFromReport(types.Report) (int64, error) { +func (s staticReportCodec) CurrentBlockNumFromReport(context.Context, types.Report) (int64, error) { return Fixtures.CurrentBlockNum, nil } func (s staticReportCodec) Evaluate(ctx context.Context, other mercury_v1_types.ReportCodec) error { - gotReport, err := other.BuildReport(Fixtures.ReportFields) + gotReport, err := other.BuildReport(ctx, Fixtures.ReportFields) if err != nil { return fmt.Errorf("failed to BuildReport: %w", err) } if !bytes.Equal(gotReport, Fixtures.Report) { return fmt.Errorf("expected Report %x but got %x", Fixtures.Report, gotReport) } - gotMax, err := other.MaxReportLength(Fixtures.MaxReportLength) + gotMax, err := other.MaxReportLength(ctx, Fixtures.MaxReportLength) if err != nil { return fmt.Errorf("failed to get MaxReportLength: %w", err) } if gotMax != Fixtures.MaxReportLength { return fmt.Errorf("expected MaxReportLength %d but got %d", Fixtures.MaxReportLength, gotMax) } - gotCurrentBlockNum, err := other.CurrentBlockNumFromReport(gotReport) + gotCurrentBlockNum, err := other.CurrentBlockNumFromReport(ctx, gotReport) if err != nil { return fmt.Errorf("failed to get ObservationTimestampFromReport: %w", err) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v2/reportcodec.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v2/reportcodec.go index ecc004427..b407efdac 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v2/reportcodec.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v2/reportcodec.go @@ -23,8 +23,8 @@ func NewReportCodecClient(cc grpc.ClientConnInterface) *ReportCodecClient { return &ReportCodecClient{grpc: mercury_v2_pb.NewReportCodecClient(cc)} } -func (r *ReportCodecClient) BuildReport(fields mercury_v2_types.ReportFields) (ocr2plus_types.Report, error) { - reply, err := r.grpc.BuildReport(context.TODO(), &mercury_v2_pb.BuildReportRequest{ +func (r *ReportCodecClient) BuildReport(ctx context.Context, fields mercury_v2_types.ReportFields) (ocr2plus_types.Report, error) { + reply, err := r.grpc.BuildReport(ctx, &mercury_v2_pb.BuildReportRequest{ ReportFields: pbReportFields(fields), }) if err != nil { @@ -33,16 +33,16 @@ func (r *ReportCodecClient) BuildReport(fields mercury_v2_types.ReportFields) (o return reply.Report, nil } -func (r *ReportCodecClient) MaxReportLength(n int) (int, error) { - reply, err := r.grpc.MaxReportLength(context.TODO(), &mercury_v2_pb.MaxReportLengthRequest{}) +func (r *ReportCodecClient) MaxReportLength(ctx context.Context, n int) (int, error) { + reply, err := r.grpc.MaxReportLength(ctx, &mercury_v2_pb.MaxReportLengthRequest{}) if err != nil { return 0, err } return int(reply.MaxReportLength), nil } -func (r *ReportCodecClient) ObservationTimestampFromReport(report ocr2plus_types.Report) (uint32, error) { - reply, err := r.grpc.ObservationTimestampFromReport(context.TODO(), &mercury_v2_pb.ObservationTimestampFromReportRequest{ +func (r *ReportCodecClient) ObservationTimestampFromReport(ctx context.Context, report ocr2plus_types.Report) (uint32, error) { + reply, err := r.grpc.ObservationTimestampFromReport(ctx, &mercury_v2_pb.ObservationTimestampFromReportRequest{ Report: report, }) if err != nil { @@ -74,7 +74,7 @@ func NewReportCodecServer(impl mercury_v2_types.ReportCodec) *ReportCodecServer } func (r *ReportCodecServer) BuildReport(ctx context.Context, request *mercury_v2_pb.BuildReportRequest) (*mercury_v2_pb.BuildReportReply, error) { - report, err := r.impl.BuildReport(reportFields(request.ReportFields)) + report, err := r.impl.BuildReport(ctx, reportFields(request.ReportFields)) if err != nil { return nil, err } @@ -82,7 +82,7 @@ func (r *ReportCodecServer) BuildReport(ctx context.Context, request *mercury_v2 } func (r *ReportCodecServer) MaxReportLength(ctx context.Context, request *mercury_v2_pb.MaxReportLengthRequest) (*mercury_v2_pb.MaxReportLengthReply, error) { - n, err := r.impl.MaxReportLength(int(request.NumOracles)) + n, err := r.impl.MaxReportLength(ctx, int(request.NumOracles)) if err != nil { return nil, err } @@ -90,7 +90,7 @@ func (r *ReportCodecServer) MaxReportLength(ctx context.Context, request *mercur } func (r *ReportCodecServer) ObservationTimestampFromReport(ctx context.Context, request *mercury_v2_pb.ObservationTimestampFromReportRequest) (*mercury_v2_pb.ObservationTimestampFromReportReply, error) { - timestamp, err := r.impl.ObservationTimestampFromReport(request.Report) + timestamp, err := r.impl.ObservationTimestampFromReport(ctx, request.Report) if err != nil { return nil, err } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v2/test/reportcodec.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v2/test/reportcodec.go index 864022a1e..a8b125f57 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v2/test/reportcodec.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v2/test/reportcodec.go @@ -35,37 +35,37 @@ var StaticReportCodecFixtures = StaticReportCodecValues{ ObservationTimestamp: 23, } -func (s staticReportCodec) BuildReport(fields mercury_v2_types.ReportFields) (types.Report, error) { +func (s staticReportCodec) BuildReport(ctx context.Context, fields mercury_v2_types.ReportFields) (types.Report, error) { return StaticReportCodecFixtures.Report, nil } // MaxReportLength Returns the maximum length of a report based on n, the number of oracles. // The output of BuildReport must respect this maximum length. -func (s staticReportCodec) MaxReportLength(n int) (int, error) { +func (s staticReportCodec) MaxReportLength(ctx context.Context, n int) (int, error) { return StaticReportCodecFixtures.MaxReportLength, nil } // CurrentBlockNumFromReport returns the median current block number from a report -func (s staticReportCodec) ObservationTimestampFromReport(types.Report) (uint32, error) { +func (s staticReportCodec) ObservationTimestampFromReport(context.Context, types.Report) (uint32, error) { return StaticReportCodecFixtures.ObservationTimestamp, nil } func (s staticReportCodec) Evaluate(ctx context.Context, other mercury_v2_types.ReportCodec) error { - gotReport, err := other.BuildReport(Fixtures.ReportFields) + gotReport, err := other.BuildReport(ctx, Fixtures.ReportFields) if err != nil { return fmt.Errorf("failed to BuildReport: %w", err) } if !bytes.Equal(gotReport, Fixtures.Report) { return fmt.Errorf("expected Report %x but got %x", Fixtures.Report, gotReport) } - gotMax, err := other.MaxReportLength(Fixtures.MaxReportLength) + gotMax, err := other.MaxReportLength(ctx, Fixtures.MaxReportLength) if err != nil { return fmt.Errorf("failed to get MaxReportLength: %w", err) } if gotMax != Fixtures.MaxReportLength { return fmt.Errorf("expected MaxReportLength %d but got %d", Fixtures.MaxReportLength, gotMax) } - gotObservedTimestamp, err := other.ObservationTimestampFromReport(gotReport) + gotObservedTimestamp, err := other.ObservationTimestampFromReport(ctx, gotReport) if err != nil { return fmt.Errorf("failed to get ObservationTimestampFromReport: %w", err) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v3/reportcodec.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v3/reportcodec.go index 1d4212c09..42acce88d 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v3/reportcodec.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v3/reportcodec.go @@ -22,8 +22,8 @@ func NewReportCodecClient(cc grpc.ClientConnInterface) *ReportCodecClient { return &ReportCodecClient{grpc: mercury_v3_pb.NewReportCodecClient(cc)} } -func (r *ReportCodecClient) BuildReport(fields mercury_v3_types.ReportFields) (ocr2plus_types.Report, error) { - reply, err := r.grpc.BuildReport(context.TODO(), &mercury_v3_pb.BuildReportRequest{ +func (r *ReportCodecClient) BuildReport(ctx context.Context, fields mercury_v3_types.ReportFields) (ocr2plus_types.Report, error) { + reply, err := r.grpc.BuildReport(ctx, &mercury_v3_pb.BuildReportRequest{ ReportFields: pbReportFields(fields), }) if err != nil { @@ -32,16 +32,16 @@ func (r *ReportCodecClient) BuildReport(fields mercury_v3_types.ReportFields) (o return reply.Report, nil } -func (r *ReportCodecClient) MaxReportLength(n int) (int, error) { - reply, err := r.grpc.MaxReportLength(context.TODO(), &mercury_v3_pb.MaxReportLengthRequest{}) +func (r *ReportCodecClient) MaxReportLength(ctx context.Context, n int) (int, error) { + reply, err := r.grpc.MaxReportLength(ctx, &mercury_v3_pb.MaxReportLengthRequest{}) if err != nil { return 0, err } return int(reply.MaxReportLength), nil } -func (r *ReportCodecClient) ObservationTimestampFromReport(report ocr2plus_types.Report) (uint32, error) { - reply, err := r.grpc.ObservationTimestampFromReport(context.TODO(), &mercury_v3_pb.ObservationTimestampFromReportRequest{ +func (r *ReportCodecClient) ObservationTimestampFromReport(ctx context.Context, report ocr2plus_types.Report) (uint32, error) { + reply, err := r.grpc.ObservationTimestampFromReport(ctx, &mercury_v3_pb.ObservationTimestampFromReportRequest{ Report: report, }) if err != nil { @@ -75,7 +75,7 @@ func NewReportCodecServer(impl mercury_v3_types.ReportCodec) *ReportCodecServer } func (r *ReportCodecServer) BuildReport(ctx context.Context, request *mercury_v3_pb.BuildReportRequest) (*mercury_v3_pb.BuildReportReply, error) { - report, err := r.impl.BuildReport(reportFields(request.ReportFields)) + report, err := r.impl.BuildReport(ctx, reportFields(request.ReportFields)) if err != nil { return nil, err } @@ -83,7 +83,7 @@ func (r *ReportCodecServer) BuildReport(ctx context.Context, request *mercury_v3 } func (r *ReportCodecServer) MaxReportLength(ctx context.Context, request *mercury_v3_pb.MaxReportLengthRequest) (*mercury_v3_pb.MaxReportLengthReply, error) { - n, err := r.impl.MaxReportLength(int(request.NumOracles)) + n, err := r.impl.MaxReportLength(ctx, int(request.NumOracles)) if err != nil { return nil, err } @@ -91,7 +91,7 @@ func (r *ReportCodecServer) MaxReportLength(ctx context.Context, request *mercur } func (r *ReportCodecServer) ObservationTimestampFromReport(ctx context.Context, request *mercury_v3_pb.ObservationTimestampFromReportRequest) (*mercury_v3_pb.ObservationTimestampFromReportReply, error) { - timestamp, err := r.impl.ObservationTimestampFromReport(request.Report) + timestamp, err := r.impl.ObservationTimestampFromReport(ctx, request.Report) if err != nil { return nil, err } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v3/test/reportcodec.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v3/test/reportcodec.go index 91c413da0..7764b74bf 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v3/test/reportcodec.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v3/test/reportcodec.go @@ -22,34 +22,34 @@ type staticReportCodec struct{} var _ ReportCodecEvaluator = staticReportCodec{} -func (staticReportCodec) BuildReport(fields mercury_v3_types.ReportFields) (ocr2plus_types.Report, error) { +func (staticReportCodec) BuildReport(ctx context.Context, fields mercury_v3_types.ReportFields) (ocr2plus_types.Report, error) { return Fixtures.Report, nil } -func (staticReportCodec) MaxReportLength(n int) (int, error) { +func (staticReportCodec) MaxReportLength(ctx context.Context, n int) (int, error) { return Fixtures.MaxReportLength, nil } -func (staticReportCodec) ObservationTimestampFromReport(report ocr2plus_types.Report) (uint32, error) { +func (staticReportCodec) ObservationTimestampFromReport(ctx context.Context, report ocr2plus_types.Report) (uint32, error) { return Fixtures.ObservationTimestamp, nil } func (staticReportCodec) Evaluate(ctx context.Context, other mercury_v3_types.ReportCodec) error { - gotReport, err := other.BuildReport(Fixtures.ReportFields) + gotReport, err := other.BuildReport(ctx, Fixtures.ReportFields) if err != nil { return fmt.Errorf("failed to BuildReport: %w", err) } if !bytes.Equal(gotReport, Fixtures.Report) { return fmt.Errorf("expected Report %x but got %x", Fixtures.Report, gotReport) } - gotMax, err := other.MaxReportLength(Fixtures.MaxReportLength) + gotMax, err := other.MaxReportLength(ctx, Fixtures.MaxReportLength) if err != nil { return fmt.Errorf("failed to get MaxReportLength: %w", err) } if gotMax != Fixtures.MaxReportLength { return fmt.Errorf("expected MaxReportLength %d but got %d", Fixtures.MaxReportLength, gotMax) } - gotObservedTimestamp, err := other.ObservationTimestampFromReport(gotReport) + gotObservedTimestamp, err := other.ObservationTimestampFromReport(ctx, gotReport) if err != nil { return fmt.Errorf("failed to get ObservationTimestampFromReport: %w", err) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v4/reportcodec.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v4/reportcodec.go index 58c6df4ec..dc5e9cf41 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v4/reportcodec.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v4/reportcodec.go @@ -21,8 +21,8 @@ func NewReportCodecClient(cc grpc.ClientConnInterface) *ReportCodecClient { return &ReportCodecClient{grpc: mercury_v4_pb.NewReportCodecClient(cc)} } -func (r *ReportCodecClient) BuildReport(fields mercury_v4_types.ReportFields) (ocr2plus_types.Report, error) { - reply, err := r.grpc.BuildReport(context.TODO(), &mercury_v4_pb.BuildReportRequest{ +func (r *ReportCodecClient) BuildReport(ctx context.Context, fields mercury_v4_types.ReportFields) (ocr2plus_types.Report, error) { + reply, err := r.grpc.BuildReport(ctx, &mercury_v4_pb.BuildReportRequest{ ReportFields: pbReportFields(fields), }) if err != nil { @@ -31,16 +31,16 @@ func (r *ReportCodecClient) BuildReport(fields mercury_v4_types.ReportFields) (o return reply.Report, nil } -func (r *ReportCodecClient) MaxReportLength(n int) (int, error) { - reply, err := r.grpc.MaxReportLength(context.TODO(), &mercury_v4_pb.MaxReportLengthRequest{}) +func (r *ReportCodecClient) MaxReportLength(ctx context.Context, n int) (int, error) { + reply, err := r.grpc.MaxReportLength(ctx, &mercury_v4_pb.MaxReportLengthRequest{}) if err != nil { return 0, err } return int(reply.MaxReportLength), nil } -func (r *ReportCodecClient) ObservationTimestampFromReport(report ocr2plus_types.Report) (uint32, error) { - reply, err := r.grpc.ObservationTimestampFromReport(context.TODO(), &mercury_v4_pb.ObservationTimestampFromReportRequest{ +func (r *ReportCodecClient) ObservationTimestampFromReport(ctx context.Context, report ocr2plus_types.Report) (uint32, error) { + reply, err := r.grpc.ObservationTimestampFromReport(ctx, &mercury_v4_pb.ObservationTimestampFromReportRequest{ Report: report, }) if err != nil { @@ -73,7 +73,7 @@ func NewReportCodecServer(impl mercury_v4_types.ReportCodec) *ReportCodecServer } func (r *ReportCodecServer) BuildReport(ctx context.Context, request *mercury_v4_pb.BuildReportRequest) (*mercury_v4_pb.BuildReportReply, error) { - report, err := r.impl.BuildReport(reportFields(request.ReportFields)) + report, err := r.impl.BuildReport(ctx, reportFields(request.ReportFields)) if err != nil { return nil, err } @@ -81,7 +81,7 @@ func (r *ReportCodecServer) BuildReport(ctx context.Context, request *mercury_v4 } func (r *ReportCodecServer) MaxReportLength(ctx context.Context, request *mercury_v4_pb.MaxReportLengthRequest) (*mercury_v4_pb.MaxReportLengthReply, error) { - n, err := r.impl.MaxReportLength(int(request.NumOracles)) + n, err := r.impl.MaxReportLength(ctx, int(request.NumOracles)) if err != nil { return nil, err } @@ -89,7 +89,7 @@ func (r *ReportCodecServer) MaxReportLength(ctx context.Context, request *mercur } func (r *ReportCodecServer) ObservationTimestampFromReport(ctx context.Context, request *mercury_v4_pb.ObservationTimestampFromReportRequest) (*mercury_v4_pb.ObservationTimestampFromReportReply, error) { - timestamp, err := r.impl.ObservationTimestampFromReport(request.Report) + timestamp, err := r.impl.ObservationTimestampFromReport(ctx, request.Report) if err != nil { return nil, err } diff --git a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v4/test/reportcodec.go b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v4/test/reportcodec.go index 5860487c3..d7e70c23c 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v4/test/reportcodec.go +++ b/pkg/loop/internal/relayer/pluginprovider/ext/mercury/v4/test/reportcodec.go @@ -22,34 +22,34 @@ type staticReportCodec struct{} var _ ReportCodecEvaluator = staticReportCodec{} -func (staticReportCodec) BuildReport(fields mercury_v4_types.ReportFields) (ocr2plus_types.Report, error) { +func (staticReportCodec) BuildReport(ctx context.Context, fields mercury_v4_types.ReportFields) (ocr2plus_types.Report, error) { return Fixtures.Report, nil } -func (staticReportCodec) MaxReportLength(n int) (int, error) { +func (staticReportCodec) MaxReportLength(ctx context.Context, n int) (int, error) { return Fixtures.MaxReportLength, nil } -func (staticReportCodec) ObservationTimestampFromReport(report ocr2plus_types.Report) (uint32, error) { +func (staticReportCodec) ObservationTimestampFromReport(ctx context.Context, report ocr2plus_types.Report) (uint32, error) { return Fixtures.ObservationTimestamp, nil } func (staticReportCodec) Evaluate(ctx context.Context, other mercury_v4_types.ReportCodec) error { - gotReport, err := other.BuildReport(Fixtures.ReportFields) + gotReport, err := other.BuildReport(ctx, Fixtures.ReportFields) if err != nil { return fmt.Errorf("failed to BuildReport: %w", err) } if !bytes.Equal(gotReport, Fixtures.Report) { return fmt.Errorf("expected Report %x but got %x", Fixtures.Report, gotReport) } - gotMax, err := other.MaxReportLength(Fixtures.MaxReportLength) + gotMax, err := other.MaxReportLength(ctx, Fixtures.MaxReportLength) if err != nil { return fmt.Errorf("failed to get MaxReportLength: %w", err) } if gotMax != Fixtures.MaxReportLength { return fmt.Errorf("expected MaxReportLength %d but got %d", Fixtures.MaxReportLength, gotMax) } - gotObservedTimestamp, err := other.ObservationTimestampFromReport(gotReport) + gotObservedTimestamp, err := other.ObservationTimestampFromReport(ctx, gotReport) if err != nil { return fmt.Errorf("failed to get ObservationTimestampFromReport: %w", err) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ocr2/config.go b/pkg/loop/internal/relayer/pluginprovider/ocr2/config.go index 9ed3d7d5b..14cafd48b 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ocr2/config.go +++ b/pkg/loop/internal/relayer/pluginprovider/ocr2/config.go @@ -47,9 +47,7 @@ type offchainConfigDigesterClient struct { grpc pb.OffchainConfigDigesterClient } -func (o *offchainConfigDigesterClient) ConfigDigest(config libocr.ContractConfig) (digest libocr.ConfigDigest, err error) { - ctx, cancel := o.StopCtx() - defer cancel() +func (o *offchainConfigDigesterClient) ConfigDigest(ctx context.Context, config libocr.ContractConfig) (digest libocr.ConfigDigest, err error) { var reply *pb.ConfigDigestReply reply, err = o.grpc.ConfigDigest(ctx, &pb.ConfigDigestRequest{ ContractConfig: pbContractConfig(config), @@ -65,9 +63,7 @@ func (o *offchainConfigDigesterClient) ConfigDigest(config libocr.ContractConfig return } -func (o *offchainConfigDigesterClient) ConfigDigestPrefix() (libocr.ConfigDigestPrefix, error) { - ctx, cancel := o.StopCtx() - defer cancel() +func (o *offchainConfigDigesterClient) ConfigDigestPrefix(ctx context.Context) (libocr.ConfigDigestPrefix, error) { reply, err := o.grpc.ConfigDigestPrefix(ctx, &pb.ConfigDigestPrefixRequest{}) if err != nil { return 0, err @@ -100,7 +96,7 @@ func (o *offchainConfigDigesterServer) ConfigDigest(ctx context.Context, request for _, t := range request.ContractConfig.Transmitters { cc.Transmitters = append(cc.Transmitters, libocr.Account(t)) } - cd, err := o.impl.ConfigDigest(cc) + cd, err := o.impl.ConfigDigest(ctx, cc) if err != nil { return nil, err } @@ -108,7 +104,7 @@ func (o *offchainConfigDigesterServer) ConfigDigest(ctx context.Context, request } func (o *offchainConfigDigesterServer) ConfigDigestPrefix(ctx context.Context, request *pb.ConfigDigestPrefixRequest) (*pb.ConfigDigestPrefixReply, error) { - p, err := o.impl.ConfigDigestPrefix() + p, err := o.impl.ConfigDigestPrefix(ctx) if err != nil { return nil, err } diff --git a/pkg/loop/internal/relayer/pluginprovider/ocr2/contract_transmitter.go b/pkg/loop/internal/relayer/pluginprovider/ocr2/contract_transmitter.go index 7c14307d1..323f73207 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ocr2/contract_transmitter.go +++ b/pkg/loop/internal/relayer/pluginprovider/ocr2/contract_transmitter.go @@ -60,8 +60,8 @@ func (c *contractTransmitterClient) LatestConfigDigestAndEpoch(ctx context.Conte return } -func (c *contractTransmitterClient) FromAccount() (libocr.Account, error) { - reply, err := c.grpc.FromAccount(context.TODO(), &pb.FromAccountRequest{}) +func (c *contractTransmitterClient) FromAccount(ctx context.Context) (libocr.Account, error) { + reply, err := c.grpc.FromAccount(ctx, &pb.FromAccountRequest{}) if err != nil { return "", err } @@ -112,7 +112,7 @@ func (c *contractTransmitterServer) LatestConfigDigestAndEpoch(ctx context.Conte } func (c *contractTransmitterServer) FromAccount(ctx context.Context, request *pb.FromAccountRequest) (*pb.FromAccountReply, error) { - a, err := c.impl.FromAccount() + a, err := c.impl.FromAccount(ctx) if err != nil { return nil, err } diff --git a/pkg/loop/internal/relayer/pluginprovider/ocr2/test/contract_transmitter.go b/pkg/loop/internal/relayer/pluginprovider/ocr2/test/contract_transmitter.go index b5f139686..c5e11e3c6 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ocr2/test/contract_transmitter.go +++ b/pkg/loop/internal/relayer/pluginprovider/ocr2/test/contract_transmitter.go @@ -44,12 +44,12 @@ func (s staticContractTransmitter) LatestConfigDigestAndEpoch(ctx context.Contex return s.ConfigDigest, s.Epoch, nil } -func (s staticContractTransmitter) FromAccount() (libocr.Account, error) { +func (s staticContractTransmitter) FromAccount(ctx context.Context) (libocr.Account, error) { return s.Account, nil } func (s staticContractTransmitter) Evaluate(ctx context.Context, ct libocr.ContractTransmitter) error { - gotAccount, err := ct.FromAccount() + gotAccount, err := ct.FromAccount(ctx) if err != nil { return fmt.Errorf("failed to get FromAccount: %w", err) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ocr2/test/offchain_config_digester.go b/pkg/loop/internal/relayer/pluginprovider/ocr2/test/offchain_config_digester.go index 2b8a043e2..badd71bd7 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ocr2/test/offchain_config_digester.go +++ b/pkg/loop/internal/relayer/pluginprovider/ocr2/test/offchain_config_digester.go @@ -21,26 +21,26 @@ type staticOffchainConfigDigester struct { var _ libocr.OffchainConfigDigester = staticOffchainConfigDigester{} -func (s staticOffchainConfigDigester) ConfigDigest(config libocr.ContractConfig) (libocr.ConfigDigest, error) { +func (s staticOffchainConfigDigester) ConfigDigest(ctx context.Context, config libocr.ContractConfig) (libocr.ConfigDigest, error) { if !assert.ObjectsAreEqual(s.contractConfig, config) { return libocr.ConfigDigest{}, fmt.Errorf("expected contract config %v but got %v", s.configDigest, config) } return s.configDigest, nil } -func (s staticOffchainConfigDigester) ConfigDigestPrefix() (libocr.ConfigDigestPrefix, error) { +func (s staticOffchainConfigDigester) ConfigDigestPrefix(ctx context.Context) (libocr.ConfigDigestPrefix, error) { return s.configDigestPrefix, nil } func (s staticOffchainConfigDigester) Evaluate(ctx context.Context, ocd libocr.OffchainConfigDigester) error { - gotDigestPrefix, err := ocd.ConfigDigestPrefix() + gotDigestPrefix, err := ocd.ConfigDigestPrefix(ctx) if err != nil { return fmt.Errorf("failed to get ConfigDigestPrefix: %w", err) } if gotDigestPrefix != s.configDigestPrefix { return fmt.Errorf("expected ConfigDigestPrefix %x but got %x", s.configDigestPrefix, gotDigestPrefix) } - gotDigest, err := ocd.ConfigDigest(contractConfig) + gotDigest, err := ocd.ConfigDigest(ctx, contractConfig) if err != nil { return fmt.Errorf("failed to get ConfigDigest: %w", err) } diff --git a/pkg/loop/internal/relayer/pluginprovider/ocr3/contract_transmitter.go b/pkg/loop/internal/relayer/pluginprovider/ocr3/contract_transmitter.go index ff96ff969..e5525ac31 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ocr3/contract_transmitter.go +++ b/pkg/loop/internal/relayer/pluginprovider/ocr3/contract_transmitter.go @@ -55,8 +55,8 @@ func (c *contractTransmitterClient) Transmit(ctx context.Context, configDigest l return nil } -func (c *contractTransmitterClient) FromAccount() (libocr.Account, error) { - reply, err := c.grpc.FromAccount(context.TODO(), &emptypb.Empty{}) +func (c *contractTransmitterClient) FromAccount(ctx context.Context) (libocr.Account, error) { + reply, err := c.grpc.FromAccount(ctx, &emptypb.Empty{}) if err != nil { return "", err } @@ -97,7 +97,7 @@ func (c *contractTransmitterServer) Transmit(ctx context.Context, request *ocr3p } func (c *contractTransmitterServer) FromAccount(ctx context.Context, request *emptypb.Empty) (*ocr3pb.FromAccountReply, error) { - a, err := c.impl.FromAccount() + a, err := c.impl.FromAccount(ctx) if err != nil { return nil, err } diff --git a/pkg/loop/internal/relayer/pluginprovider/ocr3/test/contract_transmitter.go b/pkg/loop/internal/relayer/pluginprovider/ocr3/test/contract_transmitter.go index 8372d2e88..54d8b523f 100644 --- a/pkg/loop/internal/relayer/pluginprovider/ocr3/test/contract_transmitter.go +++ b/pkg/loop/internal/relayer/pluginprovider/ocr3/test/contract_transmitter.go @@ -71,12 +71,12 @@ func (s staticOCR3ContractTransmitter) Transmit(ctx context.Context, configDiges return nil } -func (s staticOCR3ContractTransmitter) FromAccount() (libocr.Account, error) { +func (s staticOCR3ContractTransmitter) FromAccount(ctx context.Context) (libocr.Account, error) { return s.Account, nil } func (s staticOCR3ContractTransmitter) Evaluate(ctx context.Context, ct ocr3types.ContractTransmitter[[]byte]) error { - gotAccount, err := ct.FromAccount() + gotAccount, err := ct.FromAccount(ctx) if err != nil { return fmt.Errorf("failed to get FromAccount: %w", err) } diff --git a/pkg/loop/internal/relayer/relayer.go b/pkg/loop/internal/relayer/relayer.go index 0ccd85f1b..97cdc35e6 100644 --- a/pkg/loop/internal/relayer/relayer.go +++ b/pkg/loop/internal/relayer/relayer.go @@ -261,7 +261,7 @@ func (r *relayerClient) NewPluginProvider(ctx context.Context, rargs types.Relay broker := r.BrokerExt - return WrapProviderClientConnection(rargs.ProviderType, cc, broker) + return WrapProviderClientConnection(ctx, rargs.ProviderType, cc, broker) } type PluginProviderClient interface { @@ -269,13 +269,15 @@ type PluginProviderClient interface { goplugin.GRPCClientConn } -func WrapProviderClientConnection(providerType string, cc grpc.ClientConnInterface, broker *net.BrokerExt) (PluginProviderClient, error) { +func WrapProviderClientConnection(ctx context.Context, providerType string, cc grpc.ClientConnInterface, broker *net.BrokerExt) (PluginProviderClient, error) { // TODO: Remove this when we have fully transitioned all relayers to running in LOOPPs. // This allows callers to type assert a PluginProvider into a product provider type (eg. MedianProvider) // for interoperability with legacy code. switch providerType { case string(types.Median): - return median.NewProviderClient(broker, cc), nil + pc := median.NewProviderClient(broker, cc) + pc.RmUnimplemented(ctx) + return pc, nil case string(types.GenericPlugin): return ocr2.NewPluginProviderClient(broker, cc), nil case string(types.OCR3Capability): diff --git a/pkg/loop/internal/relayerset/inprocessprovider/grpc_provider_server_test.go b/pkg/loop/internal/relayerset/inprocessprovider/grpc_provider_server_test.go index 52005444a..adf3a20c4 100644 --- a/pkg/loop/internal/relayerset/inprocessprovider/grpc_provider_server_test.go +++ b/pkg/loop/internal/relayerset/inprocessprovider/grpc_provider_server_test.go @@ -10,15 +10,13 @@ import ( ocr2types "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/smartcontractkit/chainlink-common/pkg/logger" - "github.com/smartcontractkit/chainlink-common/pkg/loop/adapters/relay" "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" ) func TestProviderServer(t *testing.T) { r := &mockRelayer{} - sa := relay.NewServerAdapter(r, mockRelayerExt{}) - mp, _ := sa.NewPluginProvider(tests.Context(t), types.RelayArgs{ProviderType: string(types.Median)}, types.PluginArgs{}) + mp, _ := r.NewPluginProvider(tests.Context(t), types.RelayArgs{ProviderType: string(types.Median)}, types.PluginArgs{}) lggr := logger.Test(t) _, err := NewProviderServer(mp, "unsupported-type", lggr) @@ -35,30 +33,26 @@ type mockRelayer struct { types.Relayer } -func (m *mockRelayer) NewMedianProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.MedianProvider, error) { +func (m *mockRelayer) NewMedianProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.MedianProvider, error) { return staticMedianProvider{}, nil } -func (m *mockRelayer) NewFunctionsProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.FunctionsProvider, error) { +func (m *mockRelayer) NewFunctionsProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.FunctionsProvider, error) { return staticFunctionsProvider{}, nil } -func (m *mockRelayer) NewMercuryProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.MercuryProvider, error) { +func (m *mockRelayer) NewMercuryProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.MercuryProvider, error) { return staticMercuryProvider{}, nil } -func (m *mockRelayer) NewAutomationProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.AutomationProvider, error) { +func (m *mockRelayer) NewAutomationProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.AutomationProvider, error) { return staticAutomationProvider{}, nil } -func (m *mockRelayer) NewPluginProvider(rargs types.RelayArgs, pargs types.PluginArgs) (types.PluginProvider, error) { +func (m *mockRelayer) NewPluginProvider(ctx context.Context, rargs types.RelayArgs, pargs types.PluginArgs) (types.PluginProvider, error) { return staticPluginProvider{}, nil } -type mockRelayerExt struct { - relay.RelayerExt -} - type staticMedianProvider struct { } diff --git a/pkg/loop/internal/relayerset/relayer.go b/pkg/loop/internal/relayerset/relayer.go index 8a5ffc751..a85dcdbc6 100644 --- a/pkg/loop/internal/relayerset/relayer.go +++ b/pkg/loop/internal/relayerset/relayer.go @@ -33,7 +33,7 @@ func (r *relayerClient) NewPluginProvider(ctx context.Context, rargs core.RelayA return providerID, nil, nil }) - return relayer.WrapProviderClientConnection(rargs.ProviderType, cc, r.relayerSetClient.BrokerExt) + return relayer.WrapProviderClientConnection(ctx, rargs.ProviderType, cc, r.relayerSetClient.BrokerExt) } func (r *relayerClient) NewContractReader(_ context.Context, contractReaderConfig []byte) (types.ContractReader, error) { @@ -60,8 +60,8 @@ func (r *relayerClient) NewChainWriter(_ context.Context, chainWriterConfig []by return chainwriter.NewClient(r.relayerSetClient.BrokerExt.WithName("ChainWriterClient"), cwc), nil } -func (r *relayerClient) Start(context.Context) error { - return r.relayerSetClient.StartRelayer(context.Background(), r.relayerID) +func (r *relayerClient) Start(ctx context.Context) error { + return r.relayerSetClient.StartRelayer(ctx, r.relayerID) } func (r *relayerClient) Close() error { diff --git a/pkg/loop/internal/reportingplugin/median/median.go b/pkg/loop/internal/reportingplugin/median/median.go index dbba44261..a6b53fc68 100644 --- a/pkg/loop/internal/reportingplugin/median/median.go +++ b/pkg/loop/internal/reportingplugin/median/median.go @@ -149,6 +149,7 @@ func (m *pluginMedianServer) NewMedianFactory(ctx context.Context, request *pb.N } providerRes := net.Resource{Closer: providerConn, Name: "MedianProvider"} provider := medianprovider.NewProviderClient(m.BrokerExt, providerConn) + provider.RmUnimplemented(ctx) errorLogConn, err := m.Dial(request.ErrorLogID) if err != nil { diff --git a/pkg/loop/internal/reportingplugin/mercury/mercury_reporting.go b/pkg/loop/internal/reportingplugin/mercury/mercury_reporting.go index 996f502ba..e2d91d47d 100644 --- a/pkg/loop/internal/reportingplugin/mercury/mercury_reporting.go +++ b/pkg/loop/internal/reportingplugin/mercury/mercury_reporting.go @@ -26,9 +26,7 @@ func NewPluginFactoryClient(b *net.BrokerExt, cc grpc.ClientConnInterface) *Plug return &PluginFactoryClient{b.WithName("MercuryPluginProviderClient"), goplugin.NewServiceClient(b, cc), mercurypb.NewMercuryPluginFactoryClient(cc)} } -func (r *PluginFactoryClient) NewMercuryPlugin(config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { - ctx, cancel := r.StopCtx() - defer cancel() +func (r *PluginFactoryClient) NewMercuryPlugin(ctx context.Context, config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { response, err := r.client.NewMercuryPlugin(ctx, &mercurypb.NewMercuryPluginRequest{MercuryPluginConfig: &mercurypb.MercuryPluginConfig{ ConfigDigest: config.ConfigDigest[:], OracleID: uint32(config.OracleID), @@ -86,7 +84,7 @@ func (r *mercuryPluginFactoryServer) NewMercuryPlugin(ctx context.Context, reque } copy(cfg.ConfigDigest[:], request.MercuryPluginConfig.ConfigDigest) - rp, rpi, err := r.impl.NewMercuryPlugin(cfg) + rp, rpi, err := r.impl.NewMercuryPlugin(ctx, cfg) if err != nil { return nil, err } @@ -130,9 +128,7 @@ func (r *mercuryPluginClient) Observation(ctx context.Context, timestamp libocr. return response.Observation, nil } -func (r *mercuryPluginClient) Report(timestamp libocr.ReportTimestamp, previousReport libocr.Report, obs []libocr.AttributedObservation) (bool, libocr.Report, error) { - ctx, cancel := r.StopCtx() - defer cancel() +func (r *mercuryPluginClient) Report(ctx context.Context, timestamp libocr.ReportTimestamp, previousReport libocr.Report, obs []libocr.AttributedObservation) (bool, libocr.Report, error) { response, err := r.grpc.Report(ctx, &mercurypb.ReportRequest{ ReportTimestamp: pb.ReportTimestampToPb(timestamp), PreviousReport: previousReport, @@ -181,7 +177,7 @@ func (r *mercuryPluginServer) Report(ctx context.Context, request *mercurypb.Rep if err != nil { return nil, err } - should, report, err := r.impl.Report(rts, request.PreviousReport, obs) + should, report, err := r.impl.Report(ctx, rts, request.PreviousReport, obs) if err != nil { return nil, err } diff --git a/pkg/loop/internal/reportingplugin/test/factory.go b/pkg/loop/internal/reportingplugin/test/factory.go index aeb2849ff..d07e88544 100644 --- a/pkg/loop/internal/reportingplugin/test/factory.go +++ b/pkg/loop/internal/reportingplugin/test/factory.go @@ -48,7 +48,7 @@ func (s staticFactory) Ready() error { panic("implement me") } func (s staticFactory) HealthReport() map[string]error { panic("implement me") } -func (s staticFactory) NewReportingPlugin(config libocr.ReportingPluginConfig) (libocr.ReportingPlugin, libocr.ReportingPluginInfo, error) { +func (s staticFactory) NewReportingPlugin(ctx context.Context, config libocr.ReportingPluginConfig) (libocr.ReportingPlugin, libocr.ReportingPluginInfo, error) { err := s.equalConfig(config) if err != nil { return nil, libocr.ReportingPluginInfo{}, fmt.Errorf("config mismatch: %w", err) @@ -100,7 +100,7 @@ func RunFactory(t *testing.T, factory libocr.ReportingPluginFactory) { expectedFactory := Factory t.Run("ReportingPluginFactory", func(t *testing.T) { ctx := tests.Context(t) - rp, gotRPI, err := factory.NewReportingPlugin(expectedFactory.ReportingPluginConfig) + rp, gotRPI, err := factory.NewReportingPlugin(ctx, expectedFactory.ReportingPluginConfig) require.NoError(t, err) assert.Equal(t, expectedFactory.rpi, gotRPI) t.Cleanup(func() { assert.NoError(t, rp.Close()) }) diff --git a/pkg/loop/median_service.go b/pkg/loop/median_service.go index 0e4bf485f..44bf302c7 100644 --- a/pkg/loop/median_service.go +++ b/pkg/loop/median_service.go @@ -39,9 +39,9 @@ func NewMedianService(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec.Cm return &ms } -func (m *MedianService) NewReportingPlugin(config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { +func (m *MedianService) NewReportingPlugin(ctx context.Context, config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { if err := m.Wait(); err != nil { return nil, ocrtypes.ReportingPluginInfo{}, err } - return m.Service.NewReportingPlugin(config) + return m.Service.NewReportingPlugin(ctx, config) } diff --git a/pkg/loop/mercury_service.go b/pkg/loop/mercury_service.go index 38672444f..f3eca6e06 100644 --- a/pkg/loop/mercury_service.go +++ b/pkg/loop/mercury_service.go @@ -18,14 +18,14 @@ import ( var _ ocr3types.MercuryPluginFactory = (*MercuryV4Service)(nil) -// MercuryV3Service is a [types.Service] that maintains an internal [types.PluginMedian]. +// MercuryV4Service is a [types.Service] that maintains an internal [types.PluginMedian]. type MercuryV4Service struct { goplugin.PluginService[*GRPCPluginMercury, types.MercuryPluginFactory] } var _ ocr3types.MercuryPluginFactory = (*MercuryV4Service)(nil) -// NewMercuryV3Service returns a new [*MercuryV3Service]. +// NewMercuryV4Service returns a new [*MercuryV4Service]. // cmd must return a new exec.Cmd each time it is called. func NewMercuryV4Service(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec.Cmd, provider types.MercuryProvider, dataSource mercury_v4_types.DataSource) *MercuryV4Service { newService := func(ctx context.Context, instance any) (types.MercuryPluginFactory, error) { @@ -43,11 +43,11 @@ func NewMercuryV4Service(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec return &ms } -func (m *MercuryV4Service) NewMercuryPlugin(config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { +func (m *MercuryV4Service) NewMercuryPlugin(ctx context.Context, config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { if err := m.Wait(); err != nil { return nil, ocr3types.MercuryPluginInfo{}, err } - return m.Service.NewMercuryPlugin(config) + return m.Service.NewMercuryPlugin(ctx, config) } var _ ocr3types.MercuryPluginFactory = (*MercuryV3Service)(nil) @@ -77,11 +77,11 @@ func NewMercuryV3Service(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec return &ms } -func (m *MercuryV3Service) NewMercuryPlugin(config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { +func (m *MercuryV3Service) NewMercuryPlugin(ctx context.Context, config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { if err := m.Wait(); err != nil { return nil, ocr3types.MercuryPluginInfo{}, err } - return m.Service.NewMercuryPlugin(config) + return m.Service.NewMercuryPlugin(ctx, config) } // MercuryV1Service is a [types.Service] that maintains an internal [types.PluginMedian]. @@ -109,11 +109,11 @@ func NewMercuryV1Service(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec return &ms } -func (m *MercuryV1Service) NewMercuryPlugin(config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { +func (m *MercuryV1Service) NewMercuryPlugin(ctx context.Context, config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { if err := m.Wait(); err != nil { return nil, ocr3types.MercuryPluginInfo{}, err } - return m.Service.NewMercuryPlugin(config) + return m.Service.NewMercuryPlugin(ctx, config) } var _ ocr3types.MercuryPluginFactory = (*MercuryV1Service)(nil) @@ -143,11 +143,11 @@ func NewMercuryV2Service(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec return &ms } -func (m *MercuryV2Service) NewMercuryPlugin(config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { +func (m *MercuryV2Service) NewMercuryPlugin(ctx context.Context, config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { if err := m.Wait(); err != nil { return nil, ocr3types.MercuryPluginInfo{}, err } - return m.Service.NewMercuryPlugin(config) + return m.Service.NewMercuryPlugin(ctx, config) } var _ ocr3types.MercuryPluginFactory = (*MercuryV2Service)(nil) diff --git a/pkg/loop/plugin_median_test.go b/pkg/loop/plugin_median_test.go index 2c31cecd8..90b617f51 100644 --- a/pkg/loop/plugin_median_test.go +++ b/pkg/loop/plugin_median_test.go @@ -1,7 +1,6 @@ package loop_test import ( - "context" "testing" "time" @@ -17,6 +16,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/services/servicetest" "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink-common/pkg/types/core" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" ) func TestPluginMedian(t *testing.T) { @@ -83,7 +83,7 @@ func newStopCh(t *testing.T) <-chan struct{} { } func newMedianProvider(t *testing.T, pr loop.PluginRelayer) types.MedianProvider { - ctx := context.Background() + ctx := tests.Context(t) r, err := pr.NewRelayer(ctx, test.ConfigTOML, keystoretest.Keystore, nil) require.NoError(t, err) servicetest.Run(t, r) diff --git a/pkg/loop/plugin_mercury_test.go b/pkg/loop/plugin_mercury_test.go index dba9a9da9..36af7c35f 100644 --- a/pkg/loop/plugin_mercury_test.go +++ b/pkg/loop/plugin_mercury_test.go @@ -1,7 +1,6 @@ package loop_test import ( - "context" "testing" "github.com/hashicorp/go-plugin" @@ -15,6 +14,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/test" "github.com/smartcontractkit/chainlink-common/pkg/services/servicetest" "github.com/smartcontractkit/chainlink-common/pkg/types" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" ) func TestPluginMercury(t *testing.T) { @@ -66,7 +66,7 @@ func TestPluginMercuryExec(t *testing.T) { } func newMercuryProvider(t *testing.T, pr loop.PluginRelayer) types.MercuryProvider { - ctx := context.Background() + ctx := tests.Context(t) r, err := pr.NewRelayer(ctx, test.ConfigTOML, keystoretest.Keystore, nil) require.NoError(t, err) servicetest.Run(t, r) diff --git a/pkg/loop/relayer_adapter.go b/pkg/loop/relayer_adapter.go deleted file mode 100644 index 490245e6f..000000000 --- a/pkg/loop/relayer_adapter.go +++ /dev/null @@ -1,6 +0,0 @@ -package loop - -import "github.com/smartcontractkit/chainlink-common/pkg/loop/adapters/relay" - -// TODO temporary alias to allow 2 step migration of solana and starknet repositories -type RelayerAdapter = relay.RelayerAdapter diff --git a/pkg/loop/reportingplugins/loopp_service.go b/pkg/loop/reportingplugins/loopp_service.go index 43381ecc0..92b7db4fd 100644 --- a/pkg/loop/reportingplugins/loopp_service.go +++ b/pkg/loop/reportingplugins/loopp_service.go @@ -59,11 +59,11 @@ func NewLOOPPService( return &ps } -func (g *LOOPPService) NewReportingPlugin(config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { +func (g *LOOPPService) NewReportingPlugin(ctx context.Context, config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { if err := g.Wait(); err != nil { return nil, ocrtypes.ReportingPluginInfo{}, err } - return g.Service.NewReportingPlugin(config) + return g.Service.NewReportingPlugin(ctx, config) } func NewLOOPPServiceValidation( diff --git a/pkg/loop/reportingplugins/ocr3/loopp_service.go b/pkg/loop/reportingplugins/ocr3/loopp_service.go index bf862e7b5..7f3a088df 100644 --- a/pkg/loop/reportingplugins/ocr3/loopp_service.go +++ b/pkg/loop/reportingplugins/ocr3/loopp_service.go @@ -51,11 +51,11 @@ func NewLOOPPService( return &ps } -func (g *LOOPPService) NewReportingPlugin(config ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[[]byte], ocr3types.ReportingPluginInfo, error) { +func (g *LOOPPService) NewReportingPlugin(ctx context.Context, config ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[[]byte], ocr3types.ReportingPluginInfo, error) { if err := g.Wait(); err != nil { return nil, ocr3types.ReportingPluginInfo{}, err } - return g.Service.NewReportingPlugin(config) + return g.Service.NewReportingPlugin(ctx, config) } func NewLOOPPServiceValidation( diff --git a/pkg/loop/standard_capabilities_test.go b/pkg/loop/standard_capabilities_test.go index 425722dd6..b9d63c01e 100644 --- a/pkg/loop/standard_capabilities_test.go +++ b/pkg/loop/standard_capabilities_test.go @@ -1,7 +1,6 @@ package loop_test import ( - "context" "testing" "github.com/hashicorp/go-plugin" @@ -13,6 +12,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/loop" sctest "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/core/services/capability/standard/test" "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/test" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" ) func TestPluginStandardCapabilities(t *testing.T) { @@ -29,30 +29,32 @@ func TestPluginStandardCapabilities(t *testing.T) { Logger: logger.Test(t), StopCh: stopCh}}, func(t *testing.T, s loop.StandardCapabilities) { - infos, err := s.Infos(context.Background()) + ctx := tests.Context(t) + infos, err := s.Infos(ctx) assert.NoError(t, err) assert.Equal(t, 2, len(infos)) assert.Equal(t, capabilities.CapabilityTypeAction, infos[0].CapabilityType) assert.Equal(t, capabilities.CapabilityTypeTarget, infos[1].CapabilityType) - err = s.Initialise(context.Background(), "", nil, nil, nil, nil, nil, nil, nil) + err = s.Initialise(ctx, "", nil, nil, nil, nil, nil, nil, nil) assert.NoError(t, err) }) } func TestRunningStandardCapabilitiesPluginOutOfProcess(t *testing.T) { t.Parallel() + ctx := tests.Context(t) stopCh := newStopCh(t) scs := newOutOfProcessStandardCapabilitiesService(t, true, stopCh) - infos, err := scs.Infos(context.Background()) + infos, err := scs.Infos(ctx) assert.NoError(t, err) assert.Equal(t, 2, len(infos)) assert.Equal(t, capabilities.CapabilityTypeAction, infos[0].CapabilityType) assert.Equal(t, capabilities.CapabilityTypeTarget, infos[1].CapabilityType) - err = scs.Initialise(context.Background(), "", nil, nil, nil, nil, nil, nil, nil) + err = scs.Initialise(ctx, "", nil, nil, nil, nil, nil, nil, nil) assert.NoError(t, err) } diff --git a/pkg/monitoring/testutils.go b/pkg/monitoring/testutils.go index 96ee0267e..5b8325d90 100644 --- a/pkg/monitoring/testutils.go +++ b/pkg/monitoring/testutils.go @@ -430,7 +430,7 @@ func generateContractConfig(ctx context.Context, n int) ( Min: generateBigInt(128), Max: generateBigInt(128), } - onchainConfigEncoded, err := median.StandardOnchainConfigCodec{}.Encode(onchainConfig) + onchainConfigEncoded, err := median.StandardOnchainConfigCodec{}.Encode(ctx, onchainConfig) if err != nil { return types.ContractConfig{}, median.OnchainConfig{}, nil, nil, err } diff --git a/pkg/types/ccip/gaspriceestimator.go b/pkg/types/ccip/gaspriceestimator.go index aafc46bc0..902547308 100644 --- a/pkg/types/ccip/gaspriceestimator.go +++ b/pkg/types/ccip/gaspriceestimator.go @@ -17,7 +17,7 @@ type GasPriceEstimatorCommit interface { // TODO CCIP-1882: reconcile gas price estimator to remove unnecessary interface funcs // this can be a helper function implementation detail. not needed in the interface // Deviates checks if p1 gas price diffs from p2 by deviation options. Input prices should not be nil. - Deviates(p1 *big.Int, p2 *big.Int) (bool, error) + Deviates(ctx context.Context, p1 *big.Int, p2 *big.Int) (bool, error) } // GasPriceEstimatorExec provides gasPriceEstimatorCommon + features needed in exec plugin, e.g. message cost estimation. @@ -25,7 +25,7 @@ type GasPriceEstimatorExec interface { CommonGasPriceEstimator // EstimateMsgCostUSD estimates the costs for msg execution, and converts to USD value scaled by 1e18 (e.g. 5$ = 5e18). - EstimateMsgCostUSD(p *big.Int, wrappedNativePrice *big.Int, msg EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error) + EstimateMsgCostUSD(ctx context.Context, p *big.Int, wrappedNativePrice *big.Int, msg EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error) } // CommonGasPriceEstimator is abstraction over multi-component gas prices. @@ -34,11 +34,11 @@ type CommonGasPriceEstimator interface { // GetGasPrice fetches the current gas price. GetGasPrice(ctx context.Context) (*big.Int, error) // DenoteInUSD converts the gas price to be in units of USD. Input prices should not be nil. - DenoteInUSD(p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error) + DenoteInUSD(ctx context.Context, p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error) // TODO CCIP-1882: reconcile gas price estimator to remove unnecessary interface funcs // this can be a helper function implementation detail. not needed in the interface // Median finds the median gas price in slice. If gas price has multiple components, median of each individual component should be taken. Input prices should not contain nil. - Median(gasPrices []*big.Int) (*big.Int, error) + Median(ctx context.Context, gasPrices []*big.Int) (*big.Int, error) } // EVM2EVMOnRampCCIPSendRequestedWithMeta helper struct to hold the send request and some metadata diff --git a/pkg/types/mercury/types.go b/pkg/types/mercury/types.go index 8f0d05734..fa679d1e9 100644 --- a/pkg/types/mercury/types.go +++ b/pkg/types/mercury/types.go @@ -19,8 +19,8 @@ type OnchainConfig struct { } type OnchainConfigCodec interface { - Encode(OnchainConfig) ([]byte, error) - Decode([]byte) (OnchainConfig, error) + Encode(context.Context, OnchainConfig) ([]byte, error) + Decode(context.Context, []byte) (OnchainConfig, error) } type ServerFetcher interface { diff --git a/pkg/types/mercury/v1/types.go b/pkg/types/mercury/v1/types.go index c15efd9b5..1fc3b52ec 100644 --- a/pkg/types/mercury/v1/types.go +++ b/pkg/types/mercury/v1/types.go @@ -67,14 +67,14 @@ type ReportCodec interface { // ParsedAttributedObservation per observer, and that all observers are // valid. However, observation values, timestamps, etc... should all be // treated as untrusted. - BuildReport(fields ReportFields) (ocrtypes.Report, error) + BuildReport(ctx context.Context, fields ReportFields) (ocrtypes.Report, error) // MaxReportLength Returns the maximum length of a report based on n, the number of oracles. // The output of BuildReport must respect this maximum length. - MaxReportLength(n int) (int, error) + MaxReportLength(ctx context.Context, n int) (int, error) // CurrentBlockNumFromReport returns the median current block number from a report - CurrentBlockNumFromReport(ocrtypes.Report) (int64, error) + CurrentBlockNumFromReport(context.Context, ocrtypes.Report) (int64, error) } // DataSource implementations must be thread-safe. Observe may be called by many diff --git a/pkg/types/mercury/v2/types.go b/pkg/types/mercury/v2/types.go index 2cecacb23..e57920c90 100644 --- a/pkg/types/mercury/v2/types.go +++ b/pkg/types/mercury/v2/types.go @@ -25,13 +25,13 @@ type ReportCodec interface { // ParsedAttributedObservation per observer, and that all observers are // valid. However, observation values, timestamps, etc... should all be // treated as untrusted. - BuildReport(ReportFields) (ocrtypes.Report, error) + BuildReport(context.Context, ReportFields) (ocrtypes.Report, error) // MaxReportLength Returns the maximum length of a report based on n, the number of oracles. // The output of BuildReport must respect this maximum length. - MaxReportLength(n int) (int, error) + MaxReportLength(ctx context.Context, n int) (int, error) - ObservationTimestampFromReport(ocrtypes.Report) (uint32, error) + ObservationTimestampFromReport(context.Context, ocrtypes.Report) (uint32, error) } // DataSource implementations must be thread-safe. Observe may be called by many diff --git a/pkg/types/mercury/v3/types.go b/pkg/types/mercury/v3/types.go index 713cbda1a..0d4eefdcd 100644 --- a/pkg/types/mercury/v3/types.go +++ b/pkg/types/mercury/v3/types.go @@ -27,13 +27,13 @@ type ReportCodec interface { // ParsedAttributedObservation per observer, and that all observers are // valid. However, observation values, timestamps, etc... should all be // treated as untrusted. - BuildReport(ReportFields) (ocrtypes.Report, error) + BuildReport(context.Context, ReportFields) (ocrtypes.Report, error) // MaxReportLength Returns the maximum length of a report based on n, the number of oracles. // The output of BuildReport must respect this maximum length. - MaxReportLength(n int) (int, error) + MaxReportLength(ctx context.Context, n int) (int, error) - ObservationTimestampFromReport(ocrtypes.Report) (uint32, error) + ObservationTimestampFromReport(context.Context, ocrtypes.Report) (uint32, error) } // DataSource implementations must be thread-safe. Observe may be called by many diff --git a/pkg/types/mercury/v4/types.go b/pkg/types/mercury/v4/types.go index 5f4380b7b..d26272af5 100644 --- a/pkg/types/mercury/v4/types.go +++ b/pkg/types/mercury/v4/types.go @@ -26,13 +26,13 @@ type ReportCodec interface { // ParsedAttributedObservation per observer, and that all observers are // valid. However, observation values, timestamps, etc... should all be // treated as untrusted. - BuildReport(ReportFields) (ocrtypes.Report, error) + BuildReport(context.Context, ReportFields) (ocrtypes.Report, error) // MaxReportLength Returns the maximum length of a report based on n, the number of oracles. // The output of BuildReport must respect this maximum length. - MaxReportLength(n int) (int, error) + MaxReportLength(ctx context.Context, n int) (int, error) - ObservationTimestampFromReport(ocrtypes.Report) (uint32, error) + ObservationTimestampFromReport(context.Context, ocrtypes.Report) (uint32, error) } // DataSource implementations must be thread-safe. Observe may be called by many diff --git a/pkg/types/relayer.go b/pkg/types/relayer.go index cfcb0da09..5e43daa03 100644 --- a/pkg/types/relayer.go +++ b/pkg/types/relayer.go @@ -77,7 +77,7 @@ type NodeStatus struct { State string } -// ChainService is a sub-interface of [loop.Relayer] that encapsulates the explicit interactions with a chain +// ChainService is a sub-interface that encapsulates the explicit interactions with a chain, rather than through a provider. type ChainService interface { Service @@ -92,11 +92,9 @@ type ChainService interface { Transact(ctx context.Context, from, to string, amount *big.Int, balanceCheck bool) error } -// Relayer is the product-facing, and context-less sub-interface of [loop.Relayer]. -// -// Deprecated: use loop.Relayer, which includes context.Context. +// Relayer extends ChainService with providers for each product. type Relayer interface { - Service + ChainService // NewChainWriter returns a new ChainWriter. // The format of config depends on the implementation. @@ -104,19 +102,19 @@ type Relayer interface { // NewContractReader returns a new ContractReader. // The format of contractReaderConfig depends on the implementation. - NewContractReader(contractReaderConfig []byte) (ContractReader, error) + NewContractReader(ctx context.Context, contractReaderConfig []byte) (ContractReader, error) - NewConfigProvider(rargs RelayArgs) (ConfigProvider, error) + NewConfigProvider(ctx context.Context, rargs RelayArgs) (ConfigProvider, error) - NewMedianProvider(rargs RelayArgs, pargs PluginArgs) (MedianProvider, error) - NewMercuryProvider(rargs RelayArgs, pargs PluginArgs) (MercuryProvider, error) - NewFunctionsProvider(rargs RelayArgs, pargs PluginArgs) (FunctionsProvider, error) - NewAutomationProvider(rargs RelayArgs, pargs PluginArgs) (AutomationProvider, error) - NewLLOProvider(rargs RelayArgs, pargs PluginArgs) (LLOProvider, error) - NewCCIPCommitProvider(rargs RelayArgs, pargs PluginArgs) (CCIPCommitProvider, error) - NewCCIPExecProvider(rargs RelayArgs, pargs PluginArgs) (CCIPExecProvider, error) + NewMedianProvider(ctx context.Context, rargs RelayArgs, pargs PluginArgs) (MedianProvider, error) + NewMercuryProvider(ctx context.Context, rargs RelayArgs, pargs PluginArgs) (MercuryProvider, error) + NewFunctionsProvider(ctx context.Context, rargs RelayArgs, pargs PluginArgs) (FunctionsProvider, error) + NewAutomationProvider(ctx context.Context, rargs RelayArgs, pargs PluginArgs) (AutomationProvider, error) + NewLLOProvider(ctx context.Context, rargs RelayArgs, pargs PluginArgs) (LLOProvider, error) + NewCCIPCommitProvider(ctx context.Context, rargs RelayArgs, pargs PluginArgs) (CCIPCommitProvider, error) + NewCCIPExecProvider(ctx context.Context, rargs RelayArgs, pargs PluginArgs) (CCIPExecProvider, error) - NewPluginProvider(rargs RelayArgs, pargs PluginArgs) (PluginProvider, error) + NewPluginProvider(ctx context.Context, rargs RelayArgs, pargs PluginArgs) (PluginProvider, error) - NewOCR3CapabilityProvider(rargs RelayArgs, pargs PluginArgs) (OCR3CapabilityProvider, error) + NewOCR3CapabilityProvider(ctx context.Context, rargs RelayArgs, pargs PluginArgs) (OCR3CapabilityProvider, error) } From 46370848a78919a4974f33871de164a93c49e772 Mon Sep 17 00:00:00 2001 From: Bolek <1416262+bolekk@users.noreply.github.com> Date: Thu, 10 Oct 2024 07:37:02 -0700 Subject: [PATCH 2/9] [CM-380] Identical Aggregator (#771) * [CM-380] Identical Aggregator * [CAPPL-60] Dynamic encoder selection in OCR consensus aggregator * extract encoder name and config * Add more tests * add limit to seq num range (#781) * [chore] Handle aliases in slices (#784) * [chore] Handle aliases in slices * More aliasing tests * Lint fix * Fix test --------- Co-authored-by: Sri Kidambi <1702865+kidambisrinivas@users.noreply.github.com> * feat(observability-lib): legendoptions + improvement on node general dashboard (#785) * [CAPPL-58] Correctly stub out clock_time_get and poll_oneoff (#778) * [CAPPL-58] Further cleanup * [CAPPL-58] Add support for compression * More alias handling in Unwrap functionality of Value (#792) * 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 * Fix alias typing and tests (#788) * Fix alias typing and tests * Fix ints * errors.new instead of fmt * Add array support to slice (#789) * Replace fmt.Errorf with errors.New where possible (#795) * chore(workflows): adds unit test to utils (#782) * Have the mock runner register with capabilites (#783) * Add binary + config to custom compute (#794) * Add binary + config to custom compute * Add binary + config to custom compute * fix lint issues (#786) * execution factory constructor updated to take two providers, chainIDs, and source token address (#641) * execution factory constructor updated to take two providers and chain IDs (cherry picked from commit 6ad1f08d26810df5eaeed76a0f74e20be1908658) * Adding source token address to execution factory constructor * Support passing in a values.Value to the chainreader GetLatestValue method (#779) * add support for passing in a values.Value type to the contract readers GetLatestValue and QueryKey methods --------- Co-authored-by: Sri Kidambi <1702865+kidambisrinivas@users.noreply.github.com> Co-authored-by: Cedric Cordenier * [CAPPL-31] feat(values): adds support for time.Time as value (#787) * feat(values): adds support for time.Time as value * chore(deps): updates .tool-versions * refactor(values): uses primitive type in protos * feat(values): support float64 values (#799) * confidence level from string (#802) * Float32/Float64 wrapping (#804) * feat: implement sdk logger (#762) * Add MustEmbed Constraint to Contract Reader (#801) Reintroducing the must embed constraint to `ContractReader` implementations to ensure that all implementations of `ContractReader` embed the `UnimplementedContractReader`. If an implementation contains the unemplemented struct, changes to the interface will flow down to all implementations without introducing breaking changes. * Updated TestStruct to enable advanced querying (#798) * Updated TestStruct to enable advanced querying * linting fixes * Update pkg/codec/encodings/type_codec_test.go Co-authored-by: Clement * Update pkg/codec/encodings/type_codec_test.go Co-authored-by: Clement * Fixed codec tests --------- Co-authored-by: Clement * Properly support the range of uint64 and allow big int to unwrap into smaller integer types (#810) * Extract expirable cache abstraction for reuse (#807) * expirable_cache * remove cache (#812) * CCIP-3555 Attestation encoder interfaces (#813) * Attestation encoder interfaces * Attestation encoder interfaces * Attestation encoder interfaces * Comment * [BCF-3392] - ContractReaderByIDs Wrapper (#797) * WIP * Update ContractReaderByIDs interface method names * Unexpose types.ContractReader in contractReaderByIDs * Add multiple contract address support to fakeContractReader for tests * Add GetLatestValue unit test for contractReaderByIDs * Add GetLatestValue unit test for QueryKey * Add BatchGetLatestValues unit test for CR by custom IdDs wrapper * Rm ContractReaderByIDs interface and export the struct * Change ContractReaderByIDs wrapper Unbind handling * Improve ContractReaderByIDs wrapper err handling * Remove mockery usage from ContractReaderByIDs tests * lint * pkg/types/ccipocr3: add DestExecData to RampTokenAmount (#817) * pkg/types/ccipocr3: add DestExecData to RampTokenAmount * fix test * Allow the creation of maps from string to capbility outputs. (#815) * Add the FeeValueJuels field to ccipocr3.Message (#819) * feat(observability-lib): improve alerts rule (#803) * feat(observability-lib): improve alerts rule * chore(observability-lib): README + folder structure (#806) * chore(observability-lib): README + folder structure * feat(observability-lib): variable add current + includeAll options (#808) * chore(README): small corrections * chore(README): example improved * chore(README): add references to dashboards examples * feat(observability-lib): refactor exportable func + link to godoc * fix(observability-lib): cmd errors returns * enable errorf check (#826) * Make overridding the encoder first-class * Update mocks * Mock updates * Adjust tests * Fix mock * Fix mock * Update mock * Linting --------- Co-authored-by: Cedric Cordenier Co-authored-by: dimitris Co-authored-by: Sri Kidambi <1702865+kidambisrinivas@users.noreply.github.com> Co-authored-by: Clement Co-authored-by: Ryan Tinianov Co-authored-by: Street <5597260+MStreet3@users.noreply.github.com> Co-authored-by: Jordan Krage Co-authored-by: Patrick Co-authored-by: Matthew Pendrey Co-authored-by: Gabriel Paradiso Co-authored-by: Awbrey Hughlett Co-authored-by: Silas Lenihan <32529249+silaslenihan@users.noreply.github.com> Co-authored-by: Mateusz Sekara Co-authored-by: ilija42 <57732589+ilija42@users.noreply.github.com> Co-authored-by: Makram Co-authored-by: Ryan Stout --- .../consensus/ocr3/aggregators/identical.go | 125 ++++++++++++++ .../ocr3/aggregators/identical_test.go | 93 ++++++++++ pkg/capabilities/consensus/ocr3/capability.go | 2 + pkg/capabilities/consensus/ocr3/models.go | 4 +- .../ocr3/ocr3cap/identical_consensus.go | 12 +- .../ocr3/ocr3cap/identical_consensus_test.go | 16 +- .../ocr3captest/identical_consensus.go | 20 +-- .../ocr3/ocr3cap/ocr3captest/observations.go | 4 - .../consensus/ocr3/reporting_plugin.go | 82 +++++++++ .../consensus/ocr3/reporting_plugin_test.go | 161 +++++++++++++++++- .../consensus/ocr3/requests/request.go | 10 +- .../testdata/fixtures/capability/schema.json | 15 ++ .../consensus/ocr3/types/ocr3_types.pb.go | 143 +++++++++------- .../consensus/ocr3/types/ocr3_types.proto | 2 + pkg/workflows/sdk/testutils/runner.go | 11 -- pkg/workflows/sdk/testutils/runner_test.go | 6 +- 16 files changed, 595 insertions(+), 111 deletions(-) create mode 100644 pkg/capabilities/consensus/ocr3/aggregators/identical.go create mode 100644 pkg/capabilities/consensus/ocr3/aggregators/identical_test.go diff --git a/pkg/capabilities/consensus/ocr3/aggregators/identical.go b/pkg/capabilities/consensus/ocr3/aggregators/identical.go new file mode 100644 index 000000000..a50448bc3 --- /dev/null +++ b/pkg/capabilities/consensus/ocr3/aggregators/identical.go @@ -0,0 +1,125 @@ +package aggregators + +import ( + "crypto/sha256" + "fmt" + + "google.golang.org/protobuf/proto" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3/types" + "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink-common/pkg/values" + + ocrcommon "github.com/smartcontractkit/libocr/commontypes" +) + +type identicalAggregator struct { + config aggregatorConfig + lggr logger.Logger +} + +type aggregatorConfig struct { + // Length of the list of observations that each node is expected to provide. + // Aggregator's output (i.e. EncodableOutcome) will be a values.Map with the same + // number of elements and keyed by indices 0,1,2,... (unless KeyOverrides are provided). + // Defaults to 1. + ExpectedObservationsLen int + // If non-empty, the keys in the outcome map will be replaced with these values. + // If non-empty, must be of length ExpectedObservationsLen. + KeyOverrides []string +} + +type counter struct { + fullObservation values.Value + count int +} + +var _ types.Aggregator = (*identicalAggregator)(nil) + +func (a *identicalAggregator) Aggregate(_ *types.AggregationOutcome, observations map[ocrcommon.OracleID][]values.Value, f int) (*types.AggregationOutcome, error) { + counters := []map[[32]byte]*counter{} + for i := 0; i < a.config.ExpectedObservationsLen; i++ { + counters = append(counters, map[[32]byte]*counter{}) + } + for nodeID, nodeObservations := range observations { + if len(nodeObservations) == 0 || nodeObservations[0] == nil { + a.lggr.Warnf("node %d contributed with empty observations", nodeID) + continue + } + if len(nodeObservations) != a.config.ExpectedObservationsLen { + a.lggr.Warnf("node %d contributed with an incorrect number of observations %d - ignoring them", nodeID, len(nodeObservations)) + continue + } + for idx, observation := range nodeObservations { + marshalled, err := proto.MarshalOptions{Deterministic: true}.Marshal(values.Proto(observation)) + if err != nil { + return nil, err + } + sha := sha256.Sum256(marshalled) + elem, ok := counters[idx][sha] + if !ok { + counters[idx][sha] = &counter{ + fullObservation: observation, + count: 1, + } + } else { + elem.count++ + } + } + } + return a.collectHighestCounts(counters, f) +} + +func (a *identicalAggregator) collectHighestCounts(counters []map[[32]byte]*counter, f int) (*types.AggregationOutcome, error) { + useOverrides := len(a.config.KeyOverrides) == len(counters) + outcome := make(map[string]any) + for idx, shaToCounter := range counters { + highestCount := 0 + var highestObservation values.Value + for _, counter := range shaToCounter { + if counter.count > highestCount { + highestCount = counter.count + highestObservation = counter.fullObservation + } + } + if highestCount < 2*f+1 { + return nil, fmt.Errorf("can't reach consensus on observations with index %d", idx) + } + if useOverrides { + outcome[a.config.KeyOverrides[idx]] = highestObservation + } else { + outcome[fmt.Sprintf("%d", idx)] = highestObservation + } + } + valMap, err := values.NewMap(outcome) + if err != nil { + return nil, err + } + return &types.AggregationOutcome{ + EncodableOutcome: values.ProtoMap(valMap), + Metadata: nil, + ShouldReport: true, + }, nil +} + +func NewIdenticalAggregator(config values.Map, lggr logger.Logger) (*identicalAggregator, error) { + parsedConfig, err := ParseConfig(config) + if err != nil { + return nil, fmt.Errorf("failed to parse config (%+v): %w", config, err) + } + return &identicalAggregator{ + config: parsedConfig, + lggr: lggr, + }, nil +} + +func ParseConfig(config values.Map) (aggregatorConfig, error) { + parsedConfig := aggregatorConfig{} + if err := config.UnwrapTo(&parsedConfig); err != nil { + return aggregatorConfig{}, err + } + if parsedConfig.ExpectedObservationsLen == 0 { + parsedConfig.ExpectedObservationsLen = 1 + } + return parsedConfig, nil +} diff --git a/pkg/capabilities/consensus/ocr3/aggregators/identical_test.go b/pkg/capabilities/consensus/ocr3/aggregators/identical_test.go new file mode 100644 index 000000000..aaa146b44 --- /dev/null +++ b/pkg/capabilities/consensus/ocr3/aggregators/identical_test.go @@ -0,0 +1,93 @@ +package aggregators_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/libocr/commontypes" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3/aggregators" + "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink-common/pkg/values" +) + +func TestDataFeedsAggregator_Aggregate(t *testing.T) { + config := getConfig(t, nil) + agg, err := aggregators.NewIdenticalAggregator(*config, logger.Nop()) + require.NoError(t, err) + + observations := map[commontypes.OracleID][]values.Value{ + 0: {values.NewString("a")}, + 1: {values.NewString("a")}, + 2: {values.NewString("a")}, + 3: {values.NewString("a")}, + } + outcome, err := agg.Aggregate(nil, observations, 1) + require.NoError(t, err) + require.True(t, outcome.ShouldReport) + require.Equal(t, "", outcome.EncoderName) + require.Nil(t, outcome.EncoderConfig) + + m, err := values.FromMapValueProto(outcome.EncodableOutcome) + require.NoError(t, err) + + require.Len(t, m.Underlying, 1) + require.Equal(t, m.Underlying["0"], values.NewString("a")) +} + +func TestDataFeedsAggregator_Aggregate_OverrideWithKeys(t *testing.T) { + config := getConfig(t, []string{"outcome"}) + agg, err := aggregators.NewIdenticalAggregator(*config, logger.Nop()) + require.NoError(t, err) + + observations := map[commontypes.OracleID][]values.Value{ + 0: {values.NewString("a")}, + 1: {values.NewString("a")}, + 2: {values.NewString("a")}, + 3: {values.NewString("a")}, + } + outcome, err := agg.Aggregate(nil, observations, 1) + require.NoError(t, err) + require.True(t, outcome.ShouldReport) + require.Equal(t, "", outcome.EncoderName) + require.Nil(t, outcome.EncoderConfig) + + m, err := values.FromMapValueProto(outcome.EncodableOutcome) + require.NoError(t, err) + + require.Len(t, m.Underlying, 1) + require.Equal(t, m.Underlying["outcome"], values.NewString("a")) +} + +func TestDataFeedsAggregator_Aggregate_NoConsensus(t *testing.T) { + config := getConfig(t, []string{"outcome"}) + agg, err := aggregators.NewIdenticalAggregator(*config, logger.Nop()) + require.NoError(t, err) + + encoderStr := "evm" + encoderName := values.NewString(encoderStr) + encoderCfg, err := values.NewMap(map[string]any{"foo": "bar"}) + require.NoError(t, err) + + observations := map[commontypes.OracleID][]values.Value{ + 0: {values.NewString("a"), encoderName, encoderCfg}, + 1: {values.NewString("b"), encoderName, encoderCfg}, + 2: {values.NewString("b"), encoderName, encoderCfg}, + 3: {values.NewString("a"), encoderName, encoderCfg}, + } + outcome, err := agg.Aggregate(nil, observations, 1) + require.Nil(t, outcome) + require.ErrorContains(t, err, "can't reach consensus on observations with index 0") +} + +func getConfig(t *testing.T, overrideKeys []string) *values.Map { + unwrappedConfig := map[string]any{ + "expectedObservationsLen": len(overrideKeys), + "keyOverrides": overrideKeys, + } + + config, err := values.NewMap(unwrappedConfig) + require.NoError(t, err) + return config +} diff --git a/pkg/capabilities/consensus/ocr3/capability.go b/pkg/capabilities/consensus/ocr3/capability.go index 3255fb19c..6c4c8f1a8 100644 --- a/pkg/capabilities/consensus/ocr3/capability.go +++ b/pkg/capabilities/consensus/ocr3/capability.go @@ -282,6 +282,8 @@ func (o *capability) queueRequestForProcessing( WorkflowDonID: metadata.WorkflowDonID, WorkflowDonConfigVersion: metadata.WorkflowDonConfigVersion, Observations: i.Observations, + OverriddenEncoderName: i.EncoderName, + OverriddenEncoderConfig: i.EncoderConfig, KeyID: c.KeyID, ExpiresAt: o.clock.Now().Add(requestTimeout), } diff --git a/pkg/capabilities/consensus/ocr3/models.go b/pkg/capabilities/consensus/ocr3/models.go index e03a68a72..86662dc31 100644 --- a/pkg/capabilities/consensus/ocr3/models.go +++ b/pkg/capabilities/consensus/ocr3/models.go @@ -16,5 +16,7 @@ type config struct { } type inputs struct { - Observations *values.List `json:"observations"` + Observations *values.List `json:"observations" jsonschema:""` + EncoderName string `mapstructure:"encoder" json:"encoder,omitempty"` + EncoderConfig *values.Map `mapstructure:"encoder_config" json:"encoder_config,omitempty"` } diff --git a/pkg/capabilities/consensus/ocr3/ocr3cap/identical_consensus.go b/pkg/capabilities/consensus/ocr3/ocr3cap/identical_consensus.go index dfa7ffe48..12913126c 100644 --- a/pkg/capabilities/consensus/ocr3/ocr3cap/identical_consensus.go +++ b/pkg/capabilities/consensus/ocr3/ocr3cap/identical_consensus.go @@ -32,17 +32,17 @@ func (c IdenticalConsensusConfig[T]) New(w *sdk.WorkflowSpecFactory, ref string, } type IdenticalConsensusInput[T any] struct { - Observations sdk.CapDefinition[T] -} - -type IdenticalConsensusMergedInput[T any] struct { - Observations []T + Observation sdk.CapDefinition[T] + Encoder Encoder + EncoderConfig EncoderConfig } func (input IdenticalConsensusInput[T]) ToSteps() sdk.StepInputs { return sdk.StepInputs{ Mapping: map[string]any{ - "observations": input.Observations.Ref(), + "observations": sdk.ListOf(input.Observation).Ref(), + "encoder": input.Encoder, + "encoderConfig": input.EncoderConfig, }, } } diff --git a/pkg/capabilities/consensus/ocr3/ocr3cap/identical_consensus_test.go b/pkg/capabilities/consensus/ocr3/ocr3cap/identical_consensus_test.go index 89dc0df73..2affbeab7 100644 --- a/pkg/capabilities/consensus/ocr3/ocr3cap/identical_consensus_test.go +++ b/pkg/capabilities/consensus/ocr3/ocr3cap/identical_consensus_test.go @@ -26,7 +26,11 @@ func TestIdenticalConsensus(t *testing.T) { Encoder: ocr3.EncoderEVM, EncoderConfig: ocr3.EncoderConfig{}, ReportID: "0001", - }.New(workflow, "consensus", ocr3.IdenticalConsensusInput[basictrigger.TriggerOutputs]{Observations: trigger}) + }.New(workflow, "consensus", ocr3.IdenticalConsensusInput[basictrigger.TriggerOutputs]{ + Observation: trigger, + Encoder: "evm", + EncoderConfig: ocr3.EncoderConfig(map[string]any{"foo": "bar"}), + }) chainwriter.TargetConfig{ Address: "0x1235", @@ -55,9 +59,13 @@ func TestIdenticalConsensus(t *testing.T) { Actions: []sdk.StepDefinition{}, Consensus: []sdk.StepDefinition{ { - ID: "offchain_reporting@1.0.0", - Ref: "consensus", - Inputs: sdk.StepInputs{Mapping: map[string]any{"observations": "$(trigger.outputs)"}}, + ID: "offchain_reporting@1.0.0", + Ref: "consensus", + Inputs: sdk.StepInputs{Mapping: map[string]any{ + "observations": []any{"$(trigger.outputs)"}, + "encoder": "evm", + "encoderConfig": map[string]any{"foo": "bar"}, + }}, Config: map[string]any{ "encoder": "EVM", "encoder_config": map[string]any{}, diff --git a/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3captest/identical_consensus.go b/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3captest/identical_consensus.go index 2c89e1bad..b5a3420c6 100644 --- a/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3captest/identical_consensus.go +++ b/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3captest/identical_consensus.go @@ -1,10 +1,9 @@ package ocr3captest import ( - "errors" - "google.golang.org/protobuf/proto" + "github.com/smartcontractkit/chainlink-common/pkg/capabilities" "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3/ocr3cap" "github.com/smartcontractkit/chainlink-common/pkg/values" "github.com/smartcontractkit/chainlink-common/pkg/values/pb" @@ -32,12 +31,6 @@ func IdenticalConsensusForStep[T any](runner *testutils.Runner, step string) *Id } func identicalConsensus[T any](inputs ConsensusInput[T]) (ocr3cap.SignedReport, error) { - if len(inputs.Observations) == 0 { - return ocr3cap.SignedReport{}, errors.New("no observations were made") - } else if len(inputs.Observations) > 1 { - return ocr3cap.SignedReport{}, errors.New("more than one observation was made, but this mock isn't set up to support that") - } - wrapped, err := values.Wrap(inputs.Observations[0]) if err != nil { return ocr3cap.SignedReport{}, err @@ -63,16 +56,7 @@ type IdenticalConsensusMock[T any] struct { *testutils.Mock[ConsensusInput[T], ocr3cap.SignedReport] } -var _ testutils.ConsensusMock = &IdenticalConsensusMock[struct{}]{} - -func (c *IdenticalConsensusMock[T]) SingleToManyObservations(input values.Value) (*values.Map, error) { - tmp := singleConsensusInput[T]{} - if err := input.UnwrapTo(&tmp); err != nil { - return nil, err - } - - return values.CreateMapFromStruct(ConsensusInput[T]{Observations: []T{tmp.Observations}}) -} +var _ capabilities.ConsensusCapability = &IdenticalConsensusMock[struct{}]{} func (c *IdenticalConsensusMock[T]) GetStepDecoded(ref string) testutils.StepResults[ConsensusInput[T], T] { step := c.GetStep(ref) diff --git a/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3captest/observations.go b/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3captest/observations.go index a106b5a44..a136d9cd9 100644 --- a/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3captest/observations.go +++ b/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3captest/observations.go @@ -3,7 +3,3 @@ package ocr3captest type ConsensusInput[T any] struct { Observations []T } - -type singleConsensusInput[T any] struct { - Observations T -} diff --git a/pkg/capabilities/consensus/ocr3/reporting_plugin.go b/pkg/capabilities/consensus/ocr3/reporting_plugin.go index 60b900fad..6010575de 100644 --- a/pkg/capabilities/consensus/ocr3/reporting_plugin.go +++ b/pkg/capabilities/consensus/ocr3/reporting_plugin.go @@ -4,6 +4,7 @@ import ( "context" "crypto/sha256" "encoding/hex" + "fmt" "slices" "time" @@ -22,6 +23,7 @@ import ( pbtypes "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3/types" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/values" + "github.com/smartcontractkit/chainlink-common/pkg/values/pb" ) var _ ocr3types.ReportingPlugin[[]byte] = (*reportingPlugin)(nil) @@ -126,6 +128,13 @@ func (r *reportingPlugin) Observation(ctx context.Context, outctx ocr3types.Outc lggr.Errorw("observations are not a list") continue } + + var cfgProto *pb.Map + if rq.OverriddenEncoderConfig != nil { + cp := values.Proto(rq.OverriddenEncoderConfig).GetMapValue() + cfgProto = cp + } + newOb := &pbtypes.Observation{ Observations: listProto, Id: &pbtypes.Id{ @@ -138,6 +147,8 @@ func (r *reportingPlugin) Observation(ctx context.Context, outctx ocr3types.Outc ReportId: rq.ReportID, KeyId: rq.KeyID, }, + OverriddenEncoderName: rq.OverriddenEncoderName, + OverriddenEncoderConfig: cfgProto, } obs.Observations = append(obs.Observations, newOb) @@ -158,12 +169,39 @@ func (r *reportingPlugin) ObservationQuorum(ctx context.Context, outctx ocr3type return quorumhelper.ObservationCountReachesObservationQuorum(quorumhelper.QuorumTwoFPlusOne, r.config.N, r.config.F, aos), nil } +func shaForOverriddenEncoder(obs *pbtypes.Observation) (string, error) { + hash := sha256.New() + _, err := hash.Write([]byte(obs.OverriddenEncoderName)) + if err != nil { + return "", fmt.Errorf("could not write encoder name to hash: %w", err) + } + + marshalled, err := proto.MarshalOptions{Deterministic: true}.Marshal(obs.OverriddenEncoderConfig) + if err != nil { + return "", fmt.Errorf("could not marshal overridden encoder: %w", err) + } + + _, err = hash.Write(marshalled) + if err != nil { + return "", fmt.Errorf("could not write encoder config to hash: %w", err) + } + + return string(hash.Sum([]byte{})), nil +} + +type encoderConfig struct { + name string + config *pb.Map +} + func (r *reportingPlugin) Outcome(ctx context.Context, outctx ocr3types.OutcomeContext, query types.Query, attributedObservations []types.AttributedObservation) (ocr3types.Outcome, error) { // execution ID -> oracle ID -> list of observations execIDToOracleObservations := map[string]map[ocrcommon.OracleID][]values.Value{} seenWorkflowIDs := map[string]int{} var sortedTimestamps []*timestamppb.Timestamp var finalTimestamp *timestamppb.Timestamp + execIDToEncoderShaToCount := map[string]map[string]int{} + shaToEncoder := map[string]encoderConfig{} for _, attributedObservation := range attributedObservations { obs := &pbtypes.Observations{} err := proto.Unmarshal(attributedObservation.Observation, obs) @@ -210,6 +248,21 @@ func (r *reportingPlugin) Outcome(ctx context.Context, outctx ocr3types.OutcomeC execIDToOracleObservations[weid] = make(map[ocrcommon.OracleID][]values.Value) } execIDToOracleObservations[weid][attributedObservation.Observer] = obsList.Underlying + + sha, err := shaForOverriddenEncoder(request) + if err != nil { + r.lggr.Errorw("could not calculate sha for overridden encoder", "error", err, "observation", obs) + continue + } + + shaToEncoder[sha] = encoderConfig{ + name: request.OverriddenEncoderName, + config: request.OverriddenEncoderConfig, + } + if _, ok := execIDToEncoderShaToCount[weid]; !ok { + execIDToEncoderShaToCount[weid] = map[string]int{} + } + execIDToEncoderShaToCount[weid][sha]++ } } @@ -298,6 +351,35 @@ func (r *reportingPlugin) Outcome(ctx context.Context, outctx ocr3types.OutcomeC outcome.Timestamp = finalTimestamp + shaToCount, ok := execIDToEncoderShaToCount[weid.WorkflowExecutionId] + if !ok { + lggr.Debugw("could not find any encoder shas matching weid requested in the query") + continue + } + + // Note: no need to check the observation count here, + // we've checked this above when we checked the observations count. + var encCfg *encoderConfig + for sha, count := range shaToCount { + if count >= 2*r.config.F+1 { + encoderCfg, ok := shaToEncoder[sha] + if !ok { + lggr.Debugw("could not find encoder matching sha") + continue + } + + lggr.Debugw("consensus reached on overridden encoder", "encoderName", encoderCfg.name) + encCfg = &encoderCfg + break + } + } + + if encCfg != nil { + lggr.Debugw("overridden encoder set", "name", encCfg.name, "cfg", encCfg.config) + outcome.EncoderName = encCfg.name + outcome.EncoderConfig = encCfg.config + } + report := &pbtypes.Report{ Outcome: outcome, Id: weid, diff --git a/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go b/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go index 04be58609..9b54d61db 100644 --- a/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go +++ b/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go @@ -784,11 +784,11 @@ func TestReportPlugin_Outcome_ShouldReturnMedianTimestamp(t *testing.T) { }, { Observation: rawObs2, - Observer: commontypes.OracleID(1), + Observer: commontypes.OracleID(2), }, { Observation: rawObs3, - Observer: commontypes.OracleID(1), + Observer: commontypes.OracleID(3), }, } @@ -800,3 +800,160 @@ func TestReportPlugin_Outcome_ShouldReturnMedianTimestamp(t *testing.T) { assert.Equal(t, timestamppb.New(time2), opb1.Outcomes[workflowTestID].Timestamp) } + +func TestReportPlugin_Outcome_ShouldReturnOverriddenEncoder(t *testing.T) { + lggr := logger.Test(t) + s := requests.NewStore() + mcap := &mockCapability{ + aggregator: &aggregator{}, + encoder: &enc{}, + registeredWorkflows: map[string]bool{ + workflowTestID: true, + workflowTestID2: true, + }, + } + rp, err := newReportingPlugin(s, mcap, defaultBatchSize, ocr3types.ReportingPluginConfig{F: 1}, defaultOutcomePruningThreshold, lggr) + require.NoError(t, err) + + wowner := uuid.New().String() + id := &pbtypes.Id{ + WorkflowExecutionId: uuid.New().String(), + WorkflowId: workflowTestID, + WorkflowOwner: wowner, + WorkflowName: workflowTestName, + ReportId: reportTestID, + } + id2 := &pbtypes.Id{ + WorkflowExecutionId: uuid.New().String(), + WorkflowId: workflowTestID2, + WorkflowOwner: wowner, + WorkflowName: workflowTestName, + ReportId: reportTestID, + } + id3 := &pbtypes.Id{ + WorkflowExecutionId: uuid.New().String(), + WorkflowId: workflowTestID3, + WorkflowOwner: wowner, + WorkflowName: workflowTestName, + ReportId: reportTestID, + } + q := &pbtypes.Query{ + Ids: []*pbtypes.Id{id, id2, id3}, + } + qb, err := proto.Marshal(q) + require.NoError(t, err) + o, err := values.NewList([]any{"hello"}) + require.NoError(t, err) + time1 := time.Now().Add(time.Second * 1) + time2 := time.Now().Add(time.Second * 2) + time3 := time.Now().Add(time.Second * 3) + m, err := values.NewMap(map[string]any{"foo": "bar"}) + require.NoError(t, err) + mc := values.ProtoMap(m) + obs := &pbtypes.Observations{ + Observations: []*pbtypes.Observation{ + { + Id: id, + Observations: values.Proto(o).GetListValue(), + OverriddenEncoderName: "evm", + OverriddenEncoderConfig: mc, + }, + { + Id: id2, + Observations: values.Proto(o).GetListValue(), + OverriddenEncoderName: "evm", + OverriddenEncoderConfig: mc, + }, + { + Id: id3, + Observations: values.Proto(o).GetListValue(), + }, + }, + RegisteredWorkflowIds: []string{workflowTestID, workflowTestID2}, + Timestamp: timestamppb.New(time1), + } + obs2 := &pbtypes.Observations{ + Observations: []*pbtypes.Observation{ + { + Id: id, + Observations: values.Proto(o).GetListValue(), + OverriddenEncoderName: "evm", + OverriddenEncoderConfig: mc, + }, + { + Id: id2, + Observations: values.Proto(o).GetListValue(), + OverriddenEncoderName: "evm", + OverriddenEncoderConfig: mc, + }, + { + Id: id3, + Observations: values.Proto(o).GetListValue(), + }, + }, + RegisteredWorkflowIds: []string{workflowTestID}, + Timestamp: timestamppb.New(time2), + } + obs3 := &pbtypes.Observations{ + Observations: []*pbtypes.Observation{ + { + Id: id, + Observations: values.Proto(o).GetListValue(), + OverriddenEncoderName: "evm", + OverriddenEncoderConfig: mc, + }, + { + Id: id2, + Observations: values.Proto(o).GetListValue(), + OverriddenEncoderName: "solana", + OverriddenEncoderConfig: mc, + }, + { + Id: id3, + Observations: values.Proto(o).GetListValue(), + }, + }, + RegisteredWorkflowIds: []string{workflowTestID}, + Timestamp: timestamppb.New(time3), + } + + rawObs, err := proto.Marshal(obs) + require.NoError(t, err) + rawObs2, err := proto.Marshal(obs2) + require.NoError(t, err) + rawObs3, err := proto.Marshal(obs3) + require.NoError(t, err) + aos := []types.AttributedObservation{ + { + Observation: rawObs, + Observer: commontypes.OracleID(1), + }, + { + Observation: rawObs2, + Observer: commontypes.OracleID(2), + }, + { + Observation: rawObs3, + Observer: commontypes.OracleID(3), + }, + } + + outcome, err := rp.Outcome(tests.Context(t), ocr3types.OutcomeContext{SeqNr: 100}, qb, aos) + require.NoError(t, err) + opb1 := &pbtypes.Outcome{} + err = proto.Unmarshal(outcome, opb1) + require.NoError(t, err) + + assert.Equal(t, opb1.Outcomes[workflowTestID].EncoderName, "evm") + ec, err := values.FromMapValueProto(opb1.Outcomes[workflowTestID].EncoderConfig) + require.NoError(t, err) + assert.Equal(t, ec, m) + + // No consensus on outcome 2 + assert.Equal(t, opb1.Outcomes[workflowTestID2].EncoderName, "") + assert.Nil(t, opb1.Outcomes[workflowTestID2].EncoderConfig) + + // Outcome 3 doesn't set the encoder + assert.Equal(t, opb1.Outcomes[workflowTestID3].EncoderName, "") + assert.Nil(t, opb1.Outcomes[workflowTestID3].EncoderConfig) +} diff --git a/pkg/capabilities/consensus/ocr3/requests/request.go b/pkg/capabilities/consensus/ocr3/requests/request.go index dc99d25e7..4d427a038 100644 --- a/pkg/capabilities/consensus/ocr3/requests/request.go +++ b/pkg/capabilities/consensus/ocr3/requests/request.go @@ -8,8 +8,10 @@ import ( ) type Request struct { - Observations *values.List `mapstructure:"-"` - ExpiresAt time.Time + Observations *values.List `mapstructure:"-"` + OverriddenEncoderName string + OverriddenEncoderConfig *values.Map + ExpiresAt time.Time // CallbackCh is a channel to send a response back to the requester // after the request has been processed or timed out. @@ -29,9 +31,11 @@ type Request struct { func (r *Request) Copy() *Request { return &Request{ - Observations: r.Observations.CopyList(), + Observations: r.Observations.CopyList(), + OverriddenEncoderConfig: r.OverriddenEncoderConfig.CopyMap(), // No need to copy these, they're value types. + OverriddenEncoderName: r.OverriddenEncoderName, ExpiresAt: r.ExpiresAt, WorkflowExecutionID: r.WorkflowExecutionID, WorkflowID: r.WorkflowID, diff --git a/pkg/capabilities/consensus/ocr3/testdata/fixtures/capability/schema.json b/pkg/capabilities/consensus/ocr3/testdata/fixtures/capability/schema.json index 843dcc58c..ebdabb38d 100644 --- a/pkg/capabilities/consensus/ocr3/testdata/fixtures/capability/schema.json +++ b/pkg/capabilities/consensus/ocr3/testdata/fixtures/capability/schema.json @@ -74,6 +74,21 @@ "required": [ "Underlying" ] + }, + "encoder": { + "type": "string" + }, + "encoder_config": { + "properties": { + "Underlying": { + "type": "object" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "Underlying" + ] } }, "additionalProperties": false, diff --git a/pkg/capabilities/consensus/ocr3/types/ocr3_types.pb.go b/pkg/capabilities/consensus/ocr3/types/ocr3_types.pb.go index 27ffb7ed4..05ad85bf7 100644 --- a/pkg/capabilities/consensus/ocr3/types/ocr3_types.pb.go +++ b/pkg/capabilities/consensus/ocr3/types/ocr3_types.pb.go @@ -276,7 +276,9 @@ type Observation struct { Id *Id `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // list of observations defined in inputs.observations - Observations *pb.List `protobuf:"bytes,4,opt,name=observations,proto3" json:"observations,omitempty"` + Observations *pb.List `protobuf:"bytes,4,opt,name=observations,proto3" json:"observations,omitempty"` + OverriddenEncoderName string `protobuf:"bytes,5,opt,name=overriddenEncoderName,proto3" json:"overriddenEncoderName,omitempty"` + OverriddenEncoderConfig *pb.Map `protobuf:"bytes,6,opt,name=overriddenEncoderConfig,proto3" json:"overriddenEncoderConfig,omitempty"` } func (x *Observation) Reset() { @@ -325,6 +327,20 @@ func (x *Observation) GetObservations() *pb.List { return nil } +func (x *Observation) GetOverriddenEncoderName() string { + if x != nil { + return x.OverriddenEncoderName + } + return "" +} + +func (x *Observation) GetOverriddenEncoderConfig() *pb.Map { + if x != nil { + return x.OverriddenEncoderConfig + } + return nil +} + type Observations struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -609,53 +625,61 @@ var file_capabilities_consensus_ocr3_types_ocr3_types_proto_rawDesc = []byte{ 0x66, 0x6c, 0x6f, 0x77, 0x44, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x6b, 0x65, 0x79, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6b, 0x65, 0x79, 0x49, 0x64, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, - 0x22, 0x5f, 0x0a, 0x0b, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x22, 0xdc, 0x01, 0x0a, 0x0b, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x1e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6f, + 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x49, 0x64, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x30, 0x0a, 0x0c, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x2e, + 0x4c, 0x69, 0x73, 0x74, 0x52, 0x0c, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x12, 0x34, 0x0a, 0x15, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x64, 0x65, 0x6e, + 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x15, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x45, 0x6e, 0x63, + 0x6f, 0x64, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x45, 0x0a, 0x17, 0x6f, 0x76, 0x65, 0x72, + 0x72, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x73, 0x2e, 0x4d, 0x61, 0x70, 0x52, 0x17, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x64, + 0x65, 0x6e, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, + 0xbb, 0x01, 0x0a, 0x0c, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x12, 0x3b, 0x0a, 0x0c, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, + 0x70, 0x65, 0x73, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x0c, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x34, 0x0a, + 0x15, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x65, 0x64, 0x57, 0x6f, 0x72, 0x6b, 0x66, + 0x6c, 0x6f, 0x77, 0x49, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x15, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x65, 0x64, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, + 0x49, 0x64, 0x73, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x62, 0x0a, + 0x06, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2e, 0x49, 0x64, 0x52, 0x02, 0x69, 0x64, 0x12, 0x38, 0x0a, 0x07, 0x6f, 0x75, 0x74, 0x63, 0x6f, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x52, 0x07, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, + 0x65, 0x22, 0x51, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x49, 0x64, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x30, 0x0a, 0x0c, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x2e, 0x4c, - 0x69, 0x73, 0x74, 0x52, 0x0c, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x22, 0xbb, 0x01, 0x0a, 0x0c, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x12, 0x3b, 0x0a, 0x0c, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x5f, - 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x0c, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x34, 0x0a, 0x15, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x65, 0x64, 0x57, 0x6f, 0x72, - 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x49, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x15, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x65, 0x64, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, - 0x6f, 0x77, 0x49, 0x64, 0x73, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, - 0x62, 0x0a, 0x06, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x2e, 0x49, 0x64, 0x52, 0x02, 0x69, 0x64, 0x12, 0x38, 0x0a, 0x07, 0x6f, 0x75, 0x74, - 0x63, 0x6f, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6f, 0x63, 0x72, - 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x52, 0x07, 0x6f, 0x75, 0x74, 0x63, - 0x6f, 0x6d, 0x65, 0x22, 0x51, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x49, 0x6e, 0x66, - 0x6f, 0x12, 0x1e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, - 0x6f, 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x49, 0x64, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x5f, 0x72, 0x65, 0x70, 0x6f, - 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, - 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x22, 0xe2, 0x01, 0x0a, 0x07, 0x4f, 0x75, 0x74, 0x63, 0x6f, - 0x6d, 0x65, 0x12, 0x3d, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, - 0x73, 0x2e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x2e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, - 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, - 0x73, 0x12, 0x3b, 0x0a, 0x0f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x70, - 0x6f, 0x72, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6f, 0x63, 0x72, - 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x0e, - 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x1a, 0x5b, - 0x0a, 0x0d, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x34, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1e, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x41, 0x67, - 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x23, 0x5a, 0x21, 0x63, - 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, - 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2f, 0x6f, 0x63, 0x72, 0x33, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x23, 0x0a, 0x0d, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x52, 0x65, + 0x70, 0x6f, 0x72, 0x74, 0x22, 0xe2, 0x01, 0x0a, 0x07, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, + 0x12, 0x3d, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, + 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x2e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x73, 0x12, + 0x3b, 0x0a, 0x0f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x0e, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x1a, 0x5b, 0x0a, 0x0d, + 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x34, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, + 0x2e, 0x6f, 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x41, 0x67, 0x67, 0x72, + 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x23, 0x5a, 0x21, 0x63, 0x61, 0x70, + 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, + 0x73, 0x75, 0x73, 0x2f, 0x6f, 0x63, 0x72, 0x33, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -692,19 +716,20 @@ var file_capabilities_consensus_ocr3_types_ocr3_types_proto_depIdxs = []int32{ 2, // 3: ocr3_types.Query.ids:type_name -> ocr3_types.Id 2, // 4: ocr3_types.Observation.id:type_name -> ocr3_types.Id 11, // 5: ocr3_types.Observation.observations:type_name -> values.List - 3, // 6: ocr3_types.Observations.observations:type_name -> ocr3_types.Observation - 10, // 7: ocr3_types.Observations.timestamp:type_name -> google.protobuf.Timestamp - 2, // 8: ocr3_types.Report.id:type_name -> ocr3_types.Id - 0, // 9: ocr3_types.Report.outcome:type_name -> ocr3_types.AggregationOutcome - 2, // 10: ocr3_types.ReportInfo.id:type_name -> ocr3_types.Id - 8, // 11: ocr3_types.Outcome.outcomes:type_name -> ocr3_types.Outcome.OutcomesEntry - 5, // 12: ocr3_types.Outcome.current_reports:type_name -> ocr3_types.Report - 0, // 13: ocr3_types.Outcome.OutcomesEntry.value:type_name -> ocr3_types.AggregationOutcome - 14, // [14:14] is the sub-list for method output_type - 14, // [14:14] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name + 9, // 6: ocr3_types.Observation.overriddenEncoderConfig:type_name -> values.Map + 3, // 7: ocr3_types.Observations.observations:type_name -> ocr3_types.Observation + 10, // 8: ocr3_types.Observations.timestamp:type_name -> google.protobuf.Timestamp + 2, // 9: ocr3_types.Report.id:type_name -> ocr3_types.Id + 0, // 10: ocr3_types.Report.outcome:type_name -> ocr3_types.AggregationOutcome + 2, // 11: ocr3_types.ReportInfo.id:type_name -> ocr3_types.Id + 8, // 12: ocr3_types.Outcome.outcomes:type_name -> ocr3_types.Outcome.OutcomesEntry + 5, // 13: ocr3_types.Outcome.current_reports:type_name -> ocr3_types.Report + 0, // 14: ocr3_types.Outcome.OutcomesEntry.value:type_name -> ocr3_types.AggregationOutcome + 15, // [15:15] is the sub-list for method output_type + 15, // [15:15] is the sub-list for method input_type + 15, // [15:15] is the sub-list for extension type_name + 15, // [15:15] is the sub-list for extension extendee + 0, // [0:15] is the sub-list for field type_name } func init() { file_capabilities_consensus_ocr3_types_ocr3_types_proto_init() } diff --git a/pkg/capabilities/consensus/ocr3/types/ocr3_types.proto b/pkg/capabilities/consensus/ocr3/types/ocr3_types.proto index 265b86552..4ce555895 100644 --- a/pkg/capabilities/consensus/ocr3/types/ocr3_types.proto +++ b/pkg/capabilities/consensus/ocr3/types/ocr3_types.proto @@ -39,6 +39,8 @@ message Observation { Id id = 1; // list of observations defined in inputs.observations values.List observations = 4; + string overriddenEncoderName = 5; + values.Map overriddenEncoderConfig = 6; } message Observations { diff --git a/pkg/workflows/sdk/testutils/runner.go b/pkg/workflows/sdk/testutils/runner.go index 125b666bb..aa3c7c35a 100644 --- a/pkg/workflows/sdk/testutils/runner.go +++ b/pkg/workflows/sdk/testutils/runner.go @@ -25,11 +25,6 @@ func NewRunner(ctx context.Context) *Runner { } } -type ConsensusMock interface { - capabilities.ConsensusCapability - SingleToManyObservations(value values.Value) (*values.Map, error) -} - type Runner struct { RawConfig []byte // Context is held in this runner because it's for testing and capability calls are made by it. @@ -173,12 +168,6 @@ func (r *Runner) walk(spec sdk.WorkflowSpec, ref string) error { return err } - if c, ok := mock.(ConsensusMock); ok { - if request.Inputs, err = c.SingleToManyObservations(request.Inputs); err != nil { - return err - } - } - results, err := mock.Execute(r.ctx, request) if err != nil { return err diff --git a/pkg/workflows/sdk/testutils/runner_test.go b/pkg/workflows/sdk/testutils/runner_test.go index 61f7a99a9..555e1f5c7 100644 --- a/pkg/workflows/sdk/testutils/runner_test.go +++ b/pkg/workflows/sdk/testutils/runner_test.go @@ -54,7 +54,7 @@ func TestRunner(t *testing.T) { assert.True(t, helper.transformTriggerCalled) consensus := consensusMock.GetStepDecoded("consensus") assert.Equal(t, "it was true", consensus.Output.AdaptedThing) - require.Len(t, consensus.Input.Observations, 1) + require.NotNil(t, consensus.Input.Observations[0]) rawConsensus := consensusMock.GetStep("consensus") target := targetMock.GetAllWrites() @@ -84,7 +84,7 @@ func TestRunner(t *testing.T) { consensus := ocr3.IdenticalConsensusConfig[basicaction.ActionOutputs]{ Encoder: "Test", EncoderConfig: ocr3.EncoderConfig{}, - }.New(workflow, "consensus", ocr3.IdenticalConsensusInput[basicaction.ActionOutputs]{Observations: action}) + }.New(workflow, "consensus", ocr3.IdenticalConsensusInput[basicaction.ActionOutputs]{Observation: action}) chainwriter.TargetConfig{ Address: "0x123", @@ -350,7 +350,7 @@ func createBasicTestWorkflow(actionTransform actionTransform) *sdk.WorkflowSpecF consensus := ocr3.IdenticalConsensusConfig[basicaction.ActionOutputs]{ Encoder: "Test", EncoderConfig: ocr3.EncoderConfig{}, - }.New(workflow, "consensus", ocr3.IdenticalConsensusInput[basicaction.ActionOutputs]{Observations: action}) + }.New(workflow, "consensus", ocr3.IdenticalConsensusInput[basicaction.ActionOutputs]{Observation: action}) chainwriter.TargetConfig{ Address: "0x123", From 2fd649133aced68d944e70f3f5a855c34c858d6d Mon Sep 17 00:00:00 2001 From: Awbrey Hughlett Date: Thu, 10 Oct 2024 10:31:10 -0500 Subject: [PATCH 3/9] created integration test that asserts cursor functionality (#811) * created integration test that asserts cursor functionality * fix query key with cursor over loop and grpc type conversion bug * Added finality to QueryKey Expression * Apply suggestions from code review Co-authored-by: Jordan Krage * Increased MaxWaitTimeforEvents for contractReader tests --------- Co-authored-by: Silas Lenihan Co-authored-by: Silas Lenihan <32529249+silaslenihan@users.noreply.github.com> Co-authored-by: Jordan Krage --- .../contractreader/contract_reader.go | 6 +-- .../contractreader/contract_reader_test.go | 33 +++++++++--- .../chain_components_interface_tests.go | 53 ++++++++++++++++++- 3 files changed, 81 insertions(+), 11 deletions(-) diff --git a/pkg/loop/internal/relayer/pluginprovider/contractreader/contract_reader.go b/pkg/loop/internal/relayer/pluginprovider/contractreader/contract_reader.go index 20b6f35d1..64e1dd191 100644 --- a/pkg/loop/internal/relayer/pluginprovider/contractreader/contract_reader.go +++ b/pkg/loop/internal/relayer/pluginprovider/contractreader/contract_reader.go @@ -618,11 +618,11 @@ func convertLimitAndSortToProto(limitAndSort query.LimitAndSort) (*pb.LimitAndSo var tp pb.SortType switch sort := sortBy.(type) { - case *query.SortByBlock: + case query.SortByBlock: tp = pb.SortType_SortBlock - case *query.SortByTimestamp: + case query.SortByTimestamp: tp = pb.SortType_SortTimestamp - case *query.SortBySequence: + case query.SortBySequence: tp = pb.SortType_SortSequence default: return &pb.LimitAndSort{}, status.Errorf(codes.InvalidArgument, "Unknown sort by type: %T", sort) diff --git a/pkg/loop/internal/relayer/pluginprovider/contractreader/contract_reader_test.go b/pkg/loop/internal/relayer/pluginprovider/contractreader/contract_reader_test.go index e9faa819f..e4ad1ead9 100644 --- a/pkg/loop/internal/relayer/pluginprovider/contractreader/contract_reader_test.go +++ b/pkg/loop/internal/relayer/pluginprovider/contractreader/contract_reader_test.go @@ -7,6 +7,7 @@ import ( "math/big" "reflect" "sort" + "strconv" "strings" "sync" "testing" @@ -336,7 +337,7 @@ func (it *fakeContractReaderInterfaceTester) GenerateBlocksTillConfidenceLevel(t } func (it *fakeContractReaderInterfaceTester) MaxWaitTimeForEvents() time.Duration { - return time.Millisecond * 100 + return time.Millisecond * 1000 } type valConfidencePair struct { @@ -607,7 +608,7 @@ func (f *fakeContractReader) QueryKey(_ context.Context, bc types.BoundContract, } var sequences []types.Sequence - for _, trigger := range f.triggers[bc.String()] { + for idx, trigger := range f.triggers[bc.String()] { doAppend := true for _, expr := range filter.Expressions { if primitive, ok := expr.Primitive.(*primitives.Comparator); ok { @@ -621,21 +622,39 @@ func (f *fakeContractReader) QueryKey(_ context.Context, bc types.BoundContract, } } } - if len(filter.Expressions) == 0 || doAppend { + + var skipAppend bool + if limitAndSort.HasCursorLimit() { + cursor, err := strconv.Atoi(limitAndSort.Limit.Cursor) + if err != nil { + return nil, err + } + + // assume CursorFollowing order for now + if cursor >= idx { + skipAppend = true + } + } + + if (len(filter.Expressions) == 0 || doAppend) && !skipAppend { if isValueType { value, err := values.Wrap(trigger.testStruct) if err != nil { return nil, err } - sequences = append(sequences, types.Sequence{Data: &value}) + sequences = append(sequences, types.Sequence{Cursor: strconv.Itoa(idx), Data: &value}) } else { - sequences = append(sequences, types.Sequence{Data: trigger.testStruct}) + sequences = append(sequences, types.Sequence{Cursor: fmt.Sprintf("%d", idx), Data: trigger.testStruct}) } } + + if limitAndSort.Limit.Count > 0 && len(sequences) >= int(limitAndSort.Limit.Count) { + break + } } if isValueType { - if !limitAndSort.HasSequenceSort() { + if !limitAndSort.HasSequenceSort() && !limitAndSort.HasCursorLimit() { sort.Slice(sequences, func(i, j int) bool { valI := *sequences[i].Data.(*values.Value) valJ := *sequences[j].Data.(*values.Value) @@ -662,7 +681,7 @@ func (f *fakeContractReader) QueryKey(_ context.Context, bc types.BoundContract, }) } } else { - if !limitAndSort.HasSequenceSort() { + if !limitAndSort.HasSequenceSort() && !limitAndSort.HasCursorLimit() { sort.Slice(sequences, func(i, j int) bool { if sequences[i].Data.(TestStruct).Field == nil || sequences[j].Data.(TestStruct).Field == nil { return false diff --git a/pkg/types/interfacetests/chain_components_interface_tests.go b/pkg/types/interfacetests/chain_components_interface_tests.go index 185886c93..f258396d6 100644 --- a/pkg/types/interfacetests/chain_components_interface_tests.go +++ b/pkg/types/interfacetests/chain_components_interface_tests.go @@ -791,7 +791,58 @@ func runQueryKeyInterfaceTests[T TestingT[T]](t T, tester ChainComponentsInterfa }, }, query.LimitAndSort{}, ts) return err == nil && len(sequences) == 2 && reflect.DeepEqual(&ts2, sequences[1].Data) && reflect.DeepEqual(&ts3, sequences[0].Data) - }, tester.MaxWaitTimeForEvents(), time.Millisecond*10) + }, tester.MaxWaitTimeForEvents(), time.Millisecond*500) + }, + }, + { + name: "QueryKey can limit results with cursor", + test: func(t T) { + ctx := tests.Context(t) + cr := tester.GetContractReader(t) + bindings := tester.GetBindings(t) + + require.NoError(t, cr.Bind(ctx, bindings)) + boundContract := BindingsByName(bindings, AnyContractName)[0] + + // keep this an even number such that the cursor limit can be in batches of 2 + testStructs := make([]TestStruct, 4) + + // create test structs in sequence + for idx := range testStructs { + testStructs[idx] = CreateTestStruct(idx*2, tester) + + _ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, testStructs[idx], boundContract, types.Unconfirmed) + } + + assert.Eventually(t, func() bool { + var allSequences []types.Sequence + + filter := query.KeyFilter{Key: EventName, Expressions: []query.Expression{ + query.Confidence(primitives.Finalized), + }} + limit := query.LimitAndSort{ + SortBy: []query.SortBy{query.NewSortBySequence(query.Asc)}, + Limit: query.CountLimit(2), + } + + for idx := 0; idx < len(testStructs)/2; idx++ { + // sequences from queryKey without limit and sort should be in descending order + sequences, err := cr.QueryKey(ctx, boundContract, filter, limit, &TestStruct{}) + + require.NoError(t, err) + + if len(sequences) == 0 { + continue + } + + limit.Limit = query.CursorLimit(sequences[len(sequences)-1].Cursor, query.CursorFollowing, 2) + allSequences = append(allSequences, sequences...) + } + + return len(allSequences) == len(testStructs) && + reflect.DeepEqual(&testStructs[0], allSequences[0].Data) && + reflect.DeepEqual(&testStructs[len(testStructs)-1], allSequences[len(testStructs)-1].Data) + }, tester.MaxWaitTimeForEvents(), 500*time.Millisecond) }, }, } From d1831b62389a1a7da70765a42a0db94f2b8f27b9 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Thu, 10 Oct 2024 13:54:45 -0500 Subject: [PATCH 4/9] pkg/loop: clean up background contexts (#839) --- pkg/loop/ccip_commit.go | 2 +- pkg/loop/ccip_execution.go | 2 +- pkg/loop/internal/goplugin/plugin_service.go | 5 ----- pkg/loop/internal/relayerset/relayer.go | 4 ++-- pkg/loop/median_service.go | 2 +- pkg/loop/mercury_service.go | 8 ++++---- pkg/loop/reportingplugins/loopp_service.go | 4 ++-- pkg/loop/reportingplugins/ocr3/loopp_service.go | 2 +- 8 files changed, 12 insertions(+), 17 deletions(-) diff --git a/pkg/loop/ccip_commit.go b/pkg/loop/ccip_commit.go index 119de6128..598f06096 100644 --- a/pkg/loop/ccip_commit.go +++ b/pkg/loop/ccip_commit.go @@ -85,7 +85,7 @@ func NewCommitService(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec.Cm } func (m *CommitFactoryService) NewReportingPlugin(ctx context.Context, config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { - if err := m.Wait(); err != nil { + if err := m.WaitCtx(ctx); err != nil { return nil, ocrtypes.ReportingPluginInfo{}, err } return m.Service.NewReportingPlugin(ctx, config) diff --git a/pkg/loop/ccip_execution.go b/pkg/loop/ccip_execution.go index 099580c74..2df482a35 100644 --- a/pkg/loop/ccip_execution.go +++ b/pkg/loop/ccip_execution.go @@ -85,7 +85,7 @@ func NewExecutionService(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec } func (m *ExecutionFactoryService) NewReportingPlugin(ctx context.Context, config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { - if err := m.Wait(); err != nil { + if err := m.WaitCtx(ctx); err != nil { return nil, ocrtypes.ReportingPluginInfo{}, err } return m.Service.NewReportingPlugin(ctx, config) diff --git a/pkg/loop/internal/goplugin/plugin_service.go b/pkg/loop/internal/goplugin/plugin_service.go index 1b147f13c..bf02298e8 100644 --- a/pkg/loop/internal/goplugin/plugin_service.go +++ b/pkg/loop/internal/goplugin/plugin_service.go @@ -223,11 +223,6 @@ func (s *PluginService[P, S]) WaitCtx(ctx context.Context) error { } } -// Wait is the context-ignorant version of WaitCtx above. -func (s *PluginService[P, S]) Wait() error { - return s.WaitCtx(context.Background()) -} - // XXXTestHook returns a TestPluginService. // It must only be called once, and before Start. func (s *PluginService[P, S]) XXXTestHook() TestPluginService[P, S] { diff --git a/pkg/loop/internal/relayerset/relayer.go b/pkg/loop/internal/relayerset/relayer.go index a85dcdbc6..fe0cd4351 100644 --- a/pkg/loop/internal/relayerset/relayer.go +++ b/pkg/loop/internal/relayerset/relayer.go @@ -93,8 +93,8 @@ func (r *relayerClient) Name() string { return name } -func (r *relayerClient) LatestHead(_ context.Context) (types.Head, error) { - latestHead, err := r.relayerSetClient.RelayerLatestHead(context.Background(), r.relayerID) +func (r *relayerClient) LatestHead(ctx context.Context) (types.Head, error) { + latestHead, err := r.relayerSetClient.RelayerLatestHead(ctx, r.relayerID) if err != nil { r.log.Error("error getting latestHead", "error", err) return types.Head{}, err diff --git a/pkg/loop/median_service.go b/pkg/loop/median_service.go index 44bf302c7..eec104f7f 100644 --- a/pkg/loop/median_service.go +++ b/pkg/loop/median_service.go @@ -40,7 +40,7 @@ func NewMedianService(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec.Cm } func (m *MedianService) NewReportingPlugin(ctx context.Context, config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { - if err := m.Wait(); err != nil { + if err := m.WaitCtx(ctx); err != nil { return nil, ocrtypes.ReportingPluginInfo{}, err } return m.Service.NewReportingPlugin(ctx, config) diff --git a/pkg/loop/mercury_service.go b/pkg/loop/mercury_service.go index f3eca6e06..1696c343c 100644 --- a/pkg/loop/mercury_service.go +++ b/pkg/loop/mercury_service.go @@ -44,7 +44,7 @@ func NewMercuryV4Service(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec } func (m *MercuryV4Service) NewMercuryPlugin(ctx context.Context, config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { - if err := m.Wait(); err != nil { + if err := m.WaitCtx(ctx); err != nil { return nil, ocr3types.MercuryPluginInfo{}, err } return m.Service.NewMercuryPlugin(ctx, config) @@ -78,7 +78,7 @@ func NewMercuryV3Service(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec } func (m *MercuryV3Service) NewMercuryPlugin(ctx context.Context, config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { - if err := m.Wait(); err != nil { + if err := m.WaitCtx(ctx); err != nil { return nil, ocr3types.MercuryPluginInfo{}, err } return m.Service.NewMercuryPlugin(ctx, config) @@ -110,7 +110,7 @@ func NewMercuryV1Service(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec } func (m *MercuryV1Service) NewMercuryPlugin(ctx context.Context, config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { - if err := m.Wait(); err != nil { + if err := m.WaitCtx(ctx); err != nil { return nil, ocr3types.MercuryPluginInfo{}, err } return m.Service.NewMercuryPlugin(ctx, config) @@ -144,7 +144,7 @@ func NewMercuryV2Service(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec } func (m *MercuryV2Service) NewMercuryPlugin(ctx context.Context, config ocr3types.MercuryPluginConfig) (ocr3types.MercuryPlugin, ocr3types.MercuryPluginInfo, error) { - if err := m.Wait(); err != nil { + if err := m.WaitCtx(ctx); err != nil { return nil, ocr3types.MercuryPluginInfo{}, err } return m.Service.NewMercuryPlugin(ctx, config) diff --git a/pkg/loop/reportingplugins/loopp_service.go b/pkg/loop/reportingplugins/loopp_service.go index 92b7db4fd..8fbbaa68c 100644 --- a/pkg/loop/reportingplugins/loopp_service.go +++ b/pkg/loop/reportingplugins/loopp_service.go @@ -60,7 +60,7 @@ func NewLOOPPService( } func (g *LOOPPService) NewReportingPlugin(ctx context.Context, config ocrtypes.ReportingPluginConfig) (ocrtypes.ReportingPlugin, ocrtypes.ReportingPluginInfo, error) { - if err := g.Wait(); err != nil { + if err := g.WaitCtx(ctx); err != nil { return nil, ocrtypes.ReportingPluginInfo{}, err } return g.Service.NewReportingPlugin(ctx, config) @@ -87,7 +87,7 @@ func NewLOOPPServiceValidation( } func (g *LOOPPServiceValidation) ValidateConfig(ctx context.Context, config map[string]interface{}) error { - if err := g.Wait(); err != nil { + if err := g.WaitCtx(ctx); err != nil { return err } diff --git a/pkg/loop/reportingplugins/ocr3/loopp_service.go b/pkg/loop/reportingplugins/ocr3/loopp_service.go index 7f3a088df..7b10fcabc 100644 --- a/pkg/loop/reportingplugins/ocr3/loopp_service.go +++ b/pkg/loop/reportingplugins/ocr3/loopp_service.go @@ -52,7 +52,7 @@ func NewLOOPPService( } func (g *LOOPPService) NewReportingPlugin(ctx context.Context, config ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[[]byte], ocr3types.ReportingPluginInfo, error) { - if err := g.Wait(); err != nil { + if err := g.WaitCtx(ctx); err != nil { return nil, ocr3types.ReportingPluginInfo{}, err } return g.Service.NewReportingPlugin(ctx, config) From b7d55eff04946ebf6fa65af13644520828eac990 Mon Sep 17 00:00:00 2001 From: jinhoonbang Date: Fri, 11 Oct 2024 08:29:40 -0700 Subject: [PATCH 5/9] parse workflow YAML as float, not decimal.Decimal (#841) * parse workflow YAML as float, not decimal.Decimal * support unwrapping as decimal.Decimal --- pkg/values/float64.go | 12 ++++++++++++ pkg/values/float64_test.go | 17 +++++++++++++++++ pkg/workflows/models_yaml.go | 8 ++------ pkg/workflows/models_yaml_test.go | 5 ++--- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/pkg/values/float64.go b/pkg/values/float64.go index d02033c51..e963ec89d 100644 --- a/pkg/values/float64.go +++ b/pkg/values/float64.go @@ -3,6 +3,8 @@ package values import ( "errors" + "github.com/shopspring/decimal" + "github.com/smartcontractkit/chainlink-common/pkg/values/pb" ) @@ -27,6 +29,16 @@ func (f *Float64) UnwrapTo(to any) error { if f == nil { return errors.New("cannot unwrap nil values.Float64") } + + switch t := to.(type) { + case *decimal.Decimal: + if t == nil { + return errors.New("cannot unwrap to nil pointer") + } + *t = decimal.NewFromFloat(f.Underlying) + return nil + } + return unwrapTo(f.Underlying, to) } diff --git a/pkg/values/float64_test.go b/pkg/values/float64_test.go index 4a6a85add..ddea09cea 100644 --- a/pkg/values/float64_test.go +++ b/pkg/values/float64_test.go @@ -3,6 +3,7 @@ package values import ( "testing" + "github.com/shopspring/decimal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -42,6 +43,22 @@ func Test_Float64UnwrapTo(t *testing.T) { assert.Equal(t, myFloat64(expected), mf) } +func Test_Float64UnwrapToDecimal(t *testing.T) { + expected := decimal.NewFromFloat(1.1) + v := NewFloat64(1.1) + + var got decimal.Decimal + err := v.UnwrapTo(&got) + require.NoError(t, err) + require.Equal(t, expected, got) + + assert.Equal(t, expected, got) + + gotn := (*decimal.Decimal)(nil) + err = v.UnwrapTo(gotn) + assert.ErrorContains(t, err, "cannot unwrap to nil pointer") +} + // Test_Float64 tests that Float64 values can converted to and from protobuf representations. func Test_Float64(t *testing.T) { testCases := []struct { diff --git a/pkg/workflows/models_yaml.go b/pkg/workflows/models_yaml.go index 8706a0269..b8ace7fb7 100644 --- a/pkg/workflows/models_yaml.go +++ b/pkg/workflows/models_yaml.go @@ -11,7 +11,6 @@ import ( "github.com/invopop/jsonschema" validate "github.com/santhosh-tekuri/jsonschema/v5" - "github.com/shopspring/decimal" "sigs.k8s.io/yaml" "github.com/smartcontractkit/chainlink-common/pkg/capabilities" @@ -147,15 +146,12 @@ func (m *Mapping) UnmarshalJSON(b []byte) error { // // Supported type conversions: // - json.Number -> int64 -// - json.Number -> float64 -> decimal.Decimal +// - json.Number -> float64 func convertNumber(el any) (any, error) { switch elv := el.(type) { case json.Number: if strings.Contains(elv.String(), ".") { - f, err := elv.Float64() - if err == nil { - return decimal.NewFromFloat(f), nil - } + return elv.Float64() } return elv.Int64() diff --git a/pkg/workflows/models_yaml_test.go b/pkg/workflows/models_yaml_test.go index a2f23e1fd..89ca32fff 100644 --- a/pkg/workflows/models_yaml_test.go +++ b/pkg/workflows/models_yaml_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/santhosh-tekuri/jsonschema/v5" - "github.com/shopspring/decimal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -322,8 +321,8 @@ func TestMappingCustomType(t *testing.T) { err := m.UnmarshalJSON([]byte(data)) require.NoError(t, err) assert.Equal(t, int64(100), m["foo"], m) - assert.Equal(t, decimal.NewFromFloat(100.00), m["bar"], m) - assert.Equal(t, decimal.NewFromFloat(11.10), m["baz"].(map[string]any)["gnat"], m) + assert.Equal(t, float64(100.00), m["bar"], m) + assert.Equal(t, float64(11.10), m["baz"].(map[string]any)["gnat"], m) } func wfSpec(t *testing.T, name, owner string) any { From 5d432bcdc2e8c4e39369cb19183e3925afd37997 Mon Sep 17 00:00:00 2001 From: Alec Gard Date: Fri, 11 Oct 2024 17:09:13 +0100 Subject: [PATCH 6/9] Fix Latest timestamp metric to return timestamp in seconds (#844) --- pkg/monitoring/exporter_prometheus.go | 2 +- pkg/monitoring/exporter_prometheus_test.go | 60 +++++++++++----------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/pkg/monitoring/exporter_prometheus.go b/pkg/monitoring/exporter_prometheus.go index cf49afc42..b2905dbb3 100644 --- a/pkg/monitoring/exporter_prometheus.go +++ b/pkg/monitoring/exporter_prometheus.go @@ -199,7 +199,7 @@ func (p *prometheusExporter) exportEnvelope(envelope Envelope) { p.chainConfig.GetNetworkName(), ) p.metrics.SetOffchainAggregatorAnswersLatestTimestamp( - float64(envelope.LatestTimestamp.Second()), + float64(envelope.LatestTimestamp.Unix()), p.feedConfig.GetID(), p.feedConfig.GetID(), p.chainConfig.GetChainID(), diff --git a/pkg/monitoring/exporter_prometheus_test.go b/pkg/monitoring/exporter_prometheus_test.go index 3111ed7b3..6899dad91 100644 --- a/pkg/monitoring/exporter_prometheus_test.go +++ b/pkg/monitoring/exporter_prometheus_test.go @@ -119,16 +119,16 @@ func TestPrometheusExporter(t *testing.T) { chainConfig.GetNetworkName(), // networkName ).Once() metrics.On("SetOffchainAggregatorAnswersLatestTimestamp", - float64(envelope1.LatestTimestamp.Second()), // latestTimestamp - feedConfig.GetID(), // contractAddress - feedConfig.GetID(), // feedID - chainConfig.GetChainID(), // chainID - feedConfig.GetContractStatus(), // contractStatus - feedConfig.GetContractType(), // contractType - feedConfig.GetName(), // feedName - feedConfig.GetPath(), // feedPath - chainConfig.GetNetworkID(), // networkID - chainConfig.GetNetworkName(), // networkName + float64(envelope1.LatestTimestamp.Unix()), // latestTimestamp + feedConfig.GetID(), // contractAddress + feedConfig.GetID(), // feedID + chainConfig.GetChainID(), // chainID + feedConfig.GetContractStatus(), // contractStatus + feedConfig.GetContractType(), // contractType + feedConfig.GetName(), // feedName + feedConfig.GetPath(), // feedPath + chainConfig.GetNetworkID(), // networkID + chainConfig.GetNetworkName(), // networkName ).Once() metrics.On("SetOffchainAggregatorJuelsPerFeeCoinRaw", toFloat64(envelope1.JuelsPerFeeCoin), @@ -278,16 +278,16 @@ func TestPrometheusExporter(t *testing.T) { chainConfig.GetNetworkName(), // networkName ).Once() metrics.On("SetOffchainAggregatorAnswersLatestTimestamp", - float64(envelope2.LatestTimestamp.Second()), // latestTimestamp - feedConfig.GetID(), // contractAddress - feedConfig.GetID(), // feedID - chainConfig.GetChainID(), // chainID - feedConfig.GetContractStatus(), // contractStatus - feedConfig.GetContractType(), // contractType - feedConfig.GetName(), // feedName - feedConfig.GetPath(), // feedPath - chainConfig.GetNetworkID(), // networkID - chainConfig.GetNetworkName(), // networkName + float64(envelope2.LatestTimestamp.Unix()), // latestTimestamp + feedConfig.GetID(), // contractAddress + feedConfig.GetID(), // feedID + chainConfig.GetChainID(), // chainID + feedConfig.GetContractStatus(), // contractStatus + feedConfig.GetContractType(), // contractType + feedConfig.GetName(), // feedName + feedConfig.GetPath(), // feedPath + chainConfig.GetNetworkID(), // networkID + chainConfig.GetNetworkName(), // networkName ).Once() metrics.On("SetOffchainAggregatorJuelsPerFeeCoinRaw", toFloat64(envelope2.JuelsPerFeeCoin), @@ -504,16 +504,16 @@ func TestPrometheusExporter(t *testing.T) { chainConfig.GetNetworkName(), // networkName ).Once() metrics.On("SetOffchainAggregatorAnswersLatestTimestamp", - float64(envelope1.LatestTimestamp.Second()), // latestTimestamp - feedConfig.GetID(), // contractAddress - feedConfig.GetID(), // feedID - chainConfig.GetChainID(), // chainID - feedConfig.GetContractStatus(), // contractStatus - feedConfig.GetContractType(), // contractType - feedConfig.GetName(), // feedName - feedConfig.GetPath(), // feedPath - chainConfig.GetNetworkID(), // networkID - chainConfig.GetNetworkName(), // networkName + float64(envelope1.LatestTimestamp.Unix()), // latestTimestamp + feedConfig.GetID(), // contractAddress + feedConfig.GetID(), // feedID + chainConfig.GetChainID(), // chainID + feedConfig.GetContractStatus(), // contractStatus + feedConfig.GetContractType(), // contractType + feedConfig.GetName(), // feedName + feedConfig.GetPath(), // feedPath + chainConfig.GetNetworkID(), // networkID + chainConfig.GetNetworkName(), // networkName ).Once() metrics.On("SetOffchainAggregatorJuelsPerFeeCoinRaw", toFloat64(envelope1.JuelsPerFeeCoin), From 3619db2c34a431b1459d349ddf52e6e57848b3ae Mon Sep 17 00:00:00 2001 From: Ryan Tinianov Date: Fri, 11 Oct 2024 12:36:36 -0400 Subject: [PATCH 7/9] Enable consensus based on a value.Map (#840) * Enable consensus based on a value.Map * Add a method to get all encoder names --- .../ocr3/ocr3cap/ocr3cap_common-schema.json | 2 +- .../ocr3/ocr3cap/ocr3cap_common_generated.go | 2 + .../consensus/ocr3/ocr3cap/utils.go | 15 +++++ .../consensus/ocr3/ocr3cap/utils_test.go | 19 ++++++ .../consensus/ocr3/value_map_encoder.go | 19 ++++++ .../consensus/ocr3/value_map_encoder_test.go | 66 +++++++++++++++++++ 6 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 pkg/capabilities/consensus/ocr3/ocr3cap/utils.go create mode 100644 pkg/capabilities/consensus/ocr3/ocr3cap/utils_test.go create mode 100644 pkg/capabilities/consensus/ocr3/value_map_encoder.go create mode 100644 pkg/capabilities/consensus/ocr3/value_map_encoder_test.go diff --git a/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3cap_common-schema.json b/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3cap_common-schema.json index 280ba7e32..28f2d9998 100644 --- a/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3cap_common-schema.json +++ b/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3cap_common-schema.json @@ -46,7 +46,7 @@ }, "encoder": { "type": "string", - "enum": ["EVM"] + "enum": ["EVM", "ValueMap"] }, "encoder_config": { "type": "object", diff --git a/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3cap_common_generated.go b/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3cap_common_generated.go index b42fe1c9d..ac72a71ee 100644 --- a/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3cap_common_generated.go +++ b/pkg/capabilities/consensus/ocr3/ocr3cap/ocr3cap_common_generated.go @@ -14,9 +14,11 @@ type Encoder string type EncoderConfig map[string]interface{} const EncoderEVM Encoder = "EVM" +const EncoderValueMap Encoder = "ValueMap" var enumValues_Encoder = []interface{}{ "EVM", + "ValueMap", } // UnmarshalJSON implements json.Unmarshaler. diff --git a/pkg/capabilities/consensus/ocr3/ocr3cap/utils.go b/pkg/capabilities/consensus/ocr3/ocr3cap/utils.go new file mode 100644 index 000000000..883a61631 --- /dev/null +++ b/pkg/capabilities/consensus/ocr3/ocr3cap/utils.go @@ -0,0 +1,15 @@ +package ocr3cap + +var encoderTypes []Encoder + +func init() { + for _, v := range enumValues_Encoder { + encoderTypes = append(encoderTypes, Encoder(v.(string))) + } +} + +func Encoders() []Encoder { + cpy := make([]Encoder, len(encoderTypes)) + copy(cpy, encoderTypes) + return cpy +} diff --git a/pkg/capabilities/consensus/ocr3/ocr3cap/utils_test.go b/pkg/capabilities/consensus/ocr3/ocr3cap/utils_test.go new file mode 100644 index 000000000..f1f17882f --- /dev/null +++ b/pkg/capabilities/consensus/ocr3/ocr3cap/utils_test.go @@ -0,0 +1,19 @@ +package ocr3cap_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3/ocr3cap" +) + +func TestEncoders(t *testing.T) { + t.Parallel() + t.Run("Returns a copy of the underlying encoders", func(t *testing.T) { + orig := ocr3cap.Encoders() + orig[0] = "foo" + assert.NotEqual(t, orig, ocr3cap.Encoders()) + assert.Equal(t, ocr3cap.Encoder("foo"), orig[0]) + }) +} diff --git a/pkg/capabilities/consensus/ocr3/value_map_encoder.go b/pkg/capabilities/consensus/ocr3/value_map_encoder.go new file mode 100644 index 000000000..e234fa62a --- /dev/null +++ b/pkg/capabilities/consensus/ocr3/value_map_encoder.go @@ -0,0 +1,19 @@ +package ocr3 + +import ( + "context" + + "google.golang.org/protobuf/proto" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3/types" + "github.com/smartcontractkit/chainlink-common/pkg/values" +) + +type ValueMapEncoder struct{} + +func (v ValueMapEncoder) Encode(_ context.Context, input values.Map) ([]byte, error) { + opts := proto.MarshalOptions{Deterministic: true} + return opts.Marshal(values.Proto(&input)) +} + +var _ types.Encoder = (*ValueMapEncoder)(nil) diff --git a/pkg/capabilities/consensus/ocr3/value_map_encoder_test.go b/pkg/capabilities/consensus/ocr3/value_map_encoder_test.go new file mode 100644 index 000000000..2d1a1db00 --- /dev/null +++ b/pkg/capabilities/consensus/ocr3/value_map_encoder_test.go @@ -0,0 +1,66 @@ +package ocr3_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" + "github.com/smartcontractkit/chainlink-common/pkg/values" + "github.com/smartcontractkit/chainlink-common/pkg/values/pb" +) + +func Test_ValuesEncoder_Encode(t *testing.T) { + t.Parallel() + input := map[string]any{ + "foo": "bar", + "baz": int64(42), + "x": map[string]any{"y": "z"}, + } + inputWrapped, err := values.NewMap(input) + require.NoError(t, err) + + expectedProto := &pb.Value{ + Value: &pb.Value_MapValue{ + MapValue: &pb.Map{ + Fields: map[string]*pb.Value{ + "foo": {Value: &pb.Value_StringValue{StringValue: "bar"}}, + "baz": {Value: &pb.Value_Int64Value{Int64Value: 42}}, + "x": { + Value: &pb.Value_MapValue{ + MapValue: &pb.Map{ + Fields: map[string]*pb.Value{ + "y": {Value: &pb.Value_StringValue{StringValue: "z"}}, + }, + }, + }, + }, + }, + }, + }, + } + + encoder := ocr3.ValueMapEncoder{} + actual, err := encoder.Encode(tests.Context(t), *inputWrapped) + require.NoError(t, err) + + opts := proto.MarshalOptions{Deterministic: true} + expected, err := opts.Marshal(expectedProto) + require.NoError(t, err) + + assert.Equal(t, expected, actual) + + decoded := &pb.Value{} + require.NoError(t, proto.Unmarshal(actual, decoded)) + + val, err := values.FromProto(decoded) + require.NoError(t, err) + + output := map[string]any{} + require.NoError(t, val.UnwrapTo(&output)) + + assert.Equal(t, input, output) +} From cdeea8fc821aa56809705e9ef5fd61b1e7bb8e0e Mon Sep 17 00:00:00 2001 From: Cedric Date: Mon, 14 Oct 2024 10:43:07 +0100 Subject: [PATCH 8/9] [chore] Some logging updates for feeds aggregator (#843) * [chore] Some logging updates for feeds aggregator * [chore] Some logging updates for feeds aggregator Also pass the logger through the aggregator interface so that we can inherit the logging tags, including executionID and workflowID * Use Errorw for consistency --- .../consensus/ocr3/aggregators/identical.go | 9 ++- .../ocr3/aggregators/identical_test.go | 12 ++-- .../ocr3/datafeeds/feeds_aggregator.go | 56 +++++++++++-------- .../ocr3/datafeeds/feeds_aggregator_test.go | 18 +++--- .../consensus/ocr3/reporting_plugin.go | 13 ++--- .../consensus/ocr3/reporting_plugin_test.go | 2 +- .../consensus/ocr3/types/aggregator.go | 2 +- 7 files changed, 59 insertions(+), 53 deletions(-) diff --git a/pkg/capabilities/consensus/ocr3/aggregators/identical.go b/pkg/capabilities/consensus/ocr3/aggregators/identical.go index a50448bc3..389390882 100644 --- a/pkg/capabilities/consensus/ocr3/aggregators/identical.go +++ b/pkg/capabilities/consensus/ocr3/aggregators/identical.go @@ -36,18 +36,18 @@ type counter struct { var _ types.Aggregator = (*identicalAggregator)(nil) -func (a *identicalAggregator) Aggregate(_ *types.AggregationOutcome, observations map[ocrcommon.OracleID][]values.Value, f int) (*types.AggregationOutcome, error) { +func (a *identicalAggregator) Aggregate(lggr logger.Logger, _ *types.AggregationOutcome, observations map[ocrcommon.OracleID][]values.Value, f int) (*types.AggregationOutcome, error) { counters := []map[[32]byte]*counter{} for i := 0; i < a.config.ExpectedObservationsLen; i++ { counters = append(counters, map[[32]byte]*counter{}) } for nodeID, nodeObservations := range observations { if len(nodeObservations) == 0 || nodeObservations[0] == nil { - a.lggr.Warnf("node %d contributed with empty observations", nodeID) + lggr.Warnf("node %d contributed with empty observations", nodeID) continue } if len(nodeObservations) != a.config.ExpectedObservationsLen { - a.lggr.Warnf("node %d contributed with an incorrect number of observations %d - ignoring them", nodeID, len(nodeObservations)) + lggr.Warnf("node %d contributed with an incorrect number of observations %d - ignoring them", nodeID, len(nodeObservations)) continue } for idx, observation := range nodeObservations { @@ -102,14 +102,13 @@ func (a *identicalAggregator) collectHighestCounts(counters []map[[32]byte]*coun }, nil } -func NewIdenticalAggregator(config values.Map, lggr logger.Logger) (*identicalAggregator, error) { +func NewIdenticalAggregator(config values.Map) (*identicalAggregator, error) { parsedConfig, err := ParseConfig(config) if err != nil { return nil, fmt.Errorf("failed to parse config (%+v): %w", config, err) } return &identicalAggregator{ config: parsedConfig, - lggr: lggr, }, nil } diff --git a/pkg/capabilities/consensus/ocr3/aggregators/identical_test.go b/pkg/capabilities/consensus/ocr3/aggregators/identical_test.go index aaa146b44..711b1ab25 100644 --- a/pkg/capabilities/consensus/ocr3/aggregators/identical_test.go +++ b/pkg/capabilities/consensus/ocr3/aggregators/identical_test.go @@ -14,7 +14,7 @@ import ( func TestDataFeedsAggregator_Aggregate(t *testing.T) { config := getConfig(t, nil) - agg, err := aggregators.NewIdenticalAggregator(*config, logger.Nop()) + agg, err := aggregators.NewIdenticalAggregator(*config) require.NoError(t, err) observations := map[commontypes.OracleID][]values.Value{ @@ -23,7 +23,7 @@ func TestDataFeedsAggregator_Aggregate(t *testing.T) { 2: {values.NewString("a")}, 3: {values.NewString("a")}, } - outcome, err := agg.Aggregate(nil, observations, 1) + outcome, err := agg.Aggregate(logger.Nop(), nil, observations, 1) require.NoError(t, err) require.True(t, outcome.ShouldReport) require.Equal(t, "", outcome.EncoderName) @@ -38,7 +38,7 @@ func TestDataFeedsAggregator_Aggregate(t *testing.T) { func TestDataFeedsAggregator_Aggregate_OverrideWithKeys(t *testing.T) { config := getConfig(t, []string{"outcome"}) - agg, err := aggregators.NewIdenticalAggregator(*config, logger.Nop()) + agg, err := aggregators.NewIdenticalAggregator(*config) require.NoError(t, err) observations := map[commontypes.OracleID][]values.Value{ @@ -47,7 +47,7 @@ func TestDataFeedsAggregator_Aggregate_OverrideWithKeys(t *testing.T) { 2: {values.NewString("a")}, 3: {values.NewString("a")}, } - outcome, err := agg.Aggregate(nil, observations, 1) + outcome, err := agg.Aggregate(logger.Nop(), nil, observations, 1) require.NoError(t, err) require.True(t, outcome.ShouldReport) require.Equal(t, "", outcome.EncoderName) @@ -62,7 +62,7 @@ func TestDataFeedsAggregator_Aggregate_OverrideWithKeys(t *testing.T) { func TestDataFeedsAggregator_Aggregate_NoConsensus(t *testing.T) { config := getConfig(t, []string{"outcome"}) - agg, err := aggregators.NewIdenticalAggregator(*config, logger.Nop()) + agg, err := aggregators.NewIdenticalAggregator(*config) require.NoError(t, err) encoderStr := "evm" @@ -76,7 +76,7 @@ func TestDataFeedsAggregator_Aggregate_NoConsensus(t *testing.T) { 2: {values.NewString("b"), encoderName, encoderCfg}, 3: {values.NewString("a"), encoderName, encoderCfg}, } - outcome, err := agg.Aggregate(nil, observations, 1) + outcome, err := agg.Aggregate(logger.Nop(), nil, observations, 1) require.Nil(t, outcome) require.ErrorContains(t, err, "can't reach consensus on observations with index 0") } diff --git a/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator.go b/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator.go index 3f18e49c6..b7a1f5c6e 100644 --- a/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator.go +++ b/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator.go @@ -55,7 +55,6 @@ type feedConfig struct { type dataFeedsAggregator struct { config aggregatorConfig reportCodec datastreams.ReportCodec - lggr logger.Logger } var _ types.Aggregator = (*dataFeedsAggregator)(nil) @@ -66,18 +65,18 @@ var _ types.Aggregator = (*dataFeedsAggregator)(nil) // // EncodableOutcome is a list of aggregated price points. // Metadata is a map of feedID -> (timestamp, price) representing onchain state (see DataFeedsOutcomeMetadata proto) -func (a *dataFeedsAggregator) Aggregate(previousOutcome *types.AggregationOutcome, observations map[ocrcommon.OracleID][]values.Value, f int) (*types.AggregationOutcome, error) { - allowedSigners, minRequiredSignatures, events := a.extractSignersAndPayloads(observations, f) +func (a *dataFeedsAggregator) Aggregate(lggr logger.Logger, previousOutcome *types.AggregationOutcome, observations map[ocrcommon.OracleID][]values.Value, f int) (*types.AggregationOutcome, error) { + allowedSigners, minRequiredSignatures, events := a.extractSignersAndPayloads(lggr, observations, f) if len(events) > 0 && minRequiredSignatures == 0 { return nil, fmt.Errorf("cannot process non-empty observation payloads with minRequiredSignatures set to 0") } - a.lggr.Debugw("extracted signers", "nAllowedSigners", len(allowedSigners), "minRequired", minRequiredSignatures, "nEvents", len(events)) + lggr.Debugw("extracted signers", "nAllowedSigners", len(allowedSigners), "minRequired", minRequiredSignatures, "nEvents", len(events)) // find latest valid report for each feed ID latestReportPerFeed := make(map[datastreams.FeedID]datastreams.FeedReport) for nodeID, event := range events { mercuryReports, err := a.reportCodec.Unwrap(event) if err != nil { - a.lggr.Errorf("node %d contributed with invalid reports: %v", nodeID, err) + lggr.Errorf("node %d contributed with invalid reports: %v", nodeID, err) continue } for _, report := range mercuryReports { @@ -85,16 +84,16 @@ func (a *dataFeedsAggregator) Aggregate(previousOutcome *types.AggregationOutcom if !ok || report.ObservationTimestamp > latest.ObservationTimestamp { // lazy signature validation if err := a.reportCodec.Validate(report, allowedSigners, minRequiredSignatures); err != nil { - a.lggr.Errorf("node %d contributed with an invalid report: %v", nodeID, err) + lggr.Errorf("node %d contributed with an invalid report: %v", nodeID, err) } else { latestReportPerFeed[datastreams.FeedID(report.FeedID)] = report } } } } - a.lggr.Debugw("collected latestReportPerFeed", "len", len(latestReportPerFeed)) + lggr.Debugw("collected latestReportPerFeed", "len", len(latestReportPerFeed)) - currentState, err := a.initializeCurrentState(previousOutcome) + currentState, err := a.initializeCurrentState(lggr, previousOutcome) if err != nil { return nil, err } @@ -105,7 +104,7 @@ func (a *dataFeedsAggregator) Aggregate(previousOutcome *types.AggregationOutcom allIDs = append(allIDs, feedID) } - a.lggr.Debugw("determined feeds to check", "nFeedIds", len(allIDs)) + lggr.Debugw("determined feeds to check", "nFeedIds", len(allIDs)) // ensure deterministic order of reportsNeedingUpdate sort.Slice(allIDs, func(i, j int) bool { return allIDs[i] < allIDs[j] }) candidateIDs := []string{} @@ -113,12 +112,12 @@ func (a *dataFeedsAggregator) Aggregate(previousOutcome *types.AggregationOutcom previousReportInfo := currentState.FeedInfo[feedIDStr] feedID, err2 := datastreams.NewFeedID(feedIDStr) if err2 != nil { - a.lggr.Errorf("could not convert %s to feedID", feedID) + lggr.Errorw("could not convert %s to feedID", "feedID", feedID) continue } latestReport, ok := latestReportPerFeed[feedID] if !ok { - a.lggr.Errorf("no new Mercury report for feed: %v", feedID) + lggr.Errorw("no new Mercury report for feed", "feedID", feedID) continue } config := a.config.Feeds[feedID] @@ -126,7 +125,17 @@ func (a *dataFeedsAggregator) Aggregate(previousOutcome *types.AggregationOutcom newPrice := big.NewInt(0).SetBytes(latestReport.BenchmarkPrice) currDeviation := deviation(oldPrice, newPrice) currStaleness := latestReport.ObservationTimestamp - previousReportInfo.ObservationTimestamp - a.lggr.Debugw("checking deviation and heartbeat", "feedID", feedID, "currentTs", latestReport.ObservationTimestamp, "oldTs", previousReportInfo.ObservationTimestamp, "oldPrice", oldPrice, "newPrice", newPrice, "deviation", currDeviation) + lggr.Debugw("checking deviation and heartbeat", + "feedID", feedID, + "currentTs", latestReport.ObservationTimestamp, + "oldTs", previousReportInfo.ObservationTimestamp, + "currStaleness", currStaleness, + "heartbeat", config.Heartbeat, + "oldPrice", oldPrice, + "newPrice", newPrice, + "currDeviation", currDeviation, + "deviation", config.Deviation.InexactFloat64(), + ) if currStaleness > int64(config.Heartbeat) || currDeviation > config.Deviation.InexactFloat64() { previousReportInfo.ObservationTimestamp = latestReport.ObservationTimestamp @@ -178,7 +187,7 @@ func (a *dataFeedsAggregator) Aggregate(previousOutcome *types.AggregationOutcom } reportsProto := values.Proto(wrappedReportsNeedingUpdates) - a.lggr.Debugw("Aggregate complete", "nReportsNeedingUpdate", len(reportsNeedingUpdate)) + lggr.Debugw("Aggregate complete", "nReportsNeedingUpdate", len(reportsNeedingUpdate)) return &types.AggregationOutcome{ EncodableOutcome: reportsProto.GetMapValue(), Metadata: marshalledState, @@ -186,7 +195,7 @@ func (a *dataFeedsAggregator) Aggregate(previousOutcome *types.AggregationOutcom }, nil } -func (a *dataFeedsAggregator) initializeCurrentState(previousOutcome *types.AggregationOutcome) (*DataFeedsOutcomeMetadata, error) { +func (a *dataFeedsAggregator) initializeCurrentState(lggr logger.Logger, previousOutcome *types.AggregationOutcome) (*DataFeedsOutcomeMetadata, error) { currentState := &DataFeedsOutcomeMetadata{} if previousOutcome != nil { err := proto.Unmarshal(previousOutcome.Metadata, currentState) @@ -204,43 +213,43 @@ func (a *dataFeedsAggregator) initializeCurrentState(previousOutcome *types.Aggr ObservationTimestamp: 0, // will always trigger an update BenchmarkPrice: big.NewInt(0).Bytes(), } - a.lggr.Debugw("initializing empty onchain state for feed", "feedID", feedID.String()) + lggr.Debugw("initializing empty onchain state for feed", "feedID", feedID.String()) } } // remove obsolete feeds from state for feedID := range currentState.FeedInfo { if _, ok := a.config.Feeds[datastreams.FeedID(feedID)]; !ok { delete(currentState.FeedInfo, feedID) - a.lggr.Debugw("removed obsolete feedID from state", "feedID", feedID) + lggr.Debugw("removed obsolete feedID from state", "feedID", feedID) } } - a.lggr.Debugw("current state initialized", "state", currentState, "previousOutcome", previousOutcome) + lggr.Debugw("current state initialized", "state", currentState, "previousOutcome", previousOutcome) return currentState, nil } -func (a *dataFeedsAggregator) extractSignersAndPayloads(observations map[ocrcommon.OracleID][]values.Value, fConsensus int) ([][]byte, int, map[ocrcommon.OracleID]values.Value) { +func (a *dataFeedsAggregator) extractSignersAndPayloads(lggr logger.Logger, observations map[ocrcommon.OracleID][]values.Value, fConsensus int) ([][]byte, int, map[ocrcommon.OracleID]values.Value) { events := make(map[ocrcommon.OracleID]values.Value) signers := make(map[[addrLen]byte]int) mins := make(map[int]int) for nodeID, nodeObservations := range observations { // we only expect a single observation per node - a Streams trigger event if len(nodeObservations) == 0 || nodeObservations[0] == nil { - a.lggr.Warnf("node %d contributed with empty observations", nodeID) + lggr.Warnf("node %d contributed with empty observations", nodeID) continue } if len(nodeObservations) > 1 { - a.lggr.Warnf("node %d contributed with more than one observation", nodeID) + lggr.Warnf("node %d contributed with more than one observation", nodeID) continue } triggerEvent := &datastreams.StreamsTriggerEvent{} if err := nodeObservations[0].UnwrapTo(triggerEvent); err != nil { - a.lggr.Warnf("could not parse observations from node %d: %v", nodeID, err) + lggr.Warnf("could not parse observations from node %d: %v", nodeID, err) continue } meta := triggerEvent.Metadata currentNodeSigners, err := extractUniqueSigners(meta.Signers) if err != nil { - a.lggr.Warnf("could not extract signers from node %d: %v", nodeID, err) + lggr.Warnf("could not extract signers from node %d: %v", nodeID, err) continue } for signer := range currentNodeSigners { @@ -295,7 +304,7 @@ func deviation(oldPrice, newPrice *big.Int) float64 { return diffFl / oldFl } -func NewDataFeedsAggregator(config values.Map, reportCodec datastreams.ReportCodec, lggr logger.Logger) (types.Aggregator, error) { +func NewDataFeedsAggregator(config values.Map, reportCodec datastreams.ReportCodec) (types.Aggregator, error) { parsedConfig, err := ParseConfig(config) if err != nil { return nil, fmt.Errorf("failed to parse config (%+v): %w", config, err) @@ -303,7 +312,6 @@ func NewDataFeedsAggregator(config values.Map, reportCodec datastreams.ReportCod return &dataFeedsAggregator{ config: parsedConfig, reportCodec: reportCodec, - lggr: logger.Named(lggr, "DataFeedsAggregator"), }, nil } diff --git a/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator_test.go b/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator_test.go index a4b485e49..4d70c1511 100644 --- a/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator_test.go +++ b/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator_test.go @@ -42,11 +42,11 @@ func TestDataFeedsAggregator_Aggregate_TwoRounds(t *testing.T) { require.NoError(t, err) config := getConfig(t, feedIDA.String(), "0.1", heartbeatA) codec := mocks.NewReportCodec(t) - agg, err := datafeeds.NewDataFeedsAggregator(*config, codec, logger.Nop()) + agg, err := datafeeds.NewDataFeedsAggregator(*config, codec) require.NoError(t, err) // first round, empty previous Outcome, empty observations - outcome, err := agg.Aggregate(nil, map[commontypes.OracleID][]values.Value{}, 1) + outcome, err := agg.Aggregate(logger.Nop(), nil, map[commontypes.OracleID][]values.Value{}, 1) require.NoError(t, err) require.False(t, outcome.ShouldReport) @@ -70,7 +70,7 @@ func TestDataFeedsAggregator_Aggregate_TwoRounds(t *testing.T) { } codec.On("Unwrap", mock.Anything).Return(latestMercuryReports, nil) codec.On("Validate", mock.Anything, mock.Anything, mock.Anything).Return(nil) - outcome, err = agg.Aggregate(outcome, map[commontypes.OracleID][]values.Value{1: {mockTriggerEvent}, 2: {mockTriggerEvent}}, 1) + outcome, err = agg.Aggregate(logger.Nop(), outcome, map[commontypes.OracleID][]values.Value{1: {mockTriggerEvent}, 2: {mockTriggerEvent}}, 1) require.NoError(t, err) require.True(t, outcome.ShouldReport) @@ -117,7 +117,7 @@ func TestDataFeedsAggregator_Aggregate_AllowedPartialStaleness(t *testing.T) { require.NoError(t, err) config := getConfig(t, feedIDA.String(), "0.1", heartbeatA) codec := mocks.NewReportCodec(t) - agg, err := datafeeds.NewDataFeedsAggregator(*config, codec, logger.Nop()) + agg, err := datafeeds.NewDataFeedsAggregator(*config, codec) require.NoError(t, err) // first round, both feeds are stale @@ -135,7 +135,7 @@ func TestDataFeedsAggregator_Aggregate_AllowedPartialStaleness(t *testing.T) { } codec.On("Unwrap", mock.Anything).Return(latestReportsRound1, nil).Twice() codec.On("Validate", mock.Anything, mock.Anything, mock.Anything).Return(nil) - outcome, err := agg.Aggregate(nil, map[commontypes.OracleID][]values.Value{1: {mockTriggerEvent}, 2: {mockTriggerEvent}}, 1) + outcome, err := agg.Aggregate(logger.Nop(), nil, map[commontypes.OracleID][]values.Value{1: {mockTriggerEvent}, 2: {mockTriggerEvent}}, 1) require.NoError(t, err) require.True(t, outcome.ShouldReport) require.Equal(t, 2, len(outcome.EncodableOutcome.Fields[datafeeds.TopLevelListOutputFieldName].GetListValue().Fields)) @@ -155,7 +155,7 @@ func TestDataFeedsAggregator_Aggregate_AllowedPartialStaleness(t *testing.T) { } codec.On("Unwrap", mock.Anything).Return(latestReportsRound2, nil).Twice() codec.On("Validate", mock.Anything, mock.Anything, mock.Anything).Return(nil) - outcome, err = agg.Aggregate(outcome, map[commontypes.OracleID][]values.Value{1: {mockTriggerEvent}, 2: {mockTriggerEvent}}, 1) + outcome, err = agg.Aggregate(logger.Nop(), outcome, map[commontypes.OracleID][]values.Value{1: {mockTriggerEvent}, 2: {mockTriggerEvent}}, 1) require.NoError(t, err) require.True(t, outcome.ShouldReport) require.Equal(t, 1, len(outcome.EncodableOutcome.Fields[datafeeds.TopLevelListOutputFieldName].GetListValue().Fields)) @@ -175,7 +175,7 @@ func TestDataFeedsAggregator_Aggregate_AllowedPartialStaleness(t *testing.T) { } codec.On("Unwrap", mock.Anything).Return(latestReportsRound3, nil).Twice() codec.On("Validate", mock.Anything, mock.Anything, mock.Anything).Return(nil) - outcome, err = agg.Aggregate(outcome, map[commontypes.OracleID][]values.Value{1: {mockTriggerEvent}, 2: {mockTriggerEvent}}, 1) + outcome, err = agg.Aggregate(logger.Nop(), outcome, map[commontypes.OracleID][]values.Value{1: {mockTriggerEvent}, 2: {mockTriggerEvent}}, 1) require.NoError(t, err) require.True(t, outcome.ShouldReport) require.Equal(t, 2, len(outcome.EncodableOutcome.Fields[datafeeds.TopLevelListOutputFieldName].GetListValue().Fields)) @@ -192,11 +192,11 @@ func TestDataFeedsAggregator_Aggregate_Failures(t *testing.T) { config := getConfig(t, feedIDA.String(), "0.1", heartbeatA) codec := mocks.NewReportCodec(t) - agg, err := datafeeds.NewDataFeedsAggregator(*config, codec, logger.Nop()) + agg, err := datafeeds.NewDataFeedsAggregator(*config, codec) require.NoError(t, err) // no valid signers - each one should appear at least twice to be valid - _, err = agg.Aggregate(nil, map[commontypes.OracleID][]values.Value{1: {mockTriggerEvent}}, 1) + _, err = agg.Aggregate(logger.Nop(), nil, map[commontypes.OracleID][]values.Value{1: {mockTriggerEvent}}, 1) require.Error(t, err) } diff --git a/pkg/capabilities/consensus/ocr3/reporting_plugin.go b/pkg/capabilities/consensus/ocr3/reporting_plugin.go index 6010575de..923fdb67b 100644 --- a/pkg/capabilities/consensus/ocr3/reporting_plugin.go +++ b/pkg/capabilities/consensus/ocr3/reporting_plugin.go @@ -336,7 +336,7 @@ func (r *reportingPlugin) Outcome(ctx context.Context, outctx ocr3types.OutcomeC continue } - outcome, err2 := agg.Aggregate(workflowOutcome, obs, r.config.F) + outcome, err2 := agg.Aggregate(lggr, workflowOutcome, obs, r.config.F) if err2 != nil { lggr.Errorw("error aggregating outcome", "error", err2) return nil, err @@ -458,14 +458,13 @@ func (r *reportingPlugin) Reports(ctx context.Context, seqNr uint64, outcome ocr continue } - r.lggr.Debugw("generating reports", "len", len(o.CurrentReports), "shouldReport", report.Outcome.ShouldReport, "executionID", report.Id.WorkflowExecutionId) - lggr := logger.With( r.lggr, "workflowID", report.Id.WorkflowId, "executionID", report.Id.WorkflowExecutionId, "shouldReport", report.Outcome.ShouldReport, ) + lggr.Debugw("generating reports", "len", len(o.CurrentReports)) outcome, id := report.Outcome, report.Id @@ -517,24 +516,24 @@ func (r *reportingPlugin) Reports(ctx context.Context, seqNr uint64, outcome ocr mv, err := values.FromMapValueProto(newOutcome.EncodableOutcome) if err != nil { - r.lggr.Errorw("could not decode map from map value proto", "error", err) + lggr.Errorw("could not decode map from map value proto", "error", err) continue } rawReport, err = encoder.Encode(ctx, *mv) if err != nil { if cerr := ctx.Err(); cerr != nil { - r.lggr.Errorw("report encoding cancelled", "err", cerr) + lggr.Errorw("report encoding cancelled", "err", cerr) return nil, cerr } - r.lggr.Errorw("could not encode report for workflow", "error", err) + lggr.Errorw("could not encode report for workflow", "error", err) continue } } infob, err := marshalReportInfo(info, id.KeyId) if err != nil { - r.lggr.Errorw("could not marshal id into ReportWithInfo", "error", err) + lggr.Errorw("could not marshal id into ReportWithInfo", "error", err) continue } diff --git a/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go b/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go index 9b54d61db..d6f8326a8 100644 --- a/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go +++ b/pkg/capabilities/consensus/ocr3/reporting_plugin_test.go @@ -86,7 +86,7 @@ type aggregator struct { outcome *pbtypes.AggregationOutcome } -func (a *aggregator) Aggregate(pout *pbtypes.AggregationOutcome, observations map[commontypes.OracleID][]values.Value, _ int) (*pbtypes.AggregationOutcome, error) { +func (a *aggregator) Aggregate(lggr logger.Logger, pout *pbtypes.AggregationOutcome, observations map[commontypes.OracleID][]values.Value, _ int) (*pbtypes.AggregationOutcome, error) { a.gotObs = observations nm, err := values.NewMap( map[string]any{ diff --git a/pkg/capabilities/consensus/ocr3/types/aggregator.go b/pkg/capabilities/consensus/ocr3/types/aggregator.go index 19a2106d3..af86026ed 100644 --- a/pkg/capabilities/consensus/ocr3/types/aggregator.go +++ b/pkg/capabilities/consensus/ocr3/types/aggregator.go @@ -36,7 +36,7 @@ func (m *Metadata) padWorkflowName() { type Aggregator interface { // Called by the Outcome() phase of OCR reporting. // The inner array of observations corresponds to elements listed in "inputs.observations" section. - Aggregate(previousOutcome *AggregationOutcome, observations map[ocrcommon.OracleID][]values.Value, f int) (*AggregationOutcome, error) + Aggregate(lggr logger.Logger, previousOutcome *AggregationOutcome, observations map[ocrcommon.OracleID][]values.Value, f int) (*AggregationOutcome, error) } func AppendMetadata(outcome *AggregationOutcome, meta *Metadata) (*AggregationOutcome, error) { From 6c3cc4d0dc87f114328a309d786ae2dea8cc974f Mon Sep 17 00:00:00 2001 From: Cedric Date: Mon, 14 Oct 2024 13:28:10 +0100 Subject: [PATCH 9/9] [CAPPL-87] Support breaking a workflow from inside custom compute (#848) --- pkg/capabilities/capabilities.go | 2 +- pkg/workflows/sdk/runtime.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/capabilities/capabilities.go b/pkg/capabilities/capabilities.go index b883b13b1..4c4e6c215 100644 --- a/pkg/capabilities/capabilities.go +++ b/pkg/capabilities/capabilities.go @@ -26,7 +26,7 @@ func (e errStopExecution) Error() string { } func (e errStopExecution) Is(err error) bool { - return err.Error() == errStopExecutionMsg + return strings.Contains(err.Error(), errStopExecutionMsg) } // CapabilityType enum values. diff --git a/pkg/workflows/sdk/runtime.go b/pkg/workflows/sdk/runtime.go index 4344db34f..4eb105245 100644 --- a/pkg/workflows/sdk/runtime.go +++ b/pkg/workflows/sdk/runtime.go @@ -1,6 +1,11 @@ package sdk -import "github.com/smartcontractkit/chainlink-common/pkg/logger" +import ( + "github.com/smartcontractkit/chainlink-common/pkg/capabilities" + "github.com/smartcontractkit/chainlink-common/pkg/logger" +) + +var BreakErr = capabilities.ErrStopExecution type Runtime interface { Logger() logger.Logger