From 3bf9ef9146d5bbd54f1c60ecb4ec34d2dfaccd44 Mon Sep 17 00:00:00 2001 From: Evan Batsell Date: Wed, 10 Jan 2024 11:53:40 -0500 Subject: [PATCH] make build pass --- keepers/validator-keeper/src/lib.rs | 1 - .../idl/validator_history.json | 927 ++++++++++++++++++ .../src/instructions/copy_cluster_info.rs | 4 +- programs/validator-history/src/state.rs | 2 +- 4 files changed, 931 insertions(+), 3 deletions(-) create mode 100644 programs/validator-history/idl/validator_history.json diff --git a/keepers/validator-keeper/src/lib.rs b/keepers/validator-keeper/src/lib.rs index 2775c873..f1aaf728 100644 --- a/keepers/validator-keeper/src/lib.rs +++ b/keepers/validator-keeper/src/lib.rs @@ -8,7 +8,6 @@ use keeper_core::{CreateUpdateStats, SubmitStats}; use log::error; use solana_account_decoder::UiDataSliceConfig; use solana_client::{ - client_error::ClientError, nonblocking::rpc_client::RpcClient, rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, rpc_filter::{Memcmp, RpcFilterType}, diff --git a/programs/validator-history/idl/validator_history.json b/programs/validator-history/idl/validator_history.json new file mode 100644 index 00000000..0278f72a --- /dev/null +++ b/programs/validator-history/idl/validator_history.json @@ -0,0 +1,927 @@ +{ + "version": "0.1.0", + "name": "validator_history", + "instructions": [ + { + "name": "initializeValidatorHistoryAccount", + "accounts": [ + { + "name": "validatorHistoryAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "voteAccount", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "signer", + "isMut": true, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "reallocValidatorHistoryAccount", + "accounts": [ + { + "name": "validatorHistoryAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "voteAccount", + "isMut": false, + "isSigner": false, + "docs": [ + "Used to read validator commission." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "signer", + "isMut": true, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "initializeClusterHistoryAccount", + "accounts": [ + { + "name": "clusterHistoryAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "signer", + "isMut": true, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "reallocClusterHistoryAccount", + "accounts": [ + { + "name": "clusterHistoryAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "signer", + "isMut": true, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "copyVoteAccount", + "accounts": [ + { + "name": "validatorHistoryAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "voteAccount", + "isMut": false, + "isSigner": false + }, + { + "name": "signer", + "isMut": true, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "updateMevCommission", + "accounts": [ + { + "name": "validatorHistoryAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "voteAccount", + "isMut": false, + "isSigner": false, + "docs": [ + "Used to read validator commission." + ] + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "tipDistributionAccount", + "isMut": false, + "isSigner": false, + "docs": [ + "`owner = config.tip_distribution_program.key()` here is sufficient." + ] + }, + { + "name": "signer", + "isMut": true, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "initializeConfig", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "signer", + "isMut": true, + "isSigner": true + } + ], + "args": [ + { + "name": "authority", + "type": "publicKey" + } + ] + }, + { + "name": "setNewTipDistributionProgram", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "newTipDistributionProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tipDistributionAuthority", + "isMut": false, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "setNewTipDistributionAuthority", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "newAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "tipDistributionAuthority", + "isMut": false, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "setNewStakeAuthority", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "newAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "stakeAuthority", + "isMut": false, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "updateStakeHistory", + "accounts": [ + { + "name": "validatorHistoryAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "voteAccount", + "isMut": false, + "isSigner": false + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "stakeAuthority", + "isMut": true, + "isSigner": true + } + ], + "args": [ + { + "name": "epoch", + "type": "u64" + }, + { + "name": "lamports", + "type": "u64" + }, + { + "name": "rank", + "type": "u32" + }, + { + "name": "isSuperminority", + "type": "bool" + } + ] + }, + { + "name": "copyGossipContactInfo", + "accounts": [ + { + "name": "validatorHistoryAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "voteAccount", + "isMut": false, + "isSigner": false + }, + { + "name": "instructions", + "isMut": false, + "isSigner": false + }, + { + "name": "signer", + "isMut": true, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "copyClusterInfo", + "accounts": [ + { + "name": "clusterHistoryAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "slotHistory", + "isMut": false, + "isSigner": false + }, + { + "name": "signer", + "isMut": true, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "backfillTotalBlocks", + "accounts": [ + { + "name": "clusterHistoryAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "signer", + "isMut": true, + "isSigner": true + } + ], + "args": [ + { + "name": "epoch", + "type": "u64" + }, + { + "name": "blocksInEpoch", + "type": "u32" + } + ] + } + ], + "accounts": [ + { + "name": "Config", + "type": { + "kind": "struct", + "fields": [ + { + "name": "tipDistributionProgram", + "type": "publicKey" + }, + { + "name": "tipDistributionAuthority", + "type": "publicKey" + }, + { + "name": "stakeAuthority", + "type": "publicKey" + }, + { + "name": "counter", + "type": "u32" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "ValidatorHistory", + "type": { + "kind": "struct", + "fields": [ + { + "name": "structVersion", + "type": "u32" + }, + { + "name": "voteAccount", + "type": "publicKey" + }, + { + "name": "index", + "type": "u32" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "padding0", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "lastIpTimestamp", + "type": "u64" + }, + { + "name": "lastVersionTimestamp", + "type": "u64" + }, + { + "name": "padding1", + "type": { + "array": [ + "u8", + 232 + ] + } + }, + { + "name": "history", + "type": { + "defined": "CircBuf" + } + } + ] + } + }, + { + "name": "ClusterHistory", + "type": { + "kind": "struct", + "fields": [ + { + "name": "structVersion", + "type": "u64" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "padding0", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "clusterHistoryLastUpdateSlot", + "type": "u64" + }, + { + "name": "padding1", + "type": { + "array": [ + "u8", + 232 + ] + } + }, + { + "name": "history", + "type": { + "defined": "CircBufCluster" + } + } + ] + } + } + ], + "types": [ + { + "name": "ValidatorHistoryEntry", + "type": { + "kind": "struct", + "fields": [ + { + "name": "activatedStakeLamports", + "type": "u64" + }, + { + "name": "epoch", + "type": "u16" + }, + { + "name": "mevCommission", + "type": "u16" + }, + { + "name": "epochCredits", + "type": "u32" + }, + { + "name": "commission", + "type": "u8" + }, + { + "name": "clientType", + "type": "u8" + }, + { + "name": "version", + "type": { + "defined": "ClientVersion" + } + }, + { + "name": "ip", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "padding0", + "type": "u8" + }, + { + "name": "isSuperminority", + "type": "u8" + }, + { + "name": "rank", + "type": "u32" + }, + { + "name": "voteAccountLastUpdateSlot", + "type": "u64" + }, + { + "name": "padding1", + "type": { + "array": [ + "u8", + 88 + ] + } + } + ] + } + }, + { + "name": "ClientVersion", + "type": { + "kind": "struct", + "fields": [ + { + "name": "major", + "type": "u8" + }, + { + "name": "minor", + "type": "u8" + }, + { + "name": "patch", + "type": "u16" + } + ] + } + }, + { + "name": "CircBuf", + "type": { + "kind": "struct", + "fields": [ + { + "name": "idx", + "type": "u64" + }, + { + "name": "isEmpty", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "arr", + "type": { + "array": [ + { + "defined": "ValidatorHistoryEntry" + }, + 512 + ] + } + } + ] + } + }, + { + "name": "ClusterHistoryEntry", + "type": { + "kind": "struct", + "fields": [ + { + "name": "totalBlocks", + "type": "u32" + }, + { + "name": "epoch", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 250 + ] + } + } + ] + } + }, + { + "name": "CircBufCluster", + "type": { + "kind": "struct", + "fields": [ + { + "name": "idx", + "type": "u64" + }, + { + "name": "isEmpty", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "arr", + "type": { + "array": [ + { + "defined": "ClusterHistoryEntry" + }, + 512 + ] + } + } + ] + } + }, + { + "name": "CrdsData", + "docs": [ + "CrdsData that defines the different types of items CrdsValues can hold", + "* Merge Strategy - Latest wallclock is picked", + "* LowestSlot index is deprecated" + ], + "type": { + "kind": "enum", + "variants": [ + { + "name": "LegacyContactInfo", + "fields": [ + { + "defined": "LegacyContactInfo" + } + ] + }, + { + "name": "Vote" + }, + { + "name": "LowestSlot" + }, + { + "name": "LegacySnapshotHashes" + }, + { + "name": "AccountsHashes" + }, + { + "name": "EpochSlots" + }, + { + "name": "LegacyVersion", + "fields": [ + { + "defined": "LegacyVersion" + } + ] + }, + { + "name": "Version", + "fields": [ + { + "defined": "Version2" + } + ] + }, + { + "name": "NodeInstance" + }, + { + "name": "DuplicateShred" + }, + { + "name": "SnapshotHashes" + }, + { + "name": "ContactInfo", + "fields": [ + { + "defined": "ContactInfo" + } + ] + } + ] + } + }, + { + "name": "Error", + "type": { + "kind": "enum", + "variants": [ + { + "name": "DuplicateIpAddr", + "fields": [ + { + "defined": "IpAddr" + } + ] + }, + { + "name": "DuplicateSocket", + "fields": [ + "u8" + ] + }, + { + "name": "InvalidIpAddrIndex", + "fields": [ + { + "name": "index", + "type": "u8" + }, + { + "name": "numAddrs", + "type": { + "defined": "usize" + } + } + ] + }, + { + "name": "InvalidPort", + "fields": [ + "u16" + ] + }, + { + "name": "InvalidQuicSocket", + "fields": [ + { + "option": { + "defined": "SocketAddr" + } + }, + { + "option": { + "defined": "SocketAddr" + } + } + ] + }, + { + "name": "IpAddrsSaturated" + }, + { + "name": "MulticastIpAddr", + "fields": [ + { + "defined": "IpAddr" + } + ] + }, + { + "name": "PortOffsetsOverflow" + }, + { + "name": "SocketNotFound", + "fields": [ + "u8" + ] + }, + { + "name": "UnspecifiedIpAddr", + "fields": [ + { + "defined": "IpAddr" + } + ] + }, + { + "name": "UnusedIpAddr", + "fields": [ + { + "defined": "IpAddr" + } + ] + } + ] + } + }, + { + "name": "ValidatorHistoryVersion", + "type": { + "kind": "enum", + "variants": [ + { + "name": "V0" + } + ] + } + } + ], + "errors": [ + { + "code": 6000, + "name": "AccountFullySized", + "msg": "Account already reached proper size, no more allocations allowed" + }, + { + "code": 6001, + "name": "InvalidEpochCredits", + "msg": "Invalid epoch credits, credits must be greater than previous credits" + }, + { + "code": 6002, + "name": "EpochOutOfRange", + "msg": "Epoch is out of range of history" + }, + { + "code": 6003, + "name": "NotSigVerified", + "msg": "Gossip Signature Verification not performed" + }, + { + "code": 6004, + "name": "GossipDataInvalid", + "msg": "Gossip Data Invalid" + }, + { + "code": 6005, + "name": "UnsupportedIpFormat", + "msg": "Unsupported IP Format, only IpAddr::V4 is supported" + }, + { + "code": 6006, + "name": "NotEnoughVotingHistory", + "msg": "Not enough voting history to create account. Minimum 10 epochs required" + }, + { + "code": 6007, + "name": "GossipDataTooOld", + "msg": "Gossip data too old. Data cannot be older than the last recorded timestamp for a field" + }, + { + "code": 6008, + "name": "GossipDataInFuture", + "msg": "Gossip timestamp too far in the future" + }, + { + "code": 6009, + "name": "ArithmeticError", + "msg": "Arithmetic Error (overflow/underflow)" + }, + { + "code": 6010, + "name": "SlotHistoryOutOfDate", + "msg": "Slot history sysvar is not containing expected slots" + } + ] +} \ No newline at end of file diff --git a/programs/validator-history/src/instructions/copy_cluster_info.rs b/programs/validator-history/src/instructions/copy_cluster_info.rs index b2400559..8134813c 100644 --- a/programs/validator-history/src/instructions/copy_cluster_info.rs +++ b/programs/validator-history/src/instructions/copy_cluster_info.rs @@ -13,6 +13,8 @@ pub struct CopyClusterInfo<'info> { bump, )] pub cluster_history_account: AccountLoader<'info, ClusterHistory>, + /// CHECK: slot_history sysvar + #[account(address = anchor_lang::solana_program::sysvar::slot_history::id())] pub slot_history: UncheckedAccount<'info>, #[account(mut)] pub signer: Signer<'info>, @@ -39,7 +41,7 @@ pub fn handler(ctx: Context) -> Result<()> { Ok(()) } -fn blocks_in_epoch(epoch: u16, slot_history: &Box) -> Result { +fn blocks_in_epoch(epoch: u16, slot_history: &SlotHistory) -> Result { let epoch_schedule = EpochSchedule::get()?; let start_slot = epoch_schedule.get_first_slot_in_epoch(epoch as u64); let end_slot = epoch_schedule.get_last_slot_in_epoch(epoch as u64); diff --git a/programs/validator-history/src/state.rs b/programs/validator-history/src/state.rs index 1a94843f..47def443 100644 --- a/programs/validator-history/src/state.rs +++ b/programs/validator-history/src/state.rs @@ -604,7 +604,7 @@ impl CircBufCluster { pub fn total_blocks_latest(&self) -> Option { if let Some(entry) = self.last() { if entry.total_blocks != ClusterHistoryEntry::default().total_blocks { - return Some(entry.total_blocks); + Some(entry.total_blocks) } else { None }