AleoNet / snarkVM

A Virtual Machine for Zero-Knowledge Executions

Home Page:https://snarkvm.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] The delegator may fail to execute unbond_public

elderhammer opened this issue Β· comments

πŸ› 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

// If the delegated total is below 10M credits, continue to unbonding the validator.

        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

sub r30.microcredits r2 into r34;

        // 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