Skip to content

Commit

Permalink
chore: simplify LightClient usage (#6506)
Browse files Browse the repository at this point in the history
* chore: simplify LightClient usage

* chore: lint

* chore: lint
  • Loading branch information
jeluard committed Mar 6, 2024
1 parent 52ac155 commit 8ad2cb0
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 64 deletions.
2 changes: 1 addition & 1 deletion packages/beacon-node/test/e2e/chain/lightclient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe("chain / lightclient", function () {
});

loggerLC.info("Initialized lightclient", {headSlot: lightclient.getHead().beacon.slot});
lightclient.start();
void lightclient.start();

return new Promise<void>((resolve, reject) => {
bn.chain.emitter.on(routes.events.EventType.head, async (head) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cmds/lightclient/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ export async function lightclientHandler(args: ILightClientArgs & GlobalArgs): P
transport: new LightClientRestTransport(api),
});

client.start();
void client.start();
}
54 changes: 8 additions & 46 deletions packages/light-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,78 +51,40 @@ lodestar lightclient \
For this example we will assume there is a running beacon node at `https://beacon-node.your-domain.com`

```ts
import type {Api} from "@lodestar/api/beacon";
import {ApiError} from "@lodestar/api";
import type {Bytes32} from "@lodestar/types";
import {getClient} from "@lodestar/api";
import {createChainForkConfig} from "@lodestar/config";
import {networksChainConfig} from "@lodestar/config/networks";
import {
type GenesisData,
Lightclient,
LightclientEvent,
RunStatusCode
} from "@lodestar/light-client";
import {getClient} from "@lodestar/api";
import {Lightclient, LightclientEvent} from "@lodestar/light-client";
import {LightClientRestTransport} from "@lodestar/light-client/transport";
import {getLcLoggerConsole} from "@lodestar/light-client/utils";

async function getGenesisData(api: Pick<Api, "beacon">): Promise<GenesisData> {
const res = await api.beacon.getGenesis();
ApiError.assert(res);

return {
genesisTime: Number(res.response.data.genesisTime),
genesisValidatorsRoot: res.response.data.genesisValidatorsRoot,
};
}

async function getSyncCheckpoint(api: Pick<Api, "beacon">): Promise<Bytes32> {
const res = await api.beacon.getStateFinalityCheckpoints("head");
ApiError.assert(res);
return res.response.data.finalized.root;
}
import {getFinalizedSyncCheckpoint, getGenesisData, getLcLoggerConsole} from "@lodestar/light-client/utils";

const config = createChainForkConfig(networksChainConfig.mainnet);

const logger = getLcLoggerConsole({logDebug: Boolean(process.env.DEBUG)});

const api = getClient({urls: ["https://beacon-node.your-domain.com"]}, {config});

const transport = new LightClientRestTransport(api);

const lightclient = await Lightclient.initializeFromCheckpointRoot({
config,
logger,
transport,
transport: new LightClientRestTransport(api),
genesisData: await getGenesisData(api),
checkpointRoot: await getSyncCheckpoint(api),
checkpointRoot: await getFinalizedSyncCheckpoint(api),
opts: {
allowForcedUpdates: true,
updateHeadersOnForcedUpdate: true,
}
});

// Wait for the lightclient to start
await new Promise<void>((resolve) => {
const lightclientStarted = (status: RunStatusCode): void => {
if (status === RunStatusCode.started) {
lightclient?.emitter.off(LightclientEvent.statusChange, lightclientStarted);
resolve();
}
};
lightclient?.emitter.on(LightclientEvent.statusChange, lightclientStarted);
logger.info("Initiating lightclient");
lightclient?.start();
});
await lightclient.start();

logger.info("Lightclient synced");

lightclient.emitter.on(LightclientEvent.lightClientFinalityHeader, async (finalityUpdate) => {
console.log(finalityUpdate);
logger.info(finalityUpdate);
});

lightclient.emitter.on(LightclientEvent.lightClientOptimisticHeader, async (optimisticUpdate) => {
console.log(optimisticUpdate);
logger.info(optimisticUpdate);
});
```

Expand Down
19 changes: 16 additions & 3 deletions packages/light-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,23 @@ export class Lightclient {
return new Lightclient({...args, bootstrap});
}

start(): void {
this.runLoop().catch((e) => {
this.logger.error("Error on runLoop", {}, e as Error);
/**
* @returns a `Promise` that will resolve once `LightclientEvent.statusChange` with `RunStatusCode.started` value is emitted
*/
start(): Promise<void> {
const startPromise = new Promise<void>((resolve) => {
const lightclientStarted = (status: RunStatusCode): void => {
if (status === RunStatusCode.started) {
this.emitter.off(LightclientEvent.statusChange, lightclientStarted);
resolve();
}
};
this.emitter.on(LightclientEvent.statusChange, lightclientStarted);
});

void this.runLoop();

return startPromise;
}

stop(): void {
Expand Down
20 changes: 19 additions & 1 deletion packages/light-client/src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import bls from "@chainsafe/bls";
import type {PublicKey} from "@chainsafe/bls/types";
import {BitArray} from "@chainsafe/ssz";
import {altair, Root, ssz} from "@lodestar/types";
import {Api, ApiError} from "@lodestar/api";
import {altair, Bytes32, Root, ssz} from "@lodestar/types";
import {BeaconBlockHeader} from "@lodestar/types/phase0";
import {GenesisData} from "../index.js";
import {SyncCommitteeFast} from "../types.js";

export function sumBits(bits: BitArray): number {
Expand Down Expand Up @@ -78,3 +80,19 @@ export function isEmptyHeader(header: BeaconBlockHeader): boolean {
// Thanks https://github.com/iliakan/detect-node/blob/master/index.esm.js
export const isNode =
Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";

export async function getGenesisData(api: Pick<Api, "beacon">): Promise<GenesisData> {
const res = await api.beacon.getGenesis();
ApiError.assert(res);

return {
genesisTime: res.response.data.genesisTime,
genesisValidatorsRoot: res.response.data.genesisValidatorsRoot,
};
}

export async function getFinalizedSyncCheckpoint(api: Pick<Api, "beacon">): Promise<Bytes32> {
const res = await api.beacon.getStateFinalityCheckpoints("head");
ApiError.assert(res);
return res.response.data.finalized.root;
}
2 changes: 1 addition & 1 deletion packages/light-client/test/unit/sync.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe("sync", () => {
resolve();
}
});
lightclient.start();
void lightclient.start();
});

// Wait for lightclient to subscribe to header updates
Expand Down
14 changes: 3 additions & 11 deletions packages/prover/src/proof_provider/proof_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,10 @@ export class ProofProvider {
});

assertLightClient(this.lightClient);

this.logger.info("Initiating lightclient");
// Wait for the lightclient to start
await new Promise<void>((resolve) => {
const lightClientStarted = (status: RunStatusCode): void => {
if (status === RunStatusCode.started) {
this.lightClient?.emitter.off(LightclientEvent.statusChange, lightClientStarted);
resolve();
}
};
this.lightClient?.emitter.on(LightclientEvent.statusChange, lightClientStarted);
this.logger.info("Initiating lightclient");
this.lightClient?.start();
});
await this.lightClient?.start();
this.logger.info("Lightclient synced", this.getStatus());
this.registerEvents();

Expand Down

1 comment on commit 8ad2cb0

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for some benchmarks.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold.

Benchmark suite Current: 8ad2cb0 Previous: 52ac155 Ratio
altair processAttestation - setStatus - 1/6 committees join 229.34 us/op 74.548 us/op 3.08
altair processAttestation - setStatus - 1/3 committees join 490.32 us/op 149.72 us/op 3.27
Full benchmark results
Benchmark suite Current: 8ad2cb0 Previous: 52ac155 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.2561 ms/op 566.38 us/op 2.22
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 150.26 us/op 56.299 us/op 2.67
BLS verify - blst-native 1.3881 ms/op 1.1058 ms/op 1.26
BLS verifyMultipleSignatures 3 - blst-native 3.0346 ms/op 2.3159 ms/op 1.31
BLS verifyMultipleSignatures 8 - blst-native 6.6251 ms/op 5.0728 ms/op 1.31
BLS verifyMultipleSignatures 32 - blst-native 23.541 ms/op 18.669 ms/op 1.26
BLS verifyMultipleSignatures 64 - blst-native 45.409 ms/op 36.862 ms/op 1.23
BLS verifyMultipleSignatures 128 - blst-native 95.649 ms/op 72.699 ms/op 1.32
BLS deserializing 10000 signatures 940.75 ms/op 828.65 ms/op 1.14
BLS deserializing 100000 signatures 9.1622 s/op 8.3327 s/op 1.10
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.4252 ms/op 1.1386 ms/op 1.25
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.5697 ms/op 1.2946 ms/op 1.21
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.4063 ms/op 2.0763 ms/op 1.16
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.5166 ms/op 3.0253 ms/op 1.16
BLS verifyMultipleSignatures - same message - 128 - blst-native 5.9984 ms/op 5.0354 ms/op 1.19
BLS aggregatePubkeys 32 - blst-native 27.244 us/op 22.808 us/op 1.19
BLS aggregatePubkeys 128 - blst-native 107.59 us/op 89.483 us/op 1.20
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 68.758 ms/op 41.968 ms/op 1.64
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 62.602 ms/op 37.705 ms/op 1.66
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 53.084 ms/op 25.412 ms/op 2.09
getSlashingsAndExits - default max 175.88 us/op 121.95 us/op 1.44
getSlashingsAndExits - 2k 751.53 us/op 301.39 us/op 2.49
proposeBlockBody type=full, size=empty 7.8166 ms/op 3.7781 ms/op 2.07
isKnown best case - 1 super set check 777.00 ns/op 312.00 ns/op 2.49
isKnown normal case - 2 super set checks 744.00 ns/op 315.00 ns/op 2.36
isKnown worse case - 16 super set checks 799.00 ns/op 320.00 ns/op 2.50
CheckpointStateCache - add get delete 9.2510 us/op 4.1930 us/op 2.21
validate api signedAggregateAndProof - struct 3.5870 ms/op 2.3997 ms/op 1.49
validate gossip signedAggregateAndProof - struct 2.9441 ms/op 2.3908 ms/op 1.23
validate gossip attestation - vc 640000 1.4366 ms/op 1.1482 ms/op 1.25
batch validate gossip attestation - vc 640000 - chunk 32 186.08 us/op 137.26 us/op 1.36
batch validate gossip attestation - vc 640000 - chunk 64 165.24 us/op 122.30 us/op 1.35
batch validate gossip attestation - vc 640000 - chunk 128 157.22 us/op 113.81 us/op 1.38
batch validate gossip attestation - vc 640000 - chunk 256 132.75 us/op 111.14 us/op 1.19
pickEth1Vote - no votes 1.2594 ms/op 883.56 us/op 1.43
pickEth1Vote - max votes 8.4609 ms/op 10.820 ms/op 0.78
pickEth1Vote - Eth1Data hashTreeRoot value x2048 16.314 ms/op 12.305 ms/op 1.33
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 21.815 ms/op 26.766 ms/op 0.82
pickEth1Vote - Eth1Data fastSerialize value x2048 601.64 us/op 402.26 us/op 1.50
pickEth1Vote - Eth1Data fastSerialize tree x2048 4.5315 ms/op 8.2743 ms/op 0.55
bytes32 toHexString 566.00 ns/op 474.00 ns/op 1.19
bytes32 Buffer.toString(hex) 310.00 ns/op 325.00 ns/op 0.95
bytes32 Buffer.toString(hex) from Uint8Array 444.00 ns/op 487.00 ns/op 0.91
bytes32 Buffer.toString(hex) + 0x 296.00 ns/op 340.00 ns/op 0.87
Object access 1 prop 0.17000 ns/op 0.19900 ns/op 0.85
Map access 1 prop 0.14500 ns/op 0.19700 ns/op 0.74
Object get x1000 7.4910 ns/op 5.4710 ns/op 1.37
Map get x1000 0.82100 ns/op 0.72700 ns/op 1.13
Object set x1000 56.978 ns/op 25.175 ns/op 2.26
Map set x1000 41.590 ns/op 17.020 ns/op 2.44
Return object 10000 times 0.24740 ns/op 0.22480 ns/op 1.10
Throw Error 10000 times 3.8433 us/op 2.7758 us/op 1.38
fastMsgIdFn sha256 / 200 bytes 3.2880 us/op 2.1060 us/op 1.56
fastMsgIdFn h32 xxhash / 200 bytes 297.00 ns/op 322.00 ns/op 0.92
fastMsgIdFn h64 xxhash / 200 bytes 349.00 ns/op 373.00 ns/op 0.94
fastMsgIdFn sha256 / 1000 bytes 11.487 us/op 6.3560 us/op 1.81
fastMsgIdFn h32 xxhash / 1000 bytes 415.00 ns/op 480.00 ns/op 0.86
fastMsgIdFn h64 xxhash / 1000 bytes 424.00 ns/op 470.00 ns/op 0.90
fastMsgIdFn sha256 / 10000 bytes 103.89 us/op 51.799 us/op 2.01
fastMsgIdFn h32 xxhash / 10000 bytes 1.9340 us/op 1.7960 us/op 1.08
fastMsgIdFn h64 xxhash / 10000 bytes 1.3690 us/op 1.2280 us/op 1.11
send data - 1000 256B messages 16.607 ms/op 12.708 ms/op 1.31
send data - 1000 512B messages 27.338 ms/op 15.657 ms/op 1.75
send data - 1000 1024B messages 44.630 ms/op 26.447 ms/op 1.69
send data - 1000 1200B messages 39.117 ms/op 31.393 ms/op 1.25
send data - 1000 2048B messages 50.302 ms/op 37.619 ms/op 1.34
send data - 1000 4096B messages 34.471 ms/op 32.529 ms/op 1.06
send data - 1000 16384B messages 116.04 ms/op 100.28 ms/op 1.16
send data - 1000 65536B messages 508.30 ms/op 413.97 ms/op 1.23
enrSubnets - fastDeserialize 64 bits 1.6670 us/op 929.00 ns/op 1.79
enrSubnets - ssz BitVector 64 bits 557.00 ns/op 433.00 ns/op 1.29
enrSubnets - fastDeserialize 4 bits 239.00 ns/op 238.00 ns/op 1.00
enrSubnets - ssz BitVector 4 bits 554.00 ns/op 495.00 ns/op 1.12
prioritizePeers score -10:0 att 32-0.1 sync 2-0 119.43 us/op 78.201 us/op 1.53
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 143.11 us/op 83.859 us/op 1.71
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 206.94 us/op 126.09 us/op 1.64
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 340.58 us/op 194.74 us/op 1.75
prioritizePeers score 0:0 att 64-1 sync 4-1 381.71 us/op 212.72 us/op 1.79
array of 16000 items push then shift 1.7168 us/op 1.2597 us/op 1.36
LinkedList of 16000 items push then shift 9.8880 ns/op 6.8330 ns/op 1.45
array of 16000 items push then pop 114.03 ns/op 88.634 ns/op 1.29
LinkedList of 16000 items push then pop 8.9450 ns/op 5.6340 ns/op 1.59
array of 24000 items push then shift 2.5704 us/op 1.7721 us/op 1.45
LinkedList of 24000 items push then shift 9.0880 ns/op 6.2440 ns/op 1.46
array of 24000 items push then pop 167.01 ns/op 95.342 ns/op 1.75
LinkedList of 24000 items push then pop 8.8170 ns/op 5.5080 ns/op 1.60
intersect bitArray bitLen 8 5.9540 ns/op 4.5400 ns/op 1.31
intersect array and set length 8 74.236 ns/op 50.575 ns/op 1.47
intersect bitArray bitLen 128 35.951 ns/op 27.898 ns/op 1.29
intersect array and set length 128 1.0922 us/op 662.70 ns/op 1.65
bitArray.getTrueBitIndexes() bitLen 128 1.9260 us/op 1.1570 us/op 1.66
bitArray.getTrueBitIndexes() bitLen 248 3.0790 us/op 2.0370 us/op 1.51
bitArray.getTrueBitIndexes() bitLen 512 6.5150 us/op 4.1170 us/op 1.58
Buffer.concat 32 items 1.0750 us/op 787.00 ns/op 1.37
Uint8Array.set 32 items 2.0430 us/op 1.3860 us/op 1.47
Set add up to 64 items then delete first 4.9938 us/op 1.6868 us/op 2.96
OrderedSet add up to 64 items then delete first 6.9411 us/op 2.6453 us/op 2.62
Set add up to 64 items then delete last 5.5027 us/op 1.9930 us/op 2.76
OrderedSet add up to 64 items then delete last 7.2344 us/op 2.8758 us/op 2.52
Set add up to 64 items then delete middle 5.2546 us/op 1.9463 us/op 2.70
OrderedSet add up to 64 items then delete middle 8.3500 us/op 4.1141 us/op 2.03
Set add up to 128 items then delete first 11.009 us/op 3.7935 us/op 2.90
OrderedSet add up to 128 items then delete first 15.522 us/op 5.8974 us/op 2.63
Set add up to 128 items then delete last 10.783 us/op 3.7056 us/op 2.91
OrderedSet add up to 128 items then delete last 14.312 us/op 5.6034 us/op 2.55
Set add up to 128 items then delete middle 10.788 us/op 3.7177 us/op 2.90
OrderedSet add up to 128 items then delete middle 19.768 us/op 10.605 us/op 1.86
Set add up to 256 items then delete first 22.312 us/op 7.4698 us/op 2.99
OrderedSet add up to 256 items then delete first 30.538 us/op 11.895 us/op 2.57
Set add up to 256 items then delete last 21.526 us/op 7.7262 us/op 2.79
OrderedSet add up to 256 items then delete last 28.300 us/op 11.335 us/op 2.50
Set add up to 256 items then delete middle 21.543 us/op 7.5917 us/op 2.84
OrderedSet add up to 256 items then delete middle 52.324 us/op 31.334 us/op 1.67
transfer serialized Status (84 B) 2.0180 us/op 1.4910 us/op 1.35
copy serialized Status (84 B) 1.4720 us/op 1.2560 us/op 1.17
transfer serialized SignedVoluntaryExit (112 B) 2.1210 us/op 1.6980 us/op 1.25
copy serialized SignedVoluntaryExit (112 B) 1.5130 us/op 1.3280 us/op 1.14
transfer serialized ProposerSlashing (416 B) 3.1510 us/op 2.6060 us/op 1.21
copy serialized ProposerSlashing (416 B) 2.4770 us/op 2.7680 us/op 0.89
transfer serialized Attestation (485 B) 2.9120 us/op 2.9040 us/op 1.00
copy serialized Attestation (485 B) 2.2530 us/op 2.5100 us/op 0.90
transfer serialized AttesterSlashing (33232 B) 2.9930 us/op 2.3620 us/op 1.27
copy serialized AttesterSlashing (33232 B) 10.249 us/op 4.7370 us/op 2.16
transfer serialized Small SignedBeaconBlock (128000 B) 4.2870 us/op 2.6870 us/op 1.60
copy serialized Small SignedBeaconBlock (128000 B) 30.733 us/op 35.298 us/op 0.87
transfer serialized Avg SignedBeaconBlock (200000 B) 4.8420 us/op 2.6870 us/op 1.80
copy serialized Avg SignedBeaconBlock (200000 B) 38.986 us/op 13.593 us/op 2.87
transfer serialized BlobsSidecar (524380 B) 6.2220 us/op 2.6790 us/op 2.32
copy serialized BlobsSidecar (524380 B) 169.54 us/op 80.503 us/op 2.11
transfer serialized Big SignedBeaconBlock (1000000 B) 5.9560 us/op 3.2010 us/op 1.86
copy serialized Big SignedBeaconBlock (1000000 B) 344.33 us/op 186.71 us/op 1.84
pass gossip attestations to forkchoice per slot 6.0412 ms/op 2.8370 ms/op 2.13
forkChoice updateHead vc 100000 bc 64 eq 0 715.89 us/op 474.82 us/op 1.51
forkChoice updateHead vc 600000 bc 64 eq 0 5.5089 ms/op 2.8377 ms/op 1.94
forkChoice updateHead vc 1000000 bc 64 eq 0 8.7823 ms/op 4.5192 ms/op 1.94
forkChoice updateHead vc 600000 bc 320 eq 0 4.4398 ms/op 2.6313 ms/op 1.69
forkChoice updateHead vc 600000 bc 1200 eq 0 4.6683 ms/op 2.7928 ms/op 1.67
forkChoice updateHead vc 600000 bc 7200 eq 0 5.6812 ms/op 3.6894 ms/op 1.54
forkChoice updateHead vc 600000 bc 64 eq 1000 11.437 ms/op 9.8157 ms/op 1.17
forkChoice updateHead vc 600000 bc 64 eq 10000 12.615 ms/op 9.9266 ms/op 1.27
forkChoice updateHead vc 600000 bc 64 eq 300000 21.315 ms/op 12.793 ms/op 1.67
computeDeltas 500000 validators 300 proto nodes 7.0809 ms/op 3.2528 ms/op 2.18
computeDeltas 500000 validators 1200 proto nodes 6.9186 ms/op 3.2055 ms/op 2.16
computeDeltas 500000 validators 7200 proto nodes 7.0137 ms/op 3.1442 ms/op 2.23
computeDeltas 750000 validators 300 proto nodes 10.952 ms/op 4.6087 ms/op 2.38
computeDeltas 750000 validators 1200 proto nodes 10.297 ms/op 4.6941 ms/op 2.19
computeDeltas 750000 validators 7200 proto nodes 10.032 ms/op 4.6627 ms/op 2.15
computeDeltas 1400000 validators 300 proto nodes 21.220 ms/op 8.8964 ms/op 2.39
computeDeltas 1400000 validators 1200 proto nodes 22.709 ms/op 8.8826 ms/op 2.56
computeDeltas 1400000 validators 7200 proto nodes 21.420 ms/op 8.8943 ms/op 2.41
computeDeltas 2100000 validators 300 proto nodes 32.692 ms/op 13.923 ms/op 2.35
computeDeltas 2100000 validators 1200 proto nodes 31.774 ms/op 12.929 ms/op 2.46
computeDeltas 2100000 validators 7200 proto nodes 33.561 ms/op 13.517 ms/op 2.48
altair processAttestation - 250000 vs - 7PWei normalcase 4.2631 ms/op 1.5456 ms/op 2.76
altair processAttestation - 250000 vs - 7PWei worstcase 5.8521 ms/op 2.2286 ms/op 2.63
altair processAttestation - setStatus - 1/6 committees join 229.34 us/op 74.548 us/op 3.08
altair processAttestation - setStatus - 1/3 committees join 490.32 us/op 149.72 us/op 3.27
altair processAttestation - setStatus - 1/2 committees join 586.20 us/op 234.65 us/op 2.50
altair processAttestation - setStatus - 2/3 committees join 703.95 us/op 278.85 us/op 2.52
altair processAttestation - setStatus - 4/5 committees join 1.0132 ms/op 433.88 us/op 2.34
altair processAttestation - setStatus - 100% committees join 1.1059 ms/op 482.95 us/op 2.29
altair processBlock - 250000 vs - 7PWei normalcase 15.173 ms/op 10.363 ms/op 1.46
altair processBlock - 250000 vs - 7PWei normalcase hashState 40.144 ms/op 33.051 ms/op 1.21
altair processBlock - 250000 vs - 7PWei worstcase 46.008 ms/op 35.384 ms/op 1.30
altair processBlock - 250000 vs - 7PWei worstcase hashState 131.84 ms/op 85.495 ms/op 1.54
phase0 processBlock - 250000 vs - 7PWei normalcase 3.4748 ms/op 2.8008 ms/op 1.24
phase0 processBlock - 250000 vs - 7PWei worstcase 37.404 ms/op 27.505 ms/op 1.36
altair processEth1Data - 250000 vs - 7PWei normalcase 765.10 us/op 555.86 us/op 1.38
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 26.633 us/op 10.796 us/op 2.47
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 95.494 us/op 54.967 us/op 1.74
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 31.751 us/op 15.909 us/op 2.00
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 17.766 us/op 13.228 us/op 1.34
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 212.30 us/op 181.35 us/op 1.17
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.4092 ms/op 1.1735 ms/op 1.20
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.9643 ms/op 1.5257 ms/op 1.29
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.7949 ms/op 1.0978 ms/op 1.64
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 3.6723 ms/op 3.2692 ms/op 1.12
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.6251 ms/op 1.7741 ms/op 1.48
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 5.6445 ms/op 4.9614 ms/op 1.14
Tree 40 250000 create 394.75 ms/op 397.89 ms/op 0.99
Tree 40 250000 get(125000) 201.80 ns/op 124.53 ns/op 1.62
Tree 40 250000 set(125000) 997.04 ns/op 767.91 ns/op 1.30
Tree 40 250000 toArray() 21.546 ms/op 20.036 ms/op 1.08
Tree 40 250000 iterate all - toArray() + loop 20.149 ms/op 20.821 ms/op 0.97
Tree 40 250000 iterate all - get(i) 65.380 ms/op 51.858 ms/op 1.26
MutableVector 250000 create 14.403 ms/op 14.916 ms/op 0.97
MutableVector 250000 get(125000) 6.5080 ns/op 5.8930 ns/op 1.10
MutableVector 250000 set(125000) 295.83 ns/op 312.25 ns/op 0.95
MutableVector 250000 toArray() 3.7699 ms/op 3.7959 ms/op 0.99
MutableVector 250000 iterate all - toArray() + loop 3.8328 ms/op 3.6963 ms/op 1.04
MutableVector 250000 iterate all - get(i) 1.5311 ms/op 1.3223 ms/op 1.16
Array 250000 create 3.4024 ms/op 3.4603 ms/op 0.98
Array 250000 clone - spread 1.4357 ms/op 1.1774 ms/op 1.22
Array 250000 get(125000) 1.1790 ns/op 1.2070 ns/op 0.98
Array 250000 set(125000) 4.8960 ns/op 1.2570 ns/op 3.89
Array 250000 iterate all - loop 167.57 us/op 152.63 us/op 1.10
effectiveBalanceIncrements clone Uint8Array 300000 46.675 us/op 34.596 us/op 1.35
effectiveBalanceIncrements clone MutableVector 300000 440.00 ns/op 465.00 ns/op 0.95
effectiveBalanceIncrements rw all Uint8Array 300000 204.55 us/op 189.16 us/op 1.08
effectiveBalanceIncrements rw all MutableVector 300000 103.22 ms/op 67.187 ms/op 1.54
phase0 afterProcessEpoch - 250000 vs - 7PWei 124.36 ms/op 75.219 ms/op 1.65
phase0 beforeProcessEpoch - 250000 vs - 7PWei 39.154 ms/op 53.024 ms/op 0.74
altair processEpoch - mainnet_e81889 490.77 ms/op 457.76 ms/op 1.07
mainnet_e81889 - altair beforeProcessEpoch 87.913 ms/op 79.756 ms/op 1.10
mainnet_e81889 - altair processJustificationAndFinalization 17.726 us/op 13.741 us/op 1.29
mainnet_e81889 - altair processInactivityUpdates 5.7287 ms/op 5.0350 ms/op 1.14
mainnet_e81889 - altair processRewardsAndPenalties 70.567 ms/op 63.284 ms/op 1.12
mainnet_e81889 - altair processRegistryUpdates 2.9740 us/op 3.3470 us/op 0.89
mainnet_e81889 - altair processSlashings 510.00 ns/op 645.00 ns/op 0.79
mainnet_e81889 - altair processEth1DataReset 713.00 ns/op 841.00 ns/op 0.85
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.4476 ms/op 1.1050 ms/op 1.31
mainnet_e81889 - altair processSlashingsReset 4.5780 us/op 4.8220 us/op 0.95
mainnet_e81889 - altair processRandaoMixesReset 5.7050 us/op 9.4610 us/op 0.60
mainnet_e81889 - altair processHistoricalRootsUpdate 645.00 ns/op 1.1020 us/op 0.59
mainnet_e81889 - altair processParticipationFlagUpdates 1.8850 us/op 2.6430 us/op 0.71
mainnet_e81889 - altair processSyncCommitteeUpdates 764.00 ns/op 1.1110 us/op 0.69
mainnet_e81889 - altair afterProcessEpoch 123.86 ms/op 84.868 ms/op 1.46
capella processEpoch - mainnet_e217614 2.4542 s/op 1.7866 s/op 1.37
mainnet_e217614 - capella beforeProcessEpoch 539.41 ms/op 421.66 ms/op 1.28
mainnet_e217614 - capella processJustificationAndFinalization 25.768 us/op 12.510 us/op 2.06
mainnet_e217614 - capella processInactivityUpdates 21.672 ms/op 19.212 ms/op 1.13
mainnet_e217614 - capella processRewardsAndPenalties 429.49 ms/op 381.24 ms/op 1.13
mainnet_e217614 - capella processRegistryUpdates 29.541 us/op 16.508 us/op 1.79
mainnet_e217614 - capella processSlashings 821.00 ns/op 931.00 ns/op 0.88
mainnet_e217614 - capella processEth1DataReset 736.00 ns/op 486.00 ns/op 1.51
mainnet_e217614 - capella processEffectiveBalanceUpdates 6.5698 ms/op 3.3954 ms/op 1.93
mainnet_e217614 - capella processSlashingsReset 6.1350 us/op 2.7480 us/op 2.23
mainnet_e217614 - capella processRandaoMixesReset 8.7350 us/op 6.2040 us/op 1.41
mainnet_e217614 - capella processHistoricalRootsUpdate 1.2220 us/op 630.00 ns/op 1.94
mainnet_e217614 - capella processParticipationFlagUpdates 3.2190 us/op 2.2210 us/op 1.45
mainnet_e217614 - capella afterProcessEpoch 322.33 ms/op 226.93 ms/op 1.42
phase0 processEpoch - mainnet_e58758 649.97 ms/op 432.72 ms/op 1.50
mainnet_e58758 - phase0 beforeProcessEpoch 217.46 ms/op 120.93 ms/op 1.80
mainnet_e58758 - phase0 processJustificationAndFinalization 36.095 us/op 13.852 us/op 2.61
mainnet_e58758 - phase0 processRewardsAndPenalties 79.224 ms/op 55.007 ms/op 1.44
mainnet_e58758 - phase0 processRegistryUpdates 22.448 us/op 8.8170 us/op 2.55
mainnet_e58758 - phase0 processSlashings 1.5630 us/op 658.00 ns/op 2.38
mainnet_e58758 - phase0 processEth1DataReset 1.3190 us/op 571.00 ns/op 2.31
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.2271 ms/op 863.94 us/op 2.58
mainnet_e58758 - phase0 processSlashingsReset 8.2830 us/op 2.9170 us/op 2.84
mainnet_e58758 - phase0 processRandaoMixesReset 10.942 us/op 3.5020 us/op 3.12
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.2190 us/op 963.00 ns/op 1.27
mainnet_e58758 - phase0 processParticipationRecordUpdates 10.363 us/op 3.7370 us/op 2.77
mainnet_e58758 - phase0 afterProcessEpoch 119.78 ms/op 66.466 ms/op 1.80
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.6981 ms/op 1.0487 ms/op 2.57
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 3.0778 ms/op 1.1558 ms/op 2.66
altair processInactivityUpdates - 250000 normalcase 44.924 ms/op 24.353 ms/op 1.84
altair processInactivityUpdates - 250000 worstcase 40.686 ms/op 24.136 ms/op 1.69
phase0 processRegistryUpdates - 250000 normalcase 25.488 us/op 8.0730 us/op 3.16
phase0 processRegistryUpdates - 250000 badcase_full_deposits 553.73 us/op 425.90 us/op 1.30
phase0 processRegistryUpdates - 250000 worstcase 0.5 188.46 ms/op 118.82 ms/op 1.59
altair processRewardsAndPenalties - 250000 normalcase 64.070 ms/op 50.915 ms/op 1.26
altair processRewardsAndPenalties - 250000 worstcase 61.500 ms/op 46.477 ms/op 1.32
phase0 getAttestationDeltas - 250000 normalcase 12.868 ms/op 6.0712 ms/op 2.12
phase0 getAttestationDeltas - 250000 worstcase 12.920 ms/op 5.9759 ms/op 2.16
phase0 processSlashings - 250000 worstcase 108.45 us/op 90.901 us/op 1.19
altair processSyncCommitteeUpdates - 250000 164.19 ms/op 125.92 ms/op 1.30
BeaconState.hashTreeRoot - No change 687.00 ns/op 538.00 ns/op 1.28
BeaconState.hashTreeRoot - 1 full validator 138.20 us/op 142.30 us/op 0.97
BeaconState.hashTreeRoot - 32 full validator 1.4746 ms/op 1.0238 ms/op 1.44
BeaconState.hashTreeRoot - 512 full validator 17.632 ms/op 15.814 ms/op 1.11
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 209.81 us/op 173.49 us/op 1.21
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.8129 ms/op 2.0097 ms/op 1.40
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 30.242 ms/op 37.990 ms/op 0.80
BeaconState.hashTreeRoot - 1 balances 136.39 us/op 150.09 us/op 0.91
BeaconState.hashTreeRoot - 32 balances 1.2654 ms/op 1.8591 ms/op 0.68
BeaconState.hashTreeRoot - 512 balances 15.563 ms/op 16.819 ms/op 0.93
BeaconState.hashTreeRoot - 250000 balances 243.31 ms/op 276.39 ms/op 0.88
aggregationBits - 2048 els - zipIndexesInBitList 29.420 us/op 20.864 us/op 1.41
byteArrayEquals 32 80.909 ns/op 65.365 ns/op 1.24
Buffer.compare 32 57.456 ns/op 38.888 ns/op 1.48
byteArrayEquals 1024 2.2399 us/op 1.7795 us/op 1.26
Buffer.compare 1024 72.905 ns/op 47.608 ns/op 1.53
byteArrayEquals 16384 34.596 us/op 28.153 us/op 1.23
Buffer.compare 16384 265.28 ns/op 206.04 ns/op 1.29
byteArrayEquals 123687377 255.15 ms/op 208.20 ms/op 1.23
Buffer.compare 123687377 8.4592 ms/op 5.9075 ms/op 1.43
byteArrayEquals 32 - diff last byte 75.766 ns/op 68.534 ns/op 1.11
Buffer.compare 32 - diff last byte 57.248 ns/op 40.108 ns/op 1.43
byteArrayEquals 1024 - diff last byte 2.1277 us/op 1.7775 us/op 1.20
Buffer.compare 1024 - diff last byte 74.335 ns/op 49.067 ns/op 1.51
byteArrayEquals 16384 - diff last byte 33.031 us/op 28.966 us/op 1.14
Buffer.compare 16384 - diff last byte 284.07 ns/op 196.18 ns/op 1.45
byteArrayEquals 123687377 - diff last byte 250.14 ms/op 216.54 ms/op 1.16
Buffer.compare 123687377 - diff last byte 8.7137 ms/op 6.4805 ms/op 1.34
byteArrayEquals 32 - random bytes 6.3310 ns/op 5.0530 ns/op 1.25
Buffer.compare 32 - random bytes 71.510 ns/op 42.724 ns/op 1.67
byteArrayEquals 1024 - random bytes 6.2630 ns/op 4.6760 ns/op 1.34
Buffer.compare 1024 - random bytes 66.367 ns/op 39.808 ns/op 1.67
byteArrayEquals 16384 - random bytes 7.2220 ns/op 4.6570 ns/op 1.55
Buffer.compare 16384 - random bytes 70.479 ns/op 39.582 ns/op 1.78
byteArrayEquals 123687377 - random bytes 10.040 ns/op 8.2500 ns/op 1.22
Buffer.compare 123687377 - random bytes 79.910 ns/op 45.970 ns/op 1.74
regular array get 100000 times 48.724 us/op 42.302 us/op 1.15
wrappedArray get 100000 times 48.920 us/op 42.495 us/op 1.15
arrayWithProxy get 100000 times 18.150 ms/op 9.9510 ms/op 1.82
ssz.Root.equals 61.483 ns/op 56.960 ns/op 1.08
byteArrayEquals 58.809 ns/op 55.583 ns/op 1.06
Buffer.compare 12.371 ns/op 10.590 ns/op 1.17
shuffle list - 16384 els 7.4902 ms/op 4.9206 ms/op 1.52
shuffle list - 250000 els 114.72 ms/op 98.241 ms/op 1.17
processSlot - 1 slots 21.667 us/op 19.404 us/op 1.12
processSlot - 32 slots 3.7702 ms/op 3.1126 ms/op 1.21
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 65.818 ms/op 51.429 ms/op 1.28
getCommitteeAssignments - req 1 vs - 250000 vc 2.7769 ms/op 2.3108 ms/op 1.20
getCommitteeAssignments - req 100 vs - 250000 vc 4.0424 ms/op 3.6562 ms/op 1.11
getCommitteeAssignments - req 1000 vs - 250000 vc 4.7065 ms/op 3.8016 ms/op 1.24
findModifiedValidators - 10000 modified validators 685.22 ms/op 461.25 ms/op 1.49
findModifiedValidators - 1000 modified validators 491.34 ms/op 362.46 ms/op 1.36
findModifiedValidators - 100 modified validators 447.16 ms/op 320.97 ms/op 1.39
findModifiedValidators - 10 modified validators 470.66 ms/op 332.80 ms/op 1.41
findModifiedValidators - 1 modified validators 484.50 ms/op 327.40 ms/op 1.48
findModifiedValidators - no difference 508.03 ms/op 350.07 ms/op 1.45
compare ViewDUs 5.9696 s/op 4.2306 s/op 1.41
compare each validator Uint8Array 1.7851 s/op 1.8093 s/op 0.99
compare ViewDU to Uint8Array 1.4219 s/op 1.0409 s/op 1.37
migrate state 1000000 validators, 24 modified, 0 new 978.47 ms/op 736.93 ms/op 1.33
migrate state 1000000 validators, 1700 modified, 1000 new 1.1923 s/op 1.1076 s/op 1.08
migrate state 1000000 validators, 3400 modified, 2000 new 1.2829 s/op 1.3969 s/op 0.92
migrate state 1500000 validators, 24 modified, 0 new 720.96 ms/op 846.41 ms/op 0.85
migrate state 1500000 validators, 1700 modified, 1000 new 1.0827 s/op 1.3240 s/op 0.82
migrate state 1500000 validators, 3400 modified, 2000 new 1.3160 s/op 1.7489 s/op 0.75
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 6.1500 ns/op 5.1200 ns/op 1.20
state getBlockRootAtSlot - 250000 vs - 7PWei 965.02 ns/op 707.14 ns/op 1.36
computeProposers - vc 250000 9.8828 ms/op 8.3929 ms/op 1.18
computeEpochShuffling - vc 250000 105.44 ms/op 74.839 ms/op 1.41
getNextSyncCommittee - vc 250000 165.46 ms/op 141.81 ms/op 1.17
computeSigningRoot for AttestationData 27.087 us/op 29.084 us/op 0.93
hash AttestationData serialized data then Buffer.toString(base64) 2.3230 us/op 1.5556 us/op 1.49
toHexString serialized data 1.1221 us/op 1.3449 us/op 0.83
Buffer.toString(base64) 234.48 ns/op 226.82 ns/op 1.03

Please sign in to comment.