From 4ad5eb95178c3e3ca195bb07af7b10b8664bef35 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Wed, 14 Feb 2024 17:14:32 -0600 Subject: [PATCH] plugins/cmd/chainlink-mercury: (re)move to chainlink-data-streams repo (#11994) --- .github/workflows/ci-core.yml | 4 +- GNUmakefile | 5 -- core/scripts/go.mod | 2 +- core/scripts/go.sum | 4 +- go.md | 2 + go.mod | 2 +- go.sum | 4 +- integration-tests/go.mod | 2 +- integration-tests/go.sum | 4 +- plugins/chainlink.Dockerfile | 10 ++- plugins/cmd/chainlink-mercury/README.md | 19 ------ plugins/cmd/chainlink-mercury/main.go | 39 ----------- plugins/cmd/chainlink-mercury/plugin.go | 89 ------------------------- 13 files changed, 21 insertions(+), 165 deletions(-) delete mode 100644 plugins/cmd/chainlink-mercury/README.md delete mode 100644 plugins/cmd/chainlink-mercury/main.go delete mode 100644 plugins/cmd/chainlink-mercury/plugin.go diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index 25fbc62e268..78d655d4cd8 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -76,13 +76,15 @@ jobs: pushd $(go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-feeds) go install ./cmd/chainlink-feeds popd + pushd $(go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-data-streams) + go install ./mercury/cmd/chainlink-mercury + popd pushd $(go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-solana) go install ./pkg/solana/cmd/chainlink-solana popd pushd $(go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-starknet/relayer) go install ./pkg/chainlink/cmd/chainlink-starknet popd - make install-mercury-loop - name: Increase Race Timeout if: github.event.schedule != '' run: | diff --git a/GNUmakefile b/GNUmakefile index 5d804a75a5c..eab8a73b954 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -62,11 +62,6 @@ chainlink-local-start: install-medianpoc: ## Build & install the chainlink-medianpoc binary. go install $(GOFLAGS) ./plugins/cmd/chainlink-medianpoc -.PHONY: install-mercury-loop -install-mercury-loop: ## Build & install the chainlink-medianpoc binary. - go install $(GOFLAGS) ./plugins/cmd/chainlink-mercury - - .PHONY: docker ## Build the chainlink docker image docker: docker buildx build \ diff --git a/core/scripts/go.mod b/core/scripts/go.mod index 230cdb06a23..86aca87b5fa 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -247,7 +247,7 @@ require ( github.com/sirupsen/logrus v1.9.3 // indirect github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8 // indirect - github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 // indirect + github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336 // indirect github.com/smartcontractkit/chainlink-feeds v0.0.0-20240119021347-3c541a78cdb8 // indirect github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240213161921-c4d342b761b0 // indirect github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0 // indirect diff --git a/core/scripts/go.sum b/core/scripts/go.sum index 8f652ebf15b..6f960e78681 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1173,8 +1173,8 @@ github.com/smartcontractkit/chainlink-common v0.1.7-0.20240213113935-001c2f4befd github.com/smartcontractkit/chainlink-common v0.1.7-0.20240213113935-001c2f4befd4/go.mod h1:pRlQrvcizMmuHAUV4N96oO2e3XbA99JCQELLc6ES160= 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-20231204152908-a6e3fe8ff2a1 h1:xYqRgZO0nMSO8CBCMR0r3WA+LZ4kNL8a6bnbyk/oBtQ= -github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1/go.mod h1:GuPvyXryvbiUZIHmPeLBz4L+yJKeyGUjrDfd1KNne+o= +github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336 h1:j00D0/EqE9HRu+63v7KwUOe4ZxLc4AN5SOJFiinkkH0= +github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336/go.mod h1:umLyYLRGqyIuFfGpEREZP3So6+O8iL35cCCqW+OxX5w= github.com/smartcontractkit/chainlink-feeds v0.0.0-20240119021347-3c541a78cdb8 h1:1BcjXuviSAKttOX7BZoVHRZZGfxqoA2+AL8tykmkdoc= github.com/smartcontractkit/chainlink-feeds v0.0.0-20240119021347-3c541a78cdb8/go.mod h1:vy1L7NybTy2F/Yv7BOh+oZBa1MACD6gzd1+DkcSkfp8= github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240213161921-c4d342b761b0 h1:9IxmR+1NH1WxaX44+t553fOrrZRfxwMVvnDuBIy0tgs= diff --git a/go.md b/go.md index 2a893c2a55e..97330440a54 100644 --- a/go.md +++ b/go.md @@ -51,6 +51,8 @@ flowchart LR chainlink-common --> libocr chainlink-cosmos --> chainlink-common chainlink-cosmos --> libocr + chainlink-data-streams --> chain-selectors + click chain-selectors href "https://github.com/smartcontractkit/chain-selectors" chainlink-data-streams --> chainlink-common chainlink-data-streams --> libocr chainlink-feeds --> chainlink-common diff --git a/go.mod b/go.mod index 846e49e575d..0dfe6060adf 100644 --- a/go.mod +++ b/go.mod @@ -68,7 +68,7 @@ require ( github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240118014648-1ab6a88c9429 github.com/smartcontractkit/chainlink-common v0.1.7-0.20240213113935-001c2f4befd4 github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8 - github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 + github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336 github.com/smartcontractkit/chainlink-feeds v0.0.0-20240119021347-3c541a78cdb8 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240213161921-c4d342b761b0 github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0 diff --git a/go.sum b/go.sum index 2ca0ca1087b..9098236cfa1 100644 --- a/go.sum +++ b/go.sum @@ -1168,8 +1168,8 @@ github.com/smartcontractkit/chainlink-common v0.1.7-0.20240213113935-001c2f4befd github.com/smartcontractkit/chainlink-common v0.1.7-0.20240213113935-001c2f4befd4/go.mod h1:pRlQrvcizMmuHAUV4N96oO2e3XbA99JCQELLc6ES160= 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-20231204152908-a6e3fe8ff2a1 h1:xYqRgZO0nMSO8CBCMR0r3WA+LZ4kNL8a6bnbyk/oBtQ= -github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1/go.mod h1:GuPvyXryvbiUZIHmPeLBz4L+yJKeyGUjrDfd1KNne+o= +github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336 h1:j00D0/EqE9HRu+63v7KwUOe4ZxLc4AN5SOJFiinkkH0= +github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336/go.mod h1:umLyYLRGqyIuFfGpEREZP3So6+O8iL35cCCqW+OxX5w= github.com/smartcontractkit/chainlink-feeds v0.0.0-20240119021347-3c541a78cdb8 h1:1BcjXuviSAKttOX7BZoVHRZZGfxqoA2+AL8tykmkdoc= github.com/smartcontractkit/chainlink-feeds v0.0.0-20240119021347-3c541a78cdb8/go.mod h1:vy1L7NybTy2F/Yv7BOh+oZBa1MACD6gzd1+DkcSkfp8= github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240213161921-c4d342b761b0 h1:9IxmR+1NH1WxaX44+t553fOrrZRfxwMVvnDuBIy0tgs= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 0b88b69a05a..cf6b702b496 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -369,7 +369,7 @@ require ( github.com/sirupsen/logrus v1.9.3 // indirect github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8 // indirect - github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 // indirect + github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336 // indirect github.com/smartcontractkit/chainlink-feeds v0.0.0-20240119021347-3c541a78cdb8 // indirect github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240213161921-c4d342b761b0 // indirect github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index cc2d11d5885..265a3061202 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1505,8 +1505,8 @@ github.com/smartcontractkit/chainlink-common v0.1.7-0.20240213113935-001c2f4befd github.com/smartcontractkit/chainlink-common v0.1.7-0.20240213113935-001c2f4befd4/go.mod h1:pRlQrvcizMmuHAUV4N96oO2e3XbA99JCQELLc6ES160= 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-20231204152908-a6e3fe8ff2a1 h1:xYqRgZO0nMSO8CBCMR0r3WA+LZ4kNL8a6bnbyk/oBtQ= -github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1/go.mod h1:GuPvyXryvbiUZIHmPeLBz4L+yJKeyGUjrDfd1KNne+o= +github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336 h1:j00D0/EqE9HRu+63v7KwUOe4ZxLc4AN5SOJFiinkkH0= +github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240214203158-47dae5de1336/go.mod h1:umLyYLRGqyIuFfGpEREZP3So6+O8iL35cCCqW+OxX5w= github.com/smartcontractkit/chainlink-feeds v0.0.0-20240119021347-3c541a78cdb8 h1:1BcjXuviSAKttOX7BZoVHRZZGfxqoA2+AL8tykmkdoc= github.com/smartcontractkit/chainlink-feeds v0.0.0-20240119021347-3c541a78cdb8/go.mod h1:vy1L7NybTy2F/Yv7BOh+oZBa1MACD6gzd1+DkcSkfp8= github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240213161921-c4d342b761b0 h1:9IxmR+1NH1WxaX44+t553fOrrZRfxwMVvnDuBIy0tgs= diff --git a/plugins/chainlink.Dockerfile b/plugins/chainlink.Dockerfile index cdaa2876d79..a518b37a9e1 100644 --- a/plugins/chainlink.Dockerfile +++ b/plugins/chainlink.Dockerfile @@ -20,11 +20,9 @@ RUN make install-chainlink # Install medianpoc binary RUN make install-medianpoc -# Install the mercury binary -RUN make install-mercury-loop - # 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 RUN go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-solana | xargs -I % ln -s % /chainlink-solana RUN mkdir /chainlink-starknet RUN go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-starknet/relayer | xargs -I % ln -s % /chainlink-starknet/relayer @@ -37,6 +35,10 @@ WORKDIR /chainlink-feeds COPY --from=buildgo /chainlink-feeds . RUN go install ./cmd/chainlink-feeds +WORKDIR /chainlink-data-streams +COPY --from=buildgo /chainlink-data-streams . +RUN go install ./cmd/chainlink-data-streams/mercury/cmd/chainlink-mercury + WORKDIR /chainlink-solana COPY --from=buildgo /chainlink-solana . RUN go install ./pkg/solana/cmd/chainlink-solana @@ -63,6 +65,8 @@ COPY --from=buildgo /go/bin/chainlink-medianpoc /usr/local/bin/ COPY --from=buildplugins /go/bin/chainlink-feeds /usr/local/bin/ ENV CL_MEDIAN_CMD chainlink-feeds +COPY --from=buildplugins /go/bin/chainlink-mercury /usr/local/bin/ +ENV CL_MERCURY_CMD chainlink-mercury COPY --from=buildplugins /go/bin/chainlink-solana /usr/local/bin/ ENV CL_SOLANA_CMD chainlink-solana COPY --from=buildplugins /go/bin/chainlink-starknet /usr/local/bin/ diff --git a/plugins/cmd/chainlink-mercury/README.md b/plugins/cmd/chainlink-mercury/README.md deleted file mode 100644 index 89775cfe911..00000000000 --- a/plugins/cmd/chainlink-mercury/README.md +++ /dev/null @@ -1,19 +0,0 @@ -This directory houses the Mercury LOOPP - -# Running Integration Tests Locally - -Running the tests is as simple as -- building this binary -- setting the CL_MERCURY_CMD env var to the *fully resolved* binary path -- running the test(s) - - -The interesting tests are `TestIntegration_MercuryV*` in ` github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/mercury` - -In detail: -``` -sh - -make install-mercury-loop # builds `mercury` binary in this dir -CL_MERCURY_CMD=/plugins/cmd/mercury/mercury go test -v -timeout 120s -run ^TestIntegration_MercuryV github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/mercury 2>&1 | tee /tmp/mercury_loop.log -``` \ No newline at end of file diff --git a/plugins/cmd/chainlink-mercury/main.go b/plugins/cmd/chainlink-mercury/main.go deleted file mode 100644 index d80aa8ef41c..00000000000 --- a/plugins/cmd/chainlink-mercury/main.go +++ /dev/null @@ -1,39 +0,0 @@ -package main - -import ( - "github.com/hashicorp/go-plugin" - - "github.com/smartcontractkit/chainlink-common/pkg/loop" -) - -const ( - loggerName = "PluginMercury" -) - -func main() { - s := loop.MustNewStartedServer(loggerName) - defer s.Stop() - - p := NewPlugin(s.Logger) - defer s.Logger.ErrorIfFn(p.Close, "Failed to close") - - s.MustRegister(p) - - stop := make(chan struct{}) - defer close(stop) - - plugin.Serve(&plugin.ServeConfig{ - HandshakeConfig: loop.PluginMercuryHandshakeConfig(), - Plugins: map[string]plugin.Plugin{ - loop.PluginMercuryName: &loop.GRPCPluginMercury{ - PluginServer: p, - BrokerConfig: loop.BrokerConfig{ - StopCh: stop, - Logger: s.Logger, - GRPCOpts: s.GRPCOpts, - }, - }, - }, - GRPCServer: s.GRPCOpts.NewServer, - }) -} diff --git a/plugins/cmd/chainlink-mercury/plugin.go b/plugins/cmd/chainlink-mercury/plugin.go deleted file mode 100644 index 07531662ba9..00000000000 --- a/plugins/cmd/chainlink-mercury/plugin.go +++ /dev/null @@ -1,89 +0,0 @@ -package main - -import ( - "context" - - "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" - - "github.com/smartcontractkit/chainlink-common/pkg/logger" - "github.com/smartcontractkit/chainlink-common/pkg/loop" - "github.com/smartcontractkit/chainlink-common/pkg/services" - "github.com/smartcontractkit/chainlink-common/pkg/types" - v1 "github.com/smartcontractkit/chainlink-common/pkg/types/mercury/v1" - v2 "github.com/smartcontractkit/chainlink-common/pkg/types/mercury/v2" - v3 "github.com/smartcontractkit/chainlink-common/pkg/types/mercury/v3" - ds_v1 "github.com/smartcontractkit/chainlink-data-streams/mercury/v1" - ds_v2 "github.com/smartcontractkit/chainlink-data-streams/mercury/v2" - ds_v3 "github.com/smartcontractkit/chainlink-data-streams/mercury/v3" -) - -type Plugin struct { - loop.Plugin - stop services.StopChan -} - -func NewPlugin(lggr logger.Logger) *Plugin { - return &Plugin{Plugin: loop.Plugin{Logger: lggr}, stop: make(services.StopChan)} -} - -func (p *Plugin) NewMercuryV1Factory(ctx context.Context, provider types.MercuryProvider, dataSource v1.DataSource) (types.MercuryPluginFactory, error) { - var ctxVals loop.ContextValues - ctxVals.SetValues(ctx) - lggr := logger.With(p.Logger, ctxVals.Args()...) - - factory := ds_v1.NewFactory(dataSource, lggr, provider.OnchainConfigCodec(), provider.ReportCodecV1()) - - s := &mercuryPluginFactoryService{lggr: logger.Named(lggr, "MercuryV1PluginFactory"), MercuryPluginFactory: factory} - - p.SubService(s) - - return s, nil -} - -func (p *Plugin) NewMercuryV2Factory(ctx context.Context, provider types.MercuryProvider, dataSource v2.DataSource) (types.MercuryPluginFactory, error) { - var ctxVals loop.ContextValues - ctxVals.SetValues(ctx) - lggr := logger.With(p.Logger, ctxVals.Args()...) - - factory := ds_v2.NewFactory(dataSource, lggr, provider.OnchainConfigCodec(), provider.ReportCodecV2()) - - s := &mercuryPluginFactoryService{lggr: logger.Named(lggr, "MercuryV2PluginFactory"), MercuryPluginFactory: factory} - - p.SubService(s) - - return s, nil -} - -func (p *Plugin) NewMercuryV3Factory(ctx context.Context, provider types.MercuryProvider, dataSource v3.DataSource) (types.MercuryPluginFactory, error) { - var ctxVals loop.ContextValues - ctxVals.SetValues(ctx) - lggr := logger.With(p.Logger, ctxVals.Args()...) - - factory := ds_v3.NewFactory(dataSource, lggr, provider.OnchainConfigCodec(), provider.ReportCodecV3()) - - s := &mercuryPluginFactoryService{lggr: logger.Named(lggr, "MercuryV3PluginFactory"), MercuryPluginFactory: factory} - - p.SubService(s) - - return s, nil -} - -type mercuryPluginFactoryService struct { - services.StateMachine - lggr logger.Logger - ocr3types.MercuryPluginFactory -} - -func (r *mercuryPluginFactoryService) Name() string { return r.lggr.Name() } - -func (r *mercuryPluginFactoryService) Start(ctx context.Context) error { - return r.StartOnce("ReportingPluginFactory", func() error { return nil }) -} - -func (r *mercuryPluginFactoryService) Close() error { - return r.StopOnce("ReportingPluginFactory", func() error { return nil }) -} - -func (r *mercuryPluginFactoryService) HealthReport() map[string]error { - return map[string]error{r.Name(): r.Healthy()} -}