Jelajahi Sumber

Bump Solana, Anchor and Ubuntu (#1389)

Solana 1.16.1
Ubuntu 22.04 rather than 20.04
Anchor 0.28.0

Signed-off-by: Sean Young <sean@mess.org>
Sean Young 2 tahun lalu
induk
melakukan
a1913b6953

+ 2 - 2
.github/workflows/release.yml

@@ -9,7 +9,7 @@ jobs:
   linux-x86-64:
     name: Linux x86-64
     runs-on: solang-ubuntu-latest
-    container: ghcr.io/hyperledger/solang-llvm:ci-3
+    container: ghcr.io/hyperledger/solang-llvm:ci-4
     steps:
     - name: Checkout sources
       uses: actions/checkout@v3.1.0
@@ -33,7 +33,7 @@ jobs:
     name: Linux arm64
     runs-on: linux-arm64
     if: ${{ github.repository_owner == 'hyperledger' }}
-    container: ghcr.io/hyperledger/solang-llvm:ci-3
+    container: ghcr.io/hyperledger/solang-llvm:ci-4
     steps:
     - name: Checkout sources
       uses: actions/checkout@v3.1.0

+ 7 - 7
.github/workflows/test.yml

@@ -19,7 +19,7 @@ jobs:
   lints:
     name: Lints
     runs-on: solang-ubuntu-latest
-    container: ghcr.io/hyperledger/solang-llvm:ci-3
+    container: ghcr.io/hyperledger/solang-llvm:ci-4
     steps:
       - name: Checkout sources
         uses: actions/checkout@v3
@@ -71,7 +71,7 @@ jobs:
   linux-x86-64:
     name: Linux x86-64
     runs-on: solang-ubuntu-latest
-    container: ghcr.io/hyperledger/solang-llvm:ci-3
+    container: ghcr.io/hyperledger/solang-llvm:ci-4
     steps:
     - name: Checkout sources
       uses: actions/checkout@v3
@@ -86,14 +86,14 @@ jobs:
     - uses: actions/upload-artifact@v3.1.0
       with:
         name: solang-linux-x86-64
-        path: ./target/debug/solang 
+        path: ./target/debug/solang
 
 
   linux-arm:
     name: Linux Arm
     runs-on: linux-arm64
     if: ${{ github.repository_owner == 'hyperledger' }}
-    container: ghcr.io/hyperledger/solang-llvm:ci-3
+    container: ghcr.io/hyperledger/solang-llvm:ci-4
     steps:
     - name: Checkout sources
       uses: actions/checkout@v3
@@ -231,7 +231,7 @@ jobs:
   anchor:
     name: Anchor Integration test
     runs-on: solang-ubuntu-latest
-    container: ghcr.io/hyperledger/solang-llvm:ci-3
+    container: ghcr.io/hyperledger/solang-llvm:ci-4
     needs: linux-x86-64
     steps:
     - name: Checkout sources
@@ -278,7 +278,7 @@ jobs:
   solana:
     name: Solana Integration test
     runs-on: solang-ubuntu-latest
-    container: ghcr.io/hyperledger/solang-llvm:ci-3
+    container: ghcr.io/hyperledger/solang-llvm:ci-4
     needs: linux-x86-64
     steps:
     - name: Checkout sources
@@ -372,7 +372,7 @@ jobs:
       with:
         toolchain: stable
         default: true
-        override: true   
+        override: true
     - run: 'parallel solang compile -v --target substrate --release -o ./contracts/ ::: ../substrate/*.sol ../substrate/test/*.sol'
       working-directory: ./integration/subxt-tests
     - name: Deploy and test contracts

+ 2 - 2
Dockerfile

@@ -1,4 +1,4 @@
-FROM ghcr.io/hyperledger/solang-llvm:ci-3 as builder
+FROM ghcr.io/hyperledger/solang-llvm:ci-4 as builder
 
 COPY . src
 WORKDIR /src/stdlib/
@@ -9,7 +9,7 @@ RUN rustup default 1.68.0
 WORKDIR /src
 RUN cargo build --release
 
-FROM ubuntu:20.04
+FROM ubuntu:22.04
 COPY --from=builder /src/target/release/solang /usr/bin/solang
 
 LABEL org.opencontainers.image.title="Solang Solidity Compiler" \

+ 3 - 3
README.md

@@ -56,16 +56,16 @@ Now you can deploy the contract code using:
 solana program deploy flipper.so
 ```
 
-Now install `@project-serum/anchor`:
+Now install `@coral-xyz/anchor`:
 
 ```
-npm install @project-serum/anchor
+npm install @coral-xyz/anchor
 ```
 
 Save the following to `flipper.js`:
 ```javascript
 const { readFileSync } = require('fs');
-const anchor = require('@project-serum/anchor');
+const anchor = require('@coral-xyz/anchor');
 
 const IDL = JSON.parse(readFileSync('./flipper.json', 'utf8'));
 const PROGRAM_SO = readFileSync('./flipper.so');

+ 2 - 2
docs/targets/solana.rst

@@ -108,14 +108,14 @@ After deploying the program, you can start on the client side, which needs the a
 
 .. code-block:: bash
 
-    npm install @project-serum/anchor
+    npm install @coral-xyz/anchor
 
 Write the following javascript to a file called ``flipper.js``.
 
 .. code-block:: javascript
 
     const { readFileSync } = require('fs');
-    const anchor = require('@project-serum/anchor');
+    const anchor = require('@coral-xyz/anchor');
 
     const IDL = JSON.parse(readFileSync('./flipper.json', 'utf8'));
     const PROGRAM_SO = readFileSync('./flipper.so');

+ 2 - 2
integration/anchor/package.json

@@ -6,7 +6,7 @@
         "build": "solang compile tests/*.sol --target solana -v -o tests/"
     },
     "dependencies": {
-        "@project-serum/anchor": "^0.26.0",
+        "@coral-xyz/anchor": "^0.28.0",
         "ts-node": "^10.9.1",
         "tsc-node": "^0.0.3"
     },
@@ -21,4 +21,4 @@
         "ts-mocha": "^10.0.0",
         "typescript": "^4.3.5"
     }
-}
+}

+ 2 - 3
integration/anchor/programs/anchor/Cargo.toml

@@ -16,6 +16,5 @@ cpi = ["no-entrypoint"]
 default = []
 
 [dependencies]
-anchor-lang = "0.27.0"
-# solana-program 1.16.0 is broken, it depends on getrandom, which does not build for bpf
-solana-program = "=1.14.18"
+anchor-lang = "0.28.0"
+solana-program = "1.16.1"

+ 2 - 2
integration/anchor/tests/anchor.ts

@@ -1,8 +1,8 @@
 // SPDX-License-Identifier: Apache-2.0
 
 import expect from 'expect';
-import * as anchor from "@project-serum/anchor";
-import { Program } from "@project-serum/anchor";
+import * as anchor from "@coral-xyz/anchor";
+import { Program } from "@coral-xyz/anchor";
 import { Anchor } from "../target/types/anchor";
 
 describe("Anchor", () => {

+ 1 - 1
integration/anchor/tests/call_anchor.spec.ts

@@ -1,5 +1,5 @@
 import expect from 'expect';
-import { AnchorProvider, Program } from '@project-serum/anchor';
+import { AnchorProvider, Program } from '@coral-xyz/anchor';
 import {
     PublicKey, AccountMeta,
     Keypair, Signer,

+ 1 - 1
integration/solana/balances.spec.ts

@@ -3,7 +3,7 @@
 import expect from 'expect';
 import { Transaction, SystemProgram, sendAndConfirmTransaction } from '@solana/web3.js';
 import { loadContract } from './setup';
-import { BN } from '@project-serum/anchor';
+import { BN } from '@coral-xyz/anchor';
 
 describe('Deploy solang contract and test', function () {
     this.timeout(500000);

+ 1 - 1
integration/solana/calls.spec.ts

@@ -2,7 +2,7 @@
 
 import expect from 'expect';
 import { loadContract, loadContractWithProvider } from './setup';
-import { BN } from '@project-serum/anchor';
+import { BN } from '@coral-xyz/anchor';
 
 describe('Testing calls', function () {
     this.timeout(100000);

+ 6 - 6
integration/solana/create_contract.spec.ts

@@ -2,8 +2,8 @@
 
 import { Connection, Keypair, PublicKey, sendAndConfirmTransaction, SystemProgram, Transaction } from '@solana/web3.js';
 import expect from 'expect';
-import { Program, Provider, BN } from '@project-serum/anchor';
-import {create_account, loadContract} from './setup';
+import { Program, Provider, BN } from '@coral-xyz/anchor';
+import { create_account, loadContract } from './setup';
 import fs from 'fs';
 
 describe('ChildContract', function () {
@@ -147,14 +147,14 @@ describe('ChildContract', function () {
 
         await create_account(child, child_program, 8192);
         const signature = await program.methods.createWithoutAnnotation(child.publicKey)
-            .accounts( {dataAccount: storage.publicKey})
+            .accounts({ dataAccount: storage.publicKey })
             .remainingAccounts(
                 [
-                    {pubkey: child_program, isSigner: false, isWritable: false},
-                    {pubkey: child.publicKey, isSigner: true, isWritable: true}
+                    { pubkey: child_program, isSigner: false, isWritable: false },
+                    { pubkey: child.publicKey, isSigner: true, isWritable: true }
                 ]
             ).signers([child])
-            .rpc({ commitment: 'confirmed'});
+            .rpc({ commitment: 'confirmed' });
 
         const tx = await provider.connection.getTransaction(signature, {
             commitment: 'confirmed',

+ 1 - 1
integration/solana/errors.spec.ts

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: Apache-2.0
 
-import { BN } from '@project-serum/anchor';
+import { BN } from '@coral-xyz/anchor';
 import expect from 'expect';
 import { loadContract } from './setup';
 

+ 1 - 1
integration/solana/overflow.spec.ts

@@ -2,7 +2,7 @@
 
 import expect from 'expect';
 import { loadContract } from './setup';
-import { BN } from '@project-serum/anchor';
+import { BN } from '@coral-xyz/anchor';
 
 describe('Testing math overflow', function () {
     this.timeout(500000);

+ 2 - 2
integration/solana/package.json

@@ -17,7 +17,7 @@
     "typescript": "^4.1.2"
   },
   "dependencies": {
-    "@project-serum/anchor": "^0.26",
+    "@coral-xyz/anchor": "^0.28",
     "@solana/spl-token": "0.2.0",
     "@solana/web3.js": "^1.68",
     "ethers": "^5.2.0",
@@ -26,4 +26,4 @@
     "web3-eth-abi": "^1.3.0",
     "web3-utils": "^1.3.0"
   }
-}
+}

+ 4 - 4
integration/solana/runtime_errors.spec.ts

@@ -1,10 +1,10 @@
 // SPDX-License-Identifier: Apache-2.0
 
-import {Keypair, PublicKey, sendAndConfirmTransaction, SystemProgram, Transaction} from '@solana/web3.js';
+import { Keypair, PublicKey, sendAndConfirmTransaction, SystemProgram, Transaction } from '@solana/web3.js';
 import expect from 'expect';
-import {loadContract} from './setup';
-import {Program, Provider, BN, AnchorProvider} from '@project-serum/anchor';
-import {createAccount} from "@solana/spl-token";
+import { loadContract } from './setup';
+import { Program, Provider, BN, AnchorProvider } from '@coral-xyz/anchor';
+import { createAccount } from "@solana/spl-token";
 
 describe('Runtime Errors', function () {
     this.timeout(150000);

+ 1 - 1
integration/solana/setup.ts

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: Apache-2.0
 
 import { Connection, Keypair, LAMPORTS_PER_SOL, PublicKey, BpfLoader, Transaction, SystemProgram, BPF_LOADER_PROGRAM_ID, TransactionExpiredBlockheightExceededError } from '@solana/web3.js';
-import { AnchorProvider, Program } from '@project-serum/anchor';
+import { AnchorProvider, Program } from '@coral-xyz/anchor';
 import fs from 'fs';
 
 const endpoint: string = process.env.RPC_URL || "http://127.0.0.1:8899";

+ 1 - 1
integration/solana/simple.spec.ts

@@ -1,7 +1,7 @@
 import expect from 'expect';
 import { loadContract } from './setup';
 import crypto from 'crypto';
-import { BN } from '@project-serum/anchor';
+import { BN } from '@coral-xyz/anchor';
 
 describe('Simple solang tests', function () {
     this.timeout(500000);

+ 1 - 1
integration/solana/system_instruction.spec.ts

@@ -3,7 +3,7 @@
 import { loadContract } from "./setup";
 import { Keypair, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";
 import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
-import { BN } from '@project-serum/anchor';
+import { BN } from '@coral-xyz/anchor';
 
 
 describe('Test system instructions', function () {

+ 1 - 1
integration/solana/token.spec.ts

@@ -3,7 +3,7 @@
 import { getOrCreateAssociatedTokenAccount, createMint, TOKEN_PROGRAM_ID } from '@solana/spl-token';
 import { Keypair } from '@solana/web3.js';
 import { loadContract } from './setup';
-import { BN } from '@project-serum/anchor';
+import { BN } from '@coral-xyz/anchor';
 import expect from 'expect';
 
 describe('Create spl-token and use from solidity', function () {

+ 9 - 5
integration/solana/verify_sig.spec.ts

@@ -4,7 +4,7 @@ import { Keypair, Ed25519Program, SYSVAR_INSTRUCTIONS_PUBKEY, PublicKey } from '
 import expect from 'expect';
 import nacl from 'tweetnacl';
 import { loadContract } from './setup';
-import { Program } from '@project-serum/anchor';
+import { Program } from '@coral-xyz/anchor';
 
 describe('Signature Check', function () {
     this.timeout(150000);
@@ -30,8 +30,10 @@ describe('Signature Check', function () {
 
         const result = await program.methods.verify(payer.publicKey, message, Buffer.from(signature))
             .preInstructions([instr1])
-            .accounts({ dataAccount: storage.publicKey,
-                SysvarInstruction: SYSVAR_INSTRUCTIONS_PUBKEY})
+            .accounts({
+                dataAccount: storage.publicKey,
+                SysvarInstruction: SYSVAR_INSTRUCTIONS_PUBKEY
+            })
             .view();
 
         expect(result).toEqual(true);
@@ -54,8 +56,10 @@ describe('Signature Check', function () {
 
         const result = await program.methods.verify(payer.publicKey, message, Buffer.from(broken_signature))
             .preInstructions([instr1])
-            .accounts({ dataAccount: storage.publicKey,
-                SysvarInstruction: SYSVAR_INSTRUCTIONS_PUBKEY})
+            .accounts({
+                dataAccount: storage.publicKey,
+                SysvarInstruction: SYSVAR_INSTRUCTIONS_PUBKEY
+            })
             .view();
 
         expect(result).toEqual(false);