From 45aec5374866ae3548a79b3abb0574db32010118 Mon Sep 17 00:00:00 2001 From: Kirill Konevets Date: Sun, 4 Sep 2022 08:29:49 +0300 Subject: [PATCH] fix Solana error MergeTransientStake When there is a big amount in a reserve account Solana can't activate it in a single shot. It activates it in several epochs. When reserve SOLs are sent to stake accounts those stake accounts are still not fully activated after current epoch. But if Solido creates a new stake account in next epoch (e.g. I make a new deposit) then at the end of epoch it tries to merger these two account and gets Solana error "stake account with transient stake cannot be merged". We can't merge non fully activated stake account from different activation epochs. Same error is reproduced in Solido v2. If there is lots of SOL in a reserve account (currently we have ~4_000_000 SOL on mainnet) then after migrate to v2 instruction it stakes from reserve and stake is activated partially. And if I try to deposit e.g. 10 SOL, then another stake account is created and merging those two account fails at epoch end. Guess the same error will happen on v1 if I remove all validators and then add a new one. There should be at least 600_000 SOL in the reserve for the error to happen. On local validator Solana activates max 250_000 SOL per epoch. --- program/src/stake_account.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/program/src/stake_account.rs b/program/src/stake_account.rs index 880daac19..7f8004fc5 100644 --- a/program/src/stake_account.rs +++ b/program/src/stake_account.rs @@ -267,7 +267,10 @@ impl StakeAccount { return true; } // Two activating accounts that share an activation epoch, during the activation epoch. - if self.is_activating() && merge_from.is_activating() { + if self.is_activating() + && merge_from.is_activating() + && self.activation_epoch == merge_from.activation_epoch + { return true; } }