Skip to content

Commit

Permalink
add context
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Jan 13, 2024
1 parent cbb0b10 commit 370f7a5
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 77 deletions.
12 changes: 7 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/smartcontractkit/chainlink-solana

go 1.21

replace github.com/smartcontractkit/libocr => github.com/jmank88/libocr v0.0.0-20240112230745-2fac9a2947d0

require (
github.com/davecgh/go-spew v1.1.1
github.com/gagliardetto/binary v0.7.1
Expand All @@ -10,15 +12,15 @@ require (
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/pelletier/go-toml/v2 v2.1.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.17.0
github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327
github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112231006-32ff16a7c10b
github.com/smartcontractkit/libocr v0.0.0-20231130143053-c5102a9c0fb7
github.com/stretchr/testify v1.8.4
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.26.0
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad
golang.org/x/sync v0.3.0
gopkg.in/guregu/null.v4 v4.0.0
)
Expand Down Expand Up @@ -50,7 +52,7 @@ require (
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
github.com/klauspost/compress v1.15.11 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/linkedin/goavro/v2 v2.12.0 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
github.com/jmank88/libocr v0.0.0-20240112230745-2fac9a2947d0 h1:ON2l755Emwb9RFUYhIhQZXkraFfRdFfGfAn7Ded6akQ=
github.com/jmank88/libocr v0.0.0-20240112230745-2fac9a2947d0/go.mod h1:WcuWFMskcGK0MYZuH5hEhGJOzdJRUFeNEM4PAKlejI4=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
Expand All @@ -290,8 +292,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c=
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw=
github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down Expand Up @@ -377,8 +379,8 @@ github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b
github.com/opencontainers/runc v1.1.3/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -423,14 +425,12 @@ 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.20231218150613-43bf581ae327 h1:7P+djpKBMQ2Cpv1ieUQdkZvDLt6owPvniHfMHSPFYjQ=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112231006-32ff16a7c10b h1:cHLLVH8mUF140H9MI9nEuh/gsphFpT7hFPHuBCDNOss=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112231006-32ff16a7c10b/go.mod h1:fzgN322Qq4jCFAx/nrTi+TYvUOp6SYhpPPhIKepuzac=
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-20230925165524-ffa38fe11ef8 h1:R9NkVN+1fooUJFsN9zj9gDY1B+zv54zNO785RQZRVfE=
github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8/go.mod h1:2lyRkw/qLQgUWlrWWmq5nj0y90rWeO6Y+v+fCakRgb0=
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 Expand Up @@ -552,8 +552,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 h1:5llv2sWeaMSnA3w2kS57ouQQ4pudlXrR0dCgw51QK9o=
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad h1:g0bG7Z4uG+OgH2QDODnjp6ggkk1bJDsINcuWmJN1iJU=
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ require (
github.com/lib/pq v1.10.9
github.com/onsi/gomega v1.30.0
github.com/rs/zerolog v1.30.0
github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231215215420-f0b4a00004c1
github.com/smartcontractkit/chainlink-testing-framework v1.22.0
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231215220731-a4091a3e4d3c
github.com/smartcontractkit/chainlink/v2 v2.8.0-beta0.0.20231215220731-a4091a3e4d3c
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112231006-32ff16a7c10b
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231206154215-ec1718b7df3e
github.com/smartcontractkit/chainlink-testing-framework v1.21.0
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231212105216-0c63446ae535
github.com/smartcontractkit/chainlink/v2 v2.8.0-beta0.0.20231212105216-0c63446ae535
github.com/smartcontractkit/libocr v0.0.0-20231130143053-c5102a9c0fb7
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.23.0
Expand Down
16 changes: 8 additions & 8 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1336,8 +1336,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.1 h1:vVjBFq2Zsz21kPy1Pb0wpjF9zrbJX+zjXphDeeR4XZk=
github.com/smartcontractkit/chainlink-automation v1.0.1/go.mod h1:INSchkV3ntyDdlZKGWA030MPDpp6pbeuiRkRKYFCm2k=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 h1:7P+djpKBMQ2Cpv1ieUQdkZvDLt6owPvniHfMHSPFYjQ=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112231006-32ff16a7c10b h1:cHLLVH8mUF140H9MI9nEuh/gsphFpT7hFPHuBCDNOss=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112231006-32ff16a7c10b/go.mod h1:fzgN322Qq4jCFAx/nrTi+TYvUOp6SYhpPPhIKepuzac=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231218175426-6e0427c661e5 h1:kBnmjv3fxU7krVIqZFvo1m4F6qBc4vPURQFX/mcChhI=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231218175426-6e0427c661e5/go.mod h1:EoM7wQ81mov7wsUzG4zEnnr0EH0POEo/I0hRDg433TU=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 h1:xYqRgZO0nMSO8CBCMR0r3WA+LZ4kNL8a6bnbyk/oBtQ=
Expand All @@ -1346,14 +1346,14 @@ github.com/smartcontractkit/chainlink-feeds v0.0.0-20231127231053-2232d3a6766d h
github.com/smartcontractkit/chainlink-feeds v0.0.0-20231127231053-2232d3a6766d/go.mod h1:YPAfLNowdBwiKiYOwgwtbJHi8AJWbcxkbOY0ItAvkfc=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231218164059-e21436ef6202 h1:pamVRnh8ObftCY9gIxCITv34opH2GB1MbgGSGGyx6Bc=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231218164059-e21436ef6202/go.mod h1:YWKpf+hO9XMlzIWQT8yGoky3aeFLzMUVsjbs80LD77M=
github.com/smartcontractkit/chainlink-testing-framework v1.22.0 h1:Lur628wkrceWgcLmxGZe7Mauwxht4YO71hX9Jj5YslE=
github.com/smartcontractkit/chainlink-testing-framework v1.22.0/go.mod h1:yu6qqrppNJfutQV37fiSs4eS0uQP5QT0ebi3tlIgWN0=
github.com/smartcontractkit/chainlink-testing-framework v1.21.0 h1:MrtpGMgPpcRX06FtDEj14Vokoo6Sx8e0/D6AA9LxCgM=
github.com/smartcontractkit/chainlink-testing-framework v1.21.0/go.mod h1:9SCqZ+lcWZNEofpPgasQ+wUF6A6fFgZvWmhqQJwFYV0=
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8=
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868/go.mod h1:Kn1Hape05UzFZ7bOUnm3GVsHzP0TNrVmpfXYNHdqGGs=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231215220731-a4091a3e4d3c h1:k7qGZLRhQihZr+GmXXJXNaTJxh0KSDOGR3gPtiiPz5I=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231215220731-a4091a3e4d3c/go.mod h1:4N7BFfL8/AogYSwwLAW2KmKCPQbewZ6LcKqngFbVCEE=
github.com/smartcontractkit/chainlink/v2 v2.8.0-beta0.0.20231215220731-a4091a3e4d3c h1:XlDSTa5mopZeVsNGNzdHEZKfWm6IPhL6GfDpt+7xizg=
github.com/smartcontractkit/chainlink/v2 v2.8.0-beta0.0.20231215220731-a4091a3e4d3c/go.mod h1:+P6mpDYbhL8FVWlgYuQvjOtBd9XhazoFW1+1iljCn4M=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231212105216-0c63446ae535 h1:NnkmF2fr+3db8E4TzD9u0yhqv8dOz/AG7dG6fFmut7U=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231212105216-0c63446ae535/go.mod h1:YOO4t5xan+oU616LoRalZ2UF0aAYGwX3UCDXz3paLyg=
github.com/smartcontractkit/chainlink/v2 v2.8.0-beta0.0.20231212105216-0c63446ae535 h1:VuZjQMpXKtNQYDOR7E4suHclr4xLgC389BzmoVwYtKA=
github.com/smartcontractkit/chainlink/v2 v2.8.0-beta0.0.20231212105216-0c63446ae535/go.mod h1:1eFyYniqXFSkxbtu9/kE8kIoFh9N2WgwhaAmO0INl34=
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
2 changes: 1 addition & 1 deletion pkg/monitoring/source_envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (s *envelopeSource) Fetch(ctx context.Context) (interface{}, error) {
if err != nil {
return nil, fmt.Errorf("failed to fetch state from on-chain: %w", err)
}
contractConfig, err := pkgSolana.ConfigFromState(state)
contractConfig, err := pkgSolana.ConfigFromState(ctx, state)
if err != nil {
return nil, fmt.Errorf("failed to decode ContractConfig from on-chain state: %w", err)
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/solana/config_digester.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package solana

import (
"context"
"crypto/sha256"
"encoding/binary"
"fmt"
Expand All @@ -22,7 +23,7 @@ type OffchainConfigDigester struct {
}

// ConfigDigest is meant to do the same thing as config_digest_from_data from the program.
func (d OffchainConfigDigester) ConfigDigest(cfg types.ContractConfig) (types.ConfigDigest, error) {
func (d OffchainConfigDigester) ConfigDigest(ctx context.Context, cfg types.ContractConfig) (types.ConfigDigest, error) {
digest := types.ConfigDigest{}
buf := sha256.New()

Expand Down Expand Up @@ -87,7 +88,7 @@ func (d OffchainConfigDigester) ConfigDigest(cfg types.ContractConfig) (types.Co
return digest, fmt.Errorf("incorrect hash size %d, expected %d", n, len(digest))
}

pre, err := d.ConfigDigestPrefix()
pre, err := d.ConfigDigestPrefix(ctx)
if err != nil {
return digest, err
}
Expand All @@ -97,6 +98,6 @@ func (d OffchainConfigDigester) ConfigDigest(cfg types.ContractConfig) (types.Co
}

// This should return the same constant value on every invocation
func (OffchainConfigDigester) ConfigDigestPrefix() (types.ConfigDigestPrefix, error) {
func (OffchainConfigDigester) ConfigDigestPrefix(ctx context.Context) (types.ConfigDigestPrefix, error) {
return types.ConfigDigestPrefixSolana, nil
}
6 changes: 4 additions & 2 deletions pkg/solana/config_digester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
bin "github.com/gagliardetto/binary"
"github.com/gagliardetto/solana-go"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
)

func TestConfigDigester(t *testing.T) {
Expand All @@ -22,10 +24,10 @@ func TestConfigDigester(t *testing.T) {
var state State
err = bin.NewBorshDecoder(mockState.Raw).Decode(&state)
require.NoError(t, err)
config, err := ConfigFromState(state)
config, err := ConfigFromState(tests.Context(t), state)
require.NoError(t, err)

actualDigest, err := digester.ConfigDigest(config)
actualDigest, err := digester.ConfigDigest(tests.Context(t), config)
require.NoError(t, err)

expectedDigest := mockState.ConfigDigestHex
Expand Down
6 changes: 3 additions & 3 deletions pkg/solana/config_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (c *ConfigTracker) LatestConfigDetails(ctx context.Context) (changedInBlock
return state.Config.LatestConfigBlockNumber, state.Config.LatestConfigDigest, err
}

func ConfigFromState(state State) (types.ContractConfig, error) {
func ConfigFromState(ctx context.Context, state State) (types.ContractConfig, error) {
pubKeys := []types.OnchainPublicKey{}
accounts := []types.Account{}
oracles, err := state.Oracles.Data()
Expand All @@ -43,7 +43,7 @@ func ConfigFromState(state State) (types.ContractConfig, error) {
Max: state.Config.MaxAnswer.BigInt(),
}

onchainConfig, err := median.StandardOnchainConfigCodec{}.Encode(onchainConfigStruct)
onchainConfig, err := median.StandardOnchainConfigCodec{}.Encode(ctx, onchainConfigStruct)
if err != nil {
return types.ContractConfig{}, err
}
Expand All @@ -70,7 +70,7 @@ func (c *ConfigTracker) LatestConfig(ctx context.Context, changedInBlock uint64)
if err != nil {
return types.ContractConfig{}, err
}
return ConfigFromState(state)
return ConfigFromState(ctx, state)
}

// LatestBlockHeight returns the height of the most recent block in the chain.
Expand Down
43 changes: 20 additions & 23 deletions pkg/solana/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,15 @@ type TxManager interface {
var _ relaytypes.Relayer = &Relayer{}

type Relayer struct {
lggr logger.Logger
chain Chain
ctx context.Context
cancel func()
lggr logger.Logger
chain Chain
}

// Note: constructed in core
func NewRelayer(lggr logger.Logger, chain Chain) *Relayer {
ctx, cancel := context.WithCancel(context.Background())
return &Relayer{
lggr: lggr,
chain: chain,
ctx: ctx,
cancel: cancel,
lggr: lggr,
chain: chain,
}
}

Expand All @@ -50,47 +45,49 @@ func (r *Relayer) Name() string {
}

// Start starts the relayer respecting the given context.
func (r *Relayer) Start(context.Context) error {
func (r *Relayer) Start(ctx context.Context) error {
// No subservices started on relay start, but when the first job is started
if r.chain == nil {
return errors.New("Solana unavailable")
}
return nil
return r.chain.Start(ctx)
}

// Close will close all open subservices
func (r *Relayer) Close() error {
r.cancel()
return nil
}
func (r *Relayer) Close() error { return r.chain.Close() }

func (r *Relayer) Ready() error {
return r.chain.Ready()
}

// Healthy only if all subservices are healthy
func (r *Relayer) Healthy() error { return nil }

func (r *Relayer) HealthReport() map[string]error {
return map[string]error{r.Name(): r.Healthy()}
hp := map[string]error{r.Name(): r.Healthy()}
services.CopyHealth(hp, r.chain.HealthReport())
return hp
}

func (r *Relayer) NewAutomationProvider(ctx context.Context, rargs relaytypes.RelayArgs, pargs relaytypes.PluginArgs) (relaytypes.AutomationProvider, error) {
return nil, errors.New("automation is not supported for solana")
}

func (r *Relayer) NewMercuryProvider(rargs relaytypes.RelayArgs, pargs relaytypes.PluginArgs) (relaytypes.MercuryProvider, error) {
func (r *Relayer) NewMercuryProvider(ctx context.Context, rargs relaytypes.RelayArgs, pargs relaytypes.PluginArgs) (relaytypes.MercuryProvider, error) {
return nil, errors.New("mercury is not supported for solana")
}

func (r *Relayer) NewConfigProvider(args relaytypes.RelayArgs) (relaytypes.ConfigProvider, error) {
configWatcher, err := newConfigProvider(r.ctx, r.lggr, r.chain, args)
func (r *Relayer) NewConfigProvider(ctx context.Context, args relaytypes.RelayArgs) (relaytypes.ConfigProvider, error) {
configWatcher, err := newConfigProvider(ctx, r.lggr, r.chain, args)
if err != nil {
// Never return (*configProvider)(nil)
return nil, err
}
return configWatcher, err
}

func (r *Relayer) NewMedianProvider(rargs relaytypes.RelayArgs, pargs relaytypes.PluginArgs) (relaytypes.MedianProvider, error) {
func (r *Relayer) NewMedianProvider(ctx context.Context, rargs relaytypes.RelayArgs, pargs relaytypes.PluginArgs) (relaytypes.MedianProvider, error) {
lggr := relaylogger.Named(r.lggr, "MedianProvider")
configWatcher, err := newConfigProvider(r.ctx, lggr, r.chain, rargs)
configWatcher, err := newConfigProvider(ctx, lggr, r.chain, rargs)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -136,7 +133,7 @@ func (r *Relayer) NewMedianProvider(rargs relaytypes.RelayArgs, pargs relaytypes
}, nil
}

func (r *Relayer) NewFunctionsProvider(rargs relaytypes.RelayArgs, pargs relaytypes.PluginArgs) (relaytypes.FunctionsProvider, error) {
func (r *Relayer) NewFunctionsProvider(ctx context.Context, rargs relaytypes.RelayArgs, pargs relaytypes.PluginArgs) (relaytypes.FunctionsProvider, error) {
return nil, errors.New("functions are not supported for solana")
}

Expand Down

0 comments on commit 370f7a5

Please sign in to comment.