Skip to content

Commit

Permalink
Release v1.7.0 (#5306)
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths authored Mar 28, 2023
2 parents efe28ce + c983898 commit a2c5100
Show file tree
Hide file tree
Showing 101 changed files with 880 additions and 500 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

## Getting started

- :gear: Follow the installation method for [source install](https://chainsafe.github.io/lodestar/install/source/), [NPM install](https://chainsafe.github.io/lodestar/install/npm/), or [Docker install](https://chainsafe.github.io/lodestar/install/docker/) to install Lodestar. Or use our [comprehensive setup guide](https://hackmd.io/@philknows/HkROkZW55).
- :gear: Follow the installation method for [source install](https://chainsafe.github.io/lodestar/install/source/), [NPM install](https://chainsafe.github.io/lodestar/install/npm/), or [Docker install](https://chainsafe.github.io/lodestar/install/docker/) to install Lodestar. Or use our [Lodestar Quickstart scripts](https://github.com/ChainSafe/lodestar-quickstart).
- :books: Use [Lodestar libraries](https://chainsafe.github.io/lodestar/libraries) in your next Ethereum Typescript project.
- :globe_with_meridians: Run a beacon node on [mainnet or a public testnet](https://chainsafe.github.io/lodestar/usage/beacon-management).
- :computer: Utilize the whole stack by [starting a local testnet](https://chainsafe.github.io/lodestar/usage/local).
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
### Getting started

- Follow the installation method for [source install](install/source.md), [NPM install](install/npm.md), or [Docker install](install/docker.md) to install Lodestar. Or use our [comprehensive setup guide](https://hackmd.io/@philknows/rk5cDvKmK).
- Follow the installation method for [source install](install/source.md), [NPM install](install/npm.md), or [Docker install](install/docker.md) to install Lodestar. Or use our [Lodestar Quickstart scripts](https://github.com/ChainSafe/lodestar-quickstart).
- Use [Lodestar libraries](libraries) in your next Ethereum Typescript project.
- Run a beacon node on [mainnet or a public testnet](usage/beacon-management.md).
- Utilize the whole stack by [starting a local testnet](usage/local).
Expand Down
2 changes: 1 addition & 1 deletion docs/install/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ docker run chainsafe/lodestar --help
```
<!-- prettier-ignore-start -->
!!! info
Docker is the recommended setup for Lodestar. Use our [comprehensive setup guide](https://hackmd.io/@philknows/rk5cDvKmK) with Docker for detailed instructions.
Docker is the recommended setup for Lodestar. Use our [Lodestar Quickstart scripts](https://github.com/ChainSafe/lodestar-quickstart) with Docker for detailed instructions.
<!-- prettier-ignore-end -->
10 changes: 2 additions & 8 deletions docs/install/source.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Make sure to have [Yarn installed](https://classic.yarnpkg.com/en/docs/install).

## Clone repository

Clone the repo locally.
Clone the repo locally and build from the stable release branch.

```bash
git clone https://github.com/chainsafe/lodestar.git
git clone -b stable https://github.com/chainsafe/lodestar.git
```

Switch to created directory.
Expand All @@ -26,12 +26,6 @@ Switch to created directory.
cd lodestar
```

<!-- prettier-ignore-start -->
!!! warning
`git clone` will check out the default `unstable` branch. If you are running Lodestar in production, we recommend to either use the `stable` branch
by running `git switch stable` or to use a specific version by running `git checkout <version>`, e.g. `git checkout v1.3.0`.
<!-- prettier-ignore-end -->

## Install packages

Install across all packages. Lodestar follows a [monorepo](https://github.com/lerna/lerna) structure, so all commands below must be run in the project root. Use the `--ignore-optional` flag to prevent downloading the Ethereum Consensus spec tests.
Expand Down
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.6.0",
"version": "1.7.0",
"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.6.0",
"version": "1.7.0",
"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.6.0",
"@lodestar/params": "^1.6.0",
"@lodestar/types": "^1.6.0",
"@lodestar/utils": "^1.6.0",
"@lodestar/config": "^1.7.0",
"@lodestar/params": "^1.7.0",
"@lodestar/types": "^1.7.0",
"@lodestar/utils": "^1.7.0",
"cross-fetch": "^3.1.4",
"eventsource": "^2.0.2",
"qs": "^6.11.1"
Expand Down
10 changes: 9 additions & 1 deletion packages/api/src/beacon/routes/events.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {Epoch, phase0, capella, Slot, ssz, StringType, RootHex, altair, UintNum64, allForks} from "@lodestar/types";
import {ContainerType} from "@chainsafe/ssz";
import {ChainForkConfig} from "@lodestar/config";
import {isForkExecution, ForkName} from "@lodestar/params";

import {RouteDef, TypeJson} from "../../utils/index.js";
import {RouteDef, TypeJson, WithVersion} from "../../utils/index.js";
import {HttpStatusCode} from "../../utils/client/httpStatusCode.js";
import {ApiClientResponse} from "../../interfaces.js";

Expand Down Expand Up @@ -36,6 +37,8 @@ export enum EventType {
lightClientFinalityUpdate = "light_client_finality_update",
/** New or better light client update available */
lightClientUpdate = "light_client_update",
/** Payload attributes for block proposal */
payloadAttributes = "payload_attributes",
}

export const eventTypes: {[K in EventType]: K} = {
Expand All @@ -50,6 +53,7 @@ export const eventTypes: {[K in EventType]: K} = {
[EventType.lightClientOptimisticUpdate]: EventType.lightClientOptimisticUpdate,
[EventType.lightClientFinalityUpdate]: EventType.lightClientFinalityUpdate,
[EventType.lightClientUpdate]: EventType.lightClientUpdate,
[EventType.payloadAttributes]: EventType.payloadAttributes,
};

export type EventData = {
Expand Down Expand Up @@ -90,6 +94,7 @@ export type EventData = {
[EventType.lightClientOptimisticUpdate]: allForks.LightClientOptimisticUpdate;
[EventType.lightClientFinalityUpdate]: allForks.LightClientFinalityUpdate;
[EventType.lightClientUpdate]: allForks.LightClientUpdate;
[EventType.payloadAttributes]: {version: ForkName; data: allForks.SSEPayloadAttributes};
};

export type BeaconEvent = {[K in EventType]: {type: K; message: EventData[K]}}[EventType];
Expand Down Expand Up @@ -182,6 +187,9 @@ export function getTypeByEvent(config: ChainForkConfig): {[K in EventType]: Type
),

[EventType.contributionAndProof]: ssz.altair.SignedContributionAndProof,
[EventType.payloadAttributes]: WithVersion((fork) =>
isForkExecution(fork) ? ssz.allForksExecution[fork].SSEPayloadAttributes : ssz.bellatrix.SSEPayloadAttributes
),

[EventType.lightClientOptimisticUpdate]: {
toJson: (data) =>
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ export function WithBlockValue<T extends {data: unknown}>(type: TypeJson<T>): Ty
}),
fromJson: ({block_value, ...data}: T & {block_value: string}) => ({
...type.fromJson(data),
blockValue: BigInt(block_value),
// For cross client usage where beacon or validator are of separate clients, blockValue could be missing
blockValue: BigInt(block_value ?? "0"),
}),
};
}
Expand Down
5 changes: 5 additions & 0 deletions packages/api/test/unit/beacon/testData/events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {ssz} from "@lodestar/types";
import {ForkName} from "@lodestar/params";
import {Api, EventData, EventType} from "../../../../src/beacon/routes/events.js";
import {GenericServerTestCases} from "../../../utils/genericServerTest.js";

Expand Down Expand Up @@ -104,4 +105,8 @@ export const eventTestData: EventData = {
signatureSlot: ssz.Slot.defaultValue(),
},
[EventType.lightClientUpdate]: ssz.altair.LightClientUpdate.defaultValue(),
[EventType.payloadAttributes]: {
version: ForkName.bellatrix,
data: ssz.bellatrix.SSEPayloadAttributes.defaultValue(),
},
};
2 changes: 1 addition & 1 deletion packages/api/test/unit/builder/builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("builder", () => {
/* eslint-disable @typescript-eslint/naming-convention */
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
EIP4844_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: 0,
}),
getClient,
getRoutes,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/test/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function getTestServer(): {baseUrl: string; server: FastifyInstance} {

const server = fastify({
ajv: {customOptions: {coerceTypes: "array"}},
querystringParser: (str) => qs.parse(str, {comma: true}),
querystringParser: (str) => qs.parse(str, {comma: true, parseArrays: false}),
});

server.addHook("onError", (request, reply, error, done) => {
Expand Down
26 changes: 13 additions & 13 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.6.0",
"version": "1.7.0",
"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.6.0",
"@lodestar/config": "^1.6.0",
"@lodestar/db": "^1.6.0",
"@lodestar/fork-choice": "^1.6.0",
"@lodestar/light-client": "^1.6.0",
"@lodestar/params": "^1.6.0",
"@lodestar/reqresp": "^1.6.0",
"@lodestar/state-transition": "^1.6.0",
"@lodestar/types": "^1.6.0",
"@lodestar/utils": "^1.6.0",
"@lodestar/validator": "^1.6.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",
"@multiformats/multiaddr": "^11.0.0",
"@types/datastore-level": "^3.0.0",
"buffer-xor": "^2.0.2",
Expand All @@ -145,7 +145,7 @@
"it-pipe": "^2.0.5",
"jwt-simple": "0.5.6",
"libp2p": "0.42.2",
"prom-client": "^14.1.0",
"prom-client": "^14.2.0",
"prometheus-gc-stats": "^0.6.3",
"qs": "^6.11.1",
"snappyjs": "^0.7.0",
Expand Down
17 changes: 11 additions & 6 deletions packages/beacon-node/src/api/rest/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ export class RestApiServer {
ajv: {customOptions: {coerceTypes: "array"}},
querystringParser: (str) =>
qs.parse(str, {
// defaults to 20 but Beacon API spec allows max items of 30
arrayLimit: 30,
// array as comma-separated values must be supported to be OpenAPI spec compliant
// Array as comma-separated values must be supported to be OpenAPI spec compliant
comma: true,
// default limit of 1000 seems unnecessarily high, let's reduce it a bit
parameterLimit: 100,
// Drop support for array query strings like `id[0]=1&id[1]=2&id[2]=3` as those are not required to
// be OpenAPI spec compliant and results are inconsistent, see https://github.com/ljharb/qs/issues/331.
// The schema validation will catch this and throw an error as parsed query string results in an object.
parseArrays: false,
}),
bodyLimit: opts.bodyLimit,
});
Expand Down Expand Up @@ -97,7 +97,12 @@ export class RestApiServer {
if (err instanceof ErrorAborted || err instanceof NodeIsSyncing) return;

const {operationId} = res.context.config as RouteConfig;
this.logger.error(`Req ${req.id} ${operationId} error`, {}, err);

if (err instanceof ApiError) {
this.logger.warn(`Req ${req.id} ${operationId} failed`, {reason: err.message});
} else {
this.logger.error(`Req ${req.id} ${operationId} error`, {}, err);
}
metrics?.errors.inc({operationId});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/chain/archiver/archiveBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function archiveBlocks(
const finalizedNonCanonicalBlocks = forkChoice.getAllNonAncestorBlocks(finalizedCheckpoint.rootHex);

// NOTE: The finalized block will be exactly the first block of `epoch` or previous
const finalizedPostDeneb = finalizedCheckpoint.epoch >= config.EIP4844_FORK_EPOCH;
const finalizedPostDeneb = finalizedCheckpoint.epoch >= config.DENEB_FORK_EPOCH;

const finalizedCanonicalBlockRoots: BlockRootSlot[] = finalizedCanonicalBlocks.map((block) => ({
slot: block.slot,
Expand Down Expand Up @@ -82,7 +82,7 @@ export async function archiveBlocks(
// Keep only `[max(GENESIS_EPOCH, current_epoch - MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS), current_epoch]`
if (finalizedPostDeneb) {
const blobsSidecarMinEpoch = currentEpoch - config.MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS;
if (blobsSidecarMinEpoch >= config.EIP4844_FORK_EPOCH) {
if (blobsSidecarMinEpoch >= config.DENEB_FORK_EPOCH) {
const slotsToDelete = await db.blobsSidecarArchive.keys({lt: computeStartSlotAtEpoch(blobsSidecarMinEpoch)});
if (slotsToDelete.length > 0) {
await db.blobsSidecarArchive.batchDelete(slotsToDelete);
Expand Down
1 change: 1 addition & 0 deletions packages/beacon-node/src/chain/lightClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ export class LightClientServer {
this.logger.debug("sync committee below required MIN_SYNC_COMMITTEE_PARTICIPANTS", {
syncPeriod,
attestedPeriod,
syncAggregateParticipation,
});
this.metrics?.lightclientServer.onSyncAggregate.inc({event: "ignore_sync_committee_low"});
return;
Expand Down
3 changes: 2 additions & 1 deletion packages/beacon-node/src/chain/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type BlockProcessOpts = {
* will still issue fcU for block proposal
*/
disableImportExecutionFcU?: boolean;
emitPayloadAttributes?: boolean;
};

export const defaultChainOptions: IChainOptions = {
Expand All @@ -52,9 +53,9 @@ export const defaultChainOptions: IChainOptions = {
disableBlsBatchVerify: false,
proposerBoostEnabled: true,
computeUnrealized: true,
countUnrealizedFull: false,
safeSlotsToImportOptimistically: SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY,
suggestedFeeRecipient: defaultValidatorOptions.suggestedFeeRecipient,
assertCorrectProgressiveBalances: false,
archiveStateEpochFrequency: 1024,
emitPayloadAttributes: false,
};
18 changes: 16 additions & 2 deletions packages/beacon-node/src/chain/prepareNextSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import {computeEpochAtSlot, isExecutionStateType, computeTimeAtSlot} from "@lode
import {ChainForkConfig} from "@lodestar/config";
import {ForkSeq, SLOTS_PER_EPOCH, ForkExecution} from "@lodestar/params";
import {Slot} from "@lodestar/types";
import {Logger, sleep} from "@lodestar/utils";
import {Logger, sleep, fromHex} from "@lodestar/utils";
import {routes} from "@lodestar/api";
import {GENESIS_SLOT, ZERO_HASH_HEX} from "../constants/constants.js";
import {Metrics} from "../metrics/index.js";
import {TransitionConfigurationV1} from "../execution/engine/interface.js";
import {ChainEvent} from "./emitter.js";
import {prepareExecutionPayload} from "./produceBlock/produceBlockBody.js";
import {prepareExecutionPayload, getPayloadAttributesForSSE} from "./produceBlock/produceBlockBody.js";
import {IBeaconChain} from "./interface.js";
import {RegenCaller} from "./regen/index.js";

Expand Down Expand Up @@ -156,6 +157,19 @@ export class PrepareNextSlotScheduler {
feeRecipient,
});
}

// If emitPayloadAttributes is true emit a SSE payloadAttributes event
if (this.chain.opts.emitPayloadAttributes === true) {
const data = await getPayloadAttributesForSSE(fork as ForkExecution, this.chain, {
prepareState,
prepareSlot,
parentBlockRoot: fromHex(headRoot),
// The likely consumers of this API are builders and will anyway ignore the
// feeRecipient, so just pass zero hash for now till a real use case arises
feeRecipient: "0x0000000000000000000000000000000000000000000000000000000000000000",
});
this.chain.emitter.emit(routes.events.EventType.payloadAttributes, {data, version: fork});
}
}
} catch (e) {
this.metrics?.precomputeNextEpochTransition.count.inc({result: "error"}, 1);
Expand Down
Loading

0 comments on commit a2c5100

Please sign in to comment.