Skip to content

Commit

Permalink
feat: n-historical states feature flags (#6538)
Browse files Browse the repository at this point in the history
* feat: n-historical states feature flags

* fix: change vitest config for the using keyword

* chore: address PR comments
  • Loading branch information
twoeths committed Mar 20, 2024
1 parent b68e78e commit 31e04d6
Show file tree
Hide file tree
Showing 13 changed files with 661 additions and 19 deletions.
33 changes: 29 additions & 4 deletions packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {IExecutionEngine, IExecutionBuilder} from "../execution/index.js";
import {Clock, ClockEvent, IClock} from "../util/clock.js";
import {ensureDir, writeIfNotExist} from "../util/file.js";
import {isOptimisticBlock} from "../util/forkChoice.js";
import {BufferPool} from "../util/bufferPool.js";
import {BlockProcessor, ImportBlockOpts} from "./blocks/index.js";
import {ChainEventEmitter, ChainEvent} from "./emitter.js";
import {IBeaconChain, ProposerPreparationData, BlockHash, StateGetOpts, CommonBlockBody} from "./interface.js";
Expand Down Expand Up @@ -81,7 +82,11 @@ import {BlockRewards, computeBlockRewards} from "./rewards/blockRewards.js";
import {ShufflingCache} from "./shufflingCache.js";
import {StateContextCache} from "./stateCache/stateContextCache.js";
import {SeenGossipBlockInput} from "./seenCache/index.js";
import {CheckpointStateCache} from "./stateCache/stateContextCheckpointsCache.js";
import {InMemoryCheckpointStateCache} from "./stateCache/stateContextCheckpointsCache.js";
import {FIFOBlockStateCache} from "./stateCache/fifoBlockStateCache.js";
import {PersistentCheckpointStateCache} from "./stateCache/persistentCheckpointsCache.js";
import {DbCPStateDatastore} from "./stateCache/datastore/db.js";
import {FileCPStateDatastore} from "./stateCache/datastore/file.js";
import {SyncCommitteeRewards, computeSyncCommitteeRewards} from "./rewards/syncCommitteeRewards.js";
import {AttestationsRewards, computeAttestationsRewards} from "./rewards/attestationsRewards.js";

Expand Down Expand Up @@ -241,9 +246,28 @@ export class BeaconChain implements IBeaconChain {
this.pubkey2index = cachedState.epochCtx.pubkey2index;
this.index2pubkey = cachedState.epochCtx.index2pubkey;

const stateCache = new StateContextCache({metrics});
const checkpointStateCache = new CheckpointStateCache({metrics});

const fileDataStore = opts.nHistoricalStatesFileDataStore ?? false;
const stateCache = this.opts.nHistoricalStates
? new FIFOBlockStateCache(this.opts, {metrics})
: new StateContextCache({metrics});
const checkpointStateCache = this.opts.nHistoricalStates
? new PersistentCheckpointStateCache(
{
metrics,
logger,
clock,
shufflingCache: this.shufflingCache,
getHeadState: this.getHeadState.bind(this),
bufferPool: new BufferPool(anchorState.type.tree_serializedSize(anchorState.node), metrics),
datastore: fileDataStore
? // debug option if we want to investigate any issues with the DB
new FileCPStateDatastore()
: // production option
new DbCPStateDatastore(this.db),
},
this.opts
)
: new InMemoryCheckpointStateCache({metrics});
const {checkpoint} = computeAnchorCheckpoint(config, anchorState);
stateCache.add(cachedState);
stateCache.setHeadState(cachedState);
Expand Down Expand Up @@ -337,6 +361,7 @@ export class BeaconChain implements IBeaconChain {

/** Populate in-memory caches with persisted data. Call at least once on startup */
async loadFromDisk(): Promise<void> {
await this.regen.init();
await this.opPool.fromPersisted(this.db);
}

Expand Down
13 changes: 10 additions & 3 deletions packages/beacon-node/src/chain/forkChoice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ForkChoiceStore,
ExecutionStatus,
JustifiedBalancesGetter,
ForkChoiceOpts,
ForkChoiceOpts as RawForkChoiceOpts,
} from "@lodestar/fork-choice";
import {
CachedBeaconStateAllForks,
Expand All @@ -21,7 +21,10 @@ import {ChainEventEmitter} from "../emitter.js";
import {ChainEvent} from "../emitter.js";
import {GENESIS_SLOT} from "../../constants/index.js";

export type {ForkChoiceOpts};
export type ForkChoiceOpts = RawForkChoiceOpts & {
// for testing only
forkchoiceConstructor?: typeof ForkChoice;
};

/**
* Fork Choice extended with a ChainEventEmitter
Expand All @@ -47,7 +50,11 @@ export function initializeForkChoice(

const justifiedBalances = getEffectiveBalanceIncrementsZeroInactive(state);

return new ForkChoice(
// forkchoiceConstructor is only used for some test cases
// production code use ForkChoice constructor directly
const forkchoiceConstructor = opts.forkchoiceConstructor ?? ForkChoice;

return new forkchoiceConstructor(
config,

new ForkChoiceStore(
Expand Down
11 changes: 11 additions & 0 deletions packages/beacon-node/src/chain/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import {ArchiverOpts} from "./archiver/index.js";
import {ForkChoiceOpts} from "./forkChoice/index.js";
import {LightClientServerOpts} from "./lightClient/index.js";
import {ShufflingCacheOpts} from "./shufflingCache.js";
import {DEFAULT_MAX_BLOCK_STATES, FIFOBlockStateCacheOpts} from "./stateCache/fifoBlockStateCache.js";
import {PersistentCheckpointStateCacheOpts} from "./stateCache/persistentCheckpointsCache.js";
import {DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY} from "./stateCache/persistentCheckpointsCache.js";

export type IChainOptions = BlockProcessOpts &
PoolOpts &
SeenCacheOpts &
ForkChoiceOpts &
ArchiverOpts &
FIFOBlockStateCacheOpts &
PersistentCheckpointStateCacheOpts &
ShufflingCacheOpts &
LightClientServerOpts & {
blsVerifyAllMainThread?: boolean;
Expand All @@ -31,6 +36,8 @@ export type IChainOptions = BlockProcessOpts &
broadcastValidationStrictness?: string;
minSameMessageSignatureSetsToBatch: number;
archiveBlobEpochs?: number;
nHistoricalStates?: boolean;
nHistoricalStatesFileDataStore?: boolean;
};

export type BlockProcessOpts = {
Expand Down Expand Up @@ -103,4 +110,8 @@ export const defaultChainOptions: IChainOptions = {
// batching too much may block the I/O thread so if useWorker=false, suggest this value to be 32
// since this batch attestation work is designed to work with useWorker=true, make this the lowest value
minSameMessageSignatureSetsToBatch: 2,
nHistoricalStates: false,
nHistoricalStatesFileDataStore: false,
maxBlockStates: DEFAULT_MAX_BLOCK_STATES,
maxCPStateEpochsInMemory: DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY,
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {routes} from "@lodestar/api";
import {Metrics} from "../../metrics/index.js";
import {StateCloneOpts} from "../regen/interface.js";
import {MapTracker} from "./mapMetrics.js";
import {CheckpointStateCache as CheckpointStateCacheInterface, CacheItemType} from "./types.js";
import {CheckpointStateCache, CacheItemType} from "./types.js";

export type CheckpointHex = {epoch: Epoch; rootHex: RootHex};
const MAX_EPOCHS = 10;
Expand All @@ -16,9 +16,8 @@ const MAX_EPOCHS = 10;
* belonging to checkpoint
*
* Similar API to Repository
* TODO: rename to MemoryCheckpointStateCache in the next PR of n-historical states
*/
export class CheckpointStateCache implements CheckpointStateCacheInterface {
export class InMemoryCheckpointStateCache implements CheckpointStateCache {
private readonly cache: MapTracker<string, CachedBeaconStateAllForks>;
/** Epoch -> Set<blockRoot> */
private readonly epochIndex = new MapDef<Epoch, Set<string>>(() => new Set<string>());
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/chain/validation/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ export async function validateGossipBlock(
});
}

// getBlockSlotState also checks for whether the current finalized checkpoint is an ancestor of the block.
// use getPreState to reload state if needed. It also checks for whether the current finalized checkpoint is an ancestor of the block.
// As a result, we throw an IGNORE (whereas the spec says we should REJECT for this scenario).
// this is something we should change this in the future to make the code airtight to the spec.
// [IGNORE] The block's parent (defined by block.parent_root) has been seen (via both gossip and non-gossip sources) (a client MAY queue blocks for processing once the parent block is retrieved).
// [REJECT] The block's parent (defined by block.parent_root) passes validation.
const blockState = await chain.regen
.getBlockSlotState(parentRoot, blockSlot, {dontTransferCache: true}, RegenCaller.validateGossipBlock)
.getPreState(block, {dontTransferCache: true}, RegenCaller.validateGossipBlock)
.catch(() => {
throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.PARENT_UNKNOWN, parentRoot});
});
Expand Down

1 comment on commit 31e04d6

@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: 31e04d6 Previous: 7c92d20 Ratio
forkChoice updateHead vc 600000 bc 64 eq 300000 59.214 ms/op 11.978 ms/op 4.94

🚀🚀 Significant benchmark improvement detected

Benchmark suite Current: 31e04d6 Previous: 7c92d20 Ratio
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 18.678 us/op 57.399 us/op 0.33
Full benchmark results
Benchmark suite Current: 31e04d6 Previous: 7c92d20 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 655.04 us/op 812.64 us/op 0.81
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 102.82 us/op 119.36 us/op 0.86
BLS verify - blst-native 1.1545 ms/op 1.1432 ms/op 1.01
BLS verifyMultipleSignatures 3 - blst-native 2.4589 ms/op 2.4608 ms/op 1.00
BLS verifyMultipleSignatures 8 - blst-native 5.6791 ms/op 5.6946 ms/op 1.00
BLS verifyMultipleSignatures 32 - blst-native 20.347 ms/op 20.903 ms/op 0.97
BLS verifyMultipleSignatures 64 - blst-native 39.865 ms/op 38.284 ms/op 1.04
BLS verifyMultipleSignatures 128 - blst-native 81.306 ms/op 81.514 ms/op 1.00
BLS deserializing 10000 signatures 864.08 ms/op 823.80 ms/op 1.05
BLS deserializing 100000 signatures 8.3925 s/op 8.4124 s/op 1.00
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.1456 ms/op 1.1334 ms/op 1.01
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.2907 ms/op 1.2733 ms/op 1.01
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.0928 ms/op 2.4341 ms/op 0.86
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.9769 ms/op 2.9821 ms/op 1.33
BLS verifyMultipleSignatures - same message - 128 - blst-native 5.1605 ms/op 4.9588 ms/op 1.04
BLS aggregatePubkeys 32 - blst-native 25.121 us/op 22.504 us/op 1.12
BLS aggregatePubkeys 128 - blst-native 90.089 us/op 88.316 us/op 1.02
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 60.698 ms/op 64.729 ms/op 0.94
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 54.568 ms/op 53.923 ms/op 1.01
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 27.661 ms/op 26.313 ms/op 1.05
getSlashingsAndExits - default max 149.28 us/op 130.16 us/op 1.15
getSlashingsAndExits - 2k 584.47 us/op 547.33 us/op 1.07
proposeBlockBody type=full, size=empty 4.6913 ms/op 4.8474 ms/op 0.97
isKnown best case - 1 super set check 511.00 ns/op 576.00 ns/op 0.89
isKnown normal case - 2 super set checks 409.00 ns/op 627.00 ns/op 0.65
isKnown worse case - 16 super set checks 441.00 ns/op 530.00 ns/op 0.83
CheckpointStateCache - add get delete 7.8840 us/op 6.2720 us/op 1.26
validate api signedAggregateAndProof - struct 2.4009 ms/op 2.5823 ms/op 0.93
validate gossip signedAggregateAndProof - struct 2.4144 ms/op 2.5785 ms/op 0.94
validate gossip attestation - vc 640000 1.1691 ms/op 1.2847 ms/op 0.91
batch validate gossip attestation - vc 640000 - chunk 32 146.53 us/op 176.56 us/op 0.83
batch validate gossip attestation - vc 640000 - chunk 64 125.74 us/op 143.91 us/op 0.87
batch validate gossip attestation - vc 640000 - chunk 128 114.99 us/op 140.41 us/op 0.82
batch validate gossip attestation - vc 640000 - chunk 256 109.27 us/op 135.49 us/op 0.81
pickEth1Vote - no votes 878.65 us/op 931.53 us/op 0.94
pickEth1Vote - max votes 7.7163 ms/op 15.487 ms/op 0.50
pickEth1Vote - Eth1Data hashTreeRoot value x2048 14.278 ms/op 30.196 ms/op 0.47
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 16.881 ms/op 34.260 ms/op 0.49
pickEth1Vote - Eth1Data fastSerialize value x2048 464.21 us/op 515.66 us/op 0.90
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.7505 ms/op 4.3494 ms/op 0.86
bytes32 toHexString 489.00 ns/op 544.00 ns/op 0.90
bytes32 Buffer.toString(hex) 331.00 ns/op 339.00 ns/op 0.98
bytes32 Buffer.toString(hex) from Uint8Array 445.00 ns/op 456.00 ns/op 0.98
bytes32 Buffer.toString(hex) + 0x 321.00 ns/op 370.00 ns/op 0.87
Object access 1 prop 0.20200 ns/op 0.24800 ns/op 0.81
Map access 1 prop 0.19200 ns/op 0.20500 ns/op 0.94
Object get x1000 5.1410 ns/op 5.2860 ns/op 0.97
Map get x1000 0.76400 ns/op 0.88700 ns/op 0.86
Object set x1000 26.503 ns/op 46.077 ns/op 0.58
Map set x1000 17.438 ns/op 28.988 ns/op 0.60
Return object 10000 times 0.21560 ns/op 0.23750 ns/op 0.91
Throw Error 10000 times 2.5992 us/op 2.7465 us/op 0.95
fastMsgIdFn sha256 / 200 bytes 1.9850 us/op 2.0950 us/op 0.95
fastMsgIdFn h32 xxhash / 200 bytes 305.00 ns/op 371.00 ns/op 0.82
fastMsgIdFn h64 xxhash / 200 bytes 345.00 ns/op 410.00 ns/op 0.84
fastMsgIdFn sha256 / 1000 bytes 6.0890 us/op 6.6580 us/op 0.91
fastMsgIdFn h32 xxhash / 1000 bytes 412.00 ns/op 537.00 ns/op 0.77
fastMsgIdFn h64 xxhash / 1000 bytes 411.00 ns/op 520.00 ns/op 0.79
fastMsgIdFn sha256 / 10000 bytes 50.849 us/op 53.842 us/op 0.94
fastMsgIdFn h32 xxhash / 10000 bytes 1.7650 us/op 1.9700 us/op 0.90
fastMsgIdFn h64 xxhash / 10000 bytes 1.2020 us/op 1.3450 us/op 0.89
send data - 1000 256B messages 13.018 ms/op 16.521 ms/op 0.79
send data - 1000 512B messages 15.660 ms/op 21.029 ms/op 0.74
send data - 1000 1024B messages 30.675 ms/op 30.155 ms/op 1.02
send data - 1000 1200B messages 30.418 ms/op 32.701 ms/op 0.93
send data - 1000 2048B messages 36.566 ms/op 44.714 ms/op 0.82
send data - 1000 4096B messages 32.311 ms/op 36.985 ms/op 0.87
send data - 1000 16384B messages 92.805 ms/op 94.300 ms/op 0.98
send data - 1000 65536B messages 411.90 ms/op 417.57 ms/op 0.99
enrSubnets - fastDeserialize 64 bits 1.0060 us/op 990.00 ns/op 1.02
enrSubnets - ssz BitVector 64 bits 422.00 ns/op 461.00 ns/op 0.92
enrSubnets - fastDeserialize 4 bits 206.00 ns/op 208.00 ns/op 0.99
enrSubnets - ssz BitVector 4 bits 425.00 ns/op 442.00 ns/op 0.96
prioritizePeers score -10:0 att 32-0.1 sync 2-0 78.089 us/op 71.665 us/op 1.09
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 89.797 us/op 88.435 us/op 1.02
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 113.62 us/op 127.71 us/op 0.89
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 206.80 us/op 197.08 us/op 1.05
prioritizePeers score 0:0 att 64-1 sync 4-1 231.94 us/op 217.88 us/op 1.06
array of 16000 items push then shift 1.4422 us/op 1.3086 us/op 1.10
LinkedList of 16000 items push then shift 6.5220 ns/op 5.9490 ns/op 1.10
array of 16000 items push then pop 89.738 ns/op 49.785 ns/op 1.80
LinkedList of 16000 items push then pop 5.9260 ns/op 5.7400 ns/op 1.03
array of 24000 items push then shift 2.1031 us/op 1.9032 us/op 1.11
LinkedList of 24000 items push then shift 7.3230 ns/op 5.9620 ns/op 1.23
array of 24000 items push then pop 124.27 ns/op 114.91 ns/op 1.08
LinkedList of 24000 items push then pop 5.8430 ns/op 5.6840 ns/op 1.03
intersect bitArray bitLen 8 4.8580 ns/op 4.8350 ns/op 1.00
intersect array and set length 8 61.358 ns/op 49.373 ns/op 1.24
intersect bitArray bitLen 128 28.968 ns/op 29.608 ns/op 0.98
intersect array and set length 128 773.14 ns/op 687.21 ns/op 1.13
bitArray.getTrueBitIndexes() bitLen 128 1.4550 us/op 1.1750 us/op 1.24
bitArray.getTrueBitIndexes() bitLen 248 2.6550 us/op 1.8380 us/op 1.44
bitArray.getTrueBitIndexes() bitLen 512 4.9810 us/op 3.5020 us/op 1.42
Buffer.concat 32 items 1.0850 us/op 831.00 ns/op 1.31
Uint8Array.set 32 items 2.3040 us/op 1.5590 us/op 1.48
Set add up to 64 items then delete first 1.9567 us/op 1.7566 us/op 1.11
OrderedSet add up to 64 items then delete first 4.7050 us/op 2.6624 us/op 1.77
Set add up to 64 items then delete last 3.1813 us/op 1.9853 us/op 1.60
OrderedSet add up to 64 items then delete last 4.5609 us/op 2.9626 us/op 1.54
Set add up to 64 items then delete middle 2.4026 us/op 1.9959 us/op 1.20
OrderedSet add up to 64 items then delete middle 4.6042 us/op 4.2872 us/op 1.07
Set add up to 128 items then delete first 6.2744 us/op 4.0526 us/op 1.55
OrderedSet add up to 128 items then delete first 10.392 us/op 6.1633 us/op 1.69
Set add up to 128 items then delete last 4.8421 us/op 3.7738 us/op 1.28
OrderedSet add up to 128 items then delete last 6.1513 us/op 5.7188 us/op 1.08
Set add up to 128 items then delete middle 3.9473 us/op 3.7808 us/op 1.04
OrderedSet add up to 128 items then delete middle 11.254 us/op 10.730 us/op 1.05
Set add up to 256 items then delete first 9.7965 us/op 7.6953 us/op 1.27
OrderedSet add up to 256 items then delete first 14.483 us/op 12.258 us/op 1.18
Set add up to 256 items then delete last 8.4578 us/op 7.4316 us/op 1.14
OrderedSet add up to 256 items then delete last 16.892 us/op 11.359 us/op 1.49
Set add up to 256 items then delete middle 9.5291 us/op 7.3979 us/op 1.29
OrderedSet add up to 256 items then delete middle 32.803 us/op 31.120 us/op 1.05
transfer serialized Status (84 B) 1.3820 us/op 1.3020 us/op 1.06
copy serialized Status (84 B) 1.0720 us/op 1.1520 us/op 0.93
transfer serialized SignedVoluntaryExit (112 B) 1.4280 us/op 1.5540 us/op 0.92
copy serialized SignedVoluntaryExit (112 B) 1.1120 us/op 1.2250 us/op 0.91
transfer serialized ProposerSlashing (416 B) 1.5160 us/op 1.6100 us/op 0.94
copy serialized ProposerSlashing (416 B) 1.3330 us/op 2.1130 us/op 0.63
transfer serialized Attestation (485 B) 2.0140 us/op 1.7540 us/op 1.15
copy serialized Attestation (485 B) 2.6340 us/op 2.1320 us/op 1.24
transfer serialized AttesterSlashing (33232 B) 3.2670 us/op 1.7730 us/op 1.84
copy serialized AttesterSlashing (33232 B) 8.3160 us/op 4.6160 us/op 1.80
transfer serialized Small SignedBeaconBlock (128000 B) 2.3850 us/op 2.6760 us/op 0.89
copy serialized Small SignedBeaconBlock (128000 B) 24.005 us/op 9.4860 us/op 2.53
transfer serialized Avg SignedBeaconBlock (200000 B) 2.7140 us/op 2.2440 us/op 1.21
copy serialized Avg SignedBeaconBlock (200000 B) 60.715 us/op 12.974 us/op 4.68
transfer serialized BlobsSidecar (524380 B) 4.5200 us/op 2.8950 us/op 1.56
copy serialized BlobsSidecar (524380 B) 177.35 us/op 76.484 us/op 2.32
transfer serialized Big SignedBeaconBlock (1000000 B) 7.7410 us/op 3.3400 us/op 2.32
copy serialized Big SignedBeaconBlock (1000000 B) 347.14 us/op 143.47 us/op 2.42
pass gossip attestations to forkchoice per slot 4.0630 ms/op 2.7570 ms/op 1.47
forkChoice updateHead vc 100000 bc 64 eq 0 568.24 us/op 546.17 us/op 1.04
forkChoice updateHead vc 600000 bc 64 eq 0 4.8032 ms/op 2.8976 ms/op 1.66
forkChoice updateHead vc 1000000 bc 64 eq 0 9.5338 ms/op 4.6422 ms/op 2.05
forkChoice updateHead vc 600000 bc 320 eq 0 3.7481 ms/op 2.7680 ms/op 1.35
forkChoice updateHead vc 600000 bc 1200 eq 0 3.5696 ms/op 2.6726 ms/op 1.34
forkChoice updateHead vc 600000 bc 7200 eq 0 6.6443 ms/op 3.3488 ms/op 1.98
forkChoice updateHead vc 600000 bc 64 eq 1000 12.768 ms/op 10.164 ms/op 1.26
forkChoice updateHead vc 600000 bc 64 eq 10000 11.591 ms/op 9.9493 ms/op 1.16
forkChoice updateHead vc 600000 bc 64 eq 300000 59.214 ms/op 11.978 ms/op 4.94
computeDeltas 500000 validators 300 proto nodes 4.0055 ms/op 3.1819 ms/op 1.26
computeDeltas 500000 validators 1200 proto nodes 3.2809 ms/op 3.1515 ms/op 1.04
computeDeltas 500000 validators 7200 proto nodes 3.1498 ms/op 3.0809 ms/op 1.02
computeDeltas 750000 validators 300 proto nodes 4.7212 ms/op 4.7927 ms/op 0.99
computeDeltas 750000 validators 1200 proto nodes 4.5432 ms/op 4.9839 ms/op 0.91
computeDeltas 750000 validators 7200 proto nodes 4.5487 ms/op 4.8362 ms/op 0.94
computeDeltas 1400000 validators 300 proto nodes 8.9446 ms/op 9.9627 ms/op 0.90
computeDeltas 1400000 validators 1200 proto nodes 9.0650 ms/op 9.9531 ms/op 0.91
computeDeltas 1400000 validators 7200 proto nodes 8.8131 ms/op 9.3017 ms/op 0.95
computeDeltas 2100000 validators 300 proto nodes 12.932 ms/op 14.779 ms/op 0.88
computeDeltas 2100000 validators 1200 proto nodes 13.814 ms/op 16.466 ms/op 0.84
computeDeltas 2100000 validators 7200 proto nodes 13.518 ms/op 14.053 ms/op 0.96
altair processAttestation - 250000 vs - 7PWei normalcase 1.6290 ms/op 1.4624 ms/op 1.11
altair processAttestation - 250000 vs - 7PWei worstcase 2.4398 ms/op 2.2655 ms/op 1.08
altair processAttestation - setStatus - 1/6 committees join 97.963 us/op 81.448 us/op 1.20
altair processAttestation - setStatus - 1/3 committees join 192.30 us/op 161.01 us/op 1.19
altair processAttestation - setStatus - 1/2 committees join 274.68 us/op 224.47 us/op 1.22
altair processAttestation - setStatus - 2/3 committees join 364.14 us/op 298.89 us/op 1.22
altair processAttestation - setStatus - 4/5 committees join 499.44 us/op 416.94 us/op 1.20
altair processAttestation - setStatus - 100% committees join 597.82 us/op 481.99 us/op 1.24
altair processBlock - 250000 vs - 7PWei normalcase 8.3672 ms/op 8.4250 ms/op 0.99
altair processBlock - 250000 vs - 7PWei normalcase hashState 32.126 ms/op 34.119 ms/op 0.94
altair processBlock - 250000 vs - 7PWei worstcase 31.224 ms/op 32.333 ms/op 0.97
altair processBlock - 250000 vs - 7PWei worstcase hashState 81.230 ms/op 79.881 ms/op 1.02
phase0 processBlock - 250000 vs - 7PWei normalcase 2.0255 ms/op 2.5944 ms/op 0.78
phase0 processBlock - 250000 vs - 7PWei worstcase 23.915 ms/op 25.615 ms/op 0.93
altair processEth1Data - 250000 vs - 7PWei normalcase 306.63 us/op 291.01 us/op 1.05
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 9.3140 us/op 14.400 us/op 0.65
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 18.678 us/op 57.399 us/op 0.33
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 8.5260 us/op 9.3610 us/op 0.91
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 12.769 us/op 13.007 us/op 0.98
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 164.49 us/op 168.97 us/op 0.97
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.2354 ms/op 1.1762 ms/op 1.05
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 968.26 us/op 1.0235 ms/op 0.95
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.0200 ms/op 872.71 us/op 1.17
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.0884 ms/op 2.5181 ms/op 0.83
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.5349 ms/op 1.6885 ms/op 0.91
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 3.9060 ms/op 3.5054 ms/op 1.11
Tree 40 250000 create 260.53 ms/op 249.97 ms/op 1.04
Tree 40 250000 get(125000) 117.25 ns/op 111.64 ns/op 1.05
Tree 40 250000 set(125000) 765.33 ns/op 703.80 ns/op 1.09
Tree 40 250000 toArray() 12.031 ms/op 13.496 ms/op 0.89
Tree 40 250000 iterate all - toArray() + loop 10.111 ms/op 15.047 ms/op 0.67
Tree 40 250000 iterate all - get(i) 41.320 ms/op 41.412 ms/op 1.00
MutableVector 250000 create 12.859 ms/op 11.803 ms/op 1.09
MutableVector 250000 get(125000) 5.6440 ns/op 5.5870 ns/op 1.01
MutableVector 250000 set(125000) 201.06 ns/op 202.81 ns/op 0.99
MutableVector 250000 toArray() 2.0603 ms/op 2.7023 ms/op 0.76
MutableVector 250000 iterate all - toArray() + loop 2.2351 ms/op 2.8133 ms/op 0.79
MutableVector 250000 iterate all - get(i) 1.3810 ms/op 1.2981 ms/op 1.06
Array 250000 create 2.3054 ms/op 2.5706 ms/op 0.90
Array 250000 clone - spread 1.0476 ms/op 1.1216 ms/op 0.93
Array 250000 get(125000) 1.0230 ns/op 1.0320 ns/op 0.99
Array 250000 set(125000) 1.2140 ns/op 1.2310 ns/op 0.99
Array 250000 iterate all - loop 149.96 us/op 148.58 us/op 1.01
effectiveBalanceIncrements clone Uint8Array 300000 20.457 us/op 22.392 us/op 0.91
effectiveBalanceIncrements clone MutableVector 300000 400.00 ns/op 429.00 ns/op 0.93
effectiveBalanceIncrements rw all Uint8Array 300000 181.81 us/op 178.26 us/op 1.02
effectiveBalanceIncrements rw all MutableVector 300000 66.588 ms/op 67.345 ms/op 0.99
phase0 afterProcessEpoch - 250000 vs - 7PWei 74.149 ms/op 77.370 ms/op 0.96
phase0 beforeProcessEpoch - 250000 vs - 7PWei 44.427 ms/op 43.903 ms/op 1.01
altair processEpoch - mainnet_e81889 410.23 ms/op 439.51 ms/op 0.93
mainnet_e81889 - altair beforeProcessEpoch 64.155 ms/op 69.000 ms/op 0.93
mainnet_e81889 - altair processJustificationAndFinalization 11.287 us/op 7.1890 us/op 1.57
mainnet_e81889 - altair processInactivityUpdates 5.3321 ms/op 5.3367 ms/op 1.00
mainnet_e81889 - altair processRewardsAndPenalties 74.234 ms/op 60.104 ms/op 1.24
mainnet_e81889 - altair processRegistryUpdates 1.8510 us/op 1.8020 us/op 1.03
mainnet_e81889 - altair processSlashings 507.00 ns/op 571.00 ns/op 0.89
mainnet_e81889 - altair processEth1DataReset 599.00 ns/op 641.00 ns/op 0.93
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.6906 ms/op 1.6519 ms/op 1.02
mainnet_e81889 - altair processSlashingsReset 3.5000 us/op 3.3460 us/op 1.05
mainnet_e81889 - altair processRandaoMixesReset 3.1310 us/op 3.3500 us/op 0.93
mainnet_e81889 - altair processHistoricalRootsUpdate 943.00 ns/op 795.00 ns/op 1.19
mainnet_e81889 - altair processParticipationFlagUpdates 3.2140 us/op 1.2690 us/op 2.53
mainnet_e81889 - altair processSyncCommitteeUpdates 680.00 ns/op 687.00 ns/op 0.99
mainnet_e81889 - altair afterProcessEpoch 78.255 ms/op 77.740 ms/op 1.01
capella processEpoch - mainnet_e217614 1.6375 s/op 1.6750 s/op 0.98
mainnet_e217614 - capella beforeProcessEpoch 413.98 ms/op 391.19 ms/op 1.06
mainnet_e217614 - capella processJustificationAndFinalization 9.1030 us/op 10.423 us/op 0.87
mainnet_e217614 - capella processInactivityUpdates 15.245 ms/op 17.714 ms/op 0.86
mainnet_e217614 - capella processRewardsAndPenalties 444.87 ms/op 462.09 ms/op 0.96
mainnet_e217614 - capella processRegistryUpdates 19.887 us/op 19.823 us/op 1.00
mainnet_e217614 - capella processSlashings 590.00 ns/op 601.00 ns/op 0.98
mainnet_e217614 - capella processEth1DataReset 611.00 ns/op 635.00 ns/op 0.96
mainnet_e217614 - capella processEffectiveBalanceUpdates 3.5907 ms/op 3.5024 ms/op 1.03
mainnet_e217614 - capella processSlashingsReset 2.4000 us/op 3.3590 us/op 0.71
mainnet_e217614 - capella processRandaoMixesReset 5.5910 us/op 4.5500 us/op 1.23
mainnet_e217614 - capella processHistoricalRootsUpdate 749.00 ns/op 762.00 ns/op 0.98
mainnet_e217614 - capella processParticipationFlagUpdates 1.2300 us/op 1.6120 us/op 0.76
mainnet_e217614 - capella afterProcessEpoch 207.94 ms/op 234.06 ms/op 0.89
phase0 processEpoch - mainnet_e58758 343.23 ms/op 407.63 ms/op 0.84
mainnet_e58758 - phase0 beforeProcessEpoch 119.78 ms/op 111.10 ms/op 1.08
mainnet_e58758 - phase0 processJustificationAndFinalization 11.762 us/op 17.264 us/op 0.68
mainnet_e58758 - phase0 processRewardsAndPenalties 58.581 ms/op 57.563 ms/op 1.02
mainnet_e58758 - phase0 processRegistryUpdates 7.6900 us/op 11.144 us/op 0.69
mainnet_e58758 - phase0 processSlashings 577.00 ns/op 764.00 ns/op 0.76
mainnet_e58758 - phase0 processEth1DataReset 554.00 ns/op 647.00 ns/op 0.86
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.3599 ms/op 911.98 us/op 1.49
mainnet_e58758 - phase0 processSlashingsReset 2.1020 us/op 1.9520 us/op 1.08
mainnet_e58758 - phase0 processRandaoMixesReset 2.4540 us/op 4.3550 us/op 0.56
mainnet_e58758 - phase0 processHistoricalRootsUpdate 497.00 ns/op 818.00 ns/op 0.61
mainnet_e58758 - phase0 processParticipationRecordUpdates 2.6370 us/op 2.9300 us/op 0.90
mainnet_e58758 - phase0 afterProcessEpoch 67.215 ms/op 68.587 ms/op 0.98
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.0095 ms/op 974.95 us/op 1.04
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.1282 ms/op 1.1238 ms/op 1.00
altair processInactivityUpdates - 250000 normalcase 20.671 ms/op 26.095 ms/op 0.79
altair processInactivityUpdates - 250000 worstcase 21.783 ms/op 24.633 ms/op 0.88
phase0 processRegistryUpdates - 250000 normalcase 6.4220 us/op 9.2140 us/op 0.70
phase0 processRegistryUpdates - 250000 badcase_full_deposits 432.78 us/op 420.07 us/op 1.03
phase0 processRegistryUpdates - 250000 worstcase 0.5 118.35 ms/op 106.98 ms/op 1.11
altair processRewardsAndPenalties - 250000 normalcase 69.343 ms/op 52.241 ms/op 1.33
altair processRewardsAndPenalties - 250000 worstcase 70.257 ms/op 39.667 ms/op 1.77
phase0 getAttestationDeltas - 250000 normalcase 6.4004 ms/op 6.2859 ms/op 1.02
phase0 getAttestationDeltas - 250000 worstcase 6.7724 ms/op 5.8714 ms/op 1.15
phase0 processSlashings - 250000 worstcase 89.880 us/op 84.938 us/op 1.06
altair processSyncCommitteeUpdates - 250000 116.39 ms/op 108.21 ms/op 1.08
BeaconState.hashTreeRoot - No change 628.00 ns/op 413.00 ns/op 1.52
BeaconState.hashTreeRoot - 1 full validator 123.61 us/op 90.875 us/op 1.36
BeaconState.hashTreeRoot - 32 full validator 1.3237 ms/op 1.2300 ms/op 1.08
BeaconState.hashTreeRoot - 512 full validator 14.777 ms/op 14.065 ms/op 1.05
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 131.64 us/op 161.09 us/op 0.82
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.4432 ms/op 1.9187 ms/op 0.75
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 18.334 ms/op 26.141 ms/op 0.70
BeaconState.hashTreeRoot - 1 balances 83.747 us/op 109.62 us/op 0.76
BeaconState.hashTreeRoot - 32 balances 748.06 us/op 1.2074 ms/op 0.62
BeaconState.hashTreeRoot - 512 balances 7.0207 ms/op 11.360 ms/op 0.62
BeaconState.hashTreeRoot - 250000 balances 147.56 ms/op 198.95 ms/op 0.74
aggregationBits - 2048 els - zipIndexesInBitList 20.057 us/op 32.508 us/op 0.62
byteArrayEquals 32 64.915 ns/op 64.363 ns/op 1.01
Buffer.compare 32 38.359 ns/op 35.925 ns/op 1.07
byteArrayEquals 1024 1.6665 us/op 1.7447 us/op 0.96
Buffer.compare 1024 42.537 ns/op 47.259 ns/op 0.90
byteArrayEquals 16384 27.096 us/op 28.791 us/op 0.94
Buffer.compare 16384 190.32 ns/op 228.24 ns/op 0.83
byteArrayEquals 123687377 211.32 ms/op 213.41 ms/op 0.99
Buffer.compare 123687377 4.2127 ms/op 6.3352 ms/op 0.66
byteArrayEquals 32 - diff last byte 62.585 ns/op 60.818 ns/op 1.03
Buffer.compare 32 - diff last byte 38.198 ns/op 36.552 ns/op 1.05
byteArrayEquals 1024 - diff last byte 1.6123 us/op 1.6614 us/op 0.97
Buffer.compare 1024 - diff last byte 43.034 ns/op 42.487 ns/op 1.01
byteArrayEquals 16384 - diff last byte 25.872 us/op 28.154 us/op 0.92
Buffer.compare 16384 - diff last byte 229.72 ns/op 216.90 ns/op 1.06
byteArrayEquals 123687377 - diff last byte 210.15 ms/op 210.71 ms/op 1.00
Buffer.compare 123687377 - diff last byte 4.1371 ms/op 4.0409 ms/op 1.02
byteArrayEquals 32 - random bytes 4.6120 ns/op 4.5860 ns/op 1.01
Buffer.compare 32 - random bytes 40.007 ns/op 40.214 ns/op 0.99
byteArrayEquals 1024 - random bytes 4.4760 ns/op 4.5230 ns/op 0.99
Buffer.compare 1024 - random bytes 38.197 ns/op 38.861 ns/op 0.98
byteArrayEquals 16384 - random bytes 4.4790 ns/op 4.5130 ns/op 0.99
Buffer.compare 16384 - random bytes 38.381 ns/op 35.604 ns/op 1.08
byteArrayEquals 123687377 - random bytes 7.9200 ns/op 8.0400 ns/op 0.99
Buffer.compare 123687377 - random bytes 41.690 ns/op 59.880 ns/op 0.70
regular array get 100000 times 41.857 us/op 41.299 us/op 1.01
wrappedArray get 100000 times 42.140 us/op 41.252 us/op 1.02
arrayWithProxy get 100000 times 10.386 ms/op 9.9672 ms/op 1.04
ssz.Root.equals 56.014 ns/op 55.444 ns/op 1.01
byteArrayEquals 55.338 ns/op 54.172 ns/op 1.02
Buffer.compare 9.9430 ns/op 9.4210 ns/op 1.06
shuffle list - 16384 els 5.8929 ms/op 5.7751 ms/op 1.02
shuffle list - 250000 els 87.269 ms/op 86.759 ms/op 1.01
processSlot - 1 slots 13.467 us/op 17.968 us/op 0.75
processSlot - 32 slots 3.4089 ms/op 2.5517 ms/op 1.34
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 55.362 ms/op 57.109 ms/op 0.97
getCommitteeAssignments - req 1 vs - 250000 vc 2.4290 ms/op 2.3775 ms/op 1.02
getCommitteeAssignments - req 100 vs - 250000 vc 3.5513 ms/op 3.5459 ms/op 1.00
getCommitteeAssignments - req 1000 vs - 250000 vc 3.8182 ms/op 3.8395 ms/op 0.99
findModifiedValidators - 10000 modified validators 421.22 ms/op 416.22 ms/op 1.01
findModifiedValidators - 1000 modified validators 352.11 ms/op 333.75 ms/op 1.06
findModifiedValidators - 100 modified validators 310.96 ms/op 307.84 ms/op 1.01
findModifiedValidators - 10 modified validators 320.55 ms/op 307.55 ms/op 1.04
findModifiedValidators - 1 modified validators 317.55 ms/op 309.90 ms/op 1.02
findModifiedValidators - no difference 306.28 ms/op 293.62 ms/op 1.04
compare ViewDUs 3.9640 s/op 3.9769 s/op 1.00
compare each validator Uint8Array 1.7532 s/op 1.8654 s/op 0.94
compare ViewDU to Uint8Array 1.1657 s/op 738.21 ms/op 1.58
migrate state 1000000 validators, 24 modified, 0 new 780.62 ms/op 741.38 ms/op 1.05
migrate state 1000000 validators, 1700 modified, 1000 new 1.0638 s/op 1.0151 s/op 1.05
migrate state 1000000 validators, 3400 modified, 2000 new 1.2005 s/op 1.0433 s/op 1.15
migrate state 1500000 validators, 24 modified, 0 new 678.28 ms/op 649.28 ms/op 1.04
migrate state 1500000 validators, 1700 modified, 1000 new 1.0772 s/op 867.77 ms/op 1.24
migrate state 1500000 validators, 3400 modified, 2000 new 1.4564 s/op 1.1886 s/op 1.23
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 6.1100 ns/op 4.5100 ns/op 1.35
state getBlockRootAtSlot - 250000 vs - 7PWei 1.5321 us/op 771.97 ns/op 1.98
computeProposers - vc 250000 8.9609 ms/op 6.3854 ms/op 1.40
computeEpochShuffling - vc 250000 91.373 ms/op 83.416 ms/op 1.10
getNextSyncCommittee - vc 250000 181.34 ms/op 104.37 ms/op 1.74
computeSigningRoot for AttestationData 28.112 us/op 30.856 us/op 0.91
hash AttestationData serialized data then Buffer.toString(base64) 1.5094 us/op 1.2509 us/op 1.21
toHexString serialized data 1.0534 us/op 777.10 ns/op 1.36
Buffer.toString(base64) 175.14 ns/op 153.15 ns/op 1.14

Please sign in to comment.