From ba81267ea3987bbf2925eba4fe689c7248433047 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Wed, 3 Jan 2024 12:31:13 -0800 Subject: [PATCH 1/5] backends path for arbitrary dac set --- src/prepareNodeConfig.ts | 34 +++++++++++++++++++++++++--------- src/types/NodeConfig.ts | 11 ++++++++--- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/prepareNodeConfig.ts b/src/prepareNodeConfig.ts index 2ec162af..8b5974c1 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,8 @@ export function prepareNodeConfig({ validatorPrivateKey, parentChainId, parentChainRpcUrl, + assumedHonest, + backendsData, }: { chainName: string; chainConfig: ChainConfig; @@ -51,6 +54,8 @@ export function prepareNodeConfig({ validatorPrivateKey: string; parentChainId: number; parentChainRpcUrl: string; + assumedHonest?: number; + backendsData: BackendsData; }): NodeConfig { if (!validParentChainId(parentChainId)) { throw new Error(`[prepareNodeConfig] invalid parent chain id: ${parentChainId}`); @@ -124,6 +129,24 @@ export function prepareNodeConfig({ }; if (chainConfig.arbitrum.DataAvailabilityCommittee) { + let backends: NodeConfigDataAvailabilityRpcAggregatorBackendsJson; + if (assumedHonest !== undefined && backendsData && backendsData.length > 0) { + backends = backendsData.map((backend, index) => ({ + url: backend.url, + pubkey: backend.pubkey, + signermask: 1 << index, // 2^n + })); + } else { + backends = [ + { + url: 'http://localhost:9876', + pubkey: + 'YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==', + signermask: 1, + }, + ]; + } + config.node['data-availability'] = { 'enable': true, 'sequencer-inbox-address': coreContracts.sequencerInbox, @@ -135,17 +158,10 @@ export function prepareNodeConfig({ 'rpc-aggregator': { 'enable': true, 'assumed-honest': 1, - 'backends': stringifyBackendsJson([ - { - url: 'http://localhost:9876', - pubkey: - 'YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==', - signermask: 1, - }, - ]), + 'backends': stringifyBackendsJson(backends), }, }; } return config; -} +} \ No newline at end of file diff --git a/src/types/NodeConfig.ts b/src/types/NodeConfig.ts index ab425b0b..25b5b734 100644 --- a/src/types/NodeConfig.ts +++ b/src/types/NodeConfig.ts @@ -19,13 +19,18 @@ export type NodeConfigChainInfoJson = [ }, ]; -export type NodeConfigDataAvailabilityRpcAggregatorBackendsJson = [ +export type BackendsData = + { + url: string; + pubkey: string; + }[]; + +export type NodeConfigDataAvailabilityRpcAggregatorBackendsJson = { url: string; pubkey: string; signermask: number; - }, -]; + }[]; export type NodeConfig = { 'chain': { From 935e3427e22717b8f57eaa4334935a7a7e434e04 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:54:57 -0800 Subject: [PATCH 2/5] rest rpc on node config --- src/prepareNodeConfig.ts | 10 ++++++---- src/types/NodeConfig.ts | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/prepareNodeConfig.ts b/src/prepareNodeConfig.ts index 8b5974c1..2dd5d31a 100644 --- a/src/prepareNodeConfig.ts +++ b/src/prepareNodeConfig.ts @@ -55,7 +55,7 @@ export function prepareNodeConfig({ parentChainId: number; parentChainRpcUrl: string; assumedHonest?: number; - backendsData: BackendsData; + backendsData?: BackendsData; }): NodeConfig { if (!validParentChainId(parentChainId)) { throw new Error(`[prepareNodeConfig] invalid parent chain id: ${parentChainId}`); @@ -130,12 +130,14 @@ 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.url, + url: backend.urlRpc, pubkey: backend.pubkey, signermask: 1 << index, // 2^n })); + restUrls = backendsData.map(backend => backend.urlRest); } else { backends = [ { @@ -153,11 +155,11 @@ export function prepareNodeConfig({ 'parent-chain-node-url': parentChainRpcUrl, 'rest-aggregator': { enable: true, - urls: 'http://localhost:9876', + urls: restUrls, }, 'rpc-aggregator': { 'enable': true, - 'assumed-honest': 1, + 'assumed-honest': assumedHonest || 1, 'backends': stringifyBackendsJson(backends), }, }; diff --git a/src/types/NodeConfig.ts b/src/types/NodeConfig.ts index 25b5b734..5bd7b77c 100644 --- a/src/types/NodeConfig.ts +++ b/src/types/NodeConfig.ts @@ -21,7 +21,8 @@ export type NodeConfigChainInfoJson = [ export type BackendsData = { - url: string; + urlRest: string; + urlRpc: string; pubkey: string; }[]; @@ -88,7 +89,7 @@ export type NodeConfig = { 'parent-chain-node-url': string; 'rest-aggregator': { enable: boolean; - urls: string; + urls: string[]; }; 'rpc-aggregator': { 'enable': boolean; From 39869504b50cf67e792718fa86cc7d566bf1c45c Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Sat, 13 Jan 2024 00:15:15 -0800 Subject: [PATCH 3/5] tx hash for prepare node config and format fixed --- examples/prepare-node-config/index.ts | 2 +- src/prepareNodeConfig.ts | 8 ++++---- src/types/NodeConfig.ts | 22 ++++++++++------------ 3 files changed, 15 insertions(+), 17 deletions(-) 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 2dd5d31a..499dd01d 100644 --- a/src/prepareNodeConfig.ts +++ b/src/prepareNodeConfig.ts @@ -2,7 +2,7 @@ import { NodeConfig, NodeConfigChainInfoJson, NodeConfigDataAvailabilityRpcAggregatorBackendsJson, - BackendsData + BackendsData, } from './types/NodeConfig'; import { ChainConfig } from './types/ChainConfig'; import { CoreContracts } from './types/CoreContracts'; @@ -130,14 +130,14 @@ export function prepareNodeConfig({ if (chainConfig.arbitrum.DataAvailabilityCommittee) { let backends: NodeConfigDataAvailabilityRpcAggregatorBackendsJson; - let restUrls: string[] = ['http://localhost:9876'] + 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); + restUrls = backendsData.map((backend) => backend.urlRest); } else { backends = [ { @@ -166,4 +166,4 @@ export function prepareNodeConfig({ } return config; -} \ No newline at end of file +} diff --git a/src/types/NodeConfig.ts b/src/types/NodeConfig.ts index 5bd7b77c..5e6d91a6 100644 --- a/src/types/NodeConfig.ts +++ b/src/types/NodeConfig.ts @@ -19,19 +19,17 @@ export type NodeConfigChainInfoJson = [ }, ]; -export type BackendsData = - { - urlRest: string; - urlRpc: string; - pubkey: string; - }[]; +export type BackendsData = { + urlRest: string; + urlRpc: string; + pubkey: string; +}[]; -export type NodeConfigDataAvailabilityRpcAggregatorBackendsJson = - { - url: string; - pubkey: string; - signermask: number; - }[]; +export type NodeConfigDataAvailabilityRpcAggregatorBackendsJson = { + url: string; + pubkey: string; + signermask: number; +}[]; export type NodeConfig = { 'chain': { From bfb3273259e21673d9a51e0fd414a78fc0035272 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Tue, 16 Jan 2024 22:02:23 -0800 Subject: [PATCH 4/5] online-url-list added to node config as optional field --- src/prepareNodeConfig.ts | 6 ++++++ src/types/NodeConfig.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/src/prepareNodeConfig.ts b/src/prepareNodeConfig.ts index 499dd01d..65e95dec 100644 --- a/src/prepareNodeConfig.ts +++ b/src/prepareNodeConfig.ts @@ -46,6 +46,7 @@ export function prepareNodeConfig({ parentChainRpcUrl, assumedHonest, backendsData, + onlineUrlList }: { chainName: string; chainConfig: ChainConfig; @@ -56,6 +57,7 @@ export function prepareNodeConfig({ parentChainRpcUrl: string; assumedHonest?: number; backendsData?: BackendsData; + onlineUrlList?: string; }): NodeConfig { if (!validParentChainId(parentChainId)) { throw new Error(`[prepareNodeConfig] invalid parent chain id: ${parentChainId}`); @@ -163,6 +165,10 @@ export function prepareNodeConfig({ '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 5e6d91a6..4a71712c 100644 --- a/src/types/NodeConfig.ts +++ b/src/types/NodeConfig.ts @@ -87,6 +87,7 @@ export type NodeConfig = { 'parent-chain-node-url': string; 'rest-aggregator': { enable: boolean; + "online-url-list"?: string; urls: string[]; }; 'rpc-aggregator': { From a25dcd807b82802c4b9b280c53e4fb7a36db2854 Mon Sep 17 00:00:00 2001 From: GreatSoshiant <61604245+GreatSoshiant@users.noreply.github.com> Date: Tue, 16 Jan 2024 22:23:01 -0800 Subject: [PATCH 5/5] format fixed --- src/prepareNodeConfig.ts | 4 ++-- src/types/NodeConfig.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/prepareNodeConfig.ts b/src/prepareNodeConfig.ts index 65e95dec..024bf4a4 100644 --- a/src/prepareNodeConfig.ts +++ b/src/prepareNodeConfig.ts @@ -46,7 +46,7 @@ export function prepareNodeConfig({ parentChainRpcUrl, assumedHonest, backendsData, - onlineUrlList + onlineUrlList, }: { chainName: string; chainConfig: ChainConfig; @@ -168,7 +168,7 @@ export function prepareNodeConfig({ // 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 4a71712c..fa4f7f66 100644 --- a/src/types/NodeConfig.ts +++ b/src/types/NodeConfig.ts @@ -86,9 +86,9 @@ export type NodeConfig = { 'sequencer-inbox-address': string; 'parent-chain-node-url': string; 'rest-aggregator': { - enable: boolean; - "online-url-list"?: string; - urls: string[]; + 'enable': boolean; + 'online-url-list'?: string; + 'urls': string[]; }; 'rpc-aggregator': { 'enable': boolean;