Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get stakers increase rpc client timeout significantly, base64 zstd #52

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cli/locked-voter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ anchor-lang = "0.28.0"
anchor-spl = "0.28.0"
anchor-client = "0.28.0"
solana-rpc-client-api = "1.16.12"
solana-account-decoder = "1.16.12"
anyhow = "1.0.57"
solana-program = "1.16.12"
govern = { path = "../../programs/govern" }
smart-wallet = { path = "../../programs/smart-wallet" }
utils-cli = {path ="../utils"}
utils-cli = {path ="../utils"}
35 changes: 31 additions & 4 deletions cli/locked-voter/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
mod args;
use crate::args::*;
use anchor_client::solana_client::rpc_client::RpcClient;
use anchor_client::solana_sdk::commitment_config::CommitmentConfig;
use anchor_client::solana_sdk::pubkey::Pubkey;
use anchor_client::solana_sdk::signer::keypair::*;
use anchor_client::solana_sdk::signer::Signer;
use anchor_client::{Client, Program};
use anchor_lang::AccountDeserialize;
use anchor_lang::Discriminator;
use anchor_lang::InstructionData;
use anchor_lang::ToAccountMetas;
use anchor_spl::associated_token::get_associated_token_address;
use anyhow::Result;
use clap::*;
use solana_account_decoder::UiAccountEncoding;
use solana_program::instruction::Instruction;
use solana_rpc_client_api::config::RpcAccountInfoConfig;
use solana_rpc_client_api::config::RpcProgramAccountsConfig;
use solana_rpc_client_api::filter::Memcmp;
use solana_rpc_client_api::filter::RpcFilterType;
use std::ops::Deref;
use std::rc::Rc;
use std::str::FromStr;
use std::time::Duration;

fn main() -> Result<()> {
let opts = Opts::parse();
Expand Down Expand Up @@ -487,11 +494,31 @@ fn get_stakers<C: Deref<Target = impl Signer> + Clone>(
program: &Program<C>,
locker: Pubkey,
) -> Result<()> {
let keyed_escrows = program.accounts::<locked_voter::Escrow>(vec![RpcFilterType::Memcmp(
Memcmp::new_base58_encoded(8, &locker.to_bytes()),
)])?;
// Fat call, bump timeout
let rpc_client = RpcClient::new_with_timeout(program.rpc().url(), Duration::from_secs(120));
let program_accounts = rpc_client.get_program_accounts_with_config(
&locked_voter::ID,
RpcProgramAccountsConfig {
filters: Some(vec![
RpcFilterType::Memcmp(Memcmp::new_base58_encoded(
0,
&locked_voter::Escrow::DISCRIMINATOR,
)),
RpcFilterType::Memcmp(Memcmp::new_base58_encoded(8, &locker.to_bytes())),
]),
account_config: RpcAccountInfoConfig {
encoding: Some(UiAccountEncoding::Base64Zstd),
..Default::default()
},
..Default::default()
},
)?;
println!("Found {} escrows", program_accounts.len());

println!("escrow,owner,amount");
for (key, escrow) in keyed_escrows {
for (key, escrow_account) in program_accounts {
let escrow =
locked_voter::Escrow::try_deserialize(&mut escrow_account.data.as_slice()).unwrap();
println!("{key},{},{}", escrow.owner, escrow.amount);
}

Expand Down
Loading