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
|
||||
# os = "linux" # Ignore advisories for operating systems other than this one
|
||||
|
||||
[packages]
|
||||
source = "all" # "all", "public" or "local"
|
||||
#[packages]
|
||||
#source = "all" # "all", "public" or "local"
|
||||
|
||||
[yanked]
|
||||
enabled = false # Warn for yanked crates in Cargo.lock (default: true)
|
||||
|
|
|
@ -6,7 +6,7 @@ on:
|
|||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
SOLANA_VERSION: "1.9.5"
|
||||
SOLANA_VERSION: "1.14.10"
|
||||
RUST_TOOLCHAIN: stable
|
||||
|
||||
defaults:
|
||||
|
@ -68,5 +68,5 @@ jobs:
|
|||
echo "Generating keypair..."
|
||||
solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent
|
||||
|
||||
- name: Run bpf tests
|
||||
run: cargo test-bpf
|
||||
- name: Run sbf tests
|
||||
run: cargo test-sbf
|
||||
|
|
|
@ -7,7 +7,7 @@ on:
|
|||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
SOLANA_VERSION: "1.9.5"
|
||||
SOLANA_VERSION: "1.14.10"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
anchor_version = "0.20.1"
|
||||
solana_version = "1.9.5"
|
||||
anchor_version = "0.26.0"
|
||||
solana_version = "1.14.10"
|
||||
|
||||
[programs.localnet]
|
||||
voter_stake_registry = "4Q6WW2ouZ6V3iaNm56MTd5n2tnTm4C5fiH8miFHnAFHo"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,7 +34,7 @@ Users can:
|
|||
|
||||
## Rust
|
||||
* 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`
|
||||
* To install the typescript client, do - `yarn add @blockworks-foundation/voter-stake-registry-client`
|
||||
* usage
|
||||
|
|
|
@ -6,7 +6,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
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_json = "^1.0"
|
||||
|
|
|
@ -17,12 +17,12 @@ no-idl = []
|
|||
cpi = ["no-entrypoint"]
|
||||
default = []
|
||||
localnet = []
|
||||
test-bpf = []
|
||||
test-sbf = []
|
||||
|
||||
[dependencies]
|
||||
# a) for deployment use these
|
||||
anchor-lang = { version = "0.24.2", features = ["init-if-needed"] }
|
||||
anchor-spl = { version = "0.24.2" }
|
||||
anchor-lang = { version = "0.26.0", features = ["init-if-needed"] }
|
||||
anchor-spl = { version = "0.26.0" }
|
||||
# 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-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-addin-api = "=0.1.1"
|
||||
|
||||
solana-program = "~1.9.13"
|
||||
solana-program = "1.14.10"
|
||||
static_assertions = "1.1"
|
||||
|
||||
[dev-dependencies]
|
||||
solana-sdk = "~1.9.13"
|
||||
solana-program-test = "~1.9.13"
|
||||
solana-logger = "~1.9.13"
|
||||
solana-sdk = "1.14.10"
|
||||
solana-program-test = "1.14.10"
|
||||
solana-logger = "1.14.10"
|
||||
spl-token = { version = "^3.0.0", features = ["no-entrypoint"] }
|
||||
spl-associated-token-account = { version = "^1.0.3", features = ["no-entrypoint"] }
|
||||
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 locking_info = (seconds_left > 0).then(|| LockingInfo {
|
||||
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 {
|
||||
rate: deposit
|
||||
.amount_initially_locked_native
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(clippy::result_large_err)]
|
||||
|
||||
use anchor_lang::prelude::*;
|
||||
use instructions::*;
|
||||
use state::*;
|
||||
|
@ -120,6 +122,7 @@ pub mod voter_stake_registry {
|
|||
instructions::withdraw(ctx, deposit_entry_index, amount)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn grant(
|
||||
ctx: Context<Grant>,
|
||||
voter_bump: u8,
|
||||
|
|
|
@ -145,7 +145,7 @@ impl DepositEntry {
|
|||
max_locked_vote_weight: u64,
|
||||
lockup_saturation_secs: u64,
|
||||
) -> Result<u64> {
|
||||
let mut altered = self.clone();
|
||||
let mut altered = *self;
|
||||
|
||||
// Trigger the unlock phase for constant lockups
|
||||
if self.lockup.kind == LockupKind::Constant {
|
||||
|
|
|
@ -163,7 +163,7 @@ impl Lockup {
|
|||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(AnchorSerialize, AnchorDeserialize, Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(AnchorSerialize, AnchorDeserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum LockupKind {
|
||||
/// No lockup, tokens can be withdrawn as long as not engaged in a proposal.
|
||||
None,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::transport::TransportError;
|
||||
|
||||
use solana_sdk::{
|
||||
instruction::Instruction,
|
||||
signature::{Keypair, Signer},
|
||||
|
@ -234,7 +234,7 @@ impl AddinCookie {
|
|||
start_ts: Option<u64>,
|
||||
periods: u32,
|
||||
allow_clawback: bool,
|
||||
) -> std::result::Result<(), TransportError> {
|
||||
) -> std::result::Result<(), BanksClientError> {
|
||||
let vault = voter.vault_address(&voting_mint);
|
||||
|
||||
let data = anchor_lang::InstructionData::data(
|
||||
|
@ -287,7 +287,7 @@ impl AddinCookie {
|
|||
token_address: Pubkey,
|
||||
deposit_entry_index: u8,
|
||||
amount: u64,
|
||||
) -> std::result::Result<(), TransportError> {
|
||||
) -> std::result::Result<(), BanksClientError> {
|
||||
let vault = voter.vault_address(&voting_mint);
|
||||
|
||||
let data =
|
||||
|
@ -336,7 +336,7 @@ impl AddinCookie {
|
|||
deposit_token: Pubkey,
|
||||
token_authority: &Keypair,
|
||||
grant_authority: &Keypair,
|
||||
) -> std::result::Result<VoterCookie, TransportError> {
|
||||
) -> std::result::Result<VoterCookie, BanksClientError> {
|
||||
let (voter, voter_bump) = Pubkey::find_program_address(
|
||||
&[
|
||||
®istrar.address.to_bytes(),
|
||||
|
@ -417,7 +417,7 @@ impl AddinCookie {
|
|||
realm_authority: &Keypair,
|
||||
token_address: Pubkey,
|
||||
deposit_entry_index: u8,
|
||||
) -> std::result::Result<(), TransportError> {
|
||||
) -> std::result::Result<(), BanksClientError> {
|
||||
let vault = voter.vault_address(&voting_mint);
|
||||
|
||||
let data =
|
||||
|
@ -461,7 +461,7 @@ impl AddinCookie {
|
|||
token_address: Pubkey,
|
||||
deposit_entry_index: u8,
|
||||
amount: u64,
|
||||
) -> std::result::Result<(), TransportError> {
|
||||
) -> std::result::Result<(), BanksClientError> {
|
||||
let vault = voter.vault_address(&voting_mint);
|
||||
|
||||
let data =
|
||||
|
@ -505,7 +505,7 @@ impl AddinCookie {
|
|||
voter: &VoterCookie,
|
||||
voting_mint: &VotingMintConfigCookie,
|
||||
voter_authority: &Keypair,
|
||||
) -> std::result::Result<(), TransportError> {
|
||||
) -> std::result::Result<(), BanksClientError> {
|
||||
let vault = voter.vault_address(&voting_mint);
|
||||
|
||||
let data =
|
||||
|
@ -568,7 +568,7 @@ impl AddinCookie {
|
|||
&self,
|
||||
registrar: &RegistrarCookie,
|
||||
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)];
|
||||
|
||||
self.solana.process_transaction(&instructions, None).await?;
|
||||
|
@ -587,7 +587,7 @@ impl AddinCookie {
|
|||
voter: &VoterCookie,
|
||||
authority: &Keypair,
|
||||
deposit_entry_index: u8,
|
||||
) -> Result<(), TransportError> {
|
||||
) -> Result<(), BanksClientError> {
|
||||
let data = anchor_lang::InstructionData::data(
|
||||
&voter_stake_registry::instruction::CloseDepositEntry {
|
||||
deposit_entry_index,
|
||||
|
@ -625,7 +625,7 @@ impl AddinCookie {
|
|||
deposit_entry_index: u8,
|
||||
kind: voter_stake_registry::state::LockupKind,
|
||||
periods: u32,
|
||||
) -> Result<(), TransportError> {
|
||||
) -> Result<(), BanksClientError> {
|
||||
let data =
|
||||
anchor_lang::InstructionData::data(&voter_stake_registry::instruction::ResetLockup {
|
||||
deposit_entry_index,
|
||||
|
@ -665,7 +665,7 @@ impl AddinCookie {
|
|||
source_deposit_entry_index: u8,
|
||||
target_deposit_entry_index: u8,
|
||||
amount: u64,
|
||||
) -> Result<(), TransportError> {
|
||||
) -> Result<(), BanksClientError> {
|
||||
let data = anchor_lang::InstructionData::data(
|
||||
&voter_stake_registry::instruction::InternalTransferLocked {
|
||||
source_deposit_entry_index,
|
||||
|
@ -706,7 +706,7 @@ impl AddinCookie {
|
|||
source_deposit_entry_index: u8,
|
||||
target_deposit_entry_index: u8,
|
||||
amount: u64,
|
||||
) -> Result<(), TransportError> {
|
||||
) -> Result<(), BanksClientError> {
|
||||
let data = anchor_lang::InstructionData::data(
|
||||
&voter_stake_registry::instruction::InternalTransferUnlocked {
|
||||
source_deposit_entry_index,
|
||||
|
|
|
@ -258,7 +258,7 @@ impl GovernanceRealmCookie {
|
|||
voter: &VoterCookie,
|
||||
payer: &Keypair,
|
||||
vwr_instruction: Instruction,
|
||||
) -> std::result::Result<ProposalCookie, TransportError> {
|
||||
) -> std::result::Result<ProposalCookie, BanksClientError> {
|
||||
let proposal = spl_governance::state::proposal::get_proposal_address(
|
||||
&self.governance.program_id,
|
||||
&governance,
|
||||
|
@ -325,7 +325,7 @@ impl GovernanceRealmCookie {
|
|||
authority: &Keypair,
|
||||
payer: &Keypair,
|
||||
vwr_instruction: Instruction,
|
||||
) -> std::result::Result<(), TransportError> {
|
||||
) -> std::result::Result<(), BanksClientError> {
|
||||
let instructions = vec![
|
||||
vwr_instruction,
|
||||
spl_governance::instruction::cast_vote(
|
||||
|
@ -364,7 +364,7 @@ impl GovernanceRealmCookie {
|
|||
token_owner_record: Pubkey,
|
||||
authority: &Keypair,
|
||||
beneficiary: Pubkey,
|
||||
) -> std::result::Result<(), TransportError> {
|
||||
) -> std::result::Result<(), BanksClientError> {
|
||||
let instructions = vec![spl_governance::instruction::relinquish_vote(
|
||||
&self.governance.program_id,
|
||||
&governance,
|
||||
|
|
|
@ -11,7 +11,6 @@ use solana_sdk::{
|
|||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
transaction::Transaction,
|
||||
transport::TransportError,
|
||||
};
|
||||
use spl_token::*;
|
||||
|
||||
|
@ -27,7 +26,7 @@ impl SolanaCookie {
|
|||
&self,
|
||||
instructions: &[Instruction],
|
||||
signers: Option<&[&Keypair]>,
|
||||
) -> Result<(), TransportError> {
|
||||
) -> Result<(), BanksClientError> {
|
||||
*self.program_output.write().unwrap() = super::ProgramOutput::default();
|
||||
|
||||
let mut context = self.context.borrow_mut();
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![cfg(feature = "test-sbf")]
|
||||
|
||||
use anchor_spl::token::TokenAccount;
|
||||
use program_test::*;
|
||||
use solana_program_test::*;
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
set -euo pipefail
|
||||
|
||||
cargo test-bpf
|
||||
cargo test-sbf
|
Loading…
Reference in New Issue