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: ensure transferred ArrayBuffer are Transferable #6251

Closed
wants to merge 2 commits into from

Conversation

jeluard
Copy link
Contributor

@jeluard jeluard commented Jan 4, 2024

Motivation

test:unit do not pass on nodejs starting version 21 due to a change in ArrayBuffer transferability

 FAIL  test/unit/validator/decryptKeystoreDefinitions.test.ts > decryptKeystoreDefinitions > with keystore cache > decrypt keystores
 FAIL  test/unit/validator/decryptKeystoreDefinitions.test.ts > decryptKeystoreDefinitions > with keystore cache > decrypt keystores if lockfiles already exist if ignoreLockFile=true
 FAIL  test/unit/validator/decryptKeystoreDefinitions.test.ts > decryptKeystoreDefinitions > without keystore cache > decrypt keystores if lockfiles already exist if ignoreLockFile=true
Error: Multiple errors importing keystores

keystore_0.json: Cannot transfer object of unsupported type.
keystore_1.json: Cannot transfer object of unsupported type.

Description

Node version 21 introduces changes to the way ArrayBuffer transferability are dealt with. Specifically some of current usage now is not transferable anymore and breaks usage.
To deal with this, a new API has been introduced in node 21 to detect if an object has been marked as not transferable. This API is used (when available) to do a copy of the underlying buffer instead of directly transferring it.
Performance in this case is still assumed to be better than going through full (de)/serialization.

@jeluard jeluard requested a review from a team as a code owner January 4, 2024 15:13
Copy link

codecov bot commented Jan 4, 2024

Codecov Report

Merging #6251 (0b2efd1) into unstable (9262064) will not change coverage.
Report is 1 commits behind head on unstable.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #6251   +/-   ##
=========================================
  Coverage     80.31%   80.31%           
=========================================
  Files           202      202           
  Lines         19543    19543           
  Branches       1169     1169           
=========================================
  Hits          15695    15695           
  Misses         3820     3820           
  Partials         28       28           

Copy link
Contributor

github-actions bot commented Jan 4, 2024

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: e24bd6c Previous: b92ff14 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 739.15 us/op 811.23 us/op 0.91
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 149.14 us/op 96.417 us/op 1.55
BLS verify - blst-native 1.3550 ms/op 1.3615 ms/op 1.00
BLS verifyMultipleSignatures 3 - blst-native 2.8798 ms/op 2.7749 ms/op 1.04
BLS verifyMultipleSignatures 8 - blst-native 6.4798 ms/op 6.0845 ms/op 1.06
BLS verifyMultipleSignatures 32 - blst-native 24.529 ms/op 22.798 ms/op 1.08
BLS verifyMultipleSignatures 64 - blst-native 46.359 ms/op 43.715 ms/op 1.06
BLS verifyMultipleSignatures 128 - blst-native 92.014 ms/op 86.817 ms/op 1.06
BLS deserializing 10000 signatures 928.61 ms/op 944.84 ms/op 0.98
BLS deserializing 100000 signatures 8.9694 s/op 9.3795 s/op 0.96
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.4130 ms/op 1.3424 ms/op 1.05
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.5562 ms/op 1.4593 ms/op 1.07
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.3711 ms/op 2.2531 ms/op 1.05
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.5267 ms/op 4.4840 ms/op 0.79
BLS verifyMultipleSignatures - same message - 128 - blst-native 5.7288 ms/op 5.6847 ms/op 1.01
BLS aggregatePubkeys 32 - blst-native 27.225 us/op 25.706 us/op 1.06
BLS aggregatePubkeys 128 - blst-native 103.31 us/op 99.719 us/op 1.04
getAttestationsForBlock 58.029 ms/op 41.922 ms/op 1.38
getSlashingsAndExits - default max 191.14 us/op 158.98 us/op 1.20
getSlashingsAndExits - 2k 457.04 us/op 370.52 us/op 1.23
proposeBlockBody type=full, size=empty 6.8560 ms/op 4.9690 ms/op 1.38
isKnown best case - 1 super set check 652.00 ns/op 315.00 ns/op 2.07
isKnown normal case - 2 super set checks 646.00 ns/op 304.00 ns/op 2.13
isKnown worse case - 16 super set checks 638.00 ns/op 300.00 ns/op 2.13
CheckpointStateCache - add get delete 6.7990 us/op 4.9560 us/op 1.37
validate api signedAggregateAndProof - struct 2.8793 ms/op 2.7248 ms/op 1.06
validate gossip signedAggregateAndProof - struct 2.8723 ms/op 2.7198 ms/op 1.06
validate gossip attestation - vc 640000 1.4023 ms/op 1.3265 ms/op 1.06
batch validate gossip attestation - vc 640000 - chunk 32 170.57 us/op 157.33 us/op 1.08
batch validate gossip attestation - vc 640000 - chunk 64 156.93 us/op 138.14 us/op 1.14
batch validate gossip attestation - vc 640000 - chunk 128 152.09 us/op 134.17 us/op 1.13
batch validate gossip attestation - vc 640000 - chunk 256 142.89 us/op 125.90 us/op 1.13
pickEth1Vote - no votes 1.5281 ms/op 1.1848 ms/op 1.29
pickEth1Vote - max votes 11.869 ms/op 10.496 ms/op 1.13
pickEth1Vote - Eth1Data hashTreeRoot value x2048 20.125 ms/op 21.569 ms/op 0.93
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 35.700 ms/op 27.369 ms/op 1.30
pickEth1Vote - Eth1Data fastSerialize value x2048 746.08 us/op 600.11 us/op 1.24
pickEth1Vote - Eth1Data fastSerialize tree x2048 6.1470 ms/op 7.4428 ms/op 0.83
bytes32 toHexString 655.00 ns/op 497.00 ns/op 1.32
bytes32 Buffer.toString(hex) 320.00 ns/op 279.00 ns/op 1.15
bytes32 Buffer.toString(hex) from Uint8Array 552.00 ns/op 406.00 ns/op 1.36
bytes32 Buffer.toString(hex) + 0x 320.00 ns/op 275.00 ns/op 1.16
Object access 1 prop 0.21300 ns/op 0.14800 ns/op 1.44
Map access 1 prop 0.15500 ns/op 0.13600 ns/op 1.14
Object get x1000 7.6070 ns/op 7.4000 ns/op 1.03
Map get x1000 0.86400 ns/op 0.75400 ns/op 1.15
Object set x1000 71.600 ns/op 51.166 ns/op 1.40
Map set x1000 49.520 ns/op 38.568 ns/op 1.28
Return object 10000 times 0.26090 ns/op 0.23300 ns/op 1.12
Throw Error 10000 times 4.3051 us/op 3.8298 us/op 1.12
fastMsgIdFn sha256 / 200 bytes 3.5270 us/op 3.2270 us/op 1.09
fastMsgIdFn h32 xxhash / 200 bytes 343.00 ns/op 271.00 ns/op 1.27
fastMsgIdFn h64 xxhash / 200 bytes 380.00 ns/op 335.00 ns/op 1.13
fastMsgIdFn sha256 / 1000 bytes 11.839 us/op 11.142 us/op 1.06
fastMsgIdFn h32 xxhash / 1000 bytes 468.00 ns/op 392.00 ns/op 1.19
fastMsgIdFn h64 xxhash / 1000 bytes 458.00 ns/op 402.00 ns/op 1.14
fastMsgIdFn sha256 / 10000 bytes 106.03 us/op 102.11 us/op 1.04
fastMsgIdFn h32 xxhash / 10000 bytes 2.0460 us/op 1.9130 us/op 1.07
fastMsgIdFn h64 xxhash / 10000 bytes 1.3850 us/op 1.3060 us/op 1.06
send data - 1000 256B messages 21.489 ms/op 18.569 ms/op 1.16
send data - 1000 512B messages 29.149 ms/op 25.403 ms/op 1.15
send data - 1000 1024B messages 43.521 ms/op 39.606 ms/op 1.10
send data - 1000 1200B messages 27.602 ms/op 34.816 ms/op 0.79
send data - 1000 2048B messages 47.352 ms/op 42.405 ms/op 1.12
send data - 1000 4096B messages 45.370 ms/op 40.603 ms/op 1.12
send data - 1000 16384B messages 121.22 ms/op 110.19 ms/op 1.10
send data - 1000 65536B messages 528.05 ms/op 501.32 ms/op 1.05
enrSubnets - fastDeserialize 64 bits 1.4160 us/op 1.3520 us/op 1.05
enrSubnets - ssz BitVector 64 bits 521.00 ns/op 446.00 ns/op 1.17
enrSubnets - fastDeserialize 4 bits 213.00 ns/op 166.00 ns/op 1.28
enrSubnets - ssz BitVector 4 bits 506.00 ns/op 427.00 ns/op 1.19
prioritizePeers score -10:0 att 32-0.1 sync 2-0 118.66 us/op 107.04 us/op 1.11
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 151.75 us/op 144.46 us/op 1.05
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 204.51 us/op 167.59 us/op 1.22
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 387.52 us/op 286.74 us/op 1.35
prioritizePeers score 0:0 att 64-1 sync 4-1 400.23 us/op 341.35 us/op 1.17
array of 16000 items push then shift 1.7739 us/op 1.6471 us/op 1.08
LinkedList of 16000 items push then shift 9.7780 ns/op 9.1890 ns/op 1.06
array of 16000 items push then pop 118.69 ns/op 93.437 ns/op 1.27
LinkedList of 16000 items push then pop 9.2850 ns/op 9.0700 ns/op 1.02
array of 24000 items push then shift 2.6421 us/op 2.4752 us/op 1.07
LinkedList of 24000 items push then shift 9.8960 ns/op 9.1300 ns/op 1.08
array of 24000 items push then pop 163.36 ns/op 116.12 ns/op 1.41
LinkedList of 24000 items push then pop 9.9730 ns/op 8.9910 ns/op 1.11
intersect bitArray bitLen 8 7.1060 ns/op 6.6550 ns/op 1.07
intersect array and set length 8 105.94 ns/op 66.080 ns/op 1.60
intersect bitArray bitLen 128 36.476 ns/op 35.302 ns/op 1.03
intersect array and set length 128 1.1682 us/op 895.41 ns/op 1.30
bitArray.getTrueBitIndexes() bitLen 128 2.0130 us/op 1.5390 us/op 1.31
bitArray.getTrueBitIndexes() bitLen 248 3.5160 us/op 2.5160 us/op 1.40
bitArray.getTrueBitIndexes() bitLen 512 6.9650 us/op 5.0960 us/op 1.37
Buffer.concat 32 items 1.2800 us/op 1.0140 us/op 1.26
Uint8Array.set 32 items 2.6150 us/op 1.9460 us/op 1.34
Set add up to 64 items then delete first 5.0758 us/op 4.4991 us/op 1.13
OrderedSet add up to 64 items then delete first 6.3175 us/op 5.6190 us/op 1.12
Set add up to 64 items then delete last 5.4801 us/op 4.7886 us/op 1.14
OrderedSet add up to 64 items then delete last 7.7018 us/op 5.8514 us/op 1.32
Set add up to 64 items then delete middle 5.4685 us/op 4.5690 us/op 1.20
OrderedSet add up to 64 items then delete middle 8.8306 us/op 7.1061 us/op 1.24
Set add up to 128 items then delete first 11.032 us/op 9.4065 us/op 1.17
OrderedSet add up to 128 items then delete first 14.332 us/op 12.699 us/op 1.13
Set add up to 128 items then delete last 10.924 us/op 9.4386 us/op 1.16
OrderedSet add up to 128 items then delete last 15.297 us/op 11.580 us/op 1.32
Set add up to 128 items then delete middle 10.918 us/op 9.0854 us/op 1.20
OrderedSet add up to 128 items then delete middle 21.266 us/op 16.894 us/op 1.26
Set add up to 256 items then delete first 22.068 us/op 18.775 us/op 1.18
OrderedSet add up to 256 items then delete first 29.357 us/op 25.469 us/op 1.15
Set add up to 256 items then delete last 22.075 us/op 18.556 us/op 1.19
OrderedSet add up to 256 items then delete last 30.838 us/op 23.237 us/op 1.33
Set add up to 256 items then delete middle 21.587 us/op 18.915 us/op 1.14
OrderedSet add up to 256 items then delete middle 52.903 us/op 45.251 us/op 1.17
transfer serialized Status (84 B) 2.1550 us/op 1.7480 us/op 1.23
copy serialized Status (84 B) 1.9300 us/op 1.4580 us/op 1.32
transfer serialized SignedVoluntaryExit (112 B) 2.2820 us/op 1.8750 us/op 1.22
copy serialized SignedVoluntaryExit (112 B) 1.9500 us/op 1.5350 us/op 1.27
transfer serialized ProposerSlashing (416 B) 3.6420 us/op 1.9970 us/op 1.82
copy serialized ProposerSlashing (416 B) 3.7350 us/op 1.7300 us/op 2.16
transfer serialized Attestation (485 B) 3.7260 us/op 2.3740 us/op 1.57
copy serialized Attestation (485 B) 3.6530 us/op 2.0120 us/op 1.82
transfer serialized AttesterSlashing (33232 B) 3.5210 us/op 2.3180 us/op 1.52
copy serialized AttesterSlashing (33232 B) 7.8180 us/op 5.6870 us/op 1.37
transfer serialized Small SignedBeaconBlock (128000 B) 3.0260 us/op 2.8420 us/op 1.06
copy serialized Small SignedBeaconBlock (128000 B) 23.698 us/op 14.654 us/op 1.62
transfer serialized Avg SignedBeaconBlock (200000 B) 3.5700 us/op 3.2980 us/op 1.08
copy serialized Avg SignedBeaconBlock (200000 B) 40.578 us/op 21.135 us/op 1.92
transfer serialized BlobsSidecar (524380 B) 4.5170 us/op 3.2110 us/op 1.41
copy serialized BlobsSidecar (524380 B) 150.33 us/op 97.861 us/op 1.54
transfer serialized Big SignedBeaconBlock (1000000 B) 4.2990 us/op 3.3740 us/op 1.27
copy serialized Big SignedBeaconBlock (1000000 B) 201.31 us/op 172.99 us/op 1.16
pass gossip attestations to forkchoice per slot 4.8991 ms/op 4.5629 ms/op 1.07
forkChoice updateHead vc 100000 bc 64 eq 0 720.68 us/op 738.61 us/op 0.98
forkChoice updateHead vc 600000 bc 64 eq 0 4.7974 ms/op 4.5931 ms/op 1.04
forkChoice updateHead vc 1000000 bc 64 eq 0 8.9314 ms/op 7.4474 ms/op 1.20
forkChoice updateHead vc 600000 bc 320 eq 0 4.8282 ms/op 4.4440 ms/op 1.09
forkChoice updateHead vc 600000 bc 1200 eq 0 4.8370 ms/op 4.4554 ms/op 1.09
forkChoice updateHead vc 600000 bc 7200 eq 0 5.5965 ms/op 5.5052 ms/op 1.02
forkChoice updateHead vc 600000 bc 64 eq 1000 11.890 ms/op 11.742 ms/op 1.01
forkChoice updateHead vc 600000 bc 64 eq 10000 12.120 ms/op 12.377 ms/op 0.98
forkChoice updateHead vc 600000 bc 64 eq 300000 18.817 ms/op 15.779 ms/op 1.19
computeDeltas 500000 validators 300 proto nodes 7.3452 ms/op 6.6198 ms/op 1.11
computeDeltas 500000 validators 1200 proto nodes 7.0291 ms/op 6.6711 ms/op 1.05
computeDeltas 500000 validators 7200 proto nodes 6.9365 ms/op 6.4304 ms/op 1.08
computeDeltas 750000 validators 300 proto nodes 10.790 ms/op 9.9644 ms/op 1.08
computeDeltas 750000 validators 1200 proto nodes 11.161 ms/op 10.108 ms/op 1.10
computeDeltas 750000 validators 7200 proto nodes 11.019 ms/op 10.104 ms/op 1.09
computeDeltas 1400000 validators 300 proto nodes 21.440 ms/op 19.646 ms/op 1.09
computeDeltas 1400000 validators 1200 proto nodes 20.806 ms/op 19.448 ms/op 1.07
computeDeltas 1400000 validators 7200 proto nodes 20.337 ms/op 20.024 ms/op 1.02
computeDeltas 2100000 validators 300 proto nodes 31.065 ms/op 29.708 ms/op 1.05
computeDeltas 2100000 validators 1200 proto nodes 30.371 ms/op 29.515 ms/op 1.03
computeDeltas 2100000 validators 7200 proto nodes 30.009 ms/op 28.303 ms/op 1.06
computeProposerBoostScoreFromBalances 500000 validators 4.1285 ms/op 3.7500 ms/op 1.10
computeProposerBoostScoreFromBalances 750000 validators 3.8965 ms/op 4.0117 ms/op 0.97
computeProposerBoostScoreFromBalances 1400000 validators 3.9568 ms/op 4.0162 ms/op 0.99
computeProposerBoostScoreFromBalances 2100000 validators 3.9199 ms/op 3.8246 ms/op 1.02
altair processAttestation - 250000 vs - 7PWei normalcase 3.5442 ms/op 2.5620 ms/op 1.38
altair processAttestation - 250000 vs - 7PWei worstcase 4.7079 ms/op 3.6130 ms/op 1.30
altair processAttestation - setStatus - 1/6 committees join 162.33 us/op 153.97 us/op 1.05
altair processAttestation - setStatus - 1/3 committees join 308.03 us/op 288.85 us/op 1.07
altair processAttestation - setStatus - 1/2 committees join 425.68 us/op 394.20 us/op 1.08
altair processAttestation - setStatus - 2/3 committees join 520.27 us/op 503.40 us/op 1.03
altair processAttestation - setStatus - 4/5 committees join 741.56 us/op 692.12 us/op 1.07
altair processAttestation - setStatus - 100% committees join 935.05 us/op 799.16 us/op 1.17
altair processBlock - 250000 vs - 7PWei normalcase 14.494 ms/op 10.404 ms/op 1.39
altair processBlock - 250000 vs - 7PWei normalcase hashState 49.049 ms/op 36.938 ms/op 1.33
altair processBlock - 250000 vs - 7PWei worstcase 43.512 ms/op 41.491 ms/op 1.05
altair processBlock - 250000 vs - 7PWei worstcase hashState 127.02 ms/op 89.805 ms/op 1.41
phase0 processBlock - 250000 vs - 7PWei normalcase 3.5438 ms/op 2.4942 ms/op 1.42
phase0 processBlock - 250000 vs - 7PWei worstcase 37.820 ms/op 31.524 ms/op 1.20
altair processEth1Data - 250000 vs - 7PWei normalcase 732.85 us/op 562.51 us/op 1.30
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 23.934 us/op 10.059 us/op 2.38
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 74.626 us/op 51.404 us/op 1.45
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 36.312 us/op 20.656 us/op 1.76
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 23.333 us/op 8.7940 us/op 2.65
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 235.99 us/op 192.59 us/op 1.23
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.7393 ms/op 1.2918 ms/op 1.35
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.2898 ms/op 1.5660 ms/op 1.46
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 2.3558 ms/op 1.5771 ms/op 1.49
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.9999 ms/op 3.6380 ms/op 1.37
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 3.3839 ms/op 2.2938 ms/op 1.48
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 8.7366 ms/op 5.4119 ms/op 1.61
Tree 40 250000 create 776.54 ms/op 351.75 ms/op 2.21
Tree 40 250000 get(125000) 220.44 ns/op 195.94 ns/op 1.13
Tree 40 250000 set(125000) 3.2675 us/op 1.0389 us/op 3.15
Tree 40 250000 toArray() 27.975 ms/op 19.716 ms/op 1.42
Tree 40 250000 iterate all - toArray() + loop 36.526 ms/op 19.847 ms/op 1.84
Tree 40 250000 iterate all - get(i) 89.486 ms/op 67.517 ms/op 1.33
MutableVector 250000 create 19.416 ms/op 14.433 ms/op 1.35
MutableVector 250000 get(125000) 6.7470 ns/op 6.6500 ns/op 1.01
MutableVector 250000 set(125000) 603.34 ns/op 284.06 ns/op 2.12
MutableVector 250000 toArray() 4.8417 ms/op 3.1916 ms/op 1.52
MutableVector 250000 iterate all - toArray() + loop 5.5925 ms/op 3.3464 ms/op 1.67
MutableVector 250000 iterate all - get(i) 1.6374 ms/op 1.5375 ms/op 1.06
Array 250000 create 4.8403 ms/op 3.1447 ms/op 1.54
Array 250000 clone - spread 1.6545 ms/op 1.2492 ms/op 1.32
Array 250000 get(125000) 1.8300 ns/op 1.0500 ns/op 1.74
Array 250000 set(125000) 5.6460 ns/op 4.1210 ns/op 1.37
Array 250000 iterate all - loop 184.91 us/op 165.16 us/op 1.12
effectiveBalanceIncrements clone Uint8Array 300000 74.931 us/op 26.920 us/op 2.78
effectiveBalanceIncrements clone MutableVector 300000 445.00 ns/op 368.00 ns/op 1.21
effectiveBalanceIncrements rw all Uint8Array 300000 216.21 us/op 199.46 us/op 1.08
effectiveBalanceIncrements rw all MutableVector 300000 117.94 ms/op 83.267 ms/op 1.42
phase0 afterProcessEpoch - 250000 vs - 7PWei 122.01 ms/op 112.99 ms/op 1.08
phase0 beforeProcessEpoch - 250000 vs - 7PWei 64.779 ms/op 52.786 ms/op 1.23
altair processEpoch - mainnet_e81889 607.93 ms/op 483.47 ms/op 1.26
mainnet_e81889 - altair beforeProcessEpoch 95.843 ms/op 80.255 ms/op 1.19
mainnet_e81889 - altair processJustificationAndFinalization 22.697 us/op 15.020 us/op 1.51
mainnet_e81889 - altair processInactivityUpdates 8.3906 ms/op 6.0824 ms/op 1.38
mainnet_e81889 - altair processRewardsAndPenalties 46.361 ms/op 59.585 ms/op 0.78
mainnet_e81889 - altair processRegistryUpdates 2.6490 us/op 2.3620 us/op 1.12
mainnet_e81889 - altair processSlashings 735.00 ns/op 425.00 ns/op 1.73
mainnet_e81889 - altair processEth1DataReset 746.00 ns/op 487.00 ns/op 1.53
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.2832 ms/op 1.5816 ms/op 1.44
mainnet_e81889 - altair processSlashingsReset 4.4750 us/op 3.3860 us/op 1.32
mainnet_e81889 - altair processRandaoMixesReset 8.7440 us/op 5.0300 us/op 1.74
mainnet_e81889 - altair processHistoricalRootsUpdate 1.1010 us/op 892.00 ns/op 1.23
mainnet_e81889 - altair processParticipationFlagUpdates 2.8760 us/op 1.6230 us/op 1.77
mainnet_e81889 - altair processSyncCommitteeUpdates 652.00 ns/op 763.00 ns/op 0.85
mainnet_e81889 - altair afterProcessEpoch 126.43 ms/op 119.50 ms/op 1.06
capella processEpoch - mainnet_e217614 2.8086 s/op 2.0837 s/op 1.35
mainnet_e217614 - capella beforeProcessEpoch 547.62 ms/op 492.27 ms/op 1.11
mainnet_e217614 - capella processJustificationAndFinalization 19.900 us/op 15.649 us/op 1.27
mainnet_e217614 - capella processInactivityUpdates 24.899 ms/op 21.631 ms/op 1.15
mainnet_e217614 - capella processRewardsAndPenalties 542.58 ms/op 427.01 ms/op 1.27
mainnet_e217614 - capella processRegistryUpdates 38.541 us/op 19.467 us/op 1.98
mainnet_e217614 - capella processSlashings 1.2860 us/op 536.00 ns/op 2.40
mainnet_e217614 - capella processEth1DataReset 1.1810 us/op 351.00 ns/op 3.36
mainnet_e217614 - capella processEffectiveBalanceUpdates 6.6604 ms/op 4.8000 ms/op 1.39
mainnet_e217614 - capella processSlashingsReset 5.7010 us/op 2.9420 us/op 1.94
mainnet_e217614 - capella processRandaoMixesReset 12.244 us/op 5.0300 us/op 2.43
mainnet_e217614 - capella processHistoricalRootsUpdate 1.5260 us/op 532.00 ns/op 2.87
mainnet_e217614 - capella processParticipationFlagUpdates 3.7650 us/op 1.6040 us/op 2.35
mainnet_e217614 - capella afterProcessEpoch 340.89 ms/op 304.65 ms/op 1.12
phase0 processEpoch - mainnet_e58758 572.44 ms/op 444.70 ms/op 1.29
mainnet_e58758 - phase0 beforeProcessEpoch 192.15 ms/op 122.10 ms/op 1.57
mainnet_e58758 - phase0 processJustificationAndFinalization 28.463 us/op 16.170 us/op 1.76
mainnet_e58758 - phase0 processRewardsAndPenalties 69.418 ms/op 53.794 ms/op 1.29
mainnet_e58758 - phase0 processRegistryUpdates 23.588 us/op 12.406 us/op 1.90
mainnet_e58758 - phase0 processSlashings 2.0500 us/op 537.00 ns/op 3.82
mainnet_e58758 - phase0 processEth1DataReset 1.1980 us/op 373.00 ns/op 3.21
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.2060 ms/op 1.1142 ms/op 1.98
mainnet_e58758 - phase0 processSlashingsReset 8.3160 us/op 2.5400 us/op 3.27
mainnet_e58758 - phase0 processRandaoMixesReset 9.4440 us/op 3.9220 us/op 2.41
mainnet_e58758 - phase0 processHistoricalRootsUpdate 914.00 ns/op 367.00 ns/op 2.49
mainnet_e58758 - phase0 processParticipationRecordUpdates 8.6000 us/op 3.1390 us/op 2.74
mainnet_e58758 - phase0 afterProcessEpoch 105.27 ms/op 93.159 ms/op 1.13
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.2435 ms/op 1.3436 ms/op 1.67
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.0071 ms/op 1.4459 ms/op 1.39
altair processInactivityUpdates - 250000 normalcase 27.223 ms/op 27.163 ms/op 1.00
altair processInactivityUpdates - 250000 worstcase 30.925 ms/op 19.926 ms/op 1.55
phase0 processRegistryUpdates - 250000 normalcase 19.008 us/op 7.4760 us/op 2.54
phase0 processRegistryUpdates - 250000 badcase_full_deposits 548.32 us/op 332.16 us/op 1.65
phase0 processRegistryUpdates - 250000 worstcase 0.5 180.54 ms/op 134.29 ms/op 1.34
altair processRewardsAndPenalties - 250000 normalcase 61.077 ms/op 55.698 ms/op 1.10
altair processRewardsAndPenalties - 250000 worstcase 63.672 ms/op 54.534 ms/op 1.17
phase0 getAttestationDeltas - 250000 normalcase 12.500 ms/op 8.7347 ms/op 1.43
phase0 getAttestationDeltas - 250000 worstcase 14.178 ms/op 8.6841 ms/op 1.63
phase0 processSlashings - 250000 worstcase 138.73 us/op 79.338 us/op 1.75
altair processSyncCommitteeUpdates - 250000 208.06 ms/op 153.63 ms/op 1.35
BeaconState.hashTreeRoot - No change 367.00 ns/op 242.00 ns/op 1.52
BeaconState.hashTreeRoot - 1 full validator 205.12 us/op 156.50 us/op 1.31
BeaconState.hashTreeRoot - 32 full validator 2.3740 ms/op 1.7762 ms/op 1.34
BeaconState.hashTreeRoot - 512 full validator 22.693 ms/op 16.327 ms/op 1.39
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 220.52 us/op 157.77 us/op 1.40
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.6031 ms/op 2.0170 ms/op 1.29
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 34.582 ms/op 23.213 ms/op 1.49
BeaconState.hashTreeRoot - 1 balances 169.08 us/op 150.87 us/op 1.12
BeaconState.hashTreeRoot - 32 balances 1.7901 ms/op 1.2548 ms/op 1.43
BeaconState.hashTreeRoot - 512 balances 15.623 ms/op 13.519 ms/op 1.16
BeaconState.hashTreeRoot - 250000 balances 233.04 ms/op 208.07 ms/op 1.12
aggregationBits - 2048 els - zipIndexesInBitList 19.843 us/op 16.119 us/op 1.23
byteArrayEquals 32 78.039 ns/op 74.629 ns/op 1.05
Buffer.compare 32 57.280 ns/op 55.606 ns/op 1.03
byteArrayEquals 1024 2.1168 us/op 2.0393 us/op 1.04
Buffer.compare 1024 73.358 ns/op 71.501 ns/op 1.03
byteArrayEquals 16384 33.805 us/op 32.378 us/op 1.04
Buffer.compare 16384 282.42 ns/op 271.14 ns/op 1.04
byteArrayEquals 123687377 252.35 ms/op 245.04 ms/op 1.03
Buffer.compare 123687377 6.7838 ms/op 6.0524 ms/op 1.12
byteArrayEquals 32 - diff last byte 80.671 ns/op 72.096 ns/op 1.12
Buffer.compare 32 - diff last byte 58.903 ns/op 56.639 ns/op 1.04
byteArrayEquals 1024 - diff last byte 2.0876 us/op 2.0354 us/op 1.03
Buffer.compare 1024 - diff last byte 75.194 ns/op 72.259 ns/op 1.04
byteArrayEquals 16384 - diff last byte 33.293 us/op 32.437 us/op 1.03
Buffer.compare 16384 - diff last byte 277.33 ns/op 280.75 ns/op 0.99
byteArrayEquals 123687377 - diff last byte 273.77 ms/op 244.48 ms/op 1.12
Buffer.compare 123687377 - diff last byte 12.437 ms/op 6.1078 ms/op 2.04
byteArrayEquals 32 - random bytes 7.7100 ns/op 5.4690 ns/op 1.41
Buffer.compare 32 - random bytes 66.881 ns/op 61.333 ns/op 1.09
byteArrayEquals 1024 - random bytes 7.2330 ns/op 5.2310 ns/op 1.38
Buffer.compare 1024 - random bytes 73.630 ns/op 60.935 ns/op 1.21
byteArrayEquals 16384 - random bytes 7.0320 ns/op 5.2390 ns/op 1.34
Buffer.compare 16384 - random bytes 66.910 ns/op 60.637 ns/op 1.10
byteArrayEquals 123687377 - random bytes 12.040 ns/op 8.3900 ns/op 1.44
Buffer.compare 123687377 - random bytes 82.590 ns/op 63.840 ns/op 1.29
regular array get 100000 times 48.079 us/op 44.563 us/op 1.08
wrappedArray get 100000 times 48.114 us/op 44.513 us/op 1.08
arrayWithProxy get 100000 times 14.784 ms/op 14.295 ms/op 1.03
ssz.Root.equals 57.651 ns/op 53.727 ns/op 1.07
byteArrayEquals 60.544 ns/op 52.561 ns/op 1.15
Buffer.compare 13.545 ns/op 10.724 ns/op 1.26
shuffle list - 16384 els 7.5682 ms/op 6.9559 ms/op 1.09
shuffle list - 250000 els 109.06 ms/op 102.01 ms/op 1.07
processSlot - 1 slots 22.271 us/op 16.057 us/op 1.39
processSlot - 32 slots 3.7615 ms/op 3.7778 ms/op 1.00
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 72.645 ms/op 57.690 ms/op 1.26
getCommitteeAssignments - req 1 vs - 250000 vc 2.8874 ms/op 2.4901 ms/op 1.16
getCommitteeAssignments - req 100 vs - 250000 vc 4.1316 ms/op 3.6917 ms/op 1.12
getCommitteeAssignments - req 1000 vs - 250000 vc 4.4539 ms/op 4.0425 ms/op 1.10
findModifiedValidators - 10000 modified validators 596.00 ms/op 539.08 ms/op 1.11
findModifiedValidators - 1000 modified validators 491.00 ms/op 411.49 ms/op 1.19
findModifiedValidators - 100 modified validators 500.08 ms/op 411.29 ms/op 1.22
findModifiedValidators - 10 modified validators 464.24 ms/op 413.49 ms/op 1.12
findModifiedValidators - 1 modified validators 446.44 ms/op 390.69 ms/op 1.14
findModifiedValidators - no difference 427.51 ms/op 411.29 ms/op 1.04
compare ViewDUs 5.0917 s/op 4.3617 s/op 1.17
compare each validator Uint8Array 1.9069 s/op 1.4603 s/op 1.31
compare ViewDU to Uint8Array 1.5195 s/op 1.1286 s/op 1.35
migrate state 1000000 validators, 24 modified, 0 new 946.11 ms/op 756.53 ms/op 1.25
migrate state 1000000 validators, 1700 modified, 1000 new 1.2412 s/op 1.0907 s/op 1.14
migrate state 1000000 validators, 3400 modified, 2000 new 1.4995 s/op 1.3677 s/op 1.10
migrate state 1500000 validators, 24 modified, 0 new 1.0018 s/op 787.75 ms/op 1.27
migrate state 1500000 validators, 1700 modified, 1000 new 1.2180 s/op 1.1156 s/op 1.09
migrate state 1500000 validators, 3400 modified, 2000 new 1.4306 s/op 1.4648 s/op 0.98
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.7600 ns/op 5.0300 ns/op 0.95
state getBlockRootAtSlot - 250000 vs - 7PWei 743.94 ns/op 682.53 ns/op 1.09
computeProposers - vc 250000 9.4018 ms/op 10.312 ms/op 0.91
computeEpochShuffling - vc 250000 105.98 ms/op 110.65 ms/op 0.96
getNextSyncCommittee - vc 250000 153.62 ms/op 175.44 ms/op 0.88
computeSigningRoot for AttestationData 27.722 us/op 31.793 us/op 0.87
hash AttestationData serialized data then Buffer.toString(base64) 2.4043 us/op 2.6228 us/op 0.92
toHexString serialized data 1.1947 us/op 1.1734 us/op 1.02
Buffer.toString(base64) 231.26 ns/op 235.50 ns/op 0.98

by benchmarkbot/action

const isMarkedAsUntransferable = unknownWorker["isMarkedAsUntransferable"];
// Can be updated to direct access once minimal version of node is 21
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (isMarkedAsUntransferable && isMarkedAsUntransferable(buffer)) {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the buffer always untransferable or why do we need this check? Based on nodejs/node#47604 it would previously (node 20) just silently copy the buffer while with node 21 it throws an error. The problem seems to be related to @chainsafe/bls-keystore and how the keystore buffer is created.

Upgrading @chainsafe/bls-keystore fixes the issue for me since with v3 it uses Unit8Array instead of Buffer. Will do some performance testing with new version and open PR for that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, it might not be transferred at all with node20.

If the new @chainsafe/bls-keystore offers equivalent or better perf that's definitely the better option.

Copy link
Member

Choose a reason for hiding this comment

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

Could you try #6253 on your machine? At least on linux there are no issues running unit tests on node 21

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can confirm that it works on osx with node 21

@wemeetagain
Copy link
Member

Closing this PR for now since #6253 resolved the issue

@wemeetagain wemeetagain closed this Jan 8, 2024
@jeluard jeluard deleted the jeluard/fix-array-buffer-transferable branch January 25, 2024 14:28
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