Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handler Tenderly testnet #26

Open
wants to merge 3 commits into
base: nicka/lp
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ 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 --unlocked -vvvv

deploy-holesky:
@forge script script/deploy/DeployManager.sol --rpc-url $(HOLESKY_URL) --private-key ${DEPLOYER_PRIVATE_KEY} --broadcast --slow --verify -vvvv
Expand Down
42 changes: 35 additions & 7 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,10 +43,25 @@ abstract contract AbstractDeployScript is Script {
}

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

function setUp() external virtual {}
/// @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 isTenderlyRpc() public returns (bool) {
// Try to give ethers to "ARM_MULTISIG"
try vm.rpc("tenderly_setBalance", "[[\"0xC8F2cF4742C86295653f893214725813B16f7410\"], \"0xDE0B6B3A7640000\"]") {
tenderlyTestnet = true;
return true;
} catch {
return false;
}
}

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

function run() external {
// Will not execute script if after this block number
Expand All @@ -55,8 +72,13 @@ 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);
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 @@ -67,9 +89,15 @@ abstract contract AbstractDeployScript is Script {
_execute();

if (this.isForked()) {
vm.stopPrank();
_buildGovernanceProposal();
_fork();
if (tenderlyTestnet) {
_buildGovernanceProposal();
vm.stopBroadcast();
_fork();
} else {
vm.stopPrank();
_buildGovernanceProposal();
_fork();
}
} else {
vm.stopBroadcast();
}
Expand Down
6 changes: 5 additions & 1 deletion script/deploy/mainnet/003_UpgradeLidoARMScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ contract UpgradeLidoARMMainnetScript is AbstractDeployScript {
function _buildGovernanceProposal() internal override {}

function _fork() internal override {
vm.startPrank(Mainnet.ARM_MULTISIG);
if (tenderlyTestnet) {
vm.startBroadcast(Mainnet.ARM_MULTISIG);
} else {
vm.startPrank(Mainnet.ARM_MULTISIG);
}

if (lidoARMProxy == Proxy(0x0000000000000000000000000000000000000000)) {
revert("Lido ARM proxy not found");
Expand Down