From 7d662d7951db27edcee15fd7266bed322f0a3882 Mon Sep 17 00:00:00 2001 From: Cayman Date: Mon, 12 Dec 2022 10:05:55 -0500 Subject: [PATCH] Use node 18 (#4779) * Use node 18 * Add bigger timeouts * Add uint8array concat benchmark * increase timeouts * Debug e2e tests * Fix e2e tests, remove debug logs * "fix" types * "fix" types --- .github/workflows/benchmark.yml | 2 +- .github/workflows/docs.yml | 2 +- .github/workflows/publish-dev.yml | 2 +- .github/workflows/publish-rc.yml | 2 +- .github/workflows/publish-stable.yml | 2 +- .github/workflows/test-browser.yml | 2 +- .github/workflows/test-e2e.yml | 2 +- .github/workflows/test-sim-merge.yml | 2 +- .github/workflows/test-sim.yml | 2 +- .github/workflows/test-spec.yml | 2 +- .github/workflows/test.yml | 2 +- CONTRIBUTING.md | 2 +- Dockerfile | 6 +++--- README.md | 4 ++-- docs/install/source.md | 4 ++-- packages/beacon-node/src/network/network.ts | 2 +- packages/beacon-node/src/network/util.ts | 2 +- .../beacon-node/test/perf/util/bytes.test.ts | 17 ++++++++++++++++- packages/cli/test/e2e/runDevCmd.test.ts | 2 +- packages/cli/test/e2e/voluntaryExit.test.ts | 2 +- 20 files changed, 39 insertions(+), 24 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index cd192f05a51f..af2acd5f1a79 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: "lts/gallium" + node-version: 18 - name: Node.js version id: node run: echo "::set-output name=v8CppApiVersion::$(node --print "process.versions.modules")" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index dce273cdfd4c..b012f20cea54 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: "lts/gallium" + node-version: 18 - name: Node.js version id: node run: echo "::set-output name=v8CppApiVersion::$(node --print "process.versions.modules")" diff --git a/.github/workflows/publish-dev.yml b/.github/workflows/publish-dev.yml index 9edafec45e37..3741e4243d4c 100644 --- a/.github/workflows/publish-dev.yml +++ b/.github/workflows/publish-dev.yml @@ -20,7 +20,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-node@v2 with: - node-version: "lts/gallium" + node-version: 18 registry-url: "https://registry.npmjs.org" - name: Node.js version id: node diff --git a/.github/workflows/publish-rc.yml b/.github/workflows/publish-rc.yml index 58d6e9c753d3..1fb2a6062a29 100644 --- a/.github/workflows/publish-rc.yml +++ b/.github/workflows/publish-rc.yml @@ -54,7 +54,7 @@ jobs: fetch-depth: 0 # Needs full depth for changelog generation - uses: actions/setup-node@v2 with: - node-version: "lts/gallium" + node-version: 18 - name: Node.js version id: node run: echo "::set-output name=v8CppApiVersion::$(node --print "process.versions.modules")" diff --git a/.github/workflows/publish-stable.yml b/.github/workflows/publish-stable.yml index 423c5f2fd965..ed84193db986 100644 --- a/.github/workflows/publish-stable.yml +++ b/.github/workflows/publish-stable.yml @@ -60,7 +60,7 @@ jobs: fetch-depth: 0 # Needs full depth for changelog generation - uses: actions/setup-node@v2 with: - node-version: "lts/gallium" + node-version: 18 - name: Node.js version id: node run: echo "::set-output name=v8CppApiVersion::$(node --print "process.versions.modules")" diff --git a/.github/workflows/test-browser.yml b/.github/workflows/test-browser.yml index 0d4c70b18415..d60dfae76b66 100644 --- a/.github/workflows/test-browser.yml +++ b/.github/workflows/test-browser.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - node: [16] + node: [18] steps: # - Uses YAML anchors in the future - uses: actions/checkout@v2 diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 6c0eaf2abf9b..7150fbf114b7 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - node: [16] + node: [18] steps: # - Uses YAML anchors in the future - uses: actions/checkout@v2 diff --git a/.github/workflows/test-sim-merge.yml b/.github/workflows/test-sim-merge.yml index 3556127caa77..7cf5bff9cb08 100644 --- a/.github/workflows/test-sim-merge.yml +++ b/.github/workflows/test-sim-merge.yml @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: "lts/gallium" + node-version: 18 - name: Node.js version id: node run: echo "::set-output name=v8CppApiVersion::$(node --print "process.versions.modules")" diff --git a/.github/workflows/test-sim.yml b/.github/workflows/test-sim.yml index 7d5893c05d6e..3a7371f1280f 100644 --- a/.github/workflows/test-sim.yml +++ b/.github/workflows/test-sim.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: "lts/gallium" + node-version: 18 - name: Node.js version id: node run: echo "::set-output name=v8CppApiVersion::$(node --print "process.versions.modules")" diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index 8d5228869565..80d3331b7109 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: "lts/gallium" + node-version: 18 - name: Node.js version id: node run: echo "::set-output name=v8CppApiVersion::$(node --print "process.versions.modules")" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 97fec9f2c43d..7927ce9fb17f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - node: [16] + node: [18] steps: # - Uses YAML anchors in the future - uses: actions/checkout@v2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b54f99674f69..cbba10691559 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Thanks for your contribution to Lodestar. It's people like you that push the Eth ## Prerequisites -- :gear: [NodeJS](https://nodejs.org/) (LTS/Gallium) +- :gear: [NodeJS](https://nodejs.org/) (LTS) - :toolbox: [Yarn](https://yarnpkg.com/)/[Lerna](https://lerna.js.org/) ## Getting Started diff --git a/Dockerfile b/Dockerfile index 9cb0946be0b2..5b44cf476510 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # --platform=$BUILDPLATFORM is used build javascript source with host arch # Otherwise TS builds on emulated archs and can be extremely slow (+1h) -FROM --platform=${BUILDPLATFORM:-amd64} node:16-alpine as build_src +FROM --platform=${BUILDPLATFORM:-amd64} node:18-alpine as build_src ARG COMMIT WORKDIR /usr/app RUN apk update && apk add --no-cache g++ make python3 && rm -rf /var/cache/apk/* @@ -21,7 +21,7 @@ RUN cd packages/cli && GIT_COMMIT=${COMMIT} yarn write-git-data # Copy built src + node_modules to build native packages for archs different than host. # Note: This step is redundant for the host arch -FROM node:16-alpine as build_deps +FROM node:18-alpine as build_deps WORKDIR /usr/app RUN apk update && apk add --no-cache g++ make python3 && rm -rf /var/cache/apk/* @@ -34,7 +34,7 @@ RUN yarn install --non-interactive --frozen-lockfile --production --force # Copy built src + node_modules to a new layer to prune unnecessary fs # Previous layer weights 7.25GB, while this final 488MB (as of Oct 2020) -FROM node:16-alpine +FROM node:18-alpine WORKDIR /usr/app COPY --from=build_deps /usr/app . diff --git a/README.md b/README.md index 43bbdf7539ca..d2cdc884344e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![Eth Consensus Spec v1.1.10](https://img.shields.io/badge/ETH%20consensus--spec-1.1.10-blue)](https://github.com/ethereum/consensus-specs/releases/tag/v1.1.10) [![codecov](https://codecov.io/gh/ChainSafe/lodestar/branch/unstable/graph/badge.svg)](https://codecov.io/gh/ChainSafe/lodestar) ![ES Version](https://img.shields.io/badge/ES-2020-yellow) -![Node Version](https://img.shields.io/badge/node-16.x-green) +![Node Version](https://img.shields.io/badge/node-18.x-green) [![gitpoap badge](https://public-api.gitpoap.io/v1/repo/ChainSafe/lodestar/badge)](https://www.gitpoap.io/gh/ChainSafe/lodestar) [Lodestar](https://lodestar.chainsafe.io) is a TypeScript implementation of the [Ethereum Consensus specification](https://github.com/ethereum/consensus-specs) developed by [ChainSafe Systems](https://chainsafe.io). @@ -29,7 +29,7 @@ ## Prerequisites -- :gear: [NodeJS](https://nodejs.org/) (LTS/Gallium) +- :gear: [NodeJS](https://nodejs.org/) (LTS) - :toolbox: [Yarn](https://yarnpkg.com/)/[Lerna](https://lerna.js.org/) ###### Developer Quickstart: diff --git a/docs/install/source.md b/docs/install/source.md index 1daa251720e0..fd708e99d4af 100644 --- a/docs/install/source.md +++ b/docs/install/source.md @@ -1,10 +1,10 @@ # Install from source -Make sure to have [Yarn installed](https://classic.yarnpkg.com/en/docs/install). It is also recommended to [install NVM (Node Version Manager)](https://github.com/nvm-sh/nvm) and use v16 of [NodeJS](https://nodejs.org/en/). +Make sure to have [Yarn installed](https://classic.yarnpkg.com/en/docs/install). It is also recommended to [install NVM (Node Version Manager)](https://github.com/nvm-sh/nvm) and use v18 of [NodeJS](https://nodejs.org/en/). !!! info - NodeJS versions < 16.x are not supported by Lodestar. We currently recommend running NodeJS 16.x. + NodeJS versions < 16.x are not supported by Lodestar. We currently recommend running NodeJS 18.x. Clone the repo locally. diff --git a/packages/beacon-node/src/network/network.ts b/packages/beacon-node/src/network/network.ts index 1d5b28c0393a..387b3fd4b966 100644 --- a/packages/beacon-node/src/network/network.ts +++ b/packages/beacon-node/src/network/network.ts @@ -142,7 +142,7 @@ export class Network implements INetwork { await this.libp2p.start(); // Stop latency monitor since we handle disconnects here and don't want additional load on the event loop // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call - (this.libp2p.connectionManager as DefaultConnectionManager)["latencyMonitor"].stop(); + ((this.libp2p.connectionManager as unknown) as DefaultConnectionManager)["latencyMonitor"].stop(); // Network spec decides version changes based on clock fork, not head fork const forkCurrentSlot = this.config.getForkName(this.clock.currentSlot); diff --git a/packages/beacon-node/src/network/util.ts b/packages/beacon-node/src/network/util.ts index 6ab9ce890b42..5ae0b5bd7549 100644 --- a/packages/beacon-node/src/network/util.ts +++ b/packages/beacon-node/src/network/util.ts @@ -70,7 +70,7 @@ export function prettyPrintPeerId(peerId: PeerId): string { */ // Compat function for type mismatch reasons export function getConnectionsMap(connectionManager: ConnectionManager): Map { - return (connectionManager as DefaultConnectionManager)["connections"] as Map; + return ((connectionManager as unknown) as DefaultConnectionManager)["connections"] as Map; } export function getConnection(connectionManager: ConnectionManager, peerIdStr: string): Connection | undefined { diff --git a/packages/beacon-node/test/perf/util/bytes.test.ts b/packages/beacon-node/test/perf/util/bytes.test.ts index 537dd8470acf..bc3f6cb72e0d 100644 --- a/packages/beacon-node/test/perf/util/bytes.test.ts +++ b/packages/beacon-node/test/perf/util/bytes.test.ts @@ -17,6 +17,21 @@ describe("bytes utils", function () { fn: () => { Buffer.concat(buffers); }, - runsFactor: 1000, + }); + + itBench({ + id: `Uint8Array.set ${count} items`, + fn: () => { + let size = 0; + for (const b of buffers) { + size += b.length; + } + const arr = new Uint8Array(size); + let offset = 0; + for (const b of buffers) { + arr.set(b, offset); + offset += b.length; + } + }, }); }); diff --git a/packages/cli/test/e2e/runDevCmd.test.ts b/packages/cli/test/e2e/runDevCmd.test.ts index b9e2187b0dad..8fab64c1106a 100644 --- a/packages/cli/test/e2e/runDevCmd.test.ts +++ b/packages/cli/test/e2e/runDevCmd.test.ts @@ -23,7 +23,7 @@ describeCliTest("Run dev command", function ({spawnCli}) { } }); - const beaconUrl = `http://localhost:${beaconPort}`; + const beaconUrl = `http://127.0.0.1:${beaconPort}`; const client = getClient({baseUrl: beaconUrl}, {config}); // Wrap in retry since the API may not be listening yet diff --git a/packages/cli/test/e2e/voluntaryExit.test.ts b/packages/cli/test/e2e/voluntaryExit.test.ts index 35cc699629fd..477e3a5c7933 100644 --- a/packages/cli/test/e2e/voluntaryExit.test.ts +++ b/packages/cli/test/e2e/voluntaryExit.test.ts @@ -33,7 +33,7 @@ describeCliTest("voluntaryExit cmd", function ({spawnCli}) { } }); - const baseUrl = `http://localhost:${restPort}`; + const baseUrl = `http://127.0.0.1:${restPort}`; const client = getClient({baseUrl}, {config}); // Wait for beacon node API to be available + genesis