From 8320f27deb742eecc5325618534ece13c2022c4e Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 22 Jul 2023 18:07:17 +0200 Subject: [PATCH 01/15] Drafting deployment script and instructions The plan is to use deploy.sh script to deploy programs on Solana and use a migration script to execute required instructions on the deployed programs. --- cross-chain/solana/.gitignore | 1 + cross-chain/solana/deploy.sh | 64 +++++++++++++++++++++++++ cross-chain/solana/migrations/deploy.ts | 57 +++++++++++++++++++--- cross-chain/solana/package.json | 6 +-- cross-chain/solana/solana.env.template | 3 ++ 5 files changed, 121 insertions(+), 10 deletions(-) create mode 100755 cross-chain/solana/deploy.sh create mode 100644 cross-chain/solana/solana.env.template diff --git a/cross-chain/solana/.gitignore b/cross-chain/solana/.gitignore index 8d401163f..8ab586cef 100644 --- a/cross-chain/solana/.gitignore +++ b/cross-chain/solana/.gitignore @@ -6,3 +6,4 @@ target node_modules test-ledger .yarn +solana.env diff --git a/cross-chain/solana/deploy.sh b/cross-chain/solana/deploy.sh new file mode 100755 index 000000000..73a30218d --- /dev/null +++ b/cross-chain/solana/deploy.sh @@ -0,0 +1,64 @@ +#!/bin/bash +set -eo pipefail + +help() { + echo -e "\nUsage: $0 --cluster " + + echo -e "\nCommand line arguments:\n" + echo -e "\t--cluster: \n" \ + "\t\tAvailable deployment clusters: 'mainnet-beta', 'devnet', and 'localnet'." \ + "Overrides a cluster set in Anchor.toml" + exit 1 # Exit script after printing help +} + +# Setting env variables in the current bash shell +source solana.env + +# Transform long options to short ones +for arg in "$@"; do + shift + case "$arg" in + "--cluster") set -- "$@" "-n" ;; + "--help") set -- "$@" "-h" ;; + *) set -- "$@" "$arg" ;; + esac +done + +# Parse short options +OPTIND=1 +while getopts "n:w:h" opt; do + case "$opt" in + n) CLUSTER="$OPTARG" ;; + h) help ;; + ?) help ;; # Print help in case parameter is non-existent + esac +done +shift $(expr $OPTIND - 1) # remove options from positional parameters + +[ -z "$CLUSTER" ] && { + echo "'--cluster' option not provided" >&2 + help + exit 1 +} + +[ -z "$WALLET" ] && { + echo "'WALLET' env var is not set" >&2 + help + exit 1 +} + +echo "Building workspace for cluster: $CLUSTER" +anchor build --provider.cluster $CLUSTER + +echo "Syncing the program's id ..." +anchor keys sync + +echo "Building workspace again to include new program ID in the binary ..." +anchor build --provider.cluster $CLUSTER + +echo "Deploying program(s) for cluster: $CLUSTER" +anchor deploy --provider.cluster $CLUSTER --provider.wallet $WALLET + +echo "Migrating..." +anchor migrate --provider.cluster $CLUSTER --provider.wallet $WALLET +# TODO: anchor migrate // executes migrations/deploy.ts script diff --git a/cross-chain/solana/migrations/deploy.ts b/cross-chain/solana/migrations/deploy.ts index 82fb175fa..c1b3d1a34 100644 --- a/cross-chain/solana/migrations/deploy.ts +++ b/cross-chain/solana/migrations/deploy.ts @@ -1,12 +1,55 @@ -// Migrations are an early feature. Currently, they're nothing more than this -// single deploy script that's invoked from the CLI, injecting a provider -// configured from the workspace's Anchor.toml. - -const anchor = require("@coral-xyz/anchor"); +import * as anchor from "@coral-xyz/anchor"; +import * as web3 from "@solana/web3.js"; +import fs from "fs"; +import { Keypair } from "@solana/web3.js"; +import dotenv from "dotenv"; module.exports = async function (provider) { - // Configure client to use the provider. + dotenv.config({ path: "../solana.env" }) + anchor.setProvider(provider); - // Add your deploy script here. + const program = anchor.workspace.Tbtc; + // This wallet deployed the program and is also an authority + const authority = loadKey(process.env.WALLET); + const tbtcKeys = loadKey(process.env.TBTC_KEYS); + + const [tbtcMintPDA, _] = web3.PublicKey.findProgramAddressSync( + [ + anchor.utils.bytes.utf8.encode("tbtc-mint"), + tbtcKeys.publicKey.toBuffer(), + ], + program.programId, + ); + + // Initalize tbtc program + await program.methods + .initialize() + .accounts({ + tbtcMint: tbtcMintPDA, + tbtc: tbtcKeys.publicKey, + authority: authority.publicKey, + }) + .signers([tbtcKeys]) + .rpc(); + + // add a minter (wormhole gateway (minter keys)) + + // add a guardian? + + // update mappings (self, arbitrum, optimism, polygon) + + // transfer ownership to council + // solana program set-upgrade-authority -k --new-upgrade-authority }; + +function loadKey(filename: string): Keypair { + try { + const contents = fs.readFileSync(filename).toString(); + const bs = Uint8Array.from(JSON.parse(contents)); + + return Keypair.fromSecretKey(bs); + } catch { + console.log("Unable to read keypair...", filename); + } +} diff --git a/cross-chain/solana/package.json b/cross-chain/solana/package.json index 4a866202d..28edb0dbb 100644 --- a/cross-chain/solana/package.json +++ b/cross-chain/solana/package.json @@ -3,15 +3,15 @@ "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" }, - "dependencies": { - "@coral-xyz/anchor": "^0.28.0" - }, "devDependencies": { + "@coral-xyz/anchor": "^0.28.0", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.77.3", "@types/bn.js": "^5.1.0", "@types/chai": "^4.3.0", "@types/mocha": "^9.0.0", + "@types/node": "^18.11.18", + "dotenv": "^16.3.1", "chai": "^4.3.4", "mocha": "^9.0.3", "prettier": "^2.6.2", diff --git a/cross-chain/solana/solana.env.template b/cross-chain/solana/solana.env.template new file mode 100644 index 000000000..e87aa3bb6 --- /dev/null +++ b/cross-chain/solana/solana.env.template @@ -0,0 +1,3 @@ +WALLET= +TBTC_KEYS= +UPGRADE_AUTHORITY= \ No newline at end of file From 99f6b376b8bf776668a356d2af5130bfe43764f0 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 24 Jul 2023 22:55:06 +0200 Subject: [PATCH 02/15] Adding minter keys WormholeGateway will be the first minter of SolanaTBTC --- cross-chain/solana/migrations/deploy.ts | 28 +++++++++++++++---- cross-chain/solana/{ => scripts}/deploy.sh | 16 ++++++++--- .../solana/scripts/transfer_authority.sh | 5 ++++ cross-chain/solana/solana.env.template | 1 + 4 files changed, 41 insertions(+), 9 deletions(-) rename cross-chain/solana/{ => scripts}/deploy.sh (83%) create mode 100755 cross-chain/solana/scripts/transfer_authority.sh diff --git a/cross-chain/solana/migrations/deploy.ts b/cross-chain/solana/migrations/deploy.ts index c1b3d1a34..3a704d356 100644 --- a/cross-chain/solana/migrations/deploy.ts +++ b/cross-chain/solana/migrations/deploy.ts @@ -13,8 +13,9 @@ module.exports = async function (provider) { // This wallet deployed the program and is also an authority const authority = loadKey(process.env.WALLET); const tbtcKeys = loadKey(process.env.TBTC_KEYS); + const minterKeys = loadKey(process.env.MINTER_KEYS); - const [tbtcMintPDA, _] = web3.PublicKey.findProgramAddressSync( + const [tbtcMintPDA, ] = web3.PublicKey.findProgramAddressSync( [ anchor.utils.bytes.utf8.encode("tbtc-mint"), tbtcKeys.publicKey.toBuffer(), @@ -33,14 +34,31 @@ module.exports = async function (provider) { .signers([tbtcKeys]) .rpc(); - // add a minter (wormhole gateway (minter keys)) + const [minterInfoPDA, ] = web3.PublicKey.findProgramAddressSync( + [ + anchor.utils.bytes.utf8.encode('minter-info'), + tbtcKeys.publicKey.toBuffer(), + minterKeys.publicKey.toBuffer(), + ], + program.programId + ); + + // add minter keys (minterKeys is the wormholeGateway-keypair) + await program.methods + .addMinter() + .accounts({ + tbtc: tbtcKeys.publicKey, + authority: authority.publicKey, + minter: minterKeys.publicKey, + payer: authority.publicKey, + minterInfo: minterInfoPDA, + }) + .signers([minterKeys]) + .rpc(); // add a guardian? // update mappings (self, arbitrum, optimism, polygon) - - // transfer ownership to council - // solana program set-upgrade-authority -k --new-upgrade-authority }; function loadKey(filename: string): Keypair { diff --git a/cross-chain/solana/deploy.sh b/cross-chain/solana/scripts/deploy.sh similarity index 83% rename from cross-chain/solana/deploy.sh rename to cross-chain/solana/scripts/deploy.sh index 73a30218d..cfe008620 100755 --- a/cross-chain/solana/deploy.sh +++ b/cross-chain/solana/scripts/deploy.sh @@ -43,11 +43,20 @@ shift $(expr $OPTIND - 1) # remove options from positional parameters [ -z "$WALLET" ] && { echo "'WALLET' env var is not set" >&2 - help exit 1 } -echo "Building workspace for cluster: $CLUSTER" +[ -z "$TBTC_KEYS" ] && { + echo "'WALLET' env var is not set" >&2 + exit 1 +} + +[ -z "$MINTER_KEYS" ] && { + echo "'MINTER_KEYS' env var is not set" >&2 + exit 1 +} + +echo "Building workspace for cluster: $CLUSTER ..." anchor build --provider.cluster $CLUSTER echo "Syncing the program's id ..." @@ -56,9 +65,8 @@ anchor keys sync echo "Building workspace again to include new program ID in the binary ..." anchor build --provider.cluster $CLUSTER -echo "Deploying program(s) for cluster: $CLUSTER" +echo "Deploying program(s) for cluster: $CLUSTER ..." anchor deploy --provider.cluster $CLUSTER --provider.wallet $WALLET echo "Migrating..." anchor migrate --provider.cluster $CLUSTER --provider.wallet $WALLET -# TODO: anchor migrate // executes migrations/deploy.ts script diff --git a/cross-chain/solana/scripts/transfer_authority.sh b/cross-chain/solana/scripts/transfer_authority.sh new file mode 100755 index 000000000..f6489d506 --- /dev/null +++ b/cross-chain/solana/scripts/transfer_authority.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -eo pipefail + +# TODO: transfer upgrade authority to Threshold Council multisig +solana program set-upgrade-authority -k --new-upgrade-authority diff --git a/cross-chain/solana/solana.env.template b/cross-chain/solana/solana.env.template index e87aa3bb6..d2833955a 100644 --- a/cross-chain/solana/solana.env.template +++ b/cross-chain/solana/solana.env.template @@ -1,3 +1,4 @@ WALLET= TBTC_KEYS= +MINTER_KEYS= UPGRADE_AUTHORITY= \ No newline at end of file From 3ab2244701b1a69637691168f59cfa41ab9b951d Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 25 Jul 2023 11:07:26 +0200 Subject: [PATCH 03/15] Adding prettier, more properties in package.jon and scripts --- cross-chain/solana/.prettierrc.js | 3 +++ cross-chain/solana/package.json | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 cross-chain/solana/.prettierrc.js diff --git a/cross-chain/solana/.prettierrc.js b/cross-chain/solana/.prettierrc.js new file mode 100644 index 000000000..89028b307 --- /dev/null +++ b/cross-chain/solana/.prettierrc.js @@ -0,0 +1,3 @@ +module.exports = { + ...require("@thesis-co/prettier-config"), +} \ No newline at end of file diff --git a/cross-chain/solana/package.json b/cross-chain/solana/package.json index 28edb0dbb..d14822030 100644 --- a/cross-chain/solana/package.json +++ b/cross-chain/solana/package.json @@ -1,7 +1,15 @@ -{ +{ + "name": "@keep-network/tbtc-v2-solana", + "version": "1.0.0-dev", + "description": "tBTC v2 on Solana", + "license": "GPL-3.0-only", "scripts": { + "build": "anchor build", + "format": "npm run lint", + "format:fix": "npm run lint:fix", "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", + "test": "anchor test" }, "devDependencies": { "@coral-xyz/anchor": "^0.28.0", @@ -11,6 +19,7 @@ "@types/chai": "^4.3.0", "@types/mocha": "^9.0.0", "@types/node": "^18.11.18", + "@thesis-co/eslint-config": "github:thesis/eslint-config", "dotenv": "^16.3.1", "chai": "^4.3.4", "mocha": "^9.0.3", From 4e06f53d6cb21981606a09c624a9735bb60f1d5d Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 25 Jul 2023 11:08:04 +0200 Subject: [PATCH 04/15] Linting deploy.ts file --- cross-chain/solana/migrations/deploy.ts | 50 ++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/cross-chain/solana/migrations/deploy.ts b/cross-chain/solana/migrations/deploy.ts index 3a704d356..28cf44789 100644 --- a/cross-chain/solana/migrations/deploy.ts +++ b/cross-chain/solana/migrations/deploy.ts @@ -1,27 +1,27 @@ -import * as anchor from "@coral-xyz/anchor"; -import * as web3 from "@solana/web3.js"; -import fs from "fs"; -import { Keypair } from "@solana/web3.js"; -import dotenv from "dotenv"; +import * as anchor from "@coral-xyz/anchor" +import * as web3 from "@solana/web3.js" +import fs from "fs" +import { Keypair } from "@solana/web3.js" +import dotenv from "dotenv" module.exports = async function (provider) { dotenv.config({ path: "../solana.env" }) - anchor.setProvider(provider); + anchor.setProvider(provider) - const program = anchor.workspace.Tbtc; + const program = anchor.workspace.Tbtc // This wallet deployed the program and is also an authority - const authority = loadKey(process.env.WALLET); - const tbtcKeys = loadKey(process.env.TBTC_KEYS); - const minterKeys = loadKey(process.env.MINTER_KEYS); + const authority = loadKey(process.env.WALLET) + const tbtcKeys = loadKey(process.env.TBTC_KEYS) + const minterKeys = loadKey(process.env.MINTER_KEYS) - const [tbtcMintPDA, ] = web3.PublicKey.findProgramAddressSync( + const [tbtcMintPDA] = web3.PublicKey.findProgramAddressSync( [ anchor.utils.bytes.utf8.encode("tbtc-mint"), tbtcKeys.publicKey.toBuffer(), ], - program.programId, - ); + program.programId + ) // Initalize tbtc program await program.methods @@ -32,17 +32,17 @@ module.exports = async function (provider) { authority: authority.publicKey, }) .signers([tbtcKeys]) - .rpc(); + .rpc() - const [minterInfoPDA, ] = web3.PublicKey.findProgramAddressSync( + const [minterInfoPDA] = web3.PublicKey.findProgramAddressSync( [ - anchor.utils.bytes.utf8.encode('minter-info'), + anchor.utils.bytes.utf8.encode("minter-info"), tbtcKeys.publicKey.toBuffer(), minterKeys.publicKey.toBuffer(), ], program.programId - ); - + ) + // add minter keys (minterKeys is the wormholeGateway-keypair) await program.methods .addMinter() @@ -54,20 +54,20 @@ module.exports = async function (provider) { minterInfo: minterInfoPDA, }) .signers([minterKeys]) - .rpc(); - + .rpc() + // add a guardian? // update mappings (self, arbitrum, optimism, polygon) -}; +} function loadKey(filename: string): Keypair { try { - const contents = fs.readFileSync(filename).toString(); - const bs = Uint8Array.from(JSON.parse(contents)); + const contents = fs.readFileSync(filename).toString() + const bs = Uint8Array.from(JSON.parse(contents)) - return Keypair.fromSecretKey(bs); + return Keypair.fromSecretKey(bs) } catch { - console.log("Unable to read keypair...", filename); + console.log("Unable to read keypair...", filename) } } From 788fb8752fa91c0e2779d92227f9888f422bea2d Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 25 Jul 2023 11:26:40 +0200 Subject: [PATCH 05/15] Adding CI workflow for Solana module - Build and test job - Formatting job --- .github/workflows/cross-chain-solana.yml | 94 ++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/cross-chain-solana.yml diff --git a/.github/workflows/cross-chain-solana.yml b/.github/workflows/cross-chain-solana.yml new file mode 100644 index 000000000..f179280ac --- /dev/null +++ b/.github/workflows/cross-chain-solana.yml @@ -0,0 +1,94 @@ +name: Cross-chain Solana + +on: + schedule: + - cron: "0 0 * * *" + push: + branches: + - main + paths: + - "cross-chain/solana/**" + - ".github/workflows/cross-chain-solana.yml" + pull_request: + +jobs: + contracts-detect-changes: + runs-on: ubuntu-latest + outputs: + path-filter: ${{ steps.filter.outputs.path-filter }} + steps: + - uses: actions/checkout@v3 + if: github.event_name == 'pull_request' + + - uses: dorny/paths-filter@v2 + if: github.event_name == 'pull_request' + id: filter + with: + filters: | + path-filter: + - './cross-chain/solana/**' + - './.github/workflows/cross-chain-solana.yml' + + contracts-build-and-test: + needs: contracts-detect-changes + if: | + github.event_name != 'pull_request' + || needs.contracts-detect-changes.outputs.path-filter == 'true' + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./cross-chain/solana + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: "16.x" + cache: "yarn" + cache-dependency-path: cross-chain/solana/yarn.lock + + # A workaround for transitive dependencies that use the obsolete git:// + # prefix instead of the recommended https:// + - name: Configure git to not use unauthenticated protocol + run: git config --global url."https://".insteadOf git:// + + - name: Install dependencies + run: yarn install + + - name: Build contracts + run: yarn build + + - name: Run tests + run: yarn test + + contracts-format: + needs: contracts-detect-changes + if: | + github.event_name == 'push' + || needs.contracts-detect-changes.outputs.path-filter == 'true' + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./cross-chain/solana + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: "16.x" + cache: "yarn" + cache-dependency-path: cross-chain/solana/yarn.lock + + # A workaround for transitive dependencies that use the obsolete git:// + # prefix instead of the recommended https:// + - name: Configure git to not use unauthenticated protocol + run: git config --global url."https://".insteadOf git:// + + - name: Install dependencies + run: yarn install + + - name: Build + run: yarn build + + - name: Check formatting + run: yarn format From f986a9547058097a1bc9fad671f56126697237d1 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 25 Jul 2023 12:01:17 +0200 Subject: [PATCH 06/15] Installing Solana and Anchor for solana workflow --- .github/workflows/cross-chain-solana.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/cross-chain-solana.yml b/.github/workflows/cross-chain-solana.yml index f179280ac..d171173b8 100644 --- a/.github/workflows/cross-chain-solana.yml +++ b/.github/workflows/cross-chain-solana.yml @@ -52,6 +52,13 @@ jobs: - name: Configure git to not use unauthenticated protocol run: git config --global url."https://".insteadOf git:// + - name: Install Solana + run: sh -c "$(curl -sSfL https://release.solana.com/v1.16.5/install)" + + - name: Install Anchor + run: | + cargo install --git https://github.com/coral-xyz/anchor --tag v0.28.0 anchor-cli --locked + - name: Install dependencies run: yarn install From 2fa1622d20acd17e540420bd4c3cd5490ba24970 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 25 Jul 2023 13:23:11 +0200 Subject: [PATCH 07/15] Installing Rust for Solana workflow --- .github/workflows/cross-chain-solana.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cross-chain-solana.yml b/.github/workflows/cross-chain-solana.yml index d171173b8..2b38d928d 100644 --- a/.github/workflows/cross-chain-solana.yml +++ b/.github/workflows/cross-chain-solana.yml @@ -52,12 +52,17 @@ jobs: - name: Configure git to not use unauthenticated protocol run: git config --global url."https://".insteadOf git:// + - name: Install Solana + run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + - name: Install Solana run: sh -c "$(curl -sSfL https://release.solana.com/v1.16.5/install)" - name: Install Anchor run: | cargo install --git https://github.com/coral-xyz/anchor --tag v0.28.0 anchor-cli --locked + avm install latest + avm use latest - name: Install dependencies run: yarn install @@ -94,8 +99,5 @@ jobs: - name: Install dependencies run: yarn install - - name: Build - run: yarn build - - name: Check formatting run: yarn format From cd9f50f7e47d90ff114dff706c9ce5cc9298bf5d Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 25 Jul 2023 14:46:40 +0200 Subject: [PATCH 08/15] Accepting defaults during Rust installation --- .github/workflows/cross-chain-solana.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cross-chain-solana.yml b/.github/workflows/cross-chain-solana.yml index 2b38d928d..5caa7ad34 100644 --- a/.github/workflows/cross-chain-solana.yml +++ b/.github/workflows/cross-chain-solana.yml @@ -52,8 +52,8 @@ jobs: - name: Configure git to not use unauthenticated protocol run: git config --global url."https://".insteadOf git:// - - name: Install Solana - run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + - name: Install Rust + run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - name: Install Solana run: sh -c "$(curl -sSfL https://release.solana.com/v1.16.5/install)" From fd261c877676ddb5da2c7d8884d5dac2a3fbd0ac Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 25 Jul 2023 15:05:00 +0200 Subject: [PATCH 09/15] Installing additional dependencies for Anchor --- .github/workflows/cross-chain-solana.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cross-chain-solana.yml b/.github/workflows/cross-chain-solana.yml index 5caa7ad34..a537b2f37 100644 --- a/.github/workflows/cross-chain-solana.yml +++ b/.github/workflows/cross-chain-solana.yml @@ -61,6 +61,7 @@ jobs: - name: Install Anchor run: | cargo install --git https://github.com/coral-xyz/anchor --tag v0.28.0 anchor-cli --locked + apt-get update && apt-get upgrade && apt-get install -y pkg-config build-essential libudev-dev libssl-dev avm install latest avm use latest From c6a7913a38ffee0e2e59b0eac0a7e41c2215b44c Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 25 Jul 2023 16:33:15 +0200 Subject: [PATCH 10/15] Pinning achor version to 0.28.0 --- .github/workflows/cross-chain-solana.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/cross-chain-solana.yml b/.github/workflows/cross-chain-solana.yml index a537b2f37..131c7ee53 100644 --- a/.github/workflows/cross-chain-solana.yml +++ b/.github/workflows/cross-chain-solana.yml @@ -61,9 +61,6 @@ jobs: - name: Install Anchor run: | cargo install --git https://github.com/coral-xyz/anchor --tag v0.28.0 anchor-cli --locked - apt-get update && apt-get upgrade && apt-get install -y pkg-config build-essential libudev-dev libssl-dev - avm install latest - avm use latest - name: Install dependencies run: yarn install From b39d8eccf7ccd379002d121b8835190dc8e0b9af Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 25 Jul 2023 17:44:28 +0200 Subject: [PATCH 11/15] Checking solana version --- cross-chain/solana/Anchor.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cross-chain/solana/Anchor.toml b/cross-chain/solana/Anchor.toml index 415474b08..079acb4f3 100644 --- a/cross-chain/solana/Anchor.toml +++ b/cross-chain/solana/Anchor.toml @@ -2,14 +2,14 @@ seeds = false skip-lint = false [programs.localnet] -tbtc = "HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG" +tbtc = "H5ZSi4XCPyktRH2vLT3eNq6vjZfxnmnkjH7MAGnApkRq" [registry] url = "https://api.apr.dev" [provider] cluster = "Localnet" -wallet = "~/.config/solana/id.json" +wallet = "/Users/dp/.config/solana/id.json" [scripts] test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" From b0a3be6506bdb584778449b09b9e8a71dc690707 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 25 Jul 2023 17:52:04 +0200 Subject: [PATCH 12/15] Validating solana installation --- .github/workflows/cross-chain-solana.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cross-chain-solana.yml b/.github/workflows/cross-chain-solana.yml index 131c7ee53..b22d43127 100644 --- a/.github/workflows/cross-chain-solana.yml +++ b/.github/workflows/cross-chain-solana.yml @@ -56,7 +56,9 @@ jobs: run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - name: Install Solana - run: sh -c "$(curl -sSfL https://release.solana.com/v1.16.5/install)" + run: | + sh -c "$(curl -sSfL https://release.solana.com/v1.16.5/install)" + export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" - name: Install Anchor run: | @@ -66,10 +68,14 @@ jobs: run: yarn install - name: Build contracts - run: yarn build + run: | + export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" + yarn build - name: Run tests - run: yarn test + run: | + export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" + yarn test contracts-format: needs: contracts-detect-changes From 7041fbff2f3871437934eb825eb25a575e494781 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 26 Jul 2023 09:32:56 +0200 Subject: [PATCH 13/15] Generating new keys for testing purposes --- .github/workflows/cross-chain-solana.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cross-chain-solana.yml b/.github/workflows/cross-chain-solana.yml index b22d43127..adfc0dd04 100644 --- a/.github/workflows/cross-chain-solana.yml +++ b/.github/workflows/cross-chain-solana.yml @@ -74,7 +74,8 @@ jobs: - name: Run tests run: | - export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" + export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" + solana-keygen new yarn test contracts-format: From 1f777ddfe08699aeabb3ad58b068dba96ac2b174 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 26 Jul 2023 10:02:24 +0200 Subject: [PATCH 14/15] Setting a keyfile manually for testing purposes There is a problem with a solana-keygen new command that I don't know how to solve. Instead I'm adding a keyfile manually just for the testing purposes. --- .github/workflows/cross-chain-solana.yml | 17 ++++++++--------- cross-chain/solana/Anchor.toml | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cross-chain-solana.yml b/.github/workflows/cross-chain-solana.yml index adfc0dd04..0c3f87b3e 100644 --- a/.github/workflows/cross-chain-solana.yml +++ b/.github/workflows/cross-chain-solana.yml @@ -52,14 +52,14 @@ jobs: - name: Configure git to not use unauthenticated protocol run: git config --global url."https://".insteadOf git:// - - name: Install Rust - run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - - name: Install Solana run: | sh -c "$(curl -sSfL https://release.solana.com/v1.16.5/install)" export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" + - name: Install Rust + run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + - name: Install Anchor run: | cargo install --git https://github.com/coral-xyz/anchor --tag v0.28.0 anchor-cli --locked @@ -67,15 +67,14 @@ jobs: - name: Install dependencies run: yarn install - - name: Build contracts - run: | - export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" - yarn build + - name: Anchor build + run: yarn build + # There is problem with a `solana-keygen new` command. The workaround is to create a keyfile manually just for testing purposes. - name: Run tests run: | - export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" - solana-keygen new + solana config set -u localhost + echo "[132,196,51,204,234,79,135,213,169,81,250,90,73,168,28,41,193,49,153,71,192,44,228,74,230,78,211,95,54,241,137,50,119,155,54,147,229,137,197,57,146,111,140,177,222,54,120,254,254,250,191,135,251,47,163,16,180,160,110,108,54,111,84,76]" >> ~/.config/solana/id.json yarn test contracts-format: diff --git a/cross-chain/solana/Anchor.toml b/cross-chain/solana/Anchor.toml index 079acb4f3..415474b08 100644 --- a/cross-chain/solana/Anchor.toml +++ b/cross-chain/solana/Anchor.toml @@ -2,14 +2,14 @@ seeds = false skip-lint = false [programs.localnet] -tbtc = "H5ZSi4XCPyktRH2vLT3eNq6vjZfxnmnkjH7MAGnApkRq" +tbtc = "HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG" [registry] url = "https://api.apr.dev" [provider] cluster = "Localnet" -wallet = "/Users/dp/.config/solana/id.json" +wallet = "~/.config/solana/id.json" [scripts] test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" From 7252182f20d7d2acbf352a9a7e8d4d138120c820 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 26 Jul 2023 16:56:10 +0200 Subject: [PATCH 15/15] Exporting solana PATH --- .github/workflows/cross-chain-solana.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cross-chain-solana.yml b/.github/workflows/cross-chain-solana.yml index 0c3f87b3e..d8c21c2ae 100644 --- a/.github/workflows/cross-chain-solana.yml +++ b/.github/workflows/cross-chain-solana.yml @@ -68,11 +68,14 @@ jobs: run: yarn install - name: Anchor build - run: yarn build + run: | + export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" + yarn build # There is problem with a `solana-keygen new` command. The workaround is to create a keyfile manually just for testing purposes. - name: Run tests run: | + export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" solana config set -u localhost echo "[132,196,51,204,234,79,135,213,169,81,250,90,73,168,28,41,193,49,153,71,192,44,228,74,230,78,211,95,54,241,137,50,119,155,54,147,229,137,197,57,146,111,140,177,222,54,120,254,254,250,191,135,251,47,163,16,180,160,110,108,54,111,84,76]" >> ~/.config/solana/id.json yarn test