Skip to content

Commit

Permalink
prank delegatecall bug demo
Browse files Browse the repository at this point in the history
  • Loading branch information
maurelian committed Jan 4, 2025
1 parent 01fba5c commit 64bb4b7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/contracts-bedrock/test/setup/ForkLive.s.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { console } from "forge-std/console.sol";
// Testing
import { stdJson } from "forge-std/StdJson.sol";

Expand Down Expand Up @@ -132,17 +133,25 @@ contract ForkLive is Deployer {
IProxyAdmin proxyAdmin = IProxyAdmin(EIP1967Helper.getAdmin(address(systemConfig)));

address upgrader = proxyAdmin.owner();
vm.label(upgrader, "ProxyAdmin Owner");

ISystemConfig[] memory systemConfigs = new ISystemConfig[](1);
systemConfigs[0] = systemConfig;
IProxyAdmin[] memory proxyAdmins = new IProxyAdmin[](1);
proxyAdmins[0] = proxyAdmin;

// TODO: Add support for this prank() call to forge-std
(bool success,) = address(vm).call(abi.encodeWithSignature("prank(address,bool)", upgrader, true));
console.log("delegatecall with prank");
(bool success,) = address(vm).call(abi.encodeWithSignature("prank(address,bool)", address(this), true));
require(success, "ForkLive: Failed to prank");

(success,) = address(opcm).delegatecall(abi.encodeCall(OPContractsManager.upgrade, (systemConfigs, proxyAdmins)));
(success,) =
address(opcm).delegatecall(abi.encodeCall(OPContractsManager.upgrade, (systemConfigs, proxyAdmins)));
require(success, "ForkLive: Upgrade failed");

console.log("delegatecall without prank");
(success,) =
address(opcm).delegatecall(abi.encodeCall(OPContractsManager.upgrade, (systemConfigs, proxyAdmins)));
require(success, "ForkLive: Upgrade failed");
}

Expand Down

0 comments on commit 64bb4b7

Please sign in to comment.