From dd1e61d4472189e7619d25e3c5f0a6cf4319bf0a Mon Sep 17 00:00:00 2001 From: harkamal Date: Fri, 8 Sep 2023 16:38:54 +0530 Subject: [PATCH] build with custom ssz, to be undone later --- Dockerfile | 47 +++++++++++++------ .../beacon-node/src/execution/engine/types.ts | 1 + .../src/utils/verifyMerkleBranch.ts | 3 +- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5a9541e06f1a..5f6328102544 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,35 @@ +FROM sitespeedio/node:ubuntu-22.04-nodejs-18.16.0 as build_ssz +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl +RUN apt-get install git g++ make python3 -y +WORKDIR /usr/app +RUN git clone --branch g11tech/optional-type https://github.com/ChainSafe/ssz.git +#RUN rm /usr/app/ssz/.dockerignore +WORKDIR /usr/app/ssz +RUN pwd +RUN ls -l +RUN git status +RUN corepack enable && yarn install --immutable +RUN yarn build + # --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:20-alpine as build_src +#FROM node:20-alpine ARG COMMIT -WORKDIR /usr/app -RUN apk update && apk add --no-cache g++ make python3 && rm -rf /var/cache/apk/* +RUN apk update && apk add --no-cache git g++ make python3 && rm -rf /var/cache/apk/* +WORKDIR /usr/app COPY . . -RUN yarn install --non-interactive --frozen-lockfile && \ - yarn build && \ - yarn install --non-interactive --frozen-lockfile --production - -# To have access to the specific branch and commit used to build this source, -# a git-data.json file is created by persisting git data at build time. Then, -# a version string like `v0.35.0-beta.0/HEAD/82219149 (git)` can be shown in -# the terminal and in the logs; which is very useful to track tests better. -RUN cd packages/cli && GIT_COMMIT=${COMMIT} yarn write-git-data - +RUN yarn install +RUN rm -rf /usr/app/node_modules/@chainsafe/ssz +COPY --from=build_ssz /usr/app/ssz/packages/ssz /usr/app/node_modules/@chainsafe/ssz +RUN rm -rf /usr/app/node_modules/@chainsafe/persistent-merkle-tree +COPY --from=build_ssz /usr/app/ssz/packages/persistent-merkle-tree /usr/app/node_modules/@chainsafe/persistent-merkle-tree +RUN yarn build # Copy built src + node_modules to build native packages for archs different than host. # Note: This step is redundant for the host arch @@ -30,6 +42,10 @@ COPY --from=build_src /usr/app . # Do yarn --force to trigger a rebuild of the native packages # Emmulates `yarn rebuild` which is not available in v1 https://yarnpkg.com/cli/rebuild RUN yarn install --non-interactive --frozen-lockfile --production --force +RUN rm -rf /usr/app/node_modules/@chainsafe/ssz +COPY --from=build_ssz /usr/app/ssz/packages/ssz /usr/app/node_modules/@chainsafe/ssz +RUN rm -rf /usr/app/node_modules/@chainsafe/persistent-merkle-tree +COPY --from=build_ssz /usr/app/ssz/packages/persistent-merkle-tree /usr/app/node_modules/@chainsafe/persistent-merkle-tree # Rebuild leveldb bindings (required for arm64 build) RUN cd node_modules/classic-level && yarn rebuild @@ -38,10 +54,13 @@ RUN cd node_modules/classic-level && yarn rebuild FROM node:20-alpine WORKDIR /usr/app COPY --from=build_deps /usr/app . - + # NodeJS applications have a default memory limit of 2.5GB. # This limit is bit tight for a Prater node, it is recommended to raise the limit # since memory may spike during certain network conditions. + + + ENV NODE_OPTIONS=--max-old-space-size=4096 -ENTRYPOINT ["node", "./packages/cli/bin/lodestar"] \ No newline at end of file +ENTRYPOINT ["node", "./packages/cli/bin/lodestar"] diff --git a/packages/beacon-node/src/execution/engine/types.ts b/packages/beacon-node/src/execution/engine/types.ts index 1110bf0436c4..e6da8a671530 100644 --- a/packages/beacon-node/src/execution/engine/types.ts +++ b/packages/beacon-node/src/execution/engine/types.ts @@ -284,6 +284,7 @@ export function parseExecutionPayload( const {executionWitness} = data; (executionPayload as verge.ExecutionPayload).executionWitness = ssz.verge.ExecutionWitness.fromJson(executionWitness); + console.log("parse executionPayload from EL",{executionWitness,blockNumber:data.blockNumber}) } return {executionPayload, blockValue, blobsBundle}; diff --git a/packages/light-client/src/utils/verifyMerkleBranch.ts b/packages/light-client/src/utils/verifyMerkleBranch.ts index 7cdf673aaf87..2df196ad5fd6 100644 --- a/packages/light-client/src/utils/verifyMerkleBranch.ts +++ b/packages/light-client/src/utils/verifyMerkleBranch.ts @@ -1,9 +1,10 @@ import {byteArrayEquals} from "@chainsafe/ssz"; -import {hash} from "@chainsafe/persistent-merkle-tree"; +import {hasher} from "@chainsafe/persistent-merkle-tree"; export const SYNC_COMMITTEES_DEPTH = 4; export const SYNC_COMMITTEES_INDEX = 11; +const hash = hasher.digest64 /** * Verify that the given ``leaf`` is on the merkle branch ``proof`` * starting with the given ``root``.