Skip to content

Commit a99b906

Browse files
committed
feat(validations): invert "unstake-it-all" logic
namely, use 0 instead of u64::MAX as the "unstake-it-all" meta-value
1 parent c3e9e93 commit a99b906

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

validations/src/validations.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,9 @@ pub fn validate_unstake_transaction<'a>(
15201520
// Introduced in V2_1:
15211521
// Apply a protocol-level "rule of convenience", where an amount to unstake of u64::MAX actually
15221522
// means "unstake all my stake".
1523-
if protocol_version >= ProtocolVersion::V2_1 && amount_to_unstake == u64::MAX {
1523+
// Please take note that this validation sctrictly needs to take place before checking whether
1524+
// the "remainder" amount meets the minimum stake. Otherwise, we would never reach this block.
1525+
if protocol_version >= ProtocolVersion::V2_1 && amount_to_unstake == 0 {
15241526
amount_to_unstake = staked_amount;
15251527
}
15261528

0 commit comments

Comments
 (0)