lang, cli, spl: Update solana toolchain to v1.9.13 (#1653)

Co-authored-by: Paul Schaaf <paulsimonschaaf@gmail.com>
This commit is contained in:
Kirill Fomichev 2022-03-27 03:28:55 +03:00 committed by GitHub
parent a2e760c50c
commit 40ea715beb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 584 additions and 679 deletions

View File

@ -8,7 +8,7 @@ on:
branches:
- master
env:
SOLANA_CLI_VERSION: 1.8.14
SOLANA_CLI_VERSION: 1.9.13
NODE_VERSION: 17.0.1
jobs:
@ -239,6 +239,56 @@ jobs:
- run: cd tests/bpf-upgradeable-state && cp bpf_upgradeable_state-keypair.json target/deploy/bpf_upgradeable_state-keypair.json && anchor test --skip-local-validator --skip-build --skip-lint
- uses: ./.github/actions/git-diff/
# this test exists to make sure that anchor
# checks rent correctly for legacy accounts
# that don't have to be rent-exempt
test-misc-non-rent-exempt:
# the anchor cli is built with a different solana version
# but that's fine since it's just the cli
needs: setup-anchor-cli
name: Test tests/misc/nonRentExempt
runs-on: ubuntu-18.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup/
- uses: ./.github/actions/setup-ts/
- uses: actions/cache@v2
name: Cache Solana Tool Suite
id: cache-solana
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-${{ runner.os }}-v0000-1.8.14
# using an outdated validator but that
# is ok as long as the test doesn't
# include newer incompatible features
- run: sh -c "$(curl -sSfL https://release.solana.com/v1.8.14/install)"
shell: bash
- run: echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
shell: bash
- run: solana-keygen new --no-bip39-passphrase
shell: bash
- run: solana config set --url localhost
shell: bash
- uses: actions/download-artifact@v2
with:
name: anchor-binary
path: ~/.cargo/bin/
- run: chmod +x ~/.cargo/bin/anchor
- uses: actions/cache@v2
name: Cache tests/misc target
id: cache-test-target
with:
path: tests/misc/target
key: cargo-${{ runner.os }}-tests/misc-${{ env.ANCHOR_VERSION }}-1.8.14-${{ hashFiles('**/Cargo.lock') }}
- run: cd tests/misc && yarn --frozen-lockfile
- run: cd tests/misc && yarn link @project-serum/anchor
- run: cd tests/misc && chmod +x ci.sh && ./ci.sh
- run: cd tests/misc && anchor test --skip-lint
test-anchor-init:
needs: setup-anchor-cli
name: Test Anchor Init

View File

@ -25,6 +25,7 @@ The minor version will be incremented upon a breaking change and the patch versi
* avm: `amv install` switches to the newly installed version after installation finishes ([#1670](https://github.com/project-serum/anchor/pull/1670)).
* spl: Re-export the `spl_token` crate ([#1665](https://github.com/project-serum/anchor/pull/1665)).
* lang, cli, spl: Update solana toolchain to v1.9.13 ([#1653](https://github.com/project-serum/anchor/pull/1653)).
## [0.23.0] - 2022-03-20

880
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -25,11 +25,11 @@ shellexpand = "2.1.0"
toml = "0.5.8"
semver = "1.0.4"
serde = { version = "1.0.122", features = ["derive"] }
solana-sdk = "~1.8.14"
solana-program = "~1.8.14"
solana-client = "~1.8.14"
solana-cli-config = "~1.8.14"
solana-faucet = "~1.8.14"
solana-sdk = "~1.9.13"
solana-program = "~1.9.13"
solana-client = "~1.9.13"
solana-cli-config = "~1.9.13"
solana-faucet = "~1.9.13"
dirs = "3.0"
heck = "0.3.1"
flate2 = "1.0.19"

View File

@ -1558,12 +1558,12 @@ fn idl_set_buffer(cfg_override: &ConfigOverride, program_id: Pubkey, buffer: Pub
};
// Build the transaction.
let (recent_hash, _fee_calc) = client.get_recent_blockhash()?;
let latest_hash = client.get_latest_blockhash()?;
let tx = Transaction::new_signed_with_payer(
&[set_buffer_ix],
Some(&keypair.pubkey()),
&[&keypair],
recent_hash,
latest_hash,
);
// Send the transaction.
@ -1649,12 +1649,12 @@ fn idl_set_authority(
data,
};
// Send transaction.
let (recent_hash, _fee_calc) = client.get_recent_blockhash()?;
let latest_hash = client.get_latest_blockhash()?;
let tx = Transaction::new_signed_with_payer(
&[ix],
Some(&keypair.pubkey()),
&[&keypair],
recent_hash,
latest_hash,
);
client.send_and_confirm_transaction_with_spinner_and_config(
&tx,
@ -1734,12 +1734,12 @@ fn idl_write(cfg: &Config, program_id: &Pubkey, idl: &Idl, idl_address: Pubkey)
data,
};
// Send transaction.
let (recent_hash, _fee_calc) = client.get_recent_blockhash()?;
let latest_hash = client.get_latest_blockhash()?;
let tx = Transaction::new_signed_with_payer(
&[ix],
Some(&keypair.pubkey()),
&[&keypair],
recent_hash,
latest_hash,
);
client.send_and_confirm_transaction_with_spinner_and_config(
&tx,
@ -2179,7 +2179,7 @@ fn start_test_validator(
.and_then(|test| test.startup_wait)
.unwrap_or(5_000);
while count < ms_wait {
let r = client.get_recent_blockhash();
let r = client.get_latest_blockhash();
if r.is_ok() {
break;
}
@ -2188,7 +2188,7 @@ fn start_test_validator(
}
if count == ms_wait {
eprintln!(
"Unable to get recent blockhash. Test validator does not look started. Check {} for errors. Consider increasing [test.startup_wait] in Anchor.toml.",
"Unable to get latest blockhash. Test validator does not look started. Check {} for errors. Consider increasing [test.startup_wait] in Anchor.toml.",
test_ledger_log_filename
);
validator_handle.kill()?;
@ -2408,12 +2408,12 @@ fn create_idl_account(
accounts,
data,
};
let (recent_hash, _fee_calc) = client.get_recent_blockhash()?;
let latest_hash = client.get_latest_blockhash()?;
let tx = Transaction::new_signed_with_payer(
&[ix],
Some(&keypair.pubkey()),
&[&keypair],
recent_hash,
latest_hash,
);
client.send_and_confirm_transaction_with_spinner_and_config(
&tx,
@ -2474,12 +2474,12 @@ fn create_idl_buffer(
};
// Build the transaction.
let (recent_hash, _fee_calc) = client.get_recent_blockhash()?;
let latest_hash = client.get_latest_blockhash()?;
let tx = Transaction::new_signed_with_payer(
&[create_account_ix, create_buffer_ix],
Some(&keypair.pubkey()),
&[&keypair, &buffer],
recent_hash,
latest_hash,
);
// Send the transaction.

View File

@ -544,12 +544,12 @@ impl<'a> RequestBuilder<'a> {
let rpc_client = RpcClient::new_with_commitment(self.cluster, self.options);
let tx = {
let (recent_hash, _fee_calc) = rpc_client.get_recent_blockhash()?;
let latest_hash = rpc_client.get_latest_blockhash()?;
Transaction::new_signed_with_payer(
&instructions,
Some(&self.payer.pubkey()),
&signers,
recent_hash,
latest_hash,
)
};

View File

@ -6,7 +6,7 @@ ANCHOR_CLI=v$(shell awk -F ' = ' '$$1 ~ /version/ { gsub(/[\"]/, "", $$2); print
#
# Solana toolchain.
#
SOLANA_CLI=v1.8.14
SOLANA_CLI=v1.9.13
#
# Build version should match the Anchor cli version.
#

View File

@ -39,6 +39,6 @@ arrayref = "0.3.6"
base64 = "0.13.0"
borsh = "0.9"
bytemuck = "1.4.0"
solana-program = "~1.8.14"
solana-program = "~1.9.13"
thiserror = "1.0.20"
bincode = "1.3.3"

View File

@ -254,9 +254,7 @@ pub mod prelude {
pub use solana_program::pubkey::Pubkey;
pub use solana_program::sysvar::clock::Clock;
pub use solana_program::sysvar::epoch_schedule::EpochSchedule;
pub use solana_program::sysvar::fees::Fees;
pub use solana_program::sysvar::instructions::Instructions;
pub use solana_program::sysvar::recent_blockhashes::RecentBlockhashes;
pub use solana_program::sysvar::rent::Rent;
pub use solana_program::sysvar::rewards::Rewards;
pub use solana_program::sysvar::slot_hashes::SlotHashes;

View File

@ -20,6 +20,6 @@ dex = ["serum_dex"]
[dependencies]
anchor-lang = { path = "../lang", version = "0.23.0", features = ["derive"] }
serum_dex = { git = "https://github.com/project-serum/serum-dex", rev = "1be91f2", version = "0.4.0", features = ["no-entrypoint"], optional = true }
solana-program = "~1.8.14"
solana-program = "~1.9.13"
spl-token = { version = "3.1.1", features = ["no-entrypoint"], optional = true }
spl-associated-token-account = { version = "1.0.3", features = ["no-entrypoint"], optional = true }

@ -1 +1 @@
Subproject commit 63e7bb81beb76f2722245a37c16a7b0b00d6905a
Subproject commit 967650c531ba0f23c88374875ccfcecb9b1a7800

View File

@ -3,7 +3,7 @@ cluster = "localnet"
wallet = "~/.config/solana/id.json"
[programs.localnet]
misc = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
misc = "3TEqcc8xhrhdspwbvoamUJe2borm4Nr72JxL66k6rgrh"
misc2 = "HmbTLCmaGvZhKnn1Zfa1JVnp7vkMV4DYVxPLWBVoN65L"
[[test.genesis]]

11
tests/misc/ci.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# this script ensures that the Misc test does not
# test the miscNonRentExempt.ts during its test in the ci
# because the misc test uses a newer solana version
# than the miscNonRentExempt one. The latter needs to be on
# a validator with a version < 1.9, so it can test
# whether anchor's rent-exemption checks work for
# legacy accounts which dont have to be rent-exempt
rm ./tests/misc.ts
mv miscNonRentExempt.ts ./tests/miscNonRentExempt.ts

View File

@ -0,0 +1,135 @@
import * as anchor from "@project-serum/anchor";
import { Program, BN, IdlAccounts, AnchorError } from "@project-serum/anchor";
import {
PublicKey,
Keypair,
SystemProgram,
SYSVAR_RENT_PUBKEY,
} from "@solana/web3.js";
import { Misc } from "../target/types/misc";
const { assert } = require("chai");
describe("miscNonRentExempt", () => {
// Configure the client to use the local cluster.
anchor.setProvider(anchor.Provider.env());
const program = anchor.workspace.Misc as Program<Misc>;
it("init_if_needed checks rent_exemption if init is not needed", async () => {
const data = Keypair.generate();
await program.rpc.initDecreaseLamports({
accounts: {
data: data.publicKey,
user: anchor.getProvider().wallet.publicKey,
systemProgram: SystemProgram.programId,
},
signers: [data],
});
try {
await program.rpc.initIfNeededChecksRentExemption({
accounts: {
data: data.publicKey,
user: anchor.getProvider().wallet.publicKey,
systemProgram: SystemProgram.programId,
},
signers: [data],
});
assert.ok(false);
} catch (_err) {
assert.isTrue(_err instanceof AnchorError);
const err: AnchorError = _err;
assert.strictEqual(err.error.errorCode.number, 2005);
}
});
it("allows non-rent exempt accounts", async () => {
const data = Keypair.generate();
await program.rpc.initializeNoRentExempt({
accounts: {
data: data.publicKey,
rent: SYSVAR_RENT_PUBKEY,
},
signers: [data],
instructions: [
SystemProgram.createAccount({
programId: program.programId,
space: 8 + 16 + 16,
lamports:
await program.provider.connection.getMinimumBalanceForRentExemption(
39
),
fromPubkey: anchor.getProvider().wallet.publicKey,
newAccountPubkey: data.publicKey,
}),
],
});
await program.rpc.testNoRentExempt({
accounts: {
data: data.publicKey,
},
});
});
it("allows rent exemption to be skipped", async () => {
const data = anchor.web3.Keypair.generate();
await program.rpc.initializeSkipRentExempt({
accounts: {
data: data.publicKey,
rent: SYSVAR_RENT_PUBKEY,
},
signers: [data],
instructions: [
SystemProgram.createAccount({
programId: program.programId,
space: 8 + 16 + 16,
lamports:
await program.provider.connection.getMinimumBalanceForRentExemption(
39
),
fromPubkey: anchor.getProvider().wallet.publicKey,
newAccountPubkey: data.publicKey,
}),
],
});
});
it("can use rent_exempt to enforce rent exemption", async () => {
const data = Keypair.generate();
await program.rpc.initializeSkipRentExempt({
accounts: {
data: data.publicKey,
rent: SYSVAR_RENT_PUBKEY,
},
signers: [data],
instructions: [
SystemProgram.createAccount({
programId: program.programId,
space: 8 + 16 + 16,
lamports:
await program.provider.connection.getMinimumBalanceForRentExemption(
39
),
fromPubkey: anchor.getProvider().wallet.publicKey,
newAccountPubkey: data.publicKey,
}),
],
});
try {
await program.rpc.testEnforceRentExempt({
accounts: {
data: data.publicKey,
},
});
assert.ok(false);
} catch (_err) {
assert.isTrue(_err instanceof AnchorError);
const err: AnchorError = _err;
assert.strictEqual(err.error.errorCode.number, 2005);
assert.strictEqual(
"A rent exemption constraint was violated",
err.error.errorMessage
);
}
});
});

View File

@ -11,7 +11,7 @@ mod account;
mod context;
mod event;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
declare_id!("3TEqcc8xhrhdspwbvoamUJe2borm4Nr72JxL66k6rgrh");
#[constant]
pub const BASE: u128 = 1_000_000;

View File

@ -12,6 +12,7 @@ import {
ASSOCIATED_TOKEN_PROGRAM_ID,
} from "@solana/spl-token";
import { Misc } from "../target/types/misc";
import { Misc2 } from "../target/types/misc2";
const utf8 = anchor.utils.bytes.utf8;
const { assert } = require("chai");
const nativeAssert = require("assert");
@ -20,8 +21,8 @@ const miscIdl = require("../target/idl/misc.json");
describe("misc", () => {
// Configure the client to use the local cluster.
anchor.setProvider(anchor.Provider.env());
const program = anchor.workspace.Misc;
const misc2Program = anchor.workspace.Misc2;
const program = anchor.workspace.Misc as Program<Misc>;
const misc2Program = anchor.workspace.Misc2 as Program<Misc2>;
it("Can allocate extra space for a state constructor", async () => {
const tx = await program.state.rpc.new();
@ -152,15 +153,15 @@ describe("misc", () => {
it("Can retrieve events when simulating a transaction", async () => {
const resp = await program.simulate.testSimulate(44);
const expectedRaw = [
"Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS invoke [1]",
"Program 3TEqcc8xhrhdspwbvoamUJe2borm4Nr72JxL66k6rgrh invoke [1]",
"Program log: Instruction: TestSimulate",
"Program data: NgyCA9omwbMsAAAA",
"Program data: fPhuIELK/k7SBAAA",
"Program data: jvbowsvlmkcJAAAA",
"Program data: zxM5neEnS1kBAgMEBQYHCAkK",
"Program data: g06Ei2GL1gIBAgMEBQYHCAkKCw==",
"Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS consumed 5320 of 200000 compute units",
"Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS success",
"Program 3TEqcc8xhrhdspwbvoamUJe2borm4Nr72JxL66k6rgrh consumed 5395 of 1400000 compute units",
"Program 3TEqcc8xhrhdspwbvoamUJe2borm4Nr72JxL66k6rgrh success",
];
assert.deepStrictEqual(expectedRaw, resp.raw);
@ -1456,34 +1457,6 @@ describe("misc", () => {
}
});
it("init_if_needed checks rent_exemption if init is not needed", async () => {
const data = anchor.web3.Keypair.generate();
await program.rpc.initDecreaseLamports({
accounts: {
data: data.publicKey,
user: anchor.getProvider().wallet.publicKey,
systemProgram: SystemProgram.programId,
},
signers: [data],
});
try {
await program.rpc.initIfNeededChecksRentExemption({
accounts: {
data: data.publicKey,
user: anchor.getProvider().wallet.publicKey,
systemProgram: SystemProgram.programId,
},
signers: [data],
});
assert.ok(false);
} catch (_err) {
assert.isTrue(_err instanceof AnchorError);
const err: AnchorError = _err;
assert.strictEqual(err.error.errorCode.number, 2005);
}
});
it("Can use multidimensional array", async () => {
const array2d = new Array(10).fill(new Array(10).fill(99));
const data = anchor.web3.Keypair.generate();
@ -1525,97 +1498,6 @@ describe("misc", () => {
assert.deepStrictEqual(dataAccount.data, array2d);
});
it("allows non-rent exempt accounts", async () => {
const data = anchor.web3.Keypair.generate();
await program.rpc.initializeNoRentExempt({
accounts: {
data: data.publicKey,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
signers: [data],
instructions: [
SystemProgram.createAccount({
programId: program.programId,
space: 8 + 16 + 16,
lamports:
await program.provider.connection.getMinimumBalanceForRentExemption(
39
),
fromPubkey: anchor.getProvider().wallet.publicKey,
newAccountPubkey: data.publicKey,
}),
],
});
await program.rpc.testNoRentExempt({
accounts: {
data: data.publicKey,
},
});
});
it("allows rent exemption to be skipped", async () => {
const data = anchor.web3.Keypair.generate();
await program.rpc.initializeSkipRentExempt({
accounts: {
data: data.publicKey,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
signers: [data],
instructions: [
SystemProgram.createAccount({
programId: program.programId,
space: 8 + 16 + 16,
lamports:
await program.provider.connection.getMinimumBalanceForRentExemption(
39
),
fromPubkey: anchor.getProvider().wallet.publicKey,
newAccountPubkey: data.publicKey,
}),
],
});
});
it("can use rent_exempt to enforce rent exemption", async () => {
const data = anchor.web3.Keypair.generate();
await program.rpc.initializeSkipRentExempt({
accounts: {
data: data.publicKey,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
signers: [data],
instructions: [
SystemProgram.createAccount({
programId: program.programId,
space: 8 + 16 + 16,
lamports:
await program.provider.connection.getMinimumBalanceForRentExemption(
39
),
fromPubkey: anchor.getProvider().wallet.publicKey,
newAccountPubkey: data.publicKey,
}),
],
});
try {
await program.rpc.testEnforceRentExempt({
accounts: {
data: data.publicKey,
},
});
assert.ok(false);
} catch (_err) {
assert.isTrue(_err instanceof AnchorError);
const err: AnchorError = _err;
assert.strictEqual(err.error.errorCode.number, 2005);
assert.strictEqual(
"A rent exemption constraint was violated",
err.error.errorMessage
);
}
});
describe("Can validate PDAs derived from other program ids", () => {
it("With bumps using create_program_address", async () => {
const [firstPDA, firstBump] =

View File

@ -38,7 +38,7 @@ async fn update_foo() {
let mut pt = ProgramTest::new("zero_copy", zero_copy::id(), None);
pt.add_account(foo_pubkey, foo_account);
pt.set_bpf_compute_max_units(3077);
pt.set_compute_max_units(3157);
let (mut banks_client, payer, recent_blockhash) = pt.start().await;
let client = Client::new_with_options(