Skip to content
Merged
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 lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "1.7.0",
"version": "1.7.1",
"stream": "true",
"command": {
"version": {
Expand Down
10 changes: 5 additions & 5 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/ChainSafe/lodestar/issues"
},
"version": "1.7.0",
"version": "1.7.1",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -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"
Expand Down
24 changes: 12 additions & 12 deletions packages/beacon-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/ChainSafe/lodestar/issues"
},
"version": "1.7.0",
"version": "1.7.1",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -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",
Expand Down
22 changes: 11 additions & 11 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
23 changes: 7 additions & 16 deletions packages/cli/src/cmds/beacon/initBeaconState.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand Down
40 changes: 26 additions & 14 deletions packages/cli/src/networks/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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),
};
}
6 changes: 3 additions & 3 deletions packages/config/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
}
6 changes: 3 additions & 3 deletions packages/db/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions packages/flare/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
},
Expand Down
12 changes: 6 additions & 6 deletions packages/fork-choice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions packages/light-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/ChainSafe/lodestar/issues"
},
"version": "1.7.0",
"version": "1.7.1",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/params/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 5 additions & 5 deletions packages/reqresp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/ChainSafe/lodestar/issues"
},
"version": "1.7.0",
"version": "1.7.1",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/spec-test-util/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading