Proxies - Test
In the off-chain-compute pattern, a user computes a value off-chain and submits it to the contract. The user can submit any value they want, including a wrong one.
This scenario reflects Ethereum before the Dencun upgrade of March 2024. A UUPS implementation has a function that calls selfdestruct(payable(msg.sender)) under certain conditions. An attacker manages to trigger this on the implementation contract directly (calling it at its own address rather than through the proxy), and back then the code at the implementation address was destroyed. Since EIP-6780, selfdestruct removes a contract only when it runs in the same transaction that created that contract, so an already-deployed implementation can no longer be destroyed this way. Assuming the pre-Dencun behavior, what happens to the proxy?
A team deploys their UUPS proxy in two separate transactions. First, they call the factory to deploy the proxy + implementation. The deployment script then calls initialize() on the proxy as a follow-up transaction:
const proxy = await factory.deployProxy(implementation);
await proxy.initialize(deployerAddress); // sets ownerA bot watching the mempool sees the proxy contract deployed. Before the team's initialize() transaction confirms, the bot front-runs it by calling initialize(botAddress) itself. What is the outcome?
A function declared as function f(uint256[] memory arr) external differs from function f(uint256[] calldata arr) external in what way?
When upgrading a UUPS proxy, who initiates the upgrade?