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

feat: Anytrust chain config #40

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion examples/prepare-node-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
44 changes: 34 additions & 10 deletions src/prepareNodeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
NodeConfig,
NodeConfigChainInfoJson,
NodeConfigDataAvailabilityRpcAggregatorBackendsJson,
BackendsData,
} from './types/NodeConfig';
import { ChainConfig } from './types/ChainConfig';
import { CoreContracts } from './types/CoreContracts';
Expand Down Expand Up @@ -43,6 +44,9 @@ export function prepareNodeConfig({
validatorPrivateKey,
parentChainId,
parentChainRpcUrl,
assumedHonest,
backendsData,
onlineUrlList,
}: {
chainName: string;
chainConfig: ChainConfig;
Expand All @@ -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}`);
Expand Down Expand Up @@ -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;
Expand Down
23 changes: 14 additions & 9 deletions src/types/NodeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down Expand Up @@ -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;
Expand Down
Loading