diff --git a/integration-tests/common/common.go b/integration-tests/common/common.go index 2efcd1db5..7441f67c0 100644 --- a/integration-tests/common/common.go +++ b/integration-tests/common/common.go @@ -23,6 +23,7 @@ import ( "github.com/smartcontractkit/chainlink-env/pkg/helm/chainlink" mock_adapter "github.com/smartcontractkit/chainlink-env/pkg/helm/mock-adapter" "github.com/smartcontractkit/chainlink-env/pkg/helm/sol" + "github.com/smartcontractkit/chainlink-solana/pkg/solana" "github.com/smartcontractkit/libocr/offchainreporting2/confighelper" "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" @@ -33,7 +34,6 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" "github.com/smartcontractkit/chainlink/integration-tests/utils" - "github.com/smartcontractkit/chainlink/v2/core/chains/solana" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/store/models" @@ -495,7 +495,7 @@ func BuildNodeContractPairID(node *client.ChainlinkClient, ocr2Addr string) (str } func (c *Common) DefaultNodeConfig() *cl.Config { - solConfig := solana.SolanaConfig{ + solConfig := solana.TOMLConfig{ Enabled: utils.Ptr(true), ChainID: utils.Ptr(c.ChainId), Nodes: []*solcfg.Node{ @@ -506,7 +506,7 @@ func (c *Common) DefaultNodeConfig() *cl.Config { }, } baseConfig := node.NewBaseConfig() - baseConfig.Solana = solana.SolanaConfigs{ + baseConfig.Solana = solana.TOMLConfigs{ &solConfig, } baseConfig.OCR2.Enabled = utils.Ptr(true) diff --git a/integration-tests/go.mod b/integration-tests/go.mod index fd3964d23..056469147 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -15,14 +15,14 @@ require ( github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b github.com/smartcontractkit/chainlink-env v0.38.1 github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231009161249-65aceb85249e - github.com/smartcontractkit/chainlink-solana v1.0.3-0.20230831134610-680240b97aca - github.com/smartcontractkit/chainlink-testing-framework v1.17.6 - github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231005125809-5d088a57e308 - github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20230929172251-55c7baa1181a + github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231010222402-6cab56095b28 + github.com/smartcontractkit/chainlink-testing-framework v1.17.8 + github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231010223422-76f226d560b5 + github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20231010223422-76f226d560b5 github.com/smartcontractkit/libocr v0.0.0-20230922131214-122accb19ea6 github.com/stretchr/testify v1.8.4 github.com/testcontainers/testcontainers-go v0.23.0 - go.uber.org/zap v1.25.0 + go.uber.org/zap v1.26.0 golang.org/x/crypto v0.13.0 golang.org/x/sync v0.3.0 gopkg.in/guregu/null.v4 v4.0.0 @@ -59,7 +59,6 @@ require ( github.com/aws/aws-sdk-go v1.44.302 // indirect github.com/aws/constructs-go/constructs/v10 v10.1.255 // indirect github.com/aws/jsii-runtime-go v1.75.0 // indirect - github.com/benbjohnson/clock v1.3.4 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/blendle/zapdriver v1.3.1 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 511bf573d..09400681b 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -678,8 +678,6 @@ github.com/aws/jsii-runtime-go v1.75.0 h1:NhpUfyiL7/wsRuUekFsz8FFBCYLfPD/l61kKg9 github.com/aws/jsii-runtime-go v1.75.0/go.mod h1:TKCyrtM0pygEPo4rDZzbMSDNCDNTSYSN6/mGyHI6O3I= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/benbjohnson/clock v1.3.4 h1:wj3BFPrTw8yYgA1OlMqvUk95nc8OMv3cvBSF5erT2W4= -github.com/benbjohnson/clock v1.3.4/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -1394,8 +1392,8 @@ github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBt github.com/hashicorp/consul/api v1.22.0 h1:ydEvDooB/A0c/xpsBd8GSt7P2/zYPBui4KrNip0xGjE= github.com/hashicorp/consul/api v1.22.0/go.mod h1:zHpYgZ7TeYqS6zaszjwSt128OwESRpnhU9aGa6ue3Eg= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.14.0 h1:Hly+BMNMssVzoWddbBnBFi3W+Fzytvm0haSkihhj3GU= -github.com/hashicorp/consul/sdk v0.14.0/go.mod h1:gHYeuDa0+0qRAD6Wwr6yznMBvBwHKoxSBoW5l73+saE= +github.com/hashicorp/consul/sdk v0.14.1 h1:ZiwE2bKb+zro68sWzZ1SgHF3kRMBZ94TwOCFRF4ylPs= +github.com/hashicorp/consul/sdk v0.14.1/go.mod h1:vFt03juSzocLRFo59NkeQHHmQa6+g7oU0pfzdI1mUhg= github.com/hashicorp/cronexpr v1.1.1 h1:NJZDd87hGXjoZBdvyCF9mX4DCq5Wy7+A/w+A7q0wn6c= github.com/hashicorp/cronexpr v1.1.1/go.mod h1:P4wA0KBl9C5q2hABiMO7cp6jcIg96CDh1Efb3g1PWA4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -2357,12 +2355,12 @@ github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231009161249-65aceb85249e github.com/smartcontractkit/chainlink-relay v0.1.7-0.20231009161249-65aceb85249e/go.mod h1:uIwfoRl8ehNkNWKXffVgG11XAeRG607zAYxA32wxOPo= 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.6 h1:hcsP1eyzrqQf3veK4xh0T37PFkq5AasDwlgJfl11atY= -github.com/smartcontractkit/chainlink-testing-framework v1.17.6/go.mod h1:rypNxetVFh6bwaoHn05bsd4vCtgdEsF+1Vdyy/AhAR8= -github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231005125809-5d088a57e308 h1:/YS6gBdFVIi4Ae2nF62cVCxsn3PkSmvl3ZjJsroW+os= -github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231005125809-5d088a57e308/go.mod h1:9IKLBC7dfSi287/bLSkrnXlSTsQWqpDzi7O0p6XOvk0= -github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20230929172251-55c7baa1181a h1:1CgWi/Xhz6XbGnpEKY9Rhteb+mj+mrw7cEGQ4Rf9RHk= -github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20230929172251-55c7baa1181a/go.mod h1:Sa3rES3SkfZXEWPM2mZN6kVlIa1976o0YurAbsTxrOU= +github.com/smartcontractkit/chainlink-testing-framework v1.17.8 h1:/VEMK3biV/Ml8Liswn5M6pVrRoTnHdLvsoqKr/Cq1f8= +github.com/smartcontractkit/chainlink-testing-framework v1.17.8/go.mod h1:rypNxetVFh6bwaoHn05bsd4vCtgdEsF+1Vdyy/AhAR8= +github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231010223422-76f226d560b5 h1:K0u6ciT+On6EvhcUzN/QwQ6jXsyLv/7cYYrIpq3wia8= +github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20231010223422-76f226d560b5/go.mod h1:aii1AaC4gQRPWjC4DTARWpS1R5uwGB5tEbGUbmARvhU= +github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20231010223422-76f226d560b5 h1:JFmqoTzq+MVwNDsXvbIMBgZtL4t8sq5q5YAZKfHRcGo= +github.com/smartcontractkit/chainlink/v2 v2.5.1-0.20231010223422-76f226d560b5/go.mod h1:i9+8S2D/B0BgpeYGPJI1MDCK4uZs26tWFyUqFL3bdto= github.com/smartcontractkit/libocr v0.0.0-20230922131214-122accb19ea6 h1:eSo9r53fARv2MnIO5pqYvQOXMBsTlAwhHyQ6BAVp6bY= github.com/smartcontractkit/libocr v0.0.0-20230922131214-122accb19ea6/go.mod h1:2lyRkw/qLQgUWlrWWmq5nj0y90rWeO6Y+v+fCakRgb0= github.com/smartcontractkit/ocr2keepers v0.7.27 h1:kwqMrzmEdq6gH4yqNuLQCbdlED0KaIjwZzu3FF+Gves= @@ -2652,8 +2650,8 @@ go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= -go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc= golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= diff --git a/pkg/solana/chain.go b/pkg/solana/chain.go index 2c81e877a..b4d9885e0 100644 --- a/pkg/solana/chain.go +++ b/pkg/solana/chain.go @@ -66,7 +66,7 @@ func (o *ChainOpts) GetLogger() logger.Logger { return o.Logger } -func NewChain(cfg *SolanaConfig, opts ChainOpts) (Chain, error) { +func NewChain(cfg *TOMLConfig, opts ChainOpts) (Chain, error) { if !cfg.IsEnabled() { return nil, fmt.Errorf("cannot create new chain with ID %s: chain is disabled", *cfg.ChainID) } @@ -82,7 +82,7 @@ var _ Chain = (*chain)(nil) type chain struct { utils.StartStopOnce id string - cfg *SolanaConfig + cfg *TOMLConfig txm *txm.Txm balanceMonitor types.Service lggr logger.Logger @@ -215,7 +215,7 @@ func (v *verifiedCachedClient) GetAccountInfoWithOpts(ctx context.Context, addr return v.ReaderWriter.GetAccountInfoWithOpts(ctx, addr, opts) } -func newChain(id string, cfg *SolanaConfig, ks loop.Keystore, lggr logger.Logger) (*chain, error) { +func newChain(id string, cfg *TOMLConfig, ks loop.Keystore, lggr logger.Logger) (*chain, error) { lggr = logger.With(lggr, "chainID", id, "chain", "solana") var ch = chain{ id: id, diff --git a/pkg/solana/chain_test.go b/pkg/solana/chain_test.go index 67522b2e2..33dc849bc 100644 --- a/pkg/solana/chain_test.go +++ b/pkg/solana/chain_test.go @@ -46,7 +46,7 @@ func TestSolanaChain_GetClient(t *testing.T) { ch := solcfg.Chain{} ch.SetDefaults() - cfg := &SolanaConfig{ + cfg := &TOMLConfig{ ChainID: ptr("devnet"), Chain: ch, } @@ -143,7 +143,7 @@ func TestSolanaChain_VerifiedClient(t *testing.T) { ch := solcfg.Chain{} ch.SetDefaults() - cfg := &SolanaConfig{ + cfg := &TOMLConfig{ ChainID: ptr("devnet"), Chain: ch, } @@ -186,7 +186,7 @@ func TestSolanaChain_VerifiedClient_ParallelClients(t *testing.T) { ch := solcfg.Chain{} ch.SetDefaults() - cfg := &SolanaConfig{ + cfg := &TOMLConfig{ ChainID: ptr("devnet"), Enabled: ptr(true), Chain: ch, diff --git a/pkg/solana/config.go b/pkg/solana/config.go index 7887fbc4b..5f720e56c 100644 --- a/pkg/solana/config.go +++ b/pkg/solana/config.go @@ -17,13 +17,16 @@ import ( soldb "github.com/smartcontractkit/chainlink-solana/pkg/solana/db" ) -type SolanaConfigs []*SolanaConfig +// Deprecated: use TOMLConfigs +type SolanaConfigs = TOMLConfigs -func (cs SolanaConfigs) ValidateConfig() (err error) { +type TOMLConfigs []*TOMLConfig + +func (cs TOMLConfigs) ValidateConfig() (err error) { return cs.validateKeys() } -func (cs SolanaConfigs) validateKeys() (err error) { +func (cs TOMLConfigs) validateKeys() (err error) { // Unique chain IDs chainIDs := config.UniqueStrings{} for i, c := range cs { @@ -55,14 +58,14 @@ func (cs SolanaConfigs) validateKeys() (err error) { return } -func (cs *SolanaConfigs) SetFrom(fs *SolanaConfigs) (err error) { +func (cs *TOMLConfigs) SetFrom(fs *TOMLConfigs) (err error) { if err1 := fs.validateKeys(); err1 != nil { return err1 } for _, f := range *fs { if f.ChainID == nil { *cs = append(*cs, f) - } else if i := slices.IndexFunc(*cs, func(c *SolanaConfig) bool { + } else if i := slices.IndexFunc(*cs, func(c *TOMLConfig) bool { return c.ChainID != nil && *c.ChainID == *f.ChainID }); i == -1 { *cs = append(*cs, f) @@ -118,7 +121,10 @@ func legacySolNode(n *solcfg.Node, id string) soldb.Node { } } -type SolanaConfig struct { +// Deprecated: use TOMLConfig +type SolanaConfig = TOMLConfig + +type TOMLConfig struct { ChainID *string // Do not access directly, use [IsEnabled] Enabled *bool @@ -126,11 +132,11 @@ type SolanaConfig struct { Nodes SolanaNodes } -func (c *SolanaConfig) IsEnabled() bool { +func (c *TOMLConfig) IsEnabled() bool { return c.Enabled == nil || *c.Enabled } -func (c *SolanaConfig) SetFrom(f *SolanaConfig) { +func (c *TOMLConfig) SetFrom(f *TOMLConfig) { if f.ChainID != nil { c.ChainID = f.ChainID } @@ -174,7 +180,7 @@ func setFromChain(c, f *solcfg.Chain) { } } -func (c *SolanaConfig) ValidateConfig() (err error) { +func (c *TOMLConfig) ValidateConfig() (err error) { if c.ChainID == nil { err = multierr.Append(err, config.ErrMissing{Name: "ChainID", Msg: "required for all chains"}) } else if *c.ChainID == "" { @@ -187,7 +193,7 @@ func (c *SolanaConfig) ValidateConfig() (err error) { return } -func (c *SolanaConfig) TOMLString() (string, error) { +func (c *TOMLConfig) TOMLString() (string, error) { b, err := toml.Marshal(c) if err != nil { return "", err @@ -195,45 +201,45 @@ func (c *SolanaConfig) TOMLString() (string, error) { return string(b), nil } -var _ solcfg.Config = &SolanaConfig{} +var _ solcfg.Config = &TOMLConfig{} -func (c *SolanaConfig) BalancePollPeriod() time.Duration { +func (c *TOMLConfig) BalancePollPeriod() time.Duration { return c.Chain.BalancePollPeriod.Duration() } -func (c *SolanaConfig) ConfirmPollPeriod() time.Duration { +func (c *TOMLConfig) ConfirmPollPeriod() time.Duration { return c.Chain.ConfirmPollPeriod.Duration() } -func (c *SolanaConfig) OCR2CachePollPeriod() time.Duration { +func (c *TOMLConfig) OCR2CachePollPeriod() time.Duration { return c.Chain.OCR2CachePollPeriod.Duration() } -func (c *SolanaConfig) OCR2CacheTTL() time.Duration { +func (c *TOMLConfig) OCR2CacheTTL() time.Duration { return c.Chain.OCR2CacheTTL.Duration() } -func (c *SolanaConfig) TxTimeout() time.Duration { +func (c *TOMLConfig) TxTimeout() time.Duration { return c.Chain.TxTimeout.Duration() } -func (c *SolanaConfig) TxRetryTimeout() time.Duration { +func (c *TOMLConfig) TxRetryTimeout() time.Duration { return c.Chain.TxRetryTimeout.Duration() } -func (c *SolanaConfig) TxConfirmTimeout() time.Duration { +func (c *TOMLConfig) TxConfirmTimeout() time.Duration { return c.Chain.TxConfirmTimeout.Duration() } -func (c *SolanaConfig) SkipPreflight() bool { +func (c *TOMLConfig) SkipPreflight() bool { return *c.Chain.SkipPreflight } -func (c *SolanaConfig) Commitment() rpc.CommitmentType { +func (c *TOMLConfig) Commitment() rpc.CommitmentType { return rpc.CommitmentType(*c.Chain.Commitment) } -func (c *SolanaConfig) MaxRetries() *uint { +func (c *TOMLConfig) MaxRetries() *uint { if c.Chain.MaxRetries == nil { return nil } @@ -241,27 +247,27 @@ func (c *SolanaConfig) MaxRetries() *uint { return &mr } -func (c *SolanaConfig) FeeEstimatorMode() string { +func (c *TOMLConfig) FeeEstimatorMode() string { return *c.Chain.FeeEstimatorMode } -func (c *SolanaConfig) ComputeUnitPriceMax() uint64 { +func (c *TOMLConfig) ComputeUnitPriceMax() uint64 { return *c.Chain.ComputeUnitPriceMax } -func (c *SolanaConfig) ComputeUnitPriceMin() uint64 { +func (c *TOMLConfig) ComputeUnitPriceMin() uint64 { return *c.Chain.ComputeUnitPriceMin } -func (c *SolanaConfig) ComputeUnitPriceDefault() uint64 { +func (c *TOMLConfig) ComputeUnitPriceDefault() uint64 { return *c.Chain.ComputeUnitPriceDefault } -func (c *SolanaConfig) FeeBumpPeriod() time.Duration { +func (c *TOMLConfig) FeeBumpPeriod() time.Duration { return c.Chain.FeeBumpPeriod.Duration() } -func (c *SolanaConfig) ListNodes() ([]soldb.Node, error) { +func (c *TOMLConfig) ListNodes() ([]soldb.Node, error) { var allNodes []soldb.Node for _, n := range c.Nodes { allNodes = append(allNodes, legacySolNode(n, *c.ChainID))