From 2fd144676cad306aea88d8fa64626de0adf15393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ad=C3=A1n=20SDPC?= Date: Tue, 28 Jan 2025 14:46:54 +0100 Subject: [PATCH 1/3] feat(validations): allow unstaking all the stake at once Namely, apply a protocol-level "rule of convenience", where an amount to unstake of u64::MAX actually means "unstake all my stake" --- validations/src/validations.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/validations/src/validations.rs b/validations/src/validations.rs index d9fe95e6e..485cdc15c 100644 --- a/validations/src/validations.rs +++ b/validations/src/validations.rs @@ -1470,7 +1470,7 @@ pub fn validate_unstake_transaction<'a>( } // Check if is unstaking more than the total stake - let amount_to_unstake = ut_tx.body.value() + ut_tx.body.fee; + let mut amount_to_unstake = ut_tx.body.value() + ut_tx.body.fee; let validator = ut_tx.body.operator; let withdrawer = ut_tx.signature.public_key.pkh(); @@ -1514,6 +1514,12 @@ pub fn validate_unstake_transaction<'a>( .into()); } }; + + // Apply a protocol-level "rule of convenience", where an amount to unstake of u64::MAX actually + // means "unstake all my stake". + if amount_to_unstake == u64::MAX { + amount_to_unstake = staked_amount; + } // Allowed unstake actions: // 1) Unstake the full balance (checked by the first condition) From 4a84eff8393d7c930a8326419484903286bcf817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ad=C3=A1n=20SDPC?= Date: Tue, 28 Jan 2025 18:09:56 +0100 Subject: [PATCH 2/3] feat(data_requests): increase max witnesses on testnet and dev envs Originally by @guidiaz in b4a73d6d617c49206a1a50dd331f16d22c25f396 with edits from @drcpu-github # Conflicts: # node/src/actors/chain_manager/mod.rs --- node/src/actors/chain_manager/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/src/actors/chain_manager/mod.rs b/node/src/actors/chain_manager/mod.rs index 4cab1e353..79eca0e79 100644 --- a/node/src/actors/chain_manager/mod.rs +++ b/node/src/actors/chain_manager/mod.rs @@ -5189,7 +5189,7 @@ mod tests { // Unstake all for validator 2 process_unstake_transactions( &mut stakes, - [unstake_txn_1.clone()].iter(), + [unstake_txn_1.clone()], block_epoch, 10_000_000_000_000, ) @@ -5254,7 +5254,7 @@ mod tests { // Unstake all again for validator 2 process_unstake_transactions( &mut stakes, - [unstake_txn_2].iter(), + [unstake_txn_2], block_epoch, 10_000_000_000_000, ) From c3e9e93ec586697ba6ebd3979441a9faa7705642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ad=C3=A1n=20SDPC?= Date: Tue, 16 Sep 2025 17:15:58 +0200 Subject: [PATCH 3/3] feat(validations): guard "unstake-it-all" rule behind V2_1 guard --- node/src/actors/chain_manager/mod.rs | 4 ++-- validations/src/validations.rs | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/node/src/actors/chain_manager/mod.rs b/node/src/actors/chain_manager/mod.rs index 79eca0e79..4cab1e353 100644 --- a/node/src/actors/chain_manager/mod.rs +++ b/node/src/actors/chain_manager/mod.rs @@ -5189,7 +5189,7 @@ mod tests { // Unstake all for validator 2 process_unstake_transactions( &mut stakes, - [unstake_txn_1.clone()], + [unstake_txn_1.clone()].iter(), block_epoch, 10_000_000_000_000, ) @@ -5254,7 +5254,7 @@ mod tests { // Unstake all again for validator 2 process_unstake_transactions( &mut stakes, - [unstake_txn_2], + [unstake_txn_2].iter(), block_epoch, 10_000_000_000_000, ) diff --git a/validations/src/validations.rs b/validations/src/validations.rs index 485cdc15c..a3735c93e 100644 --- a/validations/src/validations.rs +++ b/validations/src/validations.rs @@ -1465,7 +1465,9 @@ pub fn validate_unstake_transaction<'a>( min_stake_nanowits: u64, unstake_delay: u64, ) -> Result<(u64, u32, Vec<&'a ValueTransferOutput>), anyhow::Error> { - if get_protocol_version(Some(epoch)) <= ProtocolVersion::V1_8 { + let protocol_version = get_protocol_version(Some(epoch)); + + if protocol_version <= ProtocolVersion::V1_8 { return Err(TransactionError::NoUnstakeTransactionsAllowed.into()); } @@ -1514,10 +1516,11 @@ pub fn validate_unstake_transaction<'a>( .into()); } }; - + + // Introduced in V2_1: // Apply a protocol-level "rule of convenience", where an amount to unstake of u64::MAX actually // means "unstake all my stake". - if amount_to_unstake == u64::MAX { + if protocol_version >= ProtocolVersion::V2_1 && amount_to_unstake == u64::MAX { amount_to_unstake = staked_amount; }