Skip to content

Commit

Permalink
BCF-2685: move LOOPP command from core
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Oct 17, 2023
1 parent 214e49a commit 79995af
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 17 deletions.
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ require (
github.com/gagliardetto/solana-go v1.4.1-0.20220428092759-5250b4abbb27
github.com/gagliardetto/treeout v0.1.4
github.com/google/uuid v1.3.1
github.com/hashicorp/go-plugin v1.5.2
github.com/pelletier/go-toml/v2 v2.1.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.17.0
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231016132219-9c6fdb379595
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231017172544-b4fc52327846
github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8
github.com/stretchr/testify v1.8.4
go.uber.org/multierr v1.11.0
Expand Down Expand Up @@ -42,7 +43,6 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.3 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-plugin v1.5.2 // indirect
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand Down Expand Up @@ -79,7 +79,6 @@ require (
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/ratelimit v0.2.0 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/net v0.15.0 // indirect
Expand Down
7 changes: 3 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5g
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231016132219-9c6fdb379595 h1:a6GfS0N4/7X5YQAdne0TLcdSA7w5UwJ1dG0wx6tP3GY=
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231016132219-9c6fdb379595/go.mod h1:mV+ayN6figopkI+9OwHUbBdYMhsrXa+CDvCkEM3FNt0=
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231017172544-b4fc52327846 h1:3KikrKcUFDjZJSdICTxFnc2oaW3X4jTgcxoycmzQ3Mg=
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231017172544-b4fc52327846/go.mod h1:mV+ayN6figopkI+9OwHUbBdYMhsrXa+CDvCkEM3FNt0=
github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss=
github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4=
github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU=
Expand Down Expand Up @@ -506,9 +506,8 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ require (
github.com/rs/zerolog v1.30.0
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
github.com/smartcontractkit/chainlink-env v0.38.3
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231016132219-9c6fdb379595
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231016132516-795ee7ce8d00
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231017172544-b4fc52327846
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231017172647-67d91d916f48
github.com/smartcontractkit/chainlink-testing-framework v1.17.12-0.20231016091231-25809996fbd4
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231016132655-7950ae7befec
github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20231016132655-7950ae7befec
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231017174030-d74ca31b0806
github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20231017174030-d74ca31b0806
github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.23.0
Expand Down
12 changes: 6 additions & 6 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2347,16 +2347,16 @@ github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20230913032705-f924d753cc4
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20230913032705-f924d753cc47/go.mod h1:xMwqRdj5vqYhCJXgKVqvyAwdcqM6ZAEhnwEQ4Khsop8=
github.com/smartcontractkit/chainlink-env v0.38.3 h1:ZtOnwkG622R0VCTxL5V09AnT/QXhlFwkGTjd0Lsfpfg=
github.com/smartcontractkit/chainlink-env v0.38.3/go.mod h1:7z4sw/hN8TxioQCLwFqQdhK3vaOV0a22Qe99z4bRUcg=
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231016132219-9c6fdb379595 h1:a6GfS0N4/7X5YQAdne0TLcdSA7w5UwJ1dG0wx6tP3GY=
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231016132219-9c6fdb379595/go.mod h1:mV+ayN6figopkI+9OwHUbBdYMhsrXa+CDvCkEM3FNt0=
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231017172544-b4fc52327846 h1:3KikrKcUFDjZJSdICTxFnc2oaW3X4jTgcxoycmzQ3Mg=
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231017172544-b4fc52327846/go.mod h1:mV+ayN6figopkI+9OwHUbBdYMhsrXa+CDvCkEM3FNt0=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20230901115736-bbabe542a918 h1:ByVauKFXphRlSNG47lNuxZ9aicu+r8AoNp933VRPpCw=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20230901115736-bbabe542a918/go.mod h1:/yp/sqD8Iz5GU5fcercjrw0ivJF7HDcupYg+Gjr7EPg=
github.com/smartcontractkit/chainlink-testing-framework v1.17.12-0.20231016091231-25809996fbd4 h1:yidN70ecUI3Ydweggk9eHyCSLX7N39YDmYt8GoYx2XU=
github.com/smartcontractkit/chainlink-testing-framework v1.17.12-0.20231016091231-25809996fbd4/go.mod h1:RWlmjwnjIGbQAnRfKwe02Ife82nNI3rZmdI0zgkfbyk=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231016132655-7950ae7befec h1:MPPsc+mPDXPUyj+/fnAl2LpFvr+e4KGuEUE38CO+iEo=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231016132655-7950ae7befec/go.mod h1:wrww/GG1adQOm3myNiTCkqxmh5fhXhWbaioyjOeSZoo=
github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20231016132655-7950ae7befec h1:zfHk2cClAfBNlVA3hgxp4dfyBlHxpuJq65alzxjRO4k=
github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20231016132655-7950ae7befec/go.mod h1:A0c2IZIusJlMxbmXkxKi9q/aDzh4i/5e7aiIz5/nbPk=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231017174030-d74ca31b0806 h1:JWGjtTwv6TuAjMw+5oodxY/GCRwSJ53zyYFq93QhtxA=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231017174030-d74ca31b0806/go.mod h1:gEYJKIjMcpZWNXR25fEkdGrBmcJK7wTKZEAigb1qnwM=
github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20231017174030-d74ca31b0806 h1:GGwC6ra2VyVqrDbpNgS4v7c1PO3c+aMmMQZDzYvRusc=
github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20231017174030-d74ca31b0806/go.mod h1:MMEqII4nRAqutV49I8zLONtm4ugzvEhYWsXjF96/tis=
github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss=
github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4=
github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU=
Expand Down
75 changes: 75 additions & 0 deletions pkg/solana/cmd/chainlink-solana/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package main

import (
"context"
"fmt"
"strings"

"github.com/hashicorp/go-plugin"
"github.com/pelletier/go-toml/v2"

"github.com/smartcontractkit/chainlink-relay/pkg/loop"
"github.com/smartcontractkit/chainlink-solana/pkg/solana"
)

const (
loggerName = "PluginSolana"
)

func main() {
s := loop.MustNewStartedServer(loggerName)
defer s.Stop()

p := &pluginRelayer{Plugin: loop.Plugin{Logger: s.Logger}}
defer s.Logger.ErrorIfFn(p.Close, "Failed to close")

s.MustRegister(p)

stopCh := make(chan struct{})
defer close(stopCh)

plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: loop.PluginRelayerHandshakeConfig(),
Plugins: map[string]plugin.Plugin{
loop.PluginRelayerName: &loop.GRPCPluginRelayer{
PluginServer: p,
BrokerConfig: loop.BrokerConfig{
StopCh: stopCh,
Logger: s.Logger,
GRPCOpts: s.GRPCOpts,
},
},
},
GRPCServer: s.GRPCOpts.NewServer,
})
}

type pluginRelayer struct {
loop.Plugin
}

func (c *pluginRelayer) NewRelayer(ctx context.Context, config string, keystore loop.Keystore) (loop.Relayer, error) {
d := toml.NewDecoder(strings.NewReader(config))
d.DisallowUnknownFields()
var cfg struct {
Solana solana.TOMLConfig
}

if err := d.Decode(&cfg); err != nil {
return nil, fmt.Errorf("failed to decode config toml: %w:\n\t%s", err, config)
}

opts := solana.ChainOpts{
Logger: c.Logger,
KeyStore: keystore,
}
chain, err := solana.NewChain(&cfg.Solana, opts)
if err != nil {
return nil, fmt.Errorf("failed to create chain: %w", err)
}
ra := &loop.RelayerAdapter{Relayer: solana.NewRelayer(c.Logger, chain), RelayerExt: chain}

c.SubService(ra)

return ra, nil
}

0 comments on commit 79995af

Please sign in to comment.