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

refactor: plugin redesign #125

Merged
merged 2 commits into from
Jun 28, 2023

Conversation

PaulRBerg
Copy link
Owner

Closes #122.

@PaulRBerg PaulRBerg changed the base branch from main to fix/create2-salt June 22, 2023 15:32
@PaulRBerg PaulRBerg force-pushed the fix/create2-salt branch 2 times, most recently from 231b87f to 0636044 Compare June 24, 2023 09:14
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"
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
Copy link
Collaborator

@andreivladbrg andreivladbrg left a comment

Choose a reason for hiding this comment

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

Looks good👍

Base automatically changed from fix/create2-salt to fix/plugin-method-collision June 28, 2023 18:51
@PaulRBerg PaulRBerg merged commit c3c3a1b into fix/plugin-method-collision Jun 28, 2023
@PaulRBerg
Copy link
Owner Author

Yanked in favor of #131.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save plugin method list at install time and use it when uninstalling
2 participants