Skip to content

Commit

Permalink
feat: checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDiscotech committed Oct 8, 2024
1 parent 5580a21 commit fa3bbd2
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ out-via-ir

# Config files
.env
.env.testnet

# Avoid ignoring gitkeep
!/**/.gitkeep
Expand Down
21 changes: 21 additions & 0 deletions script/DeployL1Factory.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {L1OpUSDCFactory} from 'contracts/L1OpUSDCFactory.sol';
import {Script} from 'forge-std/Script.sol';
import {console} from 'forge-std/Test.sol';
import {IL1OpUSDCFactory} from 'interfaces/IL1OpUSDCFactory.sol';

Check warning on line 7 in script/DeployL1Factory.s.sol

View workflow job for this annotation

GitHub Actions / Lint

Variable "IL1OpUSDCFactory" is unused

contract DeployL1Factory is Script {
// address public deployer = vm.rememberKey(vm.envUint('PK'));
// address public usdc = vm.envAddress('USDC_ETHEREUM_IMPLEMENTATION');

function deployFactory(uint256 _deployerPk, address _usdc) public returns (address _l1Factory) {
address _deployer = vm.rememberKey(_deployerPk);
vm.startBroadcast(_deployer);
console.log('Deploying L1OpUSDCFactory ...');
_l1Factory = address(new L1OpUSDCFactory(_usdc));
console.log('L1OpUSDCFactory deployed at:', address(_l1Factory));
vm.stopBroadcast();
}
}
55 changes: 55 additions & 0 deletions script/DeployProtocol.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {Script} from 'forge-std/Script.sol';
import {console} from 'forge-std/Test.sol';
import {IL1OpUSDCFactory} from 'interfaces/IL1OpUSDCFactory.sol';
import {IUSDC} from 'interfaces/external/IUSDC.sol';
import {USDCInitTxs} from 'src/contracts/utils/USDCInitTxs.sol';

contract DeployProtocol is Script {
uint32 public constant MIN_GAS_LIMIT_DEPLOY = 9_000_000;
// IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY'));
// address public immutable BRIDGED_USDC_IMPLEMENTATION = vm.envAddress('BRIDGED_USDC_IMPLEMENTATION');
// address public immutable L1_MESSENGER = vm.envAddress('L1_MESSENGER');
// string public chainName = vm.envString('CHAIN_NAME');
// address public owner = vm.rememberKey(vm.envUint('PK'));

function deployProtocol(
uint256 _ownerPk,
address _l1Factory,
address _bridgedUsdcImplementation,
address _l1Messenger,
string memory _chainName
) public {
address _owner = vm.rememberKey(_ownerPk);
vm.startBroadcast(_owner);

// NOTE: We have these hardcoded to default values, if used in production you will need to change them
bytes[] memory _usdcInitTxs = new bytes[](3);
string memory _name = string.concat('Bridged USDC', ' ', '(', _chainName, ')');

_usdcInitTxs[0] = abi.encodeCall(IUSDC.initializeV2, (_name));
_usdcInitTxs[1] = USDCInitTxs.INITIALIZEV2_1;
_usdcInitTxs[2] = USDCInitTxs.INITIALIZEV2_2;

// Sanity check to ensure the caller of this script changed this value to the proper naming
assert(keccak256(_usdcInitTxs[0]) != keccak256(USDCInitTxs.INITIALIZEV2));

IL1OpUSDCFactory.L2Deployments memory _l2Deployments = IL1OpUSDCFactory.L2Deployments({
l2AdapterOwner: _owner,
usdcImplAddr: _bridgedUsdcImplementation,
usdcInitTxs: _usdcInitTxs,
minGasLimitDeploy: MIN_GAS_LIMIT_DEPLOY
});

// Deploy the L2 contracts
(address _l1Adapter, address _l2Deploy, address _l2Adapter) =
IL1OpUSDCFactory(_l1Factory).deploy(_l1Messenger, _owner, _chainName, _l2Deployments);
vm.stopBroadcast();

console.log('L1 Adapter:', _l1Adapter);
console.log('L2 Adapter:', _l2Adapter);
console.log('L2 Deploy:', _l2Deploy);
}
}
7 changes: 4 additions & 3 deletions script/mainnet/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import {IL1OpUSDCFactory} from 'interfaces/IL1OpUSDCFactory.sol';
import {IUSDC} from 'interfaces/external/IUSDC.sol';
import {USDCInitTxs} from 'src/contracts/utils/USDCInitTxs.sol';

import {DeployProtocol} from 'script/DeployProtocol.s.sol';

Check warning on line 10 in script/mainnet/deploy/Deploy.s.sol

View workflow job for this annotation

GitHub Actions / Lint

Variable "DeployProtocol" is unused

contract Deploy is Script {
uint32 public constant MIN_GAS_LIMIT_DEPLOY = 9_000_000;
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY_MAINNET'));
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY'));
address public immutable BRIDGED_USDC_IMPLEMENTATION = vm.envAddress('BRIDGED_USDC_IMPLEMENTATION');
address public immutable L1_MESSENGER = vm.envAddress('L1_MESSENGER');
string public chainName = vm.envString('CHAIN_NAME');
address public owner = vm.rememberKey(vm.envUint('MAINNET_PK'));
address public owner = vm.rememberKey(vm.envUint('PK'));

function run() public {
vm.startBroadcast(owner);
Expand Down
4 changes: 2 additions & 2 deletions script/mainnet/deploy/DeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ contract DeployBase is Script {
address public constant L1_MESSENGER = 0x866E82a600A1414e583f7F13623F1aC5d58b0Afa;
uint32 public constant MIN_GAS_LIMIT_DEPLOY = 9_000_000;
string public constant CHAIN_NAME = 'Base';
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY_MAINNET'));
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY'));
address public immutable USDC_BASE_IMPLEMENTATION = vm.envAddress('USDC_BASE_IMPLEMENTATION');
address public owner = vm.rememberKey(vm.envUint('MAINNET_PK'));
address public owner = vm.rememberKey(vm.envUint('PK'));

function run() public {
vm.startBroadcast(owner);
Expand Down
4 changes: 2 additions & 2 deletions script/mainnet/deploy/DeployOptimism.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ contract DeployOptimism is Script {
address public constant L1_MESSENGER = 0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1;
uint32 public constant MIN_GAS_LIMIT_DEPLOY = 9_000_000;
string public constant CHAIN_NAME = 'Optimism';
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY_MAINNET'));
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY'));
address public immutable USDC_OPTIMISM_IMPLEMENTATION = vm.envAddress('USDC_OPTIMISM_IMPLEMENTATION');
address public owner = vm.rememberKey(vm.envUint('MAINNET_PK'));
address public owner = vm.rememberKey(vm.envUint('PK'));

function run() public {
vm.startBroadcast(owner);
Expand Down
4 changes: 2 additions & 2 deletions script/mainnet/deploy/L1FactoryDeployAndSetup.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import {console} from 'forge-std/Test.sol';
import {IL1OpUSDCFactory} from 'interfaces/IL1OpUSDCFactory.sol';

contract L1FactoryDeployAndSetup is Script {
address public deployer = vm.rememberKey(vm.envUint('MAINNET_PK'));
address public deployer = vm.rememberKey(vm.envUint('PK'));
address public usdc = vm.envAddress('USDC_ETHEREUM_IMPLEMENTATION');

function run() public {
vm.startBroadcast(deployer);
console.log('Deploying L1OpUSDCFactory ...');
IL1OpUSDCFactory _l1Factory = new L1OpUSDCFactory(usdc);
console.log('L1OpUSDCFactory deployed at:', address(_l1Factory));
/// NOTE: Hardcode the address on `L1_FACTORY_MAINNET` inside the `.env` file
/// NOTE: Hardcode the address on `L1_FACTORY` inside the `.env` file
vm.stopBroadcast();
}
}
4 changes: 2 additions & 2 deletions script/mainnet/migration/MigrateToNative.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ contract MigrateToNative is Script {
uint32 public constant MIN_GAS_LIMIT_SET_BURN_AMOUNT_L2 = 100_000;
IL1OpUSDCBridgeAdapter public immutable L1_ADAPTER = IL1OpUSDCBridgeAdapter(vm.envAddress('L1_ADAPTER'));

address public owner = vm.rememberKey(vm.envUint('MAINNET_OWNER_PK'));
address public owner = vm.rememberKey(vm.envUint('OWNER_PK'));
address public roleCaller = vm.envAddress('ROLE_CALLER');
address public burnCaller = vm.envAddress('BURN_CALLER');

function run() public {
vm.createSelectFork(vm.rpcUrl(vm.envString('MAINNET_RPC')));
vm.createSelectFork(vm.rpcUrl(vm.envString('RPC')));
vm.startBroadcast(owner);
L1_ADAPTER.migrateToNative(roleCaller, burnCaller, MIN_GAS_LIMIT_RECEIVE_L2, MIN_GAS_LIMIT_SET_BURN_AMOUNT_L2);
vm.stopBroadcast();
Expand Down
2 changes: 1 addition & 1 deletion script/mainnet/migration/MigrateToNativeOp.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract MigrateToNativeOp is Script {
uint32 public constant MIN_GAS_LIMIT_SET_BURN_AMOUNT_L2 = 100_000;
IL1OpUSDCBridgeAdapter public immutable L1_ADAPTER = IL1OpUSDCBridgeAdapter(vm.envAddress('L1_ADAPTER_OP'));

address public owner = vm.rememberKey(vm.envUint('MAINNET_OWNER_PK'));
address public owner = vm.rememberKey(vm.envUint('OWNER_PK'));
address public roleCaller = vm.envAddress('OP_ROLE_CALLER');
address public burnCaller = vm.envAddress('OP_BURN_CALLER');

Expand Down
12 changes: 6 additions & 6 deletions script/testnet/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {USDCInitTxs} from 'src/contracts/utils/USDCInitTxs.sol';

contract Deploy is Script {
uint32 public constant MIN_GAS_LIMIT_DEPLOY = 9_000_000;
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY_TESTNET'));
address public immutable BRIDGED_USDC_IMPLEMENTATION = vm.envAddress('TESTNET_BRIDGED_USDC_IMPLEMENTATION');
address public immutable L1_MESSENGER = vm.envAddress('L1_MESSENGER_TESTNET');
string public chainName = vm.envString('TESTNET_CHAIN_NAME');
address public owner = vm.rememberKey(vm.envUint('TESTNET_PK'));
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY'));
address public immutable BRIDGED_USDC_IMPLEMENTATION = vm.envAddress('BRIDGED_USDC_IMPLEMENTATION');
address public immutable L1_MESSENGER = vm.envAddress('L1_MESSENGER');
string public chainName = vm.envString('CHAIN_NAME');
address public owner = vm.rememberKey(vm.envUint('PK'));

function run() public {
vm.startBroadcast(owner);
Expand Down Expand Up @@ -41,7 +41,7 @@ contract Deploy is Script {
L1_FACTORY.deploy(L1_MESSENGER, owner, chainName, _l2Deployments);
vm.stopBroadcast();

/// NOTE: Hardcode the `L1_ADAPTER_BASE` and `L2_ADAPTER_BASE` addresses inside the `.env` file
/// NOTE: Hardcode the `L1_ADAPTER_BASE` and `L2_ADAPTER_BASE` addresses inside the `.env.example` file
console.log('L1 Adapter:', _l1Adapter);
console.log('L2 Factory:', _l2Factory);
console.log('L2 Adapter:', _l2Adapter);
Expand Down
4 changes: 2 additions & 2 deletions script/testnet/deploy/DeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract DeployBase is Script {
address public constant L1_MESSENGER = 0xC34855F4De64F1840e5686e64278da901e261f20;
uint32 public constant MIN_GAS_LIMIT_DEPLOY = 9_000_000;
string public constant CHAIN_NAME = 'Base Sepolia';
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY_TESTNET'));
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY'));
address public immutable USDC_BASE_SEPOLIA_IMPLEMENTATION = vm.envAddress('USDC_BASE_SEPOLIA_IMPLEMENTATION');

address public owner = vm.rememberKey(vm.envUint('SEPOLIA_PK'));
Expand All @@ -34,7 +34,7 @@ contract DeployBase is Script {
L1_FACTORY.deploy(L1_MESSENGER, owner, CHAIN_NAME, _l2Deployments);
vm.stopBroadcast();

/// NOTE: Hardcode the `L1_ADAPTER_BASE_SEPOLIA` and `L2_ADAPTER_BASE_SEPOLIA` addresses inside the `.env` file
/// NOTE: Hardcode the `L1_ADAPTER_BASE_SEPOLIA` and `L2_ADAPTER_BASE_SEPOLIA` addresses inside the `.env.example` file

Check warning on line 37 in script/testnet/deploy/DeployBase.s.sol

View workflow job for this annotation

GitHub Actions / Lint

Line length must be no more than 120 but current length is 123
console.log('L1 Adapter:', _l1Adapter);
console.log('L2 Factory:', _l2Factory);
console.log('L2 Adapter:', _l2Adapter);
Expand Down
4 changes: 2 additions & 2 deletions script/testnet/deploy/DeployOptimism.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract DeployOptimism is Script {
address public constant L1_MESSENGER = 0x58Cc85b8D04EA49cC6DBd3CbFFd00B4B8D6cb3ef;
uint32 public constant MIN_GAS_LIMIT_DEPLOY = 9_000_000;
string public constant CHAIN_NAME = 'Optimism Sepolia';
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY_TESTNET'));
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY'));
address public immutable USDC_OPTIMISM_SEPOLIA_IMPLEMENTATION = vm.envAddress('USDC_OPTIMISM_SEPOLIA_IMPLEMENTATION');

address public owner = vm.rememberKey(vm.envUint('SEPOLIA_PK'));
Expand All @@ -34,7 +34,7 @@ contract DeployOptimism is Script {
L1_FACTORY.deploy(L1_MESSENGER, owner, CHAIN_NAME, _l2Deployments);
vm.stopBroadcast();

/// NOTE: Hardcode the `L1_ADAPTER_OP_SEPOLIA` and `L2_ADAPTER_OP_SEPOLIA` addresses inside the `.env` file
/// NOTE: Hardcode the `L1_ADAPTER_OP_SEPOLIA` and `L2_ADAPTER_OP_SEPOLIA` addresses inside the `.env.example` file
console.log('L1 Adapter:', _l1Adapter);
console.log('L2 Factory:', _l2Factory);
console.log('L2 Adapter:', _l2Adapter);
Expand Down
6 changes: 3 additions & 3 deletions script/testnet/deploy/L1FactoryDeployAndSetup.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import {console} from 'forge-std/Test.sol';
import {IL1OpUSDCFactory} from 'interfaces/IL1OpUSDCFactory.sol';

contract L1FactoryDeployAndSetup is Script {
address public deployer = vm.rememberKey(vm.envUint('TESTNET_PK'));
address public usdc = vm.envAddress('USDC_ETHEREUM_TESTNET_IMPLEMENTATION');
address public deployer = vm.rememberKey(vm.envUint('PK'));
address public usdc = vm.envAddress('USDC_ETHEREUM_IMPLEMENTATION');

function run() public {
vm.startBroadcast(deployer);
console.log('Deploying L1OpUSDCFactory ...');
IL1OpUSDCFactory _l1Factory = new L1OpUSDCFactory(usdc);
console.log('L1OpUSDCFactory deployed at:', address(_l1Factory));
/// NOTE: Hardcode the address on `L1_FACTORY_TESTNET` inside the `.env` file
/// NOTE: Hardcode the address on `L1_FACTORY` inside the `.env.example` file
vm.stopBroadcast();
}
}

0 comments on commit fa3bbd2

Please sign in to comment.