Skip to content

Commit

Permalink
Satisfy Relayer interface with unsupported NewContractReader impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed May 24, 2024
1 parent 45db170 commit 2f13343
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 35 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ require (
github.com/mitchellh/mapstructure v1.5.0
github.com/pelletier/go-toml/v2 v2.1.1
github.com/prometheus/client_golang v1.17.0
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240516150131-e1be553a9d10
github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240524093536-4faf6e011d6d
github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c
github.com/stretchr/testify v1.9.0
go.uber.org/zap v1.26.0
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -452,14 +452,14 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240516150131-e1be553a9d10 h1:IwJKWZHPBJbbh4oI3BGX8VNT3c/ChNiPZ/XI4iq6c0E=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240516150131-e1be553a9d10/go.mod h1:sj0pjL+METqeYL9ibp0T8SXquymlaQsofa6bdfLgXX8=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240524093536-4faf6e011d6d h1:TkEpsNaANB6cdi4ODNOqo9onpe0ddmQxlRQT1dVYnvw=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240524093536-4faf6e011d6d/go.mod h1:DUZccDEW98n+J1mhdWGO7wr/Njad9p9Fzks839JN7Rs=
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=
github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f/go.mod h1:MvMXoufZAtqExNexqi4cjrNYE9MefKddKylxjS+//n0=
github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052 h1:1WFjrrVrWoQ9UpVMh7Mx4jDpzhmo1h8hFUKd9awIhIU=
github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052/go.mod h1:SJEZCHgMCAzzBvo9vMV2DQ9onfEcIJCYSViyP4JI6c4=
github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c h1:lIyMbTaF2H0Q71vkwZHX/Ew4KF2BxiKhqEXwF8rn+KI=
github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c/go.mod h1:fb1ZDVXACvu4frX3APHZaEBp0xi1DIm34DcA0CwTsZM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
Expand Down
12 changes: 6 additions & 6 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ require (
github.com/lib/pq v1.10.9
github.com/pelletier/go-toml/v2 v2.1.1
github.com/rs/zerolog v1.30.0
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240517134904-f4446b816a28
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240521200803-6c605f618787
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240524093536-4faf6e011d6d
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240523174813-45db170c1ccc
github.com/smartcontractkit/chainlink-testing-framework v1.28.15
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240515225456-aeb9f4d50d65
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240521201249-c00f33248fe4
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240524101405-efc810b13911
github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c
github.com/smartcontractkit/seth v1.0.9
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -359,10 +359,10 @@ require (
github.com/slack-go/slack v0.12.2 // indirect
github.com/smartcontractkit/chain-selectors v1.0.10 // indirect
github.com/smartcontractkit/chainlink-automation v1.0.3 // indirect
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240508101745-af1ed7bc8a69 // indirect
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240523163133-2618ef1e488d // indirect
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 // indirect
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240422130241-13c17a91b2ab // indirect
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240508155030-1024f2b55c69 // indirect
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240522213638-159fb2d99917 // indirect
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240523163038-20a173d8e5ec // indirect
github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240328204215-ac91f55f1449 // indirect
github.com/smartcontractkit/chainlink-vrf v0.0.0-20240222010609-cd67d123c772 // indirect
github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1 // indirect
Expand Down
20 changes: 10 additions & 10 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1406,16 +1406,16 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq
github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.3 h1:h/ijT0NiyV06VxYVgcNfsE3+8OEzT3Q0Z9au0z1BPWs=
github.com/smartcontractkit/chainlink-automation v1.0.3/go.mod h1:RjboV0Qd7YP+To+OrzHGXaxUxoSONveCoAK2TQ1INLU=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240517134904-f4446b816a28 h1:Pr8/CdiTNnzRwpYc2z7NpHYbw3Dpl1eqiqt9/J/Bcqc=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240517134904-f4446b816a28/go.mod h1:s+68EchlrXqHKRW3JJgZLEARvzMSKRI5+cE5Zx7pVJA=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240508101745-af1ed7bc8a69 h1:Sec/GpBpUVaTEax1kSHlTvkzF/+d3w5roAQXaj5+SLA=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240508101745-af1ed7bc8a69/go.mod h1:ZQKf+0OLzCLYIisH/OdOIQuFRI6bDuw+jPBTATyHfFM=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240524093536-4faf6e011d6d h1:TkEpsNaANB6cdi4ODNOqo9onpe0ddmQxlRQT1dVYnvw=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240524093536-4faf6e011d6d/go.mod h1:DUZccDEW98n+J1mhdWGO7wr/Njad9p9Fzks839JN7Rs=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240523163133-2618ef1e488d h1:pSguOk4l9YHLnV2R1ioe7rVmrFjqoNwCLFCK3isag94=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240523163133-2618ef1e488d/go.mod h1:WUzz+a/UgUsLOo3fdrSJQpXocLmghNg5LrcJIhRAq8Q=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 h1:xFSv8561jsLtF6gYZr/zW2z5qUUAkcFkApin2mnbYTo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540/go.mod h1:sjAmX8K2kbQhvDarZE1ZZgDgmHJ50s0BBc/66vKY2ek=
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240422130241-13c17a91b2ab h1:Ct1oUlyn03HDUVdFHJqtRGRUujMqdoMzvf/Cjhe30Ag=
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240422130241-13c17a91b2ab/go.mod h1:RPUY7r8GxgzXxS1ijtU1P/fpJomOXztXgUbEziNmbCA=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240508155030-1024f2b55c69 h1:ssh/w3oXWu+C6bE88GuFRC1+0Bx/4ihsbc80XMLrl2k=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240508155030-1024f2b55c69/go.mod h1:VsfjhvWgjxqWja4q+FlXEtX5lu8BSxn10xRo6gi948g=
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240522213638-159fb2d99917 h1:MD80ZRCTvxxJ8PBmhtrKoTnky8cVNYrCrIBLVRbrOM0=
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240522213638-159fb2d99917/go.mod h1:jwVxhctE6BgLOSSsVq9wbREpZ8Ev34H+UBxeUhESZRs=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240523163038-20a173d8e5ec h1:s4WCsBQmE39uYEAgik/Pqzh2MtUPsH3U0Axg3bsZzn4=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240523163038-20a173d8e5ec/go.mod h1:Dk/jiFcvg86hlxhbLQjdPkb6GRr6yEiti9m2koHbZuY=
github.com/smartcontractkit/chainlink-testing-framework v1.28.15 h1:mga7N6jtXQ3UOCt43IdsEnCMBh9xjOWPaE9BiM6kr6Q=
github.com/smartcontractkit/chainlink-testing-framework v1.28.15/go.mod h1:x1zDOz8zcLjEvs9fNA9y/DMguLam/2+CJdpxX0+rM8A=
github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240328204215-ac91f55f1449 h1:fX/xmGm1GBsD1ZZnooNT+eWA0hiTAqFlHzOC5CY4dy8=
Expand All @@ -1424,8 +1424,8 @@ github.com/smartcontractkit/chainlink-vrf v0.0.0-20240222010609-cd67d123c772 h1:
github.com/smartcontractkit/chainlink-vrf v0.0.0-20240222010609-cd67d123c772/go.mod h1:Kn1Hape05UzFZ7bOUnm3GVsHzP0TNrVmpfXYNHdqGGs=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240515225456-aeb9f4d50d65 h1:8AoBDPHOLgZA1JodqysYK/JxcVbjwNhyGfmwzQuep4s=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240515225456-aeb9f4d50d65/go.mod h1:DOeyxJuvSV8No26UHAtmvZTycuGe0S4w/XMMj1EGMV8=
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240521201249-c00f33248fe4 h1:KrQxqehwHCpbJJtltv2iWlVR+cxNzEoBN8EFtbwWtPg=
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240521201249-c00f33248fe4/go.mod h1:10XUZ0WuFDdW+RYD0PdTpHlnaxkh/sqeAtjrAV6vUvQ=
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240524101405-efc810b13911 h1:txjA8yF/ztl/B3BgOIyUfoEnw7k4JJwRQvQ2qZtFqPg=
github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240524101405-efc810b13911/go.mod h1:N+101og7dx8dY81uqMJqpCqu56IY2G55DoYbMGwvruM=
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
10 changes: 5 additions & 5 deletions pkg/solana/chainreader/chain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type SolanaChainReaderService struct {
}

var (
_ services.Service = &SolanaChainReaderService{}
_ types.ChainReader = &SolanaChainReaderService{}
_ services.Service = &SolanaChainReaderService{}
_ types.ContractReader = &SolanaChainReaderService{}
)

// NewChainReaderService is a constructor for a new ChainReaderService for Solana. Returns a nil service on error.
Expand Down Expand Up @@ -91,7 +91,7 @@ func (s *SolanaChainReaderService) HealthReport() map[string]error {
return map[string]error{s.Name(): s.Healthy()}
}

// GetLatestValue implements the types.ChainReader interface and requests and parses on-chain
// GetLatestValue implements the types.ContractReader interface and requests and parses on-chain
// data named by the provided contract, method, and params.
func (s *SolanaChainReaderService) GetLatestValue(ctx context.Context, contractName, method string, params any, returnVal any) error {
if err := s.Ready(); err != nil {
Expand Down Expand Up @@ -169,12 +169,12 @@ func (s *SolanaChainReaderService) GetLatestValue(ctx context.Context, contractN
return nil
}

// QueryKey implements the types.ChainReader interface.
// QueryKey implements the types.ContractReader interface.
func (s *SolanaChainReaderService) QueryKey(ctx context.Context, contractName string, filter query.KeyFilter, limitAndSort query.LimitAndSort, sequenceDataType any) ([]types.Sequence, error) {
return nil, errors.New("unimplemented")
}

// Bind implements the types.ChainReader interface and allows new contract bindings to be added
// Bind implements the types.ContractReader interface and allows new contract bindings to be added
// to the service.
func (s *SolanaChainReaderService) Bind(_ context.Context, bindings []types.BoundContract) error {
return s.bindings.Bind(bindings)
Expand Down
34 changes: 27 additions & 7 deletions pkg/solana/chainreader/chain_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (r *chainReaderInterfaceTester) Setup(t *testing.T) {
}
}

func (r *chainReaderInterfaceTester) GetChainReader(t *testing.T) types.ChainReader {
func (r *chainReaderInterfaceTester) GetChainReader(t *testing.T) types.ContractReader {
client := new(mockedRPCClient)
svc, err := chainreader.NewChainReaderService(logger.Test(t), client, r.conf)
if err != nil {
Expand Down Expand Up @@ -552,6 +552,26 @@ type wrappedTestChainReader struct {
testStructQueue []*TestStruct
}

func (r *wrappedTestChainReader) Start(ctx context.Context) error {
return nil
}

func (r *wrappedTestChainReader) Close() error {
return nil
}

func (r *wrappedTestChainReader) Ready() error {
return nil
}

func (r *wrappedTestChainReader) HealthReport() map[string]error {
return nil
}

func (r *wrappedTestChainReader) Name() string {
return "wrappedTestChainReader"
}

func (r *wrappedTestChainReader) GetLatestValue(ctx context.Context, contractName string, method string, params, returnVal any) error {
var (
a ag_solana.PublicKey
Expand Down Expand Up @@ -644,7 +664,7 @@ func (r *wrappedTestChainReader) GetLatestValue(ctx context.Context, contractNam
return r.service.GetLatestValue(ctx, contractName, method, params, returnVal)
}

// QueryKey implements the types.ChainReader interface.
// QueryKey implements the types.ContractReader interface.
func (r *wrappedTestChainReader) QueryKey(ctx context.Context, contractName string, filter query.KeyFilter, limitAndSort query.LimitAndSort, sequenceDataType any) ([]types.Sequence, error) {
r.test.Skip("QueryKey is not yet supported in Solana")
return nil, nil
Expand Down Expand Up @@ -825,15 +845,15 @@ const (
// Required to allow test skipping to be on the same goroutine
type skipEventsChainReaderTester struct{ ChainReaderInterfaceTester }

func (s *skipEventsChainReaderTester) GetChainReader(t *testing.T) types.ChainReader {
func (s *skipEventsChainReaderTester) GetChainReader(t *testing.T) types.ContractReader {
return &skipEventsChainReader{
ChainReader: s.ChainReaderInterfaceTester.GetChainReader(t),
t: t,
ContractReader: s.ChainReaderInterfaceTester.GetChainReader(t),
t: t,
}
}

type skipEventsChainReader struct {
types.ChainReader
types.ContractReader
t *testing.T
}

Expand All @@ -842,7 +862,7 @@ func (s *skipEventsChainReader) GetLatestValue(ctx context.Context, contractName
s.t.Skip("Events are not yet supported in Solana")
}

return s.ChainReader.GetLatestValue(ctx, contractName, method, params, returnVal)
return s.ContractReader.GetLatestValue(ctx, contractName, method, params, returnVal)
}

func (s *skipEventsChainReader) QueryKey(ctx context.Context, contractName string, filter query.KeyFilter, limitAndSort query.LimitAndSort, sequenceDataType any) ([]types.Sequence, error) {
Expand Down
6 changes: 5 additions & 1 deletion pkg/solana/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ func (r *Relayer) NewConfigProvider(args relaytypes.RelayArgs) (relaytypes.Confi
return configWatcher, err
}

func (r *Relayer) NewContractReader(_ []byte) (relaytypes.ContractReader, error) {
return nil, errors.New("contract reader is not supported for solana")
}

func (r *Relayer) NewMedianProvider(rargs relaytypes.RelayArgs, pargs relaytypes.PluginArgs) (relaytypes.MedianProvider, error) {
ctx, cancel := r.stopCh.NewCtx()
defer cancel()
Expand Down Expand Up @@ -283,7 +287,7 @@ func (p *medianProvider) OnchainConfigCodec() median.OnchainConfigCodec {
return median.StandardOnchainConfigCodec{}
}

func (p *medianProvider) ChainReader() relaytypes.ChainReader {
func (p *medianProvider) ChainReader() relaytypes.ContractReader {
return nil
}

Expand Down

0 comments on commit 2f13343

Please sign in to comment.