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

Insert missing entries in CopyVoteAccount #37

Merged
merged 11 commits into from
May 27, 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
9 changes: 7 additions & 2 deletions programs/validator-history/idl/validator_history.json
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@
{
"code": 6001,
"name": "InvalidEpochCredits",
"msg": "Invalid epoch credits, credits must be greater than previous credits"
"msg": "Invalid epoch credits, credits must exist and each value must be greater than previous credits"
},
{
"code": 6002,
Expand All @@ -928,7 +928,7 @@
{
"code": 6006,
"name": "NotEnoughVotingHistory",
"msg": "Not enough voting history to create account. Minimum 10 epochs required"
"msg": "Not enough voting history to create account. Minimum 5 epochs required"
},
{
"code": 6007,
Expand All @@ -954,6 +954,11 @@
"code": 6011,
"name": "EpochTooLarge",
"msg": "Epoch larger than 65535, cannot be stored"
},
{
"code": 6012,
"name": "DuplicateEpoch",
"msg": "Inserting duplicate epoch"
}
]
}
8 changes: 6 additions & 2 deletions programs/validator-history/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use anchor_lang::prelude::*;
pub enum ValidatorHistoryError {
#[msg("Account already reached proper size, no more allocations allowed")]
AccountFullySized,
#[msg("Invalid epoch credits, credits must be greater than previous credits")]
#[msg(
"Invalid epoch credits, credits must exist and each value must be greater than previous credits"
)]
InvalidEpochCredits,
#[msg("Epoch is out of range of history")]
EpochOutOfRange,
Expand All @@ -14,7 +16,7 @@ pub enum ValidatorHistoryError {
GossipDataInvalid,
#[msg("Unsupported IP Format, only IpAddr::V4 is supported")]
UnsupportedIpFormat,
#[msg("Not enough voting history to create account. Minimum 10 epochs required")]
#[msg("Not enough voting history to create account. Minimum 5 epochs required")]
NotEnoughVotingHistory,
#[msg(
"Gossip data too old. Data cannot be older than the last recorded timestamp for a field"
Expand All @@ -28,4 +30,6 @@ pub enum ValidatorHistoryError {
SlotHistoryOutOfDate,
#[msg("Epoch larger than 65535, cannot be stored")]
EpochTooLarge,
#[msg("Inserting duplicate epoch")]
DuplicateEpoch,
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub fn handle_copy_vote_account(ctx: Context<CopyVoteAccount>) -> Result<()> {
validator_history_account.set_commission_and_slot(epoch, commission, clock.slot)?;

let epoch_credits = VoteStateVersions::deserialize_epoch_credits(&ctx.accounts.vote_account)?;
validator_history_account.insert_missing_entries(&epoch_credits)?;
validator_history_account.set_epoch_credits(&epoch_credits)?;

Ok(())
Expand Down
Loading
Loading