From 60de6072c26cc306deba102864b9e94756b2bda2 Mon Sep 17 00:00:00 2001 From: Cedric Date: Fri, 16 Feb 2024 18:16:13 +0000 Subject: [PATCH] [KS-33] Add loop binary (#12050) * WIP * Add loopp binary for OCR3 capability * Update pin * Add binary to dockerfile * Add command to run ocr3 capability * Add make install command to Dockerfile * Add workflow to job type * Bump common * Pick up moved StreamID --- GNUmakefile | 4 ++ core/scripts/go.mod | 2 +- core/scripts/go.sum | 4 +- core/services/job/validate.go | 1 + core/services/ocr2/delegate.go | 2 +- core/services/streams/stream_registry.go | 2 +- go.mod | 2 +- go.sum | 4 +- integration-tests/go.mod | 2 +- integration-tests/go.sum | 4 +- plugins/chainlink.Dockerfile | 6 ++- plugins/cmd/chainlink-ocr3-capability/main.go | 44 +++++++++++++++++++ 12 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 plugins/cmd/chainlink-ocr3-capability/main.go diff --git a/GNUmakefile b/GNUmakefile index eab8a73b954..20f3eb92d51 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -62,6 +62,10 @@ chainlink-local-start: install-medianpoc: ## Build & install the chainlink-medianpoc binary. go install $(GOFLAGS) ./plugins/cmd/chainlink-medianpoc +.PHONY: install-ocr3-capability +install-ocr3-capability: ## Build & install the chainlink-ocr3-capability binary. + go install $(GOFLAGS) ./plugins/cmd/chainlink-ocr3-capability + .PHONY: docker ## Build the chainlink docker image docker: docker buildx build \ diff --git a/core/scripts/go.mod b/core/scripts/go.mod index c5136dbdb14..2c877299deb 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -20,7 +20,7 @@ require ( github.com/pelletier/go-toml/v2 v2.1.1 github.com/shopspring/decimal v1.3.1 github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240118014648-1ab6a88c9429 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216130301-0c136fa494a9 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216174848-c7f1809138d6 github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20240215150045-fe2ba71b2f0a diff --git a/core/scripts/go.sum b/core/scripts/go.sum index e00dca85002..7a4faf31ce3 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1169,8 +1169,8 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240118014648-1ab6a88c9429 h1:xkejUBZhcBpBrTSfxc91Iwzadrb6SXw8ks69bHIQ9Ww= github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240118014648-1ab6a88c9429/go.mod h1:wJmVvDf4XSjsahWtfUq3wvIAYEAuhr7oxmxYnEL/LGQ= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216130301-0c136fa494a9 h1:8YWKoBemWvERQp6R6NoGVTVOg/4yuoKaSHdil/ym9uo= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216130301-0c136fa494a9/go.mod h1:yKWUC5vRyIB+yQdmpOAf2y2A0hJ43uENKVgljk5Ve3g= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216174848-c7f1809138d6 h1:hpNkTpLtwWXKqguf7wYqetxpmxY/bSO+1PLpY8VBu2w= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216174848-c7f1809138d6/go.mod h1:6aXWSEQawX2oZXcPPOdxnEGufAhj7PqPKolXf6ijRGA= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8 h1:I326nw5GwHQHsLKHwtu5Sb9EBLylC8CfUd7BFAS0jtg= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8/go.mod h1:a65NtrK4xZb01mf0dDNghPkN2wXgcqFQ55ADthVBgMc= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336 h1:j00D0/EqE9HRu+63v7KwUOe4ZxLc4AN5SOJFiinkkH0= diff --git a/core/services/job/validate.go b/core/services/job/validate.go index f108031f72e..47c9bb5aba6 100644 --- a/core/services/job/validate.go +++ b/core/services/job/validate.go @@ -27,6 +27,7 @@ var ( Stream: {}, VRF: {}, Webhook: {}, + Workflow: {}, } ) diff --git a/core/services/ocr2/delegate.go b/core/services/ocr2/delegate.go index 55e026bd114..754f48013bd 100644 --- a/core/services/ocr2/delegate.go +++ b/core/services/ocr2/delegate.go @@ -602,7 +602,7 @@ func (d *Delegate) newServicesGenericPlugin( ps, err2 := relay.NewProviderServer(provider, types.OCR2PluginType(pCfg.ProviderType), d.lggr) if err2 != nil { - return nil, fmt.Errorf("cannot start EVM provider server: %s", err) + return nil, fmt.Errorf("cannot start EVM provider server: %s", err2) } providerClientConn, err2 = ps.GetConn() if err2 != nil { diff --git a/core/services/streams/stream_registry.go b/core/services/streams/stream_registry.go index c4795caa304..bc63e98e288 100644 --- a/core/services/streams/stream_registry.go +++ b/core/services/streams/stream_registry.go @@ -4,7 +4,7 @@ import ( "fmt" "sync" - commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types/llo" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" diff --git a/go.mod b/go.mod index 1e4b658d84f..396201fdede 100644 --- a/go.mod +++ b/go.mod @@ -67,7 +67,7 @@ require ( github.com/shopspring/decimal v1.3.1 github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240118014648-1ab6a88c9429 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216130301-0c136fa494a9 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216174848-c7f1809138d6 github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8 github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336 github.com/smartcontractkit/chainlink-feeds v0.0.0-20240119021347-3c541a78cdb8 diff --git a/go.sum b/go.sum index 85b56c9f232..e02add4ee89 100644 --- a/go.sum +++ b/go.sum @@ -1164,8 +1164,8 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240118014648-1ab6a88c9429 h1:xkejUBZhcBpBrTSfxc91Iwzadrb6SXw8ks69bHIQ9Ww= github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240118014648-1ab6a88c9429/go.mod h1:wJmVvDf4XSjsahWtfUq3wvIAYEAuhr7oxmxYnEL/LGQ= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216130301-0c136fa494a9 h1:8YWKoBemWvERQp6R6NoGVTVOg/4yuoKaSHdil/ym9uo= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216130301-0c136fa494a9/go.mod h1:yKWUC5vRyIB+yQdmpOAf2y2A0hJ43uENKVgljk5Ve3g= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216174848-c7f1809138d6 h1:hpNkTpLtwWXKqguf7wYqetxpmxY/bSO+1PLpY8VBu2w= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216174848-c7f1809138d6/go.mod h1:6aXWSEQawX2oZXcPPOdxnEGufAhj7PqPKolXf6ijRGA= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8 h1:I326nw5GwHQHsLKHwtu5Sb9EBLylC8CfUd7BFAS0jtg= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8/go.mod h1:a65NtrK4xZb01mf0dDNghPkN2wXgcqFQ55ADthVBgMc= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336 h1:j00D0/EqE9HRu+63v7KwUOe4ZxLc4AN5SOJFiinkkH0= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 1e3567c8902..ccb0810ab50 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -24,7 +24,7 @@ require ( github.com/segmentio/ksuid v1.0.4 github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240118014648-1ab6a88c9429 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216130301-0c136fa494a9 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216174848-c7f1809138d6 github.com/smartcontractkit/chainlink-testing-framework v1.23.2 github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 415fee4117e..ed933fab701 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1503,8 +1503,8 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240118014648-1ab6a88c9429 h1:xkejUBZhcBpBrTSfxc91Iwzadrb6SXw8ks69bHIQ9Ww= github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240118014648-1ab6a88c9429/go.mod h1:wJmVvDf4XSjsahWtfUq3wvIAYEAuhr7oxmxYnEL/LGQ= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216130301-0c136fa494a9 h1:8YWKoBemWvERQp6R6NoGVTVOg/4yuoKaSHdil/ym9uo= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216130301-0c136fa494a9/go.mod h1:yKWUC5vRyIB+yQdmpOAf2y2A0hJ43uENKVgljk5Ve3g= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216174848-c7f1809138d6 h1:hpNkTpLtwWXKqguf7wYqetxpmxY/bSO+1PLpY8VBu2w= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216174848-c7f1809138d6/go.mod h1:6aXWSEQawX2oZXcPPOdxnEGufAhj7PqPKolXf6ijRGA= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8 h1:I326nw5GwHQHsLKHwtu5Sb9EBLylC8CfUd7BFAS0jtg= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8/go.mod h1:a65NtrK4xZb01mf0dDNghPkN2wXgcqFQ55ADthVBgMc= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336 h1:j00D0/EqE9HRu+63v7KwUOe4ZxLc4AN5SOJFiinkkH0= diff --git a/plugins/chainlink.Dockerfile b/plugins/chainlink.Dockerfile index cdfc3ee1356..4d1e2f4e6df 100644 --- a/plugins/chainlink.Dockerfile +++ b/plugins/chainlink.Dockerfile @@ -20,6 +20,9 @@ RUN make install-chainlink # Install medianpoc binary RUN make install-medianpoc +# Install ocr3-capability binary +RUN make install-ocr3-capability + # Link LOOP Plugin source dirs with simple names RUN go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-feeds | xargs -I % ln -s % /chainlink-feeds RUN go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-data-streams | xargs -I % ln -s % /chainlink-data-streams @@ -62,6 +65,7 @@ RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ COPY --from=buildgo /go/bin/chainlink /usr/local/bin/ COPY --from=buildgo /go/bin/chainlink-medianpoc /usr/local/bin/ +COPY --from=buildgo /go/bin/chainlink-ocr3-capability /usr/local/bin/ COPY --from=buildplugins /go/bin/chainlink-feeds /usr/local/bin/ ENV CL_MEDIAN_CMD chainlink-feeds @@ -90,4 +94,4 @@ ENTRYPOINT ["chainlink"] HEALTHCHECK CMD curl -f http://localhost:6688/health || exit 1 -CMD ["local", "node"] \ No newline at end of file +CMD ["local", "node"] diff --git a/plugins/cmd/chainlink-ocr3-capability/main.go b/plugins/cmd/chainlink-ocr3-capability/main.go new file mode 100644 index 00000000000..ac8bb6454f3 --- /dev/null +++ b/plugins/cmd/chainlink-ocr3-capability/main.go @@ -0,0 +1,44 @@ +package main + +import ( + "github.com/hashicorp/go-plugin" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3" + "github.com/smartcontractkit/chainlink-common/pkg/loop" + "github.com/smartcontractkit/chainlink-common/pkg/loop/reportingplugins" + ocr3rp "github.com/smartcontractkit/chainlink-common/pkg/loop/reportingplugins/ocr3" + "github.com/smartcontractkit/chainlink-common/pkg/types" + "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" +) + +const ( + loggerName = "PluginOCR3Capability" +) + +func main() { + s := loop.MustNewStartedServer(loggerName) + defer s.Stop() + + p := ocr3.NewOCR3(s.Logger, evm.NewEVMEncoder) + defer s.Logger.ErrorIfFn(p.Close, "Failed to close") + + s.MustRegister(p) + + stop := make(chan struct{}) + defer close(stop) + + plugin.Serve(&plugin.ServeConfig{ + HandshakeConfig: reportingplugins.ReportingPluginHandshakeConfig(), + Plugins: map[string]plugin.Plugin{ + ocr3rp.PluginServiceName: &ocr3rp.GRPCService[types.PluginProvider]{ + PluginServer: p, + BrokerConfig: loop.BrokerConfig{ + Logger: s.Logger, + StopCh: stop, + GRPCOpts: s.GRPCOpts, + }, + }, + }, + GRPCServer: s.GRPCOpts.NewServer, + }) +}