Skip to content
This repository was archived by the owner on May 22, 2023. It is now read-only.

Require beneficiary to be set for withdraw #478

Merged
merged 14 commits into from
Jun 30, 2020
Merged

Conversation

nkuba
Copy link
Member

@nkuba nkuba commented Jun 10, 2020

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.

nkuba added 7 commits June 10, 2020 12:56
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.
Copy link
Member

@pdyraga pdyraga left a 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.

nkuba added 2 commits June 24, 2020 14:51
This reverts commit c3de57f.

To become a keep member, stake delegation has to exist and
the beneficiary has to be defined.
@nkuba nkuba requested a review from pdyraga June 24, 2020 12:59
Copy link
Member

@pdyraga pdyraga left a 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.

nkuba added 2 commits June 29, 2020 16:28
We removed the part of code that the test were validating, so we need to
remove the test too.
@nkuba
Copy link
Member Author

nkuba commented Jun 29, 2020

@pdyraga it's ready

@nkuba nkuba requested a review from pdyraga June 30, 2020 07:51
@pdyraga pdyraga merged commit 8638825 into master Jun 30, 2020
@pdyraga pdyraga deleted the no-beneficiary-withdraw branch June 30, 2020 07:52
@Shadowfiend
Copy link
Contributor

Previously it was possible that bonding value was deposited for the operator before stake delegation happened, so the beneficiary was not set yet.

Do we want to fix this by preventing withdrawal for an unset beneficiary, or by preventing bonding?

@pdyraga pdyraga added this to the v1.2.0 milestone Sep 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants