From fb67e62ba19c37a74c5d59af7bb8ca52cc7861a1 Mon Sep 17 00:00:00 2001 From: philknows Date: Wed, 29 Mar 2023 16:28:06 -0400 Subject: [PATCH 1/2] v1.7.1 --- lerna.json | 2 +- packages/api/package.json | 10 +++++----- packages/beacon-node/package.json | 24 ++++++++++++------------ packages/cli/package.json | 22 +++++++++++----------- packages/config/package.json | 6 +++--- packages/db/package.json | 6 +++--- packages/flare/package.json | 10 +++++----- packages/fork-choice/package.json | 12 ++++++------ packages/light-client/package.json | 12 ++++++------ packages/params/package.json | 2 +- packages/reqresp/package.json | 10 +++++----- packages/spec-test-util/package.json | 4 ++-- packages/state-transition/package.json | 10 +++++----- packages/types/package.json | 4 ++-- packages/utils/package.json | 2 +- packages/validator/package.json | 16 ++++++++-------- 16 files changed, 76 insertions(+), 76 deletions(-) diff --git a/lerna.json b/lerna.json index 44caa7830be8..50c78bed5412 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "1.7.0", + "version": "1.7.1", "stream": "true", "command": { "version": { diff --git a/packages/api/package.json b/packages/api/package.json index 445041c46147..ae58f972c8a0 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.7.0", + "version": "1.7.1", "type": "module", "exports": { ".": { @@ -70,10 +70,10 @@ "dependencies": { "@chainsafe/persistent-merkle-tree": "^0.5.0", "@chainsafe/ssz": "^0.10.1", - "@lodestar/config": "^1.7.0", - "@lodestar/params": "^1.7.0", - "@lodestar/types": "^1.7.0", - "@lodestar/utils": "^1.7.0", + "@lodestar/config": "^1.7.1", + "@lodestar/params": "^1.7.1", + "@lodestar/types": "^1.7.1", + "@lodestar/utils": "^1.7.1", "cross-fetch": "^3.1.4", "eventsource": "^2.0.2", "qs": "^6.11.1" diff --git a/packages/beacon-node/package.json b/packages/beacon-node/package.json index db226d9184df..8c00056fd75a 100644 --- a/packages/beacon-node/package.json +++ b/packages/beacon-node/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.7.0", + "version": "1.7.1", "type": "module", "exports": { ".": { @@ -117,17 +117,17 @@ "@libp2p/peer-id-factory": "^2.0.1", "@libp2p/prometheus-metrics": "^1.1.2", "@libp2p/tcp": "^6.1.0", - "@lodestar/api": "^1.7.0", - "@lodestar/config": "^1.7.0", - "@lodestar/db": "^1.7.0", - "@lodestar/fork-choice": "^1.7.0", - "@lodestar/light-client": "^1.7.0", - "@lodestar/params": "^1.7.0", - "@lodestar/reqresp": "^1.7.0", - "@lodestar/state-transition": "^1.7.0", - "@lodestar/types": "^1.7.0", - "@lodestar/utils": "^1.7.0", - "@lodestar/validator": "^1.7.0", + "@lodestar/api": "^1.7.1", + "@lodestar/config": "^1.7.1", + "@lodestar/db": "^1.7.1", + "@lodestar/fork-choice": "^1.7.1", + "@lodestar/light-client": "^1.7.1", + "@lodestar/params": "^1.7.1", + "@lodestar/reqresp": "^1.7.1", + "@lodestar/state-transition": "^1.7.1", + "@lodestar/types": "^1.7.1", + "@lodestar/utils": "^1.7.1", + "@lodestar/validator": "^1.7.1", "@multiformats/multiaddr": "^11.0.0", "@types/datastore-level": "^3.0.0", "buffer-xor": "^2.0.2", diff --git a/packages/cli/package.json b/packages/cli/package.json index 2cff84f1ca53..60599ae75544 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@chainsafe/lodestar", - "version": "1.7.0", + "version": "1.7.1", "description": "Command line interface for lodestar", "author": "ChainSafe Systems", "license": "LGPL-3.0", @@ -61,16 +61,16 @@ "@chainsafe/discv5": "^3.0.0", "@chainsafe/ssz": "^0.10.1", "@libp2p/peer-id-factory": "^2.0.1", - "@lodestar/api": "^1.7.0", - "@lodestar/beacon-node": "^1.7.0", - "@lodestar/config": "^1.7.0", - "@lodestar/db": "^1.7.0", - "@lodestar/light-client": "^1.7.0", - "@lodestar/params": "^1.7.0", - "@lodestar/state-transition": "^1.7.0", - "@lodestar/types": "^1.7.0", - "@lodestar/utils": "^1.7.0", - "@lodestar/validator": "^1.7.0", + "@lodestar/api": "^1.7.1", + "@lodestar/beacon-node": "^1.7.1", + "@lodestar/config": "^1.7.1", + "@lodestar/db": "^1.7.1", + "@lodestar/light-client": "^1.7.1", + "@lodestar/params": "^1.7.1", + "@lodestar/state-transition": "^1.7.1", + "@lodestar/types": "^1.7.1", + "@lodestar/utils": "^1.7.1", + "@lodestar/validator": "^1.7.1", "@multiformats/multiaddr": "^11.0.0", "@types/lockfile": "^1.0.1", "bip39": "^3.0.2", diff --git a/packages/config/package.json b/packages/config/package.json index beefe7aa9734..4aa9f608c46a 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/config", - "version": "1.7.0", + "version": "1.7.1", "description": "Chain configuration required for lodestar", "author": "ChainSafe Systems", "license": "Apache-2.0", @@ -66,7 +66,7 @@ ], "dependencies": { "@chainsafe/ssz": "^0.10.1", - "@lodestar/params": "^1.7.0", - "@lodestar/types": "^1.7.0" + "@lodestar/params": "^1.7.1", + "@lodestar/types": "^1.7.1" } } diff --git a/packages/db/package.json b/packages/db/package.json index d9a3cdede169..d7fa7b3cb100 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/db", - "version": "1.7.0", + "version": "1.7.1", "description": "DB modules of Lodestar", "author": "ChainSafe Systems", "homepage": "https://github.com/ChainSafe/lodestar#readme", @@ -39,8 +39,8 @@ }, "dependencies": { "@chainsafe/ssz": "^0.10.1", - "@lodestar/config": "^1.7.0", - "@lodestar/utils": "^1.7.0", + "@lodestar/config": "^1.7.1", + "@lodestar/utils": "^1.7.1", "@types/levelup": "^4.3.3", "it-all": "^2.0.0", "level": "^8.0.0" diff --git a/packages/flare/package.json b/packages/flare/package.json index aab32c6aeefb..32b7491434af 100644 --- a/packages/flare/package.json +++ b/packages/flare/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/flare", - "version": "1.7.0", + "version": "1.7.1", "description": "Beacon chain debugging tool", "author": "ChainSafe Systems", "license": "Apache-2.0", @@ -59,10 +59,10 @@ "blockchain" ], "dependencies": { - "@lodestar/api": "^1.7.0", - "@lodestar/config": "^1.7.0", - "@lodestar/state-transition": "^1.7.0", - "@lodestar/types": "^1.7.0", + "@lodestar/api": "^1.7.1", + "@lodestar/config": "^1.7.1", + "@lodestar/state-transition": "^1.7.1", + "@lodestar/types": "^1.7.1", "source-map-support": "^0.5.19", "yargs": "^16.1.0" }, diff --git a/packages/fork-choice/package.json b/packages/fork-choice/package.json index 2959cf77be60..b2825456f2ab 100644 --- a/packages/fork-choice/package.json +++ b/packages/fork-choice/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.7.0", + "version": "1.7.1", "type": "module", "exports": "./lib/index.js", "types": "./lib/index.d.ts", @@ -40,11 +40,11 @@ }, "dependencies": { "@chainsafe/ssz": "^0.10.1", - "@lodestar/config": "^1.7.0", - "@lodestar/params": "^1.7.0", - "@lodestar/state-transition": "^1.7.0", - "@lodestar/types": "^1.7.0", - "@lodestar/utils": "^1.7.0" + "@lodestar/config": "^1.7.1", + "@lodestar/params": "^1.7.1", + "@lodestar/state-transition": "^1.7.1", + "@lodestar/types": "^1.7.1", + "@lodestar/utils": "^1.7.1" }, "keywords": [ "ethereum", diff --git a/packages/light-client/package.json b/packages/light-client/package.json index bff6ad1c82ef..df0aa3144dd5 100644 --- a/packages/light-client/package.json +++ b/packages/light-client/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.7.0", + "version": "1.7.1", "type": "module", "exports": { ".": { @@ -66,11 +66,11 @@ "@chainsafe/bls": "7.1.1", "@chainsafe/persistent-merkle-tree": "^0.5.0", "@chainsafe/ssz": "^0.10.1", - "@lodestar/api": "^1.7.0", - "@lodestar/config": "^1.7.0", - "@lodestar/params": "^1.7.0", - "@lodestar/types": "^1.7.0", - "@lodestar/utils": "^1.7.0", + "@lodestar/api": "^1.7.1", + "@lodestar/config": "^1.7.1", + "@lodestar/params": "^1.7.1", + "@lodestar/types": "^1.7.1", + "@lodestar/utils": "^1.7.1", "cross-fetch": "^3.1.4", "mitt": "^3.0.0", "strict-event-emitter-types": "^2.0.0" diff --git a/packages/params/package.json b/packages/params/package.json index bc0814a9d143..bef6aa3c3de4 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/params", - "version": "1.7.0", + "version": "1.7.1", "description": "Chain parameters required for lodestar", "author": "ChainSafe Systems", "license": "Apache-2.0", diff --git a/packages/reqresp/package.json b/packages/reqresp/package.json index 66eacd23809b..1023a92f7cf2 100644 --- a/packages/reqresp/package.json +++ b/packages/reqresp/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.7.0", + "version": "1.7.1", "type": "module", "exports": { ".": { @@ -59,10 +59,10 @@ "@chainsafe/snappy-stream": "^5.1.2", "@libp2p/interface-connection": "^3.0.2", "@libp2p/interface-peer-id": "^2.0.1", - "@lodestar/config": "^1.7.0", - "@lodestar/params": "^1.7.0", - "@lodestar/types": "^1.7.0", - "@lodestar/utils": "^1.7.0", + "@lodestar/config": "^1.7.1", + "@lodestar/params": "^1.7.1", + "@lodestar/types": "^1.7.1", + "@lodestar/utils": "^1.7.1", "it-all": "^2.0.0", "snappyjs": "^0.7.0", "stream-to-it": "^0.2.0", diff --git a/packages/spec-test-util/package.json b/packages/spec-test-util/package.json index f28e35350e61..c240f5e37368 100644 --- a/packages/spec-test-util/package.json +++ b/packages/spec-test-util/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/spec-test-util", - "version": "1.7.0", + "version": "1.7.1", "description": "Spec test suite generator from yaml test files", "author": "ChainSafe Systems", "license": "Apache-2.0", @@ -46,7 +46,7 @@ "blockchain" ], "dependencies": { - "@lodestar/utils": "^1.7.0", + "@lodestar/utils": "^1.7.1", "async-retry": "^1.3.3", "axios": "^0.21.0", "chai": "^4.3.6", diff --git a/packages/state-transition/package.json b/packages/state-transition/package.json index e6b824980fd9..d2e163dad782 100644 --- a/packages/state-transition/package.json +++ b/packages/state-transition/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.7.0", + "version": "1.7.1", "type": "module", "exports": { ".": { @@ -63,10 +63,10 @@ "@chainsafe/persistent-merkle-tree": "^0.5.0", "@chainsafe/persistent-ts": "^0.19.1", "@chainsafe/ssz": "^0.10.1", - "@lodestar/config": "^1.7.0", - "@lodestar/params": "^1.7.0", - "@lodestar/types": "^1.7.0", - "@lodestar/utils": "^1.7.0", + "@lodestar/config": "^1.7.1", + "@lodestar/params": "^1.7.1", + "@lodestar/types": "^1.7.1", + "@lodestar/utils": "^1.7.1", "bigint-buffer": "^1.1.5", "buffer-xor": "^2.0.2" }, diff --git a/packages/types/package.json b/packages/types/package.json index 12dc9971af42..fd5c8a8c5eb5 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.7.0", + "version": "1.7.1", "type": "module", "exports": { ".": { @@ -69,7 +69,7 @@ "types": "lib/index.d.ts", "dependencies": { "@chainsafe/ssz": "^0.10.1", - "@lodestar/params": "^1.7.0" + "@lodestar/params": "^1.7.1" }, "keywords": [ "ethereum", diff --git a/packages/utils/package.json b/packages/utils/package.json index 08f193c92b36..810b09b3f6c3 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/ChainSafe/lodestar/issues" }, - "version": "1.7.0", + "version": "1.7.1", "type": "module", "exports": "./lib/index.js", "files": [ diff --git a/packages/validator/package.json b/packages/validator/package.json index 0d97e11ab1a6..16e464e49d8a 100644 --- a/packages/validator/package.json +++ b/packages/validator/package.json @@ -1,6 +1,6 @@ { "name": "@lodestar/validator", - "version": "1.7.0", + "version": "1.7.1", "description": "A Typescript implementation of the validator client", "author": "ChainSafe Systems", "license": "LGPL-3.0", @@ -51,13 +51,13 @@ "dependencies": { "@chainsafe/bls": "7.1.1", "@chainsafe/ssz": "^0.10.1", - "@lodestar/api": "^1.7.0", - "@lodestar/config": "^1.7.0", - "@lodestar/db": "^1.7.0", - "@lodestar/params": "^1.7.0", - "@lodestar/state-transition": "^1.7.0", - "@lodestar/types": "^1.7.0", - "@lodestar/utils": "^1.7.0", + "@lodestar/api": "^1.7.1", + "@lodestar/config": "^1.7.1", + "@lodestar/db": "^1.7.1", + "@lodestar/params": "^1.7.1", + "@lodestar/state-transition": "^1.7.1", + "@lodestar/types": "^1.7.1", + "@lodestar/utils": "^1.7.1", "bigint-buffer": "^1.1.5", "cross-fetch": "^3.1.4", "strict-event-emitter-types": "^2.0.0" From baa95e482dc76b015c5ffe486bfcba1cf8a4f510 Mon Sep 17 00:00:00 2001 From: g11tech Date: Wed, 29 Mar 2023 08:33:37 +0530 Subject: [PATCH 2/2] Use finalized state id when no checkpoint provided in checkpoint sync (#5313) * Use finalized state id when no checkpoint provided in checkpoint sync * add stateid to log --- .../cli/src/cmds/beacon/initBeaconState.ts | 23 ++++------- packages/cli/src/networks/index.ts | 40 ++++++++++++------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/packages/cli/src/cmds/beacon/initBeaconState.ts b/packages/cli/src/cmds/beacon/initBeaconState.ts index 07ef5e3926ee..bbfce46a7ea1 100644 --- a/packages/cli/src/cmds/beacon/initBeaconState.ts +++ b/packages/cli/src/cmds/beacon/initBeaconState.ts @@ -1,12 +1,7 @@ import {ssz} from "@lodestar/types"; import {createBeaconConfig, BeaconConfig, ChainForkConfig} from "@lodestar/config"; import {Logger} from "@lodestar/utils"; -import { - getLatestBlockRoot, - isWithinWeakSubjectivityPeriod, - BeaconStateAllForks, - computeCheckpointEpochAtStateSlot, -} from "@lodestar/state-transition"; +import {isWithinWeakSubjectivityPeriod, BeaconStateAllForks} from "@lodestar/state-transition"; import { IBeaconDb, IBeaconNodeOptions, @@ -18,18 +13,14 @@ import {Checkpoint} from "@lodestar/types/phase0"; import {downloadOrLoadFile} from "../../util/index.js"; import {defaultNetwork, GlobalArgs} from "../../options/globalOptions.js"; -import {fetchWeakSubjectivityState, getCheckpointFromArg, getGenesisFileUrl} from "../../networks/index.js"; +import { + fetchWeakSubjectivityState, + getCheckpointFromArg, + getGenesisFileUrl, + getCheckpointFromState, +} from "../../networks/index.js"; import {BeaconArgs} from "./options.js"; -export function getCheckpointFromState(state: BeaconStateAllForks): Checkpoint { - return { - // the correct checkpoint is based on state's slot, its latestBlockHeader's slot's epoch can be - // behind the state - epoch: computeCheckpointEpochAtStateSlot(state.slot), - root: getLatestBlockRoot(state), - }; -} - async function initAndVerifyWeakSubjectivityState( config: BeaconConfig, db: IBeaconDb, diff --git a/packages/cli/src/networks/index.ts b/packages/cli/src/networks/index.ts index 7dad5fcfcec1..8e5e9c460a81 100644 --- a/packages/cli/src/networks/index.ts +++ b/packages/cli/src/networks/index.ts @@ -1,12 +1,13 @@ import fs from "node:fs"; import got from "got"; -import {SLOTS_PER_EPOCH, ForkName} from "@lodestar/params"; +import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {ApiError, getClient} from "@lodestar/api"; import {getStateTypeFromBytes} from "@lodestar/beacon-node"; import {ChainConfig, ChainForkConfig} from "@lodestar/config"; import {Checkpoint} from "@lodestar/types/phase0"; +import {Slot} from "@lodestar/types"; import {fromHex, callFnWhenAwait, Logger} from "@lodestar/utils"; -import {BeaconStateAllForks} from "@lodestar/state-transition"; +import {BeaconStateAllForks, getLatestBlockRoot, computeCheckpointEpochAtStateSlot} from "@lodestar/state-transition"; import {parseBootnodesFile} from "../util/format.js"; import * as mainnet from "./mainnet.js"; import * as dev from "./dev.js"; @@ -140,20 +141,21 @@ export async function fetchWeakSubjectivityState( {checkpointSyncUrl, wssCheckpoint}: {checkpointSyncUrl: string; wssCheckpoint?: string} ): Promise<{wsState: BeaconStateAllForks; wsCheckpoint: Checkpoint}> { try { - let wsCheckpoint; + let wsCheckpoint: Checkpoint | null; + let stateId: Slot | "finalized"; + const api = getClient({baseUrl: checkpointSyncUrl}, {config}); if (wssCheckpoint) { wsCheckpoint = getCheckpointFromArg(wssCheckpoint); + stateId = wsCheckpoint.epoch * SLOTS_PER_EPOCH; } else { - const res = await api.beacon.getStateFinalityCheckpoints("head"); - ApiError.assert(res, "Can not fetch finalized checkpoint"); - wsCheckpoint = res.response.data.finalized; + // Fetch current finalized state and extract checkpoint from it + stateId = "finalized"; + wsCheckpoint = null; } - const stateSlot = wsCheckpoint.epoch * SLOTS_PER_EPOCH; - const getStatePromise = - config.getForkName(stateSlot) === ForkName.phase0 - ? api.debug.getState(`${stateSlot}`, "ssz") - : api.debug.getStateV2(`${stateSlot}`, "ssz"); + + // getStateV2 should be available for all forks including phase0 + const getStatePromise = api.debug.getStateV2(stateId, "ssz"); const stateBytes = await callFnWhenAwait( getStatePromise, @@ -164,11 +166,12 @@ export async function fetchWeakSubjectivityState( return res.response; }); - logger.info("Download completed"); + logger.info("Download completed", {stateId}); + const wsState = getStateTypeFromBytes(config, stateBytes).deserializeToViewDU(stateBytes); return { - wsState: getStateTypeFromBytes(config, stateBytes).deserializeToViewDU(stateBytes), - wsCheckpoint, + wsState, + wsCheckpoint: wsCheckpoint ?? getCheckpointFromState(wsState), }; } catch (e) { throw new Error("Unable to fetch weak subjectivity state: " + (e as Error).message); @@ -183,3 +186,12 @@ export function getCheckpointFromArg(checkpointStr: string): Checkpoint { } return {root: fromHex(match[1]), epoch: parseInt(match[2])}; } + +export function getCheckpointFromState(state: BeaconStateAllForks): Checkpoint { + return { + // the correct checkpoint is based on state's slot, its latestBlockHeader's slot's epoch can be + // behind the state + epoch: computeCheckpointEpochAtStateSlot(state.slot), + root: getLatestBlockRoot(state), + }; +}