[Bug] The delegator may fail to execute unbond_public
elderhammer opened this issue ยท 0 comments
elderhammer commented
๐ Bug Report
The delegator may fail to execute unbond_public.
Steps to Reproduce
Assuming the validator is a committee member, any delegator can call unbond_public. The validator's bond is 100 credits and the delegator's bond is 10,000 credits.
1.Unbond the delegator
position end_unbond_delegator;
// {
// Check if the new delegated total is at least 10M credits.
gte r22 10_000_000_000_000u64 into r26;
// Jump to end if the delegated total is at least 10M credits.
branch.eq r26 true to end;
// }
// If the delegated total is below 10M credits, continue to unbonding the validator.
If delegated[validator.address] is less than the threshold after the delegator unbinds the funds, the logic continues to execute.
2.Unbond the validator
// Calculate the updated amount of microcredits after unbonding.
sub r30.microcredits r2 into r34;
In the /* Unbond the Validator */ logic, because the validator's funds of 100 are less than the delegator's funds of 10000, the calculation will overflow and the function call will fail.
Expected Behavior
The delegator can unbind the funds normally.
Your Environment
snarkVM Version: 5050cb1