From cc959e2e6f665d465033f68782be4da9575d22e0 Mon Sep 17 00:00:00 2001 From: ilija Date: Tue, 2 Jul 2024 22:03:26 +0200 Subject: [PATCH] Handle new CR GetLatestValue changes --- go.mod | 2 +- go.sum | 4 +- integration-tests/go.mod | 10 ++--- integration-tests/go.sum | 16 ++++---- pkg/solana/chainreader/chain_reader.go | 3 +- pkg/solana/chainreader/chain_reader_test.go | 43 +++++++++++++-------- 6 files changed, 44 insertions(+), 34 deletions(-) diff --git a/go.mod b/go.mod index cbbed8acc..16673c257 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ 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.20240625074419-c278d083facf + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240702185825-549bafba6352 github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c github.com/stretchr/testify v1.9.0 go.uber.org/zap v1.26.0 diff --git a/go.sum b/go.sum index 19c680b7f..f5fdd2b67 100644 --- a/go.sum +++ b/go.sum @@ -452,8 +452,8 @@ 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.20240625074419-c278d083facf h1:d9AS/K8RSVG64USb20N/U7RaPOsYPcmuLGJq7iE+caM= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240625074419-c278d083facf/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240702185825-549bafba6352 h1:mfet9cY1OxXSGZAOFOPzN+3Eh2QrJswR085AXarcgiw= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240702185825-549bafba6352/go.mod h1:EWvSuqIJUYXZLEHewC7WCaPylM2jyjF3Q36BZPS4MoI= 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= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 97780a4f6..6d6ef5343 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -14,11 +14,11 @@ require ( github.com/lib/pq v1.10.9 github.com/pelletier/go-toml/v2 v2.2.2 github.com/rs/zerolog v1.31.0 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240627145530-c769d7129f16 - github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240627134229-63de1a005c44 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240702185825-549bafba6352 + github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240701154249-032706dcb7c8 github.com/smartcontractkit/chainlink-testing-framework v1.31.7 github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240628194526-3f8c00a6f188 - github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240628194526-3f8c00a6f188 + github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240702192716-7665badbb90f github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c github.com/smartcontractkit/seth v1.0.12 github.com/stretchr/testify v1.9.0 @@ -359,8 +359,8 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.10 // indirect github.com/smartcontractkit/chainlink-automation v1.0.4 // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240621143432-85370a54b141 // indirect - github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 // indirect - github.com/smartcontractkit/chainlink-feeds v0.0.0-20240522213638-159fb2d99917 // indirect + github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240702144807-761f63e7b527 // indirect + github.com/smartcontractkit/chainlink-feeds v0.0.0-20240702171509-6ad6674ca700 // indirect github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240625074951-06ab5e670dba // indirect github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240405215812-5a72bc9af239 // indirect github.com/smartcontractkit/chainlink-vrf v0.0.0-20240222010609-cd67d123c772 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index c45bf7b41..bda526994 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1407,14 +1407,14 @@ 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.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8= github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240627145530-c769d7129f16 h1:YTE+iBNaRNZplGiiTZFYlnUrVYq1pyQr8Yiz3V3gsN8= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240627145530-c769d7129f16/go.mod h1:EWvSuqIJUYXZLEHewC7WCaPylM2jyjF3Q36BZPS4MoI= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240702185825-549bafba6352 h1:mfet9cY1OxXSGZAOFOPzN+3Eh2QrJswR085AXarcgiw= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240702185825-549bafba6352/go.mod h1:EWvSuqIJUYXZLEHewC7WCaPylM2jyjF3Q36BZPS4MoI= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240621143432-85370a54b141 h1:TMOoYaeSDkkI3jkCH7lKHOZaLkeDuxFTNC+XblD6M0M= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240621143432-85370a54b141/go.mod h1:0UNuO3nDt9MFsZPaHJBEUolxVkN0iC69j1ccDp95e8k= -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-20240522213638-159fb2d99917 h1:MD80ZRCTvxxJ8PBmhtrKoTnky8cVNYrCrIBLVRbrOM0= -github.com/smartcontractkit/chainlink-feeds v0.0.0-20240522213638-159fb2d99917/go.mod h1:jwVxhctE6BgLOSSsVq9wbREpZ8Ev34H+UBxeUhESZRs= +github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240702144807-761f63e7b527 h1:Vs6myS+bpPwb8chUY7XxveJyhvejknhOmhDTddgsK5I= +github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240702144807-761f63e7b527/go.mod h1:KRK7KlAEpmORi+nJgT0vxQVWvlLEBQ6zgzXziZuKvUM= +github.com/smartcontractkit/chainlink-feeds v0.0.0-20240702171509-6ad6674ca700 h1:9ZoXURU4S0V5RbrXHJQkMNf0Cxah4+la2T/tn2+m90I= +github.com/smartcontractkit/chainlink-feeds v0.0.0-20240702171509-6ad6674ca700/go.mod h1:5UI5aQ70Z96O3eI3KeRw0cQKfzZqv2fe+6L5hBPBE3Q= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240625074951-06ab5e670dba h1:YNSlhK5mobyAaw02LPGgIEuS3lXyCTXcc6oaV2L6uUI= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240625074951-06ab5e670dba/go.mod h1:UVFRacRkP7O7TQAzFmR52v5mUlxf+G1ovMlCQAB/cHU= github.com/smartcontractkit/chainlink-testing-framework v1.31.7 h1:Vy4ah8VAfj+Y7vVmhjvwyAO6wG+Fp2vzdkSJwJPMQO4= @@ -1425,8 +1425,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-20240628194526-3f8c00a6f188 h1:Mv3AcLG4oPWy+2pFSP8RNC/MYgv4xdzSxhzhYrDLRFk= github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240628194526-3f8c00a6f188/go.mod h1:dfS7QEXweze1Rhckl9cxXGyE6Ht0POxqe0J0ND7N1tk= -github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240628194526-3f8c00a6f188 h1:Im3F/GiktNZjbznuVxUokKtbLOR+cKUCTBT84N93Nu0= -github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240628194526-3f8c00a6f188/go.mod h1:5Z7DcWYnEB7G5MRUf6EvmN+NbdTGzFxCbzjdt3WfDAE= +github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240702192716-7665badbb90f h1:lvqw4AOjLPhRxw37vMYfR4lq+UuGGkeunUhVuPfyynM= +github.com/smartcontractkit/chainlink/v2 v2.10.0-beta0.0.20240702192716-7665badbb90f/go.mod h1:Rf2zU+afBFKo+F/V5wY6hoTcwosD9prMIVBKJAuOQYw= 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= diff --git a/pkg/solana/chainreader/chain_reader.go b/pkg/solana/chainreader/chain_reader.go index 10d7b0908..31888261e 100644 --- a/pkg/solana/chainreader/chain_reader.go +++ b/pkg/solana/chainreader/chain_reader.go @@ -15,6 +15,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/services" "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink-common/pkg/types/query" + "github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives" "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec" "github.com/smartcontractkit/chainlink-solana/pkg/solana/config" @@ -93,7 +94,7 @@ func (s *SolanaChainReaderService) HealthReport() map[string]error { // 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 { +func (s *SolanaChainReaderService) GetLatestValue(ctx context.Context, contractName, method string, _ primitives.ConfidenceLevel, params any, returnVal any) error { if err := s.Ready(); err != nil { return err } diff --git a/pkg/solana/chainreader/chain_reader_test.go b/pkg/solana/chainreader/chain_reader_test.go index db970f011..a4bc931b9 100644 --- a/pkg/solana/chainreader/chain_reader_test.go +++ b/pkg/solana/chainreader/chain_reader_test.go @@ -24,6 +24,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types" . "github.com/smartcontractkit/chainlink-common/pkg/types/interfacetests" //nolint common practice to import test mods with . "github.com/smartcontractkit/chainlink-common/pkg/types/query" + "github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" "github.com/smartcontractkit/chainlink-solana/pkg/solana/chainreader" @@ -102,7 +103,7 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { var result modifiedStructWithNestedStruct - require.NoError(t, svc.GetLatestValue(ctx, Namespace, NamedMethod, nil, &result)) + require.NoError(t, svc.GetLatestValue(ctx, Namespace, NamedMethod, "", nil, &result)) assert.Equal(t, expected.InnerStruct, result.InnerStruct) assert.Equal(t, expected.Value, result.V) assert.Equal(t, expected.TimeVal, result.TimeVal) @@ -130,7 +131,7 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { var result modifiedStructWithNestedStruct - assert.ErrorIs(t, svc.GetLatestValue(ctx, Namespace, NamedMethod, nil, &result), expectedErr) + assert.ErrorIs(t, svc.GetLatestValue(ctx, Namespace, NamedMethod, "", nil, &result), expectedErr) }) t.Run("Method Not Found", func(t *testing.T) { @@ -151,7 +152,7 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { var result modifiedStructWithNestedStruct - assert.NotNil(t, svc.GetLatestValue(ctx, Namespace, "Unknown", nil, &result)) + assert.NotNil(t, svc.GetLatestValue(ctx, Namespace, "Unknown", "", nil, &result)) }) t.Run("Namespace Not Found", func(t *testing.T) { @@ -172,7 +173,7 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { var result modifiedStructWithNestedStruct - assert.NotNil(t, svc.GetLatestValue(ctx, "Unknown", "Unknown", nil, &result)) + assert.NotNil(t, svc.GetLatestValue(ctx, "Unknown", "Unknown", "", nil, &result)) }) t.Run("Bind Success", func(t *testing.T) { @@ -572,7 +573,7 @@ func (r *wrappedTestChainReader) Name() string { return "wrappedTestChainReader" } -func (r *wrappedTestChainReader) GetLatestValue(ctx context.Context, contractName string, method string, params, returnVal any) error { +func (r *wrappedTestChainReader) GetLatestValue(ctx context.Context, contractName string, method string, confidenceLevel primitives.ConfidenceLevel, params, returnVal any) error { var ( a ag_solana.PublicKey b ag_solana.PublicKey @@ -661,7 +662,7 @@ func (r *wrappedTestChainReader) GetLatestValue(ctx context.Context, contractNam r.client.SetForAddress(b, bts, nil, 50*time.Millisecond) } - return r.service.GetLatestValue(ctx, contractName, method, params, returnVal) + return r.service.GetLatestValue(ctx, contractName, method, confidenceLevel, params, returnVal) } // QueryKey implements the types.ContractReader interface. @@ -691,10 +692,18 @@ func (r *wrappedTestChainReader) CreateContractType(contractName, itemType strin return r.service.CreateContractType(contractName, itemType, forEncoding) } +func (r *chainReaderInterfaceTester) SetUintLatestValue(t *testing.T, _ uint64) { + t.Skip("SetUintLatestValue is not yet supported in Solana") +} + +func (r *chainReaderInterfaceTester) GenerateBlocksTillConfidenceLevel(t *testing.T, _, _ string, _ primitives.ConfidenceLevel) { + t.Skip("GenerateBlocksTillConfidenceLevel is not yet supported in Solana") +} + // SetLatestValue is expected to return the same bound contract and method in the same test // Any setup required for this should be done in Setup. // The contract should take a LatestParams as the params and return the nth TestStruct set -func (r *chainReaderInterfaceTester) SetLatestValue(t *testing.T, testStruct *TestStruct) { +func (r *chainReaderInterfaceTester) SetTestStructLatestValue(t *testing.T, testStruct *TestStruct) { if r.reader == nil { r.reader = &wrappedTestChainReader{ test: t, @@ -711,14 +720,14 @@ func (r *chainReaderInterfaceTester) TriggerEvent(t *testing.T, testStruct *Test func (r *chainReaderInterfaceTester) GetBindings(t *testing.T) []types.BoundContract { return []types.BoundContract{ - {Name: strings.Join([]string{AnyContractName, MethodTakingLatestParamsReturningTestStruct, "0"}, "."), Address: r.address[0], Pending: true}, - {Name: strings.Join([]string{AnyContractName, MethodTakingLatestParamsReturningTestStruct, "1"}, "."), Address: r.address[1], Pending: true}, - {Name: strings.Join([]string{AnyContractName, MethodReturningUint64, "0"}, "."), Address: r.address[2], Pending: true}, - {Name: strings.Join([]string{AnyContractName, DifferentMethodReturningUint64, "0"}, "."), Address: r.address[3], Pending: true}, - {Name: strings.Join([]string{AnyContractName, MethodReturningUint64Slice, "0"}, "."), Address: r.address[4], Pending: true}, - {Name: strings.Join([]string{AnyContractName, MethodReturningSeenStruct, "0"}, "."), Address: r.address[5], Pending: true}, - {Name: strings.Join([]string{AnyContractName, MethodReturningSeenStruct, "1"}, "."), Address: r.address[6], Pending: true}, - {Name: strings.Join([]string{AnySecondContractName, MethodReturningUint64, "0"}, "."), Address: r.address[7], Pending: true}, + {Name: strings.Join([]string{AnyContractName, MethodTakingLatestParamsReturningTestStruct, "0"}, "."), Address: r.address[0]}, + {Name: strings.Join([]string{AnyContractName, MethodTakingLatestParamsReturningTestStruct, "1"}, "."), Address: r.address[1]}, + {Name: strings.Join([]string{AnyContractName, MethodReturningUint64, "0"}, "."), Address: r.address[2]}, + {Name: strings.Join([]string{AnyContractName, DifferentMethodReturningUint64, "0"}, "."), Address: r.address[3]}, + {Name: strings.Join([]string{AnyContractName, MethodReturningUint64Slice, "0"}, "."), Address: r.address[4]}, + {Name: strings.Join([]string{AnyContractName, MethodReturningSeenStruct, "0"}, "."), Address: r.address[5]}, + {Name: strings.Join([]string{AnyContractName, MethodReturningSeenStruct, "1"}, "."), Address: r.address[6]}, + {Name: strings.Join([]string{AnySecondContractName, MethodReturningUint64, "0"}, "."), Address: r.address[7]}, } } @@ -859,12 +868,12 @@ type skipEventsChainReader struct { t *testing.T } -func (s *skipEventsChainReader) GetLatestValue(ctx context.Context, contractName string, method string, params, returnVal any) error { +func (s *skipEventsChainReader) GetLatestValue(ctx context.Context, contractName string, method string, confidenceLevel primitives.ConfidenceLevel, params, returnVal any) error { if contractName == AnyContractName && method == EventName { s.t.Skip("Events are not yet supported in Solana") } - return s.ContractReader.GetLatestValue(ctx, contractName, method, params, returnVal) + return s.ContractReader.GetLatestValue(ctx, contractName, method, confidenceLevel, params, returnVal) } func (s *skipEventsChainReader) QueryKey(ctx context.Context, contractName string, filter query.KeyFilter, limitAndSort query.LimitAndSort, sequenceDataType any) ([]types.Sequence, error) {