From 7b9cd7f45ff285735c85957f37b770f91a7be279 Mon Sep 17 00:00:00 2001 From: g11tech <76567250+g11tech@users.noreply.github.com> Date: Tue, 24 May 2022 14:07:32 +0530 Subject: [PATCH] Add ropsten network (#4051) --- packages/cli/src/networks/index.ts | 7 ++- packages/cli/src/networks/ropsten.ts | 13 ++++++ .../src/chainConfig/networks/ropsten.ts | 44 +++++++++++++++++++ packages/config/src/networks.ts | 6 ++- packages/light-client/src/networks.ts | 5 +++ 5 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 packages/cli/src/networks/ropsten.ts create mode 100644 packages/config/src/chainConfig/networks/ropsten.ts diff --git a/packages/cli/src/networks/index.ts b/packages/cli/src/networks/index.ts index dc224af3755..61bdd9ea700 100644 --- a/packages/cli/src/networks/index.ts +++ b/packages/cli/src/networks/index.ts @@ -12,9 +12,10 @@ import got from "got"; import * as mainnet from "./mainnet"; import * as prater from "./prater"; import * as kiln from "./kiln"; +import * as ropsten from "./ropsten"; -export type NetworkName = "mainnet" | "prater" | "kiln" | "dev"; -export const networkNames: NetworkName[] = ["mainnet", "prater", "kiln"]; +export type NetworkName = "mainnet" | "prater" | "kiln" | "ropsten" | "dev"; +export const networkNames: NetworkName[] = ["mainnet", "prater", "kiln", "ropsten"]; export type WeakSubjectivityFetchOptions = { weakSubjectivityServerUrl: string; @@ -37,6 +38,8 @@ function getNetworkData( return prater; case "kiln": return kiln; + case "ropsten": + return ropsten; default: throw Error(`Network not supported: ${network}`); } diff --git a/packages/cli/src/networks/ropsten.ts b/packages/cli/src/networks/ropsten.ts new file mode 100644 index 00000000000..6962b4194cf --- /dev/null +++ b/packages/cli/src/networks/ropsten.ts @@ -0,0 +1,13 @@ +import {ropstenChainConfig} from "@chainsafe/lodestar-config/networks"; + +export const chainConfig = ropstenChainConfig; + +/* eslint-disable max-len */ + +export const depositContractDeployBlock = 12269949; +export const genesisFileUrl = + "https://raw.githubusercontent.com/eth-clients/merge-testnets/main/ropsten-beacon-chain/genesis.ssz"; +export const bootnodesFileUrl = + "https://raw.githubusercontent.com/eth-clients/merge-testnets/main/ropsten-beacon-chain/bootstrap_nodes.txt"; + +export const bootEnrs = []; diff --git a/packages/config/src/chainConfig/networks/ropsten.ts b/packages/config/src/chainConfig/networks/ropsten.ts new file mode 100644 index 00000000000..56fe960cf07 --- /dev/null +++ b/packages/config/src/chainConfig/networks/ropsten.ts @@ -0,0 +1,44 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +import {fromHexString as b} from "@chainsafe/ssz"; +import {IChainConfig} from "../types"; +import {chainConfig as mainnet} from "../presets/mainnet"; + +/* eslint-disable max-len */ + +// Ropsten beacon chain config: +// https://github.com/eth-clients/merge-testnets/blob/main/ropsten-beacon-chain/config.yaml + +export const ropstenChainConfig: IChainConfig = { + ...mainnet, + + // Genesis + // --------------------------------------------------------------- + MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: 100000, + // # Monday, May 30th, 2022 3:00:00 PM +UTC + MIN_GENESIS_TIME: 1653318000, + GENESIS_FORK_VERSION: b("0x80000069"), + + // Forking + // --------------------------------------------------------------- + // # Altair + ALTAIR_FORK_VERSION: b("0x80000070"), + ALTAIR_FORK_EPOCH: 500, + // # Merge + BELLATRIX_FORK_VERSION: b("0x80000071"), + BELLATRIX_FORK_EPOCH: 750, + TERMINAL_TOTAL_DIFFICULTY: BigInt(43531756765713534), + // # Sharding + SHARDING_FORK_VERSION: b("0x03001020"), + SHARDING_FORK_EPOCH: Infinity, + + // Fork choice + // --------------------------------------------------------------- + // 40% + PROPOSER_SCORE_BOOST: 40, + + // Deposit contract + // --------------------------------------------------------------- + DEPOSIT_CHAIN_ID: 3, + DEPOSIT_NETWORK_ID: 3, + DEPOSIT_CONTRACT_ADDRESS: b("0x6f22fFbC56eFF051aECF839396DD1eD9aD6BBA9D"), +}; diff --git a/packages/config/src/networks.ts b/packages/config/src/networks.ts index 9fe09c3089e..89c29aedc66 100644 --- a/packages/config/src/networks.ts +++ b/packages/config/src/networks.ts @@ -2,12 +2,14 @@ import {IChainConfig} from "./chainConfig"; import {mainnetChainConfig} from "./chainConfig/networks/mainnet"; import {praterChainConfig} from "./chainConfig/networks/prater"; import {kilnChainConfig} from "./chainConfig/networks/kiln"; +import {ropstenChainConfig} from "./chainConfig/networks/ropsten"; -export {mainnetChainConfig, praterChainConfig, kilnChainConfig}; +export {mainnetChainConfig, praterChainConfig, kilnChainConfig, ropstenChainConfig}; -export type NetworkName = "mainnet" | "prater" | "kiln"; +export type NetworkName = "mainnet" | "prater" | "kiln" | "ropsten"; export const networksChainConfig: Record = { mainnet: mainnetChainConfig, prater: praterChainConfig, kiln: kilnChainConfig, + ropsten: ropstenChainConfig, }; diff --git a/packages/light-client/src/networks.ts b/packages/light-client/src/networks.ts index e4b106e93e8..f43d8851704 100644 --- a/packages/light-client/src/networks.ts +++ b/packages/light-client/src/networks.ts @@ -4,6 +4,7 @@ enum NetworkName { mainnet = "mainnet", prater = "prater", kiln = "kiln", + ropsten = "ropsten", } export type GenesisDataHex = { @@ -29,4 +30,8 @@ export const networkGenesis: Record = { genesisTime: 1647007500, genesisValidatorsRoot: "0x99b09fcd43e5905236c370f184056bec6e6638cfc31a323b304fc4aa789cb4ad", }, + [NetworkName.ropsten]: { + genesisTime: 1653922800, + genesisValidatorsRoot: "0x44f1e56283ca88b35c789f7f449e52339bc1fefe3a45913a43a6d16edcd33cf1", + }, };