Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi client 👨‍🦯 #565

Merged
merged 36 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e45a6c5
implement prysm beacon node select
BeroBurny Apr 2, 2021
705d8ae
implement prysm local testnet
BeroBurny Apr 2, 2021
e44380a
Merge branch 'develop' into beroburny/prysm-beacon
BeroBurny Apr 9, 2021
9056814
fix missing parts after sync
BeroBurny Apr 9, 2021
63c6f69
add nimbus testnet
mpetrunic Apr 15, 2021
9481486
cleanup
mpetrunic Apr 15, 2021
da520e3
save prysm
BeroBurny May 20, 2021
d690515
nimbus step1
BeroBurny May 25, 2021
c9bffda
sad commit :sad:
BeroBurny May 26, 2021
3beeb7c
Merge branch 'beroburny/prysm-beacon' into beroburnt/multi-client
BeroBurny May 26, 2021
3b951bc
update teku version
BeroBurny May 27, 2021
e25e0ae
update lighthouse testnet scripts
BeroBurny May 27, 2021
a6b75bf
update script
BeroBurny May 31, 2021
8d2ff45
update lighthouse
BeroBurny May 31, 2021
3027499
eth1 ?!?
BeroBurny Jun 1, 2021
b5677d5
implement get validator prysm
BeroBurny Jun 2, 2021
5a7bccd
implement prysm getAttesterDuties and getProposerDuties
BeroBurny Jun 2, 2021
80b7905
refactor types
BeroBurny Jun 4, 2021
495801e
implement additional prysm endpoints
BeroBurny Jun 7, 2021
50cdd36
prysm code improvements
BeroBurny Jun 7, 2021
f9a6f01
remove unused code
BeroBurny Jun 7, 2021
470d73d
fix prysm produceBlock
BeroBurny Jun 7, 2021
cb0eec2
refactor mapper
BeroBurny Jun 8, 2021
5d667b0
prysm fix and refactor
BeroBurny Jun 8, 2021
e88d0eb
fix prysm AggregateAndProofs
BeroBurny Jun 9, 2021
1fa7f1d
prysm improvements
BeroBurny Jun 9, 2021
53f6523
prysm improvements
BeroBurny Jun 10, 2021
f518869
refactor prysm to work with 1.3.11
BeroBurny Jun 21, 2021
c7d1393
update nimbus version
BeroBurny Jun 23, 2021
4d8cb05
nin prepareBeaconCommitteeSubnet
BeroBurny Jun 23, 2021
03ed6f0
implement nimbus events
BeroBurny Jun 24, 2021
e6b066b
implement nimbus in CG
BeroBurny Jun 24, 2021
81e2c0a
implement nimbus events error handling
BeroBurny Jun 24, 2021
f72fe31
fix watchOnHead saga
BeroBurny Jun 25, 2021
dd5e27b
fix type
BeroBurny Jun 25, 2021
d55c8d4
fix
BeroBurny Jun 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ SENTRY_DSN=https://[email protected]/yyyyyyy
SENTRY_ORG=nodefactory
SENTRY_PROJECT=chainguardian
SENTRY_AUTH_TOKEN=xxx
DOCKER_LIGHTHOUSE_IMAGE=sigp/lighthouse:v1.1.1
DOCKER_TEKU_IMAGE=consensys/teku:21.3.2
DOCKER_LIGHTHOUSE_IMAGE=sigp/lighthouse:v1.3.0
DOCKER_TEKU_IMAGE=consensys/teku:21.5
DOCKER_PRYSM_IMAGE=gcr.io/prysmaticlabs/prysm/beacon-chain:v1.3.3
DOCKER_PRYSM_VALIDATOR_IMAGE=gcr.io/prysmaticlabs/prysm/validator:v1.3.3
DOCKER_NIMBUS_IMAGE=statusim/nimbus-eth2:amd64-v1.3.0
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ coverage
*.log
package-lock.json
*.db
/eth2_testnet/genesis.ssz
.tmp
*.sqlite*
1 change: 1 addition & 0 deletions integration/nimbus-keystore.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"crypto":{"kdf":{"function":"pbkdf2","params":{"dklen":32,"c":262144,"prf":"hmac-sha256","salt":"394aa7bf7b8543bec9328678fabbb82b1d88b651a1629992c596011c87035ee0"},"message":""},"checksum":{"function":"sha256","params":{},"message":"4e1093d856e9cfa77b2ef37e49d96e248aa2b88be51c542a1a5c295f97eb30c2"},"cipher":{"function":"aes-128-ctr","params":{"iv":"8fa9958ef656695f12e3999d869d291e"},"message":"5869a4b6f5bab27676d6212737afbdedf5823ecb522ea88a72322c50a2f4c392"}},"description":"","pubkey":"8309a5281dd43297a3eccc1e70553831ec4dbf6a0b5b38fc910b49fb4eecf37075c90269443fd5fc6b8cad701e3eec53","path":"m/12381/3600/29/0/0","uuid":"97ee5497-09d8-489b-af81-e060358f5d5c","version":4}
38 changes: 38 additions & 0 deletions integration/nimbus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import assert from "assert";
import {restValidation} from "./restValidation";
import {config} from "@chainsafe/lodestar-config/lib/presets/mainnet";
import {CgNimbusEth2Api} from "../src/renderer/services/eth2/client/module";
import {SecretKey} from "@chainsafe/bls";
import {Keystore} from "@chainsafe/bls-keystore";

import keystore from "./nimbus-keystore.json";
const keystorePassword = "4E015C5AF6C9610B0230DBC4FD9714B786F24A28414E49C52D85950E1ED23AD8";

(async function (): Promise<void> {
const {proposer, attestation} = await restValidation({
baseUrl: "http://localhost:5052",
getValidatorPrivateKey: async () =>
SecretKey.fromBytes(await Keystore.fromObject(keystore).decrypt(keystorePassword)),
limit: 5,
config,
ApiClient: CgNimbusEth2Api,
});

console.log("\n\n\n");
let isFailed = false;
try {
assert.equal(proposer.proposed, proposer.delegated);
console.info(`Successfully proposed all ${proposer.delegated} blocks`);
} catch (e) {
console.error("Proposals", e.message);
isFailed = true;
}
try {
assert.equal(attestation.attestations, attestation.delegated);
console.info(`Successfully provide all ${proposer.delegated} attestations`);
} catch (e) {
console.error("Attestations", e.message);
isFailed = true;
}
process.exit(Number(isFailed));
})();
33 changes: 33 additions & 0 deletions integration/prysm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {getInteropKey} from "../src/renderer/services/validator/interop_keys";
import assert from "assert";
import {restValidation} from "./restValidation";
import {config} from "@chainsafe/lodestar-config/lib/presets/mainnet";
import {CgPrysmEth2Api} from "../src/renderer/services/eth2/client/module";

(async function (): Promise<void> {
const {proposer, attestation} = await restValidation({
baseUrl: "http://localhost:5050",
getValidatorPrivateKey: async () => getInteropKey(7),
limit: 5,
config,
ApiClient: CgPrysmEth2Api,
});

console.log("\n\n\n");
let isFailed = false;
try {
assert.equal(proposer.proposed, proposer.delegated);
console.info(`Successfully proposed all ${proposer.delegated} blocks`);
} catch (e) {
console.error("Proposals", e.message);
isFailed = true;
}
try {
assert.equal(attestation.attestations, attestation.delegated);
console.info(`Successfully provide all ${proposer.delegated} attestations`);
} catch (e) {
console.error("Attestations", e.message);
isFailed = true;
}
process.exit(Number(isFailed));
})();
13 changes: 13 additions & 0 deletions nimbus-testnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.4"

services:
beacon_node:
image: "${DOCKER_NIMBUS_IMAGE:-statusim/nimbus-eth2:amd64-v1.3.0}"
container_name: "eth2_testnet_beacon_nimbus"
entrypoint: "/bin/bash"
ports:
- "9190:9190"
- "5052:5052"
volumes:
- ./testnet/nimbus:/tmp/scripts
command: /tmp/scripts/run_local_testnet.sh --reuse-existing-data-dir --data-dir /tmp/scripts --disable-vc --nodes 1
16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,21 @@
"storybook": "start-storybook -p 6006",
"codecov": "codecov",
"script": "node -r ts-node/register",
"generate:validators": "yarn run script scripts/generate_interop_validators.ts",
"testnet:dev": "./testnet/lighthouse/reset_genesis_time.sh && docker-compose -f lighthouse-testnet.yml up",
"build-storybook": "build-storybook",
"generate:validators": "yarn run script scripts/generate_interop_validators.ts",
"testnet:lighthouse": "docker-compose -f lighthouse-testnet.yml up",
"testnet:lighthouse:down": "docker-compose -f lighthouse-testnet.yml down",
"testnet:lighthouse:reset-genesis": "cd ./testnet/lighthouse && ./reset_genesis_time.sh",
"testnet:teku": "docker-compose -f teku-testnet.yml up",
"testnet:teku:down": "docker-compose -f teku-testnet.yml down",
"testnet:nimbus": "docker-compose -f nimbus-testnet.yml up",
"testnet:nimbus:down": "docker-compose -f nimbus-testnet.yml down",
"testnet:prysm": "docker-compose -f prysm-testnet.yml up",
"testnet:prysm:down": "docker-compose -f prysm-testnet.yml down",
"integration:lighthouse": "yarn run script integration/lighthouse.ts",
"integration:teku": "yarn run script integration/teku.ts.ts"
"integration:teku": "yarn run script integration/teku.ts",
"integration:prysm": "yarn run script integration/prysm.ts",
"integration:nimbus": "yarn run script integration/nimbus.ts"
},
"jest": {
"transform": {
Expand Down
41 changes: 41 additions & 0 deletions prysm-testnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.6'

services:
prysm_beacon:
image: "${DOCKER_PRYSM_IMAGE:-gcr.io/prysmaticlabs/prysm/beacon-chain:v1.3.5}"
container_name: "eth2_testnet_prysm_beacon"
volumes:
- ./testnet/prysm/data:/data
ports:
- '5050:5050'
- '4000:4000'
- '13000:13000'
- '12000:12000'
network_mode: "host"
env_file: ./testnet/prysm/vars.env
command: >
--accept-terms-of-use
--disable-monitoring
--force-clear-db
--datadir=/data
--grpc-gateway-port=5050
--min-sync-peers=0
--bootstrap-node=
--disable-sync
--interop-genesis-state /data/genesis.ssz
--interop-eth1data-votes

prysm_validator:
image: "${DOCKER_PRYSM_VALIDATOR_IMAGE:-gcr.io/prysmaticlabs/prysm/validator:v1.3.5}"
container_name: "eth2_testnet_prysm_validator"
volumes:
- ./testnet/prysm/data:/data
network_mode: "host"
env_file: ./testnet/prysm/vars.env
command: >
--accept-terms-of-use
--disable-monitoring
--force-clear-db
--datadir=/data
--interop-start-index=0
--interop-num-validators=15
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface IConfigureBNProps {
clientName?: string;
}

const clients = ["teku", "lighthouse"];
const clients = ["prysm", "teku", "lighthouse"];
BeroBurny marked this conversation as resolved.
Show resolved Hide resolved

export const ConfigureBeaconNode: React.FunctionComponent<IConfigureBNProps> = (props: IConfigureBNProps) => {
// TODO: refactor to use list from src/renderer/services/eth2/networks/index.ts
Expand Down
13 changes: 6 additions & 7 deletions src/renderer/ducks/beacon/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,20 @@ function* startLocalBeaconSaga({
if (pullSuccess) {
yield put(
addBeacon(`http://localhost:${rpcPort}`, network, {
id: (yield call(
BeaconChain.startBeaconChain,
SupportedNetworks.LOCALHOST,
getClientParams(ports, {
id: (yield call(BeaconChain.startBeaconChain, SupportedNetworks.LOCALHOST, {
...getClientParams({
network,
libp2pPort,
discoveryPort,
rpcPort,
client,
memory,
eth1Url,
chainDataDir,
image,
}),
)).getParams().name,
memory,
ports,
image,
})).getParams().name,
network,
chainDataDir,
eth1Url,
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/ducks/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ if (typeof module.hot !== "undefined") {
);
}

(window as any).store = store;

export default store;
2 changes: 1 addition & 1 deletion src/renderer/services/docker/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {cgLogger} from "../../../main/logger";
export class BeaconChain extends Container {
public static async startBeaconChain(
network: SupportedNetworks,
params: Partial<Exclude<IDockerRunParams, "name">> = {},
params: Partial<Omit<IDockerRunParams, "name">> = {},
waitUntilReady = false,
): Promise<BeaconChain> {
const imageName = BeaconChain.getContainerName(network);
Expand Down
36 changes: 27 additions & 9 deletions src/renderer/services/docker/getClientParams.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
import {DockerPort, IDockerRunParams} from "./type";
import {IDockerRunParams} from "./type";
import {IConfigureBNSubmitOptions} from "../../components/ConfigureBeaconNode/ConfigureBeaconNode";

export const getClientParams = (
ports: DockerPort[],
{network, libp2pPort, discoveryPort, rpcPort, eth1Url, chainDataDir, client, memory}: IConfigureBNSubmitOptions,
): Partial<Exclude<IDockerRunParams, "name">> => {
export const getClientParams = ({
network,
libp2pPort,
discoveryPort,
rpcPort,
eth1Url,
chainDataDir,
client,
}: Omit<IConfigureBNSubmitOptions, "memory" | "image">): Partial<Omit<IDockerRunParams, "name">> => {
const eth1QueryLimit = 200;
switch (client) {
case "prysm": {
const networkEnvironment = network !== "mainet" ? " --" + network : "";
const cmd = [
`--accept-terms-of-use`,
`--datadir=/data${networkEnvironment}`,
`--p2p-tcp-port=${libp2pPort}`,
`--p2p-udp-port=${discoveryPort}`,
`--grpc-gateway-host=0.0.0.0`,
`--grpc-gateway-port=${rpcPort}`,
`--http-web3provider=${eth1Url}`,
// --fallback-web3provider=<PROVIDER 1> --fallback-web3provider=<PROVIDER 2>
].join(" ");
return {
cmd,
volume: `${chainDataDir}:/data`,
};
}
case "teku": {
const cors =
process.env.NODE_ENV !== "production" ? " --rest-api-cors-origins=http://localhost:2003 " : " ";
Expand All @@ -21,9 +43,7 @@ export const getClientParams = (
`--log-destination=CONSOLE`,
].join(" ");
return {
ports,
cmd,
memory,
volume: `${chainDataDir}:/opt/teku/.local/share/teku/beacon`,
};
}
Expand All @@ -39,9 +59,7 @@ export const getClientParams = (
`--eth1-blocks-per-log-query ${eth1QueryLimit}`,
].join(" ");
return {
ports,
cmd,
memory,
volume: `${chainDataDir}:/root/.lighthouse`,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class CgEth2BeaconApi implements ICGEth2BeaconApi {
public state: ICGBeaconStateApi;
public pool: IBeaconPoolApi;

private readonly httpClient: HttpClient;
private readonly config: IBeaconConfig;
protected readonly httpClient: HttpClient;
protected readonly config: IBeaconConfig;
public constructor(config: IBeaconConfig, httpClient: HttpClient, publicKey?: string, dispatch?: Dispatch) {
this.config = config;
this.httpClient = httpClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {Attestation} from "@chainsafe/lodestar-types/lib/types/operations";
import {matomo} from "../../../tracking";

export class CgEth2BeaconBlocksApi implements ICGETH2BeaconBlocksApi {
private readonly httpClient: HttpClient;
private readonly config: IBeaconConfig;
protected readonly httpClient: HttpClient;
protected readonly config: IBeaconConfig;
public constructor(config: IBeaconConfig, httpClient: HttpClient) {
this.config = config;
this.httpClient = httpClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {toHex} from "@chainsafe/lodestar-utils";
import {Dispatch} from "redux";

export class CgEth2BeaconPoolApi implements IBeaconPoolApi {
private readonly httpClient: HttpClient;
private readonly config: IBeaconConfig;
private readonly publicKey?: string;
private readonly dispatch?: Dispatch;
protected readonly httpClient: HttpClient;
protected readonly config: IBeaconConfig;
protected readonly publicKey?: string;
protected readonly dispatch?: Dispatch;

public constructor(config: IBeaconConfig, httpClient: HttpClient, publicKey?: string, dispatch?: Dispatch) {
this.config = config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import logger from "electron-log";
import {cgLogger} from "../../../../../main/logger";

export class CgEth2BeaconStateApi implements ICGBeaconStateApi {
private readonly httpClient: HttpClient;
private readonly config: IBeaconConfig;
protected readonly httpClient: HttpClient;
protected readonly config: IBeaconConfig;
public constructor(config: IBeaconConfig, httpClient: HttpClient) {
this.config = config;
this.httpClient = httpClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import querystring from "querystring";
import {aAPLogger} from "../../../../../main/logger";

export class CgEth2ValidatorApi implements ICGEth2ValidatorApi {
private readonly httpClient: HttpClient;
private readonly config: IBeaconConfig;
protected readonly httpClient: HttpClient;
protected readonly config: IBeaconConfig;
public constructor(config: IBeaconConfig, httpClient: HttpClient) {
this.config = config;
this.httpClient = httpClient;
Expand Down Expand Up @@ -108,8 +108,6 @@ export class CgEth2ValidatorApi implements ICGEth2ValidatorApi {
} catch (e) {
aAPLogger.error(e);
error = e;
} finally {
aAPLogger.debug(data);
}
if (error) throw error;
};
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/services/eth2/client/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
export * from "./eth2ApiClient";
export * from "./lighthouse";
export * from "./teku";
export * from "./nimbus";
export * from "./prysm";

// as you wish
export * from "./utils";
Expand Down
Loading