Skip to content

Commit

Permalink
cleaning up more files removing all non hardcoded and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderLiteplo committed Sep 26, 2024
1 parent ad2af49 commit bc24175
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 455 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ In `config.json` set the following values:
"endpointV2Id": <your endpoint id for v2>,
"rpcUrl": "<your rpc url>",
"networkName": "<your network name>",
"stage": "<your network stage (mainnet, testnet, sandbox)>",
"treasuryGasLimit": <your treasury gas limit>,
"treasuryGasForFeeCap": <your treasury gas for fee cap>
```
Note: The treasury fields will be converted to 10**18 using ethers.utils.parseEther()
> Note: The treasury fields will be converted to 10**18 using ethers.utils.parseEther()
### V1 Endpoint:
cd to `v1-endpoint-deployment`
Expand Down
8 changes: 6 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"endpointV1Id": null,
"endpointV2Id": null,
"rpcUrl": null,
"rpcUrl": null,
"networkName": null,
"_comment": "Treasury fields will be converted to 10**18 using ethers.utils.parseEther()",
"_comment0": "stages can be mainnet, testnet, sandbox",
"stage": null,
"executorRoleAdmin": "0x9F403140Bc0574D7d36eA472b82DAa1Bbd4eF327",
"admins": ["0xe93685f3bBA03016F02bD1828BaDD6195988D950","0x339d413CCEfD986b1B3647A9cfa9CBbE70A30749","0x9F403140Bc0574D7d36eA472b82DAa1Bbd4eF327"],
"_comment1": "Treasury fields will be converted to 10**18 using ethers.utils.parseEther()",
"treasuryGasLimit": null,
"treasuryGasForFeeCap": null
}
4 changes: 4 additions & 0 deletions v1-endpoint-deployment/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const config: HardhatUserConfig = {
],
},
networks: {
hardhat: {
live: false,
saveDeployments: true,
},
[networkName]: {
eid: configJson.endpointV1Id,
url: configJson.rpcUrl,
Expand Down
2 changes: 1 addition & 1 deletion v2-endpoint-deployment/deploy/001-EndpointV2.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs'

import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction, Deployment } from 'hardhat-deploy/types'
import { DeployFunction } from 'hardhat-deploy/types'
import '@nomiclabs/hardhat-ethers'
import 'hardhat-deploy'

Expand Down
6 changes: 3 additions & 3 deletions v2-endpoint-deployment/deploy/001-SendUln301.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import '@nomiclabs/hardhat-ethers'
import 'hardhat-deploy'

import * as fs from 'fs'

import { HardhatRuntimeEnvironment } from 'hardhat/types'

import { EndpointVersion, Environment, networkToEnv } from '@layerzerolabs/lz-definitions'

import { getEndpointV1Address, tryGetDeployedV1Address } from './util'

import * as fs from 'fs';

module.exports = async function (hre: HardhatRuntimeEnvironment): Promise<boolean> {
module.exports = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments
const { getNamedAccounts } = hre
const { deployer } = await getNamedAccounts()
Expand Down
2 changes: 1 addition & 1 deletion v2-endpoint-deployment/deploy/003-SendUln302.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getDeployedAddress } from './util'

// config

module.exports = async function (hre: HardhatRuntimeEnvironment): Promise<boolean> {
module.exports = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments
const { getNamedAccounts } = hre
const { deployer } = await getNamedAccounts()
Expand Down
26 changes: 6 additions & 20 deletions v2-endpoint-deployment/deploy/102-DVN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,10 @@ import 'hardhat-deploy'
import '@nomiclabs/hardhat-ethers'
import { Deployment } from 'hardhat-deploy/dist/types'

import { EndpointVersion, isNetworkEndpointIdSupported, networkToStage } from '@layerzerolabs/lz-definitions'
import { EndpointVersion, isNetworkEndpointIdSupported } from '@layerzerolabs/lz-definitions'

import { supportedDVNDeployConfig } from './configs/dvn'
import { getDeployedV1Address, getUltraLightNodeV2Address } from './util'

function getConfigForSuffix(stage: string, suffix?: string) {
if (suffix === undefined) {
suffix = 'default'
}
suffix = suffix.toLowerCase()
const config = supportedDVNDeployConfig[stage][suffix]
if (typeof config === 'undefined') {
throw new Error(`No config found for Stage: ${stage} Suffix: ${suffix}`)
}
return config
}

// This is the mainnet default config
const config = {
deploymentSuffix: '',
Expand All @@ -38,11 +25,14 @@ const config = {
// default price feed
}

module.exports = async function (hre: HardhatRuntimeEnvironment): Promise<boolean> {
module.exports = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre
const { deploy } = deployments
const { verifier } = await getNamedAccounts()
const stage = networkToStage(hre.network.name)
const configFile = fs.readFileSync('../config.json', 'utf-8')
const endpointConfig = JSON.parse(configFile)
const vid = endpointConfig.endpointV1Id
const stage = endpointConfig.stage
const suffix = process.env.DVNSUFFIX

const priceFeed = getDeployedV1Address(hre, 'PriceFeed')
Expand Down Expand Up @@ -106,10 +96,6 @@ module.exports = async function (hre: HardhatRuntimeEnvironment): Promise<boolea
name = `${name}${suffix}`
}

const configFile = fs.readFileSync('../config.json', 'utf-8')
const config = JSON.parse(configFile)
const vid = config.endpointV1Id

const args = [vid, messageLibs, priceFeed, signers, quorum, admins]
console.log(
'vid, messageLibs, priceFeed, signers, quorom, admins',
Expand Down
37 changes: 9 additions & 28 deletions v2-endpoint-deployment/deploy/111-Executor.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
import fs from 'fs'

import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { Deployment } from 'hardhat-deploy/dist/types'
import invariant from 'tiny-invariant'
// import invariant from 'tiny-invariant'
import 'hardhat-deploy'
import '@nomiclabs/hardhat-ethers'

import {
EndpointVersion,
Environment,
isZKSyncBasedChain,
networkToChain,
networkToEnv,
networkToStage,
} from '@layerzerolabs/lz-definitions'

import { EXECUTOR_ADMINS, EXECUTOR_ROLE_ADMIN } from './configs/deployConfig'
import {
getDeployedAddress,
getDeployedV1Address,
getUltraLightNodeV2Address,
getUltraLightNodeV2AltTokenAddress,
} from './util'

// config
const ROLE_ADMIN = EXECUTOR_ROLE_ADMIN

const ADMINS = EXECUTOR_ADMINS

module.exports = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre
const { deploy } = deployments
Expand Down Expand Up @@ -62,23 +50,16 @@ module.exports = async function (hre: HardhatRuntimeEnvironment) {
console.log(`UltraLightNodeV2 and UltraLightNodeV2AltToken both not deployed, skip`)
}
console.log(`executor messageLibs: ${messageLibs}`)

const stage = networkToStage(hre.network.name)
let roleAdmin = ROLE_ADMIN[stage]
const admins = [...ADMINS[stage]]
// get the config from ../config.json
const config = JSON.parse(fs.readFileSync('../config.json', 'utf-8'))
const roleAdmin = config.executorRoleAdmin
const admins = config.admins
admins.push(relayerAdmin)

// for local test
if (networkToEnv(hre.network.name, EndpointVersion.V2) === Environment.LOCAL) {
const { relayerRoleAdmin } = await getNamedAccounts()
roleAdmin = relayerRoleAdmin
}
// invariant(roleAdmin, 'roleAdmin is not set')
invariant(roleAdmin, 'roleAdmin is not set')
console.log(`Executor roleAdmin: ${roleAdmin}`)

const proxyContract = isZKSyncBasedChain(networkToChain(hre.network.name))
? 'TransparentUpgradeableProxy'
: 'OptimizedTransparentProxy'
const proxyContract = 'OptimizedTransparentProxy'

console.log(`[${hre.network.name}] Executor proxyContract: ${proxyContract}`)

Expand Down
67 changes: 0 additions & 67 deletions v2-endpoint-deployment/deploy/configs/deployConfig.ts

This file was deleted.

Loading

0 comments on commit bc24175

Please sign in to comment.