Skip to content

Commit

Permalink
fix: check pubkey or validator index known to a state (#7284)
Browse files Browse the repository at this point in the history
* fix: check pubkey or validator index known to a state

* chore: add more comments
  • Loading branch information
twoeths authored Dec 6, 2024
1 parent cd1211f commit e353f67
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {electra, ssz} from "@lodestar/types";

import {CachedBeaconStateElectra} from "../types.js";
import {hasEth1WithdrawalCredential} from "../util/capella.js";
import {hasExecutionWithdrawalCredential, switchToCompoundingValidator} from "../util/electra.js";
import {hasExecutionWithdrawalCredential, isPubkeyKnown, switchToCompoundingValidator} from "../util/electra.js";
import {computeConsolidationEpochAndUpdateChurn} from "../util/epoch.js";
import {getConsolidationChurnLimit, isActiveValidator} from "../util/validator.js";

Expand All @@ -13,6 +13,10 @@ export function processConsolidationRequest(
consolidationRequest: electra.ConsolidationRequest
): void {
const {sourcePubkey, targetPubkey, sourceAddress} = consolidationRequest;
if (!isPubkeyKnown(state, sourcePubkey) || !isPubkeyKnown(state, targetPubkey)) {
return;
}

const sourceIndex = state.epochCtx.getValidatorIndex(sourcePubkey);
const targetIndex = state.epochCtx.getValidatorIndex(targetPubkey);

Expand Down Expand Up @@ -97,6 +101,7 @@ function isValidSwitchToCompoundRequest(

// Verify pubkey exists
if (sourceIndex === null) {
// this check is mainly to make the compiler happy, pubkey is checked by the consumer already
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/state-transition/src/epoch/processPendingDeposits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {PendingDeposit} from "@lodestar/types/lib/electra/types.js";
import {addValidatorToRegistry, isValidDepositSignature} from "../block/processDeposit.js";
import {CachedBeaconStateElectra, EpochTransitionCache} from "../types.js";
import {increaseBalance} from "../util/balance.js";
import {hasCompoundingWithdrawalCredential} from "../util/electra.js";
import {hasCompoundingWithdrawalCredential, isValidatorKnown} from "../util/electra.js";
import {computeStartSlotAtEpoch} from "../util/epoch.js";
import {getActivationExitChurnLimit} from "../util/validator.js";

Expand Down Expand Up @@ -51,7 +51,7 @@ export function processPendingDeposits(state: CachedBeaconStateElectra, cache: E
let isValidatorWithdrawn = false;

const validatorIndex = state.epochCtx.getValidatorIndex(deposit.pubkey);
if (validatorIndex !== null) {
if (isValidatorKnown(state, validatorIndex)) {
const validator = state.validators.getReadonly(validatorIndex);
isValidatorExited = validator.exitEpoch < FAR_FUTURE_EPOCH;
isValidatorWithdrawn = validator.withdrawableEpoch < nextEpoch;
Expand Down Expand Up @@ -103,7 +103,7 @@ function applyPendingDeposit(
const {pubkey, withdrawalCredentials, amount, signature} = deposit;
const cachedBalances = cache.balances;

if (validatorIndex === null) {
if (!isValidatorKnown(state, validatorIndex)) {
// Verify the deposit signature (proof of possession) which is not checked by the deposit contract
if (isValidDepositSignature(state.config, pubkey, withdrawalCredentials, amount, signature)) {
addValidatorToRegistry(ForkSeq.electra, state, pubkey, withdrawalCredentials, amount);
Expand Down
17 changes: 17 additions & 0 deletions packages/state-transition/src/util/electra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,20 @@ export function queueExcessActiveBalance(state: CachedBeaconStateElectra, index:
state.pendingDeposits.push(pendingDeposit);
}
}

/**
* Since we share pubkey2index, pubkey maybe added by other epoch transition but we don't have that validator in this state
*/
export function isPubkeyKnown(state: CachedBeaconStateElectra, pubkey: Uint8Array): boolean {
return isValidatorKnown(state, state.epochCtx.getValidatorIndex(pubkey));
}

/**
* Since we share pubkey2index, validatorIndex maybe not null but we don't have that validator in this state
*/
export function isValidatorKnown(
state: CachedBeaconStateElectra,
index: ValidatorIndex | null
): index is ValidatorIndex {
return index !== null && index < state.validators.length;
}

1 comment on commit e353f67

@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: e353f67 Previous: cd1211f Ratio
getSlashingsAndExits - default max 280.18 us/op 78.762 us/op 3.56
Full benchmark results
Benchmark suite Current: e353f67 Previous: cd1211f Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.8611 ms/op 1.6206 ms/op 1.15
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 66.150 us/op 45.587 us/op 1.45
BLS verify - blst 1.0097 ms/op 886.08 us/op 1.14
BLS verifyMultipleSignatures 3 - blst 1.3789 ms/op 1.6728 ms/op 0.82
BLS verifyMultipleSignatures 8 - blst 2.0167 ms/op 2.1152 ms/op 0.95
BLS verifyMultipleSignatures 32 - blst 6.1680 ms/op 4.4443 ms/op 1.39
BLS verifyMultipleSignatures 64 - blst 11.061 ms/op 8.3860 ms/op 1.32
BLS verifyMultipleSignatures 128 - blst 18.063 ms/op 15.980 ms/op 1.13
BLS deserializing 10000 signatures 713.14 ms/op 623.34 ms/op 1.14
BLS deserializing 100000 signatures 7.6594 s/op 6.2124 s/op 1.23
BLS verifyMultipleSignatures - same message - 3 - blst 1.1960 ms/op 985.84 us/op 1.21
BLS verifyMultipleSignatures - same message - 8 - blst 1.2856 ms/op 1.1168 ms/op 1.15
BLS verifyMultipleSignatures - same message - 32 - blst 2.2443 ms/op 1.7468 ms/op 1.28
BLS verifyMultipleSignatures - same message - 64 - blst 3.1287 ms/op 2.5993 ms/op 1.20
BLS verifyMultipleSignatures - same message - 128 - blst 4.9239 ms/op 4.2300 ms/op 1.16
BLS aggregatePubkeys 32 - blst 23.127 us/op 18.209 us/op 1.27
BLS aggregatePubkeys 128 - blst 75.337 us/op 63.745 us/op 1.18
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 140.97 ms/op 48.887 ms/op 2.88
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 71.910 ms/op 43.330 ms/op 1.66
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 58.196 ms/op 39.523 ms/op 1.47
getSlashingsAndExits - default max 280.18 us/op 78.762 us/op 3.56
getSlashingsAndExits - 2k 1.0132 ms/op 398.23 us/op 2.54
proposeBlockBody type=full, size=empty 8.2603 ms/op 5.0230 ms/op 1.64
isKnown best case - 1 super set check 711.00 ns/op 463.00 ns/op 1.54
isKnown normal case - 2 super set checks 761.00 ns/op 446.00 ns/op 1.71
isKnown worse case - 16 super set checks 759.00 ns/op 449.00 ns/op 1.69
InMemoryCheckpointStateCache - add get delete 4.9130 us/op 2.7350 us/op 1.80
validate api signedAggregateAndProof - struct 1.7936 ms/op 1.4582 ms/op 1.23
validate gossip signedAggregateAndProof - struct 1.7146 ms/op 1.6441 ms/op 1.04
batch validate gossip attestation - vc 640000 - chunk 32 143.80 us/op 118.04 us/op 1.22
batch validate gossip attestation - vc 640000 - chunk 64 124.20 us/op 112.75 us/op 1.10
batch validate gossip attestation - vc 640000 - chunk 128 114.49 us/op 101.76 us/op 1.13
batch validate gossip attestation - vc 640000 - chunk 256 113.21 us/op 98.952 us/op 1.14
pickEth1Vote - no votes 1.5117 ms/op 866.60 us/op 1.74
pickEth1Vote - max votes 9.3053 ms/op 4.4534 ms/op 2.09
pickEth1Vote - Eth1Data hashTreeRoot value x2048 16.225 ms/op 9.8374 ms/op 1.65
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 25.272 ms/op 14.596 ms/op 1.73
pickEth1Vote - Eth1Data fastSerialize value x2048 621.66 us/op 369.71 us/op 1.68
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.5772 ms/op 2.0284 ms/op 1.76
bytes32 toHexString 698.00 ns/op 585.00 ns/op 1.19
bytes32 Buffer.toString(hex) 256.00 ns/op 407.00 ns/op 0.63
bytes32 Buffer.toString(hex) from Uint8Array 500.00 ns/op 498.00 ns/op 1.00
bytes32 Buffer.toString(hex) + 0x 283.00 ns/op 408.00 ns/op 0.69
Object access 1 prop 0.21200 ns/op 0.32300 ns/op 0.66
Map access 1 prop 0.15000 ns/op 0.32300 ns/op 0.46
Object get x1000 6.6460 ns/op 5.6910 ns/op 1.17
Map get x1000 7.0490 ns/op 6.5120 ns/op 1.08
Object set x1000 60.015 ns/op 23.027 ns/op 2.61
Map set x1000 42.321 ns/op 19.001 ns/op 2.23
Return object 10000 times 0.32820 ns/op 0.30350 ns/op 1.08
Throw Error 10000 times 3.5306 us/op 2.7187 us/op 1.30
toHex 175.05 ns/op 116.05 ns/op 1.51
Buffer.from 173.84 ns/op 105.89 ns/op 1.64
shared Buffer 97.511 ns/op 69.799 ns/op 1.40
fastMsgIdFn sha256 / 200 bytes 2.4690 us/op 1.9650 us/op 1.26
fastMsgIdFn h32 xxhash / 200 bytes 310.00 ns/op 396.00 ns/op 0.78
fastMsgIdFn h64 xxhash / 200 bytes 297.00 ns/op 427.00 ns/op 0.70
fastMsgIdFn sha256 / 1000 bytes 7.7820 us/op 5.9870 us/op 1.30
fastMsgIdFn h32 xxhash / 1000 bytes 456.00 ns/op 538.00 ns/op 0.85
fastMsgIdFn h64 xxhash / 1000 bytes 369.00 ns/op 511.00 ns/op 0.72
fastMsgIdFn sha256 / 10000 bytes 70.066 us/op 47.066 us/op 1.49
fastMsgIdFn h32 xxhash / 10000 bytes 2.0560 us/op 1.9100 us/op 1.08
fastMsgIdFn h64 xxhash / 10000 bytes 1.3210 us/op 1.3040 us/op 1.01
send data - 1000 256B messages 18.048 ms/op 11.422 ms/op 1.58
send data - 1000 512B messages 24.680 ms/op 16.100 ms/op 1.53
send data - 1000 1024B messages 33.335 ms/op 25.163 ms/op 1.32
send data - 1000 1200B messages 29.483 ms/op 25.071 ms/op 1.18
send data - 1000 2048B messages 39.051 ms/op 28.722 ms/op 1.36
send data - 1000 4096B messages 40.562 ms/op 29.721 ms/op 1.36
send data - 1000 16384B messages 83.187 ms/op 71.308 ms/op 1.17
send data - 1000 65536B messages 246.51 ms/op 268.85 ms/op 0.92
enrSubnets - fastDeserialize 64 bits 1.6520 us/op 1.2540 us/op 1.32
enrSubnets - ssz BitVector 64 bits 483.00 ns/op 576.00 ns/op 0.84
enrSubnets - fastDeserialize 4 bits 215.00 ns/op 342.00 ns/op 0.63
enrSubnets - ssz BitVector 4 bits 422.00 ns/op 568.00 ns/op 0.74
prioritizePeers score -10:0 att 32-0.1 sync 2-0 185.22 us/op 131.55 us/op 1.41
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 201.62 us/op 142.32 us/op 1.42
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 323.73 us/op 251.16 us/op 1.29
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 524.97 us/op 392.05 us/op 1.34
prioritizePeers score 0:0 att 64-1 sync 4-1 693.81 us/op 419.01 us/op 1.66
array of 16000 items push then shift 1.7096 us/op 1.2808 us/op 1.33
LinkedList of 16000 items push then shift 8.2580 ns/op 6.4240 ns/op 1.29
array of 16000 items push then pop 144.37 ns/op 76.473 ns/op 1.89
LinkedList of 16000 items push then pop 7.7880 ns/op 6.2930 ns/op 1.24
array of 24000 items push then shift 2.5820 us/op 1.9178 us/op 1.35
LinkedList of 24000 items push then shift 8.0560 ns/op 6.5500 ns/op 1.23
array of 24000 items push then pop 193.01 ns/op 107.11 ns/op 1.80
LinkedList of 24000 items push then pop 8.0270 ns/op 6.2900 ns/op 1.28
intersect bitArray bitLen 8 6.6530 ns/op 5.4790 ns/op 1.21
intersect array and set length 8 49.346 ns/op 37.818 ns/op 1.30
intersect bitArray bitLen 128 31.924 ns/op 26.751 ns/op 1.19
intersect array and set length 128 728.89 ns/op 578.33 ns/op 1.26
bitArray.getTrueBitIndexes() bitLen 128 1.4190 us/op 1.3460 us/op 1.05
bitArray.getTrueBitIndexes() bitLen 248 2.3610 us/op 2.1690 us/op 1.09
bitArray.getTrueBitIndexes() bitLen 512 4.5470 us/op 3.8930 us/op 1.17
Buffer.concat 32 items 726.00 ns/op 910.00 ns/op 0.80
Uint8Array.set 32 items 1.4270 us/op 1.7210 us/op 0.83
Buffer.copy 2.5020 us/op 2.4760 us/op 1.01
Uint8Array.set - with subarray 2.2170 us/op 2.1020 us/op 1.05
Uint8Array.set - without subarray 1.3690 us/op 1.4550 us/op 0.94
getUint32 - dataview 232.00 ns/op 394.00 ns/op 0.59
getUint32 - manual 173.00 ns/op 331.00 ns/op 0.52
Set add up to 64 items then delete first 2.2087 us/op 1.7836 us/op 1.24
OrderedSet add up to 64 items then delete first 3.2785 us/op 2.7467 us/op 1.19
Set add up to 64 items then delete last 2.4940 us/op 2.0370 us/op 1.22
OrderedSet add up to 64 items then delete last 3.6674 us/op 3.0436 us/op 1.20
Set add up to 64 items then delete middle 2.5764 us/op 2.0383 us/op 1.26
OrderedSet add up to 64 items then delete middle 5.2776 us/op 4.4656 us/op 1.18
Set add up to 128 items then delete first 5.1315 us/op 4.0427 us/op 1.27
OrderedSet add up to 128 items then delete first 7.8987 us/op 6.2336 us/op 1.27
Set add up to 128 items then delete last 4.9310 us/op 3.9009 us/op 1.26
OrderedSet add up to 128 items then delete last 7.4171 us/op 5.8391 us/op 1.27
Set add up to 128 items then delete middle 4.8816 us/op 3.8850 us/op 1.26
OrderedSet add up to 128 items then delete middle 13.749 us/op 11.815 us/op 1.16
Set add up to 256 items then delete first 10.686 us/op 7.8624 us/op 1.36
OrderedSet add up to 256 items then delete first 15.955 us/op 12.309 us/op 1.30
Set add up to 256 items then delete last 10.101 us/op 7.6147 us/op 1.33
OrderedSet add up to 256 items then delete last 14.475 us/op 11.580 us/op 1.25
Set add up to 256 items then delete middle 9.7710 us/op 7.5578 us/op 1.29
OrderedSet add up to 256 items then delete middle 43.362 us/op 34.279 us/op 1.26
transfer serialized Status (84 B) 2.6350 us/op 2.1280 us/op 1.24
copy serialized Status (84 B) 1.3390 us/op 1.2550 us/op 1.07
transfer serialized SignedVoluntaryExit (112 B) 2.6240 us/op 2.1850 us/op 1.20
copy serialized SignedVoluntaryExit (112 B) 1.4120 us/op 1.2830 us/op 1.10
transfer serialized ProposerSlashing (416 B) 2.9900 us/op 2.3040 us/op 1.30
copy serialized ProposerSlashing (416 B) 2.0750 us/op 1.4020 us/op 1.48
transfer serialized Attestation (485 B) 3.4510 us/op 2.3350 us/op 1.48
copy serialized Attestation (485 B) 2.0820 us/op 1.4500 us/op 1.44
transfer serialized AttesterSlashing (33232 B) 2.9610 us/op 2.4230 us/op 1.22
copy serialized AttesterSlashing (33232 B) 5.9370 us/op 3.5320 us/op 1.68
transfer serialized Small SignedBeaconBlock (128000 B) 3.1760 us/op 2.7210 us/op 1.17
copy serialized Small SignedBeaconBlock (128000 B) 19.063 us/op 8.2790 us/op 2.30
transfer serialized Avg SignedBeaconBlock (200000 B) 3.8880 us/op 3.3490 us/op 1.16
copy serialized Avg SignedBeaconBlock (200000 B) 21.590 us/op 17.763 us/op 1.22
transfer serialized BlobsSidecar (524380 B) 4.1760 us/op 3.4900 us/op 1.20
copy serialized BlobsSidecar (524380 B) 94.555 us/op 130.03 us/op 0.73
transfer serialized Big SignedBeaconBlock (1000000 B) 5.2810 us/op 3.9380 us/op 1.34
copy serialized Big SignedBeaconBlock (1000000 B) 158.47 us/op 361.81 us/op 0.44
pass gossip attestations to forkchoice per slot 2.8285 ms/op 2.3794 ms/op 1.19
forkChoice updateHead vc 100000 bc 64 eq 0 462.13 us/op 364.18 us/op 1.27
forkChoice updateHead vc 600000 bc 64 eq 0 3.2094 ms/op 2.5377 ms/op 1.26
forkChoice updateHead vc 1000000 bc 64 eq 0 4.9682 ms/op 4.0034 ms/op 1.24
forkChoice updateHead vc 600000 bc 320 eq 0 2.8988 ms/op 2.1741 ms/op 1.33
forkChoice updateHead vc 600000 bc 1200 eq 0 2.9281 ms/op 2.2659 ms/op 1.29
forkChoice updateHead vc 600000 bc 7200 eq 0 3.6572 ms/op 2.6398 ms/op 1.39
forkChoice updateHead vc 600000 bc 64 eq 1000 10.443 ms/op 9.2436 ms/op 1.13
forkChoice updateHead vc 600000 bc 64 eq 10000 10.564 ms/op 9.3593 ms/op 1.13
forkChoice updateHead vc 600000 bc 64 eq 300000 13.529 ms/op 11.621 ms/op 1.16
computeDeltas 500000 validators 300 proto nodes 4.3807 ms/op 3.2269 ms/op 1.36
computeDeltas 500000 validators 1200 proto nodes 4.5817 ms/op 3.3283 ms/op 1.38
computeDeltas 500000 validators 7200 proto nodes 4.5185 ms/op 3.3858 ms/op 1.33
computeDeltas 750000 validators 300 proto nodes 6.4843 ms/op 4.9353 ms/op 1.31
computeDeltas 750000 validators 1200 proto nodes 6.9674 ms/op 4.8130 ms/op 1.45
computeDeltas 750000 validators 7200 proto nodes 7.3958 ms/op 4.7123 ms/op 1.57
computeDeltas 1400000 validators 300 proto nodes 13.512 ms/op 8.9540 ms/op 1.51
computeDeltas 1400000 validators 1200 proto nodes 15.617 ms/op 9.2553 ms/op 1.69
computeDeltas 1400000 validators 7200 proto nodes 16.388 ms/op 9.2040 ms/op 1.78
computeDeltas 2100000 validators 300 proto nodes 24.994 ms/op 13.687 ms/op 1.83
computeDeltas 2100000 validators 1200 proto nodes 24.612 ms/op 14.079 ms/op 1.75
computeDeltas 2100000 validators 7200 proto nodes 25.869 ms/op 14.778 ms/op 1.75
altair processAttestation - 250000 vs - 7PWei normalcase 3.0299 ms/op 1.7841 ms/op 1.70
altair processAttestation - 250000 vs - 7PWei worstcase 4.0541 ms/op 2.3573 ms/op 1.72
altair processAttestation - setStatus - 1/6 committees join 148.94 us/op 102.96 us/op 1.45
altair processAttestation - setStatus - 1/3 committees join 244.61 us/op 189.44 us/op 1.29
altair processAttestation - setStatus - 1/2 committees join 295.60 us/op 271.05 us/op 1.09
altair processAttestation - setStatus - 2/3 committees join 433.31 us/op 354.12 us/op 1.22
altair processAttestation - setStatus - 4/5 committees join 616.84 us/op 491.42 us/op 1.26
altair processAttestation - setStatus - 100% committees join 768.64 us/op 597.51 us/op 1.29
altair processBlock - 250000 vs - 7PWei normalcase 5.4702 ms/op 4.6231 ms/op 1.18
altair processBlock - 250000 vs - 7PWei normalcase hashState 37.767 ms/op 26.004 ms/op 1.45
altair processBlock - 250000 vs - 7PWei worstcase 45.998 ms/op 36.297 ms/op 1.27
altair processBlock - 250000 vs - 7PWei worstcase hashState 91.080 ms/op 84.708 ms/op 1.08
phase0 processBlock - 250000 vs - 7PWei normalcase 3.3763 ms/op 1.5863 ms/op 2.13
phase0 processBlock - 250000 vs - 7PWei worstcase 31.558 ms/op 21.545 ms/op 1.46
altair processEth1Data - 250000 vs - 7PWei normalcase 645.76 us/op 268.70 us/op 2.40
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 11.041 us/op 4.9860 us/op 2.21
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 85.560 us/op 46.927 us/op 1.82
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 17.529 us/op 11.937 us/op 1.47
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 11.949 us/op 6.0930 us/op 1.96
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 198.65 us/op 184.94 us/op 1.07
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.4545 ms/op 1.4466 ms/op 1.01
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.1446 ms/op 1.7671 ms/op 1.21
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.5417 ms/op 1.8773 ms/op 0.82
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.2391 ms/op 3.2103 ms/op 1.32
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.9879 ms/op 1.1384 ms/op 1.75
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 3.9456 ms/op 3.0876 ms/op 1.28
Tree 40 250000 create 264.81 ms/op 189.38 ms/op 1.40
Tree 40 250000 get(125000) 157.22 ns/op 113.30 ns/op 1.39
Tree 40 250000 set(125000) 771.21 ns/op 509.89 ns/op 1.51
Tree 40 250000 toArray() 23.715 ms/op 12.704 ms/op 1.87
Tree 40 250000 iterate all - toArray() + loop 23.183 ms/op 12.440 ms/op 1.86
Tree 40 250000 iterate all - get(i) 55.475 ms/op 41.625 ms/op 1.33
Array 250000 create 4.0550 ms/op 2.4157 ms/op 1.68
Array 250000 clone - spread 1.5559 ms/op 1.2333 ms/op 1.26
Array 250000 get(125000) 0.42600 ns/op 0.55400 ns/op 0.77
Array 250000 set(125000) 0.44800 ns/op 0.56900 ns/op 0.79
Array 250000 iterate all - loop 83.333 us/op 73.412 us/op 1.14
phase0 afterProcessEpoch - 250000 vs - 7PWei 51.918 ms/op 40.931 ms/op 1.27
Array.fill - length 1000000 3.6573 ms/op 2.4553 ms/op 1.49
Array push - length 1000000 21.713 ms/op 9.5107 ms/op 2.28
Array.get 0.28507 ns/op 0.25539 ns/op 1.12
Uint8Array.get 0.44205 ns/op 0.34363 ns/op 1.29
phase0 beforeProcessEpoch - 250000 vs - 7PWei 19.185 ms/op 17.781 ms/op 1.08
altair processEpoch - mainnet_e81889 296.28 ms/op 277.14 ms/op 1.07
mainnet_e81889 - altair beforeProcessEpoch 18.983 ms/op 18.035 ms/op 1.05
mainnet_e81889 - altair processJustificationAndFinalization 16.077 us/op 7.0400 us/op 2.28
mainnet_e81889 - altair processInactivityUpdates 5.6131 ms/op 4.3099 ms/op 1.30
mainnet_e81889 - altair processRewardsAndPenalties 52.126 ms/op 49.659 ms/op 1.05
mainnet_e81889 - altair processRegistryUpdates 2.2210 us/op 2.4830 us/op 0.89
mainnet_e81889 - altair processSlashings 512.00 ns/op 774.00 ns/op 0.66
mainnet_e81889 - altair processEth1DataReset 496.00 ns/op 770.00 ns/op 0.64
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.1590 ms/op 1.6326 ms/op 1.32
mainnet_e81889 - altair processSlashingsReset 3.7400 us/op 2.5540 us/op 1.46
mainnet_e81889 - altair processRandaoMixesReset 4.5060 us/op 3.3530 us/op 1.34
mainnet_e81889 - altair processHistoricalRootsUpdate 1.0560 us/op 843.00 ns/op 1.25
mainnet_e81889 - altair processParticipationFlagUpdates 3.9030 us/op 1.8710 us/op 2.09
mainnet_e81889 - altair processSyncCommitteeUpdates 815.00 ns/op 787.00 ns/op 1.04
mainnet_e81889 - altair afterProcessEpoch 51.355 ms/op 43.150 ms/op 1.19
capella processEpoch - mainnet_e217614 1.0074 s/op 904.46 ms/op 1.11
mainnet_e217614 - capella beforeProcessEpoch 65.945 ms/op 63.405 ms/op 1.04
mainnet_e217614 - capella processJustificationAndFinalization 18.498 us/op 10.633 us/op 1.74
mainnet_e217614 - capella processInactivityUpdates 17.822 ms/op 15.220 ms/op 1.17
mainnet_e217614 - capella processRewardsAndPenalties 224.07 ms/op 233.97 ms/op 0.96
mainnet_e217614 - capella processRegistryUpdates 15.032 us/op 15.958 us/op 0.94
mainnet_e217614 - capella processSlashings 693.00 ns/op 821.00 ns/op 0.84
mainnet_e217614 - capella processEth1DataReset 460.00 ns/op 749.00 ns/op 0.61
mainnet_e217614 - capella processEffectiveBalanceUpdates 14.559 ms/op 4.6872 ms/op 3.11
mainnet_e217614 - capella processSlashingsReset 4.1070 us/op 3.2650 us/op 1.26
mainnet_e217614 - capella processRandaoMixesReset 5.8210 us/op 6.2870 us/op 0.93
mainnet_e217614 - capella processHistoricalRootsUpdate 803.00 ns/op 894.00 ns/op 0.90
mainnet_e217614 - capella processParticipationFlagUpdates 1.3650 us/op 1.8000 us/op 0.76
mainnet_e217614 - capella afterProcessEpoch 125.48 ms/op 103.41 ms/op 1.21
phase0 processEpoch - mainnet_e58758 341.24 ms/op 281.91 ms/op 1.21
mainnet_e58758 - phase0 beforeProcessEpoch 85.928 ms/op 72.915 ms/op 1.18
mainnet_e58758 - phase0 processJustificationAndFinalization 13.941 us/op 11.049 us/op 1.26
mainnet_e58758 - phase0 processRewardsAndPenalties 27.494 ms/op 29.445 ms/op 0.93
mainnet_e58758 - phase0 processRegistryUpdates 9.0680 us/op 8.8360 us/op 1.03
mainnet_e58758 - phase0 processSlashings 475.00 ns/op 820.00 ns/op 0.58
mainnet_e58758 - phase0 processEth1DataReset 405.00 ns/op 809.00 ns/op 0.50
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.5373 ms/op 1.4369 ms/op 1.07
mainnet_e58758 - phase0 processSlashingsReset 2.6460 us/op 2.2980 us/op 1.15
mainnet_e58758 - phase0 processRandaoMixesReset 6.8060 us/op 3.6390 us/op 1.87
mainnet_e58758 - phase0 processHistoricalRootsUpdate 704.00 ns/op 754.00 ns/op 0.93
mainnet_e58758 - phase0 processParticipationRecordUpdates 5.8040 us/op 3.3780 us/op 1.72
mainnet_e58758 - phase0 afterProcessEpoch 41.409 ms/op 35.660 ms/op 1.16
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.3428 ms/op 1.7186 ms/op 0.78
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 3.5802 ms/op 1.3454 ms/op 2.66
altair processInactivityUpdates - 250000 normalcase 18.682 ms/op 15.397 ms/op 1.21
altair processInactivityUpdates - 250000 worstcase 20.664 ms/op 16.586 ms/op 1.25
phase0 processRegistryUpdates - 250000 normalcase 7.0430 us/op 8.2350 us/op 0.86
phase0 processRegistryUpdates - 250000 badcase_full_deposits 537.34 us/op 359.22 us/op 1.50
phase0 processRegistryUpdates - 250000 worstcase 0.5 97.173 ms/op 101.46 ms/op 0.96
altair processRewardsAndPenalties - 250000 normalcase 41.872 ms/op 35.869 ms/op 1.17
altair processRewardsAndPenalties - 250000 worstcase 55.139 ms/op 41.499 ms/op 1.33
phase0 getAttestationDeltas - 250000 normalcase 7.8362 ms/op 6.4177 ms/op 1.22
phase0 getAttestationDeltas - 250000 worstcase 7.4605 ms/op 6.2682 ms/op 1.19
phase0 processSlashings - 250000 worstcase 119.43 us/op 92.758 us/op 1.29
altair processSyncCommitteeUpdates - 250000 116.55 ms/op 110.73 ms/op 1.05
BeaconState.hashTreeRoot - No change 243.00 ns/op 465.00 ns/op 0.52
BeaconState.hashTreeRoot - 1 full validator 126.09 us/op 120.11 us/op 1.05
BeaconState.hashTreeRoot - 32 full validator 1.5429 ms/op 1.3227 ms/op 1.17
BeaconState.hashTreeRoot - 512 full validator 8.8324 ms/op 11.813 ms/op 0.75
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 113.27 us/op 142.55 us/op 0.79
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.9487 ms/op 1.8451 ms/op 1.06
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 24.072 ms/op 25.961 ms/op 0.93
BeaconState.hashTreeRoot - 1 balances 118.78 us/op 116.47 us/op 1.02
BeaconState.hashTreeRoot - 32 balances 1.0747 ms/op 992.12 us/op 1.08
BeaconState.hashTreeRoot - 512 balances 8.3605 ms/op 7.6221 ms/op 1.10
BeaconState.hashTreeRoot - 250000 balances 206.48 ms/op 180.66 ms/op 1.14
aggregationBits - 2048 els - zipIndexesInBitList 28.595 us/op 19.197 us/op 1.49
byteArrayEquals 32 53.196 ns/op 45.785 ns/op 1.16
Buffer.compare 32 17.083 ns/op 16.160 ns/op 1.06
byteArrayEquals 1024 1.5651 us/op 1.2621 us/op 1.24
Buffer.compare 1024 25.997 ns/op 22.478 ns/op 1.16
byteArrayEquals 16384 24.963 us/op 20.104 us/op 1.24
Buffer.compare 16384 196.56 ns/op 180.68 ns/op 1.09
byteArrayEquals 123687377 189.64 ms/op 148.88 ms/op 1.27
Buffer.compare 123687377 6.4044 ms/op 4.2095 ms/op 1.52
byteArrayEquals 32 - diff last byte 52.101 ns/op 46.893 ns/op 1.11
Buffer.compare 32 - diff last byte 17.038 ns/op 17.226 ns/op 0.99
byteArrayEquals 1024 - diff last byte 1.5749 us/op 1.2530 us/op 1.26
Buffer.compare 1024 - diff last byte 25.195 ns/op 23.374 ns/op 1.08
byteArrayEquals 16384 - diff last byte 25.043 us/op 19.859 us/op 1.26
Buffer.compare 16384 - diff last byte 202.03 ns/op 167.12 ns/op 1.21
byteArrayEquals 123687377 - diff last byte 189.33 ms/op 142.88 ms/op 1.33
Buffer.compare 123687377 - diff last byte 6.7821 ms/op 5.2922 ms/op 1.28
byteArrayEquals 32 - random bytes 5.1080 ns/op 4.7240 ns/op 1.08
Buffer.compare 32 - random bytes 16.989 ns/op 14.946 ns/op 1.14
byteArrayEquals 1024 - random bytes 5.0920 ns/op 4.7390 ns/op 1.07
Buffer.compare 1024 - random bytes 17.006 ns/op 14.787 ns/op 1.15
byteArrayEquals 16384 - random bytes 5.1120 ns/op 4.7270 ns/op 1.08
Buffer.compare 16384 - random bytes 17.028 ns/op 14.805 ns/op 1.15
byteArrayEquals 123687377 - random bytes 6.4000 ns/op 7.4300 ns/op 0.86
Buffer.compare 123687377 - random bytes 18.350 ns/op 17.540 ns/op 1.05
regular array get 100000 times 32.897 us/op 29.389 us/op 1.12
wrappedArray get 100000 times 32.810 us/op 29.428 us/op 1.11
arrayWithProxy get 100000 times 13.144 ms/op 8.3966 ms/op 1.57
ssz.Root.equals 45.623 ns/op 40.533 ns/op 1.13
byteArrayEquals 45.006 ns/op 41.506 ns/op 1.08
Buffer.compare 10.301 ns/op 8.6260 ns/op 1.19
processSlot - 1 slots 13.269 us/op 13.281 us/op 1.00
processSlot - 32 slots 2.9395 ms/op 2.8874 ms/op 1.02
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 41.496 ms/op 40.240 ms/op 1.03
getCommitteeAssignments - req 1 vs - 250000 vc 1.9987 ms/op 1.8131 ms/op 1.10
getCommitteeAssignments - req 100 vs - 250000 vc 3.8819 ms/op 3.5555 ms/op 1.09
getCommitteeAssignments - req 1000 vs - 250000 vc 4.1555 ms/op 3.7908 ms/op 1.10
findModifiedValidators - 10000 modified validators 227.62 ms/op 216.26 ms/op 1.05
findModifiedValidators - 1000 modified validators 156.38 ms/op 135.92 ms/op 1.15
findModifiedValidators - 100 modified validators 157.45 ms/op 132.56 ms/op 1.19
findModifiedValidators - 10 modified validators 141.92 ms/op 134.82 ms/op 1.05
findModifiedValidators - 1 modified validators 144.38 ms/op 130.08 ms/op 1.11
findModifiedValidators - no difference 156.78 ms/op 133.95 ms/op 1.17
compare ViewDUs 3.1827 s/op 3.3114 s/op 0.96
compare each validator Uint8Array 1.0649 s/op 1.5505 s/op 0.69
compare ViewDU to Uint8Array 881.36 ms/op 725.81 ms/op 1.21
migrate state 1000000 validators, 24 modified, 0 new 709.79 ms/op 684.43 ms/op 1.04
migrate state 1000000 validators, 1700 modified, 1000 new 1.0012 s/op 895.51 ms/op 1.12
migrate state 1000000 validators, 3400 modified, 2000 new 1.1285 s/op 1.0944 s/op 1.03
migrate state 1500000 validators, 24 modified, 0 new 770.32 ms/op 725.78 ms/op 1.06
migrate state 1500000 validators, 1700 modified, 1000 new 953.89 ms/op 955.14 ms/op 1.00
migrate state 1500000 validators, 3400 modified, 2000 new 1.2425 s/op 1.0997 s/op 1.13
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.6500 ns/op 6.7600 ns/op 0.69
state getBlockRootAtSlot - 250000 vs - 7PWei 726.36 ns/op 411.71 ns/op 1.76
computeProposers - vc 250000 7.1492 ms/op 5.8066 ms/op 1.23
computeEpochShuffling - vc 250000 43.621 ms/op 36.288 ms/op 1.20
getNextSyncCommittee - vc 250000 138.25 ms/op 114.33 ms/op 1.21
computeSigningRoot for AttestationData 27.919 us/op 24.369 us/op 1.15
hash AttestationData serialized data then Buffer.toString(base64) 1.6834 us/op 1.2125 us/op 1.39
toHexString serialized data 1.2167 us/op 789.43 ns/op 1.54
Buffer.toString(base64) 190.03 ns/op 124.40 ns/op 1.53
nodejs block root to RootHex using toHex 155.02 ns/op 118.94 ns/op 1.30
nodejs block root to RootHex using toRootHex 92.480 ns/op 79.315 ns/op 1.17
browser block root to RootHex using the deprecated toHexString 242.02 ns/op 208.45 ns/op 1.16
browser block root to RootHex using toHex 196.18 ns/op 166.99 ns/op 1.17
browser block root to RootHex using toRootHex 174.97 ns/op 154.13 ns/op 1.14

Please sign in to comment.