-
Notifications
You must be signed in to change notification settings - Fork 7
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
Implement proxy plugin #29
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
d05e089
to
12da1a2
Compare
This comment was marked as resolved.
This comment was marked as resolved.
b56d8f8
to
ec6a8e6
Compare
test: add proxyHelpers testing contract test: add installPlugin helper function chore: say target instead of proxyTarget
test: onStreamCanceled function test: methodList function test: add assertEq function for bytes4[] test: remove unnecessary assertEq functions
ec6a8e6
to
02d413c
Compare
02d413c
to
d2688ff
Compare
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.
Great work. Specific feedback left in the comments below.
It may be clearer to rename the sender
user to something else, e.g. Alice
. It can be confusing to name it like that given that the proxy contract is the sender.
docs: improve wording in natspec chore: various improvements in comments test: change the header for the target functions in Base_Test test: cast to uint256 in assertEq function for the Status
For now, let's keep it as it is and sleep on this idea. |
Fine, I will create a separate PR for changing the default proxy owner. |
refactor: rename header separators test: add more explanatory comments test: simplify variables in "test_MethodList" test: use periphery contract for checking function signature
During my latest code review, I discovered an important issue with the current Anyone can run a proxy plugin, not just the proxy owner. It would thus be a good idea to check that |
To follow up on my previous point - there are more issues with the current implementation of the proxy plugin.
|
build: bump prb-proxy refactor: load "owner" from storage directly
chore: add explanatory comments docs: improve writing feat: add "InvalidCall" error test: add new helper for "createWithRange" test: test direct call to "onStreamCanceled" test: test invalid calls to "onStreamCanceled"
@andreivladbrg - I have finished re-implementing the proxy plugin in light of my feedback above. Can you please review it? |
test: improve writing in comments
Thanks for the feedback.
I think you are talking about something like this: ISablierV2LockupSender(address(proxy)).onStreamCanceled(linear, streamId, users.recipient.addr, 10e18, 0); and not to: plugin.onStreamCanceled(linear, streamId, users.recipient.addr, 10e18, 0); The second version won't work and would do nothing. The first version can only work if the proxy contract holds the assets associated with the The solution you suggested, i.e. function test_OnStreamCanceled() external {
uint256 streamId = createWithRange();
vm.warp(defaults.CLIFF_TIME());
uint256 initialBalance = dai.balanceOf(users.sender.addr);
expectCallToTransfer({ to: users.sender.addr, amount: 10e18 });
deal({ token: address(dai), to: address(proxy), give: 10e18 });
ISablierV2LockupSender(address(proxy)).onStreamCanceled(linear, streamId, users.recipient.addr, 10e18, 0);
uint256 actualBalance = dai.balanceOf(users.sender.addr);
uint256 expectedBalance = initialBalance + 10e18;
assertEq(actualBalance, expectedBalance, "balances do not match");
} To really fix this we should make this check instead: if (msg.sender != address(lockup)) {
revert Errors.InvalidCaller();
} Regarding inheriting A downside to inheriting I just realised a potentially more dangerous issue: Certain ERC20 implementations, such as OpenZeppelin, incorporate hooks for before- and after-transfer. I kept thinking about a malicious scenario involving re-entrancy in the fallback function, which could potentially result in losing funds. Although no specific instances come to mind at the moment but I believe it's worth investigating deeper into this. |
I was actually referring to calling the plugin contract directly. Nonetheless, you made an excellent observation, i.e., that we should write another test for the case when a third party calls the
Yes, because Sablier disregards reverts triggered by hooks, but we have to write tests to validate this behavior. And this is precisely what I did: see
This doesn't work, unfortunately, because I suggest we merge this PR as is, and consider how to address this problem later - the only solution I can think of now is to add an allowlist of Sablier contract addresses, which would require us to inherit from
Correction: the material security of the proxy wouldn't be affected at the moment. However, from a best practices point of view, it is best to inherit from
It's pretty clear to me that inheriting from
The final nail in the coffin 🙈
Great point. We should also be mindful of ERC-777 tokens.
I agree that it is good to be wary about this, but I also can't think of any security threat. |
As we talked about on the phone, I need to make some clarifications because I made a few errors - thanks for correcting them, @andreivladbrg. The first error is the name of the The second is my (very) ambiguous formulation here:
I made a mush out of the plugin's behavior. There are three separate points:
|
docs: improve writing in comments feat: add "NoStandardCall" feat: add chain log to "SablierV2ProxyPlugin" feat: add interface for "SablierV2ProxyPlugin" feat: add script for deploying "SablierV2ChainLog" feat: check chain log in "onStreamCanceled" refactor: add new errors refactor: delete "InvalidCall" error refactor: disallow standard calls in "onStreamCanceled" test: add "eve" user test: add "listContracts" helper in "Base_Test" test: various small improvements test: update tests for "onStreamCanceled"
FYI, @andreivladbrg, I have accidentally merged #35 into this PR's head branch. This is not ready to review just yet, though. I will let you know. |
Depends on #28.
Addresses #19.