Skip to content

Commit

Permalink
Move configs to ts files (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
godzillaba authored Jun 13, 2024
1 parent 3fe1734 commit 316c1bd
Show file tree
Hide file tree
Showing 19 changed files with 306 additions and 330 deletions.
5 changes: 2 additions & 3 deletions contracts/.env-sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
L1_RPC_URL="http://localhost:8545"
L1_PRIV_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
EXECUTOR="0xE6841D92B0C345144506576eC13ECf5103aC7f49" # for the upgrade test, address that can call the upgrade executor
CONFIG_LOCATION="./scripts/files/mainnetConfig.json"
DEPLOYED_CONTRACTS_LOCATION="./scripts/files/mainnetDeployedContracts.json"
CONFIG_NETWORK_NAME="arb1"
DEPLOYED_CONTRACTS_DIR="./scripts/files/"
45 changes: 20 additions & 25 deletions contracts/scripts/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { BigNumber, providers } from 'ethers'
import { parseEther } from 'ethers/lib/utils'
import fs from 'fs'

import { configs } from './files/configs'

export interface DeployedContracts {
bridge: string
seqInbox: string
Expand All @@ -26,11 +29,15 @@ export const getJsonFile = (fileLocation: string) => {
}

export const getConfig = async (
configLocation: string,
configName: string,
l1Rpc: providers.Provider
): Promise<Config> => {
const config = getJsonFile(configLocation) as RawConfig
return await validateConfig(config, l1Rpc)
const config = configs[configName as keyof typeof configs]
if (!config) {
throw new Error('config not found')
}
await validateConfig(config, l1Rpc)
return config
}

export interface Config {
Expand Down Expand Up @@ -84,9 +91,9 @@ export type RawConfig = Omit<Config, 'settings'> & {
}

export const validateConfig = async (
config: RawConfig,
config: Config,
l1Rpc: providers.Provider
): Promise<Config> => {
) => {
// check all the config.contracts exist
if ((await l1Rpc.getCode(config.contracts.l1Timelock)).length <= 2) {
throw new Error('l1Timelock address is not a contract')
Expand Down Expand Up @@ -128,25 +135,25 @@ export const validateConfig = async (
}

// check all the settings exist
if (config.settings.confirmPeriodBlocks == 0) {
if (config.settings.confirmPeriodBlocks === 0) {
throw new Error('confirmPeriodBlocks is 0')
}
if (config.settings.stakeToken.length == 0) {
if (config.settings.stakeToken.length === 0) {
throw new Error('stakeToken address is empty')
}
if (config.settings.chainId == 0) {
if (config.settings.chainId === 0) {
throw new Error('chainId is 0')
}
if (config.settings.blockLeafSize == 0) {
if (config.settings.blockLeafSize === 0) {
throw new Error('blockLeafSize is 0')
}
if (config.settings.bigStepLeafSize == 0) {
if (config.settings.bigStepLeafSize === 0) {
throw new Error('bigStepLeafSize is 0')
}
if (config.settings.smallStepLeafSize == 0) {
if (config.settings.smallStepLeafSize === 0) {
throw new Error('smallStepLeafSize is 0')
}
if (config.settings.numBigStepLevel == 0) {
if (config.settings.numBigStepLevel === 0) {
throw new Error('numBigStepLevel is 0')
}

Expand All @@ -160,20 +167,8 @@ export const validateConfig = async (
if (miniStakeAmounts.length !== config.settings.numBigStepLevel + 2) {
throw new Error('miniStakeAmts length is not numBigStepLevel + 2')
}
if (miniStakeAmounts.some((amt) => amt.lt(parseEther('0.1')))) {
throw new Error('miniStakeAmt is less than 0.1 eth')
}

if (config.validators.length == 0) {
if (config.validators.length === 0) {
throw new Error('no validators')
}

return {
...config,
settings: {
...config.settings,
stakeAmt: stakeAmount,
miniStakeAmounts,
},
}
}
62 changes: 62 additions & 0 deletions contracts/scripts/files/configs/arb1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { parseEther } from 'ethers/lib/utils'
import { Config } from '../../common'

export const arb1: Config = {
contracts: {
// the l1Timelock does not actually need to be the timelock
// it is only used to set the excess stake receiver / loser stake escrow
// TODO: change this to a fee router before real deployment
l1Timelock: '0xE6841D92B0C345144506576eC13ECf5103aC7f49',
rollup: '0x5eF0D09d1E6204141B4d37530808eD19f60FBa35',
bridge: '0x8315177aB297bA92A06054cE80a67Ed4DBd7ed3a',
sequencerInbox: '0x1c479675ad559DC151F6Ec7ed3FbF8ceE79582B6',
rollupEventInbox: '0x57Bd336d579A51938619271a7Cc137a46D0501B1',
outbox: '0x0B9857ae2D4A3DBe74ffE1d7DF045bb7F96E4840',
inbox: '0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f',
upgradeExecutor: '0x3ffFbAdAF827559da092217e474760E2b2c3CeDd',
},
proxyAdmins: {
outbox: '0x554723262467f125ac9e1cdfa9ce15cc53822dbd',
inbox: '0x554723262467f125ac9e1cdfa9ce15cc53822dbd',
bridge: '0x554723262467f125ac9e1cdfa9ce15cc53822dbd',
rei: '0x554723262467f125ac9e1cdfa9ce15cc53822dbd',
seqInbox: '0x554723262467f125ac9e1cdfa9ce15cc53822dbd',
},
settings: {
challengeGracePeriodBlocks: 14400, // 2 days
confirmPeriodBlocks: 45818, // same as old rollup, ~6.4 days
challengePeriodBlocks: 45818, // same as confirm period
stakeToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
stakeAmt: parseEther('3600'),
miniStakeAmounts: [parseEther('0'), parseEther('555'), parseEther('79')],
chainId: 42161,
anyTrustFastConfirmer: '0x0000000000000000000000000000000000000000',
disableValidatorWhitelist: true,
blockLeafSize: 1048576, // todo below
bigStepLeafSize: 512,
smallStepLeafSize: 128,
numBigStepLevel: 1,
maxDataSize: 117964,
isDelayBufferable: true,
bufferConfig: {
max: 14400,
threshold: 300,
replenishRateInBasis: 500,
},
},
validators: [
'0x0ff813f6bd577c3d1cdbe435bac0621be6ae34b4',
'0x54c0d3d6c101580db3be8763a2ae2c6bb9dc840c',
'0x56d83349c2b8dcf74d7e92d5b6b33d0badd52d78',
'0x610aa279989f440820e14248bd3879b148717974',
'0x6fb914de4653ec5592b7c15f4d9466cbd03f2104',
'0x758c6bb08b3ea5889b5cddbdef9a45b3a983c398',
'0x7cf3d537733f6ba4183a833c9b021265716ce9d0',
'0x83215480db2c6a7e56f9e99ef93ab9b36f8a3dd5',
'0xab1a39332e934300ebcc57b5f95ca90631a347ff',
'0xb0cb1384e3f4a9a9b2447e39b05e10631e1d34b0',
'0xddf2f71ab206c0138a8eceeb54386567d5abf01e',
'0xf59caf75e8a4bfba4e6e07ad86c7e498e4d2519b',
'0xf8d3e1cf58386c92b27710c6a0d8a54c76bc6ab5',
],
}
11 changes: 11 additions & 0 deletions contracts/scripts/files/configs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { arb1 } from './arb1'
import { nova } from './nova'
import { sepolia } from './sepolia'
import { local } from './local'

export const configs = {
arb1,
nova,
sepolia,
local,
}
52 changes: 52 additions & 0 deletions contracts/scripts/files/configs/local.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { parseEther } from 'ethers/lib/utils'
import { Config } from '../../common'

export const local: Config = {
contracts: {
bridge: '0x5eCF728ffC5C5E802091875f96281B5aeECf6C49',
inbox: '0x9f8c1c641336A371031499e3c362e40d58d0f254',
outbox: '0x50143333b44Ea46255BEb67255C9Afd35551072F',
rollup: '0xC3124dD1FA0e5D6135c25279760DBF9d9286467B',
sequencerInbox: '0x18d19C5d3E685f5be5b9C86E097f0E439285D216',
rollupEventInbox: '0x0e73faf857e1ca53e700856fcf19f31f920a1e3c',
upgradeExecutor: '0x513d9f96d4d0563debae8a0dc307ea0e46b10ed7',
l1Timelock: '0xC3124dD1FA0e5D6135c25279760DBF9d9286467B',
},
proxyAdmins: {
outbox: '0x2a1f38c9097e7883570e0b02bfbe6869cc25d8a3',
inbox: '0x2a1f38c9097e7883570e0b02bfbe6869cc25d8a3',
bridge: '0x2a1f38c9097e7883570e0b02bfbe6869cc25d8a3',
rei: '0x2a1f38c9097e7883570e0b02bfbe6869cc25d8a3',
seqInbox: '0x2a1f38c9097e7883570e0b02bfbe6869cc25d8a3',
},
settings: {
challengeGracePeriodBlocks: 10,
confirmPeriodBlocks: 100,
challengePeriodBlocks: 110,
stakeToken: '0x408Da76E87511429485C32E4Ad647DD14823Fdc4',
stakeAmt: parseEther('1'),
miniStakeAmounts: [
parseEther('6'),
parseEther('5'),
parseEther('4'),
parseEther('3'),
parseEther('2'),
parseEther('1'),
],
chainId: 412346,
anyTrustFastConfirmer: '0x6d903f6003cca6255D85CcA4D3B5E5146dC33925',
disableValidatorWhitelist: true,
blockLeafSize: 1048576,
bigStepLeafSize: 512,
smallStepLeafSize: 128,
numBigStepLevel: 4,
maxDataSize: 117964,
isDelayBufferable: true,
bufferConfig: {
max: 14400,
threshold: 300,
replenishRateInBasis: 500,
},
},
validators: ['0xf10EF80c6eF4930A62C5F9661c91339Df4dBB173'],
}
56 changes: 56 additions & 0 deletions contracts/scripts/files/configs/nova.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { parseEther } from 'ethers/lib/utils'
import { Config } from '../../common'

export const nova: Config = {
contracts: {
l1Timelock: '0xE6841D92B0C345144506576eC13ECf5103aC7f49',
rollup: '0xFb209827c58283535b744575e11953DCC4bEAD88',
bridge: '0xC1Ebd02f738644983b6C4B2d440b8e77DdE276Bd',
sequencerInbox: '0x211E1c4c7f1bF5351Ac850Ed10FD68CFfCF6c21b',
rollupEventInbox: '0x304807A7ed6c1296df2128E6ff3836e477329CD2',
outbox: '0xD4B80C3D7240325D18E645B49e6535A3Bf95cc58',
inbox: '0xc4448b71118c9071Bcb9734A0EAc55D18A153949',
upgradeExecutor: '0x3ffFbAdAF827559da092217e474760E2b2c3CeDd',
},
proxyAdmins: {
outbox: '0x71d78dc7ccc0e037e12de1e50f5470903ce37148',
inbox: '0x71d78dc7ccc0e037e12de1e50f5470903ce37148',
bridge: '0x71d78dc7ccc0e037e12de1e50f5470903ce37148',
rei: '0x71d78dc7ccc0e037e12de1e50f5470903ce37148',
seqInbox: '0x71d78dc7ccc0e037e12de1e50f5470903ce37148',
},
settings: {
challengeGracePeriodBlocks: 14400,
confirmPeriodBlocks: 50400,
challengePeriodBlocks: 51600,
stakeToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
stakeAmt: parseEther('1'),
miniStakeAmounts: [
parseEther('6'),
parseEther('5'),
parseEther('4'),
parseEther('3'),
parseEther('2'),
parseEther('1'),
],
chainId: 42161,
anyTrustFastConfirmer: '0x0000000000000000000000000000000000000000',
disableValidatorWhitelist: false,
blockLeafSize: 1048576,
bigStepLeafSize: 512,
smallStepLeafSize: 128,
numBigStepLevel: 4,
maxDataSize: 117964,
isDelayBufferable: true,
bufferConfig: {
max: 14400,
threshold: 300,
replenishRateInBasis: 500,
},
},
validators: [
'0xE27d4Ed355e5273A3D4855c8e11BC4a8d3e39b87',
'0x57004b440Cc4eb2FEd8c4d1865FaC907F9150C76',
'0x24ca61c31c7f9af3ab104db6b9a444f28e9071e3',
],
}
56 changes: 56 additions & 0 deletions contracts/scripts/files/configs/sepolia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { parseEther } from 'ethers/lib/utils'
import { Config } from '../../common'

export const sepolia: Config = {
contracts: {
l1Timelock: '0x6EC62D826aDc24AeA360be9cF2647c42b9Cdb19b',
rollup: '0xd80810638dbDF9081b72C1B33c65375e807281C8',
bridge: '0x38f918D0E9F1b721EDaA41302E399fa1B79333a9',
sequencerInbox: '0x6c97864CE4bEf387dE0b3310A44230f7E3F1be0D',
rollupEventInbox: '0xD5B196dd7EC4D823ff5F695536c61f7c8E642B94',
outbox: '0x65f07C7D521164a4d5DaC6eB8Fac8DA067A3B78F',
inbox: '0xaAe29B0366299461418F5324a79Afc425BE5ae21',
upgradeExecutor: '0x5FEe78FE9AD96c1d8557C6D6BB22Eb5A61eeD315',
},
proxyAdmins: {
outbox: '0xdd63bcaa89d7c3199ef220c1dd59c49f821078b8',
inbox: '0xdd63bcaa89d7c3199ef220c1dd59c49f821078b8',
bridge: '0xdd63bcaa89d7c3199ef220c1dd59c49f821078b8',
rei: '0xdd63bcaa89d7c3199ef220c1dd59c49f821078b8',
seqInbox: '0xdd63bcaa89d7c3199ef220c1dd59c49f821078b8',
},
settings: {
challengeGracePeriodBlocks: 14400,
confirmPeriodBlocks: 50400,
challengePeriodBlocks: 51600,
stakeToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
stakeAmt: parseEther('1'),
miniStakeAmounts: [
parseEther('6'),
parseEther('5'),
parseEther('4'),
parseEther('3'),
parseEther('2'),
parseEther('1'),
],
chainId: 42161,
anyTrustFastConfirmer: '0x0000000000000000000000000000000000000000',
disableValidatorWhitelist: false,
blockLeafSize: 1048576,
bigStepLeafSize: 512,
smallStepLeafSize: 128,
numBigStepLevel: 4,
maxDataSize: 117964,
isDelayBufferable: true,
bufferConfig: {
max: 14400,
threshold: 300,
replenishRateInBasis: 500,
},
},
validators: [
'0x8a8f0a24d7e58a76FC8F77bb68C7c902b91e182e',
'0x87630025E63A30eCf9Ca9d580d9D95922Fea6aF0',
'0xC32B93e581db6EBc50C08ce381143A259B92f1ED',
],
}
51 changes: 0 additions & 51 deletions contracts/scripts/files/localConfig.json

This file was deleted.

Loading

0 comments on commit 316c1bd

Please sign in to comment.