Skip to content

Commit

Permalink
WIP Broadcast fork section of deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
naddison36 committed Sep 30, 2024
1 parent 7abcc1d commit 3940168
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ deploy:
@forge script script/deploy/DeployManager.sol --rpc-url $(PROVIDER_URL) --private-key ${DEPLOYER_PRIVATE_KEY} --broadcast --slow --verify -vvvv

deploy-testnet:
@forge script script/deploy/DeployManager.sol --rpc-url $(TESTNET_URL) --private-key ${DEPLOYER_PRIVATE_KEY} --broadcast --slow -vvvv
@forge script script/deploy/DeployManager.sol --rpc-url $(TESTNET_URL) --broadcast --slow -vv

deploy-holesky:
@forge script script/deploy/DeployManager.sol --rpc-url $(HOLESKY_URL) --private-key ${DEPLOYER_PRIVATE_KEY} --broadcast --slow --verify -vvvv
@forge script script/deploy/DeployManager.sol --rpc-url $(HOLESKY_URL) --private-key ${DEPLOYER_PRIVATE_KEY} --broadcast --slow --verify -vvv

# Override default `test` and `coverage` targets
.PHONY: test coverage
31 changes: 23 additions & 8 deletions script/deploy/AbstractDeployScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ abstract contract AbstractDeployScript is Script {
address deployer;
uint256 public deployBlockNum = type(uint256).max;

bool public tenderlyTestnet;

// DeployerRecord stuff to be extracted as well
struct DeployRecord {
string name;
Expand All @@ -41,21 +43,25 @@ abstract contract AbstractDeployScript is Script {
}

function isForked() public returns (bool) {
return isRcpUrlTestnet() || vm.isContext(VmSafe.ForgeContext.ScriptDryRun)
return isTenderlyRpc() || vm.isContext(VmSafe.ForgeContext.ScriptDryRun)
|| vm.isContext(VmSafe.ForgeContext.TestGroup);
}

/// @notice Detect if the RPC URL is a tendrly testnet, by trying to call a specific tenderly method on rpc.
/// @dev if the call success, it means we are on a tenderly testnet, otherwise we arn't.
function isRcpUrlTestnet() public returns (bool) {
try vm.rpc("tenderly_setBalance", "[[\"0x000000000000000000000000000000000000000b\"], \"0x0\"]") {
function isTenderlyRpc() public returns (bool) {
// Try to give ethers to "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf" which is the address for pk = 0x0....01
try vm.rpc("tenderly_setBalance", "[[\"0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf\"], \"0xDE0B6B3A7640000\"]") {
tenderlyTestnet = true;
return true;
} catch {
return false;
}
}

function setUp() external virtual {}
function setUp() external virtual {
isTenderlyRpc();
}

function run() external {
// Will not execute script if after this block number
Expand All @@ -65,9 +71,14 @@ abstract contract AbstractDeployScript is Script {
}

if (this.isForked()) {
deployer = Mainnet.INITIAL_DEPLOYER;
console.log("Running script on mainnet fork impersonating: %s", deployer);
vm.startPrank(deployer);
deployer = vm.rememberKey(uint256(1));
if (tenderlyTestnet) {
console.log("Deploying on Tenderly testnet with deployer: %s", deployer);
vm.startBroadcast(deployer);
} else {
console.log("Running script on mainnet fork impersonating: %s", deployer);
vm.startPrank(deployer);
}
} else {
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");
deployer = vm.rememberKey(deployerPrivateKey);
Expand All @@ -78,7 +89,11 @@ abstract contract AbstractDeployScript is Script {
_execute();

if (this.isForked()) {
vm.stopPrank();
if (tenderlyTestnet) {
vm.stopBroadcast();
} else {
vm.stopPrank();
}
_buildGovernanceProposal();
_fork();
} else {
Expand Down
16 changes: 14 additions & 2 deletions script/deploy/mainnet/003_UpgradeLidoARMScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ contract UpgradeLidoARMMainnetScript is AbstractDeployScript {
// 7. Transfer ownership of LiquidityProviderController to the mainnet 5/8 multisig
lpcProxy.setOwner(Mainnet.GOV_MULTISIG);

console.log("Finished deploying", DEPLOY_NAME);

// Post deploy
// 1. The Lido ARM multisig needs to set the owner to the mainnet 5/8 multisig
// 1. The mainnet 5/8 multisig needs to upgrade and call initialize on the Lido ARM
Expand All @@ -68,7 +70,13 @@ contract UpgradeLidoARMMainnetScript is AbstractDeployScript {
function _buildGovernanceProposal() internal override {}

function _fork() internal override {
vm.startPrank(Mainnet.ARM_MULTISIG);
if (tenderlyTestnet) {
console.log("Broadcasting fork script to Tenderly as: %s", Mainnet.ARM_MULTISIG);
vm.startBroadcast(Mainnet.ARM_MULTISIG);
} else {
console.log("Executing fork script against a fork as: %s", Mainnet.ARM_MULTISIG);
vm.startPrank(Mainnet.ARM_MULTISIG);
}

if (lidoARMProxy == Proxy(0x0000000000000000000000000000000000000000)) {
revert("Lido ARM proxy not found");
Expand Down Expand Up @@ -120,6 +128,10 @@ contract UpgradeLidoARMMainnetScript is AbstractDeployScript {

console.log("Finished running initializing Lido ARM as ARM_MULTISIG");

vm.stopPrank();
if (tenderlyTestnet) {
vm.stopBroadcast();
} else {
vm.stopPrank();
}
}
}
8 changes: 1 addition & 7 deletions src/contracts/utils/Addresses.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ library Mainnet {
address public constant GOVERNOR_FIVE = 0x3cdD07c16614059e66344a7b579DAB4f9516C0b6;
address public constant GOVERNOR_SIX = 0x1D3Fbd4d129Ddd2372EA85c5Fa00b2682081c9EC;
address public constant STRATEGIST = 0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC;
address public constant TREASURY = 0x0000000000000000000000000000000000000001;
address public constant TREASURY = 0x6E3fddab68Bf1EBaf9daCF9F7907c7Bc0951D1dc;

// Multisig and EOAs
address public constant INITIAL_DEPLOYER = address(0x1001);
address public constant GOV_MULTISIG = 0xbe2AB3d3d8F6a32b96414ebbd865dBD276d3d899;
address public constant ARM_MULTISIG = 0xC8F2cF4742C86295653f893214725813B16f7410;
address public constant OETH_RELAYER = 0x4b91827516f79d6F6a1F292eD99671663b09169a;
Expand All @@ -40,7 +39,6 @@ library Mainnet {

library Holesky {
// Multisig and EOAs
address public constant INITIAL_DEPLOYER = 0x1b94CA50D3Ad9f8368851F8526132272d1a5028C;
address public constant RELAYER = 0x3C6B0c7835a2E2E0A45889F64DcE4ee14c1D5CB4;

// Tokens
Expand Down Expand Up @@ -84,7 +82,6 @@ contract AddressResolver {
resolver[MAINNET]["LIDO_ARM"] = Mainnet.LIDO_ARM;

// Test accounts
resolver[MAINNET]["INITIAL_DEPLOYER"] = address(0x1001);
resolver[MAINNET]["WHALE_OETH"] = 0x8E02247D3eE0E6153495c971FFd45Aa131f4D7cB;

///// Holesky //////
Expand All @@ -99,9 +96,6 @@ contract AddressResolver {
// Contracts
resolver[HOLESKY]["OETH_VAULT"] = Holesky.OETH_VAULT;
resolver[HOLESKY]["OETH_ARM"] = Mainnet.OETH_ARM;

// Test accounts
resolver[HOLESKY]["INITIAL_DEPLOYER"] = Holesky.INITIAL_DEPLOYER;
}

function resolve(string memory name) public view returns (address resolved) {
Expand Down

0 comments on commit 3940168

Please sign in to comment.