Skip to content

Commit

Permalink
fix: deprecate transfer epoch (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos authored Sep 10, 2024
1 parent a63a2da commit 577a509
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
6 changes: 0 additions & 6 deletions staking/programs/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,6 @@ pub mod staking {
return Err(error!(ErrorCode::InvalidVotingEpoch));
}

if let Some(transfer_epoch) = ctx.accounts.stake_account_metadata.transfer_epoch {
if epoch_of_snapshot <= transfer_epoch {
return Err(error!(ErrorCode::VoteDuringTransferEpoch));
}
}

voter_record.voter_weight = compute_voter_weight(
stake_account_positions,
epoch_of_snapshot,
Expand Down
9 changes: 4 additions & 5 deletions staking/programs/staking/src/state/stake_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ pub struct StakeAccountMetadataV2 {
pub owner: Pubkey,
pub lock: VestingSchedule,
pub next_index: u8,
pub transfer_epoch: Option<u64>, /* null if the account was created, some epoch if
* the account received a transfer */
pub _deprecated: Option<u64>,
pub signed_agreement_hash: Option<[u8; 32]>,
}

Expand Down Expand Up @@ -56,7 +55,7 @@ impl StakeAccountMetadataV2 {
self.voter_bump = 0;
self.owner = *owner;
self.next_index = 0;
self.transfer_epoch = None;
self._deprecated = None;
self.signed_agreement_hash = None;
}

Expand Down Expand Up @@ -96,7 +95,7 @@ pub mod tests {
owner: Pubkey::default(),
lock: VestingSchedule::FullyVested,
next_index: 0,
transfer_epoch: None,
_deprecated: None,
signed_agreement_hash: Some([0; 32]),
};
assert!(stake_account_metadata_llc_member
Expand All @@ -116,7 +115,7 @@ pub mod tests {
owner: Pubkey::default(),
lock: VestingSchedule::FullyVested,
next_index: 0,
transfer_epoch: None,
_deprecated: None,
signed_agreement_hash: None,
};
assert!(stake_account_metadata_non_llc_member
Expand Down
2 changes: 1 addition & 1 deletion staking/target/idl/staking.json
Original file line number Diff line number Diff line change
Expand Up @@ -2853,7 +2853,7 @@
"type": "u8"
},
{
"name": "transfer_epoch",
"name": "_deprecated",
"type": {
"option": "u64"
}
Expand Down
2 changes: 1 addition & 1 deletion staking/target/types/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2859,7 +2859,7 @@ export type Staking = {
"type": "u8"
},
{
"name": "transferEpoch",
"name": "deprecated",
"type": {
"option": "u64"
}
Expand Down
2 changes: 1 addition & 1 deletion staking/tests/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe("staking", async () => {
owner,
lock: { fullyVested: {} },
nextIndex: 0,
transferEpoch: null,
deprecated: null,
signedAgreementHash: null,
})
);
Expand Down

0 comments on commit 577a509

Please sign in to comment.