Skip to content

Commit

Permalink
Address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain committed Sep 24, 2019
1 parent 62c8c24 commit a773f82
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 18 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ version: '2'
services:
prometheus:
image: prom/prometheus:v2.9.2
depends_on:
- lodestar
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
Expand Down
37 changes: 37 additions & 0 deletions docker/Dockerfile.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM node:10.16-alpine

WORKDIR /usr/app

RUN apk add --update git python make g++ linux-headers paxctl gcc && \
rm -rf /tmp/* /var/cache/apk/*

COPY lerna.json .
COPY package.json .
COPY packages/lodestar/package.json ./packages/lodestar/package.json
COPY yarn.lock .

RUN yarn install --frozen-lockfile && node_modules/.bin/lerna bootstrap && yarn cache clean

COPY . .

RUN node_modules/.bin/lerna run build

FROM node:10.16-alpine

RUN apk add --update git python make g++ linux-headers paxctl gcc && \
rm -rf /tmp/* /var/cache/apk/*

WORKDIR /app

COPY --from=0 /usr/app/packages/lodestar/lib /app/lib
COPY --from=0 /usr/app/packages/lodestar/bin /app/bin
COPY --from=0 /usr/app/packages/lodestar/package.json /app/package.json
COPY --from=0 /usr/app/yarn.lock /app/yarn.lock

RUN yarn install --frozen-lockfile --production && yarn cache clean && apk del git python g++ gcc make

RUN chown -R node: .

USER node

ENTRYPOINT ["/app/bin/lodestar"]
1 change: 0 additions & 1 deletion packages/lodestar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
"pull-pushable": "^2.2.0",
"pull-stream": "^3.6.13",
"qs": "^6.7.0",
"queue": "^6.0.1",
"snake-case": "^2.1.0",
"strict-event-emitter-types": "^2.0.0",
"varint": "^5.0.0",
Expand Down
5 changes: 0 additions & 5 deletions packages/lodestar/peerId.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/lodestar/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {IChainOptions} from "./options";
import {OpPool} from "../opPool";
import {Block} from "ethers/providers";
import fs from "fs";
import {sleep} from "../validator/services/attestation";
import {sleep} from "../util/sleep";
import {AsyncQueue, queue} from "async";
import FastPriorityQueue from "fastpriorityqueue";
import {getCurrentSlot} from "./stateTransition/util/genesis";
Expand Down
9 changes: 6 additions & 3 deletions packages/lodestar/src/interop/dump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import {quickStartState} from "./state";
import {ProgressiveMerkleTree} from "../util/merkleTree";
import {DEPOSIT_CONTRACT_TREE_DEPTH} from "../constants";

import yargs from "yargs";
const args = yargs.parse()._;

// This file runs the dump command:
// node -r ts-node/register src/interop/dump.ts genesisTime validatorCount outputFile

export function dumpQuickStartState(
genesisTime: number,
validatorCount: number,
Expand All @@ -17,7 +23,4 @@ export function dumpQuickStartState(
fs.writeFileSync(output, serialize(state, BeaconState));
}

// eslint-disable-next-line
import yargs from "yargs";
const args = yargs.parse()._;
dumpQuickStartState(parseInt(args[0]), parseInt(args[1]), args[2]);
2 changes: 1 addition & 1 deletion packages/lodestar/src/metrics/server/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class HttpMetricsServer implements IMetricsServer {

public async start(): Promise<void> {
if (this.opts.enabled) {
this.logger.info("Starting prometheus...");
this.logger.info(`Starting metrics HTTP server on port ${this.opts.serverPort}`);
await promisify(this.http.listen.bind(this.http))(this.opts.serverPort);
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/lodestar/src/util/sleep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function sleep(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}
5 changes: 1 addition & 4 deletions packages/lodestar/src/validator/services/attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ import {IRpcClient} from "../rpc";
import {DomainType} from "../../constants";
import {IValidatorDB} from "../../db/api";
import {ILogger} from "../../logger";
import {sleep} from "../../util/sleep";
import {Keypair} from "@chainsafe/bls";

export function sleep(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}

export class AttestationService {

private config: IBeaconConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ describe("produce block", function () {
return await assembleBlock(config, chainStub, dbStub, opPoolStub, eth1Stub, slot, randao);
});
const block = await blockProposingService.createAndPublishBlock(1, state.fork);
stateTransition(config, state, block, false)
//expect(() => stateTransition(config, state, block, false)).to.not.throw();
expect(() => stateTransition(config, state, block, false)).to.not.throw();
});

function getBlockProposingService(keypair: Keypair): BlockProposingService {
Expand Down
3 changes: 2 additions & 1 deletion packages/lodestar/test/e2e/network/network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {shardAttestationTopic} from "../../../src/network/util";
import {ILogger, WinstonLogger} from "../../../src/logger";
import {INetworkOptions} from "../../../src/network/options";
import {BeaconMetrics} from "../../../src/metrics";
import {sleep} from "../../../src/util/sleep";
import Libp2p from "libp2p";

const multiaddr = "/ip4/127.0.0.1/tcp/0";
Expand Down Expand Up @@ -63,7 +64,7 @@ describe("[network] network", function () {
new Promise((resolve) => netA.on("peer:disconnect", resolve)),
new Promise((resolve) => netB.on("peer:disconnect", resolve)),
]);
await new Promise(resolve => setTimeout(resolve, 100));
await sleep(100);

await netA.disconnect(netB.peerInfo);
await disconnection;
Expand Down

0 comments on commit a773f82

Please sign in to comment.