PaulRBerg / prb-proxy

Proxy contract to compose Ethereum transactions
https://prbproxy.com
MIT License
273 stars 47 forks source link

[Note] Selfdestructed proxies cannot be re-deployed #171

Closed emo-eth closed 1 year ago

emo-eth commented 1 year ago

This may be desired behavior, as metamorphic contracts are extremely weird, but the onlyNonProxyOwner modifier prevents a proxy being deployed for a user more than once, since it checks that _proxy[user] != address(0), and _deploy sets _proxy[user] = <create2'd address>.

If this is intended behavior, I suggest making explicit in the documentation that once a proxy is selfdestructed, it cannot be re-deployed. This can be considered a safety feature akin to @0age's ImmutableCreate2Factory.

If this is unintended behavior, i.e., a user should be able to re-deploy a proxy, it could be mitigated by checking the codesize of the proxy address is nonzero (this would not work within the same transaction as the selfdestruct, but this is broadly an issue with the selfdestruct opcode). Alternatively, you could optimistically deploy the proxy and check the address is non-zero, though this will incur significant gas overhead in the failure case.