Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid uncaught exception when polling validator indices #6891

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Jun 17, 2024

Motivation

See #6888 for logs and more context

Description

Avoid uncaught exception when polling validator indices. The finally was called in a different context, causing an uncaught exception as catch handlers of upstream code where called earlier.

Copy link
Contributor

github-actions bot commented Jun 17, 2024

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 01da9f1 Previous: 7e35c92 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 462.91 us/op 909.57 us/op 0.51
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 52.849 us/op 72.322 us/op 0.73
BLS verify - blst-native 1.2177 ms/op 1.2584 ms/op 0.97
BLS verifyMultipleSignatures 3 - blst-native 2.5549 ms/op 2.6870 ms/op 0.95
BLS verifyMultipleSignatures 8 - blst-native 5.6634 ms/op 5.9055 ms/op 0.96
BLS verifyMultipleSignatures 32 - blst-native 20.814 ms/op 21.758 ms/op 0.96
BLS verifyMultipleSignatures 64 - blst-native 40.963 ms/op 43.217 ms/op 0.95
BLS verifyMultipleSignatures 128 - blst-native 82.205 ms/op 87.270 ms/op 0.94
BLS deserializing 10000 signatures 860.79 ms/op 912.33 ms/op 0.94
BLS deserializing 100000 signatures 8.7249 s/op 10.082 s/op 0.87
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.2438 ms/op 1.4174 ms/op 0.88
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.4177 ms/op 1.5905 ms/op 0.89
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.3112 ms/op 2.3293 ms/op 0.99
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.5949 ms/op 3.4058 ms/op 1.06
BLS verifyMultipleSignatures - same message - 128 - blst-native 5.5524 ms/op 6.7974 ms/op 0.82
BLS aggregatePubkeys 32 - blst-native 24.906 us/op 27.037 us/op 0.92
BLS aggregatePubkeys 128 - blst-native 96.494 us/op 103.03 us/op 0.94
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 79.884 ms/op 58.962 ms/op 1.35
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 70.937 ms/op 71.688 ms/op 0.99
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 37.324 ms/op 33.791 ms/op 1.10
getSlashingsAndExits - default max 100.23 us/op 141.03 us/op 0.71
getSlashingsAndExits - 2k 285.23 us/op 329.68 us/op 0.87
proposeBlockBody type=full, size=empty 5.5554 ms/op 5.9083 ms/op 0.94
isKnown best case - 1 super set check 303.00 ns/op 471.00 ns/op 0.64
isKnown normal case - 2 super set checks 274.00 ns/op 472.00 ns/op 0.58
isKnown worse case - 16 super set checks 268.00 ns/op 574.00 ns/op 0.47
InMemoryCheckpointStateCache - add get delete 4.5940 us/op 6.5360 us/op 0.70
validate api signedAggregateAndProof - struct 2.6243 ms/op 2.7003 ms/op 0.97
validate gossip signedAggregateAndProof - struct 2.6228 ms/op 2.7125 ms/op 0.97
validate gossip attestation - vc 640000 1.2761 ms/op 1.3033 ms/op 0.98
batch validate gossip attestation - vc 640000 - chunk 32 150.93 us/op 162.59 us/op 0.93
batch validate gossip attestation - vc 640000 - chunk 64 136.54 us/op 148.06 us/op 0.92
batch validate gossip attestation - vc 640000 - chunk 128 123.56 us/op 144.80 us/op 0.85
batch validate gossip attestation - vc 640000 - chunk 256 118.85 us/op 148.66 us/op 0.80
pickEth1Vote - no votes 996.35 us/op 1.5118 ms/op 0.66
pickEth1Vote - max votes 10.078 ms/op 17.659 ms/op 0.57
pickEth1Vote - Eth1Data hashTreeRoot value x2048 13.891 ms/op 21.934 ms/op 0.63
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 22.809 ms/op 43.306 ms/op 0.53
pickEth1Vote - Eth1Data fastSerialize value x2048 468.82 us/op 756.30 us/op 0.62
pickEth1Vote - Eth1Data fastSerialize tree x2048 6.7358 ms/op 5.8245 ms/op 1.16
bytes32 toHexString 426.00 ns/op 840.00 ns/op 0.51
bytes32 Buffer.toString(hex) 249.00 ns/op 289.00 ns/op 0.86
bytes32 Buffer.toString(hex) from Uint8Array 375.00 ns/op 460.00 ns/op 0.82
bytes32 Buffer.toString(hex) + 0x 247.00 ns/op 266.00 ns/op 0.93
Object access 1 prop 0.13000 ns/op 0.19800 ns/op 0.66
Map access 1 prop 0.12400 ns/op 0.13900 ns/op 0.89
Object get x1000 5.7040 ns/op 6.1880 ns/op 0.92
Map get x1000 6.5590 ns/op 6.6730 ns/op 0.98
Object set x1000 32.203 ns/op 48.647 ns/op 0.66
Map set x1000 22.916 ns/op 38.330 ns/op 0.60
Return object 10000 times 0.28760 ns/op 0.31470 ns/op 0.91
Throw Error 10000 times 3.3173 us/op 3.7794 us/op 0.88
fastMsgIdFn sha256 / 200 bytes 2.2010 us/op 2.5580 us/op 0.86
fastMsgIdFn h32 xxhash / 200 bytes 231.00 ns/op 313.00 ns/op 0.74
fastMsgIdFn h64 xxhash / 200 bytes 272.00 ns/op 290.00 ns/op 0.94
fastMsgIdFn sha256 / 1000 bytes 7.4780 us/op 7.7670 us/op 0.96
fastMsgIdFn h32 xxhash / 1000 bytes 409.00 ns/op 453.00 ns/op 0.90
fastMsgIdFn h64 xxhash / 1000 bytes 337.00 ns/op 394.00 ns/op 0.86
fastMsgIdFn sha256 / 10000 bytes 64.953 us/op 70.428 us/op 0.92
fastMsgIdFn h32 xxhash / 10000 bytes 1.9000 us/op 2.1690 us/op 0.88
fastMsgIdFn h64 xxhash / 10000 bytes 1.2340 us/op 1.4050 us/op 0.88
send data - 1000 256B messages 14.324 ms/op 16.193 ms/op 0.88
send data - 1000 512B messages 18.500 ms/op 23.301 ms/op 0.79
send data - 1000 1024B messages 28.881 ms/op 32.541 ms/op 0.89
send data - 1000 1200B messages 27.358 ms/op 33.200 ms/op 0.82
send data - 1000 2048B messages 33.740 ms/op 34.771 ms/op 0.97
send data - 1000 4096B messages 35.567 ms/op 34.797 ms/op 1.02
send data - 1000 16384B messages 75.047 ms/op 75.871 ms/op 0.99
send data - 1000 65536B messages 230.75 ms/op 235.76 ms/op 0.98
enrSubnets - fastDeserialize 64 bits 1.0640 us/op 1.2770 us/op 0.83
enrSubnets - ssz BitVector 64 bits 403.00 ns/op 384.00 ns/op 1.05
enrSubnets - fastDeserialize 4 bits 183.00 ns/op 182.00 ns/op 1.01
enrSubnets - ssz BitVector 4 bits 453.00 ns/op 453.00 ns/op 1.00
prioritizePeers score -10:0 att 32-0.1 sync 2-0 149.01 us/op 191.15 us/op 0.78
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 159.01 us/op 194.41 us/op 0.82
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 226.93 us/op 293.85 us/op 0.77
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 413.46 us/op 500.43 us/op 0.83
prioritizePeers score 0:0 att 64-1 sync 4-1 598.18 us/op 648.01 us/op 0.92
array of 16000 items push then shift 1.7171 us/op 1.7722 us/op 0.97
LinkedList of 16000 items push then shift 8.2920 ns/op 8.1710 ns/op 1.01
array of 16000 items push then pop 120.03 ns/op 146.84 ns/op 0.82
LinkedList of 16000 items push then pop 7.2580 ns/op 7.5990 ns/op 0.96
array of 24000 items push then shift 2.4314 us/op 2.5813 us/op 0.94
LinkedList of 24000 items push then shift 8.0200 ns/op 8.1090 ns/op 0.99
array of 24000 items push then pop 157.75 ns/op 174.69 ns/op 0.90
LinkedList of 24000 items push then pop 7.6340 ns/op 7.3380 ns/op 1.04
intersect bitArray bitLen 8 6.5840 ns/op 6.5740 ns/op 1.00
intersect array and set length 8 45.196 ns/op 49.383 ns/op 0.92
intersect bitArray bitLen 128 29.846 ns/op 30.654 ns/op 0.97
intersect array and set length 128 724.15 ns/op 755.25 ns/op 0.96
bitArray.getTrueBitIndexes() bitLen 128 1.4690 us/op 1.8990 us/op 0.77
bitArray.getTrueBitIndexes() bitLen 248 2.3100 us/op 3.6270 us/op 0.64
bitArray.getTrueBitIndexes() bitLen 512 5.2360 us/op 8.7400 us/op 0.60
Buffer.concat 32 items 1.0260 us/op 1.1120 us/op 0.92
Uint8Array.set 32 items 2.0940 us/op 1.6730 us/op 1.25
Buffer.copy 2.5940 us/op 1.6940 us/op 1.53
Uint8Array.set - with subarray 3.4090 us/op 2.6870 us/op 1.27
Uint8Array.set - without subarray 1.9430 us/op 1.3830 us/op 1.40
Set add up to 64 items then delete first 2.2338 us/op 3.0933 us/op 0.72
OrderedSet add up to 64 items then delete first 3.2539 us/op 4.5889 us/op 0.71
Set add up to 64 items then delete last 2.4618 us/op 3.1843 us/op 0.77
OrderedSet add up to 64 items then delete last 3.8692 us/op 4.4885 us/op 0.86
Set add up to 64 items then delete middle 2.5333 us/op 2.7978 us/op 0.91
OrderedSet add up to 64 items then delete middle 5.2555 us/op 5.7482 us/op 0.91
Set add up to 128 items then delete first 4.9552 us/op 5.7243 us/op 0.87
OrderedSet add up to 128 items then delete first 7.2260 us/op 9.5107 us/op 0.76
Set add up to 128 items then delete last 5.0998 us/op 6.9310 us/op 0.74
OrderedSet add up to 128 items then delete last 7.7434 us/op 12.272 us/op 0.63
Set add up to 128 items then delete middle 5.3821 us/op 7.1686 us/op 0.75
OrderedSet add up to 128 items then delete middle 14.665 us/op 19.150 us/op 0.77
Set add up to 256 items then delete first 10.459 us/op 13.882 us/op 0.75
OrderedSet add up to 256 items then delete first 15.538 us/op 20.402 us/op 0.76
Set add up to 256 items then delete last 10.258 us/op 14.070 us/op 0.73
OrderedSet add up to 256 items then delete last 16.306 us/op 23.804 us/op 0.69
Set add up to 256 items then delete middle 10.010 us/op 15.272 us/op 0.66
OrderedSet add up to 256 items then delete middle 43.215 us/op 52.549 us/op 0.82
transfer serialized Status (84 B) 1.4700 us/op 1.5510 us/op 0.95
copy serialized Status (84 B) 1.2350 us/op 1.4060 us/op 0.88
transfer serialized SignedVoluntaryExit (112 B) 1.6990 us/op 1.8440 us/op 0.92
copy serialized SignedVoluntaryExit (112 B) 1.4660 us/op 1.4270 us/op 1.03
transfer serialized ProposerSlashing (416 B) 2.3190 us/op 1.8440 us/op 1.26
copy serialized ProposerSlashing (416 B) 1.7300 us/op 1.7500 us/op 0.99
transfer serialized Attestation (485 B) 2.0500 us/op 1.7450 us/op 1.17
copy serialized Attestation (485 B) 2.2690 us/op 2.2300 us/op 1.02
transfer serialized AttesterSlashing (33232 B) 2.3170 us/op 2.7210 us/op 0.85
copy serialized AttesterSlashing (33232 B) 6.5030 us/op 7.8510 us/op 0.83
transfer serialized Small SignedBeaconBlock (128000 B) 2.9660 us/op 3.1020 us/op 0.96
copy serialized Small SignedBeaconBlock (128000 B) 16.601 us/op 24.180 us/op 0.69
transfer serialized Avg SignedBeaconBlock (200000 B) 3.1270 us/op 3.6500 us/op 0.86
copy serialized Avg SignedBeaconBlock (200000 B) 22.501 us/op 44.365 us/op 0.51
transfer serialized BlobsSidecar (524380 B) 3.0280 us/op 4.4750 us/op 0.68
copy serialized BlobsSidecar (524380 B) 100.10 us/op 138.26 us/op 0.72
transfer serialized Big SignedBeaconBlock (1000000 B) 3.1490 us/op 5.6470 us/op 0.56
copy serialized Big SignedBeaconBlock (1000000 B) 153.46 us/op 249.85 us/op 0.61
pass gossip attestations to forkchoice per slot 3.1572 ms/op 3.3042 ms/op 0.96
forkChoice updateHead vc 100000 bc 64 eq 0 506.11 us/op 582.58 us/op 0.87
forkChoice updateHead vc 600000 bc 64 eq 0 3.2106 ms/op 3.4568 ms/op 0.93
forkChoice updateHead vc 1000000 bc 64 eq 0 5.4399 ms/op 5.7106 ms/op 0.95
forkChoice updateHead vc 600000 bc 320 eq 0 3.2537 ms/op 4.6082 ms/op 0.71
forkChoice updateHead vc 600000 bc 1200 eq 0 3.2374 ms/op 3.6533 ms/op 0.89
forkChoice updateHead vc 600000 bc 7200 eq 0 3.7294 ms/op 4.2997 ms/op 0.87
forkChoice updateHead vc 600000 bc 64 eq 1000 10.697 ms/op 11.009 ms/op 0.97
forkChoice updateHead vc 600000 bc 64 eq 10000 11.864 ms/op 12.938 ms/op 0.92
forkChoice updateHead vc 600000 bc 64 eq 300000 16.547 ms/op 17.917 ms/op 0.92
computeDeltas 500000 validators 300 proto nodes 3.7682 ms/op 4.0964 ms/op 0.92
computeDeltas 500000 validators 1200 proto nodes 3.9124 ms/op 3.9905 ms/op 0.98
computeDeltas 500000 validators 7200 proto nodes 3.8560 ms/op 3.8525 ms/op 1.00
computeDeltas 750000 validators 300 proto nodes 5.2580 ms/op 5.9319 ms/op 0.89
computeDeltas 750000 validators 1200 proto nodes 5.3600 ms/op 5.7302 ms/op 0.94
computeDeltas 750000 validators 7200 proto nodes 5.7252 ms/op 5.7518 ms/op 1.00
computeDeltas 1400000 validators 300 proto nodes 10.222 ms/op 10.096 ms/op 1.01
computeDeltas 1400000 validators 1200 proto nodes 10.046 ms/op 9.8390 ms/op 1.02
computeDeltas 1400000 validators 7200 proto nodes 10.612 ms/op 10.006 ms/op 1.06
computeDeltas 2100000 validators 300 proto nodes 15.862 ms/op 14.966 ms/op 1.06
computeDeltas 2100000 validators 1200 proto nodes 15.126 ms/op 14.979 ms/op 1.01
computeDeltas 2100000 validators 7200 proto nodes 14.816 ms/op 14.985 ms/op 0.99
altair processAttestation - 250000 vs - 7PWei normalcase 1.6684 ms/op 1.6404 ms/op 1.02
altair processAttestation - 250000 vs - 7PWei worstcase 2.4851 ms/op 2.5056 ms/op 0.99
altair processAttestation - setStatus - 1/6 committees join 95.446 us/op 88.506 us/op 1.08
altair processAttestation - setStatus - 1/3 committees join 182.79 us/op 181.92 us/op 1.00
altair processAttestation - setStatus - 1/2 committees join 266.24 us/op 250.03 us/op 1.06
altair processAttestation - setStatus - 2/3 committees join 324.68 us/op 327.37 us/op 0.99
altair processAttestation - setStatus - 4/5 committees join 476.50 us/op 525.04 us/op 0.91
altair processAttestation - setStatus - 100% committees join 556.27 us/op 583.48 us/op 0.95
altair processBlock - 250000 vs - 7PWei normalcase 4.9028 ms/op 4.0317 ms/op 1.22
altair processBlock - 250000 vs - 7PWei normalcase hashState 28.116 ms/op 25.199 ms/op 1.12
altair processBlock - 250000 vs - 7PWei worstcase 46.311 ms/op 39.963 ms/op 1.16
altair processBlock - 250000 vs - 7PWei worstcase hashState 100.84 ms/op 77.376 ms/op 1.30
phase0 processBlock - 250000 vs - 7PWei normalcase 2.3382 ms/op 2.0740 ms/op 1.13
phase0 processBlock - 250000 vs - 7PWei worstcase 26.360 ms/op 28.136 ms/op 0.94
altair processEth1Data - 250000 vs - 7PWei normalcase 307.90 us/op 351.31 us/op 0.88
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 8.0240 us/op 6.0930 us/op 1.32
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 30.343 us/op 24.792 us/op 1.22
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 8.9630 us/op 8.3790 us/op 1.07
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 9.2760 us/op 6.1260 us/op 1.51
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 114.85 us/op 100.26 us/op 1.15
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.0762 ms/op 767.00 us/op 1.40
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.5687 ms/op 958.36 us/op 1.64
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.7268 ms/op 878.08 us/op 1.97
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.4682 ms/op 4.3609 ms/op 0.57
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 3.0007 ms/op 1.7918 ms/op 1.67
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 3.6853 ms/op 3.9990 ms/op 0.92
Tree 40 250000 create 216.12 ms/op 235.56 ms/op 0.92
Tree 40 250000 get(125000) 140.12 ns/op 164.07 ns/op 0.85
Tree 40 250000 set(125000) 663.11 ns/op 867.80 ns/op 0.76
Tree 40 250000 toArray() 16.008 ms/op 20.041 ms/op 0.80
Tree 40 250000 iterate all - toArray() + loop 15.819 ms/op 18.759 ms/op 0.84
Tree 40 250000 iterate all - get(i) 52.326 ms/op 56.929 ms/op 0.92
MutableVector 250000 create 14.200 ms/op 9.1469 ms/op 1.55
MutableVector 250000 get(125000) 6.0860 ns/op 10.920 ns/op 0.56
MutableVector 250000 set(125000) 186.48 ns/op 252.33 ns/op 0.74
MutableVector 250000 toArray() 3.3739 ms/op 4.8450 ms/op 0.70
MutableVector 250000 iterate all - toArray() + loop 3.6099 ms/op 4.3867 ms/op 0.82
MutableVector 250000 iterate all - get(i) 1.5372 ms/op 1.6994 ms/op 0.90
Array 250000 create 3.0059 ms/op 4.3335 ms/op 0.69
Array 250000 clone - spread 1.4477 ms/op 2.0192 ms/op 0.72
Array 250000 get(125000) 0.40700 ns/op 0.45200 ns/op 0.90
Array 250000 set(125000) 0.43000 ns/op 0.51500 ns/op 0.83
Array 250000 iterate all - loop 107.37 us/op 111.97 us/op 0.96
effectiveBalanceIncrements clone Uint8Array 300000 36.687 us/op 58.386 us/op 0.63
effectiveBalanceIncrements clone MutableVector 300000 123.00 ns/op 132.00 ns/op 0.93
effectiveBalanceIncrements rw all Uint8Array 300000 199.16 us/op 219.09 us/op 0.91
effectiveBalanceIncrements rw all MutableVector 300000 66.608 ms/op 101.70 ms/op 0.65
phase0 afterProcessEpoch - 250000 vs - 7PWei 88.646 ms/op 96.806 ms/op 0.92
phase0 beforeProcessEpoch - 250000 vs - 7PWei 42.845 ms/op 42.447 ms/op 1.01
altair processEpoch - mainnet_e81889 377.84 ms/op 477.56 ms/op 0.79
mainnet_e81889 - altair beforeProcessEpoch 68.177 ms/op 89.105 ms/op 0.77
mainnet_e81889 - altair processJustificationAndFinalization 20.696 us/op 22.047 us/op 0.94
mainnet_e81889 - altair processInactivityUpdates 6.0787 ms/op 8.8231 ms/op 0.69
mainnet_e81889 - altair processRewardsAndPenalties 64.350 ms/op 48.824 ms/op 1.32
mainnet_e81889 - altair processRegistryUpdates 3.3720 us/op 2.6400 us/op 1.28
mainnet_e81889 - altair processSlashings 693.00 ns/op 685.00 ns/op 1.01
mainnet_e81889 - altair processEth1DataReset 534.00 ns/op 571.00 ns/op 0.94
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.9192 ms/op 2.0872 ms/op 1.40
mainnet_e81889 - altair processSlashingsReset 6.6160 us/op 4.5410 us/op 1.46
mainnet_e81889 - altair processRandaoMixesReset 6.2970 us/op 8.8050 us/op 0.72
mainnet_e81889 - altair processHistoricalRootsUpdate 743.00 ns/op 1.0080 us/op 0.74
mainnet_e81889 - altair processParticipationFlagUpdates 2.0470 us/op 3.1140 us/op 0.66
mainnet_e81889 - altair processSyncCommitteeUpdates 623.00 ns/op 668.00 ns/op 0.93
mainnet_e81889 - altair afterProcessEpoch 92.991 ms/op 99.914 ms/op 0.93
capella processEpoch - mainnet_e217614 1.3277 s/op 1.7186 s/op 0.77
mainnet_e217614 - capella beforeProcessEpoch 267.23 ms/op 320.71 ms/op 0.83
mainnet_e217614 - capella processJustificationAndFinalization 21.305 us/op 19.356 us/op 1.10
mainnet_e217614 - capella processInactivityUpdates 20.010 ms/op 24.403 ms/op 0.82
mainnet_e217614 - capella processRewardsAndPenalties 258.07 ms/op 256.43 ms/op 1.01
mainnet_e217614 - capella processRegistryUpdates 12.779 us/op 19.123 us/op 0.67
mainnet_e217614 - capella processSlashings 581.00 ns/op 1.5890 us/op 0.37
mainnet_e217614 - capella processEth1DataReset 367.00 ns/op 775.00 ns/op 0.47
mainnet_e217614 - capella processEffectiveBalanceUpdates 15.275 ms/op 5.7888 ms/op 2.64
mainnet_e217614 - capella processSlashingsReset 3.0620 us/op 7.5690 us/op 0.40
mainnet_e217614 - capella processRandaoMixesReset 3.9830 us/op 6.9280 us/op 0.57
mainnet_e217614 - capella processHistoricalRootsUpdate 1.0760 us/op 1.6190 us/op 0.66
mainnet_e217614 - capella processParticipationFlagUpdates 1.5930 us/op 4.4860 us/op 0.36
mainnet_e217614 - capella afterProcessEpoch 245.57 ms/op 306.33 ms/op 0.80
phase0 processEpoch - mainnet_e58758 355.76 ms/op 397.27 ms/op 0.90
mainnet_e58758 - phase0 beforeProcessEpoch 110.12 ms/op 107.96 ms/op 1.02
mainnet_e58758 - phase0 processJustificationAndFinalization 13.855 us/op 17.404 us/op 0.80
mainnet_e58758 - phase0 processRewardsAndPenalties 33.448 ms/op 33.188 ms/op 1.01
mainnet_e58758 - phase0 processRegistryUpdates 10.024 us/op 10.429 us/op 0.96
mainnet_e58758 - phase0 processSlashings 353.00 ns/op 603.00 ns/op 0.59
mainnet_e58758 - phase0 processEth1DataReset 324.00 ns/op 628.00 ns/op 0.52
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.6763 ms/op 1.0784 ms/op 1.55
mainnet_e58758 - phase0 processSlashingsReset 3.8030 us/op 4.9500 us/op 0.77
mainnet_e58758 - phase0 processRandaoMixesReset 6.3960 us/op 9.1900 us/op 0.70
mainnet_e58758 - phase0 processHistoricalRootsUpdate 445.00 ns/op 945.00 ns/op 0.47
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.9830 us/op 6.4710 us/op 0.62
mainnet_e58758 - phase0 afterProcessEpoch 77.163 ms/op 84.891 ms/op 0.91
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.0156 ms/op 1.3655 ms/op 1.48
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 3.4339 ms/op 2.9970 ms/op 1.15
altair processInactivityUpdates - 250000 normalcase 22.500 ms/op 22.467 ms/op 1.00
altair processInactivityUpdates - 250000 worstcase 22.722 ms/op 22.848 ms/op 0.99
phase0 processRegistryUpdates - 250000 normalcase 8.8410 us/op 13.151 us/op 0.67
phase0 processRegistryUpdates - 250000 badcase_full_deposits 464.10 us/op 436.04 us/op 1.06
phase0 processRegistryUpdates - 250000 worstcase 0.5 120.53 ms/op 151.18 ms/op 0.80
altair processRewardsAndPenalties - 250000 normalcase 44.865 ms/op 64.564 ms/op 0.69
altair processRewardsAndPenalties - 250000 worstcase 36.806 ms/op 54.820 ms/op 0.67
phase0 getAttestationDeltas - 250000 normalcase 7.2156 ms/op 14.902 ms/op 0.48
phase0 getAttestationDeltas - 250000 worstcase 7.4480 ms/op 13.349 ms/op 0.56
phase0 processSlashings - 250000 worstcase 92.296 us/op 120.68 us/op 0.76
altair processSyncCommitteeUpdates - 250000 124.33 ms/op 150.95 ms/op 0.82
BeaconState.hashTreeRoot - No change 271.00 ns/op 603.00 ns/op 0.45
BeaconState.hashTreeRoot - 1 full validator 111.46 us/op 158.92 us/op 0.70
BeaconState.hashTreeRoot - 32 full validator 1.3410 ms/op 1.4620 ms/op 0.92
BeaconState.hashTreeRoot - 512 full validator 13.263 ms/op 17.627 ms/op 0.75
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 164.44 us/op 195.66 us/op 0.84
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.0607 ms/op 2.8065 ms/op 0.73
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 26.370 ms/op 32.079 ms/op 0.82
BeaconState.hashTreeRoot - 1 balances 123.43 us/op 131.64 us/op 0.94
BeaconState.hashTreeRoot - 32 balances 1.3098 ms/op 1.3439 ms/op 0.97
BeaconState.hashTreeRoot - 512 balances 12.206 ms/op 13.207 ms/op 0.92
BeaconState.hashTreeRoot - 250000 balances 181.49 ms/op 236.27 ms/op 0.77
aggregationBits - 2048 els - zipIndexesInBitList 24.431 us/op 39.363 us/op 0.62
byteArrayEquals 32 54.121 ns/op 58.803 ns/op 0.92
Buffer.compare 32 45.578 ns/op 48.388 ns/op 0.94
byteArrayEquals 1024 1.5828 us/op 1.6456 us/op 0.96
Buffer.compare 1024 54.055 ns/op 58.262 ns/op 0.93
byteArrayEquals 16384 25.301 us/op 26.283 us/op 0.96
Buffer.compare 16384 242.06 ns/op 268.42 ns/op 0.90
byteArrayEquals 123687377 187.66 ms/op 226.89 ms/op 0.83
Buffer.compare 123687377 6.1613 ms/op 11.892 ms/op 0.52
byteArrayEquals 32 - diff last byte 51.642 ns/op 58.409 ns/op 0.88
Buffer.compare 32 - diff last byte 45.420 ns/op 50.817 ns/op 0.89
byteArrayEquals 1024 - diff last byte 1.5571 us/op 1.7073 us/op 0.91
Buffer.compare 1024 - diff last byte 54.836 ns/op 58.641 ns/op 0.94
byteArrayEquals 16384 - diff last byte 24.824 us/op 27.063 us/op 0.92
Buffer.compare 16384 - diff last byte 223.76 ns/op 261.07 ns/op 0.86
byteArrayEquals 123687377 - diff last byte 187.94 ms/op 214.41 ms/op 0.88
Buffer.compare 123687377 - diff last byte 6.7728 ms/op 13.487 ms/op 0.50
byteArrayEquals 32 - random bytes 5.2170 ns/op 5.9410 ns/op 0.88
Buffer.compare 32 - random bytes 48.604 ns/op 53.441 ns/op 0.91
byteArrayEquals 1024 - random bytes 5.2180 ns/op 5.9700 ns/op 0.87
Buffer.compare 1024 - random bytes 46.584 ns/op 60.800 ns/op 0.77
byteArrayEquals 16384 - random bytes 5.1620 ns/op 6.0700 ns/op 0.85
Buffer.compare 16384 - random bytes 46.402 ns/op 53.830 ns/op 0.86
byteArrayEquals 123687377 - random bytes 6.4500 ns/op 7.5600 ns/op 0.85
Buffer.compare 123687377 - random bytes 48.780 ns/op 54.190 ns/op 0.90
regular array get 100000 times 34.281 us/op 37.348 us/op 0.92
wrappedArray get 100000 times 40.841 us/op 48.241 us/op 0.85
arrayWithProxy get 100000 times 12.141 ms/op 17.943 ms/op 0.68
ssz.Root.equals 44.412 ns/op 52.741 ns/op 0.84
byteArrayEquals 43.692 ns/op 55.176 ns/op 0.79
Buffer.compare 10.265 ns/op 11.844 ns/op 0.87
shuffle list - 16384 els 6.1929 ms/op 7.8382 ms/op 0.79
shuffle list - 250000 els 92.227 ms/op 115.97 ms/op 0.80
processSlot - 1 slots 12.479 us/op 25.532 us/op 0.49
processSlot - 32 slots 3.4035 ms/op 3.9127 ms/op 0.87
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 41.866 ms/op 46.457 ms/op 0.90
getCommitteeAssignments - req 1 vs - 250000 vc 2.1098 ms/op 2.4823 ms/op 0.85
getCommitteeAssignments - req 100 vs - 250000 vc 4.0493 ms/op 4.6781 ms/op 0.87
getCommitteeAssignments - req 1000 vs - 250000 vc 4.4098 ms/op 4.9957 ms/op 0.88
findModifiedValidators - 10000 modified validators 260.82 ms/op 512.12 ms/op 0.51
findModifiedValidators - 1000 modified validators 165.84 ms/op 378.99 ms/op 0.44
findModifiedValidators - 100 modified validators 176.73 ms/op 348.04 ms/op 0.51
findModifiedValidators - 10 modified validators 173.28 ms/op 315.46 ms/op 0.55
findModifiedValidators - 1 modified validators 164.37 ms/op 273.79 ms/op 0.60
findModifiedValidators - no difference 157.83 ms/op 237.82 ms/op 0.66
compare ViewDUs 3.2415 s/op 5.0038 s/op 0.65
compare each validator Uint8Array 1.5532 s/op 2.4221 s/op 0.64
compare ViewDU to Uint8Array 1.0436 s/op 1.6269 s/op 0.64
migrate state 1000000 validators, 24 modified, 0 new 577.42 ms/op 781.14 ms/op 0.74
migrate state 1000000 validators, 1700 modified, 1000 new 808.80 ms/op 1.0334 s/op 0.78
migrate state 1000000 validators, 3400 modified, 2000 new 1.0144 s/op 1.2094 s/op 0.84
migrate state 1500000 validators, 24 modified, 0 new 605.69 ms/op 798.17 ms/op 0.76
migrate state 1500000 validators, 1700 modified, 1000 new 828.66 ms/op 1.1303 s/op 0.73
migrate state 1500000 validators, 3400 modified, 2000 new 1.0338 s/op 1.4044 s/op 0.74
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.6700 ns/op 5.9300 ns/op 0.79
state getBlockRootAtSlot - 250000 vs - 7PWei 626.04 ns/op 797.43 ns/op 0.79
computeProposers - vc 250000 7.3713 ms/op 10.358 ms/op 0.71
computeEpochShuffling - vc 250000 93.860 ms/op 108.98 ms/op 0.86
getNextSyncCommittee - vc 250000 126.02 ms/op 150.23 ms/op 0.84
computeSigningRoot for AttestationData 20.595 us/op 33.375 us/op 0.62
hash AttestationData serialized data then Buffer.toString(base64) 1.5510 us/op 1.9061 us/op 0.81
toHexString serialized data 935.61 ns/op 1.6010 us/op 0.58
Buffer.toString(base64) 176.79 ns/op 267.53 ns/op 0.66

by benchmarkbot/action

Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

sorry i don't materially see what this PR solves which the other PR didn't.

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.75%. Comparing base (f29a6db) to head (7124377).
Report is 1 commits behind head on unstable.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #6891   +/-   ##
=========================================
  Coverage     62.75%   62.75%           
=========================================
  Files           578      578           
  Lines         61347    61345    -2     
  Branches       2114     2124   +10     
=========================================
  Hits          38498    38498           
+ Misses        22811    22809    -2     
  Partials         38       38           

@nflaig
Copy link
Member Author

nflaig commented Jun 17, 2024

sorry i don't materially see what this PR solves which the other PR didn't.

The other PR returns an empty array if there is an error, if the upstream caller does not have a handler attached this results in no error, and wrongly returns no (new) indices.

This can have unwanted side-effects e.g. in doppelganger protection (see #6888 (comment))

// Attempt to collect missing indexes
const newIndices = await this.indicesService.pollValidatorIndices(pubkeysToCheckWithoutIndex);

We can apply these minimal changes on your PR, I don't mind either way, just opened a new PR as it seemed simpler

@g11tech
Copy link
Contributor

g11tech commented Jun 17, 2024

sorry i don't materially see what this PR solves which the other PR didn't.

The other PR returns an empty array if there is an error, if the upstream caller does not have a handler attached this results in no error, and wrongly returns no (new) indices.

  1. there was a log warn for that. also the call flow should proceed further even if indices are not discorvered so that call flow can do what it wants to do will already discovered indices.

  2. your solution doesn't solve unrejected exception see the inline comment

@nflaig
Copy link
Member Author

nflaig commented Jun 17, 2024

also the call flow should proceed further even if indices are not discorvered so that call flow can do what it wants to do will already discovered indices.

This is dangerous in some cases, e.g. doppelganger protection service. The contract of pollValidatorIndices is to return newly discovered validator indicies, and not pretend there are no new indices due to an error.

There are different upstream consumers on this which needs to handle it in different way

e.g. when polling beacon proposer, we catch and log the error, and continue as it's not critical for this code path that the request succeeds

await validatorStore.pollValidatorIndices().catch((e: Error) => {
logger.error("Error on pollValidatorIndices for prepareBeaconProposer", {epoch}, e);
});

but we have a case where it is important that the code does not proceed

const newIndices = await this.indicesService.pollValidatorIndices(pubkeysToCheckWithoutIndex);

it's important that we throw here and not return an empty array [] in the worst case, this could get someone slashed due to double attestation vote if their state validator request fails for some reason.

it's just not the responsibility of pollValidatorIndices to decide what do to with the error if encounter any, most likey due to failing getStateValidators request

your solution doesn't solve unrejected exception see the inline comment

it does, the uncaught exception was due to a floating promise, we accidentally created by not handling the return value of finally which creates another promise, chaining the operation fixes this on your branch and this branch.

Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

ok i see that at other places pollValidatorIndices has been caught and handled, however this is a "harmless" service.

lets say you have 100 batches which you polled and 1 batch always error out of 100 (lets say you got a bad BN), you will never do any duty as the entire poll is invalidated.

We need to make sure that if we can go forward with remaining keys for whatever duty/work/monitoring we should do it and not block other keys.

This goes for other duties as well and well require some more work. so i am approving the PR as of now as it does seem that it will handle uncaught rejection

@nflaig
Copy link
Member Author

nflaig commented Jun 17, 2024

however this is a "harmless" service.

yeah, sorry about confusing regarding doppelganger, our implementation is pretty robust and handles all cases well

lets say you have 100 batches which you polled and 1 batch always error out of 100 (lets say you got a bad BN), you will never do any duty as the entire poll is invalidated.

you mean specifically here because we have batches of 64 right now? I think we can kinda solve this by switching to postValidators which can send batches of like 10k validators which essentially would be just one request, see issue #6831. Still need to review if all clients have implemented the API but seems like it.

@g11tech
Copy link
Contributor

g11tech commented Jun 17, 2024

which can send batches of like 10k validators which essentially wou

no no, small batches are good, but latency of batch size to number of batches needs to be optimized unless the apis are send in aprallel (whose concurrently also needs to be fixed)

for e.g. this.pollBeaconAttesters(epoch, this.validatorStore.getAllLocalIndices()).catch((e: Error) => {

here we send all indices, so we need to see if a setup has 1000 keys, what is the error rate/latency of batching this up etc

@nflaig
Copy link
Member Author

nflaig commented Jun 17, 2024

no no, small batches are good, but latency of batch size to number of batches needs to be optimized unless the apis are send in aprallel (whose concurrently also needs to be fixed)

really not sure if small batches are good here, we have to apply same filtering on the beacon node side for each request, this seems really inefficient to me, a single request would reduce the work on the BN side by a lot. One problem with this endpoint is definitely the lack of ssz-serialization, there is some work in progess on the spec side.

here we send all indices, so we need to see if a setup has 1000 keys, what is the error rate/latency of batching this up etc

Right now, this is all done at startup, even if you have 10k keys, it spams the beacon node but it usually works out fine and after that you only poll undiscovered keys, so unless there are a lot of keys imported that are unknown (to be discvered) it's not big deal, I've never seen an error on any of my nodes due to this api.

A lot of client (like LH) poll this API every epoch for all pubkeys because they keep track for validator statuses over time, even that seems fine to me but we need to get rid of these 64 chunked requests which are all executed in sequence and parallel might be DoS on the beacon node.

@g11tech
Copy link
Contributor

g11tech commented Jun 17, 2024

really not sure if small batches are good here, we have to apply same filtering on the beacon node side for each request, this seems really inefficient to me, a single request would reduce the work on the BN side by a lot. One problem with this endpoint is definitely the lack of ssz-serialization, there is some work in progess on the spec side.

yes, we need to empirically see whats what.

Right now, this is all done at startup, even if you have 10k keys, it spams the beacon node but it usually works out fine and after that you only poll undiscovered keys, so unless there are a lot of keys imported that are unknown (to be discvered) it's not big deal, I've never seen an error on any of my nodes due to this api.

pollBeaconAttesters is done every epoch i think

I am bringing this up because our error rate is hight on obol dvt setups so whatever is the reason someone needs to dig it up and make changes

@nflaig
Copy link
Member Author

nflaig commented Jun 17, 2024

pollBeaconAttesters is done every epoch i think

yeah, what I meant is we only poll for pubkeys we haven't discovered yet, so unless there are tons of pending pubkeys should be just one request as it's 64 per batch, or none at all. If I look at my metrics, there are no getStateValidator requests at all in the last 24h.

const pubkeysHexToDiscover = pubkeysHex.filter((pubkey) => !this.pubkey2index.has(pubkey));
if (pubkeysHexToDiscover.length === 0) {
return [];
}

I am bringing this up because our error rate is hight on obol dvt setups so whatever is the reason someone needs to dig it up and make changes

we need to have a proper testing setup for this, let's discuss on discord

@nflaig nflaig merged commit 89ab742 into unstable Jun 18, 2024
20 checks passed
@nflaig nflaig deleted the nflaig/fix-pollValidatorIndices branch June 18, 2024 13:37
@wemeetagain
Copy link
Member

🎉 This PR is included in v1.20.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants