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

fix: require up to date delegator record when slashing #526

Merged
merged 1 commit into from
Sep 10, 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
38 changes: 27 additions & 11 deletions staking/integration-tests/tests/integrity_pool_slash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,17 +313,6 @@ fn test_slash() {
post_dummy_publisher_caps(&mut svm, &payer, publisher_keypair.pubkey(), 50);
advance(&mut svm, &payer, publisher_caps).unwrap();

advance_delegation_record(
&mut svm,
&payer,
publisher_keypair.pubkey(),
stake_account_positions,
pyth_token_mint.pubkey(),
pool_data_pubkey,
None,
)
.unwrap();

// undelegate 2 PYTH at epoch N + 2
undelegate(
&mut svm,
Expand Down Expand Up @@ -373,6 +362,32 @@ fn test_slash() {
}
);

assert_anchor_program_error!(
slash(
&mut svm,
&payer,
stake_account_positions,
0,
slash_custody,
publisher_keypair.pubkey(),
pool_data_pubkey,
),
IntegrityPoolError::OutdatedDelegatorAccounting,
0
);
svm.expire_blockhash();

advance_delegation_record(
&mut svm,
&payer,
publisher_keypair.pubkey(),
stake_account_positions,
pyth_token_mint.pubkey(),
pool_data_pubkey,
None,
)
.unwrap();

assert_anchor_program_error!(
slash(
&mut svm,
Expand All @@ -387,6 +402,7 @@ fn test_slash() {
0
);


slash(
&mut svm,
&payer,
Expand Down
3 changes: 3 additions & 0 deletions staking/programs/integrity-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ pub mod integrity_pool {

let current_epoch = get_current_epoch()?;

// assert delegator record is up to date
delegation_record.assert_up_to_date(current_epoch)?;

require_gte!(
current_epoch,
slash_event.epoch,
Expand Down
Loading