Skip to content

Commit

Permalink
Merge pull request #7 from yieldnest/feature/morph-addition
Browse files Browse the repository at this point in the history
add morph l2
  • Loading branch information
dan13ram authored Sep 20, 2024
2 parents 452cc07 + b86fbe3 commit 3a7fe18
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ OPTIMISTIC_ETHERSCAN_API_KEY=
ARBISCAN_API_KEY=
BASESCAN_API_KEY=
FRAXSCAN_API_KEY=
MORPHSCAN_API_KEY=

# for testing and deploying the contracts please use full arhcival nodes
BASE_RPC_URL=
Expand All @@ -14,6 +15,7 @@ HOLESKY_RPC_URL=
SEPOLIA_RPC_URL=
MAINNET_RPC_URL=
FRAX_TESTNET_RPC_URL=
MORPH_TESTNET_RPC_URL=

# for use with cast wallet. store the deployer private key in the keystore and put the public address here.
DEPLOYER_ACCOUNT_NAME=
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,28 @@ jobs:
path: '**/node_modules'
key: cached-node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install Dependencies
run: |
yarn install --frozen-lockfile
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install Dependencies
run: |
yarn install --frozen-lockfile
- name: Run Forge build
run: |
forge --version
forge build --sizes
id: build

- name: Run Forge tests
env:
CI: true
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
ARBITRUM_RPC_URL: ${{ secrets.ARBITRUM_RPC_URL }}
OPTIMISM_RPC_URL: ${{ secrets.OPTIMISM_RPC_URL }}

run: |
forge test -vvv
id: test
78 changes: 67 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,73 @@ You can find template JSON files for reference in the `script/inputs/` directory

This script will deploy all the necessary contracts across the chains specified in the JSON file, including both the Layer 1 and all Layer 2 chains.

#### Adding New Chains

If you need to add a new chain after an initial deployment, you can update the input JSON file by adding the new chain's ID to the `l2ChainIds` list and re-run the deployment command:

```bash
yarn deploy script/inputs/mainnet-ynETH.json
```

This will deploy the required contracts on the new chain and provide instructions if any manual configuration is needed on previously deployed networks to support the new chain.

The deployment script also includes a verification step to ensure that the contracts have been deployed and configured correctly across all chains.
### Adding a New L2 Chain

To add a new L2 chain to an existing deployment, follow these steps using Morph Testnet as an example:

1. Update the `BaseData.s.sol` file:
- Add the new testnet chain's ID to the `ChainIds` struct:
```solidity
struct ChainIds {
// ... existing chain IDs
uint256 morphTestnet;
}
```
- Initialize the new testnet chain ID in the `__chainIds` variable:
```solidity
__chainIds = ChainIds({
// ... existing chain IDs
morphTestnet: 2810
});
```
- Add the testnet chain-specific data to the `setUp()` function:
```solidity
__chainIdToData[__chainIds.morphTestnet] = Data({
OFT_OWNER: TEMP_GNOSIS_SAFE,
TOKEN_ADMIN: TEMP_GNOSIS_SAFE,
PROXY_ADMIN: TEMP_PROXY_CONTROLLER,
LZ_ENDPOINT: 0x1a44076050125825900e736c501f859c50fE728c,
LZ_EID: 30210 // LayerZero Endpoint ID for Morph Testnet
});
```

2. Update the deployment input JSON file for testnets (e.g., `script/inputs/holesky-ynETH.json`):
- Add the new testnet chain ID to the `l2ChainIds` array:
```json
{
"l2ChainIds": [
2522,
2810
],
// ... other existing configuration
}
```

3. Add the new testnet chain's RPC URL to the `.env` file:
```
MORPH_TESTNET_RPC_URL=https://rpc-testnet.morphl2.io
```

4. Update the `foundry.toml` file to include the new testnet RPC endpoint:
```toml
[rpc_endpoints]
morph_testnet = "${MORPH_TESTNET_RPC_URL}"
```

5. Run the deployment script for the testnet environment:
```bash
yarn deploy script/inputs/holesky-ynETH.json
```

This will deploy the necessary contracts on the new Morph Testnet chain and update the existing contracts on other testnet chains to recognize the new L2 testnet.

6. After deployment, verify that the new testnet chain has been properly added:
- Check that the L2YnOFTAdapter on Morph Testnet has the correct peers set for all other testnet chains.
- Verify that all other L2YnOFTAdapters and the L1YnOFTAdapter on testnets have been updated to include Morph Testnet as a peer.

7. Update any front-end applications or scripts to include support for the new Morph Testnet chain, such as adding it to the list of supported testnet networks and including its contract addresses.

By following these steps, you can successfully add Morph Testnet (or any other new L2 testnet chain) to your existing multi-chain testnet deployment.

### Gas Snapshots

Expand Down
2 changes: 2 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fraxtal = "${FRAX_RPC_URL}"
holesky = "${HOLESKY_RPC_URL}"
sepolia = "${SEPOLIA_RPC_URL}"
fraxtal_testnet = "${FRAX_TESTNET_RPC_URL}"
morph_testnet = "${MORPH_TESTNET_RPC_URL}"

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}" }
Expand All @@ -40,3 +41,4 @@ holesky = { key = "${ETHERSCAN_API_KEY}" }
sepolia = { key = "${ETHERSCAN_API_KEY}" }
fraxtal = { key = "${FRAXSCAN_API_KEY}", url = "https://api.fraxscan.io/api/" }
fraxtal_testnet = { key = "${FRAXSCAN_API_KEY}", url = "https://api-holesky.fraxscan.io/api/" }
morph_testnet = { key = "${MORPHSCAN_API_KEY}", url = "https://explorer-api-holesky.morphl2.io/api/" }
19 changes: 15 additions & 4 deletions script/BaseData.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ contract BaseData is Script {
uint256 holesky;
uint256 sepolia;
uint256 fraxtalTestnet;
uint256 morphTestnet;
}

mapping(uint256 => Data) private __chainIdToData;
Expand All @@ -34,7 +35,8 @@ contract BaseData is Script {
fraxtal: 252,
holesky: 17000,
sepolia: 11155111,
fraxtalTestnet: 2522
fraxtalTestnet: 2522,
morphTestnet: 2810
});

address private TEMP_GNOSIS_SAFE;
Expand Down Expand Up @@ -106,6 +108,14 @@ contract BaseData is Script {
LZ_ENDPOINT: 0x6EDCE65403992e310A62460808c4b910D972f10f,
LZ_EID: 40255
});

__chainIdToData[__chainIds.morphTestnet] = Data({
OFT_OWNER: TEMP_GNOSIS_SAFE,
TOKEN_ADMIN: TEMP_GNOSIS_SAFE,
PROXY_ADMIN: TEMP_PROXY_CONTROLLER,
LZ_ENDPOINT: 0x6C7Ab2202C98C4227C5c46f1417D81144DA716Ff,
LZ_EID: 40322
});
}

function getData(uint256 chainId) internal view returns (Data storage _data) {
Expand Down Expand Up @@ -133,11 +143,12 @@ contract BaseData is Script {
function isSupportedChainId(uint256 chainId) internal view returns (bool isSupported) {
isSupported = chainId == __chainIds.mainnet || chainId == __chainIds.base || chainId == __chainIds.fraxtal
|| chainId == __chainIds.optimism || chainId == __chainIds.arbitrum || chainId == __chainIds.holesky
|| chainId == __chainIds.fraxtalTestnet || chainId == __chainIds.sepolia;
|| chainId == __chainIds.fraxtalTestnet || chainId == __chainIds.sepolia
|| chainId == __chainIds.morphTestnet;
}

function isTestnetChainId(uint256 chainId) internal view returns (bool isTestnet) {
isTestnet =
chainId == __chainIds.holesky || chainId == __chainIds.fraxtalTestnet || chainId == __chainIds.sepolia;
isTestnet = chainId == __chainIds.holesky || chainId == __chainIds.fraxtalTestnet
|| chainId == __chainIds.sepolia || chainId == __chainIds.morphTestnet;
}
}
2 changes: 1 addition & 1 deletion script/BaseScript.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ contract BaseScript is BaseData {
Deployment public deployment;
ChainDeployment public currentDeployment;
PredictedAddresses public predictions;
string private constant _version = "v1.0.0";
string private constant _version = "v0.0.1";

function _getRateLimitConfigs() internal view returns (RateLimiter.RateLimitConfig[] memory) {
RateLimiter.RateLimitConfig[] memory rateLimitConfigs =
Expand Down
3 changes: 3 additions & 0 deletions script/BatchScript.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ abstract contract BatchScript is Script {
} else if (chainId == 2522) {
SAFE_API_BASE_URL = "";
SAFE_MULTISEND_ADDRESS = 0x998739BFdAAdde7C933B942a68053933098f9EDa;
} else if (chainId == 2810) {
SAFE_API_BASE_URL = "";
SAFE_MULTISEND_ADDRESS = 0x998739BFdAAdde7C933B942a68053933098f9EDa;
} else {
revert("Unsupported chain");
}
Expand Down
3 changes: 3 additions & 0 deletions script/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ function getRPC() {
11155111)
echo "sepolia"
;;
2810)
echo "morph_testnet"
;;
2522)
echo "fraxtal_testnet"
;;
Expand Down
3 changes: 2 additions & 1 deletion script/inputs/holesky-ynETH.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"erc20Symbol": "ynETH",
"l1ChainId": 17000,
"l2ChainIds": [
2522
2522,
2810
],
"l1ERC20Address": "0xd9029669BC74878BCB5BE58c259ed0A277C5c16E",
"rateLimitConfig": {
Expand Down

0 comments on commit 3a7fe18

Please sign in to comment.