Skip to content

Commit

Permalink
feat: require valid default config for LZ. Will replace this
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonCase committed Aug 16, 2024
1 parent 122666b commit 538f757
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
10 changes: 5 additions & 5 deletions deployment-config/sei-eth-l1-08-08-24.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"protocolAdmin": "0x0000000000417626Ef34D62C4DC189b021603f2F",

"boringVault":{
"boringVaultSalt": "0x1000000000000000000000000000000000000000000000000000000000000000",
"boringVaultSalt": "0x100000000000000000000000000000000000000000000000000000000000000a",
"boringVaultName": "Sei Native Yield Nucleus Token",
"boringVaultSymbol": "seiyanETH",

"address": "0x0000000000000000000000000000000000000000"
},

"manager":{
"managerSalt": "0x2000000000000000000000000000000000000000000000000000000000000000",
"managerSalt": "0x200000000000000000000000000000000000000000000000000000000000000a",

"address": "0x0000000000000000000000000000000000000000"
},

"accountant":{
"accountantSalt": "0x3000000000000000000000000000000000000000000000000000000000000000",
"accountantSalt": "0x300000000000000000000000000000000000000000000000000000000000000a",
"payoutAddress": "0x0000000000417626Ef34D62C4DC189b021603f2F",
"allowedExchangeRateChangeUpper": "10030",
"allowedExchangeRateChangeLower": "9980",
Expand All @@ -27,7 +27,7 @@
},

"teller": {
"tellerSalt": "0x4000000000000000000000000000000000000000000000000000000000000000",
"tellerSalt": "0x400000000000000000000000000000000000000000000000000000000000000a",
"maxGasForPeer": 200000,
"minGasForPeer": 60000,
"peerEid": 30280,
Expand All @@ -43,7 +43,7 @@
"address": "0x0000000000000000000000000000000000000000"
},
"rolesAuthority": {
"rolesAuthoritySalt": "0x5000000000000000000000000000000000000000000000000000000000000000",
"rolesAuthoritySalt": "0x500000000000000000000000000000000000000000000000000000000000000a",
"strategist": "0x0000000000417626Ef34D62C4DC189b021603f2F",
"exchangeRateBot": "0x0000000000417626Ef34D62C4DC189b021603f2F",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 538f757

Please sign in to comment.