Skip to content

Commit

Permalink
feat: use napi-rs pubkey-index-map (#7091)
Browse files Browse the repository at this point in the history
* feat: use napi-rs pubkey-index-map

* fix: export toMemoryEfficientHexStr()

* fix: state-transition CachedBeaconState unit test

* chore: remove commented code
  • Loading branch information
twoeths authored Sep 30, 2024
1 parent d69d809 commit fe7e21b
Show file tree
Hide file tree
Showing 27 changed files with 94 additions and 62 deletions.
1 change: 1 addition & 0 deletions packages/beacon-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"@chainsafe/prometheus-gc-stats": "^1.0.0",
"@chainsafe/ssz": "^0.17.1",
"@chainsafe/threads": "^1.11.1",
"@chainsafe/pubkey-index-map": "2.0.0",
"@ethersproject/abi": "^5.7.0",
"@fastify/bearer-auth": "^10.0.1",
"@fastify/cors": "^10.0.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/beacon-node/src/api/impl/beacon/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getRandaoMix,
} from "@lodestar/state-transition";
import {EPOCHS_PER_HISTORICAL_VECTOR} from "@lodestar/params";
import {fromHex} from "@lodestar/utils";
import {ApiError} from "../../errors.js";
import {ApiModules} from "../../types.js";
import {
Expand Down Expand Up @@ -200,7 +201,7 @@ export function getBeaconStateApi({
}
balances.push({index: id, balance: state.balances.get(id)});
} else {
const index = headState.epochCtx.pubkey2index.get(id);
const index = headState.epochCtx.pubkey2index.get(fromHex(id));
if (index != null && index <= state.validators.length) {
balances.push({index, balance: state.balances.get(index)});
}
Expand Down
5 changes: 3 additions & 2 deletions packages/beacon-node/src/api/impl/beacon/state/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {routes} from "@lodestar/api";
import {FAR_FUTURE_EPOCH, GENESIS_SLOT} from "@lodestar/params";
import {BeaconStateAllForks, PubkeyIndexMap} from "@lodestar/state-transition";
import {BeaconStateAllForks} from "@lodestar/state-transition";
import {BLSPubkey, Epoch, phase0, RootHex, Slot, ValidatorIndex} from "@lodestar/types";
import {fromHex} from "@lodestar/utils";
import {CheckpointWithHex, IForkChoice} from "@lodestar/fork-choice";
Expand Down Expand Up @@ -187,7 +188,7 @@ export function getStateValidatorIndex(

// typeof id === Uint8Array
const validatorIndex = pubkey2index.get(id);
if (validatorIndex === undefined) {
if (validatorIndex === null) {
return {valid: false, code: 404, reason: "Validator pubkey not found in state"};
}
if (validatorIndex >= state.validators.length) {
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ export function getValidatorApi(
const filteredRegistrations = registrations.filter((registration) => {
const {pubkey} = registration.message;
const validatorIndex = headState.epochCtx.pubkey2index.get(pubkey);
if (validatorIndex === undefined) return false;
if (validatorIndex === null) return false;

const validator = headState.validators.getReadonly(validatorIndex);
const status = getValidatorStatus(validator, currentEpoch);
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from "node:path";
import {CompositeTypeAny, TreeView, Type} from "@chainsafe/ssz";
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {
BeaconStateAllForks,
CachedBeaconStateAllForks,
Expand All @@ -10,7 +11,6 @@ import {
getEffectiveBalanceIncrementsZeroInactive,
isCachedBeaconState,
Index2PubkeyCache,
PubkeyIndexMap,
EpochShuffling,
computeEndSlotAtEpoch,
computeAnchorCheckpoint,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {
BeaconStateAllForks,
CachedBeaconStateAllForks,
DataAvailableStatus,
ExecutionPayloadStatus,
PubkeyIndexMap,
createCachedBeaconState,
stateTransition,
} from "@lodestar/state-transition";
Expand Down
8 changes: 2 additions & 6 deletions packages/beacon-node/src/chain/historicalState/worker.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import worker from "node:worker_threads";
import {Transfer, expose} from "@chainsafe/threads/worker";
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {createBeaconConfig, chainConfigFromJson} from "@lodestar/config";
import {getNodeLogger} from "@lodestar/logger/node";
import {
EpochTransitionStep,
PubkeyIndexMap,
StateCloneSource,
StateHashTreeRootSource,
} from "@lodestar/state-transition";
import {EpochTransitionStep, StateCloneSource, StateHashTreeRootSource} from "@lodestar/state-transition";
import {LevelDbController} from "@lodestar/db";
import {RegistryMetricCreator, collectNodeJSMetrics} from "../../metrics/index.js";
import {JobFnQueue} from "../../util/queue/fnQueue.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {CompositeTypeAny, TreeView, Type} from "@chainsafe/ssz";
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {
UintNum64,
Root,
Expand All @@ -21,7 +22,6 @@ import {
CachedBeaconStateAllForks,
EpochShuffling,
Index2PubkeyCache,
PubkeyIndexMap,
} from "@lodestar/state-transition";
import {BeaconConfig} from "@lodestar/config";
import {Logger} from "@lodestar/utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
isInInactivityLeak,
} from "@lodestar/state-transition";
import {BeaconConfig} from "@lodestar/config";
import {fromHex} from "@lodestar/utils";

export type AttestationsRewards = routes.beacon.AttestationsRewards;
type IdealAttestationsReward = routes.beacon.IdealAttestationsReward;
Expand Down Expand Up @@ -143,7 +144,7 @@ function computeTotalAttestationsRewardsAltair(
const {flags} = transitionCache;
const {epochCtx, config} = state;
const validatorIndices = validatorIds
.map((id) => (typeof id === "number" ? id : epochCtx.pubkey2index.get(id)))
.map((id) => (typeof id === "number" ? id : epochCtx.pubkey2index.get(fromHex(id))))
.filter((index) => index !== undefined); // Validator indices to include in the result

const inactivityPenaltyDenominator = config.INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_ALTAIR;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {itBench, setBenchOpts} from "@dapplion/benchmark";
import {Map} from "immutable";
import {Map as ImmutableMap} from "immutable";
import {toBufferBE} from "bigint-buffer";
import {digest} from "@chainsafe/as-sha256";
import {SecretKey} from "@chainsafe/blst";
import {ssz} from "@lodestar/types";
import {type CachedBeaconStateAllForks, PubkeyIndexMap} from "@lodestar/state-transition";
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {ValidatorIndex, ssz} from "@lodestar/types";
import {type CachedBeaconStateAllForks, toMemoryEfficientHexStr} from "@lodestar/state-transition";
import {bytesToBigInt, intToBytes} from "@lodestar/utils";
import {InMemoryCheckpointStateCache, BlockStateCacheImpl} from "../../../../src/chain/stateCache/index.js";
import {BlockStateCache} from "../../../../src/chain/stateCache/types.js";
Expand All @@ -31,7 +32,7 @@ describe("updateUnfinalizedPubkeys perf tests", function () {
itBench({
id: `updateUnfinalizedPubkeys - updating ${numPubkeysToBeFinalized} pubkeys`,
beforeEach: async () => {
baseState.epochCtx.unfinalizedPubkey2index = Map(unfinalizedPubkey2Index.map);
baseState.epochCtx.unfinalizedPubkey2index = ImmutableMap(unfinalizedPubkey2Index);
baseState.epochCtx.pubkey2index = new PubkeyIndexMap();
baseState.epochCtx.index2pubkey = [];

Expand Down Expand Up @@ -80,12 +81,14 @@ describe("updateUnfinalizedPubkeys perf tests", function () {
});
}

function generatePubkey2Index(startIndex: number, endIndex: number): PubkeyIndexMap {
const pubkey2Index = new PubkeyIndexMap();
type PubkeyHex = string;

function generatePubkey2Index(startIndex: number, endIndex: number): Map<PubkeyHex, ValidatorIndex> {
const pubkey2Index = new Map<string, number>();
const pubkeys = generatePubkeys(endIndex - startIndex);

for (let i = startIndex; i < endIndex; i++) {
pubkey2Index.set(pubkeys[i], i);
pubkey2Index.set(toMemoryEfficientHexStr(pubkeys[i]), i);
}

return pubkey2Index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ describe("beacon state api utils", function () {
// "validator id not in state"
expect(getStateValidatorIndex(String(state.validators.length), state, pubkey2index).valid).toBe(false);
// "validator pubkey not in state"
expect(getStateValidatorIndex("0xabcd", state, pubkey2index).valid).toBe(false);
expect(
getStateValidatorIndex(
"0xa99af0913a2834ef4959637e8d7c4e17f0b63adc587d36ab43510452db3102d0771a4554ea4118a33913827d5ee80b76",
state,
pubkey2index
).valid
).toBe(false);
});

it("should return valid: true on validator indices / pubkeys in the state", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/test/utils/state.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {SecretKey} from "@chainsafe/blst";
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {config as minimalConfig} from "@lodestar/config/default";
import {
BeaconStateAllForks,
CachedBeaconStateAllForks,
createCachedBeaconState,
PubkeyIndexMap,
CachedBeaconStateBellatrix,
BeaconStateBellatrix,
CachedBeaconStateElectra,
Expand Down
1 change: 1 addition & 0 deletions packages/state-transition/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@lodestar/config": "^1.22.0",
"@lodestar/params": "^1.22.0",
"@lodestar/types": "^1.22.0",
"@chainsafe/pubkey-index-map": "2.0.0",
"@lodestar/utils": "^1.22.0",
"bigint-buffer": "^1.1.5",
"immutable": "^4.3.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function processConsolidationRequest(
const sourceIndex = state.epochCtx.getValidatorIndex(sourcePubkey);
const targetIndex = state.epochCtx.getValidatorIndex(targetPubkey);

if (sourceIndex === undefined || targetIndex === undefined) {
if (sourceIndex === null || targetIndex === null) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/src/block/processDeposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function applyDeposit(
const {pubkey, withdrawalCredentials, amount} = deposit;

const cachedIndex = epochCtx.getValidatorIndex(pubkey);
if (cachedIndex === undefined || !Number.isSafeInteger(cachedIndex) || cachedIndex >= validators.length) {
if (cachedIndex === null || !Number.isSafeInteger(cachedIndex) || cachedIndex >= validators.length) {
if (isValidDepositSignature(config, pubkey, withdrawalCredentials, amount, deposit.signature)) {
addValidatorToRegistry(fork, state, pubkey, withdrawalCredentials, amount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function processWithdrawalRequest(
// bail out if validator is not in beacon state
// note that we don't need to check for 6110 unfinalized vals as they won't be eligible for withdraw/exit anyway
const validatorIndex = pubkey2index.get(withdrawalRequest.validatorPubkey);
if (validatorIndex === undefined) {
if (validatorIndex === null) {
return;
}

Expand Down
15 changes: 9 additions & 6 deletions packages/state-transition/src/cache/epochCache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {PublicKey} from "@chainsafe/blst";
import * as immutable from "immutable";
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {
BLSSignature,
CommitteeIndex,
Expand Down Expand Up @@ -53,7 +54,6 @@ import {EffectiveBalanceIncrements, getEffectiveBalanceIncrementsWithLen} from "
import {BeaconStateAllForks, BeaconStateAltair} from "./types.js";
import {
Index2PubkeyCache,
PubkeyIndexMap,
UnfinalizedPubkeyIndexMap,
syncPubkeys,
toMemoryEfficientHexStr,
Expand Down Expand Up @@ -1023,9 +1023,9 @@ export class EpochCache {
return this.index2pubkey[index];
}

getValidatorIndex(pubkey: Uint8Array | PubkeyHex): ValidatorIndex | undefined {
getValidatorIndex(pubkey: Uint8Array): ValidatorIndex | null {
if (this.isPostElectra()) {
return this.pubkey2index.get(pubkey) ?? this.unfinalizedPubkey2index.get(toMemoryEfficientHexStr(pubkey));
return this.pubkey2index.get(pubkey) ?? this.unfinalizedPubkey2index.get(toMemoryEfficientHexStr(pubkey)) ?? null;
} else {
return this.pubkey2index.get(pubkey);
}
Expand Down Expand Up @@ -1059,17 +1059,20 @@ export class EpochCache {
* Add finalized validator index and pubkey into finalized cache.
* Since addFinalizedPubkey() primarily takes pubkeys from unfinalized cache, it can take pubkey hex string directly
*/
addFinalizedPubkey(index: ValidatorIndex, pubkey: PubkeyHex | Uint8Array, metrics?: EpochCacheMetrics): void {
addFinalizedPubkey(index: ValidatorIndex, pubkeyOrHex: PubkeyHex | Uint8Array, metrics?: EpochCacheMetrics): void {
const pubkey = typeof pubkeyOrHex === "string" ? fromHex(pubkeyOrHex) : pubkeyOrHex;
const existingIndex = this.pubkey2index.get(pubkey);

if (existingIndex !== undefined) {
if (existingIndex !== null) {
if (existingIndex === index) {
// Repeated insert.
metrics?.finalizedPubkeyDuplicateInsert.inc();
return;
} else {
// attempt to insert the same pubkey with different index, should never happen.
throw Error("inserted existing pubkey into finalizedPubkey2index cache with a different index");
throw Error(
`inserted existing pubkey into finalizedPubkey2index cache with a different index, index=${index} priorIndex=${existingIndex}`
);
}
}

Expand Down
21 changes: 1 addition & 20 deletions packages/state-transition/src/cache/pubkeyCache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {PublicKey} from "@chainsafe/blst";
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import * as immutable from "immutable";
import {ValidatorIndex, phase0} from "@lodestar/types";

Expand Down Expand Up @@ -39,26 +40,6 @@ export function newUnfinalizedPubkeyIndexMap(): UnfinalizedPubkeyIndexMap {
return immutable.Map<PubkeyHex, ValidatorIndex>();
}

export class PubkeyIndexMap {
// We don't really need the full pubkey. We could just use the first 20 bytes like an Ethereum address
readonly map = new Map<PubkeyHex, ValidatorIndex>();

get size(): number {
return this.map.size;
}

/**
* Must support reading with string for API support where pubkeys are already strings
*/
get(key: Uint8Array | PubkeyHex): ValidatorIndex | undefined {
return this.map.get(toMemoryEfficientHexStr(key));
}

set(key: Uint8Array | PubkeyHex, value: ValidatorIndex): void {
this.map.set(toMemoryEfficientHexStr(key), value);
}
}

/**
* Checks the pubkey indices against a state and adds missing pubkeys
*
Expand Down
4 changes: 2 additions & 2 deletions packages/state-transition/src/cache/syncCommitteeCache.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CompositeViewDU} from "@chainsafe/ssz";
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {ssz, ValidatorIndex} from "@lodestar/types";
import {toPubkeyHex} from "@lodestar/utils";
import {PubkeyIndexMap} from "./pubkeyCache.js";

type SyncComitteeValidatorIndexMap = Map<ValidatorIndex, number[]>;

Expand Down Expand Up @@ -82,7 +82,7 @@ function computeSyncCommitteeIndices(
const pubkeys = syncCommittee.pubkeys.getAllReadonly();
for (const pubkey of pubkeys) {
const validatorIndex = pubkey2index.get(pubkey);
if (validatorIndex === undefined) {
if (validatorIndex === null) {
throw Error(`SyncCommittee pubkey is unknown ${toPubkeyHex(pubkey)}`);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ export {
EpochCacheError,
EpochCacheErrorCode,
} from "./cache/epochCache.js";
export {toMemoryEfficientHexStr} from "./cache/pubkeyCache.js";
export {type EpochTransitionCache, beforeProcessEpoch} from "./cache/epochTransitionCache.js";

// Aux data-structures
export {
PubkeyIndexMap,
type Index2PubkeyCache,
type UnfinalizedPubkeyIndexMap,
newUnfinalizedPubkeyIndexMap,
Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/test/perf/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {BitArray, fromHexString} from "@chainsafe/ssz";
import {PublicKey, SecretKey} from "@chainsafe/blst";
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {phase0, ssz, Slot, BeaconState} from "@lodestar/types";
import {config} from "@lodestar/config/default";
import {createBeaconConfig, createChainForkConfig} from "@lodestar/config";
Expand All @@ -17,7 +18,6 @@ import {
interopSecretKey,
computeEpochAtSlot,
getActiveValidatorIndices,
PubkeyIndexMap,
newFilledArray,
createCachedBeaconState,
computeCommitteeCount,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {itBench, setBenchOpts} from "@dapplion/benchmark";
import {PublicKey} from "@chainsafe/blst";
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {loadState} from "../../../../src/util/loadState/loadState.js";
import {createCachedBeaconState} from "../../../../src/cache/stateCache.js";
import {Index2PubkeyCache, PubkeyIndexMap} from "../../../../src/cache/pubkeyCache.js";
import {Index2PubkeyCache} from "../../../../src/cache/pubkeyCache.js";
import {generatePerfTestCachedStateAltair} from "../../util.js";

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/state-transition/test/unit/cachedBeaconState.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {fromHexString} from "@chainsafe/ssz";
import {describe, it, expect} from "vitest";
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
import {ssz} from "@lodestar/types";
import {toHexString} from "@lodestar/utils";
import {config as defaultConfig} from "@lodestar/config/default";
import {createBeaconConfig, createChainForkConfig} from "@lodestar/config";
import {createCachedBeaconStateTest} from "../utils/state.js";
import {PubkeyIndexMap} from "../../src/cache/pubkeyCache.js";
import {createCachedBeaconState, loadCachedBeaconState} from "../../src/cache/stateCache.js";
import {interopPubkeysCached} from "../utils/interop.js";
import {modifyStateSameValidator, newStateWithValidators} from "../utils/capella.js";
Expand Down Expand Up @@ -83,7 +83,7 @@ describe("CachedBeaconState", () => {

expect(state1.epochCtx.getValidatorIndex(pubkey1)).toBe(index1);
expect(state2.epochCtx.getValidatorIndex(pubkey1)).toBe(index1);
expect(state1.epochCtx.getValidatorIndex(pubkey2)).toBe(undefined);
expect(state1.epochCtx.getValidatorIndex(pubkey2)).toBe(null);
expect(state2.epochCtx.getValidatorIndex(pubkey2)).toBe(index2);
});

Expand Down
Loading

1 comment on commit fe7e21b

@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: fe7e21b Previous: d69d809 Ratio
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 175.07 us/op 53.329 us/op 3.28
BLS verifyMultipleSignatures 8 - blst 7.0275 ms/op 1.9009 ms/op 3.70
BLS verifyMultipleSignatures 32 - blst 20.324 ms/op 5.8605 ms/op 3.47
BLS verifyMultipleSignatures 64 - blst 37.674 ms/op 10.792 ms/op 3.49
BLS verifyMultipleSignatures 128 - blst 55.985 ms/op 17.251 ms/op 3.25
BLS verifyMultipleSignatures - same message - 3 - blst 3.4407 ms/op 1.1093 ms/op 3.10
BLS verifyMultipleSignatures - same message - 32 - blst 6.0416 ms/op 1.8242 ms/op 3.31
BLS verifyMultipleSignatures - same message - 64 - blst 10.390 ms/op 2.6034 ms/op 3.99
BLS verifyMultipleSignatures - same message - 128 - blst 15.403 ms/op 4.3304 ms/op 3.56
BLS aggregatePubkeys 32 - blst 90.141 us/op 20.002 us/op 4.51
BLS aggregatePubkeys 128 - blst 270.70 us/op 70.383 us/op 3.85
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 170.72 ms/op 54.754 ms/op 3.12
isKnown best case - 1 super set check 1.1150 us/op 304.00 ns/op 3.67
isKnown normal case - 2 super set checks 1.0330 us/op 284.00 ns/op 3.64
isKnown worse case - 16 super set checks 1.0610 us/op 283.00 ns/op 3.75
Object get x1000 17.779 ns/op 5.8620 ns/op 3.03
Map get x1000 20.442 ns/op 6.2680 ns/op 3.26
send data - 1000 65536B messages 1.1354 s/op 206.06 ms/op 5.51
Buffer.concat 32 items 2.7940 us/op 892.00 ns/op 3.13
getUint32 - manual 515.00 ns/op 149.00 ns/op 3.46
OrderedSet add up to 64 items then delete first 10.273 us/op 3.1889 us/op 3.22
Set add up to 64 items then delete last 7.4399 us/op 2.4576 us/op 3.03
OrderedSet add up to 128 items then delete first 24.782 us/op 7.6974 us/op 3.22
Set add up to 128 items then delete last 15.192 us/op 4.7761 us/op 3.18
OrderedSet add up to 128 items then delete last 21.894 us/op 7.1026 us/op 3.08
Set add up to 256 items then delete first 30.880 us/op 10.034 us/op 3.08
pass gossip attestations to forkchoice per slot 8.5510 ms/op 2.7686 ms/op 3.09
forkChoice updateHead vc 600000 bc 64 eq 0 11.614 ms/op 2.9482 ms/op 3.94
forkChoice updateHead vc 600000 bc 64 eq 300000 51.115 ms/op 14.493 ms/op 3.53
altair processAttestation - setStatus - 4/5 committees join 1.5583 ms/op 482.73 us/op 3.23
Full benchmark results
Benchmark suite Current: fe7e21b Previous: d69d809 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 4.7169 ms/op 1.8918 ms/op 2.49
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 175.07 us/op 53.329 us/op 3.28
BLS verify - blst 2.7948 ms/op 993.66 us/op 2.81
BLS verifyMultipleSignatures 3 - blst 3.7195 ms/op 1.4510 ms/op 2.56
BLS verifyMultipleSignatures 8 - blst 7.0275 ms/op 1.9009 ms/op 3.70
BLS verifyMultipleSignatures 32 - blst 20.324 ms/op 5.8605 ms/op 3.47
BLS verifyMultipleSignatures 64 - blst 37.674 ms/op 10.792 ms/op 3.49
BLS verifyMultipleSignatures 128 - blst 55.985 ms/op 17.251 ms/op 3.25
BLS deserializing 10000 signatures 2.0264 s/op 683.96 ms/op 2.96
BLS deserializing 100000 signatures 20.064 s/op 6.8383 s/op 2.93
BLS verifyMultipleSignatures - same message - 3 - blst 3.4407 ms/op 1.1093 ms/op 3.10
BLS verifyMultipleSignatures - same message - 8 - blst 3.3593 ms/op 1.2126 ms/op 2.77
BLS verifyMultipleSignatures - same message - 32 - blst 6.0416 ms/op 1.8242 ms/op 3.31
BLS verifyMultipleSignatures - same message - 64 - blst 10.390 ms/op 2.6034 ms/op 3.99
BLS verifyMultipleSignatures - same message - 128 - blst 15.403 ms/op 4.3304 ms/op 3.56
BLS aggregatePubkeys 32 - blst 90.141 us/op 20.002 us/op 4.51
BLS aggregatePubkeys 128 - blst 270.70 us/op 70.383 us/op 3.85
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 124.47 ms/op 71.054 ms/op 1.75
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 170.72 ms/op 54.754 ms/op 3.12
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 96.809 ms/op 38.291 ms/op 2.53
getSlashingsAndExits - default max 252.18 us/op 92.023 us/op 2.74
getSlashingsAndExits - 2k 475.83 us/op 378.15 us/op 1.26
proposeBlockBody type=full, size=empty 14.902 ms/op 5.6779 ms/op 2.62
isKnown best case - 1 super set check 1.1150 us/op 304.00 ns/op 3.67
isKnown normal case - 2 super set checks 1.0330 us/op 284.00 ns/op 3.64
isKnown worse case - 16 super set checks 1.0610 us/op 283.00 ns/op 3.75
InMemoryCheckpointStateCache - add get delete 7.1060 us/op 4.0740 us/op 1.74
updateUnfinalizedPubkeys - updating 10 pubkeys 1.9958 ms/op 976.42 us/op 2.04
updateUnfinalizedPubkeys - updating 100 pubkeys 11.103 ms/op 3.6573 ms/op 3.04
updateUnfinalizedPubkeys - updating 1000 pubkeys 124.50 ms/op 51.971 ms/op 2.40
validate api signedAggregateAndProof - struct 3.6943 ms/op 1.7544 ms/op 2.11
validate gossip signedAggregateAndProof - struct 3.2083 ms/op 2.7557 ms/op 1.16
validate gossip attestation - vc 640000 1.8684 ms/op 1.2341 ms/op 1.51
batch validate gossip attestation - vc 640000 - chunk 32 305.70 us/op 134.52 us/op 2.27
batch validate gossip attestation - vc 640000 - chunk 64 283.73 us/op 118.48 us/op 2.39
batch validate gossip attestation - vc 640000 - chunk 128 277.69 us/op 101.25 us/op 2.74
batch validate gossip attestation - vc 640000 - chunk 256 225.92 us/op 102.62 us/op 2.20
pickEth1Vote - no votes 2.6460 ms/op 994.71 us/op 2.66
pickEth1Vote - max votes 12.424 ms/op 7.1445 ms/op 1.74
pickEth1Vote - Eth1Data hashTreeRoot value x2048 27.255 ms/op 15.263 ms/op 1.79
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 38.255 ms/op 23.228 ms/op 1.65
pickEth1Vote - Eth1Data fastSerialize value x2048 1.0652 ms/op 449.43 us/op 2.37
pickEth1Vote - Eth1Data fastSerialize tree x2048 6.1004 ms/op 4.3530 ms/op 1.40
bytes32 toHexString 1.1570 us/op 410.00 ns/op 2.82
bytes32 Buffer.toString(hex) 619.00 ns/op 242.00 ns/op 2.56
bytes32 Buffer.toString(hex) from Uint8Array 918.00 ns/op 369.00 ns/op 2.49
bytes32 Buffer.toString(hex) + 0x 571.00 ns/op 246.00 ns/op 2.32
Object access 1 prop 0.35300 ns/op 0.13100 ns/op 2.69
Map access 1 prop 0.32000 ns/op 0.13000 ns/op 2.46
Object get x1000 17.779 ns/op 5.8620 ns/op 3.03
Map get x1000 20.442 ns/op 6.2680 ns/op 3.26
Object set x1000 93.599 ns/op 31.795 ns/op 2.94
Map set x1000 60.696 ns/op 21.266 ns/op 2.85
Return object 10000 times 0.63430 ns/op 0.28070 ns/op 2.26
Throw Error 10000 times 8.1671 us/op 3.2278 us/op 2.53
toHex 386.16 ns/op 143.46 ns/op 2.69
Buffer.from 337.67 ns/op 129.66 ns/op 2.60
shared Buffer 224.86 ns/op 86.943 ns/op 2.59
fastMsgIdFn sha256 / 200 bytes 4.8410 us/op 2.1270 us/op 2.28
fastMsgIdFn h32 xxhash / 200 bytes 491.00 ns/op 218.00 ns/op 2.25
fastMsgIdFn h64 xxhash / 200 bytes 548.00 ns/op 263.00 ns/op 2.08
fastMsgIdFn sha256 / 1000 bytes 16.999 us/op 7.2320 us/op 2.35
fastMsgIdFn h32 xxhash / 1000 bytes 847.00 ns/op 344.00 ns/op 2.46
fastMsgIdFn h64 xxhash / 1000 bytes 822.00 ns/op 328.00 ns/op 2.51
fastMsgIdFn sha256 / 10000 bytes 171.89 us/op 62.920 us/op 2.73
fastMsgIdFn h32 xxhash / 10000 bytes 4.3550 us/op 1.7570 us/op 2.48
fastMsgIdFn h64 xxhash / 10000 bytes 2.6800 us/op 1.1600 us/op 2.31
send data - 1000 256B messages 24.282 ms/op 12.019 ms/op 2.02
send data - 1000 512B messages 34.865 ms/op 15.829 ms/op 2.20
send data - 1000 1024B messages 51.093 ms/op 25.775 ms/op 1.98
send data - 1000 1200B messages 46.894 ms/op 27.243 ms/op 1.72
send data - 1000 2048B messages 40.346 ms/op 32.071 ms/op 1.26
send data - 1000 4096B messages 60.136 ms/op 30.669 ms/op 1.96
send data - 1000 16384B messages 170.07 ms/op 72.210 ms/op 2.36
send data - 1000 65536B messages 1.1354 s/op 206.06 ms/op 5.51
enrSubnets - fastDeserialize 64 bits 2.5970 us/op 1.0050 us/op 2.58
enrSubnets - ssz BitVector 64 bits 883.00 ns/op 347.00 ns/op 2.54
enrSubnets - fastDeserialize 4 bits 383.00 ns/op 141.00 ns/op 2.72
enrSubnets - ssz BitVector 4 bits 964.00 ns/op 347.00 ns/op 2.78
prioritizePeers score -10:0 att 32-0.1 sync 2-0 370.01 us/op 141.54 us/op 2.61
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 412.69 us/op 192.72 us/op 2.14
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 560.77 us/op 262.04 us/op 2.14
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 911.92 us/op 647.08 us/op 1.41
prioritizePeers score 0:0 att 64-1 sync 4-1 1.2805 ms/op 780.63 us/op 1.64
array of 16000 items push then shift 3.3952 us/op 1.5846 us/op 2.14
LinkedList of 16000 items push then shift 16.667 ns/op 7.0490 ns/op 2.36
array of 16000 items push then pop 206.04 ns/op 100.31 ns/op 2.05
LinkedList of 16000 items push then pop 15.268 ns/op 6.7930 ns/op 2.25
array of 24000 items push then shift 4.0991 us/op 2.3549 us/op 1.74
LinkedList of 24000 items push then shift 14.376 ns/op 6.9750 ns/op 2.06
array of 24000 items push then pop 370.56 ns/op 125.31 ns/op 2.96
LinkedList of 24000 items push then pop 18.928 ns/op 6.6770 ns/op 2.83
intersect bitArray bitLen 8 21.200 ns/op 6.1870 ns/op 3.43
intersect array and set length 8 110.89 ns/op 45.187 ns/op 2.45
intersect bitArray bitLen 128 78.282 ns/op 28.857 ns/op 2.71
intersect array and set length 128 2.2886 us/op 656.34 ns/op 3.49
bitArray.getTrueBitIndexes() bitLen 128 5.0550 us/op 2.5300 us/op 2.00
bitArray.getTrueBitIndexes() bitLen 248 8.2770 us/op 3.8660 us/op 2.14
bitArray.getTrueBitIndexes() bitLen 512 21.514 us/op 7.8460 us/op 2.74
Buffer.concat 32 items 2.7940 us/op 892.00 ns/op 3.13
Uint8Array.set 32 items 4.2090 us/op 1.5500 us/op 2.72
Buffer.copy 4.9950 us/op 1.9820 us/op 2.52
Uint8Array.set - with subarray 7.9070 us/op 2.9310 us/op 2.70
Uint8Array.set - without subarray 3.2860 us/op 1.5860 us/op 2.07
getUint32 - dataview 651.00 ns/op 232.00 ns/op 2.81
getUint32 - manual 515.00 ns/op 149.00 ns/op 3.46
Set add up to 64 items then delete first 6.3741 us/op 2.1482 us/op 2.97
OrderedSet add up to 64 items then delete first 10.273 us/op 3.1889 us/op 3.22
Set add up to 64 items then delete last 7.4399 us/op 2.4576 us/op 3.03
OrderedSet add up to 64 items then delete last 8.6487 us/op 3.5638 us/op 2.43
Set add up to 64 items then delete middle 6.1435 us/op 2.4644 us/op 2.49
OrderedSet add up to 64 items then delete middle 11.537 us/op 5.0656 us/op 2.28
Set add up to 128 items then delete first 13.941 us/op 4.9191 us/op 2.83
OrderedSet add up to 128 items then delete first 24.782 us/op 7.6974 us/op 3.22
Set add up to 128 items then delete last 15.192 us/op 4.7761 us/op 3.18
OrderedSet add up to 128 items then delete last 21.894 us/op 7.1026 us/op 3.08
Set add up to 128 items then delete middle 13.781 us/op 4.7575 us/op 2.90
OrderedSet add up to 128 items then delete middle 37.267 us/op 13.320 us/op 2.80
Set add up to 256 items then delete first 30.880 us/op 10.034 us/op 3.08
OrderedSet add up to 256 items then delete first 43.956 us/op 15.717 us/op 2.80
Set add up to 256 items then delete last 25.945 us/op 9.7166 us/op 2.67
OrderedSet add up to 256 items then delete last 29.882 us/op 14.084 us/op 2.12
Set add up to 256 items then delete middle 19.261 us/op 9.4631 us/op 2.04
OrderedSet add up to 256 items then delete middle 76.914 us/op 40.283 us/op 1.91
transfer serialized Status (84 B) 2.2100 us/op 1.3320 us/op 1.66
copy serialized Status (84 B) 1.9550 us/op 1.1200 us/op 1.75
transfer serialized SignedVoluntaryExit (112 B) 2.3760 us/op 1.4930 us/op 1.59
copy serialized SignedVoluntaryExit (112 B) 2.2190 us/op 1.1750 us/op 1.89
transfer serialized ProposerSlashing (416 B) 4.0410 us/op 2.0170 us/op 2.00
copy serialized ProposerSlashing (416 B) 4.2540 us/op 1.9040 us/op 2.23
transfer serialized Attestation (485 B) 4.7790 us/op 2.6860 us/op 1.78
copy serialized Attestation (485 B) 4.3660 us/op 2.0730 us/op 2.11
transfer serialized AttesterSlashing (33232 B) 5.2030 us/op 2.9020 us/op 1.79
copy serialized AttesterSlashing (33232 B) 23.559 us/op 5.7490 us/op 4.10
transfer serialized Small SignedBeaconBlock (128000 B) 5.3950 us/op 3.8680 us/op 1.39
copy serialized Small SignedBeaconBlock (128000 B) 36.692 us/op 15.328 us/op 2.39
transfer serialized Avg SignedBeaconBlock (200000 B) 5.4930 us/op 4.1450 us/op 1.33
copy serialized Avg SignedBeaconBlock (200000 B) 133.25 us/op 21.747 us/op 6.13
transfer serialized BlobsSidecar (524380 B) 6.2350 us/op 3.0960 us/op 2.01
copy serialized BlobsSidecar (524380 B) 142.07 us/op 81.154 us/op 1.75
transfer serialized Big SignedBeaconBlock (1000000 B) 5.4780 us/op 2.7080 us/op 2.02
copy serialized Big SignedBeaconBlock (1000000 B) 246.93 us/op 388.63 us/op 0.64
pass gossip attestations to forkchoice per slot 8.5510 ms/op 2.7686 ms/op 3.09
forkChoice updateHead vc 100000 bc 64 eq 0 1.4313 ms/op 600.64 us/op 2.38
forkChoice updateHead vc 600000 bc 64 eq 0 11.614 ms/op 2.9482 ms/op 3.94
forkChoice updateHead vc 1000000 bc 64 eq 0 13.358 ms/op 5.2543 ms/op 2.54
forkChoice updateHead vc 600000 bc 320 eq 0 8.8071 ms/op 2.9541 ms/op 2.98
forkChoice updateHead vc 600000 bc 1200 eq 0 7.8778 ms/op 3.0720 ms/op 2.56
forkChoice updateHead vc 600000 bc 7200 eq 0 7.3968 ms/op 4.3606 ms/op 1.70
forkChoice updateHead vc 600000 bc 64 eq 1000 25.218 ms/op 10.642 ms/op 2.37
forkChoice updateHead vc 600000 bc 64 eq 10000 23.441 ms/op 10.526 ms/op 2.23
forkChoice updateHead vc 600000 bc 64 eq 300000 51.115 ms/op 14.493 ms/op 3.53
computeDeltas 500000 validators 300 proto nodes 6.8431 ms/op 3.4054 ms/op 2.01
computeDeltas 500000 validators 1200 proto nodes 7.6924 ms/op 3.5416 ms/op 2.17
computeDeltas 500000 validators 7200 proto nodes 8.1579 ms/op 3.4954 ms/op 2.33
computeDeltas 750000 validators 300 proto nodes 11.312 ms/op 5.1813 ms/op 2.18
computeDeltas 750000 validators 1200 proto nodes 13.694 ms/op 5.2059 ms/op 2.63
computeDeltas 750000 validators 7200 proto nodes 13.090 ms/op 5.2249 ms/op 2.51
computeDeltas 1400000 validators 300 proto nodes 21.890 ms/op 9.6137 ms/op 2.28
computeDeltas 1400000 validators 1200 proto nodes 18.953 ms/op 9.6158 ms/op 1.97
computeDeltas 1400000 validators 7200 proto nodes 17.632 ms/op 9.7295 ms/op 1.81
computeDeltas 2100000 validators 300 proto nodes 38.997 ms/op 14.773 ms/op 2.64
computeDeltas 2100000 validators 1200 proto nodes 42.353 ms/op 14.951 ms/op 2.83
computeDeltas 2100000 validators 7200 proto nodes 41.342 ms/op 15.130 ms/op 2.73
altair processAttestation - 250000 vs - 7PWei normalcase 4.3774 ms/op 1.6979 ms/op 2.58
altair processAttestation - 250000 vs - 7PWei worstcase 5.8156 ms/op 2.5600 ms/op 2.27
altair processAttestation - setStatus - 1/6 committees join 213.56 us/op 95.096 us/op 2.25
altair processAttestation - setStatus - 1/3 committees join 461.57 us/op 173.67 us/op 2.66
altair processAttestation - setStatus - 1/2 committees join 680.00 us/op 246.37 us/op 2.76
altair processAttestation - setStatus - 2/3 committees join 967.23 us/op 323.66 us/op 2.99
altair processAttestation - setStatus - 4/5 committees join 1.5583 ms/op 482.73 us/op 3.23
altair processAttestation - setStatus - 100% committees join 1.3392 ms/op 559.87 us/op 2.39
altair processBlock - 250000 vs - 7PWei normalcase 9.8911 ms/op 5.3082 ms/op 1.86
altair processBlock - 250000 vs - 7PWei normalcase hashState 52.769 ms/op 27.266 ms/op 1.94
altair processBlock - 250000 vs - 7PWei worstcase 73.997 ms/op 39.904 ms/op 1.85
altair processBlock - 250000 vs - 7PWei worstcase hashState 131.03 ms/op 81.948 ms/op 1.60
phase0 processBlock - 250000 vs - 7PWei normalcase 3.8590 ms/op 2.3810 ms/op 1.62
phase0 processBlock - 250000 vs - 7PWei worstcase 38.886 ms/op 25.867 ms/op 1.50
altair processEth1Data - 250000 vs - 7PWei normalcase 677.22 us/op 278.75 us/op 2.43
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 8.1650 us/op 7.4700 us/op 1.09
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 53.469 us/op 45.314 us/op 1.18
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 14.651 us/op 11.838 us/op 1.24
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 11.870 us/op 7.8130 us/op 1.52
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 211.22 us/op 116.40 us/op 1.81
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 2.0662 ms/op 1.5442 ms/op 1.34
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.8623 ms/op 1.8954 ms/op 1.51
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 3.0193 ms/op 2.3274 ms/op 1.30
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 7.1082 ms/op 3.6064 ms/op 1.97
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 3.1089 ms/op 2.2056 ms/op 1.41
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 7.3160 ms/op 3.7553 ms/op 1.95
Tree 40 250000 create 395.03 ms/op 209.43 ms/op 1.89
Tree 40 250000 get(125000) 275.09 ns/op 148.64 ns/op 1.85
Tree 40 250000 set(125000) 1.0792 us/op 639.68 ns/op 1.69
Tree 40 250000 toArray() 22.791 ms/op 16.438 ms/op 1.39
Tree 40 250000 iterate all - toArray() + loop 23.471 ms/op 17.367 ms/op 1.35
Tree 40 250000 iterate all - get(i) 88.460 ms/op 51.294 ms/op 1.72
Array 250000 create 5.2210 ms/op 3.0865 ms/op 1.69
Array 250000 clone - spread 2.4276 ms/op 1.4048 ms/op 1.73
Array 250000 get(125000) 0.74200 ns/op 0.42800 ns/op 1.73
Array 250000 set(125000) 0.83700 ns/op 0.43400 ns/op 1.93
Array 250000 iterate all - loop 141.19 us/op 105.80 us/op 1.33
phase0 afterProcessEpoch - 250000 vs - 7PWei 184.92 ms/op 88.201 ms/op 2.10
Array.fill - length 1000000 8.9082 ms/op 3.5293 ms/op 2.52
Array push - length 1000000 43.679 ms/op 28.090 ms/op 1.55
Array.get 0.44581 ns/op 0.30038 ns/op 1.48
Uint8Array.get 0.70910 ns/op 0.44248 ns/op 1.60
phase0 beforeProcessEpoch - 250000 vs - 7PWei 31.815 ms/op 18.838 ms/op 1.69
altair processEpoch - mainnet_e81889 473.43 ms/op 331.22 ms/op 1.43
mainnet_e81889 - altair beforeProcessEpoch 30.342 ms/op 18.804 ms/op 1.61
mainnet_e81889 - altair processJustificationAndFinalization 23.129 us/op 20.149 us/op 1.15
mainnet_e81889 - altair processInactivityUpdates 7.0594 ms/op 4.8945 ms/op 1.44
mainnet_e81889 - altair processRewardsAndPenalties 68.917 ms/op 60.560 ms/op 1.14
mainnet_e81889 - altair processRegistryUpdates 2.8930 us/op 2.8450 us/op 1.02
mainnet_e81889 - altair processSlashings 743.00 ns/op 708.00 ns/op 1.05
mainnet_e81889 - altair processEth1DataReset 516.00 ns/op 533.00 ns/op 0.97
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.0618 ms/op 3.5557 ms/op 0.58
mainnet_e81889 - altair processSlashingsReset 4.7750 us/op 4.2950 us/op 1.11
mainnet_e81889 - altair processRandaoMixesReset 6.5870 us/op 5.2420 us/op 1.26
mainnet_e81889 - altair processHistoricalRootsUpdate 839.00 ns/op 787.00 ns/op 1.07
mainnet_e81889 - altair processParticipationFlagUpdates 2.4300 us/op 2.9930 us/op 0.81
mainnet_e81889 - altair processSyncCommitteeUpdates 577.00 ns/op 574.00 ns/op 1.01
mainnet_e81889 - altair afterProcessEpoch 139.25 ms/op 93.290 ms/op 1.49
capella processEpoch - mainnet_e217614 1.5813 s/op 1.1483 s/op 1.38
mainnet_e217614 - capella beforeProcessEpoch 85.124 ms/op 70.267 ms/op 1.21
mainnet_e217614 - capella processJustificationAndFinalization 20.023 us/op 22.510 us/op 0.89
mainnet_e217614 - capella processInactivityUpdates 20.933 ms/op 18.146 ms/op 1.15
mainnet_e217614 - capella processRewardsAndPenalties 295.58 ms/op 286.58 ms/op 1.03
mainnet_e217614 - capella processRegistryUpdates 17.168 us/op 20.750 us/op 0.83
mainnet_e217614 - capella processSlashings 559.00 ns/op 716.00 ns/op 0.78
mainnet_e217614 - capella processEth1DataReset 508.00 ns/op 504.00 ns/op 1.01
mainnet_e217614 - capella processEffectiveBalanceUpdates 16.758 ms/op 11.233 ms/op 1.49
mainnet_e217614 - capella processSlashingsReset 11.492 us/op 3.6210 us/op 3.17
mainnet_e217614 - capella processRandaoMixesReset 5.5460 us/op 8.6890 us/op 0.64
mainnet_e217614 - capella processHistoricalRootsUpdate 760.00 ns/op 816.00 ns/op 0.93
mainnet_e217614 - capella processParticipationFlagUpdates 2.3280 us/op 3.0800 us/op 0.76
mainnet_e217614 - capella afterProcessEpoch 327.00 ms/op 230.73 ms/op 1.42
phase0 processEpoch - mainnet_e58758 421.81 ms/op 436.68 ms/op 0.97
mainnet_e58758 - phase0 beforeProcessEpoch 85.921 ms/op 95.230 ms/op 0.90
mainnet_e58758 - phase0 processJustificationAndFinalization 16.611 us/op 19.377 us/op 0.86
mainnet_e58758 - phase0 processRewardsAndPenalties 38.127 ms/op 38.853 ms/op 0.98
mainnet_e58758 - phase0 processRegistryUpdates 10.598 us/op 8.9140 us/op 1.19
mainnet_e58758 - phase0 processSlashings 521.00 ns/op 461.00 ns/op 1.13
mainnet_e58758 - phase0 processEth1DataReset 543.00 ns/op 414.00 ns/op 1.31
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.9828 ms/op 1.8220 ms/op 1.09
mainnet_e58758 - phase0 processSlashingsReset 3.8650 us/op 3.8890 us/op 0.99
mainnet_e58758 - phase0 processRandaoMixesReset 4.7540 us/op 6.7620 us/op 0.70
mainnet_e58758 - phase0 processHistoricalRootsUpdate 631.00 ns/op 415.00 ns/op 1.52
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.1730 us/op 5.3770 us/op 0.78
mainnet_e58758 - phase0 afterProcessEpoch 119.12 ms/op 82.016 ms/op 1.45
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.1000 ms/op 1.6751 ms/op 1.25
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 3.6733 ms/op 2.4532 ms/op 1.50
altair processInactivityUpdates - 250000 normalcase 22.773 ms/op 18.596 ms/op 1.22
altair processInactivityUpdates - 250000 worstcase 31.045 ms/op 17.990 ms/op 1.73
phase0 processRegistryUpdates - 250000 normalcase 13.907 us/op 8.5980 us/op 1.62
phase0 processRegistryUpdates - 250000 badcase_full_deposits 520.16 us/op 358.86 us/op 1.45
phase0 processRegistryUpdates - 250000 worstcase 0.5 201.15 ms/op 139.25 ms/op 1.44
altair processRewardsAndPenalties - 250000 normalcase 55.927 ms/op 43.286 ms/op 1.29
altair processRewardsAndPenalties - 250000 worstcase 66.958 ms/op 43.828 ms/op 1.53
phase0 getAttestationDeltas - 250000 normalcase 11.125 ms/op 7.7279 ms/op 1.44
phase0 getAttestationDeltas - 250000 worstcase 12.691 ms/op 7.7909 ms/op 1.63
phase0 processSlashings - 250000 worstcase 114.68 us/op 102.47 us/op 1.12
altair processSyncCommitteeUpdates - 250000 205.88 ms/op 126.71 ms/op 1.62
BeaconState.hashTreeRoot - No change 334.00 ns/op 316.00 ns/op 1.06
BeaconState.hashTreeRoot - 1 full validator 149.22 us/op 100.56 us/op 1.48
BeaconState.hashTreeRoot - 32 full validator 1.4662 ms/op 1.0915 ms/op 1.34
BeaconState.hashTreeRoot - 512 full validator 16.344 ms/op 15.386 ms/op 1.06
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 190.19 us/op 175.25 us/op 1.09
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.8136 ms/op 2.1639 ms/op 1.30
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 34.316 ms/op 28.914 ms/op 1.19
BeaconState.hashTreeRoot - 1 balances 142.21 us/op 123.18 us/op 1.15
BeaconState.hashTreeRoot - 32 balances 1.3937 ms/op 1.0956 ms/op 1.27
BeaconState.hashTreeRoot - 512 balances 15.254 ms/op 6.8260 ms/op 2.23
BeaconState.hashTreeRoot - 250000 balances 239.76 ms/op 153.18 ms/op 1.57
aggregationBits - 2048 els - zipIndexesInBitList 39.369 us/op 22.673 us/op 1.74
byteArrayEquals 32 87.034 ns/op 52.202 ns/op 1.67
Buffer.compare 32 30.328 ns/op 16.790 ns/op 1.81
byteArrayEquals 1024 2.3244 us/op 1.5362 us/op 1.51
Buffer.compare 1024 41.134 ns/op 24.202 ns/op 1.70
byteArrayEquals 16384 38.448 us/op 24.701 us/op 1.56
Buffer.compare 16384 330.04 ns/op 198.97 ns/op 1.66
byteArrayEquals 123687377 325.11 ms/op 187.05 ms/op 1.74
Buffer.compare 123687377 9.5798 ms/op 6.0452 ms/op 1.58
byteArrayEquals 32 - diff last byte 127.55 ns/op 51.275 ns/op 2.49
Buffer.compare 32 - diff last byte 43.380 ns/op 16.716 ns/op 2.60
byteArrayEquals 1024 - diff last byte 3.5043 us/op 1.5443 us/op 2.27
Buffer.compare 1024 - diff last byte 54.528 ns/op 24.592 ns/op 2.22
byteArrayEquals 16384 - diff last byte 55.163 us/op 24.593 us/op 2.24
Buffer.compare 16384 - diff last byte 390.36 ns/op 192.92 ns/op 2.02
byteArrayEquals 123687377 - diff last byte 382.41 ms/op 186.69 ms/op 2.05
Buffer.compare 123687377 - diff last byte 8.9067 ms/op 6.4032 ms/op 1.39
byteArrayEquals 32 - random bytes 9.7980 ns/op 5.1010 ns/op 1.92
Buffer.compare 32 - random bytes 33.231 ns/op 17.043 ns/op 1.95
byteArrayEquals 1024 - random bytes 10.096 ns/op 5.1560 ns/op 1.96
Buffer.compare 1024 - random bytes 37.940 ns/op 16.926 ns/op 2.24
byteArrayEquals 16384 - random bytes 10.579 ns/op 5.0940 ns/op 2.08
Buffer.compare 16384 - random bytes 36.006 ns/op 17.098 ns/op 2.11
byteArrayEquals 123687377 - random bytes 13.810 ns/op 6.3800 ns/op 2.16
Buffer.compare 123687377 - random bytes 46.570 ns/op 18.170 ns/op 2.56
regular array get 100000 times 80.143 us/op 34.995 us/op 2.29
wrappedArray get 100000 times 59.339 us/op 34.134 us/op 1.74
arrayWithProxy get 100000 times 35.531 ms/op 14.137 ms/op 2.51
ssz.Root.equals 85.888 ns/op 45.831 ns/op 1.87
byteArrayEquals 81.313 ns/op 45.096 ns/op 1.80
Buffer.compare 23.257 ns/op 10.354 ns/op 2.25
shuffle list - 16384 els 11.350 ms/op 6.2072 ms/op 1.83
shuffle list - 250000 els 169.03 ms/op 91.830 ms/op 1.84
processSlot - 1 slots 27.146 us/op 10.421 us/op 2.60
processSlot - 32 slots 4.7410 ms/op 3.1249 ms/op 1.52
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 69.701 ms/op 37.285 ms/op 1.87
getCommitteeAssignments - req 1 vs - 250000 vc 4.2035 ms/op 2.1093 ms/op 1.99
getCommitteeAssignments - req 100 vs - 250000 vc 7.3561 ms/op 4.1299 ms/op 1.78
getCommitteeAssignments - req 1000 vs - 250000 vc 8.4647 ms/op 4.4687 ms/op 1.89
findModifiedValidators - 10000 modified validators 584.15 ms/op 245.96 ms/op 2.38
findModifiedValidators - 1000 modified validators 455.67 ms/op 177.28 ms/op 2.57
findModifiedValidators - 100 modified validators 402.69 ms/op 164.78 ms/op 2.44
findModifiedValidators - 10 modified validators 421.23 ms/op 177.75 ms/op 2.37
findModifiedValidators - 1 modified validators 393.25 ms/op 156.92 ms/op 2.51
findModifiedValidators - no difference 384.05 ms/op 157.40 ms/op 2.44
compare ViewDUs 5.4231 s/op 3.1822 s/op 1.70
compare each validator Uint8Array 2.5755 s/op 979.75 ms/op 2.63
compare ViewDU to Uint8Array 2.0990 s/op 1.0996 s/op 1.91
migrate state 1000000 validators, 24 modified, 0 new 1.2529 s/op 887.99 ms/op 1.41
migrate state 1000000 validators, 1700 modified, 1000 new 1.3325 s/op 1.1101 s/op 1.20
migrate state 1000000 validators, 3400 modified, 2000 new 1.5773 s/op 1.3848 s/op 1.14
migrate state 1500000 validators, 24 modified, 0 new 1.0498 s/op 928.72 ms/op 1.13
migrate state 1500000 validators, 1700 modified, 1000 new 1.2457 s/op 1.1626 s/op 1.07
migrate state 1500000 validators, 3400 modified, 2000 new 1.4443 s/op 1.3758 s/op 1.05
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.5100 ns/op 4.3500 ns/op 1.04
state getBlockRootAtSlot - 250000 vs - 7PWei 726.73 ns/op 739.99 ns/op 0.98
computeProposers - vc 250000 7.0528 ms/op 6.6813 ms/op 1.06
computeEpochShuffling - vc 250000 97.492 ms/op 90.122 ms/op 1.08
getNextSyncCommittee - vc 250000 127.24 ms/op 118.79 ms/op 1.07
computeSigningRoot for AttestationData 25.947 us/op 26.853 us/op 0.97
hash AttestationData serialized data then Buffer.toString(base64) 1.6844 us/op 1.5324 us/op 1.10
toHexString serialized data 983.71 ns/op 853.43 ns/op 1.15
Buffer.toString(base64) 194.73 ns/op 184.22 ns/op 1.06
nodejs block root to RootHex using toHex 161.78 ns/op 147.14 ns/op 1.10
nodejs block root to RootHex using toRootHex 99.962 ns/op 93.084 ns/op 1.07
browser block root to RootHex using the deprecated toHexString 246.85 ns/op 220.23 ns/op 1.12
browser block root to RootHex using toHex 190.53 ns/op 176.69 ns/op 1.08
browser block root to RootHex using toRootHex 172.49 ns/op 157.14 ns/op 1.10

Please sign in to comment.