Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow Spawn of invalid vaults #5862

Open
lrettig opened this issue Apr 18, 2024 · 0 comments
Open

Disallow Spawn of invalid vaults #5862

lrettig opened this issue Apr 18, 2024 · 0 comments

Comments

@lrettig
Copy link
Member

lrettig commented Apr 18, 2024

At present a user can spawn a vault with invalid/misconfigured parameters, e.g., one where VestingStart > VestingEnd (see below thread). Do we want to forbid this by causing Spawn txs for such a vault to fail? We might also want to check that the vault contains at least TotalAmount before it's spawned. Note, however, that one possible adverse outcome if we go this route is that someone might deposit coins to an address under the mistaken belief that they could later spawn a vault there, then find out that they can't spawn the vault because the params are invalid, which means the coins would be stuck.

This however raises the question - do we want to allow Spawning of misconfigured/invalid Vaults in the first place? Examples would be an insufficient balance, or VestingStart > VestingEnd. With the code as it stands there's no harm in allowing them, and I've written the logic here in such a way that the funds in the vault can still be spent. We may also want to prevent Spawn of any Vault other than the genesis Vaults to prevent this sort of issue.

I prefer when objects in invalid state cannot exist in the first place rather than have to have checks around in the logic because the checks are easy to miss or get wrong.

If VestingStart > VestingEnd, no Spend can occur until VestingStart layer, at which point the TotalAmount becomes available. If account balance < unvested portion of TotalAmount, no Spend can occur, but this can always be remedied by sending more coins to the account.

I think VestingStart > VestingEnd is not possible because of this check:

if spawn.VestingEnd.Before(spawn.VestingStart) {
return nil, fmt.Errorf("vesting end %s should be atleast equal to start %s",
spawn.VestingEnd, spawn.VestingStart)
}

However, VestingStart == VestingEnd is possible, in which case the code in

vested.Div(vested, new(big.Int).SetUint64(uint64(v.VestingEnd.Difference(v.VestingStart))))
would crash (division by zero).

Originally posted by @poszu in #5840 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant