diff --git a/examples/prepare-node-config/index.ts b/examples/prepare-node-config/index.ts index fe3a2f71..1699f6c5 100644 --- a/examples/prepare-node-config/index.ts +++ b/examples/prepare-node-config/index.ts @@ -22,7 +22,7 @@ const parentChainPublicClient = createPublicClient({ async function main() { // tx hash for the transaction to create rollup - const txHash = '0x22bb24020ee839e4a266960aa73c6bf5b02621e2de3f2a755c9f2869014140d7'; + const txHash = '0x668c555942aa34c4eb09fb3ad8a95544246b54dba5977e74669e5c8c07af35c2'; // get the transaction const tx = createRollupPrepareTransaction( diff --git a/src/prepareNodeConfig.ts b/src/prepareNodeConfig.ts index 2ec162af..024bf4a4 100644 --- a/src/prepareNodeConfig.ts +++ b/src/prepareNodeConfig.ts @@ -2,6 +2,7 @@ import { NodeConfig, NodeConfigChainInfoJson, NodeConfigDataAvailabilityRpcAggregatorBackendsJson, + BackendsData, } from './types/NodeConfig'; import { ChainConfig } from './types/ChainConfig'; import { CoreContracts } from './types/CoreContracts'; @@ -43,6 +44,9 @@ export function prepareNodeConfig({ validatorPrivateKey, parentChainId, parentChainRpcUrl, + assumedHonest, + backendsData, + onlineUrlList, }: { chainName: string; chainConfig: ChainConfig; @@ -51,6 +55,9 @@ export function prepareNodeConfig({ validatorPrivateKey: string; parentChainId: number; parentChainRpcUrl: string; + assumedHonest?: number; + backendsData?: BackendsData; + onlineUrlList?: string; }): NodeConfig { if (!validParentChainId(parentChainId)) { throw new Error(`[prepareNodeConfig] invalid parent chain id: ${parentChainId}`); @@ -124,27 +131,44 @@ export function prepareNodeConfig({ }; if (chainConfig.arbitrum.DataAvailabilityCommittee) { + let backends: NodeConfigDataAvailabilityRpcAggregatorBackendsJson; + let restUrls: string[] = ['http://localhost:9876']; + if (assumedHonest !== undefined && backendsData && backendsData.length > 0) { + backends = backendsData.map((backend, index) => ({ + url: backend.urlRpc, + pubkey: backend.pubkey, + signermask: 1 << index, // 2^n + })); + restUrls = backendsData.map((backend) => backend.urlRest); + } else { + backends = [ + { + url: 'http://localhost:9876', + pubkey: + 'YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==', + signermask: 1, + }, + ]; + } + config.node['data-availability'] = { 'enable': true, 'sequencer-inbox-address': coreContracts.sequencerInbox, 'parent-chain-node-url': parentChainRpcUrl, 'rest-aggregator': { enable: true, - urls: 'http://localhost:9876', + urls: restUrls, }, 'rpc-aggregator': { 'enable': true, - 'assumed-honest': 1, - 'backends': stringifyBackendsJson([ - { - url: 'http://localhost:9876', - pubkey: - 'YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==', - signermask: 1, - }, - ]), + 'assumed-honest': assumedHonest || 1, + 'backends': stringifyBackendsJson(backends), }, }; + // Check if onlineUrlList is provided and not empty + if (onlineUrlList && onlineUrlList.length > 0 && config.node['data-availability']) { + config.node['data-availability']['rest-aggregator']['online-url-list'] = onlineUrlList; + } } return config; diff --git a/src/types/NodeConfig.ts b/src/types/NodeConfig.ts index ab425b0b..fa4f7f66 100644 --- a/src/types/NodeConfig.ts +++ b/src/types/NodeConfig.ts @@ -19,13 +19,17 @@ export type NodeConfigChainInfoJson = [ }, ]; -export type NodeConfigDataAvailabilityRpcAggregatorBackendsJson = [ - { - url: string; - pubkey: string; - signermask: number; - }, -]; +export type BackendsData = { + urlRest: string; + urlRpc: string; + pubkey: string; +}[]; + +export type NodeConfigDataAvailabilityRpcAggregatorBackendsJson = { + url: string; + pubkey: string; + signermask: number; +}[]; export type NodeConfig = { 'chain': { @@ -82,8 +86,9 @@ export type NodeConfig = { 'sequencer-inbox-address': string; 'parent-chain-node-url': string; 'rest-aggregator': { - enable: boolean; - urls: string; + 'enable': boolean; + 'online-url-list'?: string; + 'urls': string[]; }; 'rpc-aggregator': { 'enable': boolean;