-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
refactor: ownership redesign #119
Conversation
8e42354
to
9750486
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.
I can say that the design is cleaner now.
Not sure if it's a good idea(it would slightly increase the gas) but what do you think about changing the internal _deploy
function to: function _deploy(ConstructorParams calldata params)
. This way you will be able to remove duplicated code from _deploy
and deployAndExecute
.
Thanks for the review. I agree that the new design is clearer - and safer. Interesting idea to pass Both functions are well-tested, so we have a pretty good idea that they work as expected. |
c738a35
to
b9144a7
Compare
b229563
to
17f65af
Compare
Just noticed prb-proxy/src/PRBProxyRegistry.sol Lines 132 to 134 in 17f65af
Given that the only variable used here is the owner, this can be optimized to: constructorParams.owner = owner;
proxy = new PRBProxy{ salt: salt }();
constructorParams.owner = address(0); |
Interesting optimization idea @andreivladbrg but the two implementations cost the same gas when only the https://chat.openai.com/share/3187fa95-2732-4fe8-95c0-539e259fc835 Also, assigning only the |
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.
Set the proxies[owner] to a temp value before creating the proxy to avoid reentrancy for the same owner
prb-proxy/src/PRBProxyRegistry.sol
Lines 95 to 99 in 17f65af
proxy = new PRBProxy{ salt: salt }(); | |
delete constructorParams; | |
// Associate the the owner with the proxy in the mapping. | |
proxies[owner] = proxy; |
noProxy(owner)
modifier would pass otherwise when calling deployFor
on the registry with the same owner creating 2 proxies with the same owner set in the proxy itself, and the first one set in the registry.
All constructor params should be set here (target and data to 0), not just the owner prb-proxy/src/PRBProxyRegistry.sol Line 132 in 17f65af
|
I don't think that using GPT for this specific use case is the best choice, tested this in remix and it was actually a difference by few thousands.
Right, it is safer to use |
Thanks for your review, both!
As discussed on Discord, this cannot happen under the current design - happy to take a call tomorrow to walk through the low-level steps.
Agree with this proposal - it would be a good precautionary step even if the attack above cannot happen.
You may be right about ChatGPT (the 2021 cut-off), but did you use via IR and the same number of optimizer runs in your test?
Yep |
Yes |
a721d89
to
af7353c
Compare
chore: ignore and clean "coverage" directory feat: add "ConstructorParams" in registry refactor: delete "owner" from storage refactor: make "owner" immutable refactor: disallow delegate calling to the registry test: add tests for proxy owner test: delete unused imports test: polish error messages in assertions
af7353c
to
e060114
Compare
e060114
to
07fed42
Compare
@tibbarytsur and @andreivladbrg have reviewed this PR, but I will also wait for Zach's confirmation before merging this in. |
Closes #108, addressing all of the audit report findings mentioned there.