Skip to content

Commit

Permalink
chore: release v1.20.1 (#6955)
Browse files Browse the repository at this point in the history
  • Loading branch information
philknows authored Jul 16, 2024
2 parents 27b9c03 + c1877bf commit 3859741
Show file tree
Hide file tree
Showing 25 changed files with 143 additions and 103 deletions.
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",
"useNx": true,
"version": "1.20.0",
"version": "1.20.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.20.0",
"version": "1.20.1",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -72,10 +72,10 @@
"dependencies": {
"@chainsafe/persistent-merkle-tree": "^0.7.1",
"@chainsafe/ssz": "^0.15.1",
"@lodestar/config": "^1.20.0",
"@lodestar/params": "^1.20.0",
"@lodestar/types": "^1.20.0",
"@lodestar/utils": "^1.20.0",
"@lodestar/config": "^1.20.1",
"@lodestar/params": "^1.20.1",
"@lodestar/types": "^1.20.1",
"@lodestar/utils": "^1.20.1",
"eventsource": "^2.0.2",
"qs": "^6.11.1"
},
Expand Down
13 changes: 12 additions & 1 deletion packages/api/src/utils/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ export enum HttpHeader {
ContentType = "content-type",
Accept = "accept",
Authorization = "authorization",
/**
* Used to indicate which response headers should be made available to
* scripts running in the browser, in response to a cross-origin request.
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
*/
ExposeHeaders = "access-control-expose-headers",
}

export enum MediaType {
Expand Down Expand Up @@ -44,7 +50,12 @@ export function parseAcceptHeader(accept?: string, supported = SUPPORTED_MEDIA_T
// Normalize here, using 1 as the default qvalue
const quality = current.includes(";") ? current.split(";") : [current, "q=1"];

const mediaType = quality[0].trim();
let mediaType = quality[0].trim();

if (mediaType === "*/*") {
// Default to json if all media types are accepted
mediaType = MediaType.json;
}

// If the mime type isn't acceptable, move on to the next entry
if (!isSupportedMediaType(mediaType, supported)) {
Expand Down
7 changes: 7 additions & 0 deletions packages/api/src/utils/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {StringType, ssz, stringType} from "@lodestar/types";
import {ResponseMetadataCodec} from "./types.js";
import {toBoolean} from "./serdes.js";
import {toForkName} from "./fork.js";
import {HttpHeader} from "./headers.js";

export const VersionType = new ContainerType({
/**
Expand Down Expand Up @@ -90,6 +91,7 @@ export const ExecutionOptimisticCodec: ResponseMetadataCodec<ExecutionOptimistic
fromJson: (val) => ExecutionOptimisticType.fromJson(val),
toHeadersObject: (val) => ({
[MetaHeader.ExecutionOptimistic]: val.executionOptimistic.toString(),
[HttpHeader.ExposeHeaders]: MetaHeader.ExecutionOptimistic,
}),
fromHeaders: (headers) => ({
executionOptimistic: toBoolean(headers.getOrDefault(MetaHeader.ExecutionOptimistic, "false")),
Expand All @@ -101,6 +103,7 @@ export const VersionCodec: ResponseMetadataCodec<VersionMeta> = {
fromJson: (val) => VersionType.fromJson(val),
toHeadersObject: (val) => ({
[MetaHeader.Version]: val.version,
[HttpHeader.ExposeHeaders]: MetaHeader.Version,
}),
fromHeaders: (headers) => ({
version: toForkName(headers.getRequired(MetaHeader.Version)),
Expand All @@ -113,6 +116,7 @@ export const ExecutionOptimisticAndVersionCodec: ResponseMetadataCodec<Execution
toHeadersObject: (val) => ({
[MetaHeader.ExecutionOptimistic]: val.executionOptimistic.toString(),
[MetaHeader.Version]: val.version,
[HttpHeader.ExposeHeaders]: [MetaHeader.ExecutionOptimistic, MetaHeader.Version].toString(),
}),
fromHeaders: (headers) => ({
executionOptimistic: toBoolean(headers.getOrDefault(MetaHeader.ExecutionOptimistic, "false")),
Expand All @@ -126,6 +130,7 @@ export const ExecutionOptimisticAndFinalizedCodec: ResponseMetadataCodec<Executi
toHeadersObject: (val) => ({
[MetaHeader.ExecutionOptimistic]: val.executionOptimistic.toString(),
[MetaHeader.Finalized]: val.finalized.toString(),
[HttpHeader.ExposeHeaders]: [MetaHeader.ExecutionOptimistic, MetaHeader.Finalized].toString(),
}),
fromHeaders: (headers) => ({
executionOptimistic: toBoolean(headers.getOrDefault(MetaHeader.ExecutionOptimistic, "false")),
Expand All @@ -141,6 +146,7 @@ export const ExecutionOptimisticFinalizedAndVersionCodec: ResponseMetadataCodec<
[MetaHeader.ExecutionOptimistic]: val.executionOptimistic.toString(),
[MetaHeader.Finalized]: val.finalized.toString(),
[MetaHeader.Version]: val.version,
[HttpHeader.ExposeHeaders]: [MetaHeader.ExecutionOptimistic, MetaHeader.Finalized, MetaHeader.Version].toString(),
}),
fromHeaders: (headers) => ({
executionOptimistic: toBoolean(headers.getOrDefault(MetaHeader.ExecutionOptimistic, "false")),
Expand All @@ -156,6 +162,7 @@ export const ExecutionOptimisticAndDependentRootCodec: ResponseMetadataCodec<Exe
toHeadersObject: (val) => ({
[MetaHeader.ExecutionOptimistic]: val.executionOptimistic.toString(),
[MetaHeader.DependentRoot]: val.dependentRoot,
[HttpHeader.ExposeHeaders]: [MetaHeader.ExecutionOptimistic, MetaHeader.DependentRoot].toString(),
}),
fromHeaders: (headers) => ({
executionOptimistic: toBoolean(headers.getOrDefault(MetaHeader.ExecutionOptimistic, "false")),
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/utils/server/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function createFastifyHandler<E extends Endpoint>(
if (definition.resp.isEmpty) {
// Ignore Accept header, the response will be sent without body
responseMediaType = null;
} else if (acceptHeader === undefined || acceptHeader === "*/*") {
} else if (acceptHeader === undefined) {
// Default to json to not force user to set header, e.g. when using curl
responseMediaType = MediaType.json;
} else {
Expand Down
10 changes: 9 additions & 1 deletion packages/api/test/unit/utils/headers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ describe("utils / headers", () => {
describe("parseAcceptHeader", () => {
const testCases: {header: string | undefined; expected: MediaType | null}[] = [
{header: undefined, expected: null},
{header: "*/*", expected: null},
{header: "*/*", expected: MediaType.json},
{header: "application/json", expected: MediaType.json},
{header: "application/octet-stream", expected: MediaType.ssz},
{header: "application/invalid", expected: null},
{header: "application/invalid;q=1,application/octet-stream;q=0.1", expected: MediaType.ssz},
{header: "application/octet-stream;q=0.5,application/json;q=1", expected: MediaType.json},
{header: "application/octet-stream;q=1,application/json;q=0.1", expected: MediaType.ssz},
{header: "application/octet-stream;q=1,application/json;q=0.9", expected: MediaType.ssz},
{header: "application/octet-stream;q=1,*/*;q=0.9", expected: MediaType.ssz},
{header: "application/octet-stream,application/json;q=0.1", expected: MediaType.ssz},
{header: "application/octet-stream;,application/json;q=0.1", expected: MediaType.json},
{header: "application/octet-stream;q=2,application/json;q=0.1", expected: MediaType.json},
Expand All @@ -20,6 +22,12 @@ describe("utils / headers", () => {
{header: "application/octet-stream ; q=0.5 , application/json ; q=1", expected: MediaType.json},
{header: "application/octet-stream ; q=1 , application/json ; q=0.1", expected: MediaType.ssz},
{header: "application/octet-stream;q=1,application/json;q=0.1", expected: MediaType.ssz},
{
// Default Accept header set by chrome browser
header:
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
expected: MediaType.json,
},

// The implementation is order dependent, however, RFC-9110 doesn't specify a preference.
// The following tests serve to document the behavior at the time of implementation- not a
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.20.0",
"version": "1.20.1",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -120,18 +120,18 @@
"@libp2p/peer-id-factory": "^4.1.0",
"@libp2p/prometheus-metrics": "^3.0.21",
"@libp2p/tcp": "9.0.23",
"@lodestar/api": "^1.20.0",
"@lodestar/config": "^1.20.0",
"@lodestar/db": "^1.20.0",
"@lodestar/fork-choice": "^1.20.0",
"@lodestar/light-client": "^1.20.0",
"@lodestar/logger": "^1.20.0",
"@lodestar/params": "^1.20.0",
"@lodestar/reqresp": "^1.20.0",
"@lodestar/state-transition": "^1.20.0",
"@lodestar/types": "^1.20.0",
"@lodestar/utils": "^1.20.0",
"@lodestar/validator": "^1.20.0",
"@lodestar/api": "^1.20.1",
"@lodestar/config": "^1.20.1",
"@lodestar/db": "^1.20.1",
"@lodestar/fork-choice": "^1.20.1",
"@lodestar/light-client": "^1.20.1",
"@lodestar/logger": "^1.20.1",
"@lodestar/params": "^1.20.1",
"@lodestar/reqresp": "^1.20.1",
"@lodestar/state-transition": "^1.20.1",
"@lodestar/types": "^1.20.1",
"@lodestar/utils": "^1.20.1",
"@lodestar/validator": "^1.20.1",
"@multiformats/multiaddr": "^12.1.3",
"c-kzg": "^2.1.2",
"datastore-core": "^9.1.1",
Expand Down
12 changes: 12 additions & 0 deletions packages/beacon-node/src/api/rest/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ export class RestApiServer {
const operationId = getOperationId(req);
this.logger.debug(`Req ${req.id} ${req.ip} ${operationId}`);
metrics?.requests.inc({operationId});

// Workaround to fix compatibility with go-eth2-client
// See https://github.com/attestantio/go-eth2-client/issues/144
if (
// go-eth2-client supports handling SSZ data in response for these endpoints
!["produceBlindedBlock", "produceBlockV3", "getBlockV2", "getStateV2"].includes(operationId) &&
// Only Vouch seems to override default header
["go-eth2-client", "Go-http-client", "Vouch"].includes(req.headers["user-agent"]?.split("/")[0] ?? "")
) {
// Override Accept header to force server to return JSON
req.headers.accept = "application/json";
}
});

server.addHook("preHandler", async (req, _res) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {describe, it, beforeEach, afterEach, expect} from "vitest";
import bls from "@chainsafe/bls";
import {createBeaconConfig, ChainConfig} from "@lodestar/config";
import {chainConfig as chainConfigDef} from "@lodestar/config/default";
import {getClient, routes} from "@lodestar/api";
import {getClient, HttpHeader, routes} from "@lodestar/api";
import {sleep} from "@lodestar/utils";
import {ForkName, SYNC_COMMITTEE_SIZE} from "@lodestar/params";
import {Validator} from "@lodestar/validator";
Expand Down Expand Up @@ -102,6 +102,8 @@ describe("lightclient api", function () {
expect(update.attestedHeader.beacon.slot).toBe(slot - 1);
// version is set
expect(res.meta().version).toBe(ForkName.altair);
// Ensure version header is made available to scripts running in the browser
expect(res.headers.get(HttpHeader.ExposeHeaders)?.includes("Eth-Consensus-Version")).toBe(true);
});

it.skip("getLightClientFinalityUpdate()", async function () {
Expand Down
26 changes: 13 additions & 13 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chainsafe/lodestar",
"version": "1.20.0",
"version": "1.20.1",
"description": "Command line interface for lodestar",
"author": "ChainSafe Systems",
"license": "LGPL-3.0",
Expand Down Expand Up @@ -63,17 +63,17 @@
"@libp2p/crypto": "^4.1.0",
"@libp2p/peer-id": "^4.1.0",
"@libp2p/peer-id-factory": "^4.1.0",
"@lodestar/api": "^1.20.0",
"@lodestar/beacon-node": "^1.20.0",
"@lodestar/config": "^1.20.0",
"@lodestar/db": "^1.20.0",
"@lodestar/light-client": "^1.20.0",
"@lodestar/logger": "^1.20.0",
"@lodestar/params": "^1.20.0",
"@lodestar/state-transition": "^1.20.0",
"@lodestar/types": "^1.20.0",
"@lodestar/utils": "^1.20.0",
"@lodestar/validator": "^1.20.0",
"@lodestar/api": "^1.20.1",
"@lodestar/beacon-node": "^1.20.1",
"@lodestar/config": "^1.20.1",
"@lodestar/db": "^1.20.1",
"@lodestar/light-client": "^1.20.1",
"@lodestar/logger": "^1.20.1",
"@lodestar/params": "^1.20.1",
"@lodestar/state-transition": "^1.20.1",
"@lodestar/types": "^1.20.1",
"@lodestar/utils": "^1.20.1",
"@lodestar/validator": "^1.20.1",
"@multiformats/multiaddr": "^12.1.3",
"deepmerge": "^4.3.1",
"ethers": "^6.7.0",
Expand All @@ -89,7 +89,7 @@
"yargs": "^17.7.1"
},
"devDependencies": {
"@lodestar/test-utils": "^1.20.0",
"@lodestar/test-utils": "^1.20.1",
"@types/debug": "^4.1.7",
"@types/got": "^9.6.12",
"@types/inquirer": "^9.0.3",
Expand Down
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.20.0",
"version": "1.20.1",
"description": "Chain configuration required for lodestar",
"author": "ChainSafe Systems",
"license": "Apache-2.0",
Expand Down Expand Up @@ -65,7 +65,7 @@
],
"dependencies": {
"@chainsafe/ssz": "^0.15.1",
"@lodestar/params": "^1.20.0",
"@lodestar/types": "^1.20.0"
"@lodestar/params": "^1.20.1",
"@lodestar/types": "^1.20.1"
}
}
8 changes: 4 additions & 4 deletions packages/db/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lodestar/db",
"version": "1.20.0",
"version": "1.20.1",
"description": "DB modules of Lodestar",
"author": "ChainSafe Systems",
"homepage": "https://github.com/ChainSafe/lodestar#readme",
Expand Down Expand Up @@ -36,12 +36,12 @@
},
"dependencies": {
"@chainsafe/ssz": "^0.15.1",
"@lodestar/config": "^1.20.0",
"@lodestar/utils": "^1.20.0",
"@lodestar/config": "^1.20.1",
"@lodestar/utils": "^1.20.1",
"classic-level": "^1.4.1",
"it-all": "^3.0.4"
},
"devDependencies": {
"@lodestar/logger": "^1.20.0"
"@lodestar/logger": "^1.20.1"
}
}
14 changes: 7 additions & 7 deletions packages/flare/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lodestar/flare",
"version": "1.20.0",
"version": "1.20.1",
"description": "Beacon chain debugging tool",
"author": "ChainSafe Systems",
"license": "Apache-2.0",
Expand Down Expand Up @@ -60,12 +60,12 @@
"dependencies": {
"@chainsafe/bls": "7.1.3",
"@chainsafe/bls-keygen": "^0.4.0",
"@lodestar/api": "^1.20.0",
"@lodestar/config": "^1.20.0",
"@lodestar/params": "^1.20.0",
"@lodestar/state-transition": "^1.20.0",
"@lodestar/types": "^1.20.0",
"@lodestar/utils": "^1.20.0",
"@lodestar/api": "^1.20.1",
"@lodestar/config": "^1.20.1",
"@lodestar/params": "^1.20.1",
"@lodestar/state-transition": "^1.20.1",
"@lodestar/types": "^1.20.1",
"@lodestar/utils": "^1.20.1",
"source-map-support": "^0.5.21",
"yargs": "^17.7.1"
},
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.20.0",
"version": "1.20.1",
"type": "module",
"exports": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand All @@ -37,11 +37,11 @@
},
"dependencies": {
"@chainsafe/ssz": "^0.15.1",
"@lodestar/config": "^1.20.0",
"@lodestar/params": "^1.20.0",
"@lodestar/state-transition": "^1.20.0",
"@lodestar/types": "^1.20.0",
"@lodestar/utils": "^1.20.0"
"@lodestar/config": "^1.20.1",
"@lodestar/params": "^1.20.1",
"@lodestar/state-transition": "^1.20.1",
"@lodestar/types": "^1.20.1",
"@lodestar/utils": "^1.20.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.20.0",
"version": "1.20.1",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -76,11 +76,11 @@
"@chainsafe/bls": "7.1.3",
"@chainsafe/persistent-merkle-tree": "^0.7.1",
"@chainsafe/ssz": "^0.15.1",
"@lodestar/api": "^1.20.0",
"@lodestar/config": "^1.20.0",
"@lodestar/params": "^1.20.0",
"@lodestar/types": "^1.20.0",
"@lodestar/utils": "^1.20.0",
"@lodestar/api": "^1.20.1",
"@lodestar/config": "^1.20.1",
"@lodestar/params": "^1.20.1",
"@lodestar/types": "^1.20.1",
"@lodestar/utils": "^1.20.1",
"mitt": "^3.0.0"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 3859741

Please sign in to comment.