-
Notifications
You must be signed in to change notification settings - Fork 1
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): introduce leave() function #78
Conversation
0477df4
to
175e3b5
Compare
9ebd0ff
to
9539e9a
Compare
175e3b5
to
3e6c25e
Compare
9539e9a
to
a30eb94
Compare
3e6c25e
to
ec2dc08
Compare
@@ -136,13 +189,11 @@ contract StakeVault is Ownable { | |||
} | |||
|
|||
function _stake(uint256 _amount, uint256 _seconds, address _source) internal { | |||
stakeManager.stake(_amount, _seconds); |
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.
Any reason for reordering 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.
Just o adhere to CEI pattern. I think this should've been the case from the get go.
|
||
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
|
||
contract StakeManagerProxy is ERC1967Proxy { |
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.
Is this contract going to be deployed? If not, it should be an interface, or at least abstract.
I think that having the IStakeManagerProxy should be enough. Why we need 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.
We need a contract that exposes the implementation address of the ERC1967 proxy via a public function.
Otherwise StakeVault
is unable to determine the implementation address of the StakeManager
as there's no way to get the value of a storage slot of an external contract within the EVM.
That proxy implementation here is the one that will be deployed for every stakemanager.
@@ -29,7 +31,7 @@ contract RewardsStreamerMPTest is Test { | |||
bytes memory initializeData = | |||
abi.encodeCall(RewardsStreamerMP.initialize, (address(this), address(stakingToken), address(rewardToken))); | |||
address impl = address(new RewardsStreamerMP()); | |||
address proxy = address(new ERC1967Proxy(impl, initializeData)); | |||
address proxy = address(new StakeManagerProxy(impl, initializeData)); |
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.
Why can't we use the default proxy?
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.
a30eb94
to
816f72b
Compare
This function allows users to `leave()` the system if they can't or don't want to trust the stake manager. This is the case when the owner of the stake manager performs an upgrade. In case of such an upgrade, the stake manager will be marked as not trusted which prevents the user from staking, unstaking, locking etc. The user can then either explicitly trust stake manager (will happen in future changes) to enable the vault's functionality again, or, `leave()` the system at which point it will try to perform a benign `leave()` operation and then move the funds out of the vault. Closes #66
…k overflow If there's a malicious upgrade which causes a stack overflow error when `leave()` is called, the user of the vault should still be able to get their funds out. This commit adds a test that proofs this is happening.
dfe8929
to
09fc92d
Compare
This function allows users to
leave()
the system if they can't ordon't want to trust the stake manager. This is the case when the owner
of the stake manager performs an upgrade.
In case of such an upgrade, the stake manager will be marked as not
trusted which prevents the user from staking, unstaking, locking etc.
The user can then either explicitly trust stake manager (will happen in
future changes) to enable the vault's functionality again, or,
leave()
the system at which point it will try to perform a benign
leave()
operation and then move the funds out of the vault.
Closes #66