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

Improve prepare-node-config for Orbit Rollup Deployment #228

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
5 changes: 4 additions & 1 deletion examples/prepare-node-config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
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=
43 changes: 40 additions & 3 deletions examples/prepare-node-config/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review lines 97 and 100. Verify if the outputs for minL2BaseFee and utils are correct.

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
Expand All @@ -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();
28 changes: 28 additions & 0 deletions src/prepareNodeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down