-
-
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: plugin redesign #125
Merged
PaulRBerg
merged 2 commits into
fix/plugin-method-collision
from
refactor/plugin-redesign
Jun 28, 2023
Merged
refactor: plugin redesign #125
PaulRBerg
merged 2 commits into
fix/plugin-method-collision
from
refactor/plugin-redesign
Jun 28, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PaulRBerg
force-pushed
the
fix/create2-salt
branch
2 times, most recently
from
June 24, 2023 09:14
231b87f
to
0636044
Compare
docs: polish NatSpe comments feat: add getters for retrieving plugin methods feat: store plugin methods in reverse mapping refactor: rename "methodList" to "methods" refactor: update error names test: rename "dummy" to "basic" test: update tests for "installPlugin" and "uninstallPlugin"
PaulRBerg
force-pushed
the
refactor/plugin-redesign
branch
from
June 24, 2023 09:14
685f8b9
to
2897e45
Compare
Comment on lines
+248
to
+281
function _installPlugin(IPRBProxyPlugin plugin) internal { | ||
// Retrieve the methods to install. | ||
bytes4[] memory methods = plugin.getMethods(); | ||
|
||
// The plugin must implement at least one method. | ||
uint256 length = methods.length; | ||
if (length == 0) { | ||
revert PRBProxyRegistry_PluginWithZeroMethods(plugin); | ||
} | ||
|
||
// Install every method in the list. | ||
address owner = msg.sender; | ||
for (uint256 i = 0; i < length;) { | ||
// Check for collisions. | ||
bytes4 method = methods[i]; | ||
if (address(_plugins[owner][method]) != address(0)) { | ||
revert PRBProxyRegistry_PluginMethodCollision({ | ||
currentPlugin: _plugins[owner][method], | ||
newPlugin: plugin, | ||
method: method | ||
}); | ||
} | ||
_plugins[owner][method] = plugin; | ||
unchecked { | ||
i += 1; | ||
} | ||
} | ||
|
||
// Set the methods in the reverse mapping. | ||
_methods[owner][plugin] = methods; | ||
|
||
// Log the plugin installation. | ||
emit InstallPlugin(owner, _proxies[owner], plugin, methods); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
Reentrancy in PRBProxyRegistry._installPlugin(IPRBProxyPlugin) (src/PRBProxyRegistry.sol#248-281):
External calls:
- methods = plugin.getMethods() (src/PRBProxyRegistry.sol#250)
State variables written after the call(s):
- _methods[owner][plugin] = methods (src/PRBProxyRegistry.sol#277)
- _plugins[owner][method] = plugin (src/PRBProxyRegistry.sol#270)
docs: polish NatSpec comments
PaulRBerg
force-pushed
the
refactor/plugin-redesign
branch
from
June 24, 2023 10:05
d824f3d
to
2fc7d99
Compare
andreivladbrg
approved these changes
Jun 28, 2023
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.
Looks good👍
Yanked in favor of #131. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #122.