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

feat(RewardsStreamerMP): make RewardsStreamerMP upgradeable #79

Merged
merged 1 commit into from
Dec 1, 2024

Conversation

0x-r4bbit
Copy link
Collaborator

@0x-r4bbit 0x-r4bbit commented Nov 29, 2024

This commit introduces upgradeability of the RewardsStreamerMP contract by leveraging the UUPS pattern.

This means, for deployment, we have to first deploy an instance of RewardsStreamerMP contract as a "template" logic contract and then create a ERC1967Proxy that points to it.

The proxy ensures the implementation address is stored in a deterministic storage slot.

This will later be leveraged by the StakeVault contract to implement the functionality to leave the system in case there was a malicious upgrade.

A lot of this is based on @3esmit work done in #73 with these changes:

  • Since we need access to ERC1967Proxy 's implementation address, we need a custom contract that exposes the address (because we can't read storage slots from external contracts within EVM)
  • Since we can't use plain ERC1967Proxy, we can't easily use Open Zeppelin's UnsafeUpgrades. Furthermore, since we've been using UnsafeUpgrades (not Upgrades) we're not getting any of the safety features anyways. Also I didn't manage to make SafeUpgrades work
  • Because of that, we have to manually deploy the implementation contract and the StakeManagerProxy and initialize it properly (this is done here in the changes)

Closes #22

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Added natspec comments?
  • Ran pnpm adorno?
  • Ran pnpm verify?

@0x-r4bbit 0x-r4bbit mentioned this pull request Nov 29, 2024
3 tasks
@0x-r4bbit 0x-r4bbit force-pushed the feat/upgradeability branch 2 times, most recently from 9539e9a to a30eb94 Compare November 29, 2024 10:56
Copy link
Contributor

@3esmit 3esmit left a comment

Choose a reason for hiding this comment

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

Please, avoid creating a new PR next time, as it makes the review process more complicated.

This commit introduces upgradeability of the `RewardsStreamerMP`
contract by leveraging the UUPS pattern.

This means, for deployment, we have to first deploy an instance of
`RewardsStreamerMP` contract as a "template" logic contract and then
create a ERC1967Proxy that points to it.

The proxy ensures the implementation address is stored in a
deterministic storage slot.

This will later be leveraged by the `StakeVault` contract to implement
the functionality to leave the system in case there was a malicious
upgrade.

Closes #22
@0x-r4bbit 0x-r4bbit force-pushed the feat/upgradeability branch from a30eb94 to 816f72b Compare December 1, 2024 07:00
@0x-r4bbit 0x-r4bbit merged commit 8561a68 into main Dec 1, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Make RewardStreamer/StakeManager upgradeable via UUPS
2 participants