Skip to content

Commit

Permalink
feat: add standard endpoint to retrieve fork choice context (#7127)
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig authored Oct 7, 2024
1 parent 0d1fd9c commit 5f7b611
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 3 deletions.
53 changes: 53 additions & 0 deletions packages/api/src/beacon/routes/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,34 @@ const DebugChainHeadType = new ContainerType(
{jsonCase: "eth2"}
);

const ForkChoiceNodeType = new ContainerType(
{
slot: ssz.Slot,
blockRoot: stringType,
parentRoot: stringType,
justifiedEpoch: ssz.Epoch,
finalizedEpoch: ssz.Epoch,
weight: ssz.UintNum64,
validity: new StringType<"valid" | "invalid" | "optimistic">(),
executionBlockHash: stringType,
},
{jsonCase: "eth2"}
);
const ForkChoiceResponseType = new ContainerType(
{
justifiedCheckpoint: ssz.phase0.Checkpoint,
finalizedCheckpoint: ssz.phase0.Checkpoint,
forkChoiceNodes: ArrayOf(ForkChoiceNodeType),
},
{jsonCase: "eth2"}
);

const ProtoNodeListType = ArrayOf(ProtoNodeType);
const DebugChainHeadListType = ArrayOf(DebugChainHeadType);

type ProtoNodeList = ValueOf<typeof ProtoNodeListType>;
type DebugChainHeadList = ValueOf<typeof DebugChainHeadListType>;
type ForkChoiceResponse = ValueOf<typeof ForkChoiceResponseType>;

export type Endpoints = {
/**
Expand All @@ -77,6 +100,18 @@ export type Endpoints = {
EmptyMeta
>;

/**
* Retrieves all current fork choice context
*/
getDebugForkChoice: Endpoint<
// ⏎
"GET",
EmptyArgs,
EmptyRequest,
ForkChoiceResponse,
EmptyMeta
>;

/**
* Dump all ProtoArray's nodes to debug
*/
Expand Down Expand Up @@ -115,6 +150,24 @@ export function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpo
onlySupport: WireFormat.json,
},
},
getDebugForkChoice: {
url: "/eth/v1/debug/fork_choice",
method: "GET",
req: EmptyRequestCodec,
resp: {
data: ForkChoiceResponseType,
meta: EmptyMetaCodec,
onlySupport: WireFormat.json,
transform: {
toResponse: (data) => ({
...(data as ForkChoiceResponse),
}),
fromResponse: (resp) => ({
data: resp as ForkChoiceResponse,
}),
},
},
},
getProtoArrayNodes: {
url: "/eth/v0/debug/forkchoice",
method: "GET",
Expand Down
1 change: 0 additions & 1 deletion packages/api/test/unit/beacon/oapiSpec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const ignoredOperations = [
/* missing route */
"getDepositSnapshot", // Won't fix for now, see https://github.com/ChainSafe/lodestar/issues/5697
"getNextWithdrawals", // https://github.com/ChainSafe/lodestar/issues/5696
"getDebugForkChoice", // https://github.com/ChainSafe/lodestar/issues/5700
/* Must support ssz response body */
"getLightClientUpdatesByRange", // https://github.com/ChainSafe/lodestar/issues/6841
];
Expand Down
30 changes: 29 additions & 1 deletion packages/api/test/unit/beacon/testData/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,41 @@ import {ssz} from "@lodestar/types";
import {Endpoints} from "../../../../src/beacon/routes/debug.js";
import {GenericServerTestCases} from "../../../utils/genericServerTest.js";

const rootHex = toHexString(Buffer.alloc(32, 1));
const root = new Uint8Array(32).fill(1);
const rootHex = toHexString(root);

export const testData: GenericServerTestCases<Endpoints> = {
getDebugChainHeadsV2: {
args: undefined,
res: {data: [{slot: 1, root: rootHex, executionOptimistic: true}]},
},
getDebugForkChoice: {
args: undefined,
res: {
data: {
justifiedCheckpoint: {
epoch: 2,
root,
},
finalizedCheckpoint: {
epoch: 1,
root,
},
forkChoiceNodes: [
{
slot: 1,
blockRoot: rootHex,
parentRoot: rootHex,
justifiedEpoch: 1,
finalizedEpoch: 1,
weight: 1,
validity: "valid",
executionBlockHash: rootHex,
},
],
},
},
},
getProtoArrayNodes: {
args: undefined,
res: {
Expand Down
31 changes: 31 additions & 0 deletions packages/beacon-node/src/api/impl/debug/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {routes} from "@lodestar/api";
import {ApplicationMethods} from "@lodestar/api/server";
import {ExecutionStatus} from "@lodestar/fork-choice";
import {BeaconState} from "@lodestar/types";
import {ZERO_HASH_HEX} from "@lodestar/params";
import {getStateResponseWithRegen} from "../beacon/state/utils.js";
import {ApiModules} from "../types.js";
import {isOptimisticBlock} from "../../../util/forkChoice.js";
Expand All @@ -22,6 +24,35 @@ export function getDebugApi({
};
},

async getDebugForkChoice() {
return {
data: {
justifiedCheckpoint: chain.forkChoice.getJustifiedCheckpoint(),
finalizedCheckpoint: chain.forkChoice.getFinalizedCheckpoint(),
forkChoiceNodes: chain.forkChoice.getAllNodes().map((node) => ({
slot: node.slot,
blockRoot: node.blockRoot,
parentRoot: node.parentRoot,
justifiedEpoch: node.justifiedEpoch,
finalizedEpoch: node.finalizedEpoch,
weight: node.weight,
validity: (() => {
switch (node.executionStatus) {
case ExecutionStatus.Valid:
return "valid";
case ExecutionStatus.Invalid:
return "invalid";
case ExecutionStatus.Syncing:
case ExecutionStatus.PreMerge:
return "optimistic";
}
})(),
executionBlockHash: node.executionPayloadBlockHash ?? ZERO_HASH_HEX,
})),
},
};
},

async getProtoArrayNodes() {
const nodes = chain.forkChoice.getAllNodes().map((node) => ({
// if node has executionPayloadNumber, it will overwrite the below default
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/api/rest/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class RestApiServer {
if (err.validation) {
const {instancePath, message} = err.validation[0];
const payload: ErrorResponse = {
code: err.statusCode ?? 400,
code: 400,
message: `${instancePath.substring(instancePath.lastIndexOf("/") + 1)} ${message}`,
stacktraces,
};
Expand Down

1 comment on commit 5f7b611

@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: 5f7b611 Previous: 0d1fd9c Ratio
altair processEth1Data - 250000 vs - 7PWei normalcase 812.37 us/op 259.01 us/op 3.14
phase0 processEffectiveBalanceUpdates - 250000 normalcase 3.4518 ms/op 966.36 us/op 3.57
Full benchmark results
Benchmark suite Current: 5f7b611 Previous: 0d1fd9c Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.3062 ms/op 1.8512 ms/op 1.25
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 76.487 us/op 39.441 us/op 1.94
BLS verify - blst 1.0993 ms/op 852.98 us/op 1.29
BLS verifyMultipleSignatures 3 - blst 1.6452 ms/op 1.4373 ms/op 1.14
BLS verifyMultipleSignatures 8 - blst 2.2064 ms/op 2.0655 ms/op 1.07
BLS verifyMultipleSignatures 32 - blst 6.7973 ms/op 4.4732 ms/op 1.52
BLS verifyMultipleSignatures 64 - blst 11.857 ms/op 8.1416 ms/op 1.46
BLS verifyMultipleSignatures 128 - blst 19.677 ms/op 15.782 ms/op 1.25
BLS deserializing 10000 signatures 806.87 ms/op 603.08 ms/op 1.34
BLS deserializing 100000 signatures 7.8990 s/op 6.0504 s/op 1.31
BLS verifyMultipleSignatures - same message - 3 - blst 1.0929 ms/op 939.94 us/op 1.16
BLS verifyMultipleSignatures - same message - 8 - blst 1.2019 ms/op 1.1121 ms/op 1.08
BLS verifyMultipleSignatures - same message - 32 - blst 1.8900 ms/op 1.6300 ms/op 1.16
BLS verifyMultipleSignatures - same message - 64 - blst 2.8681 ms/op 2.4197 ms/op 1.19
BLS verifyMultipleSignatures - same message - 128 - blst 4.8381 ms/op 4.1835 ms/op 1.16
BLS aggregatePubkeys 32 - blst 22.911 us/op 17.921 us/op 1.28
BLS aggregatePubkeys 128 - blst 78.211 us/op 63.060 us/op 1.24
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 84.056 ms/op 58.388 ms/op 1.44
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 58.545 ms/op 40.352 ms/op 1.45
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 41.760 ms/op 28.706 ms/op 1.45
getSlashingsAndExits - default max 101.17 us/op 80.735 us/op 1.25
getSlashingsAndExits - 2k 308.44 us/op 269.88 us/op 1.14
proposeBlockBody type=full, size=empty 6.6298 ms/op 5.1155 ms/op 1.30
isKnown best case - 1 super set check 378.00 ns/op 566.00 ns/op 0.67
isKnown normal case - 2 super set checks 418.00 ns/op 542.00 ns/op 0.77
isKnown worse case - 16 super set checks 425.00 ns/op 519.00 ns/op 0.82
InMemoryCheckpointStateCache - add get delete 3.1360 us/op 3.2790 us/op 0.96
updateUnfinalizedPubkeys - updating 10 pubkeys 1.2893 ms/op 678.84 us/op 1.90
updateUnfinalizedPubkeys - updating 100 pubkeys 3.9314 ms/op 2.4769 ms/op 1.59
updateUnfinalizedPubkeys - updating 1000 pubkeys 60.221 ms/op 37.960 ms/op 1.59
validate api signedAggregateAndProof - struct 1.6168 ms/op 1.9665 ms/op 0.82
validate gossip signedAggregateAndProof - struct 1.6255 ms/op 1.9115 ms/op 0.85
validate gossip attestation - vc 640000 1.1596 ms/op 981.08 us/op 1.18
batch validate gossip attestation - vc 640000 - chunk 32 153.06 us/op 129.87 us/op 1.18
batch validate gossip attestation - vc 640000 - chunk 64 128.55 us/op 116.78 us/op 1.10
batch validate gossip attestation - vc 640000 - chunk 128 113.84 us/op 104.72 us/op 1.09
batch validate gossip attestation - vc 640000 - chunk 256 107.06 us/op 102.28 us/op 1.05
pickEth1Vote - no votes 1.1492 ms/op 846.22 us/op 1.36
pickEth1Vote - max votes 5.9328 ms/op 4.4186 ms/op 1.34
pickEth1Vote - Eth1Data hashTreeRoot value x2048 15.487 ms/op 9.9643 ms/op 1.55
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 21.931 ms/op 13.724 ms/op 1.60
pickEth1Vote - Eth1Data fastSerialize value x2048 568.08 us/op 357.46 us/op 1.59
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.6625 ms/op 2.0672 ms/op 1.77
bytes32 toHexString 558.00 ns/op 585.00 ns/op 0.95
bytes32 Buffer.toString(hex) 256.00 ns/op 445.00 ns/op 0.58
bytes32 Buffer.toString(hex) from Uint8Array 398.00 ns/op 542.00 ns/op 0.73
bytes32 Buffer.toString(hex) + 0x 259.00 ns/op 442.00 ns/op 0.59
Object access 1 prop 0.14600 ns/op 0.33300 ns/op 0.44
Map access 1 prop 0.13300 ns/op 0.32700 ns/op 0.41
Object get x1000 6.1480 ns/op 5.1200 ns/op 1.20
Map get x1000 6.8050 ns/op 5.8540 ns/op 1.16
Object set x1000 37.161 ns/op 22.954 ns/op 1.62
Map set x1000 24.182 ns/op 18.840 ns/op 1.28
Return object 10000 times 0.30400 ns/op 0.30080 ns/op 1.01
Throw Error 10000 times 3.5148 us/op 2.7184 us/op 1.29
toHex 152.68 ns/op 111.52 ns/op 1.37
Buffer.from 132.58 ns/op 102.96 ns/op 1.29
shared Buffer 100.09 ns/op 69.944 ns/op 1.43
fastMsgIdFn sha256 / 200 bytes 2.4220 us/op 2.0710 us/op 1.17
fastMsgIdFn h32 xxhash / 200 bytes 278.00 ns/op 412.00 ns/op 0.67
fastMsgIdFn h64 xxhash / 200 bytes 281.00 ns/op 459.00 ns/op 0.61
fastMsgIdFn sha256 / 1000 bytes 7.7230 us/op 5.9260 us/op 1.30
fastMsgIdFn h32 xxhash / 1000 bytes 414.00 ns/op 546.00 ns/op 0.76
fastMsgIdFn h64 xxhash / 1000 bytes 353.00 ns/op 537.00 ns/op 0.66
fastMsgIdFn sha256 / 10000 bytes 66.505 us/op 49.986 us/op 1.33
fastMsgIdFn h32 xxhash / 10000 bytes 1.9680 us/op 1.9500 us/op 1.01
fastMsgIdFn h64 xxhash / 10000 bytes 1.2450 us/op 1.3550 us/op 0.92
send data - 1000 256B messages 14.516 ms/op 9.4972 ms/op 1.53
send data - 1000 512B messages 19.007 ms/op 13.188 ms/op 1.44
send data - 1000 1024B messages 31.153 ms/op 24.936 ms/op 1.25
send data - 1000 1200B messages 27.568 ms/op 22.437 ms/op 1.23
send data - 1000 2048B messages 32.552 ms/op 28.732 ms/op 1.13
send data - 1000 4096B messages 34.345 ms/op 25.077 ms/op 1.37
send data - 1000 16384B messages 71.186 ms/op 63.834 ms/op 1.12
send data - 1000 65536B messages 199.85 ms/op 233.01 ms/op 0.86
enrSubnets - fastDeserialize 64 bits 1.0230 us/op 1.1600 us/op 0.88
enrSubnets - ssz BitVector 64 bits 353.00 ns/op 521.00 ns/op 0.68
enrSubnets - fastDeserialize 4 bits 143.00 ns/op 325.00 ns/op 0.44
enrSubnets - ssz BitVector 4 bits 360.00 ns/op 518.00 ns/op 0.69
prioritizePeers score -10:0 att 32-0.1 sync 2-0 152.14 us/op 109.66 us/op 1.39
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 186.88 us/op 137.38 us/op 1.36
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 350.11 us/op 201.24 us/op 1.74
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 556.40 us/op 333.69 us/op 1.67
prioritizePeers score 0:0 att 64-1 sync 4-1 948.25 us/op 423.20 us/op 2.24
array of 16000 items push then shift 1.6315 us/op 1.2336 us/op 1.32
LinkedList of 16000 items push then shift 7.0580 ns/op 7.5650 ns/op 0.93
array of 16000 items push then pop 110.11 ns/op 99.399 ns/op 1.11
LinkedList of 16000 items push then pop 6.9110 ns/op 6.1760 ns/op 1.12
array of 24000 items push then shift 2.3842 us/op 1.8010 us/op 1.32
LinkedList of 24000 items push then shift 7.3240 ns/op 6.8930 ns/op 1.06
array of 24000 items push then pop 141.55 ns/op 125.49 ns/op 1.13
LinkedList of 24000 items push then pop 6.8390 ns/op 6.1900 ns/op 1.10
intersect bitArray bitLen 8 6.3010 ns/op 5.1430 ns/op 1.23
intersect array and set length 8 46.103 ns/op 37.152 ns/op 1.24
intersect bitArray bitLen 128 29.458 ns/op 25.386 ns/op 1.16
intersect array and set length 128 664.16 ns/op 549.85 ns/op 1.21
bitArray.getTrueBitIndexes() bitLen 128 2.4080 us/op 1.4880 us/op 1.62
bitArray.getTrueBitIndexes() bitLen 248 3.8870 us/op 2.2750 us/op 1.71
bitArray.getTrueBitIndexes() bitLen 512 8.5590 us/op 4.1950 us/op 2.04
Buffer.concat 32 items 957.00 ns/op 948.00 ns/op 1.01
Uint8Array.set 32 items 1.8130 us/op 1.5160 us/op 1.20
Buffer.copy 2.1150 us/op 1.7490 us/op 1.21
Uint8Array.set - with subarray 2.8090 us/op 2.2670 us/op 1.24
Uint8Array.set - without subarray 1.9460 us/op 1.5110 us/op 1.29
getUint32 - dataview 238.00 ns/op 386.00 ns/op 0.62
getUint32 - manual 158.00 ns/op 331.00 ns/op 0.48
Set add up to 64 items then delete first 2.2114 us/op 1.6622 us/op 1.33
OrderedSet add up to 64 items then delete first 3.3338 us/op 2.7679 us/op 1.20
Set add up to 64 items then delete last 2.5386 us/op 1.9191 us/op 1.32
OrderedSet add up to 64 items then delete last 3.6905 us/op 3.0305 us/op 1.22
Set add up to 64 items then delete middle 2.6214 us/op 2.0029 us/op 1.31
OrderedSet add up to 64 items then delete middle 5.3547 us/op 4.2560 us/op 1.26
Set add up to 128 items then delete first 5.1093 us/op 3.7615 us/op 1.36
OrderedSet add up to 128 items then delete first 7.9758 us/op 5.8568 us/op 1.36
Set add up to 128 items then delete last 4.9110 us/op 3.6270 us/op 1.35
OrderedSet add up to 128 items then delete last 7.3190 us/op 5.5414 us/op 1.32
Set add up to 128 items then delete middle 4.9308 us/op 3.6341 us/op 1.36
OrderedSet add up to 128 items then delete middle 14.823 us/op 11.264 us/op 1.32
Set add up to 256 items then delete first 10.983 us/op 7.3960 us/op 1.49
OrderedSet add up to 256 items then delete first 17.618 us/op 11.963 us/op 1.47
Set add up to 256 items then delete last 11.004 us/op 7.2074 us/op 1.53
OrderedSet add up to 256 items then delete last 15.771 us/op 11.202 us/op 1.41
Set add up to 256 items then delete middle 10.217 us/op 7.1048 us/op 1.44
OrderedSet add up to 256 items then delete middle 46.790 us/op 34.528 us/op 1.36
transfer serialized Status (84 B) 1.5550 us/op 1.4030 us/op 1.11
copy serialized Status (84 B) 1.4180 us/op 1.2000 us/op 1.18
transfer serialized SignedVoluntaryExit (112 B) 1.8350 us/op 1.5450 us/op 1.19
copy serialized SignedVoluntaryExit (112 B) 1.4770 us/op 1.3420 us/op 1.10
transfer serialized ProposerSlashing (416 B) 2.5610 us/op 1.6980 us/op 1.51
copy serialized ProposerSlashing (416 B) 2.6470 us/op 2.1530 us/op 1.23
transfer serialized Attestation (485 B) 2.2340 us/op 2.0920 us/op 1.07
copy serialized Attestation (485 B) 2.0420 us/op 2.0210 us/op 1.01
transfer serialized AttesterSlashing (33232 B) 2.6710 us/op 2.2850 us/op 1.17
copy serialized AttesterSlashing (33232 B) 6.3690 us/op 5.1650 us/op 1.23
transfer serialized Small SignedBeaconBlock (128000 B) 3.7660 us/op 2.7910 us/op 1.35
copy serialized Small SignedBeaconBlock (128000 B) 15.602 us/op 9.5210 us/op 1.64
transfer serialized Avg SignedBeaconBlock (200000 B) 4.1650 us/op 2.4920 us/op 1.67
copy serialized Avg SignedBeaconBlock (200000 B) 23.876 us/op 11.831 us/op 2.02
transfer serialized BlobsSidecar (524380 B) 4.0430 us/op 3.0330 us/op 1.33
copy serialized BlobsSidecar (524380 B) 116.56 us/op 73.961 us/op 1.58
transfer serialized Big SignedBeaconBlock (1000000 B) 3.8720 us/op 3.1730 us/op 1.22
copy serialized Big SignedBeaconBlock (1000000 B) 163.49 us/op 132.52 us/op 1.23
pass gossip attestations to forkchoice per slot 2.9478 ms/op 2.4098 ms/op 1.22
forkChoice updateHead vc 100000 bc 64 eq 0 519.22 us/op 472.22 us/op 1.10
forkChoice updateHead vc 600000 bc 64 eq 0 3.1978 ms/op 2.6057 ms/op 1.23
forkChoice updateHead vc 1000000 bc 64 eq 0 5.6722 ms/op 4.0555 ms/op 1.40
forkChoice updateHead vc 600000 bc 320 eq 0 3.7985 ms/op 2.4924 ms/op 1.52
forkChoice updateHead vc 600000 bc 1200 eq 0 4.0655 ms/op 2.5436 ms/op 1.60
forkChoice updateHead vc 600000 bc 7200 eq 0 5.7529 ms/op 2.7706 ms/op 2.08
forkChoice updateHead vc 600000 bc 64 eq 1000 12.514 ms/op 9.6252 ms/op 1.30
forkChoice updateHead vc 600000 bc 64 eq 10000 11.754 ms/op 9.4451 ms/op 1.24
forkChoice updateHead vc 600000 bc 64 eq 300000 17.569 ms/op 11.589 ms/op 1.52
computeDeltas 500000 validators 300 proto nodes 5.1458 ms/op 3.0197 ms/op 1.70
computeDeltas 500000 validators 1200 proto nodes 5.0852 ms/op 3.0237 ms/op 1.68
computeDeltas 500000 validators 7200 proto nodes 5.8153 ms/op 3.1144 ms/op 1.87
computeDeltas 750000 validators 300 proto nodes 6.9836 ms/op 4.4246 ms/op 1.58
computeDeltas 750000 validators 1200 proto nodes 7.5508 ms/op 4.3886 ms/op 1.72
computeDeltas 750000 validators 7200 proto nodes 8.1293 ms/op 4.5213 ms/op 1.80
computeDeltas 1400000 validators 300 proto nodes 14.087 ms/op 8.6127 ms/op 1.64
computeDeltas 1400000 validators 1200 proto nodes 13.289 ms/op 8.5352 ms/op 1.56
computeDeltas 1400000 validators 7200 proto nodes 13.505 ms/op 8.5737 ms/op 1.58
computeDeltas 2100000 validators 300 proto nodes 21.099 ms/op 13.151 ms/op 1.60
computeDeltas 2100000 validators 1200 proto nodes 20.816 ms/op 12.746 ms/op 1.63
computeDeltas 2100000 validators 7200 proto nodes 20.541 ms/op 12.778 ms/op 1.61
altair processAttestation - 250000 vs - 7PWei normalcase 2.8894 ms/op 1.4115 ms/op 2.05
altair processAttestation - 250000 vs - 7PWei worstcase 4.5764 ms/op 2.0993 ms/op 2.18
altair processAttestation - setStatus - 1/6 committees join 131.06 us/op 72.076 us/op 1.82
altair processAttestation - setStatus - 1/3 committees join 314.39 us/op 146.36 us/op 2.15
altair processAttestation - setStatus - 1/2 committees join 437.66 us/op 183.48 us/op 2.39
altair processAttestation - setStatus - 2/3 committees join 505.69 us/op 278.70 us/op 1.81
altair processAttestation - setStatus - 4/5 committees join 1.0160 ms/op 431.82 us/op 2.35
altair processAttestation - setStatus - 100% committees join 1.0586 ms/op 514.96 us/op 2.06
altair processBlock - 250000 vs - 7PWei normalcase 11.543 ms/op 5.2211 ms/op 2.21
altair processBlock - 250000 vs - 7PWei normalcase hashState 48.504 ms/op 26.210 ms/op 1.85
altair processBlock - 250000 vs - 7PWei worstcase 53.970 ms/op 34.790 ms/op 1.55
altair processBlock - 250000 vs - 7PWei worstcase hashState 113.51 ms/op 76.777 ms/op 1.48
phase0 processBlock - 250000 vs - 7PWei normalcase 4.0199 ms/op 2.0183 ms/op 1.99
phase0 processBlock - 250000 vs - 7PWei worstcase 35.829 ms/op 22.970 ms/op 1.56
altair processEth1Data - 250000 vs - 7PWei normalcase 812.37 us/op 259.01 us/op 3.14
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 12.386 us/op 6.1370 us/op 2.02
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 56.079 us/op 28.803 us/op 1.95
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 20.787 us/op 9.7820 us/op 2.13
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 13.707 us/op 5.8820 us/op 2.33
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 201.81 us/op 131.53 us/op 1.53
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.8822 ms/op 864.55 us/op 2.18
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.9056 ms/op 1.2773 ms/op 2.27
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 2.4345 ms/op 1.1102 ms/op 2.19
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 6.6113 ms/op 2.9440 ms/op 2.25
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.6231 ms/op 1.1777 ms/op 2.23
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 9.2460 ms/op 3.1553 ms/op 2.93
Tree 40 250000 create 725.58 ms/op 228.02 ms/op 3.18
Tree 40 250000 get(125000) 218.08 ns/op 119.08 ns/op 1.83
Tree 40 250000 set(125000) 2.7274 us/op 545.30 ns/op 5.00
Tree 40 250000 toArray() 35.648 ms/op 24.008 ms/op 1.48
Tree 40 250000 iterate all - toArray() + loop 31.326 ms/op 22.474 ms/op 1.39
Tree 40 250000 iterate all - get(i) 79.655 ms/op 56.913 ms/op 1.40
Array 250000 create 4.8820 ms/op 3.8791 ms/op 1.26
Array 250000 clone - spread 4.6557 ms/op 1.2256 ms/op 3.80
Array 250000 get(125000) 0.91800 ns/op 0.59700 ns/op 1.54
Array 250000 set(125000) 0.68900 ns/op 0.60600 ns/op 1.14
Array 250000 iterate all - loop 149.44 us/op 76.362 us/op 1.96
phase0 afterProcessEpoch - 250000 vs - 7PWei 129.74 ms/op 86.728 ms/op 1.50
Array.fill - length 1000000 7.9361 ms/op 2.7566 ms/op 2.88
Array push - length 1000000 43.814 ms/op 17.435 ms/op 2.51
Array.get 0.43044 ns/op 0.27840 ns/op 1.55
Uint8Array.get 0.55972 ns/op 0.36012 ns/op 1.55
phase0 beforeProcessEpoch - 250000 vs - 7PWei 34.148 ms/op 23.350 ms/op 1.46
altair processEpoch - mainnet_e81889 480.35 ms/op 276.08 ms/op 1.74
mainnet_e81889 - altair beforeProcessEpoch 29.593 ms/op 23.343 ms/op 1.27
mainnet_e81889 - altair processJustificationAndFinalization 30.336 us/op 16.318 us/op 1.86
mainnet_e81889 - altair processInactivityUpdates 9.6113 ms/op 4.6084 ms/op 2.09
mainnet_e81889 - altair processRewardsAndPenalties 67.661 ms/op 49.484 ms/op 1.37
mainnet_e81889 - altair processRegistryUpdates 6.6260 us/op 2.0300 us/op 3.26
mainnet_e81889 - altair processSlashings 1.0190 us/op 721.00 ns/op 1.41
mainnet_e81889 - altair processEth1DataReset 889.00 ns/op 714.00 ns/op 1.25
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.9844 ms/op 1.6882 ms/op 1.18
mainnet_e81889 - altair processSlashingsReset 9.4760 us/op 2.6200 us/op 3.62
mainnet_e81889 - altair processRandaoMixesReset 15.648 us/op 3.2170 us/op 4.86
mainnet_e81889 - altair processHistoricalRootsUpdate 1.7040 us/op 742.00 ns/op 2.30
mainnet_e81889 - altair processParticipationFlagUpdates 6.5180 us/op 4.2740 us/op 1.53
mainnet_e81889 - altair processSyncCommitteeUpdates 1.3040 us/op 850.00 ns/op 1.53
mainnet_e81889 - altair afterProcessEpoch 138.19 ms/op 82.189 ms/op 1.68
capella processEpoch - mainnet_e217614 1.4510 s/op 1.2437 s/op 1.17
mainnet_e217614 - capella beforeProcessEpoch 87.841 ms/op 140.75 ms/op 0.62
mainnet_e217614 - capella processJustificationAndFinalization 30.612 us/op 22.496 us/op 1.36
mainnet_e217614 - capella processInactivityUpdates 23.946 ms/op 24.694 ms/op 0.97
mainnet_e217614 - capella processRewardsAndPenalties 247.98 ms/op 303.03 ms/op 0.82
mainnet_e217614 - capella processRegistryUpdates 13.672 us/op 16.256 us/op 0.84
mainnet_e217614 - capella processSlashings 597.00 ns/op 960.00 ns/op 0.62
mainnet_e217614 - capella processEth1DataReset 494.00 ns/op 995.00 ns/op 0.50
mainnet_e217614 - capella processEffectiveBalanceUpdates 19.598 ms/op 18.998 ms/op 1.03
mainnet_e217614 - capella processSlashingsReset 5.6280 us/op 4.9010 us/op 1.15
mainnet_e217614 - capella processRandaoMixesReset 7.9270 us/op 7.4200 us/op 1.07
mainnet_e217614 - capella processHistoricalRootsUpdate 512.00 ns/op 1.1200 us/op 0.46
mainnet_e217614 - capella processParticipationFlagUpdates 3.5150 us/op 5.4880 us/op 0.64
mainnet_e217614 - capella afterProcessEpoch 260.75 ms/op 202.38 ms/op 1.29
phase0 processEpoch - mainnet_e58758 407.69 ms/op 401.07 ms/op 1.02
mainnet_e58758 - phase0 beforeProcessEpoch 78.516 ms/op 122.65 ms/op 0.64
mainnet_e58758 - phase0 processJustificationAndFinalization 22.228 us/op 19.905 us/op 1.12
mainnet_e58758 - phase0 processRewardsAndPenalties 33.158 ms/op 25.219 ms/op 1.31
mainnet_e58758 - phase0 processRegistryUpdates 8.7130 us/op 12.576 us/op 0.69
mainnet_e58758 - phase0 processSlashings 386.00 ns/op 979.00 ns/op 0.39
mainnet_e58758 - phase0 processEth1DataReset 485.00 ns/op 951.00 ns/op 0.51
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.0552 ms/op 1.4756 ms/op 1.39
mainnet_e58758 - phase0 processSlashingsReset 3.9700 us/op 6.5900 us/op 0.60
mainnet_e58758 - phase0 processRandaoMixesReset 6.2710 us/op 7.1580 us/op 0.88
mainnet_e58758 - phase0 processHistoricalRootsUpdate 589.00 ns/op 1.4820 us/op 0.40
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.9820 us/op 4.6910 us/op 1.06
mainnet_e58758 - phase0 afterProcessEpoch 82.183 ms/op 66.784 ms/op 1.23
phase0 processEffectiveBalanceUpdates - 250000 normalcase 3.4518 ms/op 966.36 us/op 3.57
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.2795 ms/op 1.9654 ms/op 1.16
altair processInactivityUpdates - 250000 normalcase 21.220 ms/op 20.650 ms/op 1.03
altair processInactivityUpdates - 250000 worstcase 20.564 ms/op 24.639 ms/op 0.83
phase0 processRegistryUpdates - 250000 normalcase 7.3310 us/op 6.0020 us/op 1.22
phase0 processRegistryUpdates - 250000 badcase_full_deposits 317.02 us/op 332.41 us/op 0.95
phase0 processRegistryUpdates - 250000 worstcase 0.5 144.80 ms/op 126.69 ms/op 1.14
altair processRewardsAndPenalties - 250000 normalcase 48.670 ms/op 59.693 ms/op 0.82
altair processRewardsAndPenalties - 250000 worstcase 47.636 ms/op 45.258 ms/op 1.05
phase0 getAttestationDeltas - 250000 normalcase 8.9252 ms/op 6.3114 ms/op 1.41
phase0 getAttestationDeltas - 250000 worstcase 8.5742 ms/op 6.6061 ms/op 1.30
phase0 processSlashings - 250000 worstcase 97.020 us/op 91.586 us/op 1.06
altair processSyncCommitteeUpdates - 250000 134.48 ms/op 105.07 ms/op 1.28
BeaconState.hashTreeRoot - No change 243.00 ns/op 455.00 ns/op 0.53
BeaconState.hashTreeRoot - 1 full validator 93.551 us/op 147.54 us/op 0.63
BeaconState.hashTreeRoot - 32 full validator 1.0063 ms/op 1.4310 ms/op 0.70
BeaconState.hashTreeRoot - 512 full validator 10.420 ms/op 8.4238 ms/op 1.24
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 126.30 us/op 91.510 us/op 1.38
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.1642 ms/op 1.8866 ms/op 1.15
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 34.414 ms/op 21.464 ms/op 1.60
BeaconState.hashTreeRoot - 1 balances 106.69 us/op 89.457 us/op 1.19
BeaconState.hashTreeRoot - 32 balances 1.1629 ms/op 726.01 us/op 1.60
BeaconState.hashTreeRoot - 512 balances 12.089 ms/op 6.6603 ms/op 1.82
BeaconState.hashTreeRoot - 250000 balances 185.55 ms/op 130.03 ms/op 1.43
aggregationBits - 2048 els - zipIndexesInBitList 26.582 us/op 23.726 us/op 1.12
byteArrayEquals 32 58.234 ns/op 47.490 ns/op 1.23
Buffer.compare 32 18.223 ns/op 15.093 ns/op 1.21
byteArrayEquals 1024 1.7193 us/op 1.2427 us/op 1.38
Buffer.compare 1024 27.394 ns/op 22.716 ns/op 1.21
byteArrayEquals 16384 28.797 us/op 19.735 us/op 1.46
Buffer.compare 16384 213.96 ns/op 178.22 ns/op 1.20
byteArrayEquals 123687377 213.92 ms/op 150.11 ms/op 1.43
Buffer.compare 123687377 7.7526 ms/op 4.3862 ms/op 1.77
byteArrayEquals 32 - diff last byte 56.856 ns/op 46.648 ns/op 1.22
Buffer.compare 32 - diff last byte 18.610 ns/op 15.796 ns/op 1.18
byteArrayEquals 1024 - diff last byte 1.7396 us/op 1.2502 us/op 1.39
Buffer.compare 1024 - diff last byte 28.091 ns/op 24.032 ns/op 1.17
byteArrayEquals 16384 - diff last byte 26.576 us/op 19.838 us/op 1.34
Buffer.compare 16384 - diff last byte 208.17 ns/op 201.91 ns/op 1.03
byteArrayEquals 123687377 - diff last byte 199.68 ms/op 144.07 ms/op 1.39
Buffer.compare 123687377 - diff last byte 7.4336 ms/op 5.4276 ms/op 1.37
byteArrayEquals 32 - random bytes 5.6470 ns/op 4.8040 ns/op 1.18
Buffer.compare 32 - random bytes 18.994 ns/op 15.070 ns/op 1.26
byteArrayEquals 1024 - random bytes 5.4230 ns/op 4.7800 ns/op 1.13
Buffer.compare 1024 - random bytes 18.150 ns/op 14.797 ns/op 1.23
byteArrayEquals 16384 - random bytes 5.4150 ns/op 4.7000 ns/op 1.15
Buffer.compare 16384 - random bytes 18.071 ns/op 14.832 ns/op 1.22
byteArrayEquals 123687377 - random bytes 6.8300 ns/op 7.5600 ns/op 0.90
Buffer.compare 123687377 - random bytes 19.420 ns/op 17.680 ns/op 1.10
regular array get 100000 times 38.354 us/op 29.324 us/op 1.31
wrappedArray get 100000 times 36.058 us/op 29.330 us/op 1.23
arrayWithProxy get 100000 times 15.015 ms/op 10.186 ms/op 1.47
ssz.Root.equals 50.578 ns/op 44.283 ns/op 1.14
byteArrayEquals 51.005 ns/op 43.086 ns/op 1.18
Buffer.compare 11.531 ns/op 9.1160 ns/op 1.26
shuffle list - 16384 els 7.0350 ms/op 5.3620 ms/op 1.31
shuffle list - 250000 els 104.32 ms/op 79.830 ms/op 1.31
processSlot - 1 slots 15.342 us/op 12.714 us/op 1.21
processSlot - 32 slots 3.4354 ms/op 2.5557 ms/op 1.34
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 41.594 ms/op 38.478 ms/op 1.08
getCommitteeAssignments - req 1 vs - 250000 vc 2.2044 ms/op 1.8144 ms/op 1.21
getCommitteeAssignments - req 100 vs - 250000 vc 4.3218 ms/op 3.4647 ms/op 1.25
getCommitteeAssignments - req 1000 vs - 250000 vc 4.6206 ms/op 3.7900 ms/op 1.22
findModifiedValidators - 10000 modified validators 254.05 ms/op 229.85 ms/op 1.11
findModifiedValidators - 1000 modified validators 177.85 ms/op 136.68 ms/op 1.30
findModifiedValidators - 100 modified validators 153.63 ms/op 139.80 ms/op 1.10
findModifiedValidators - 10 modified validators 182.31 ms/op 141.79 ms/op 1.29
findModifiedValidators - 1 modified validators 154.89 ms/op 145.86 ms/op 1.06
findModifiedValidators - no difference 162.89 ms/op 139.20 ms/op 1.17
compare ViewDUs 3.2685 s/op 3.0761 s/op 1.06
compare each validator Uint8Array 1.3032 s/op 1.5870 s/op 0.82
compare ViewDU to Uint8Array 1.2654 s/op 772.85 ms/op 1.64
migrate state 1000000 validators, 24 modified, 0 new 1.0986 s/op 805.87 ms/op 1.36
migrate state 1000000 validators, 1700 modified, 1000 new 1.3876 s/op 1.0616 s/op 1.31
migrate state 1000000 validators, 3400 modified, 2000 new 1.8559 s/op 1.2092 s/op 1.53
migrate state 1500000 validators, 24 modified, 0 new 1.1889 s/op 762.24 ms/op 1.56
migrate state 1500000 validators, 1700 modified, 1000 new 1.5597 s/op 1.1511 s/op 1.35
migrate state 1500000 validators, 3400 modified, 2000 new 1.9366 s/op 1.3126 s/op 1.48
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.4800 ns/op 6.4000 ns/op 0.86
state getBlockRootAtSlot - 250000 vs - 7PWei 700.79 ns/op 415.03 ns/op 1.69
computeProposers - vc 250000 8.9014 ms/op 5.5841 ms/op 1.59
computeEpochShuffling - vc 250000 115.72 ms/op 78.132 ms/op 1.48
getNextSyncCommittee - vc 250000 188.16 ms/op 95.009 ms/op 1.98
computeSigningRoot for AttestationData 31.804 us/op 25.349 us/op 1.25
hash AttestationData serialized data then Buffer.toString(base64) 1.8952 us/op 1.2006 us/op 1.58
toHexString serialized data 1.1422 us/op 862.56 ns/op 1.32
Buffer.toString(base64) 218.93 ns/op 165.31 ns/op 1.32
nodejs block root to RootHex using toHex 186.05 ns/op 115.54 ns/op 1.61
nodejs block root to RootHex using toRootHex 110.44 ns/op 74.927 ns/op 1.47
browser block root to RootHex using the deprecated toHexString 275.52 ns/op 227.98 ns/op 1.21
browser block root to RootHex using toHex 225.34 ns/op 176.07 ns/op 1.28
browser block root to RootHex using toRootHex 190.97 ns/op 148.12 ns/op 1.29

Please sign in to comment.