diff --git a/examples/prepare-node-config/.env.example b/examples/prepare-node-config/.env.example index ea6610a4..fe165a63 100644 --- a/examples/prepare-node-config/.env.example +++ b/examples/prepare-node-config/.env.example @@ -7,4 +7,7 @@ VALIDATOR_PRIVATE_KEY= ETHEREUM_BEACON_RPC_URL= # (Optional) Infura RPC endpoint for the parent chain (Arbitrum Sepolia), if not provided, the script might fail with timeout -PARENT_CHAIN_RPC=https://arbitrum-sepolia.infura.io/v3/YOUR_API_KEY \ No newline at end of file +PARENT_CHAIN_RPC=https://arbitrum-sepolia.infura.io/v3/YOUR_API_KEY + +# (Optional) Name for the Orbit chain, if not provided, defaults to 'My Orbit Chain' +CHAIN_NAME= \ No newline at end of file diff --git a/examples/prepare-node-config/index.ts b/examples/prepare-node-config/index.ts index abbb6bcb..d615390a 100644 --- a/examples/prepare-node-config/index.ts +++ b/examples/prepare-node-config/index.ts @@ -1,9 +1,12 @@ import { writeFile } from 'fs/promises'; import { Chain, createPublicClient, http } from 'viem'; import { arbitrumSepolia } from 'viem/chains'; +import { privateKeyToAccount } from 'viem/accounts'; +import { sanitizePrivateKey } from '@arbitrum/orbit-sdk/utils'; import { ChainConfig, PrepareNodeConfigParams, + OrbitSetupScriptConfigParams, createRollupPrepareTransaction, createRollupPrepareTransactionReceipt, prepareNodeConfig, @@ -69,15 +72,45 @@ async function main() { // get the core contracts from the transaction receipt const coreContracts = txReceipt.getCoreContracts(); + const chainName = process.env.CHAIN_NAME ?? 'My Orbit Chain'; + const parentChainRpc = process.env.PARENT_CHAIN_RPC ?? getRpcUrl(parentChain); + // prepare the node config const nodeConfigParameters: PrepareNodeConfigParams = { - chainName: 'My Orbit Chain', + chainName, chainConfig, coreContracts, batchPosterPrivateKey: process.env.BATCH_POSTER_PRIVATE_KEY as `0x${string}`, validatorPrivateKey: process.env.VALIDATOR_PRIVATE_KEY as `0x${string}`, parentChainId: parentChain.id, - parentChainRpcUrl: getRpcUrl(parentChain), + parentChainRpcUrl: parentChainRpc, + }; + + const orbitSetupScriptConfigParams: OrbitSetupScriptConfigParams = { + networkFeeReceiver: chainConfig.arbitrum.InitialChainOwner, + infrastructureFeeCollector: chainConfig.arbitrum.InitialChainOwner, + staker: privateKeyToAccount(sanitizePrivateKey(process.env.VALIDATOR_PRIVATE_KEY!)).address, + batchPoster: privateKeyToAccount(sanitizePrivateKey(process.env.BATCH_POSTER_PRIVATE_KEY!)).address, + chainOwner: chainConfig.arbitrum.InitialChainOwner, + chainId: chainConfig.chainId, + chainName, + minL2BaseFee: 100000000, // todo: check default? + parentChainId: parentChain.id, + 'parent-chain-node-url': parentChainRpc, + utils: coreContracts.validatorUtils, // todo: same as validatorUtils? + rollup: coreContracts.rollup, + inbox: coreContracts.inbox, + nativeToken: coreContracts.nativeToken, + outbox: coreContracts.outbox, + rollupEventInbox: coreContracts.rollupEventInbox, + challengeManager: coreContracts.challengeManager, + adminProxy: coreContracts.adminProxy, + sequencerInbox: coreContracts.sequencerInbox, + bridge: coreContracts.bridge, + upgradeExecutor: coreContracts.upgradeExecutor, + validatorUtils: coreContracts.validatorUtils, + validatorWalletCreator: coreContracts.validatorWalletCreator, + deployedAtBlockNumber: coreContracts.deployedAtBlockNumber }; // For L2 Orbit chains settling to Ethereum mainnet or testnet @@ -87,8 +120,12 @@ async function main() { const nodeConfig = prepareNodeConfig(nodeConfigParameters); - await writeFile('node-config.json', JSON.stringify(nodeConfig, null, 2)); + await writeFile('nodeConfig.json', JSON.stringify(nodeConfig, null, 2)); console.log(`Node config written to "node-config.json"`); + + await writeFile('orbitSetupScriptConfig.json', JSON.stringify(orbitSetupScriptConfigParams, null, 2)); + console.log(`Orbit setup script config written to "orbitSetupScriptConfig.json"`); + } main(); diff --git a/src/index.ts b/src/index.ts index 02d77be8..5e58dbc1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -75,7 +75,7 @@ import { CoreContracts } from './types/CoreContracts'; import { ParentChain, ParentChainId } from './types/ParentChain'; import { NodeConfig } from './types/NodeConfig.generated'; import { NodeConfigChainInfoJson } from './types/NodeConfig'; -import { PrepareNodeConfigParams, prepareNodeConfig } from './prepareNodeConfig'; +import { PrepareNodeConfigParams, prepareNodeConfig, OrbitSetupScriptConfigParams } from './prepareNodeConfig'; import { CreateTokenBridgeParams, CreateTokenBridgeResults, @@ -228,6 +228,7 @@ export { NodeConfig, NodeConfigChainInfoJson, PrepareNodeConfigParams, + OrbitSetupScriptConfigParams, prepareNodeConfig, prepareKeyset, utils, diff --git a/src/prepareNodeConfig.ts b/src/prepareNodeConfig.ts index d43ae50e..8dcd0b90 100644 --- a/src/prepareNodeConfig.ts +++ b/src/prepareNodeConfig.ts @@ -8,6 +8,7 @@ import { CoreContracts } from './types/CoreContracts'; import { ParentChainId, validateParentChain } from './types/ParentChain'; import { getParentChainLayer } from './utils'; import { parentChainIsArbitrum } from './parentChainIsArbitrum'; +import { Address } from 'viem'; // this is different from `sanitizePrivateKey` from utils, as this removes the 0x prefix function sanitizePrivateKey(privateKey: string) { @@ -37,6 +38,33 @@ export type PrepareNodeConfigParams = { dasServerUrl?: string; }; +export type OrbitSetupScriptConfigParams = { + networkFeeReceiver: Address; + infrastructureFeeCollector: Address; + staker: Address; + batchPoster: Address; + chainOwner: Address; + chainId: number; + chainName: string; + minL2BaseFee: number; + parentChainId: number; + 'parent-chain-node-url': string; + utils: Address; + rollup: Address; + inbox: Address; + nativeToken: Address; + outbox: Address; + rollupEventInbox: Address; + challengeManager: Address; + adminProxy: Address; + sequencerInbox: Address; + bridge: Address; + upgradeExecutor: Address; + validatorUtils: Address; + validatorWalletCreator: Address; + deployedAtBlockNumber: number; +}; + function getDisableBlobReader(parentChainId: ParentChainId): boolean { if (getParentChainLayer(parentChainId) !== 1 && !parentChainIsArbitrum(parentChainId)) { return true;