-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cluster History account with blocks per epoch tracking (#14)
Cluster History Struct: - Sets up new account type: ClusterHistory - Reads number of landed blocks from SlotHistory for last epoch - Adds support for cranking this per epoch - Backfill instruction + CLI command for filling in data since epoch 500 - Tests Also includes IDL updated with ClusterHistory types
- Loading branch information
Showing
15 changed files
with
1,628 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::sync::Arc; | ||
|
||
use anchor_lang::{InstructionData, ToAccountMetas}; | ||
use keeper_core::{submit_instructions, SubmitStats, TransactionExecutionError}; | ||
use solana_client::nonblocking::rpc_client::RpcClient; | ||
use solana_sdk::{instruction::Instruction, pubkey::Pubkey, signature::Keypair, signer::Signer}; | ||
use validator_history::state::ClusterHistory; | ||
|
||
pub async fn update_cluster_info( | ||
client: Arc<RpcClient>, | ||
keypair: Arc<Keypair>, | ||
program_id: &Pubkey, | ||
) -> Result<SubmitStats, (TransactionExecutionError, SubmitStats)> { | ||
let (cluster_history_account, _) = | ||
Pubkey::find_program_address(&[ClusterHistory::SEED], program_id); | ||
|
||
let update_instruction = Instruction { | ||
program_id: *program_id, | ||
accounts: validator_history::accounts::CopyClusterInfo { | ||
cluster_history_account, | ||
slot_history: solana_program::sysvar::slot_history::id(), | ||
signer: keypair.pubkey(), | ||
} | ||
.to_account_metas(None), | ||
data: validator_history::instruction::CopyClusterInfo {}.data(), | ||
}; | ||
|
||
submit_instructions(&client, vec![update_instruction], &keypair).await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.