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

DVN script added to LZ deployment #14

Merged
merged 71 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
538f757
feat: require valid default config for LZ. Will replace this
CarsonCase Aug 16, 2024
41aaf28
feat: instead of error, configures DVN on lack of default with hardco…
CarsonCase Aug 16, 2024
3f70262
feat: config files for dvm
CarsonCase Aug 19, 2024
b418923
feat: added helper script for send1weicrosschain
CarsonCase Aug 19, 2024
ec38591
fix: proompt for use of default
CarsonCase Aug 19, 2024
38820a6
fix: leftPaddedBytes32 for peer with check
CarsonCase Aug 20, 2024
5898682
refactor: dead address constant
CarsonCase Aug 20, 2024
41dabdb
feat: new lzConfigCheck.cjs file
CarsonCase Aug 21, 2024
d08740b
refactor: cleanup and added script to package.json
CarsonCase Aug 21, 2024
e370738
feat: generic rate provider test and deployment for swBTC
junkim012 Aug 22, 2024
8fcbdd6
Merge branch 'master' into jun/rswBTC
junkim012 Aug 22, 2024
1150638
feat: deployment script for generic rate provider
junkim012 Aug 22, 2024
32b51d6
chore: rswBTC deployment config
junkim012 Aug 22, 2024
b8036ab
chore: fix spelling error and remove base from chain specific config …
junkim012 Aug 22, 2024
dcc199e
fix: do not hardcode boring vault decimals
junkim012 Aug 22, 2024
9ccf8e9
refactor: nucleus vault and removed convinence script
CarsonCase Aug 22, 2024
75486a1
feat: incrementSalt.cjs
CarsonCase Aug 22, 2024
730e53d
feat: optional --sig run(string memory) configFile deployment script …
CarsonCase Aug 22, 2024
5d9f961
removed old live tests
CarsonCase Aug 22, 2024
8eddf81
fix: bug in deployment script
CarsonCase Aug 22, 2024
29b9d21
refactor: fmt
CarsonCase Aug 22, 2024
d5e989b
Merge branch 'carson/dvm-script' into carson/deploy-testing
CarsonCase Aug 22, 2024
4bcbf6a
test: beginings of live tests. Passing
CarsonCase Aug 23, 2024
9bec840
test: included bulk withdrawal in test
CarsonCase Aug 23, 2024
7cf84b0
test: passing test for rate change
CarsonCase Aug 26, 2024
dba7e36
test: including rate change for non-base assets
CarsonCase Aug 27, 2024
1fa6eba
feat: makefile for checkL1 and checkL2
CarsonCase Aug 27, 2024
906e20e
test: LiveDeploy complete, working on RateMath
CarsonCase Aug 29, 2024
d6304bb
fix: live test now works with default
CarsonCase Aug 29, 2024
1dc1123
fix: removed testMath in teller test
CarsonCase Aug 29, 2024
a33b2f8
test: refactoring tests according to PR comments
CarsonCase Aug 29, 2024
1df9d53
chore: renamed math test file
CarsonCase Aug 29, 2024
6f1b314
chore: removed .working file and moved it to another branch
CarsonCase Aug 29, 2024
8b31ff5
fix: import error
CarsonCase Aug 29, 2024
37153f6
test: Work In Progress, for team to see
CarsonCase Aug 29, 2024
4bb9320
test: ERC20 check
CarsonCase Aug 30, 2024
34eb07b
chore: chain config sepolia
CarsonCase Aug 30, 2024
5bc1215
refactor: ready for deployment, awaiting form confirmation
CarsonCase Aug 30, 2024
770d84a
test: prep for rate apxETH rate provider and test
CarsonCase Aug 30, 2024
9ffceab
test: jamie wbtc scenario
CarsonCase Aug 30, 2024
1954e86
test: jamie btc scenario changes
CarsonCase Aug 30, 2024
cbe0b2e
build: form deployment on sepolia
CarsonCase Sep 1, 2024
aa5da38
example changed
CarsonCase Sep 1, 2024
3d9635b
test: rate math
CarsonCase Sep 5, 2024
799dbdd
refactor: comment to clarify why CREATEX is different
CarsonCase Sep 5, 2024
2ed232c
refactor: no assets in example
CarsonCase Sep 5, 2024
0364552
refactor: codespell
CarsonCase Sep 6, 2024
fcdf25d
refactor: removed the unused ignoreExisting flag for rate provider de…
CarsonCase Sep 6, 2024
fad49b2
refactor: moved CREATEX to env
CarsonCase Sep 6, 2024
b30e95e
refactor: moved deploy createx expected to env
CarsonCase Sep 6, 2024
84fe201
refactor: args check in lzConfigCheck
CarsonCase Sep 6, 2024
bca4f72
refactor: spell error
CarsonCase Sep 6, 2024
fcb8dd1
refactor: spell error, unsaved file
CarsonCase Sep 6, 2024
f0c86ff
fix: makefile fix
CarsonCase Sep 6, 2024
882e6c3
fix: innacurate chain config data
CarsonCase Sep 6, 2024
b3bdef2
chore: scripts moved to makefile
CarsonCase Sep 6, 2024
c15a117
test: generic rate provider require has asserts
CarsonCase Sep 6, 2024
4b3daa7
test: fuzz erc20
CarsonCase Sep 6, 2024
ec346bb
fix: typo
CarsonCase Sep 6, 2024
d0580a3
Merge pull request #18 from Ion-Protocol/carson/decimal-testing
CarsonCase Sep 6, 2024
884446f
Merge pull request #17 from Ion-Protocol/carson/deploy-testing
CarsonCase Sep 6, 2024
4f54ce6
merge resolution
CarsonCase Sep 6, 2024
330d94f
Merge pull request #20 from Ion-Protocol/carson/form-deployment
CarsonCase Sep 6, 2024
49b5948
resolved merge confligts
CarsonCase Sep 6, 2024
9fc4d5f
merge conflicts on remote resolved
CarsonCase Sep 6, 2024
2e95188
chore: gitignore .vscode file
CarsonCase Sep 8, 2024
687ec62
Delete .vscode directory
CarsonCase Sep 8, 2024
ebf971f
chore: removed package json script tags
CarsonCase Sep 8, 2024
8472ff6
Merge branch 'carson/dvm-script' of github.com:Ion-Protocol/nucleus-b…
CarsonCase Sep 8, 2024
6a1f729
fix: package.json formatting
CarsonCase Sep 8, 2024
fa306d0
chore: new fmt
CarsonCase Sep 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,23 @@
"tellerSalt": "0x51f8968749a56d01202c9100000000000000000000000000000000000000000a",
"maxGasForPeer": 100000,
"minGasForPeer": 0,
"peerEid": 0,
"peerEid": 30280,
"tellerContractName": "MultiChainLayerZeroTellerWithMultiAssetSupport",
"assets": [
"0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
"0xbf5495Efe5DB9ce00f80364C8B423567e58d2110"
],
"dvnIfNoDefault":{
"required":["0x589dEDbD617e0CBcB916A9223F4d1300c294236b"],
"optional":[
"0x380275805876Ff19055EA900CDb2B46a94ecF20D",
"0x8FafAE7Dd957044088b3d0F67359C327c6200d18",
"0xa59BA433ac34D2927232918Ef5B2eaAfcF130BA5",
"0xe552485d02EDd3067FE7FCbD4dd56BB1D3A998D2"
],
"blockConfirmationsRequiredIfNoDefault": 15,
"optionalThreshold": 1
},

"address": "0x00000000004F96C07B83e86600D86F0000000000"
},
Expand Down
67 changes: 67 additions & 0 deletions deployment-config/exampleL2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"protocolAdmin": "0xF2dE1311C5b2C1BD94de996DA13F80010453e505",

"boringVault":{
"boringVaultSalt": "0x1ddd634c506ad203da17ff00000000000000000000000000000000000000000a",
"boringVaultName": "Ion Vault L2",
"boringVaultSymbol": "IVT",

"address": "0x0000000000E7Ab44153eEBEF2343ba5289F65dAC"
},

"manager":{
"managerSalt": "0x30432d4b4ec00003b4a25000000000000000000000000000000000000000000a",

"address": "0x0000000000fAd6Db23abdC1a85621B97bd1Dc82f"
},

"accountant":{
"accountantSalt": "0x6a184dbea6f3cc0318679f00000000000000000000000000000000000000000a",
"payoutAddress": "0x0000000000417626Ef34D62C4DC189b021603f2F",
"base": "0x5f207d42F869fd1c71d7f0f81a2A67Fc20FF7323",
"allowedExchangeRateChangeUpper": "10003",
"allowedExchangeRateChangeLower": "9998",
"minimumUpdateDelayInSeconds": "3600",
"managementFee": "2000",

"address": "0x00000000004F96C07B83e86600D86F9479bB43fa"
},

"teller": {
"tellerSalt": "0x51f8968749a56d01202c9100000000000000000000000000000000000000000a",
"maxGasForPeer": 100000,
"minGasForPeer": 0,
"peerEid": 30280,
"tellerContractName": "MultiChainLayerZeroTellerWithMultiAssetSupport",
"assets": [
],
"dvnIfNoDefault":{
"required":["0x6788f52439aca6bff597d3eec2dc9a44b8fee842"],
"optional":[
"0x1feb08b1a53a9710afce82d380b8c2833c69a37e",
"0x87048402c32632b7c4d0a892d82bc1160e8b2393",
"0xd24972c11f91c1bb9eaee97ec96bb9c33cf7af24",
"0xbd00c87850416db0995ef8030b104f875e1bdd15"
],
"blockConfirmationsRequiredIfNoDefault": 15,
"optionalThreshold": 1
},

"address": "0x00000000004F96C07B83e86600D86F0000000000"
},

"rolesAuthority": {
"rolesAuthoritySalt": "0x66bbc3b3b3000b01466a3a00000000000000000000000000000000000000000a",
"strategist": "0xC2d99d76bb9D46BF8Ec9449E4DfAE48C30CF0839",
"exchangeRateBot": "0x00000000004F96C07B83e86600D86F0000000000",

"address": "0x00000000004F96C07B83e86600D86F0000000000"
},

"decoder": {
"decoderSalt": "0x48b53893da2e0b0248268c00000000000000000000000000000000000000000a",

"address": "0x00000000004F96C07B83e86600D86F0000000000"
}

}
725 changes: 725 additions & 0 deletions deployment-config/layerzero/dvn-deployments.json

Large diffs are not rendered by default.

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
126 changes: 126 additions & 0 deletions lzConfigCheck.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
const fs = require('fs');
const readline = require('readline');

// Function to load the DVN JSON data
function loadDvns() {
const data = fs.readFileSync('./deployment-config/layerzero/dvn-deployments.json', 'utf8');
return JSON.parse(data);
}

// Function to find an address in the JSON data
function findAddressInJson(addresses, jsonData, searchKey = "") {
const results = [];
const lowerCaseAddresses = addresses.map(a => a.toLowerCase());

for (const [parentKey, parentValue] of Object.entries(jsonData)) {
for (const [key, value] of Object.entries(parentValue)) {
if (lowerCaseAddresses.includes(value.toLowerCase())) {
results.push([parentKey, key, value]);
}
}
}

if (searchKey === "") {
if (results.length === 1) {
const [parentKey, key, value] = results[0];
return [true, key, parentKey];
} else {
return [false, null, null];
}
} else {
for (const [parentKey, key, value] of results) {
if (key === searchKey) {
return [true, key, parentKey];
}
}
return [false, null, null];
}
}

// Function to get findings from a config file
function getFindingsInConfig(configName) {
const dvnJsonData = loadDvns();
const data = fs.readFileSync(`./deployment-config/${configName}`, 'utf8');
const configJsonData = JSON.parse(data);

const required = configJsonData.teller.dvnIfNoDefault.required;
const optional = configJsonData.teller.dvnIfNoDefault.optional;
const addresses = [...required, ...optional];

let chain = "";
for (const address of addresses) {
const [found, key, parentKey] = findAddressInJson([address], dvnJsonData);
if (found) {
chain = key;
break;
}
}

if (chain === "") {
throw new Error("❌ All provided configs have duplicates or are not found in the DVN registry");
}

const findings = [];
for (const address of addresses) {
const [found, key, parentKey] = findAddressInJson([address], dvnJsonData, chain);
if (found) {
findings.push({ address, chain: key, provider: parentKey });
} else {
console.log("Not Found ", address);
}
}

return {
findings,
requiredCount: required.length,
optionalCount: optional.length,
confirmations: configJsonData.teller.dvnIfNoDefault.blockConfirmationsRequiredIfNoDefault,
threshold: configJsonData.teller.dvnIfNoDefault.optionalThreshold
};
}

function assert(statement, message){
if(!statement){
throw new Error("❌ "+message)
}
}

// Main function
async function main() {
const args = process.argv.slice(2);

if (args.length < 2) {
CarsonCase marked this conversation as resolved.
Show resolved Hide resolved
console.error("Usage: node script.js <file1Name> <file2Name>");
process.exit(1);
}

const [file1Name, file2Name] = args;

try {
const findings1 = getFindingsInConfig(file1Name);
const findings2 = getFindingsInConfig(file2Name);

assert(findings1.confirmations == findings2.confirmations, "Confirmations do not match");
assert(findings1.threshold == findings2.threshold, "thresholds do not match");
assert(findings1.requiredCount == findings2.requiredCount, "required DVNs count does not match");
assert(findings1.optionalCount == findings2.optionalCount, "optional DVNs count does not match");

const chain1 = findings1.findings[0].chain;
const providers1 = findings1.findings.map(finding => finding.provider);
for (const finding of findings1.findings) {
assert(finding.chain == chain1, "Networks do not match for "+finding)
}

const chain2 = findings2.findings[0].chain;
for (const finding of findings2.findings) {
assert(providers1.includes(finding.provider), "Provider: "+finding.provider+" does not havea matching provider in the first config");
assert(finding.chain == chain2, "Networks do not match for: "+finding);
}

console.log("✅ Config check passed");
} catch (error) {
console.error(error.message);
}
}

main();
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"deploy-createx-l1": "forge script script/DeployCustomCreatex.s.sol --rpc-url $L1_RPC_URL --private-key $PRIVATE_KEY --slow",
"deploy-createx-l2": "forge script script/DeployCustomCreatex.s.sol --rpc-url $L2_RPC_URL --private-key $PRIVATE_KEY --slow",
"deploy-l1": "forge script script/deploy/deployAll.s.sol -f $L1_RPC_URL --private-key=$PRIVATE_KEY --slow",
"deploy-l2": "forge script script/deploy/deployAll.s.sol -f $L2_RPC_URL --private-key=$PRIVATE_KEY --slow"
"deploy-l2": "forge script script/deploy/deployAll.s.sol -f $L2_RPC_URL --private-key=$PRIVATE_KEY --slow",
"check-configs": "bun lzConfigCheck.cjs"
},
"devDependencies": {
"@layerzerolabs/lz-definitions": "^2.3.25",
Expand Down
4 changes: 4 additions & 0 deletions script/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,8 @@ abstract contract BaseScript is Script {
path = string.concat(CONFIG_PATH_ROOT, vm.prompt("Please Enter The Deployments Configuration File Name: "));
return vm.readFile(path);
}

function compareStrings(string memory a, string memory b) internal returns (bool) {
return (keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b)));
}
}
10 changes: 10 additions & 0 deletions script/ConfigReader.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ library ConfigReader {
address balancerVault;
bytes32 tellerSalt;
uint32 peerEid;
address[] requiredDvns;
address[] optionalDvns;
uint64 dvnBlockConfirmationsRequired;
uint8 optionalDvnThreshold;
address accountant;
address opMessenger;
uint64 maxGasForPeer;
Expand Down Expand Up @@ -83,6 +87,12 @@ library ConfigReader {
config.assets = _config.readAddressArray(".teller.assets");
config.peerEid = uint32(_config.readUint(".teller.peerEid"));

config.requiredDvns = _config.readAddressArray(".teller.dvnIfNoDefault.required");
config.optionalDvns = _config.readAddressArray(".teller.dvnIfNoDefault.optional");
config.dvnBlockConfirmationsRequired =
uint64(_config.readUint(".teller.dvnIfNoDefault.blockConfirmationsRequiredIfNoDefault"));
config.optionalDvnThreshold = uint8(_config.readUint(".teller.dvnIfNoDefault.optionalThreshold"));

// Reading from the 'rolesAuthority' section
config.rolesAuthority = _config.readAddress(".rolesAuthority.address");
config.rolesAuthoritySalt = _config.readBytes32(".rolesAuthority.rolesAuthoritySalt");
Expand Down
82 changes: 82 additions & 0 deletions script/Send1WeiAccrossChain.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import { MainnetAddresses } from "test/resources/MainnetAddresses.sol";
import { BoringVault } from "src/base/BoringVault.sol";
import { ManagerWithMerkleVerification } from "src/base/Roles/ManagerWithMerkleVerification.sol";
import { SafeTransferLib } from "@solmate/utils/SafeTransferLib.sol";
import { FixedPointMathLib } from "@solmate/utils/FixedPointMathLib.sol";
import { ERC20 } from "@solmate/tokens/ERC20.sol";
import { BalancerVault } from "src/interfaces/BalancerVault.sol";
import { EtherFiLiquidDecoderAndSanitizer } from "src/base/DecodersAndSanitizers/EtherFiLiquidDecoderAndSanitizer.sol";
import { RolesAuthority, Authority } from "@solmate/auth/authorities/RolesAuthority.sol";
import { TellerWithMultiAssetSupport } from "src/base/Roles/TellerWithMultiAssetSupport.sol";
import { MultiChainLayerZeroTellerWithMultiAssetSupport } from
"src/base/Roles/CrossChain/MultiChainLayerZeroTellerWithMultiAssetSupport.sol";
import { AccountantWithRateProviders } from "src/base/Roles/AccountantWithRateProviders.sol";
import { CrossChainTellerBase } from "src/base/Roles/CrossChain/CrossChainTellerBase.sol";
import { BridgeData } from "src/base/Roles/CrossChain/CrossChainTellerBase.sol";
import { ILayerZeroEndpointV2 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
import { SetConfigParam } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLibManager.sol";
import "@forge-std/Script.sol";
import "@forge-std/StdJson.sol";
import { console2 } from "forge-std/console2.sol";
import { Test, stdStorage, StdStorage, stdError, console } from "@forge-std/Test.sol";

interface IWETH {
function deposit() external payable;
function approve(address, uint256) external;
}

/**
* source .env && forge script script/DeployTestBoringVault.s.sol:DeployTestBoringVaultScript --with-gas-price
* 30000000000 --slow --broadcast --etherscan-api-key $ETHERSCAN_KEY --verify
* @dev Optionally can change --with-gas-price to something more reasonable
*/
contract TestScript is Script {
uint256 public privateKey;
address broadcaster;

CrossChainTellerBase teller;

function setUp() external {
privateKey = vm.envUint("PRIVATE_KEY");
broadcaster = vm.addr(privateKey);
}

function run() external {
vm.startBroadcast(privateKey);

ERC20 NATIVE = ERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
ERC20 WETH = ERC20(0xFC00000000000000000000000000000000000006);
// ERC20 WETH = ERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
// ERC20 WETH = ERC20(0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000);
address BORING_VAULT = 0x647Ea8b492832e9D99A06DE8cc9A05e58FcCdF02;
address TELLER = 0xD9395622c8Ec792D1cb6F39B562095fDa240BA57;

teller = CrossChainTellerBase(TELLER);

require(teller.isSupported(WETH), "asset not supported");

// WETH.approve(BORING_VAULT, 1 ether);
// payable(address(WETH)).call{value: 1}("");
// require(WETH.balanceOf(broadcaster) > 1, "No WETH");

// teller.deposit(WETH, 1000000000, 1000000000);
BridgeData memory data = BridgeData({
chainSelector: 30_101,
destinationChainReceiver: broadcaster,
bridgeFeeToken: NATIVE,
messageGas: 100_000,
data: ""
});

uint256 fee = teller.previewFee(1, data);

// teller.depositAndBridge{ value: fee }(WETH, 1, 1, data);
teller.bridge{ value: fee }(1, data);
// boring_vault = new BoringVault(owner, "Test Boring Vault", "BV", 18);

// manager = new ManagerWithMerkleVerification(owner, address(boring_vault), balancerVault);
}
}
4 changes: 0 additions & 4 deletions script/deploy/deployAll.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,4 @@ contract DeployAll is BaseScript {
revert INVALID_TELLER_CONTRACT_NAME();
}
}

function compareStrings(string memory a, string memory b) private returns (bool) {
return (keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b)));
}
}
Loading