From 538f757701e9678b641d0ddc01465150d5d89141 Mon Sep 17 00:00:00 2001 From: Carson Date: Fri, 16 Aug 2024 15:43:17 -0400 Subject: [PATCH] feat: require valid default config for LZ. Will replace this --- deployment-config/sei-eth-l1-08-08-24.json | 10 +++---- ...LayerZeroTellerWithMultiAssetSupport.s.sol | 28 ++++++++++++++++++- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/deployment-config/sei-eth-l1-08-08-24.json b/deployment-config/sei-eth-l1-08-08-24.json index 7200aa4..dffe844 100644 --- a/deployment-config/sei-eth-l1-08-08-24.json +++ b/deployment-config/sei-eth-l1-08-08-24.json @@ -2,7 +2,7 @@ "protocolAdmin": "0x0000000000417626Ef34D62C4DC189b021603f2F", "boringVault":{ - "boringVaultSalt": "0x1000000000000000000000000000000000000000000000000000000000000000", + "boringVaultSalt": "0x100000000000000000000000000000000000000000000000000000000000000a", "boringVaultName": "Sei Native Yield Nucleus Token", "boringVaultSymbol": "seiyanETH", @@ -10,13 +10,13 @@ }, "manager":{ - "managerSalt": "0x2000000000000000000000000000000000000000000000000000000000000000", + "managerSalt": "0x200000000000000000000000000000000000000000000000000000000000000a", "address": "0x0000000000000000000000000000000000000000" }, "accountant":{ - "accountantSalt": "0x3000000000000000000000000000000000000000000000000000000000000000", + "accountantSalt": "0x300000000000000000000000000000000000000000000000000000000000000a", "payoutAddress": "0x0000000000417626Ef34D62C4DC189b021603f2F", "allowedExchangeRateChangeUpper": "10030", "allowedExchangeRateChangeLower": "9980", @@ -27,7 +27,7 @@ }, "teller": { - "tellerSalt": "0x4000000000000000000000000000000000000000000000000000000000000000", + "tellerSalt": "0x400000000000000000000000000000000000000000000000000000000000000a", "maxGasForPeer": 200000, "minGasForPeer": 60000, "peerEid": 30280, @@ -43,7 +43,7 @@ "address": "0x0000000000000000000000000000000000000000" }, "rolesAuthority": { - "rolesAuthoritySalt": "0x5000000000000000000000000000000000000000000000000000000000000000", + "rolesAuthoritySalt": "0x500000000000000000000000000000000000000000000000000000000000000a", "strategist": "0x0000000000417626Ef34D62C4DC189b021603f2F", "exchangeRateBot": "0x0000000000417626Ef34D62C4DC189b021603f2F", diff --git a/script/deploy/single/05b_DeployMultiChainLayerZeroTellerWithMultiAssetSupport.s.sol b/script/deploy/single/05b_DeployMultiChainLayerZeroTellerWithMultiAssetSupport.s.sol index b1287f6..59f46f7 100644 --- a/script/deploy/single/05b_DeployMultiChainLayerZeroTellerWithMultiAssetSupport.s.sol +++ b/script/deploy/single/05b_DeployMultiChainLayerZeroTellerWithMultiAssetSupport.s.sol @@ -7,9 +7,20 @@ import { MultiChainLayerZeroTellerWithMultiAssetSupport } from import { BaseScript } from "./../../Base.s.sol"; import { stdJson as StdJson } from "@forge-std/StdJson.sol"; import { ConfigReader } from "../../ConfigReader.s.sol"; - +import {ILayerZeroEndpointV2} from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; contract DeployMultiChainLayerZeroTellerWithMultiAssetSupport is BaseScript { using StdJson for string; + address dead = 0x000000000000000000000000000000000000dEaD; + + struct UlnConfig { + uint64 confirmations; + // we store the length of required DVNs and optional DVNs instead of using DVN.length directly to save gas + uint8 requiredDVNCount; // 0 indicate DEFAULT, NIL_DVN_COUNT indicate NONE (to override the value of default) + uint8 optionalDVNCount; // 0 indicate DEFAULT, NIL_DVN_COUNT indicate NONE (to override the value of default) + uint8 optionalDVNThreshold; // (0, optionalDVNCount] + address[] requiredDVNs; // no duplicates. sorted an an ascending order. allowed overlap with optionalDVNs + address[] optionalDVNs; // no duplicates. sorted an an ascending order. allowed overlap with requiredDVNs + } function run() public returns (address teller) { return deploy(getConfig()); @@ -49,6 +60,21 @@ contract DeployMultiChainLayerZeroTellerWithMultiAssetSupport is BaseScript { ); require(address(teller.endpoint()) == config.lzEndpoint, "OP Teller must have messenger set"); + // check if the DVN is configured and print a message to the screen to inform the deployer if not. + ILayerZeroEndpointV2 endpoint = ILayerZeroEndpointV2(config.lzEndpoint); + address lib = endpoint.defaultSendLibrary(config.peerEid); + bytes memory configBytes = endpoint.getConfig(config.teller, lib, config.peerEid, 2); + UlnConfig memory ulnConfig = abi.decode(configBytes, (UlnConfig)); + + require(ulnConfig.confirmations != 0, "uln config confirmations cannot be 0"); + uint8 numRequiredDVN = ulnConfig.requiredDVNCount; + uint8 numOptionalDVN = ulnConfig.optionalDVNCount; + for(uint i; i < numRequiredDVN; ++i){ + require(ulnConfig.requiredDVNs[i] != dead, "uln config must not include dead"); + } + for(uint i; i < numRequiredDVN; ++i){ + require(ulnConfig.optionalDVNs[i] != dead, "uln config must not include dead"); + } return address(teller); } }