-
Notifications
You must be signed in to change notification settings - Fork 23
Require beneficiary to be set for withdraw #478
Conversation
We were handling a special case where beneficiary is not set on TokenStakingStub contract which was inconsistent with what the TokenStaking contract actually does. If the beneficiary is not set the contract will simply return zero address and here we do the same in the stub.
It is possible that unbonded value is deposited for the operator before beneficiary is set for that operator (via stake delegation). In such case beneficiaryOf will return zero address and the funds will be transfered to this address. Here we check if the beneficiary is set, if not the transaction will revert.
Before sending the valuse to beneficiary we need to check if it's set for the operator. It could happen that the value was sent to the zero address in case of beneficiary not defined.
Since the value is not sent directly to operator address we added also beneficiary to the event to help tracking transfers.
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.
Everything looks good to me except the piece in BondedECDSAKeep (comment from the last week). This situation is not possible to happen and I don't think we should guard against it in the code. It's additional instruction that could be confusing and even if we had it and reverted the transaction, there is no way to recover - delegation parameters can not be updated.
This reverts commit c3de57f. To become a keep member, stake delegation has to exist and the beneficiary has to be defined.
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.
One failing test and we should be good to go.
We removed the part of code that the test were validating, so we need to remove the test too.
@pdyraga it's ready |
Do we want to fix this by preventing withdrawal for an unset beneficiary, or by preventing bonding? |
In this PR we update ETH withdraws with checks that a beneficiary is set for the operator.
Previously it was possible that bonding value was deposited for the operator before stake delegation happened, so the beneficiary was not set yet. In such a case, the operator was able to withdraw the unbonded value, but the
tokenStaking.beneficiaryOf
returned zero address, to which funds could be transferred.Here we added verification if the beneficiary is defined. If not the transaction will revert.