From d21618a95296179f63e0da2f48b07a6e65f24687 Mon Sep 17 00:00:00 2001 From: aalu1418 <50029043+aalu1418@users.noreply.github.com> Date: Mon, 20 May 2024 07:47:32 -0600 Subject: [PATCH 1/5] remove default pass on integration tests + relayer --- .github/workflows/golangci-lint.yml | 10 +++++++++- .tool-versions | 2 +- Makefile | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 18f1cbe66..772dc434e 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,6 +16,10 @@ jobs: nix_path: nixpkgs=channel:nixos-unstable - name: golangci-lint run: nix develop -c make lint-go-integration-tests + - name: Print lint report artifact + if: failure() + shell: bash + run: cat ./integration-tests/golangci-lint-integration-tests-report.xml - name: Store lint report artifact if: always() uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 @@ -35,9 +39,13 @@ jobs: nix_path: nixpkgs=channel:nixos-unstable - name: golangci-lint run: nix develop -c make lint-go-relay + - name: Print lint report artifact + if: failure() + shell: bash + run: cat ./pkg/golangci-lint-relay-report.xml - name: Store lint report artifact if: always() uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: golangci-lint-relay-report - path: ./pkg/golangci-lint-relay-report.xml \ No newline at end of file + path: ./pkg/golangci-lint-relay-report.xml diff --git a/.tool-versions b/.tool-versions index 4451aa237..bbab638c5 100644 --- a/.tool-versions +++ b/.tool-versions @@ -2,7 +2,7 @@ nodejs 16.13.2 yarn 1.22.19 rust 1.59.0 golang 1.21.1 -golangci-lint 1.52.1 +golangci-lint 1.55.2 pulumi 3.40.1 ginkgo 2.5.1 actionlint 1.6.22 diff --git a/Makefile b/Makefile index 43acdd31a..4030022bd 100644 --- a/Makefile +++ b/Makefile @@ -94,11 +94,11 @@ gomodtidy: .PHONY: lint-go-integration-tests lint-go-integration-tests: - cd ./integration-tests && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-integration-tests-report.xml run || true + cd ./integration-tests && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-integration-tests-report.xml run .PHONY: lint-go-relay lint-go-relay: - cd ./pkg && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-relay-report.xml run || true + cd ./pkg && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-relay-report.xml run .PHONY: upgrade-e2e-solana-image upgrade-e2e-solana-image: From 2c383f196f2a37f841ab5406308a5ee434e4c9d5 Mon Sep 17 00:00:00 2001 From: aalu1418 <50029043+aalu1418@users.noreply.github.com> Date: Mon, 20 May 2024 08:35:25 -0600 Subject: [PATCH 2/5] upgrade to go1.21.6 --- .tool-versions | 2 +- flake.lock | 30 +++++++++++++++--------------- go.mod | 2 +- shell.nix | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.tool-versions b/.tool-versions index bbab638c5..87bd4e87a 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,7 +1,7 @@ nodejs 16.13.2 yarn 1.22.19 rust 1.59.0 -golang 1.21.1 +golang 1.21.6 golangci-lint 1.55.2 pulumi 3.40.1 ginkgo 2.5.1 diff --git a/flake.lock b/flake.lock index 5aacf0d5e..0b9d870fd 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1692799911, - "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", - "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { @@ -23,11 +23,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { @@ -38,11 +38,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1694183432, - "narHash": "sha256-YyPGNapgZNNj51ylQMw9lAgvxtM2ai1HZVUu3GS8Fng=", + "lastModified": 1707689078, + "narHash": "sha256-UUGmRa84ZJHpGZ1WZEBEUOzaPOWG8LZ0yPg1pdDF/yM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "db9208ab987cdeeedf78ad9b4cf3c55f5ebd269b", + "rev": "f9d39fb9aff0efee4a3d5f4a6d7c17701d38a1d8", "type": "github" }, "original": { @@ -54,11 +54,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1681358109, - "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", "type": "github" }, "original": { @@ -81,11 +81,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1694398298, - "narHash": "sha256-Hi904+2V5DJhFdEy9DcARSRrGJOlYSILHUC6CgTtuZU=", + "lastModified": 1707790272, + "narHash": "sha256-KQXPNl3BLdRbz7xx+mwIq/017fxLRk6JhXHxVWCKsTU=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "6c520f2e31f4bebeb29cc4563543de7187013575", + "rev": "8dfbe2dffc28c1a18a29ffa34d5d0b269622b158", "type": "github" }, "original": { diff --git a/go.mod b/go.mod index a2d9d9405..ee369de8e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/smartcontractkit/chainlink-solana -go 1.21 +go 1.21.6 require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc diff --git a/shell.nix b/shell.nix index 83369d06f..dd6049a1d 100644 --- a/shell.nix +++ b/shell.nix @@ -3,7 +3,7 @@ pkgs.mkShell { nativeBuildInputs = with pkgs; [ (rust-bin.stable.latest.default.override { extensions = ["rust-src"]; }) - lld_10 + # lld_10 llvm_11 stdenv.cc.cc.lib pkg-config @@ -16,7 +16,7 @@ pkgs.mkShell { # Golang # Keep this golang version in sync with the version in .tool-versions please - go_1_20 + go_1_21 gopls delve golangci-lint From 333b8ea6bb45707093fd110f0204564a6535b924 Mon Sep 17 00:00:00 2001 From: aalu1418 <50029043+aalu1418@users.noreply.github.com> Date: Mon, 20 May 2024 09:22:31 -0600 Subject: [PATCH 3/5] fix relay linter issues --- ops/monitoring/Dockerfile | 2 +- pkg/monitoring/testutils/testutils.go | 3 ++- pkg/monitoring/types/txdetails.go | 2 +- pkg/solana/cache_test.go | 6 ++++-- pkg/solana/client/client_test.go | 20 ++++++++++---------- pkg/solana/config.go | 7 +------ pkg/solana/fees/computebudget.go | 18 +++++++++--------- pkg/solana/fees/computebudget_test.go | 6 +++--- pkg/solana/relay.go | 2 +- 9 files changed, 32 insertions(+), 34 deletions(-) diff --git a/ops/monitoring/Dockerfile b/ops/monitoring/Dockerfile index 60092d296..7ae9a9c25 100644 --- a/ops/monitoring/Dockerfile +++ b/ops/monitoring/Dockerfile @@ -1,6 +1,6 @@ # Build image -FROM golang:1.21.5 AS build +FROM golang:1.21.10 AS build # OS dependencies RUN apt-get update && apt-get install -y wget gcc diff --git a/pkg/monitoring/testutils/testutils.go b/pkg/monitoring/testutils/testutils.go index d1998fef7..17e46b966 100644 --- a/pkg/monitoring/testutils/testutils.go +++ b/pkg/monitoring/testutils/testutils.go @@ -2,6 +2,7 @@ package testutils import ( "context" + crand "crypto/rand" "fmt" "math" "math/rand" @@ -59,7 +60,7 @@ func GenerateFeedConfig() config.SolanaFeedConfig { func Generate32ByteArr() [32]byte { buf := make([]byte, 32) - _, err := rand.Read(buf) + _, err := crand.Read(buf) if err != nil { panic("unable to Generate [32]byte from rand") } diff --git a/pkg/monitoring/types/txdetails.go b/pkg/monitoring/types/txdetails.go index d26ddd626..7788aca28 100644 --- a/pkg/monitoring/types/txdetails.go +++ b/pkg/monitoring/types/txdetails.go @@ -142,7 +142,7 @@ func ParseTx(tx *solanaGo.Transaction, programAddr solanaGo.PublicKey) (TxDetail } // find compute budget program instruction - if tx.Message.AccountKeys[instruction.ProgramIDIndex] == solanaGo.MustPublicKeyFromBase58(fees.COMPUTE_BUDGET_PROGRAM) { + if tx.Message.AccountKeys[instruction.ProgramIDIndex] == solanaGo.MustPublicKeyFromBase58(fees.ComputeBudgetProgram) { // parsing compute unit price var err error txDetails.ComputeUnitPrice, err = fees.ParseComputeUnitPrice(instruction.Data) diff --git a/pkg/solana/cache_test.go b/pkg/solana/cache_test.go index 59e6c7bb6..3d2529d8d 100644 --- a/pkg/solana/cache_test.go +++ b/pkg/solana/cache_test.go @@ -158,13 +158,15 @@ func TestCache(t *testing.T) { // state query if bytes.Contains(body, []byte("11111111111111111111111111111111")) { // Drop error, client may cancel ctx. - w.Write(testStateResponse()) + _, err = w.Write(testStateResponse()) + require.NoError(t, err) return } // transmissions query // Drop error, client may cancel ctx. - w.Write(testTransmissionsResponse(t, body, 0)) + _, err = w.Write(testTransmissionsResponse(t, body, 0)) + require.NoError(t, err) })) lggr := logger.Test(t) diff --git a/pkg/solana/client/client_test.go b/pkg/solana/client/client_test.go index 0ac0ebcdb..d2e067cce 100644 --- a/pkg/solana/client/client_test.go +++ b/pkg/solana/client/client_test.go @@ -134,10 +134,10 @@ func TestClient_Writer_Integration(t *testing.T) { // create + sign transaction createTx := func(to solana.PublicKey) *solana.Transaction { - hash, err := c.LatestBlockhash() - assert.NoError(t, err) + hash, hashErr := c.LatestBlockhash() + assert.NoError(t, hashErr) - tx, err := solana.NewTransaction( + tx, txErr := solana.NewTransaction( []solana.Instruction{ system.NewTransferInstruction( 1, @@ -148,8 +148,8 @@ func TestClient_Writer_Integration(t *testing.T) { hash.Value.Blockhash, solana.TransactionPayer(pubKey), ) - assert.NoError(t, err) - _, err = tx.Sign( + assert.NoError(t, txErr) + _, signErr := tx.Sign( func(key solana.PublicKey) *solana.PrivateKey { if pubKey.Equals(key) { return &privKey @@ -157,7 +157,7 @@ func TestClient_Writer_Integration(t *testing.T) { return nil }, ) - assert.NoError(t, err) + assert.NoError(t, signErr) return tx } @@ -256,8 +256,8 @@ func TestClient_SendTxDuplicates_Integration(t *testing.T) { for i := 0; i < n; i++ { go func(i int) { time.Sleep(time.Duration(rand.Intn(500)) * time.Millisecond) // randomly submit txs - sig, err := c.SendTx(ctx, tx) - assert.NoError(t, err) + sig, sendErr := c.SendTx(ctx, tx) + assert.NoError(t, sendErr) sigs[i] = sig wg.Done() }(i) @@ -271,8 +271,8 @@ func TestClient_SendTxDuplicates_Integration(t *testing.T) { // try waiting for tx to execute - reduce flakiness require.Eventually(t, func() bool { - res, err := c.SignatureStatuses(ctx, []solana.Signature{sigs[0]}) - require.NoError(t, err) + res, statusErr := c.SignatureStatuses(ctx, []solana.Signature{sigs[0]}) + require.NoError(t, statusErr) require.Equal(t, 1, len(res)) if res[0] == nil { return false diff --git a/pkg/solana/config.go b/pkg/solana/config.go index 82c463b64..16e48b55e 100644 --- a/pkg/solana/config.go +++ b/pkg/solana/config.go @@ -17,9 +17,6 @@ import ( soldb "github.com/smartcontractkit/chainlink-solana/pkg/solana/db" ) -// Deprecated: use TOMLConfigs -type SolanaConfigs = TOMLConfigs - type TOMLConfigs []*TOMLConfig func (cs TOMLConfigs) ValidateConfig() (err error) { @@ -88,6 +85,7 @@ func nodeStatus(n *solcfg.Node, id string) (relaytypes.NodeStatus, error) { return s, nil } +// revive:disable-next-line will be handled in https://github.com/smartcontractkit/chainlink-solana/pull/709 type SolanaNodes []*solcfg.Node func (ns *SolanaNodes) SetFrom(fs *SolanaNodes) { @@ -121,9 +119,6 @@ func legacySolNode(n *solcfg.Node, id string) soldb.Node { } } -// Deprecated: use TOMLConfig -type SolanaConfig = TOMLConfig - type TOMLConfig struct { ChainID *string // Do not access directly, use [IsEnabled] diff --git a/pkg/solana/fees/computebudget.go b/pkg/solana/fees/computebudget.go index ba980f0a2..fec4a4442 100644 --- a/pkg/solana/fees/computebudget.go +++ b/pkg/solana/fees/computebudget.go @@ -11,27 +11,27 @@ import ( // https://github.com/solana-labs/solana/blob/60858d043ca612334de300805d93ea3014e8ab37/sdk/src/compute_budget.rs#L25 const ( // deprecated: will not support for building instruction - Instruction_RequestUnitsDeprecated uint8 = iota + InstructionRequestUnitsDeprecated uint8 = iota // Request a specific transaction-wide program heap region size in bytes. // The value requested must be a multiple of 1024. This new heap region // size applies to each program executed in the transaction, including all // calls to CPIs. // note: uses ag_binary.Varuint32 - Instruction_RequestHeapFrame + InstructionRequestHeapFrame // Set a specific compute unit limit that the transaction is allowed to consume. // note: uses ag_binary.Varuint32 - Instruction_SetComputeUnitLimit + InstructionSetComputeUnitLimit // Set a compute unit price in "micro-lamports" to pay a higher transaction // fee for higher transaction prioritization. // note: uses ag_binary.Uint64 - Instruction_SetComputeUnitPrice + InstructionSetComputeUnitPrice ) const ( - COMPUTE_BUDGET_PROGRAM = "ComputeBudget111111111111111111111111111111" + ComputeBudgetProgram = "ComputeBudget111111111111111111111111111111" ) // https://docs.solana.com/developing/programming-model/runtime @@ -39,7 +39,7 @@ type ComputeUnitPrice uint64 // returns the compute budget program func (val ComputeUnitPrice) ProgramID() solana.PublicKey { - return solana.MustPublicKeyFromBase58(COMPUTE_BUDGET_PROGRAM) + return solana.MustPublicKeyFromBase58(ComputeBudgetProgram) } // No accounts needed @@ -52,7 +52,7 @@ func (val ComputeUnitPrice) Data() ([]byte, error) { buf := new(bytes.Buffer) // encode method identifier - if err := buf.WriteByte(Instruction_SetComputeUnitPrice); err != nil { + if err := buf.WriteByte(InstructionSetComputeUnitPrice); err != nil { return []byte{}, err } @@ -69,7 +69,7 @@ func ParseComputeUnitPrice(data []byte) (ComputeUnitPrice, error) { return 0, fmt.Errorf("invalid length: %d", len(data)) } - if data[0] != Instruction_SetComputeUnitPrice { + if data[0] != InstructionSetComputeUnitPrice { return 0, fmt.Errorf("not SetComputeUnitPrice identifier: %d", data[0]) } @@ -117,7 +117,7 @@ func SetComputeUnitPrice(tx *solana.Transaction, price ComputeUnitPrice) error { for i := range tx.Message.Instructions { if tx.Message.Instructions[i].ProgramIDIndex == programIdx && len(tx.Message.Instructions[i].Data) > 0 && - tx.Message.Instructions[i].Data[0] == Instruction_SetComputeUnitPrice { + tx.Message.Instructions[i].Data[0] == InstructionSetComputeUnitPrice { found = true instructionIdx = i break diff --git a/pkg/solana/fees/computebudget_test.go b/pkg/solana/fees/computebudget_test.go index 64ce7fdce..c80550297 100644 --- a/pkg/solana/fees/computebudget_test.go +++ b/pkg/solana/fees/computebudget_test.go @@ -32,7 +32,7 @@ func TestSetComputeUnitPrice(t *testing.T) { currentCount := len(tx.Message.Instructions) assert.Greater(t, currentCount, instructionCount) assert.Equal(t, 2, currentCount) - assert.Equal(t, COMPUTE_BUDGET_PROGRAM, tx.Message.AccountKeys[tx.Message.Instructions[0].ProgramIDIndex].String()) + assert.Equal(t, ComputeBudgetProgram, tx.Message.AccountKeys[tx.Message.Instructions[0].ProgramIDIndex].String()) data, err := ComputeUnitPrice(1).Data() assert.NoError(t, err) assert.Equal(t, data, []byte(tx.Message.Instructions[0].Data)) @@ -58,7 +58,7 @@ func TestSetComputeUnitPrice(t *testing.T) { // accounts should not have changed assert.Equal(t, accountCount, len(tx.Message.AccountKeys)) assert.Equal(t, 2, len(tx.Message.Instructions)) - assert.Equal(t, COMPUTE_BUDGET_PROGRAM, tx.Message.AccountKeys[tx.Message.Instructions[0].ProgramIDIndex].String()) + assert.Equal(t, ComputeBudgetProgram, tx.Message.AccountKeys[tx.Message.Instructions[0].ProgramIDIndex].String()) data, err := ComputeUnitPrice(1).Data() assert.NoError(t, err) assert.Equal(t, data, []byte(tx.Message.Instructions[0].Data)) @@ -115,7 +115,7 @@ func TestParseComputeUnitPrice(t *testing.T) { assert.ErrorContains(t, err, "invalid length") invalidData := data - invalidData[0] = Instruction_RequestHeapFrame + invalidData[0] = InstructionRequestHeapFrame _, err = ParseComputeUnitPrice(invalidData) assert.ErrorContains(t, err, "not SetComputeUnitPrice identifier") } diff --git a/pkg/solana/relay.go b/pkg/solana/relay.go index 8b5df44ad..68652fcd2 100644 --- a/pkg/solana/relay.go +++ b/pkg/solana/relay.go @@ -26,7 +26,7 @@ type TxManager interface { Enqueue(accountID string, msg *solana.Transaction) error } -var _ relaytypes.Relayer = &Relayer{} +var _ relaytypes.Relayer = &Relayer{} //nolint:staticcheck type Relayer struct { lggr logger.Logger From a2cb4d3882eda3d058903f61cb9eee78404be881 Mon Sep 17 00:00:00 2001 From: aalu1418 <50029043+aalu1418@users.noreply.github.com> Date: Mon, 20 May 2024 11:02:26 -0600 Subject: [PATCH 4/5] fix e2e test linter --- integration-tests/common/common.go | 36 +++++----- integration-tests/common/test_common.go | 67 ++++++++++--------- .../docker/{test_env => testenv}/sol.go | 60 ++++++++--------- integration-tests/gauntlet/gauntlet_solana.go | 64 +++++++++--------- integration-tests/smoke/ocr2_test.go | 12 ++-- integration-tests/solclient/deployer.go | 13 +--- integration-tests/solclient/ocr2.go | 3 + integration-tests/solclient/solclient.go | 27 -------- 8 files changed, 124 insertions(+), 158 deletions(-) rename integration-tests/docker/{test_env => testenv}/sol.go (81%) diff --git a/integration-tests/common/common.go b/integration-tests/common/common.go index 9053d188e..3469b5c84 100644 --- a/integration-tests/common/common.go +++ b/integration-tests/common/common.go @@ -40,7 +40,7 @@ import ( commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" - test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/test_env" + test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/testenv" "github.com/smartcontractkit/chainlink-solana/integration-tests/solclient" "github.com/smartcontractkit/chainlink-solana/pkg/solana" solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config" @@ -59,7 +59,7 @@ const ( type Common struct { IsK8s bool ChainName string - ChainId string + ChainID string NodeCount int NodeOpts []test_env.ClNodeOption TTL time.Duration @@ -68,7 +68,7 @@ type Common struct { K8Config *environment.Config Env *environment.Environment DockerEnv *SolCLClusterTestEnv - SolanaUrl string + SolanaURL string } type SolCLClusterTestEnv struct { @@ -122,15 +122,15 @@ func New(env string, isK8s bool) *Common { c = &Common{ IsK8s: isK8s, ChainName: ChainName, - ChainId: DevnetChainID, - SolanaUrl: SolanaDevnetURL, + ChainID: DevnetChainID, + SolanaURL: SolanaDevnetURL, } } else { c = &Common{ IsK8s: isK8s, ChainName: ChainName, - ChainId: LocalnetChainID, - SolanaUrl: SolanaLocalNetURL, + ChainID: LocalnetChainID, + SolanaURL: SolanaLocalNetURL, } } // Checking if count of OCR nodes is defined in ENV @@ -171,14 +171,14 @@ func New(env string, isK8s bool) *Common { func (c *Common) CreateSolanaChainAndNode(nodes []*client.ChainlinkClient) error { for _, n := range nodes { - _, _, err := n.CreateSolanaChain(&client.SolanaChainAttributes{ChainID: c.ChainId}) + _, _, err := n.CreateSolanaChain(&client.SolanaChainAttributes{ChainID: c.ChainID}) if err != nil { return err } _, _, err = n.CreateSolanaNode(&client.SolanaNodeAttributes{ Name: ChainName, - SolanaChainID: c.ChainId, - SolanaURL: c.SolanaUrl, + SolanaChainID: c.ChainID, + SolanaURL: c.SolanaURL, }) if err != nil { return err @@ -196,7 +196,7 @@ func (c *Common) CreateNodeKeysBundle(nodes []*client.ChainlinkClient) ([]client } peerID := p2pkeys.Data[0].Attributes.PeerID - txKey, _, err := n.CreateTxKey(ChainName, c.ChainId) + txKey, _, err := n.CreateTxKey(ChainName, c.ChainID) if err != nil { return nil, err } @@ -300,7 +300,7 @@ func OffChainConfigParamsFromNodes(nodeCount int, nkb []client.NodeKeysBundle) ( }, nil } -func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, mockUrl string, isK8s bool) error { +func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, mockURL string, isK8s bool) error { for i, nodesInfo := range ContractsIdxMapToContractsNodeInfo { // Bootstrap node first var err error @@ -315,7 +315,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, } sourceValueBridge := client.BridgeTypeAttributes{ Name: nodeContractPairID, - URL: fmt.Sprintf("%s/%s", mockUrl, "five"), + URL: fmt.Sprintf("%s/%s", mockURL, "five"), RequestData: "{}", } observationSource := client.ObservationSourceSpecBridge(&sourceValueBridge) @@ -329,7 +329,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, } juelsBridge := client.BridgeTypeAttributes{ Name: nodeContractPairID + "juels", - URL: fmt.Sprintf("%s/%s", mockUrl, "five"), + URL: fmt.Sprintf("%s/%s", mockURL, "five"), RequestData: "{}", } juelsSource := client.ObservationSourceSpecBridge(&juelsBridge) @@ -362,7 +362,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, } sourceValueBridge := client.BridgeTypeAttributes{ Name: nodeContractPairID, - URL: fmt.Sprintf("%s/%s", mockUrl, "five"), + URL: fmt.Sprintf("%s/%s", mockURL, "five"), RequestData: "{}", } observationSource := client.ObservationSourceSpecBridge(&sourceValueBridge) @@ -376,7 +376,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, } juelsBridge := client.BridgeTypeAttributes{ Name: nodeContractPairID + "juels", - URL: fmt.Sprintf("%s/%s", mockUrl, "five"), + URL: fmt.Sprintf("%s/%s", mockURL, "five"), RequestData: "{}", } juelsSource := client.ObservationSourceSpecBridge(&juelsBridge) @@ -499,11 +499,11 @@ func BuildNodeContractPairID(node *client.ChainlinkClient, ocr2Addr string) (str func (c *Common) DefaultNodeConfig() *cl.Config { solConfig := solana.TOMLConfig{ Enabled: ptr.Ptr(true), - ChainID: ptr.Ptr(c.ChainId), + ChainID: ptr.Ptr(c.ChainID), Nodes: []*solcfg.Node{ { Name: ptr.Ptr("primary"), - URL: config.MustParseURL(c.SolanaUrl), + URL: config.MustParseURL(c.SolanaURL), }, }, } diff --git a/integration-tests/common/test_common.go b/integration-tests/common/test_common.go index c809a6f1d..86bec56c8 100644 --- a/integration-tests/common/test_common.go +++ b/integration-tests/common/test_common.go @@ -18,7 +18,7 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/utils/osutil" "github.com/smartcontractkit/chainlink/integration-tests/testconfig" - test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/test_env" + test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/testenv" "github.com/smartcontractkit/chainlink-solana/integration-tests/solclient" "golang.org/x/sync/errgroup" @@ -60,7 +60,7 @@ type Contracts struct { type OCR2OnChainConfig struct { Oracles []Operator `json:"oracles"` F int `json:"f"` - ProposalId string `json:"proposalId"` + ProposalID string `json:"proposalId"` } type OffchainConfig struct { @@ -92,7 +92,7 @@ type ReportingPluginConfig struct { // TODO - Decouple all OCR2 config structs to be reusable between chains type OCROffChainConfig struct { - ProposalId string `json:"proposalId"` + ProposalID string `json:"proposalId"` OffchainConfig OffchainConfig `json:"offchainConfig"` UserSecret string `json:"userSecret"` } @@ -105,11 +105,11 @@ type Operator struct { type PayeeConfig struct { Operators []Operator `json:"operators"` - ProposalId string `json:"proposalId"` + ProposalID string `json:"proposalId"` } type ProposalAcceptConfig struct { - ProposalId string `json:"proposalId"` + ProposalID string `json:"proposalId"` Version int `json:"version"` F int `json:"f"` Oracles []Operator `json:"oracles"` @@ -193,7 +193,7 @@ func (m *OCRv2TestState) DeployCluster(contractsDir string) { sol := test_env_sol.NewSolana([]string{env.DockerNetwork.Name}) err = sol.StartContainer() require.NoError(m.T, err) - m.Common.SolanaUrl = sol.InternalHttpUrl + m.Common.SolanaURL = sol.InternalHTTPURL b, err := test_env.NewCLTestEnvBuilder(). WithNonEVM(). WithTestInstance(m.T). @@ -239,7 +239,7 @@ func (m *OCRv2TestState) DeployEnv(contractsDir string) { err := m.Common.Env.Run() require.NoError(m.T, err) - m.Common.SolanaUrl = m.Common.Env.URLs[m.Client.Config.Name][0] + m.Common.SolanaURL = m.Common.Env.URLs[m.Client.Config.Name][0] m.UploadProgramBinaries(contractsDir) } @@ -248,8 +248,8 @@ func (m *OCRv2TestState) NewSolanaClientSetup(networkSettings *solclient.SolNetw networkSettings.URLs = m.Common.Env.URLs[networkSettings.Name] } else { networkSettings.URLs = []string{ - m.Common.DockerEnv.Sol.ExternalHttpUrl, - m.Common.DockerEnv.Sol.ExternalWsUrl, + m.Common.DockerEnv.Sol.ExternalHTTPURL, + m.Common.DockerEnv.Sol.ExternalWsURL, } } ec, err := solclient.NewClient(networkSettings) @@ -388,18 +388,18 @@ func (m *OCRv2TestState) DeployContracts(contractsDir string) { // CreateJobs creating OCR jobs and EA stubs func (m *OCRv2TestState) CreateJobs() { var nodes []*client.ChainlinkClient - var mockInternalUrl string + var mockInternalURL string if m.Common.IsK8s { nodes = m.GetChainlinkNodes() - mockInternalUrl = m.Common.Env.URLs["qa_mock_adapter_internal"][0] + mockInternalURL = m.Common.Env.URLs["qa_mock_adapter_internal"][0] } else { nodes = m.Common.DockerEnv.ClCluster.NodeAPIs() - mockInternalUrl = m.Common.DockerEnv.Killgrave.InternalEndpoint + mockInternalURL = m.Common.DockerEnv.Killgrave.InternalEndpoint } - m.L.Info().Str("Url", mockInternalUrl).Msg("Mock adapter url") + m.L.Info().Str("Url", mockInternalURL).Msg("Mock adapter url") m.err = m.Common.CreateSolanaChainAndNode(nodes) require.NoError(m.T, m.err) - m.err = CreateBridges(m.ContractsNodeSetup, mockInternalUrl, m.Common.IsK8s) + m.err = CreateBridges(m.ContractsNodeSetup, mockInternalURL, m.Common.IsK8s) require.NoError(m.T, m.err) g := errgroup.Group{} for i := 0; i < len(m.ContractsNodeSetup); i++ { @@ -463,7 +463,7 @@ func (m *OCRv2TestState) ValidateRoundsAfter(chaosStartTime time.Time, timeout t }, timeout, NewRoundCheckPollInterval).Should(gomega.Succeed()) } -func (m *OCRv2TestState) GenerateOnChainConfig(nodeKeys []client.NodeKeysBundle, vaultAddress string, proposalId string) (OCR2OnChainConfig, error) { +func (m *OCRv2TestState) GenerateOnChainConfig(nodeKeys []client.NodeKeysBundle, vaultAddress string, proposalID string) (OCR2OnChainConfig, error) { var oracles []Operator for _, nodeKey := range nodeKeys { @@ -477,13 +477,13 @@ func (m *OCRv2TestState) GenerateOnChainConfig(nodeKeys []client.NodeKeysBundle, return OCR2OnChainConfig{ Oracles: oracles, F: 1, - ProposalId: proposalId, + ProposalID: proposalID, }, nil } func (m *OCRv2TestState) GenerateOffChainConfig( nodeKeysBundle []client.NodeKeysBundle, - proposalId string, + proposalID string, reportingConfig ReportingPluginConfig, deltaProgressNanoseconds int64, deltaResendNanoseconds int64, @@ -515,7 +515,7 @@ func (m *OCRv2TestState) GenerateOffChainConfig( } offChainConfig := OCROffChainConfig{ - ProposalId: proposalId, + ProposalID: proposalID, OffchainConfig: OffchainConfig{ DeltaProgressNanoseconds: deltaProgressNanoseconds, DeltaResendNanoseconds: deltaResendNanoseconds, @@ -540,7 +540,7 @@ func (m *OCRv2TestState) GenerateOffChainConfig( return offChainConfig } -func (m *OCRv2TestState) GeneratePayees(nodeKeys []client.NodeKeysBundle, vaultAddress string, proposalId string) PayeeConfig { +func (m *OCRv2TestState) GeneratePayees(nodeKeys []client.NodeKeysBundle, vaultAddress string, proposalID string) PayeeConfig { var operators []Operator for _, key := range nodeKeys { operators = append(operators, Operator{ @@ -552,12 +552,12 @@ func (m *OCRv2TestState) GeneratePayees(nodeKeys []client.NodeKeysBundle, vaultA return PayeeConfig{ Operators: operators, - ProposalId: proposalId, + ProposalID: proposalID, } } func (m *OCRv2TestState) GenerateProposalAcceptConfig( - proposalId string, + proposalID string, version int, f int, oracles []Operator, @@ -566,7 +566,7 @@ func (m *OCRv2TestState) GenerateProposalAcceptConfig( ) ProposalAcceptConfig { return ProposalAcceptConfig{ - ProposalId: proposalId, + ProposalID: proposalID, Version: version, F: f, Oracles: oracles, @@ -580,12 +580,12 @@ func (m *OCRv2TestState) ConfigureGauntlet(secret string) map[string]string { if err != nil { panic("Error setting SECRET") } - rpcUrl, exists := os.LookupEnv("RPC_URL") + rpcURL, exists := os.LookupEnv("RPC_URL") if !exists { panic("Please define RPC_URL") } - wsUrl, exists := os.LookupEnv("WS_URL") + wsURL, exists := os.LookupEnv("WS_URL") if !exists { panic("Please define WS_URL") } @@ -593,17 +593,17 @@ func (m *OCRv2TestState) ConfigureGauntlet(secret string) map[string]string { if !exists { panic("Please define PRIVATE_KEY") } - programIdOCR2, exists := os.LookupEnv("PROGRAM_ID_OCR2") + programIDOCR2, exists := os.LookupEnv("PROGRAM_ID_OCR2") if !exists { panic("Please define PROGRAM_ID_OCR2") } - programIdAccessController, exists := os.LookupEnv("PROGRAM_ID_ACCESS_CONTROLLER") + programIDAccessController, exists := os.LookupEnv("PROGRAM_ID_ACCESS_CONTROLLER") if !exists { panic("Please define PROGRAM_ID_ACCESS_CONTROLLER") } - programIdStore, exists := os.LookupEnv("PROGRAM_ID_STORE") + programIDStore, exists := os.LookupEnv("PROGRAM_ID_STORE") if !exists { panic("Please define PROGRAM_ID_STORE") } @@ -619,12 +619,12 @@ func (m *OCRv2TestState) ConfigureGauntlet(secret string) map[string]string { } return map[string]string{ - "NODE_URL": rpcUrl, - "WS_URL": wsUrl, + "NODE_URL": rpcURL, + "WS_URL": wsURL, "PRIVATE_KEY": privateKey, - "PROGRAM_ID_OCR2": programIdOCR2, - "PROGRAM_ID_ACCESS_CONTROLLER": programIdAccessController, - "PROGRAM_ID_STORE": programIdStore, + "PROGRAM_ID_OCR2": programIDOCR2, + "PROGRAM_ID_ACCESS_CONTROLLER": programIDAccessController, + "PROGRAM_ID_STORE": programIDStore, "LINK": linkToken, "VAULT": vault, } @@ -632,7 +632,7 @@ func (m *OCRv2TestState) ConfigureGauntlet(secret string) map[string]string { // GauntletEnvToRemoteRunner Setup the environment variables that will be needed inside the remote runner func (m *OCRv2TestState) GauntletEnvToRemoteRunner() { - osutil.SetupEnvVarsForRemoteRunner([]string{ + err := osutil.SetupEnvVarsForRemoteRunner([]string{ "RPC_URL", "WS_URL", "PRIVATE_KEY", @@ -642,6 +642,7 @@ func (m *OCRv2TestState) GauntletEnvToRemoteRunner() { "LINK_TOKEN", "VAULT_ADDRESS", }) + require.NoError(m.T, err) } func (m *OCRv2TestState) GetChainlinkNodes() []*client.ChainlinkClient { diff --git a/integration-tests/docker/test_env/sol.go b/integration-tests/docker/testenv/sol.go similarity index 81% rename from integration-tests/docker/test_env/sol.go rename to integration-tests/docker/testenv/sol.go index 8bec26f7f..501b543ed 100644 --- a/integration-tests/docker/test_env/sol.go +++ b/integration-tests/docker/testenv/sol.go @@ -1,4 +1,4 @@ -package test_env +package testenv import ( "context" @@ -25,11 +25,11 @@ import ( ) const ( - SOL_HTTP_PORT = "8899" - SOL_WS_PORT = "8900" + SolHTTPPort = "8899" + SolWSPort = "8900" ) -var config_yml = ` +var configYmlRaw = ` json_rpc_url: http://0.0.0.0:8899 websocket_url: ws://0.0.0.0:8900 keypair_path: /root/.config/solana/cli/id.json @@ -38,16 +38,16 @@ address_labels: commitment: finalized ` -var id_json = ` +var idJSONRaw = ` [205,246,252,222,193,57,3,13,164,146,52,162,143,135,8,254,37,4,250,48,137,61,49,57,187,210,209,118,108,125,81,235,136,69,202,17,24,209,91,226,206,92,80,45,83,14,222,113,229,190,94,142,188,124,102,122,15,246,40,190,24,247,69,133] ` type Solana struct { test_env.EnvComponent - ExternalHttpUrl string - ExternalWsUrl string - InternalHttpUrl string - InternalWsUrl string + ExternalHTTPURL string + ExternalWsURL string + InternalHTTPURL string + InternalWsURL string t *testing.T l zerolog.Logger } @@ -105,29 +105,29 @@ func (s *Solana) StartContainer() error { if err != nil { return err } - httpPort, err := c.MappedPort(testcontext.Get(s.t), test_env.NatPort(SOL_HTTP_PORT)) + httpPort, err := c.MappedPort(testcontext.Get(s.t), test_env.NatPort(SolHTTPPort)) if err != nil { return err } - wsPort, err := c.MappedPort(testcontext.Get(s.t), test_env.NatPort(SOL_WS_PORT)) + wsPort, err := c.MappedPort(testcontext.Get(s.t), test_env.NatPort(SolWSPort)) if err != nil { return err } - s.ExternalHttpUrl = fmt.Sprintf("http://%s:%s", host, httpPort.Port()) - s.InternalHttpUrl = fmt.Sprintf("http://%s:%s", s.ContainerName, SOL_HTTP_PORT) - s.ExternalWsUrl = fmt.Sprintf("ws://%s:%s", host, wsPort.Port()) - s.InternalWsUrl = fmt.Sprintf("ws://%s:%s", s.ContainerName, SOL_WS_PORT) + s.ExternalHTTPURL = fmt.Sprintf("http://%s:%s", host, httpPort.Port()) + s.InternalHTTPURL = fmt.Sprintf("http://%s:%s", s.ContainerName, SolHTTPPort) + s.ExternalWsURL = fmt.Sprintf("ws://%s:%s", host, wsPort.Port()) + s.InternalWsURL = fmt.Sprintf("ws://%s:%s", s.ContainerName, SolWSPort) s.l.Info(). - Any("ExternalHttpUrl", s.ExternalHttpUrl). - Any("InternalHttpUrl", s.InternalHttpUrl). - Any("ExternalWsUrl", s.ExternalWsUrl). - Any("InternalWsUrl", s.InternalWsUrl). + Any("ExternalHTTPURL", s.ExternalHTTPURL). + Any("InternalHTTPURL", s.InternalHTTPURL). + Any("ExternalWsURL", s.ExternalWsURL). + Any("InternalWsURL", s.InternalWsURL). Str("containerName", s.ContainerName). Msgf("Started Solana container") // validate features are properly set - inactiveLocalFeatures, err := GetInactiveFeatureHashes(s.ExternalHttpUrl) + inactiveLocalFeatures, err := GetInactiveFeatureHashes(s.ExternalHTTPURL) if err != nil { return err } @@ -137,39 +137,39 @@ func (s *Solana) StartContainer() error { return nil } -func (ms *Solana) getContainerRequest(inactiveFeatures InactiveFeatures) (*tc.ContainerRequest, error) { +func (s *Solana) getContainerRequest(inactiveFeatures InactiveFeatures) (*tc.ContainerRequest, error) { configYml, err := os.CreateTemp("", "config.yml") if err != nil { return nil, err } - _, err = configYml.WriteString(config_yml) + _, err = configYml.WriteString(configYmlRaw) if err != nil { return nil, err } - idJson, err := os.CreateTemp("", "id.json") + idJSON, err := os.CreateTemp("", "id.json") if err != nil { return nil, err } - _, err = idJson.WriteString(id_json) + _, err = idJSON.WriteString(idJSONRaw) if err != nil { return nil, err } return &tc.ContainerRequest{ - Name: ms.ContainerName, + Name: s.ContainerName, Image: "solanalabs/solana:v1.17.33", - ExposedPorts: []string{test_env.NatPortFormat(SOL_HTTP_PORT), test_env.NatPortFormat(SOL_WS_PORT)}, + ExposedPorts: []string{test_env.NatPortFormat(SolHTTPPort), test_env.NatPortFormat(SolWSPort)}, Env: map[string]string{ "SERVER_PORT": "1080", }, - Networks: ms.Networks, + Networks: s.Networks, WaitingFor: tcwait.ForLog("Processed Slot: 1"). WithStartupTimeout(30 * time.Second). WithPollInterval(100 * time.Millisecond), Mounts: tc.ContainerMounts{ tc.ContainerMount{ - Source: tc.GenericBindMountSource{ + Source: tc.GenericBindMountSource{ //nolint:staticcheck HostPath: utils.ContractsDir, }, Target: "/programs", @@ -183,7 +183,7 @@ func (ms *Solana) getContainerRequest(inactiveFeatures InactiveFeatures) (*tc.Co if err != nil { return err } - err = container.CopyFileToContainer(ctx, idJson.Name(), "/root/.config/solana/cli/id.json", 0644) + err = container.CopyFileToContainer(ctx, idJSON.Name(), "/root/.config/solana/cli/id.json", 0644) return err }, }, @@ -215,7 +215,7 @@ func (f InactiveFeatures) CLIString() string { // This is used in conjunction with the solana-test-validator command to produce a solana network that has the same features as mainnet // the solana-test-validator has all features on by default (released + unreleased) func GetInactiveFeatureHashes(url string) (output InactiveFeatures, err error) { - cmd := exec.Command("solana", "feature", "status", "-u="+url, "--output=json") // -um is for mainnet url + cmd := exec.Command("solana", "feature", "status", "-u="+url, "--output=json") //nolint:gosec // -um is for mainnet url stdout, err := cmd.Output() if err != nil { return nil, fmt.Errorf("Failed to get feature status: %w", err) diff --git a/integration-tests/gauntlet/gauntlet_solana.go b/integration-tests/gauntlet/gauntlet_solana.go index 5244dc6cf..0c4ffe147 100644 --- a/integration-tests/gauntlet/gauntlet_solana.go +++ b/integration-tests/gauntlet/gauntlet_solana.go @@ -17,7 +17,7 @@ var ( type SolanaGauntlet struct { dir string G *gauntlet.Gauntlet - gr *GauntletResponse + gr *Response options *gauntlet.ExecCommandOptions AccessControllerAddress string BillingControllerAddress string @@ -50,8 +50,8 @@ type StoreWriterConfig struct { Transmissions string `json:"transmissions"` } -// GauntletResponse Default response output for starknet gauntlet commands -type GauntletResponse struct { +// Response Default response output for starknet gauntlet commands +type Response struct { Responses []struct { Tx struct { Hash string `json:"hash"` @@ -75,7 +75,7 @@ type GauntletResponse struct { type Transmission struct { LatestTransmissionNo int64 `json:"latestTransmissionNo"` - RoundId int64 `json:"roundId"` + RoundID int64 `json:"roundId"` Answer int64 `json:"answer"` Transmitter string `json:"transmitter"` } @@ -90,7 +90,7 @@ func NewSolanaGauntlet(workingDir string) (*SolanaGauntlet, error) { sg = &SolanaGauntlet{ dir: workingDir, G: g, - gr: &GauntletResponse{}, + gr: &Response{}, options: &gauntlet.ExecCommandOptions{ ErrHandling: []string{}, CheckErrorsInRead: true, @@ -99,9 +99,9 @@ func NewSolanaGauntlet(workingDir string) (*SolanaGauntlet, error) { return sg, nil } -// FetchGauntletJsonOutput Parse gauntlet json response that is generated after yarn gauntlet command execution -func (sg *SolanaGauntlet) FetchGauntletJsonOutput() (*GauntletResponse, error) { - var payload = &GauntletResponse{} +// FetchGauntletJSONOutput Parse gauntlet json response that is generated after yarn gauntlet command execution +func (sg *SolanaGauntlet) FetchGauntletJSONOutput() (*Response, error) { + var payload = &Response{} gauntletOutput, err := os.ReadFile(sg.dir + "/report.json") if err != nil { return payload, err @@ -141,7 +141,7 @@ func (sg *SolanaGauntlet) InitializeAccessController() (string, error) { if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -153,7 +153,7 @@ func (sg *SolanaGauntlet) InitializeStore(billingController string) (string, err if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -169,7 +169,7 @@ func (sg *SolanaGauntlet) StoreCreateFeed(length int, feedConfig *StoreFeedConfi if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -182,7 +182,7 @@ func (sg *SolanaGauntlet) StoreSetValidatorConfig(feedAddress string, threshold if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -202,7 +202,7 @@ func (sg *SolanaGauntlet) InitializeOCR2(requesterAccessController string, billi if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -226,7 +226,7 @@ func (sg *SolanaGauntlet) StoreSetWriter(storeConfig *StoreWriterConfig, ocrAddr if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -250,7 +250,7 @@ func (sg *SolanaGauntlet) OCR2SetBilling(ocr2BillingConfig *OCR2BillingConfig, o if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -269,7 +269,7 @@ func (sg *SolanaGauntlet) OCR2CreateProposal(version int) (string, error) { if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -277,7 +277,7 @@ func (sg *SolanaGauntlet) OCR2CreateProposal(version int) (string, error) { return *sg.gr.Data.Proposal, nil } -func (sg *SolanaGauntlet) ProposeOnChainConfig(proposalId string, onChainConfig common.OCR2OnChainConfig, ocrFeedAddress string) (string, error) { +func (sg *SolanaGauntlet) ProposeOnChainConfig(proposalID string, onChainConfig common.OCR2OnChainConfig, ocrFeedAddress string) (string, error) { config, err := json.Marshal(onChainConfig) if err != nil { return "", err @@ -285,7 +285,7 @@ func (sg *SolanaGauntlet) ProposeOnChainConfig(proposalId string, onChainConfig _, err = sg.G.ExecCommand([]string{ "ocr2:propose_config", - fmt.Sprintf("--proposalId=%s", proposalId), + fmt.Sprintf("--proposalID=%s", proposalID), fmt.Sprintf("--input=%v", string(config)), ocrFeedAddress, }, @@ -295,7 +295,7 @@ func (sg *SolanaGauntlet) ProposeOnChainConfig(proposalId string, onChainConfig if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -303,7 +303,7 @@ func (sg *SolanaGauntlet) ProposeOnChainConfig(proposalId string, onChainConfig return sg.gr.Responses[0].Contract, nil } -func (sg *SolanaGauntlet) ProposeOffChainConfig(proposalId string, offChainConfig common.OCROffChainConfig, ocrFeedAddress string) (string, error) { +func (sg *SolanaGauntlet) ProposeOffChainConfig(proposalID string, offChainConfig common.OCROffChainConfig, ocrFeedAddress string) (string, error) { config, err := json.Marshal(offChainConfig) if err != nil { return "", err @@ -311,7 +311,7 @@ func (sg *SolanaGauntlet) ProposeOffChainConfig(proposalId string, offChainConfi _, err = sg.G.ExecCommand([]string{ "ocr2:propose_offchain_config", - fmt.Sprintf("--proposalId=%s", proposalId), + fmt.Sprintf("--proposalID=%s", proposalID), fmt.Sprintf("--input=%v", string(config)), ocrFeedAddress, }, @@ -321,7 +321,7 @@ func (sg *SolanaGauntlet) ProposeOffChainConfig(proposalId string, offChainConfi if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -329,7 +329,7 @@ func (sg *SolanaGauntlet) ProposeOffChainConfig(proposalId string, offChainConfi return sg.gr.Responses[0].Contract, nil } -func (sg *SolanaGauntlet) ProposePayees(proposalId string, payeesConfig common.PayeeConfig, ocrFeedAddress string) (string, error) { +func (sg *SolanaGauntlet) ProposePayees(proposalID string, payeesConfig common.PayeeConfig, ocrFeedAddress string) (string, error) { config, err := json.Marshal(payeesConfig) if err != nil { return "", err @@ -337,7 +337,7 @@ func (sg *SolanaGauntlet) ProposePayees(proposalId string, payeesConfig common.P _, err = sg.G.ExecCommand([]string{ "ocr2:propose_payees", - fmt.Sprintf("--proposalId=%s", proposalId), + fmt.Sprintf("--proposalID=%s", proposalID), fmt.Sprintf("--input=%v", string(config)), ocrFeedAddress, }, @@ -347,7 +347,7 @@ func (sg *SolanaGauntlet) ProposePayees(proposalId string, payeesConfig common.P if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -355,10 +355,10 @@ func (sg *SolanaGauntlet) ProposePayees(proposalId string, payeesConfig common.P return sg.gr.Responses[0].Contract, nil } -func (sg *SolanaGauntlet) FinalizeProposal(proposalId string) (string, error) { +func (sg *SolanaGauntlet) FinalizeProposal(proposalID string) (string, error) { _, err := sg.G.ExecCommand([]string{ "ocr2:finalize_proposal", - fmt.Sprintf("--proposalId=%s", proposalId), + fmt.Sprintf("--proposalID=%s", proposalID), }, *sg.options, ) @@ -366,7 +366,7 @@ func (sg *SolanaGauntlet) FinalizeProposal(proposalId string) (string, error) { if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -374,7 +374,7 @@ func (sg *SolanaGauntlet) FinalizeProposal(proposalId string) (string, error) { return sg.gr.Responses[0].Contract, nil } -func (sg *SolanaGauntlet) AcceptProposal(proposalId string, secret string, proposalAcceptConfig common.ProposalAcceptConfig, ocrFeedAddres string) (string, error) { +func (sg *SolanaGauntlet) AcceptProposal(proposalID string, secret string, proposalAcceptConfig common.ProposalAcceptConfig, ocrFeedAddres string) (string, error) { config, err := json.Marshal(proposalAcceptConfig) if err != nil { return "", err @@ -382,7 +382,7 @@ func (sg *SolanaGauntlet) AcceptProposal(proposalId string, secret string, propo _, err = sg.G.ExecCommand([]string{ "ocr2:accept_proposal", - fmt.Sprintf("--proposalId=%s", proposalId), + fmt.Sprintf("--proposalID=%s", proposalID), fmt.Sprintf("--secret=%s", secret), fmt.Sprintf("--input=%s", string(config)), ocrFeedAddres, @@ -393,7 +393,7 @@ func (sg *SolanaGauntlet) AcceptProposal(proposalId string, secret string, propo if err != nil { return "", err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return "", err } @@ -413,7 +413,7 @@ func (sg *SolanaGauntlet) FetchTransmissions(ocrState string) ([]Transmission, e if err != nil { return nil, err } - sg.gr, err = sg.FetchGauntletJsonOutput() + sg.gr, err = sg.FetchGauntletJSONOutput() if err != nil { return nil, err } diff --git a/integration-tests/smoke/ocr2_test.go b/integration-tests/smoke/ocr2_test.go index 3c972d161..53bcf2831 100644 --- a/integration-tests/smoke/ocr2_test.go +++ b/integration-tests/smoke/ocr2_test.go @@ -81,7 +81,7 @@ func TestSolanaGauntletOCRV2Smoke(t *testing.T) { if state.Common.Env.WillUseRemoteRunner() { // run the remote runner and exit state.GauntletEnvToRemoteRunner() - err := state.Common.Env.Run() + err = state.Common.Env.Run() require.NoError(t, err) return } @@ -90,7 +90,7 @@ func TestSolanaGauntletOCRV2Smoke(t *testing.T) { err = state.Common.Env.Run() require.NoError(t, err) t.Cleanup(func() { - if err := actions.TeardownSuite(t, state.Common.Env, state.ChainlinkNodesK8s, nil, zapcore.PanicLevel, nil); err != nil { + if err = actions.TeardownSuite(t, state.Common.Env, state.ChainlinkNodesK8s, nil, zapcore.PanicLevel, nil); err != nil { l.Error().Err(err).Msg("Error tearing down environment") } }) @@ -162,11 +162,11 @@ func TestSolanaGauntletOCRV2Smoke(t *testing.T) { // TODO - The current setup in common.go is using the solana validator, so we need to create one method for both gauntlet and solana // Leaving this for the time being as is so we have Testnet runs enabled on Solana relayConfig := job.JSONConfig{ - "nodeEndpointHTTP": state.Common.SolanaUrl, + "nodeEndpointHTTP": state.Common.SolanaURL, "ocr2ProgramID": gauntletConfig["PROGRAM_ID_OCR2"], "transmissionsID": sg.FeedAddress, "storeProgramID": gauntletConfig["PROGRAM_ID_STORE"], - "chainID": state.Common.ChainId, + "chainID": state.Common.ChainID, } bootstrapPeers := []client.P2PData{ { @@ -247,9 +247,9 @@ func TestSolanaGauntletOCRV2Smoke(t *testing.T) { if len(transmissions) <= 1 { l.Info().Str("Contract", sg.OcrAddress).Str("No", "Transmissions") } else { - l.Info().Str("Contract", sg.OcrAddress).Interface("Answer", transmissions[0].Answer).Int64("RoundID", transmissions[0].RoundId).Msg("New answer found") + l.Info().Str("Contract", sg.OcrAddress).Interface("Answer", transmissions[0].Answer).Int64("RoundID", transmissions[0].RoundID).Msg("New answer found") assert.Equal(t, transmissions[0].Answer, int64(5), fmt.Sprintf("Actual: %d, Expected: 5", transmissions[0].Answer)) - assert.Less(t, transmissions[1].RoundId, transmissions[0].RoundId, fmt.Sprintf("Expected round %d to be less than %d", transmissions[1].RoundId, transmissions[0].RoundId)) + assert.Less(t, transmissions[1].RoundID, transmissions[0].RoundID, fmt.Sprintf("Expected round %d to be less than %d", transmissions[1].RoundID, transmissions[0].RoundID)) } time.Sleep(time.Second * 6) } diff --git a/integration-tests/solclient/deployer.go b/integration-tests/solclient/deployer.go index 63089f1f5..f24a18a27 100644 --- a/integration-tests/solclient/deployer.go +++ b/integration-tests/solclient/deployer.go @@ -19,7 +19,7 @@ import ( access_controller2 "github.com/smartcontractkit/chainlink-solana/contracts/generated/access_controller" ocr_2 "github.com/smartcontractkit/chainlink-solana/contracts/generated/ocr2" store2 "github.com/smartcontractkit/chainlink-solana/contracts/generated/store" - test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/test_env" + test_env_sol "github.com/smartcontractkit/chainlink-solana/integration-tests/docker/testenv" ) // All account sizes are calculated from Rust structures, ex. programs/access-controller/src/lib.rs:L80 @@ -234,17 +234,6 @@ func (c *ContractDeployer) CreateFeed(desc string, decimals uint8, granularity i return nil } -func (c *ContractDeployer) addMintToAccInstr(instr *[]solana.Instruction, dest solana.PublicKey, amount uint64) error { - *instr = append(*instr, token.NewMintToInstruction( - amount, - c.Accounts.Mint.PublicKey(), - dest, - c.Accounts.MintAuthority.PublicKey(), - nil, - ).Build()) - return nil -} - func (c *ContractDeployer) DeployLinkTokenContract() (*LinkToken, error) { var err error payer := c.Client.DefaultWallet diff --git a/integration-tests/solclient/ocr2.go b/integration-tests/solclient/ocr2.go index 2c8ac7598..557e43e66 100644 --- a/integration-tests/solclient/ocr2.go +++ b/integration-tests/solclient/ocr2.go @@ -195,6 +195,9 @@ func (m *OCRv2) fetchProposalAccount() (*ocr_2.Proposal, error) { m.Proposal.PublicKey(), &proposal, ) + if err != nil { + return nil, err + } // reimplement GetAccountDataInto with options resp, err := m.Client.RPC.GetAccountInfoWithOpts( context.Background(), diff --git a/integration-tests/solclient/solclient.go b/integration-tests/solclient/solclient.go index ea54027bb..d2d3a638c 100644 --- a/integration-tests/solclient/solclient.go +++ b/integration-tests/solclient/solclient.go @@ -10,9 +10,6 @@ import ( "path/filepath" "time" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/gagliardetto/solana-go" @@ -89,14 +86,6 @@ type Client struct { LinkToken *LinkToken } -func (c *Client) BalanceAt(ctx context.Context, address common.Address) (*big.Int, error) { - panic("implement me") -} - -func (c *Client) GetTxReceipt(txHash common.Hash) (*types.Receipt, error) { - panic("implement me") -} - func (c *Client) GetNetworkType() string { return c.Config.Type } @@ -472,22 +461,6 @@ func (c *Client) LatestBlockNumber(ctx context.Context) (uint64, error) { panic("implement me") } -func (c *Client) DeployContract(contractName string, deployer blockchain.ContractDeployer) (*common.Address, *types.Transaction, interface{}, error) { - panic("implement me") -} - -func (c *Client) TransactionOpts(from *blockchain.EthereumWallet) (*bind.TransactOpts, error) { - panic("implement me") -} - -func (c *Client) ProcessTransaction(tx *types.Transaction) error { - panic("implement me") -} - -func (c *Client) IsTxConfirmed(txHash common.Hash) (bool, error) { - panic("implement me") -} - func (c *Client) GasStats() *blockchain.GasStats { panic("implement me") } From d08ed050e66a8645e3e9cfca0d32d0b26429831e Mon Sep 17 00:00:00 2001 From: aalu1418 <50029043+aalu1418@users.noreply.github.com> Date: Mon, 20 May 2024 13:14:17 -0600 Subject: [PATCH 5/5] fix e2e tests --- integration-tests/gauntlet/gauntlet_solana.go | 10 +++++----- integration-tests/go.mod | 2 +- integration-tests/solclient/ocr2.go | 9 --------- pkg/solana/cache_test.go | 6 ++---- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/integration-tests/gauntlet/gauntlet_solana.go b/integration-tests/gauntlet/gauntlet_solana.go index 0c4ffe147..3c74464ac 100644 --- a/integration-tests/gauntlet/gauntlet_solana.go +++ b/integration-tests/gauntlet/gauntlet_solana.go @@ -285,7 +285,7 @@ func (sg *SolanaGauntlet) ProposeOnChainConfig(proposalID string, onChainConfig _, err = sg.G.ExecCommand([]string{ "ocr2:propose_config", - fmt.Sprintf("--proposalID=%s", proposalID), + fmt.Sprintf("--proposalId=%s", proposalID), fmt.Sprintf("--input=%v", string(config)), ocrFeedAddress, }, @@ -311,7 +311,7 @@ func (sg *SolanaGauntlet) ProposeOffChainConfig(proposalID string, offChainConfi _, err = sg.G.ExecCommand([]string{ "ocr2:propose_offchain_config", - fmt.Sprintf("--proposalID=%s", proposalID), + fmt.Sprintf("--proposalId=%s", proposalID), fmt.Sprintf("--input=%v", string(config)), ocrFeedAddress, }, @@ -337,7 +337,7 @@ func (sg *SolanaGauntlet) ProposePayees(proposalID string, payeesConfig common.P _, err = sg.G.ExecCommand([]string{ "ocr2:propose_payees", - fmt.Sprintf("--proposalID=%s", proposalID), + fmt.Sprintf("--proposalId=%s", proposalID), fmt.Sprintf("--input=%v", string(config)), ocrFeedAddress, }, @@ -358,7 +358,7 @@ func (sg *SolanaGauntlet) ProposePayees(proposalID string, payeesConfig common.P func (sg *SolanaGauntlet) FinalizeProposal(proposalID string) (string, error) { _, err := sg.G.ExecCommand([]string{ "ocr2:finalize_proposal", - fmt.Sprintf("--proposalID=%s", proposalID), + fmt.Sprintf("--proposalId=%s", proposalID), }, *sg.options, ) @@ -382,7 +382,7 @@ func (sg *SolanaGauntlet) AcceptProposal(proposalID string, secret string, propo _, err = sg.G.ExecCommand([]string{ "ocr2:accept_proposal", - fmt.Sprintf("--proposalID=%s", proposalID), + fmt.Sprintf("--proposalId=%s", proposalID), fmt.Sprintf("--secret=%s", secret), fmt.Sprintf("--input=%s", string(config)), ocrFeedAddres, diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 49e42190d..4657015b2 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -5,7 +5,6 @@ go 1.21.7 replace github.com/smartcontractkit/chainlink-solana => ../ require ( - github.com/ethereum/go-ethereum v1.13.8 github.com/gagliardetto/binary v0.7.7 github.com/gagliardetto/solana-go v1.8.4 github.com/google/uuid v1.6.0 @@ -136,6 +135,7 @@ require ( github.com/emicklei/go-restful/v3 v3.10.2 // indirect github.com/esote/minmaxheap v1.0.0 // indirect github.com/ethereum/c-kzg-4844 v0.4.0 // indirect + github.com/ethereum/go-ethereum v1.13.8 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect diff --git a/integration-tests/solclient/ocr2.go b/integration-tests/solclient/ocr2.go index 557e43e66..c2f0f7e29 100644 --- a/integration-tests/solclient/ocr2.go +++ b/integration-tests/solclient/ocr2.go @@ -190,15 +190,6 @@ func (m *OCRv2) makeDigest() ([]byte, error) { func (m *OCRv2) fetchProposalAccount() (*ocr_2.Proposal, error) { var proposal ocr_2.Proposal - err := m.Client.RPC.GetAccountDataInto( - context.Background(), - m.Proposal.PublicKey(), - &proposal, - ) - if err != nil { - return nil, err - } - // reimplement GetAccountDataInto with options resp, err := m.Client.RPC.GetAccountInfoWithOpts( context.Background(), m.Proposal.PublicKey(), diff --git a/pkg/solana/cache_test.go b/pkg/solana/cache_test.go index 3d2529d8d..fb5605a40 100644 --- a/pkg/solana/cache_test.go +++ b/pkg/solana/cache_test.go @@ -158,15 +158,13 @@ func TestCache(t *testing.T) { // state query if bytes.Contains(body, []byte("11111111111111111111111111111111")) { // Drop error, client may cancel ctx. - _, err = w.Write(testStateResponse()) - require.NoError(t, err) + w.Write(testStateResponse()) //nolint:errcheck return } // transmissions query // Drop error, client may cancel ctx. - _, err = w.Write(testTransmissionsResponse(t, body, 0)) - require.NoError(t, err) + w.Write(testTransmissionsResponse(t, body, 0)) //nolint:errcheck })) lggr := logger.Test(t)