Skip to content

Commit

Permalink
build with custom ssz, to be undone later
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Sep 8, 2023
1 parent eada6b3 commit dd1e61d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
47 changes: 33 additions & 14 deletions 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
Expand All @@ -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

Expand All @@ -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"]
ENTRYPOINT ["node", "./packages/cli/bin/lodestar"]
1 change: 1 addition & 0 deletions packages/beacon-node/src/execution/engine/types.ts
Expand Up @@ -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};
Expand Down
3 changes: 2 additions & 1 deletion 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``.
Expand Down

0 comments on commit dd1e61d

Please sign in to comment.