-
Notifications
You must be signed in to change notification settings - Fork 5
Conversation
@@ -438,7 +440,6 @@ library LibStaking { | |||
s.validatorSet.confirmWithdraw(validator, amount); | |||
|
|||
// release stake from gateway and transfer to user | |||
IGateway(s.ipcGatewayAddr).releaseStake(amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see if I understand this: the stake is added to the gateway in one go when the subnet registers itself, right? So it makes sense that before that, this should not be trying to release anything.
Strange we haven't caught any issues with this 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know. I feel that there were a bunch of tests that were commented so we lost track of this. But I included a few to catch it. Good that you raised this issue, as it already uncovered this bug :)
revert NotEnoughBalance(); | ||
} | ||
|
||
s.genesisBalance[msg.sender] -= amount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this can't go negative, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It reverts on underflow/overflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are uint256
, they can't be negative (they could theoretically underflow though). However, if preFund
and preRelease
don't have bugs this shouldn't happen.
In spite of this, do you think we should add a sanity-check just to be safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay, I recommended the balance < amount => revert
fix, but if it would revert even if you try an underflow, then it's okay, what matters is there is no way get more out.
…pc-solidity-actors into ipc-361-pre-release Signed-off-by: Alfonso de la Rocha <adlrocha@tutamail.com>
Signed-off-by: Alfonso de la Rocha <adlrocha@tutamail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR addresses the following issue raised by @aakoshh: consensus-shipyard/ipc#361 (review)
pre-release
method to the subnet contract to allow users to recover their initial balance if they need to before the subnet bootstraps.leave
and allows validators leaving the subnet before it is bootstrapped to recover their initial balance.