Plugin support #42
Replies: 5 comments 1 reply
-
Wow, this is such a detailed feature proposal. Thanks for taking the time to write it up! I'm totally onboard with this - it does not add much overhead in terms of extra gas to pay for deploying the proxy, and generally it is non-invasive to the default user experience. A user has to opt-in to the plugin system by manually installing a plugin only when they need it, which effectively addresses the concerns I shared in #24. I don't have an ETA for when I will finish implementing this, but it will be done! |
Beta Was this translation helpful? Give feedback.
-
@cleanunicorn awesome work! I'd be interested in using the plug-in system. Do you have plans to open a PR to merge it upstream? |
Beta Was this translation helpful? Give feedback.
-
I have some time these following weeks to create an implementation with complete tests that add the plugin system. I'll create a PR as soon as I have something. @PaulRBerg would that be okay with you? |
Beta Was this translation helpful? Give feedback.
-
I started working on this. Will push a PR within a week. |
Beta Was this translation helpful? Give feedback.
-
Going to lock this discussion as this feature has been implemented in #53. |
Beta Was this translation helpful? Give feedback.
-
There is a need for this proxy to support receiving tokens. Unfortunately in its current form, the proxy does not support that.
Background
We use this proxy to enhance the user experience, but we hit the limitation of not being able to receive tokens (specifically EIP1155 and EIP721).
Thus, we had to fork the proxy, since an extension of this functionality was not possible. We achieved this by forking the proxy and inheriting ERC1155Holder and ERC721Holder from OpenZeppelin.
https://github.com/fiatdao/proxy/blob/553a28073011521fcf393842ceb10fa05dcb7fa7/contracts/PRBProxy.sol#L25
Proposal
My idea is a plugin system that allows each plugin to be installed/uninstalled by the owner.
This can be achieved when the proxy implements the
fallback()
method and checks for known, installed method signatures. If they are found, it can delegate execution to the plugin implementation.Such an implementation of the
fallback()
method could look like this:Checking if a method is implemented can be done by maintaining a list of installed methods:
The fallback method can use this mapping to check if the request should be delegated or exit early:
The rest of the execution can be very similar to how the proxy handles execution right now:
gasleft() - minGasReserve
) to the executionFunctionality
The plugin should have a standardized way of installing and uninstalling plugins. For this, an
interface
needs to be provided and implemented.methods()
- returns a list of method signatures it supportsThe proxy needs to implement and additional pair of methods:
install(address plugin_)
- installs a new pluginuninstall(address plugin_)
- uninstalls an existing pluginThese methods need to be generalized and they should use the list provided by
IPRBProxyPlugin.methods()
to register or unregister implemented methods.An example of these methods:
More functionality needs to be added in these methods:
[Work in progress] Implementation
A working repository that extends the current PRBProxy and adds this functionality on top is here.
To help with navigating the repo, here are the important parts:
References
These features can be implemented as plugins
Beta Was this translation helpful? Give feedback.
All reactions