Merge pull request #55 from blockworks-foundation/anchor-v0-26-0-upgrade
Upgrade anchor to v0.26.0 Note: test_all_deposits timeouts on the CI build but works locally and needs to be investigated separately
This commit is contained in:
commit
62f96fee96
|
@ -27,8 +27,8 @@ show_tree = true # Show inverse dependency trees along with advisories (default:
|
||||||
# arch = "x86_64" # Ignore advisories for CPU architectures other than this one
|
# arch = "x86_64" # Ignore advisories for CPU architectures other than this one
|
||||||
# os = "linux" # Ignore advisories for operating systems other than this one
|
# os = "linux" # Ignore advisories for operating systems other than this one
|
||||||
|
|
||||||
[packages]
|
#[packages]
|
||||||
source = "all" # "all", "public" or "local"
|
#source = "all" # "all", "public" or "local"
|
||||||
|
|
||||||
[yanked]
|
[yanked]
|
||||||
enabled = false # Warn for yanked crates in Cargo.lock (default: true)
|
enabled = false # Warn for yanked crates in Cargo.lock (default: true)
|
||||||
|
|
|
@ -6,7 +6,7 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
SOLANA_VERSION: "1.9.5"
|
SOLANA_VERSION: "1.14.10"
|
||||||
RUST_TOOLCHAIN: stable
|
RUST_TOOLCHAIN: stable
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
|
@ -68,5 +68,5 @@ jobs:
|
||||||
echo "Generating keypair..."
|
echo "Generating keypair..."
|
||||||
solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent
|
solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent
|
||||||
|
|
||||||
- name: Run bpf tests
|
- name: Run sbf tests
|
||||||
run: cargo test-bpf
|
run: cargo test-sbf
|
||||||
|
|
|
@ -7,7 +7,7 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
SOLANA_VERSION: "1.9.5"
|
SOLANA_VERSION: "1.14.10"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
anchor_version = "0.20.1"
|
anchor_version = "0.26.0"
|
||||||
solana_version = "1.9.5"
|
solana_version = "1.14.10"
|
||||||
|
|
||||||
[programs.localnet]
|
[programs.localnet]
|
||||||
voter_stake_registry = "4Q6WW2ouZ6V3iaNm56MTd5n2tnTm4C5fiH8miFHnAFHo"
|
voter_stake_registry = "4Q6WW2ouZ6V3iaNm56MTd5n2tnTm4C5fiH8miFHnAFHo"
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,7 +34,7 @@ Users can:
|
||||||
|
|
||||||
## Rust
|
## Rust
|
||||||
* Built and developed using - rust stable(`rustc 1.57.0 (f1edd0429 2021-11-29)`)
|
* Built and developed using - rust stable(`rustc 1.57.0 (f1edd0429 2021-11-29)`)
|
||||||
* Run rust based tests - `cargo test-bpf`
|
* Run rust based tests - `cargo test-sbf`
|
||||||
* `run-generate-anchor-types.sh` generates latest anchor types file and writes to `./voter_stake_registry.ts`
|
* `run-generate-anchor-types.sh` generates latest anchor types file and writes to `./voter_stake_registry.ts`
|
||||||
* To install the typescript client, do - `yarn add @blockworks-foundation/voter-stake-registry-client`
|
* To install the typescript client, do - `yarn add @blockworks-foundation/voter-stake-registry-client`
|
||||||
* usage
|
* usage
|
||||||
|
|
|
@ -6,7 +6,7 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
voter-stake-registry = { path = "../programs/voter-stake-registry", features = ["no-entrypoint"] }
|
voter-stake-registry = { path = "../programs/voter-stake-registry", features = ["no-entrypoint"] }
|
||||||
|
|
||||||
anchor-lang = "0.24.2"
|
anchor-lang = "0.26.0"
|
||||||
|
|
||||||
serde = "^1.0"
|
serde = "^1.0"
|
||||||
serde_json = "^1.0"
|
serde_json = "^1.0"
|
||||||
|
|
|
@ -17,12 +17,12 @@ no-idl = []
|
||||||
cpi = ["no-entrypoint"]
|
cpi = ["no-entrypoint"]
|
||||||
default = []
|
default = []
|
||||||
localnet = []
|
localnet = []
|
||||||
test-bpf = []
|
test-sbf = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# a) for deployment use these
|
# a) for deployment use these
|
||||||
anchor-lang = { version = "0.24.2", features = ["init-if-needed"] }
|
anchor-lang = { version = "0.26.0", features = ["init-if-needed"] }
|
||||||
anchor-spl = { version = "0.24.2" }
|
anchor-spl = { version = "0.26.0" }
|
||||||
# b) while testing, use below dependencies for debugging instead of above ones
|
# b) while testing, use below dependencies for debugging instead of above ones
|
||||||
# anchor-lang = { git = "https://github.com/microwavedcola1/anchor.git", branch = "master-debug" }
|
# anchor-lang = { git = "https://github.com/microwavedcola1/anchor.git", branch = "master-debug" }
|
||||||
# anchor-spl = { git = "https://github.com/microwavedcola1/anchor.git", branch = "master-debug", features = ["governance"]}
|
# anchor-spl = { git = "https://github.com/microwavedcola1/anchor.git", branch = "master-debug", features = ["governance"]}
|
||||||
|
@ -39,13 +39,13 @@ bytemuck = "1.9.1"
|
||||||
spl-governance = { version = "=2.2.1", features = ["no-entrypoint"] }
|
spl-governance = { version = "=2.2.1", features = ["no-entrypoint"] }
|
||||||
spl-governance-addin-api = "=0.1.1"
|
spl-governance-addin-api = "=0.1.1"
|
||||||
|
|
||||||
solana-program = "~1.9.13"
|
solana-program = "1.14.10"
|
||||||
static_assertions = "1.1"
|
static_assertions = "1.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
solana-sdk = "~1.9.13"
|
solana-sdk = "1.14.10"
|
||||||
solana-program-test = "~1.9.13"
|
solana-program-test = "1.14.10"
|
||||||
solana-logger = "~1.9.13"
|
solana-logger = "1.14.10"
|
||||||
spl-token = { version = "^3.0.0", features = ["no-entrypoint"] }
|
spl-token = { version = "^3.0.0", features = ["no-entrypoint"] }
|
||||||
spl-associated-token-account = { version = "^1.0.3", features = ["no-entrypoint"] }
|
spl-associated-token-account = { version = "^1.0.3", features = ["no-entrypoint"] }
|
||||||
bytemuck = "^1.7.2"
|
bytemuck = "^1.7.2"
|
||||||
|
|
|
@ -50,7 +50,7 @@ pub fn log_voter_info(
|
||||||
let voting_mint_config = ®istrar.voting_mints[deposit.voting_mint_config_idx as usize];
|
let voting_mint_config = ®istrar.voting_mints[deposit.voting_mint_config_idx as usize];
|
||||||
let locking_info = (seconds_left > 0).then(|| LockingInfo {
|
let locking_info = (seconds_left > 0).then(|| LockingInfo {
|
||||||
amount: deposit.amount_locked(curr_ts),
|
amount: deposit.amount_locked(curr_ts),
|
||||||
end_timestamp: (lockup.kind != LockupKind::Constant).then(|| end_ts),
|
end_timestamp: (lockup.kind != LockupKind::Constant).then_some(end_ts),
|
||||||
vesting: lockup.kind.is_vesting().then(|| VestingInfo {
|
vesting: lockup.kind.is_vesting().then(|| VestingInfo {
|
||||||
rate: deposit
|
rate: deposit
|
||||||
.amount_initially_locked_native
|
.amount_initially_locked_native
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(clippy::result_large_err)]
|
||||||
|
|
||||||
use anchor_lang::prelude::*;
|
use anchor_lang::prelude::*;
|
||||||
use instructions::*;
|
use instructions::*;
|
||||||
use state::*;
|
use state::*;
|
||||||
|
@ -120,6 +122,7 @@ pub mod voter_stake_registry {
|
||||||
instructions::withdraw(ctx, deposit_entry_index, amount)
|
instructions::withdraw(ctx, deposit_entry_index, amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn grant(
|
pub fn grant(
|
||||||
ctx: Context<Grant>,
|
ctx: Context<Grant>,
|
||||||
voter_bump: u8,
|
voter_bump: u8,
|
||||||
|
|
|
@ -145,7 +145,7 @@ impl DepositEntry {
|
||||||
max_locked_vote_weight: u64,
|
max_locked_vote_weight: u64,
|
||||||
lockup_saturation_secs: u64,
|
lockup_saturation_secs: u64,
|
||||||
) -> Result<u64> {
|
) -> Result<u64> {
|
||||||
let mut altered = self.clone();
|
let mut altered = *self;
|
||||||
|
|
||||||
// Trigger the unlock phase for constant lockups
|
// Trigger the unlock phase for constant lockups
|
||||||
if self.lockup.kind == LockupKind::Constant {
|
if self.lockup.kind == LockupKind::Constant {
|
||||||
|
|
|
@ -163,7 +163,7 @@ impl Lockup {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(AnchorSerialize, AnchorDeserialize, Debug, Clone, Copy, PartialEq)]
|
#[derive(AnchorSerialize, AnchorDeserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum LockupKind {
|
pub enum LockupKind {
|
||||||
/// No lockup, tokens can be withdrawn as long as not engaged in a proposal.
|
/// No lockup, tokens can be withdrawn as long as not engaged in a proposal.
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
use solana_sdk::transport::TransportError;
|
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
instruction::Instruction,
|
instruction::Instruction,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
|
@ -234,7 +234,7 @@ impl AddinCookie {
|
||||||
start_ts: Option<u64>,
|
start_ts: Option<u64>,
|
||||||
periods: u32,
|
periods: u32,
|
||||||
allow_clawback: bool,
|
allow_clawback: bool,
|
||||||
) -> std::result::Result<(), TransportError> {
|
) -> std::result::Result<(), BanksClientError> {
|
||||||
let vault = voter.vault_address(&voting_mint);
|
let vault = voter.vault_address(&voting_mint);
|
||||||
|
|
||||||
let data = anchor_lang::InstructionData::data(
|
let data = anchor_lang::InstructionData::data(
|
||||||
|
@ -287,7 +287,7 @@ impl AddinCookie {
|
||||||
token_address: Pubkey,
|
token_address: Pubkey,
|
||||||
deposit_entry_index: u8,
|
deposit_entry_index: u8,
|
||||||
amount: u64,
|
amount: u64,
|
||||||
) -> std::result::Result<(), TransportError> {
|
) -> std::result::Result<(), BanksClientError> {
|
||||||
let vault = voter.vault_address(&voting_mint);
|
let vault = voter.vault_address(&voting_mint);
|
||||||
|
|
||||||
let data =
|
let data =
|
||||||
|
@ -336,7 +336,7 @@ impl AddinCookie {
|
||||||
deposit_token: Pubkey,
|
deposit_token: Pubkey,
|
||||||
token_authority: &Keypair,
|
token_authority: &Keypair,
|
||||||
grant_authority: &Keypair,
|
grant_authority: &Keypair,
|
||||||
) -> std::result::Result<VoterCookie, TransportError> {
|
) -> std::result::Result<VoterCookie, BanksClientError> {
|
||||||
let (voter, voter_bump) = Pubkey::find_program_address(
|
let (voter, voter_bump) = Pubkey::find_program_address(
|
||||||
&[
|
&[
|
||||||
®istrar.address.to_bytes(),
|
®istrar.address.to_bytes(),
|
||||||
|
@ -417,7 +417,7 @@ impl AddinCookie {
|
||||||
realm_authority: &Keypair,
|
realm_authority: &Keypair,
|
||||||
token_address: Pubkey,
|
token_address: Pubkey,
|
||||||
deposit_entry_index: u8,
|
deposit_entry_index: u8,
|
||||||
) -> std::result::Result<(), TransportError> {
|
) -> std::result::Result<(), BanksClientError> {
|
||||||
let vault = voter.vault_address(&voting_mint);
|
let vault = voter.vault_address(&voting_mint);
|
||||||
|
|
||||||
let data =
|
let data =
|
||||||
|
@ -461,7 +461,7 @@ impl AddinCookie {
|
||||||
token_address: Pubkey,
|
token_address: Pubkey,
|
||||||
deposit_entry_index: u8,
|
deposit_entry_index: u8,
|
||||||
amount: u64,
|
amount: u64,
|
||||||
) -> std::result::Result<(), TransportError> {
|
) -> std::result::Result<(), BanksClientError> {
|
||||||
let vault = voter.vault_address(&voting_mint);
|
let vault = voter.vault_address(&voting_mint);
|
||||||
|
|
||||||
let data =
|
let data =
|
||||||
|
@ -505,7 +505,7 @@ impl AddinCookie {
|
||||||
voter: &VoterCookie,
|
voter: &VoterCookie,
|
||||||
voting_mint: &VotingMintConfigCookie,
|
voting_mint: &VotingMintConfigCookie,
|
||||||
voter_authority: &Keypair,
|
voter_authority: &Keypair,
|
||||||
) -> std::result::Result<(), TransportError> {
|
) -> std::result::Result<(), BanksClientError> {
|
||||||
let vault = voter.vault_address(&voting_mint);
|
let vault = voter.vault_address(&voting_mint);
|
||||||
|
|
||||||
let data =
|
let data =
|
||||||
|
@ -568,7 +568,7 @@ impl AddinCookie {
|
||||||
&self,
|
&self,
|
||||||
registrar: &RegistrarCookie,
|
registrar: &RegistrarCookie,
|
||||||
voter: &VoterCookie,
|
voter: &VoterCookie,
|
||||||
) -> std::result::Result<voter_stake_registry::state::VoterWeightRecord, TransportError> {
|
) -> std::result::Result<voter_stake_registry::state::VoterWeightRecord, BanksClientError> {
|
||||||
let instructions = vec![self.update_voter_weight_record_instruction(registrar, voter)];
|
let instructions = vec![self.update_voter_weight_record_instruction(registrar, voter)];
|
||||||
|
|
||||||
self.solana.process_transaction(&instructions, None).await?;
|
self.solana.process_transaction(&instructions, None).await?;
|
||||||
|
@ -587,7 +587,7 @@ impl AddinCookie {
|
||||||
voter: &VoterCookie,
|
voter: &VoterCookie,
|
||||||
authority: &Keypair,
|
authority: &Keypair,
|
||||||
deposit_entry_index: u8,
|
deposit_entry_index: u8,
|
||||||
) -> Result<(), TransportError> {
|
) -> Result<(), BanksClientError> {
|
||||||
let data = anchor_lang::InstructionData::data(
|
let data = anchor_lang::InstructionData::data(
|
||||||
&voter_stake_registry::instruction::CloseDepositEntry {
|
&voter_stake_registry::instruction::CloseDepositEntry {
|
||||||
deposit_entry_index,
|
deposit_entry_index,
|
||||||
|
@ -625,7 +625,7 @@ impl AddinCookie {
|
||||||
deposit_entry_index: u8,
|
deposit_entry_index: u8,
|
||||||
kind: voter_stake_registry::state::LockupKind,
|
kind: voter_stake_registry::state::LockupKind,
|
||||||
periods: u32,
|
periods: u32,
|
||||||
) -> Result<(), TransportError> {
|
) -> Result<(), BanksClientError> {
|
||||||
let data =
|
let data =
|
||||||
anchor_lang::InstructionData::data(&voter_stake_registry::instruction::ResetLockup {
|
anchor_lang::InstructionData::data(&voter_stake_registry::instruction::ResetLockup {
|
||||||
deposit_entry_index,
|
deposit_entry_index,
|
||||||
|
@ -665,7 +665,7 @@ impl AddinCookie {
|
||||||
source_deposit_entry_index: u8,
|
source_deposit_entry_index: u8,
|
||||||
target_deposit_entry_index: u8,
|
target_deposit_entry_index: u8,
|
||||||
amount: u64,
|
amount: u64,
|
||||||
) -> Result<(), TransportError> {
|
) -> Result<(), BanksClientError> {
|
||||||
let data = anchor_lang::InstructionData::data(
|
let data = anchor_lang::InstructionData::data(
|
||||||
&voter_stake_registry::instruction::InternalTransferLocked {
|
&voter_stake_registry::instruction::InternalTransferLocked {
|
||||||
source_deposit_entry_index,
|
source_deposit_entry_index,
|
||||||
|
@ -706,7 +706,7 @@ impl AddinCookie {
|
||||||
source_deposit_entry_index: u8,
|
source_deposit_entry_index: u8,
|
||||||
target_deposit_entry_index: u8,
|
target_deposit_entry_index: u8,
|
||||||
amount: u64,
|
amount: u64,
|
||||||
) -> Result<(), TransportError> {
|
) -> Result<(), BanksClientError> {
|
||||||
let data = anchor_lang::InstructionData::data(
|
let data = anchor_lang::InstructionData::data(
|
||||||
&voter_stake_registry::instruction::InternalTransferUnlocked {
|
&voter_stake_registry::instruction::InternalTransferUnlocked {
|
||||||
source_deposit_entry_index,
|
source_deposit_entry_index,
|
||||||
|
|
|
@ -258,7 +258,7 @@ impl GovernanceRealmCookie {
|
||||||
voter: &VoterCookie,
|
voter: &VoterCookie,
|
||||||
payer: &Keypair,
|
payer: &Keypair,
|
||||||
vwr_instruction: Instruction,
|
vwr_instruction: Instruction,
|
||||||
) -> std::result::Result<ProposalCookie, TransportError> {
|
) -> std::result::Result<ProposalCookie, BanksClientError> {
|
||||||
let proposal = spl_governance::state::proposal::get_proposal_address(
|
let proposal = spl_governance::state::proposal::get_proposal_address(
|
||||||
&self.governance.program_id,
|
&self.governance.program_id,
|
||||||
&governance,
|
&governance,
|
||||||
|
@ -325,7 +325,7 @@ impl GovernanceRealmCookie {
|
||||||
authority: &Keypair,
|
authority: &Keypair,
|
||||||
payer: &Keypair,
|
payer: &Keypair,
|
||||||
vwr_instruction: Instruction,
|
vwr_instruction: Instruction,
|
||||||
) -> std::result::Result<(), TransportError> {
|
) -> std::result::Result<(), BanksClientError> {
|
||||||
let instructions = vec![
|
let instructions = vec![
|
||||||
vwr_instruction,
|
vwr_instruction,
|
||||||
spl_governance::instruction::cast_vote(
|
spl_governance::instruction::cast_vote(
|
||||||
|
@ -364,7 +364,7 @@ impl GovernanceRealmCookie {
|
||||||
token_owner_record: Pubkey,
|
token_owner_record: Pubkey,
|
||||||
authority: &Keypair,
|
authority: &Keypair,
|
||||||
beneficiary: Pubkey,
|
beneficiary: Pubkey,
|
||||||
) -> std::result::Result<(), TransportError> {
|
) -> std::result::Result<(), BanksClientError> {
|
||||||
let instructions = vec![spl_governance::instruction::relinquish_vote(
|
let instructions = vec![spl_governance::instruction::relinquish_vote(
|
||||||
&self.governance.program_id,
|
&self.governance.program_id,
|
||||||
&governance,
|
&governance,
|
||||||
|
|
|
@ -11,7 +11,6 @@ use solana_sdk::{
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
transaction::Transaction,
|
transaction::Transaction,
|
||||||
transport::TransportError,
|
|
||||||
};
|
};
|
||||||
use spl_token::*;
|
use spl_token::*;
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ impl SolanaCookie {
|
||||||
&self,
|
&self,
|
||||||
instructions: &[Instruction],
|
instructions: &[Instruction],
|
||||||
signers: Option<&[&Keypair]>,
|
signers: Option<&[&Keypair]>,
|
||||||
) -> Result<(), TransportError> {
|
) -> Result<(), BanksClientError> {
|
||||||
*self.program_output.write().unwrap() = super::ProgramOutput::default();
|
*self.program_output.write().unwrap() = super::ProgramOutput::default();
|
||||||
|
|
||||||
let mut context = self.context.borrow_mut();
|
let mut context = self.context.borrow_mut();
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![cfg(feature = "test-sbf")]
|
||||||
|
|
||||||
use anchor_spl::token::TokenAccount;
|
use anchor_spl::token::TokenAccount;
|
||||||
use program_test::*;
|
use program_test::*;
|
||||||
use solana_program_test::*;
|
use solana_program_test::*;
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
cargo test-bpf
|
cargo test-sbf
|
Loading…
Reference in New Issue