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

Add a variant of the Vesting wallet for updating the beneficiary #264

Closed
wants to merge 5 commits into from

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented May 9, 2024

Some beneficiary of vesting wallets have lost access to their keys. This PR add a variant of the VestingWallet.

The admin can upgrade the wallet to that new variant and the use the new updateBeneficiary function to update the beneficiary address to a new value.

@Amxx Amxx requested a review from frangio May 9, 2024 09:01
@Amxx
Copy link
Collaborator Author

Amxx commented May 9, 2024

@ernestognw

@Amxx Amxx temporarily deployed to development May 9, 2024 09:03 — with GitHub Actions Inactive
Copy link

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contracts/vesting/VestingWalletRecovery.sol Outdated Show resolved Hide resolved
function updateBeneficiary(address newBeneficiary) external onlyOwner {
_setBeneficiary(newBeneficiary);
emit BeneficiaryUpdate(newBeneficiary);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add another function to accept the beneficiary change? That might be a way of avoiding an issue of changing the beneficiary to a centralized exchange wallet (as an example)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be a way of avoiding an issue of changing the beneficiary to a centralized exchange wallet

My understanding is that is exactly what they plan to use. Apparently, coinbase has a thing where the user as a "long lasting" address that can receive assets (including ERC20) ... but I'm not 100% sure it can be use to interract with arbitrary smart contracts.

Copy link

@ernestognw ernestognw May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I recall someone mention the Coinbase Account, but if that's the purpose then it is okay under the assumption that this VestingWallet is more legally-restricted than code-restricted. Let's just keep this in mind, might be an important detail before making the change.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah since release is permisionless we can't assume that the beneficiary wallet is able to interact with the smart contract.


function updateBeneficiary(address newBeneficiary) external onlyOwner {
_setBeneficiary(newBeneficiary);
emit BeneficiaryUpdate(newBeneficiary);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say this event should be emitted inside of _setBeneficiary instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to minimize the changes to V1. If the storage was not private I wouldn't have touched it.

Copy link

@ernestognw ernestognw May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I was thinking of overriding _setBeneficiary in V2:

function _setBeneficiary(address newBeneficiary) override ... {
  super._setBeneficiary(newBeneficiary);
  emit BeneficiaryUpdate(newBeneficiary);
}

Would you say this is acceptable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels a bit too much to me. It means having two function instead of one in VestingWalletRecovery.

contract VestingWalletRecovery is VestingWalletV1 {
    event BeneficiaryUpdate(address newBeneficiary);

    function updateBeneficiary(address newBeneficiary) external onlyOwner {
        _setBeneficiary(newBeneficiary);
    }

    function _setBeneficiary(address newBeneficiary) internal virtual override {
        super._setBeneficiary(newBeneficiary);
        emit BeneficiaryUpdate(newBeneficiary);
    }
}

vs

contract VestingWalletRecovery is VestingWalletV1 {
    event BeneficiaryUpdate(address newBeneficiary);

    function updateBeneficiary(address newBeneficiary) external onlyOwner {
        _setBeneficiary(newBeneficiary);
        emit BeneficiaryUpdate(newBeneficiary);
    }
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with prioritizing fewer code and fewer changes to V1.

@Amxx Amxx temporarily deployed to development May 9, 2024 09:33 — with GitHub Actions Inactive
@Amxx Amxx temporarily deployed to development May 13, 2024 09:33 — with GitHub Actions Inactive
@Amxx Amxx temporarily deployed to development May 13, 2024 09:34 — with GitHub Actions Inactive
@Amxx
Copy link
Collaborator Author

Amxx commented May 13, 2024

@ernestognw @frangio

I added the "light" version, that would work as a temporary implementation. Let me know what you think. I don't feel its safer, but I like that it doesn't require any change to the V1 implementation to expose the private variable.

Comment on lines +38 to +39
function changeOwnerAndUpgrade(address newBeneficiary, address newImplementation) external {
// change ownership
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "change beneficiary"! Owner is a different entity.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly the name of the function should be changeBeneficiaryAndUpgrade

uint256[50] private __gap_3;
// ERC1967UpgradeUpgradeable
uint256[50] private __gap_4;
// VestingWallerV1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// VestingWallerV1
// VestingWalletV1

bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
event Upgraded(address indexed implementation);

function changeOwnerAndUpgrade(address newBeneficiary, address newImplementation) external {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should either be onlyOwner or the parameters should be immutably set in the constructor. Otherwise there is a possible error where the wallet is upgraded without calling this function and it becomes open to anyone to steal the tokens.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, considering it's supposed to be light, then setting immutables at construction sounds better


function updateBeneficiary(address newBeneficiary) external onlyOwner {
_setBeneficiary(newBeneficiary);
emit BeneficiaryUpdate(newBeneficiary);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with prioritizing fewer code and fewer changes to V1.

/**
* This contract is designed for recovery in case the beneficiary was lost.
*/
contract VestingWalletRecovery is VestingWalletV1 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also VestingWalletV2. I don't know if any of the affected wallets are using V2 but if so this recovery upgrade would remove V2 features.

This seems like another reason to use the "light" recovery mode. It keeps the wallet in the same version it's at (V1 or V2).

function updateBeneficiary(address newBeneficiary) external onlyOwner {
_setBeneficiary(newBeneficiary);
emit BeneficiaryUpdate(newBeneficiary);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah since release is permisionless we can't assume that the beneficiary wallet is able to interact with the smart contract.

* This contract is designed for recovery in case the beneficiary was lost.
*/
contract VestingWalletRecoveryLight {
/// Storage
Copy link
Collaborator

@frangio frangio May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the storage layout should be that of V2.


this.vesting = await deployUpgradeable(
hre,
'VestingWallet',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be deploying "V0" of the vesting wallet:

contract VestingWallet is OwnableUpgradeable, UUPSUpgradeable {

I think it should be VestingWalletV2 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wallets we are targeting are using V0.

Not that the storage layout described in VestingWalletRecoveryLight is common to V0, V1 and V2.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following Fran's comments, I'd rename this file to VestingWalletV1.recovery.test.js. Consistent with the name of the underlying wallet that's being updated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Amxx
Copy link
Collaborator Author

Amxx commented May 14, 2024

Replaced by OpenZeppelin#1

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

Successfully merging this pull request may close these issues.

3 participants