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

fix: spearbit audit #139

Merged
merged 57 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
85b002f
fix: refactor message hash (#106)
hexshire Jul 15, 2024
004baf3
fix: add blacklist check on target address (#109)
excaliborr Jul 16, 2024
12a94f0
fix: rename l2 contract (#110)
hexshire Jul 16, 2024
2c89ed6
feat: add burned amount value on migration complete event (#107)
0xDiscotech Jul 16, 2024
0461cab
fix: add events (#113)
hexshire Jul 17, 2024
58bef50
refactor: user nonces (#108)
0xDiscotech Jul 22, 2024
3c707af
fix: deploy through portal (#115)
excaliborr Jul 22, 2024
006a27c
fix: edgecase where user is blacklisted with an inflight message (#105)
excaliborr Jul 23, 2024
dc00d18
fix: deploy l2 implementation first (#114)
excaliborr Jul 23, 2024
5ec5891
fix: create2 address has dirty bytes (#117)
excaliborr Jul 24, 2024
d3d4aa4
fix: use encodeCall and docs (#116)
excaliborr Jul 24, 2024
7a4adfa
fix: bridged usdc token naming (#118)
excaliborr Jul 24, 2024
56f49a3
fix: address zero sanity check (#120)
excaliborr Jul 24, 2024
39a260f
fix: relay old failed messages after migration (#111)
hexshire Jul 25, 2024
a198ce8
fix: eip-712 compliance (#121)
excaliborr Jul 25, 2024
8a379d6
fix: event parameters (#124)
excaliborr Jul 26, 2024
601ec75
refactor: upgradeable adapters (#122)
0xDiscotech Jul 29, 2024
3bf97c5
refactor: blacklisted funds logic (#125)
hexshire Jul 29, 2024
35dccc4
docs: improve readme (#127)
excaliborr Jul 29, 2024
c868999
docs: enhance readme (#128)
0xDiscotech Jul 29, 2024
2fa5cda
chore: add initialize function on interface (#130)
0xDiscotech Jul 29, 2024
e63941d
chore: unify modifiers (#131)
0xDiscotech Jul 30, 2024
5b94ef9
chore: update deployment flow image (#132)
0xDiscotech Jul 30, 2024
d443487
fix: invariant tests (#129)
hexshire Jul 31, 2024
0155cca
test: add new logic test cases
hexshire Jul 31, 2024
74fa428
fix: refund blacklisted funds after migration test
hexshire Jul 31, 2024
a55f2cf
test: withdraw blacklisted funds
hexshire Jul 31, 2024
f8423b2
chore: add replayed funds sent back to l1 event on l2 adapter receive…
0xDiscotech Jul 31, 2024
19b88a2
fix: natspec and comments typos (#138)
0xDiscotech Aug 1, 2024
f84d3cf
Merge branch 'audit/spearbit' into fix/echidna
hexshire Aug 1, 2024
d2d9d5c
chore: script commands and arbitrary scripts (#137)
excaliborr Aug 1, 2024
456c933
Merge branch 'audit/spearbit' into fix/echidna
hexshire Aug 1, 2024
84aca83
test: fix test
hexshire Aug 1, 2024
014e0b7
Merge branch 'fix/echidna' of github.com:defi-wonderland/opUSDC into …
hexshire Aug 1, 2024
573513f
test: blacklisted funds on l2
hexshire Aug 1, 2024
b12bc4c
fix: prop 12 on l2
simon-something Aug 1, 2024
4e9ecf3
fix: constraints 12
simon-something Aug 1, 2024
e0d8ba9
test: fill empty catch branches
hexshire Aug 2, 2024
7df9958
fix: exclude l1 blacklist from l2 test
simon-something Aug 2, 2024
3af5731
fix: resume bridging when needed
simon-something Aug 2, 2024
65e6e5d
chore: typo
simon-something Aug 2, 2024
4ea10ee
fix: status for incoming msg
simon-something Aug 2, 2024
7ee93ff
feat: corpus (temp to migrate to corpus repo)
simon-something Aug 2, 2024
a0ff97a
fix: wrong selector count + corpus
simon-something Aug 2, 2024
e63459b
test: fix migrate to native test
hexshire Aug 2, 2024
f3b6eff
feat: symb exec prop 19 (#135)
simon-something Aug 2, 2024
1fd35f9
Merge branch 'audit/spearbit' into fix/echidna
hexshire Aug 2, 2024
eb625f9
test: add new logic tests to echidna (#136)
simon-something Aug 2, 2024
f95bd80
fix: var naming (#142)
excaliborr Aug 6, 2024
075b168
chore: cancel nonce event (#143)
excaliborr Aug 7, 2024
8efdc98
chore: naming convention changed (#144)
excaliborr Aug 7, 2024
79f128e
docs: deploying & migrating section (#141)
excaliborr Aug 7, 2024
71ac5a2
docs: needed items from circle at migration (#145)
excaliborr Aug 8, 2024
2a628f7
docs: update readme (#147)
zainbacchus Aug 9, 2024
174be47
docs: spearbit report (#148)
excaliborr Aug 13, 2024
8ed9c12
fix: ci (#149)
excaliborr Aug 13, 2024
859db9d
fix: report (#150)
excaliborr Aug 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
36 changes: 28 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,55 @@ MAINNET_RPC=
OPTIMISM_RPC=
BASE_RPC=

## Mainnet
# Mainnet
MAINNET_PK=
L1_FACTORY_MAINNET=
L1_ADAPTER_OP=
L2_ADAPTER_OP=

### Optimism
#### Migration
# Custom Chain
BRIDGED_USDC_IMPLEMENTATION=
L1_MESSENGER=
CHAIN_NAME=
L1_ADAPTER=
ROLE_CALLER=
BURN_CALLER=


# Optimism
# Migration related variables
OP_USDC_ADMIN=
OP_ROLE_CALLER=
OP_ROLE_CALLER_PK=
OP_BURN_CALLER=
OP_BURN_CALLER_PK=
OP_NEW_USDC_OWNER=

## Testnet
# Testnet
SEPOLIA_PK=
L1_FACTORY_SEPOLIA=
L1_ADAPTER_OP_SEPOLIA=
L2_ADAPTER_OP_SEPOLIA=

### Op Sepolia
#### Migration
# Op Sepolia
# Migration related variables
OP_SEPOLIA_USDC_ADMIN=
OP_SEPOLIA_ROLE_CALLER=
OP_SEPOLIA_ROLE_CALLER_PK=
SEPOLIA_OP_BURN_CALLER=
SEPOLIA_OP_BURN_CALLER_PK=
OP_SEPOLIA_NEW_USDC_OWNER=

## Etherscan
ETHERSCAN_API_KEY=
# Etherscan
ETHERSCAN_API_KEY=

# USDC Implementation addresses
# These need to be deployed and set manually, ideally from circle's stablecoin-evm repo

# Mainnets
USDC_BASE_IMPLEMENTATION=
USDC_OPTIMISM_IMPLEMENTATION=

# Testnets
USDC_BASE_SEPOLIA_IMPLEMENTATION=
USDC_OPTIMISM_SEPOLIA_IMPLEMENTATION=
28 changes: 14 additions & 14 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ L2OpUSDCBridgeAdapter_Unit_SendMessageWithSignature:test_invalidSignature(addres
L2OpUSDCBridgeAdapter_Unit_SendMessageWithSignature:test_nonceIncrement(address,uint256,uint256,uint32) (runs: 1000, μ: 67918, ~: 67918)
L2OpUSDCBridgeAdapter_Unit_SendMessageWithSignature:test_revertOnExpiredMessage(address,uint256,bytes,uint256,uint256,uint32) (runs: 1000, μ: 17618, ~: 17571)
L2OpUSDCBridgeAdapter_Unit_SendMessageWithSignature:test_revertOnMessengerNotActive(address,uint256,bytes,uint256,uint32) (runs: 1000, μ: 37675, ~: 37632)
L2OpUSDCFactory_Unit_Constructor:test_callChangeAdminWithFallbackProxy() (gas: 2617614)
L2OpUSDCFactory_Unit_Constructor:test_deployAdapter() (gas: 2626966)
L2OpUSDCFactory_Unit_Constructor:test_deployUsdcImplementation() (gas: 2617585)
L2OpUSDCFactory_Unit_Constructor:test_deployUsdcProxy() (gas: 2620287)
L2OpUSDCFactory_Unit_Constructor:test_executeUsdcImplInitTxs() (gas: 2632056)
L2OpUSDCFactory_Unit_Constructor:test_executeUsdcProxyInitTxs() (gas: 2632101)
L2OpUSDCFactory_Unit_DeployCreate:test_deployCreate() (gas: 467261)
L2OpUSDCFactory_Unit_DeployCreate:test_revertIfDeploymentFailed() (gas: 41318)
L2OpUSDCFactory_Unit_ExecuteInitTxs:test_callConfigureMinter(address) (runs: 1000, μ: 27586, ~: 27586)
L2OpUSDCFactory_Unit_ExecuteInitTxs:test_callInitialize(address) (runs: 1000, μ: 30082, ~: 30082)
L2OpUSDCFactory_Unit_ExecuteInitTxs:test_callTransferOwnership(address) (runs: 1000, μ: 27463, ~: 27463)
L2OpUSDCFactory_Unit_ExecuteInitTxs:test_callUpdateMasterMinter(address) (runs: 1000, μ: 27420, ~: 27420)
L2OpUSDCFactory_Unit_ExecuteInitTxs:test_executeInitTxsArray(address) (runs: 1000, μ: 45148, ~: 45148)
L2OpUSDCFactory_Unit_ExecuteInitTxs:test_revertIfInitTxsOnArrayFail(address) (runs: 1000, μ: 77139, ~: 77139)
L2OpUSDCDeploy_Unit_Constructor:test_callChangeAdminWithFallbackProxy() (gas: 2617614)
L2OpUSDCDeploy_Unit_Constructor:test_deployAdapter() (gas: 2626966)
L2OpUSDCDeploy_Unit_Constructor:test_deployUsdcImplementation() (gas: 2617585)
L2OpUSDCDeploy_Unit_Constructor:test_deployUsdcProxy() (gas: 2620287)
L2OpUSDCDeploy_Unit_Constructor:test_executeUsdcImplInitTxs() (gas: 2632056)
L2OpUSDCDeploy_Unit_Constructor:test_executeUsdcProxyInitTxs() (gas: 2632101)
L2OpUSDCDeploy_Unit_DeployCreate:test_deployCreate() (gas: 467261)
L2OpUSDCDeploy_Unit_DeployCreate:test_revertIfDeploymentFailed() (gas: 41318)
L2OpUSDCDeploy_Unit_ExecuteInitTxs:test_callConfigureMinter(address) (runs: 1000, μ: 27586, ~: 27586)
L2OpUSDCDeploy_Unit_ExecuteInitTxs:test_callInitialize(address) (runs: 1000, μ: 30082, ~: 30082)
L2OpUSDCDeploy_Unit_ExecuteInitTxs:test_callTransferOwnership(address) (runs: 1000, μ: 27463, ~: 27463)
L2OpUSDCDeploy_Unit_ExecuteInitTxs:test_callUpdateMasterMinter(address) (runs: 1000, μ: 27420, ~: 27420)
L2OpUSDCDeploy_Unit_ExecuteInitTxs:test_executeInitTxsArray(address) (runs: 1000, μ: 45148, ~: 45148)
L2OpUSDCDeploy_Unit_ExecuteInitTxs:test_revertIfInitTxsOnArrayFail(address) (runs: 1000, μ: 77139, ~: 77139)
OpUSDCBridgeAdapter_Unit_CheckSignature:test_invalidSignature(bytes,string) (runs: 1000, μ: 70125, ~: 70146)
OpUSDCBridgeAdapter_Unit_CheckSignature:test_validSignature(bytes) (runs: 1000, μ: 19615, ~: 19563)
OpUSDCBridgeAdapter_Unit_Constructor:test_constructorParams() (gas: 20858)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright © 2023 Wonderland
Copyright © 2024 Wonderland

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
109 changes: 99 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
# opUSDC
# Bridged USDC Standard for the OP Stack

> ⚠️ This code has not been audited yet and is not production ready at this time, tread with caution.

USDC is one of the most bridged assets across the crypto ecosystem, and USDC is often bridged to new chains prior to any action from Circle. This can create a challenge when Bridged USDC achieves substantial marketshare, but Native USDC is preferred by the ecosystem, leading to fragmentation between multiple representations of USDC. Circle introduced the (Bridged USDC Standard)[https://www.circle.com/blog/bridged-usdc-standard] to ensure that chains can easily deploy a form of USDC that is capable of being upgraded in-place by Circle to Native USDC, if and when appropriate, and prevent the fragmentation problem.

Bridged USDC Standard for the OP Stack allows for an efficient and modular solution for expanding the Bridged USDC Standard across the Superchain ecosystem. Utilizing the cross chain messaging of the canonical OP Stack bridge the adapter allows for easy access to Bridged USDC liquidity across OP Stack chains.

Chain operators can use the Bridged USDC Standard for the OP Stack to get Bridged USDC on their OP Stack chain while also providing the optionality for Circle to seamlessly upgrade Bridged USDC to Native USDC and retain existing supply, holders, and app integrations.

opUSDC allows for an efficient and modular solution for expanding USDC across the optimism super chain ecosystem. Utilizing the cross chain messaging of the canonical bridge the adapter allows for easy access to USDC liquidity across all op chains.

## Contracts

_`L1OpUSDCFactory.sol`_ - Factory contract to deploy and setup the `L1OpUSDCBridgeAdapter` contract on L1. Precalculates the addresses of the L2 deployments and triggers their deployment. Setup the L1 adapter and the L2 adapter.
_`L1OpUSDCFactory.sol`_ - Factory contract to deploy and setup the `L1OpUSDCBridgeAdapter` contract on L1. Precalculates the addresses of the L2 deployments and triggers their deployment, by sending a transaction to L2.

_`L2OpUSDCFactory.sol`_ - Factory contract deployed from the L1 factory through a cross-chain deployment for deploying the L2 USDC implementation, proxy, and `L2OpUSDCBridgeAdapter` contract, all at once on the `deploy()` function.
_`L2OpUSDCDeploy.sol`_ - One time use deployer contract deployed from the L1 factory through a cross-chain deployment. Used as a utility contract for deploying the L2 USDC Proxy, and `L2OpUSDCBridgeAdapter` contract, all at once in its constructor.

_`L1OpUSDCBridgeAdapter`_ - Contract that allows for the transfer of USDC from Ethereum Mainnet to a specific OP-chain. Locks USDC on Ethereum Mainnet and sends a message to the other chain to mint the equivalent amount of USDC. Receives messages from the other chain and unlocks USDC on the Ethereum Mainnet. Controls the message flow between layers. Supports the requirements for the Bridged USDC to be migrated to Native USDC, should the chain operator and Circle want to.
_`L1OpUSDCBridgeAdapter`_ - Contract that allows for the transfer of USDC from Ethereum Mainnet to a specific OP-chain. Locks USDC on Ethereum Mainnet and sends a message to the other chain to mint the equivalent amount of USDC. Receives messages from the other chain and unlocks USDC on the Ethereum Mainnet. Controls the message flow between layers. Supports the requirements for the Bridged USDC to be migrated to Native USDC should the chain operator and Circle want to.

_`L2OpUSDCBridgeAdapter`_ - Contract that allows for the transfer of USDC from the a specific OP-chain to Ethereum Mainnet. Burns USDC on the other chain and sends a message to Ethereum Mainnet to unlock the equivalent amount of USDC. Receives messages from Ethereum Mainnet and mints USDC on the the other chain. Allows contract owner to execute arbitrary functions on the Bridged USDC contract.
_`L2OpUSDCBridgeAdapter`_ - Contract that allows for the transfer of USDC from the specific OP-chain to Ethereum Mainnet. Burns USDC on the L2 and sends a message to Ethereum Mainnet to unlock the equivalent amount of USDC. Receives messages from Ethereum Mainnet and mints USDC. Allows chain operator to execute arbitrary functions on the Bridged USDC contract as if they were the owner of the contract.

## L1 → L2 Deployment
![image](https://github.com/defi-wonderland/opUSDC/assets/165055168/ac9d0b57-03e7-40ae-b109-34d656d7539b)

![image](https://github.com/user-attachments/assets/1ec286f6-87ae-4b08-8086-ee8077a36ae3)

## L1 → L2 USDC Canonical Bridging

![image](https://github.com/defi-wonderland/opUSDC/assets/165055168/eaf55522-e768-463f-830b-b9305cec1e79)

## Migrating from Bridged USDC to Native USDC
![image](https://github.com/defi-wonderland/opUSDC/assets/165055168/17aebc4a-709f-4084-ab83-000e299a70bd)

![image](https://github.com/user-attachments/assets/291aae4c-e9fb-43a5-a11d-71bb3fc78311)


## Setup

1. Install Foundry by following the instructions from [their repository](https://github.com/foundry-rs/foundry#installation).
2. Copy the `.env.example` file to `.env` and fill in the variables.
3. Install the dependencies by running: `yarn install`. In case there is an error with the commands, run `foundryup` and try them again.
3. Install the dependencies by running: `yarn install`. If there is an error with the commands, run `foundryup` and try them again.

## Build

Expand All @@ -46,7 +54,7 @@ yarn build:optimized

## Running tests

Unit tests should be isolated from any externalities, while Integration usually run in a fork of the blockchain. In this boilerplate you will find example of both.
Unit tests should be isolated from any externalities, while Integration tests usually run in a blockchain fork. In this boilerplate, you will find examples of both.

In order to run both unit and integration tests, run:

Expand Down Expand Up @@ -78,5 +86,86 @@ In order to check your current code coverage, run:
yarn coverage
```

## Deploying

In order to deploy the opUSDC procotol for your op-chain, you will need to fill out these variables in the `.env` file:

```python
# The factory contract address on L1
L1_FACTORY_MAINNET=
# The bridged USDC implementation address on L2
BRIDGED_USDC_IMPLEMENTATION=
# The address of your CrossDomainMessenger on L1
L1_MESSENGER=
# The name of your chain
CHAIN_NAME=
# The private key that will sign the transactions on L1
MAINNET_PK=
# Ethereum RPC URL
MAINNET_RPC=
```

After all these variables are set, navigate to the `script/mainnet/Deploy.s.sol` file and edit the following lines with your desired configuration, we add a sanity check that will revert if you forget to change this value:
```solidity
// NOTE: We have these hardcoded to default values, if used in product you will need to change them

bytes[] memory _usdcInitTxs = new bytes[](3);

_usdcInitTxs[0] = USDCInitTxs.INITIALIZEV2;
_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));
```

Then run this command to test:
```bash
yarn script:deploy
```

And when you are ready to deploy to mainnet, run:
```bash
yarn script:deploy:broadcast
```

## Migrating to Native USDC
> ⚠️ Migrating to native USDC is a manual process that requires communication with circle, this section assumes both parties are ready to migrate to native USDC.

In order to migrate to native USDC, you will need to fill out these variables in the `.env` file:
```python
# The address of the L1 opUSDC bridge adapter
L1_ADAPTER=
# The private key of the transaction signer, should be the owner of the L1 Adapter
MAINNET_OWNER_PK=
# The address of the role caller, should be provided by circle
ROLE_CALLER=
# The address of the burn caller, should be provided by circle
BURN_CALLER
```

After all these variables are set, run this command to test:
```bash
yarn script:migrate
```

And when you are ready to migrate to native USDC, run:
```bash
yarn script:migrate:broadcast
```

### What will circle need at migration?

#### Circle will need the metadata from the original deployment of the USDC implementation that was used

To do this you will need to go back to the `stablecoin-evm` github repo that the implementation was deployed from in order to extract the raw metadata from the compiled files. The compiled files are usually found in the `out/` or `artifacts/` folders. To extract the raw metadata you can run a command like this:

```bash
cat out/example.sol/example.json | jq -jr '.rawMetadata' > example.metadata.json
```

You will need to do this for both the token contract and any external libraries that get deployed with it, at the time of writing this these are `FiatTokenV2_2` and `SignatureChecker` but these are subject to change in the future.

## Licensing

The primary license for the boilerplate is MIT, see [`LICENSE`](https://github.com/defi-wonderland/opUSDC/blob/main/LICENSE)
2 changes: 1 addition & 1 deletion crytic-export/combined_solc.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"lint:sol-logic": "solhint -c .solhint.json 'src/**/*.sol' 'script/**/*.sol'",
"lint:sol-tests": "solhint -c .solhint.tests.json 'test/**/*.sol'",
"prepare": "husky install",
"script:deploy": "forge script script/mainnet/deploy/Deploy.s.sol --slow --via-ir",
"script:deploy:broadcast": "forge script script/mainnet/deploy/Deploy.s.sol --broadcast --verify --slow --via-ir",
"script:migrate": "forge script script/mainnet/migration/MigrateToNative.s.sol --slow --via-ir",
"script:migrate:broadcast": "forge script script/mainnet/migration/MigrateToNative.s.sol --broadcast --verify --slow --via-ir",
"test": "forge test -vvv",
"test:fuzz": "echidna test/invariants/fuzz/OpUSDC.t.sol --config test/invariants/fuzz/config.yaml --contract OpUsdcTest",
"test:integration": "forge test --match-contract Integration -vvv",
Expand Down
49 changes: 49 additions & 0 deletions script/mainnet/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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 {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_MAINNET'));
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'));

function run() public {
vm.createSelectFork(vm.rpcUrl(vm.envString('MAINNET_RPC')));
vm.startBroadcast(owner);

// NOTE: We have these hardcoded to default values, if used in product you will need to change them

bytes[] memory _usdcInitTxs = new bytes[](3);

_usdcInitTxs[0] = USDCInitTxs.INITIALIZEV2;
_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: BRIDGED_USDC_IMPLEMENTATION,
usdcInitTxs: _usdcInitTxs,
minGasLimitDeploy: MIN_GAS_LIMIT_DEPLOY
});

// Deploy the L2 contracts
(address _l1Adapter, address _l2Factory, address _l2Adapter) =
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
console.log('L1 Adapter:', _l1Adapter);
console.log('L2 Factory:', _l2Factory);
console.log('L2 Adapter:', _l2Adapter);
}
}
7 changes: 4 additions & 3 deletions script/mainnet/deploy/DeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ 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 {USDC_IMPLEMENTATION_CREATION_CODE} from 'script/utils/USDCImplementationCreationCode.sol';
import {USDCInitTxs} from 'src/contracts/utils/USDCInitTxs.sol';

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'));
address public immutable USDC_BASE_IMPLEMENTATION = vm.envAddress('USDC_BASE_IMPLEMENTATION');
address public owner = vm.rememberKey(vm.envUint('MAINNET_PK'));

function run() public {
Expand All @@ -22,14 +23,14 @@ contract DeployBase is Script {

IL1OpUSDCFactory.L2Deployments memory _l2Deployments = IL1OpUSDCFactory.L2Deployments({
l2AdapterOwner: owner,
usdcImplementationInitCode: USDC_IMPLEMENTATION_CREATION_CODE,
usdcImplAddr: USDC_BASE_IMPLEMENTATION,
usdcInitTxs: _usdcInitTxs,
minGasLimitDeploy: MIN_GAS_LIMIT_DEPLOY
});

// Deploy the L2 contracts
(address _l1Adapter, address _l2Factory, address _l2Adapter) =
L1_FACTORY.deploy(L1_MESSENGER, owner, _l2Deployments);
L1_FACTORY.deploy(L1_MESSENGER, owner, CHAIN_NAME, _l2Deployments);
vm.stopBroadcast();

/// NOTE: Hardcode the `L1_ADAPTER_BASE` and `L2_ADAPTER_BASE` addresses inside the `.env` file
Expand Down
Loading