When calculating stake delegations for the tip distribution merkle tree, the code doesn't handle partially deactivated stake correctly:
E.g the use of stake_account.delegation().stake in
|
lamports_delegated: stake_account.delegation().stake, |
is wrong and could overestimate the active stake of a delegation that has been partially withdrawn.
Instead you should use
stake_account.delegation().stake(bank.epoch(), ....) .
Otherwise someone could inflate their stake if the cluster is in cooldown.