improve contract deployment infra for bsc and polygon t
estnet deploys
This commit is contained in:
parent
a7fb5b46e9
commit
4443138296
|
@ -0,0 +1,38 @@
|
|||
import { env, getSigner, init, loadChains, loadPrivateKey } from "../helpers/env"
|
||||
|
||||
const processName = "checkNetworks"
|
||||
|
||||
init()
|
||||
const chains = loadChains()
|
||||
const privateKey = loadPrivateKey()
|
||||
|
||||
async function main() {
|
||||
console.log(`Env: ${env}`)
|
||||
console.log(`Start ${processName}!`)
|
||||
const output: any = {
|
||||
relayProviderImplementations: [],
|
||||
relayProviderSetups: [],
|
||||
relayProviderProxies: [],
|
||||
}
|
||||
|
||||
console.log("Checking networks before deploying...")
|
||||
for (const chain of chains) {
|
||||
const signer = getSigner(chain)
|
||||
const network = await signer.provider?.getNetwork()
|
||||
const balance = await signer.getBalance()
|
||||
if (!network?.name || !balance) {
|
||||
console.log("Failed to get network for chain " + chain.chainId + ". Exiting...")
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(`Balance ${balance.toString()}`)
|
||||
console.log(`Network ${network.name} checked`)
|
||||
}
|
||||
console.log("")
|
||||
console.log("Networks checked")
|
||||
console.log("")
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
})
|
|
@ -0,0 +1,61 @@
|
|||
import { readFileSync, writeFileSync } from "fs"
|
||||
import {
|
||||
getCoreRelayer,
|
||||
getMockIntegration,
|
||||
getRelayProvider,
|
||||
init,
|
||||
loadChains,
|
||||
} from "../helpers/env"
|
||||
|
||||
const env = init({ lastRunOverride: true })
|
||||
const chains = loadChains()
|
||||
|
||||
interface Address {
|
||||
chainId: number
|
||||
address: string
|
||||
}
|
||||
interface ContractsJson {
|
||||
relayProviders: Address[]
|
||||
coreRelayers: Address[]
|
||||
mockIntegrations: Address[]
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const path = `./ts-scripts/config/${env}/contracts.json`
|
||||
const blob = readFileSync(path)
|
||||
const contracts: ContractsJson = JSON.parse(String(blob))
|
||||
console.log("Old:")
|
||||
console.log(`${String(blob)}`)
|
||||
for (const chain of chains) {
|
||||
update(contracts.relayProviders, {
|
||||
chainId: chain.chainId,
|
||||
address: getRelayProvider(chain).address,
|
||||
})
|
||||
update(contracts.coreRelayers, {
|
||||
chainId: chain.chainId,
|
||||
address: getCoreRelayer(chain).address,
|
||||
})
|
||||
update(contracts.mockIntegrations, {
|
||||
chainId: chain.chainId,
|
||||
address: getMockIntegration(chain).address,
|
||||
})
|
||||
}
|
||||
const newStr = JSON.stringify(contracts, undefined, 2)
|
||||
console.log("New:")
|
||||
console.log(`${String(newStr)}`)
|
||||
writeFileSync(path, newStr)
|
||||
}
|
||||
|
||||
function update(arr: Address[], newAddress: Address) {
|
||||
const idx = arr.findIndex((a) => a.chainId === newAddress.chainId)
|
||||
if (idx === -1) {
|
||||
arr.push(newAddress)
|
||||
} else {
|
||||
arr[idx] = newAddress
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
})
|
|
@ -18,16 +18,16 @@
|
|||
},
|
||||
{
|
||||
"description": "BSC",
|
||||
"rpc": "https://data-seed-prebsc-2-s1.binance.org:8545",
|
||||
"chainId": 4,
|
||||
"evmNetworkId": 97,
|
||||
"chainId": 4,
|
||||
"rpc": "https://bsc-testnet.public.blastapi.io",
|
||||
"wormholeAddress": "0x68605AD7b15c732a30b1BbC62BE8F2A509D74b4D"
|
||||
},
|
||||
{
|
||||
"description": "Mumbai",
|
||||
"rpc": "https://matic-mumbai.chainstacklabs.com",
|
||||
"chainId": 5,
|
||||
"evmNetworkId": 80001,
|
||||
"chainId": 5,
|
||||
"rpc": "https://matic-mumbai.chainstacklabs.com",
|
||||
"wormholeAddress": "0x0CBE91CF822c73C2315FB05100C2F714765d5c20"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -4,31 +4,55 @@
|
|||
"relayProviders": [
|
||||
{
|
||||
"chainId": 6,
|
||||
"address": "0x302f4D287204b8c383a79BA86Ad1fD1F81fb00E2"
|
||||
"address": "0xb19eBF87f3b957B6e99d8bACC994c987805C74E2"
|
||||
},
|
||||
{
|
||||
"chainId": 14,
|
||||
"address": "0x1A7d2aCBa5Ae7ad19e4DA7a512d369CC4aEFe66B"
|
||||
"address": "0xb4e6BcD5dBbD502443bb4480aA5213DfCC9F1fC8"
|
||||
},
|
||||
{
|
||||
"chainId": 4,
|
||||
"address": "0x128eE477E3DEC6b97978E7EC41a95C5cBE111c44"
|
||||
},
|
||||
{
|
||||
"chainId": 5,
|
||||
"address": "0xde609ED85F6EaaD58AA422Fd95Fea213cDA83650"
|
||||
}
|
||||
],
|
||||
"coreRelayers": [
|
||||
{
|
||||
"chainId": 6,
|
||||
"address": "0xDED10060E839c497B8D71C3091f9f24dCe4110cF"
|
||||
"address": "0x74D59cBFEBAf363769C78E2e2165503228F2b92F"
|
||||
},
|
||||
{
|
||||
"chainId": 14,
|
||||
"address": "0xDED10060E839c497B8D71C3091f9f24dCe4110cF"
|
||||
"address": "0x22baa6Ff6454C1B5f514CfE09DFDc77f44a6be56"
|
||||
},
|
||||
{
|
||||
"chainId": 4,
|
||||
"address": "0x8bCce102F34C6DbF53655958586d7Bc196dCB3c5"
|
||||
},
|
||||
{
|
||||
"chainId": 5,
|
||||
"address": "0x128eE477E3DEC6b97978E7EC41a95C5cBE111c44"
|
||||
}
|
||||
],
|
||||
"mockIntegrations": [
|
||||
{
|
||||
"chainId": 6,
|
||||
"address": "0x62C4143AB8BEe162eBF6166a679A746cAE1D1385"
|
||||
"address": "0xbFEA8140309070f0dB56c1970fc9de61970F464E"
|
||||
},
|
||||
{
|
||||
"chainId": 14,
|
||||
"address": "0xbeD6e30Ff857944931F3eF0B26EdC0B616e92d57"
|
||||
"address": "0x3Af9D81E5AE37fE3828234E3dBC06c7b2983c7fD"
|
||||
},
|
||||
{
|
||||
"chainId": 4,
|
||||
"address": "0x26Dc6Fa3a53Ab99187176e0E445065E054ca5CB3"
|
||||
},
|
||||
{
|
||||
"chainId": 5,
|
||||
"address": "0x660fF93943d6741ECc60a97D695760F13f094628"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -36,31 +36,31 @@
|
|||
"pricingInfo": [
|
||||
{
|
||||
"chainId": 6,
|
||||
"deliverGasOverhead": "350_000",
|
||||
"updatePriceGas": "30_000_000_000",
|
||||
"updatePriceNative": "100_000",
|
||||
"maximumBudget": "1_000_000_000_000_000_000"
|
||||
"deliverGasOverhead": "350000",
|
||||
"updatePriceGas": "30000000000",
|
||||
"updatePriceNative": "100000",
|
||||
"maximumBudget": "1000000000000000000"
|
||||
},
|
||||
{
|
||||
"chainId": 14,
|
||||
"deliverGasOverhead": "350_000",
|
||||
"updatePriceGas": "30_000_000_000",
|
||||
"updatePriceNative": "100_000",
|
||||
"maximumBudget": "1_000_000_000_000_000_000"
|
||||
"deliverGasOverhead": "350000",
|
||||
"updatePriceGas": "30000000000",
|
||||
"updatePriceNative": "100000",
|
||||
"maximumBudget": "1000000000000000000"
|
||||
},
|
||||
{
|
||||
"chainId": 5,
|
||||
"deliverGasOverhead": "350_000",
|
||||
"updatePriceGas": "7_322_000_000",
|
||||
"updatePriceNative": "1_000_000",
|
||||
"maximumBudget": "1_000_000_000_000_000_000"
|
||||
"deliverGasOverhead": "350000",
|
||||
"updatePriceGas": "7322000000",
|
||||
"updatePriceNative": "1000000",
|
||||
"maximumBudget": "1000000000000000000"
|
||||
},
|
||||
{
|
||||
"chainId": 4,
|
||||
"deliverGasOverhead": "350_000",
|
||||
"updatePriceGas": "600_000_000_000",
|
||||
"updatePriceNative": "1_000_000",
|
||||
"maximumBudget": "1_000_000_000_000_000_000"
|
||||
"deliverGasOverhead": "350000",
|
||||
"updatePriceGas": "600000000000",
|
||||
"updatePriceNative": "1000000",
|
||||
"maximumBudget": "1000000000000000000"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -22,18 +22,21 @@ export type Deployment = {
|
|||
address: string
|
||||
}
|
||||
|
||||
let env = ""
|
||||
export let env = ""
|
||||
let lastRunOverride: boolean | undefined
|
||||
|
||||
export function init() {
|
||||
export function init(overrides: { lastRunOverride?: boolean }): string {
|
||||
env = get_env_var("ENV")
|
||||
if (!env) {
|
||||
console.log("No environment was specified, using default environment files")
|
||||
env = "default"
|
||||
}
|
||||
lastRunOverride = overrides.lastRunOverride
|
||||
|
||||
require("dotenv").config({
|
||||
path: `./ts-scripts/.env${env != "default" ? "." + env : ""}`,
|
||||
})
|
||||
return env
|
||||
}
|
||||
|
||||
function get_env_var(env: string): string {
|
||||
|
@ -84,7 +87,7 @@ export function loadRelayProviders(): Deployment[] {
|
|||
throw Error("Failed to find contracts file for this process!")
|
||||
}
|
||||
const contracts = JSON.parse(contractsFile.toString())
|
||||
if (contracts.useLastRun) {
|
||||
if (contracts.useLastRun || lastRunOverride) {
|
||||
const lastRunFile = fs.readFileSync(
|
||||
`./ts-scripts/output/${env}/deployRelayProvider/lastrun.json`
|
||||
)
|
||||
|
@ -106,7 +109,7 @@ export function loadCoreRelayers(): Deployment[] {
|
|||
throw Error("Failed to find contracts file for this process!")
|
||||
}
|
||||
const contracts = JSON.parse(contractsFile.toString())
|
||||
if (contracts.useLastRun) {
|
||||
if (contracts.useLastRun || lastRunOverride) {
|
||||
const lastRunFile = fs.readFileSync(
|
||||
`./ts-scripts/output/${env}/deployCoreRelayer/lastrun.json`
|
||||
)
|
||||
|
@ -126,7 +129,7 @@ export function loadMockIntegrations(): Deployment[] {
|
|||
throw Error("Failed to find contracts file for this process!")
|
||||
}
|
||||
const contracts = JSON.parse(contractsFile.toString())
|
||||
if (contracts.useLastRun) {
|
||||
if (contracts.useLastRun || lastRunOverride) {
|
||||
const lastRunFile = fs.readFileSync(
|
||||
`./ts-scripts/output/${env}/deployMockIntegration/lastrun.json`
|
||||
)
|
||||
|
|
|
@ -38,7 +38,7 @@ async function configureChainsRelayProvider(chain: ChainInfo) {
|
|||
throw new Error("Failed to find approvedSenders info for chain " + chain.chainId)
|
||||
}
|
||||
|
||||
//Set address info
|
||||
console.log("Set address info...")
|
||||
await relayProvider.updateRewardAddress(thisChainsConfigInfo.rewardAddress).then(wait)
|
||||
for (let i = 0; i < thisChainsConfigInfo.approvedSenders.length; i++) {
|
||||
await relayProvider
|
||||
|
@ -50,6 +50,7 @@ async function configureChainsRelayProvider(chain: ChainInfo) {
|
|||
}
|
||||
|
||||
//TODO refactor to use the batch price update, probably
|
||||
console.log("Set gas and native prices...")
|
||||
for (let i = 0; i < chains.length; i++) {
|
||||
const targetChainPriceUpdate = config.pricingInfo.find(
|
||||
(x: any) => x.chainId == chains[i].chainId
|
||||
|
|
|
@ -3,7 +3,13 @@ import {
|
|||
deployRelayProviderProxy,
|
||||
deployRelayProviderSetup,
|
||||
} from "../helpers/deployments"
|
||||
import { init, loadChains, loadPrivateKey, writeOutputFiles } from "../helpers/env"
|
||||
import {
|
||||
getSigner,
|
||||
init,
|
||||
loadChains,
|
||||
loadPrivateKey,
|
||||
writeOutputFiles,
|
||||
} from "../helpers/env"
|
||||
|
||||
const processName = "deployRelayProvider"
|
||||
init()
|
||||
|
@ -11,7 +17,7 @@ const chains = loadChains()
|
|||
const privateKey = loadPrivateKey()
|
||||
|
||||
async function run() {
|
||||
console.log("Start!")
|
||||
console.log(`Start ${processName}!`)
|
||||
const output: any = {
|
||||
relayProviderImplementations: [],
|
||||
relayProviderSetups: [],
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
ts-node ./ts-scripts/relayProvider/deployRelayProvider.ts \
|
||||
ts-node ./ts-scripts/config/checkNetworks.ts \
|
||||
&& ts-node ./ts-scripts/relayProvider/deployRelayProvider.ts \
|
||||
&& ts-node ./ts-scripts/coreRelayer/deployCoreRelayer.ts \
|
||||
&& ts-node ./ts-scripts/relayProvider/registerChainsRelayProvider.ts \
|
||||
&& ts-node ./ts-scripts/coreRelayer/registerChainsCoreRelayerSelfSign.ts \
|
||||
|
|
Loading…
Reference in New Issue