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

feat: add verifySignatureSetsSameMessage BLS api #5747

Merged
merged 10 commits into from
Jul 21, 2023

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Jul 12, 2023

Motivation

  • verifying signature sets of the same signing root is 6x to >10x faster than verifyMultipleSignatures() api
  • as a preparation for feat: verify attestation gossip messages in batch #5729 where we'll validate signature sets with same signing root
  • we want to leverage our worker pool to control canAcceptWork() (if we should process a gossip message or not)

Description

  • new verifySignatureSetsSameMessage() bls api
  • the current job queue item is JobQueueItemDefault, add another job queue item JobQueueItemSameMessage
  • defer the pubkey aggregation of JobQueueItemDefault when runJob(), take that chance to aggregate pubkeys and signatures of JobQueueItemSameMessage and transform it to a regular BlsWorkReq, see jobItemWorkReq
  • for JobQueueItemSameMessage if it fails to verify, transform it to multiple JobQueueItemDefault and retry, see jobItemSameMessageToMultiSet

part of #5416

@twoeths twoeths changed the title Add verifySignatureSetsSameMessage feat: add verifySignatureSetsSameMessage BLS api Jul 12, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 12, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 7cc65be Previous: 4e6408a Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 677.01 us/op 540.43 us/op 1.25
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 83.835 us/op 81.340 us/op 1.03
BLS verify - blst-native 1.2424 ms/op 1.2267 ms/op 1.01
BLS verifyMultipleSignatures 3 - blst-native 2.5246 ms/op 2.5242 ms/op 1.00
BLS verifyMultipleSignatures 8 - blst-native 5.4472 ms/op 5.4132 ms/op 1.01
BLS verifyMultipleSignatures 32 - blst-native 19.643 ms/op 19.826 ms/op 0.99
BLS aggregatePubkeys 32 - blst-native 26.412 us/op 25.847 us/op 1.02
BLS aggregatePubkeys 128 - blst-native 101.65 us/op 104.04 us/op 0.98
getAttestationsForBlock 56.322 ms/op 60.361 ms/op 0.93
isKnown best case - 1 super set check 324.00 ns/op 322.00 ns/op 1.01
isKnown normal case - 2 super set checks 290.00 ns/op 455.00 ns/op 0.64
isKnown worse case - 16 super set checks 266.00 ns/op 407.00 ns/op 0.65
CheckpointStateCache - add get delete 5.3380 us/op 5.6880 us/op 0.94
validate api signedAggregateAndProof - struct 2.7473 ms/op 2.8049 ms/op 0.98
validate gossip signedAggregateAndProof - struct 2.7957 ms/op 2.8446 ms/op 0.98
validate api attestation - struct 1.3250 ms/op 1.3484 ms/op 0.98
validate gossip attestation - struct 1.3465 ms/op 1.3502 ms/op 1.00
pickEth1Vote - no votes 1.2217 ms/op 1.3040 ms/op 0.94
pickEth1Vote - max votes 8.5876 ms/op 9.8772 ms/op 0.87
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.6898 ms/op 9.3744 ms/op 0.93
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 14.393 ms/op 16.044 ms/op 0.90
pickEth1Vote - Eth1Data fastSerialize value x2048 627.93 us/op 717.23 us/op 0.88
pickEth1Vote - Eth1Data fastSerialize tree x2048 7.2397 ms/op 7.7218 ms/op 0.94
bytes32 toHexString 522.00 ns/op 584.00 ns/op 0.89
bytes32 Buffer.toString(hex) 314.00 ns/op 302.00 ns/op 1.04
bytes32 Buffer.toString(hex) from Uint8Array 534.00 ns/op 544.00 ns/op 0.98
bytes32 Buffer.toString(hex) + 0x 323.00 ns/op 302.00 ns/op 1.07
Object access 1 prop 0.16500 ns/op 0.18400 ns/op 0.90
Map access 1 prop 0.15200 ns/op 0.15200 ns/op 1.00
Object get x1000 7.2500 ns/op 8.0040 ns/op 0.91
Map get x1000 0.69700 ns/op 0.69600 ns/op 1.00
Object set x1000 56.492 ns/op 52.724 ns/op 1.07
Map set x1000 43.831 ns/op 51.016 ns/op 0.86
Return object 10000 times 0.24440 ns/op 0.24720 ns/op 0.99
Throw Error 10000 times 3.9442 us/op 3.9306 us/op 1.00
fastMsgIdFn sha256 / 200 bytes 3.3610 us/op 3.4010 us/op 0.99
fastMsgIdFn h32 xxhash / 200 bytes 291.00 ns/op 333.00 ns/op 0.87
fastMsgIdFn h64 xxhash / 200 bytes 339.00 ns/op 347.00 ns/op 0.98
fastMsgIdFn sha256 / 1000 bytes 11.443 us/op 11.428 us/op 1.00
fastMsgIdFn h32 xxhash / 1000 bytes 465.00 ns/op 457.00 ns/op 1.02
fastMsgIdFn h64 xxhash / 1000 bytes 466.00 ns/op 439.00 ns/op 1.06
fastMsgIdFn sha256 / 10000 bytes 104.72 us/op 104.01 us/op 1.01
fastMsgIdFn h32 xxhash / 10000 bytes 2.0380 us/op 2.0120 us/op 1.01
fastMsgIdFn h64 xxhash / 10000 bytes 1.3920 us/op 1.3920 us/op 1.00
enrSubnets - fastDeserialize 64 bits 1.6080 us/op 1.3510 us/op 1.19
enrSubnets - ssz BitVector 64 bits 539.00 ns/op 498.00 ns/op 1.08
enrSubnets - fastDeserialize 4 bits 229.00 ns/op 209.00 ns/op 1.10
enrSubnets - ssz BitVector 4 bits 524.00 ns/op 494.00 ns/op 1.06
prioritizePeers score -10:0 att 32-0.1 sync 2-0 129.68 us/op 109.28 us/op 1.19
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 133.67 us/op 143.69 us/op 0.93
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 198.58 us/op 212.11 us/op 0.94
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 337.90 us/op 348.73 us/op 0.97
prioritizePeers score 0:0 att 64-1 sync 4-1 379.80 us/op 357.44 us/op 1.06
array of 16000 items push then shift 1.6344 us/op 1.6906 us/op 0.97
LinkedList of 16000 items push then shift 9.4220 ns/op 9.2550 ns/op 1.02
array of 16000 items push then pop 64.602 ns/op 78.601 ns/op 0.82
LinkedList of 16000 items push then pop 9.2490 ns/op 10.063 ns/op 0.92
array of 24000 items push then shift 2.4489 us/op 2.5148 us/op 0.97
LinkedList of 24000 items push then shift 9.5460 ns/op 9.4180 ns/op 1.01
array of 24000 items push then pop 125.94 ns/op 125.34 ns/op 1.00
LinkedList of 24000 items push then pop 9.6830 ns/op 8.7800 ns/op 1.10
intersect bitArray bitLen 8 7.0960 ns/op 7.0490 ns/op 1.01
intersect array and set length 8 91.183 ns/op 57.693 ns/op 1.58
intersect bitArray bitLen 128 34.378 ns/op 31.994 ns/op 1.07
intersect array and set length 128 1.0086 us/op 782.58 ns/op 1.29
bitArray.getTrueBitIndexes() bitLen 128 1.8180 us/op 1.5450 us/op 1.18
bitArray.getTrueBitIndexes() bitLen 248 2.9220 us/op 2.5100 us/op 1.16
bitArray.getTrueBitIndexes() bitLen 512 6.0670 us/op 5.1720 us/op 1.17
Buffer.concat 32 items 1.0230 us/op 952.00 ns/op 1.07
Uint8Array.set 32 items 1.7600 us/op 1.7040 us/op 1.03
transfer serialized Status (84 B) 1.8150 us/op 1.7640 us/op 1.03
copy serialized Status (84 B) 1.6460 us/op 1.5490 us/op 1.06
transfer serialized SignedVoluntaryExit (112 B) 1.9330 us/op 1.8980 us/op 1.02
copy serialized SignedVoluntaryExit (112 B) 1.6110 us/op 1.6370 us/op 0.98
transfer serialized ProposerSlashing (416 B) 2.2730 us/op 2.2240 us/op 1.02
copy serialized ProposerSlashing (416 B) 2.3010 us/op 2.4970 us/op 0.92
transfer serialized Attestation (485 B) 2.2030 us/op 2.3730 us/op 0.93
copy serialized Attestation (485 B) 2.2640 us/op 2.2390 us/op 1.01
transfer serialized AttesterSlashing (33232 B) 2.4350 us/op 2.2620 us/op 1.08
copy serialized AttesterSlashing (33232 B) 8.3000 us/op 5.4830 us/op 1.51
transfer serialized Small SignedBeaconBlock (128000 B) 2.5260 us/op 2.5370 us/op 1.00
copy serialized Small SignedBeaconBlock (128000 B) 23.200 us/op 16.073 us/op 1.44
transfer serialized Avg SignedBeaconBlock (200000 B) 2.8780 us/op 3.3530 us/op 0.86
copy serialized Avg SignedBeaconBlock (200000 B) 32.018 us/op 22.530 us/op 1.42
transfer serialized BlobsSidecar (524380 B) 2.9950 us/op 3.0890 us/op 0.97
copy serialized BlobsSidecar (524380 B) 97.975 us/op 91.966 us/op 1.07
transfer serialized Big SignedBeaconBlock (1000000 B) 3.0160 us/op 3.0360 us/op 0.99
copy serialized Big SignedBeaconBlock (1000000 B) 178.32 us/op 154.64 us/op 1.15
pass gossip attestations to forkchoice per slot 2.4088 ms/op 2.2263 ms/op 1.08
forkChoice updateHead vc 100000 bc 64 eq 0 2.2122 ms/op 2.5497 ms/op 0.87
forkChoice updateHead vc 600000 bc 64 eq 0 11.847 ms/op 14.719 ms/op 0.80
forkChoice updateHead vc 1000000 bc 64 eq 0 19.299 ms/op 24.804 ms/op 0.78
forkChoice updateHead vc 600000 bc 320 eq 0 17.761 ms/op 16.833 ms/op 1.06
forkChoice updateHead vc 600000 bc 1200 eq 0 93.897 ms/op 89.017 ms/op 1.05
forkChoice updateHead vc 600000 bc 64 eq 1000 19.918 ms/op 22.994 ms/op 0.87
forkChoice updateHead vc 600000 bc 64 eq 10000 22.533 ms/op 25.536 ms/op 0.88
forkChoice updateHead vc 600000 bc 64 eq 300000 35.947 ms/op 39.334 ms/op 0.91
computeDeltas 3.4920 ms/op 3.3577 ms/op 1.04
computeProposerBoostScoreFromBalances 404.66 us/op 409.33 us/op 0.99
altair processAttestation - 250000 vs - 7PWei normalcase 2.3901 ms/op 3.3735 ms/op 0.71
altair processAttestation - 250000 vs - 7PWei worstcase 3.8704 ms/op 3.7123 ms/op 1.04
altair processAttestation - setStatus - 1/6 committees join 190.12 us/op 182.06 us/op 1.04
altair processAttestation - setStatus - 1/3 committees join 360.77 us/op 360.27 us/op 1.00
altair processAttestation - setStatus - 1/2 committees join 474.43 us/op 538.55 us/op 0.88
altair processAttestation - setStatus - 2/3 committees join 597.96 us/op 626.66 us/op 0.95
altair processAttestation - setStatus - 4/5 committees join 791.46 us/op 912.47 us/op 0.87
altair processAttestation - setStatus - 100% committees join 938.52 us/op 1.0671 ms/op 0.88
altair processBlock - 250000 vs - 7PWei normalcase 10.191 ms/op 11.864 ms/op 0.86
altair processBlock - 250000 vs - 7PWei normalcase hashState 17.563 ms/op 20.193 ms/op 0.87
altair processBlock - 250000 vs - 7PWei worstcase 39.810 ms/op 43.647 ms/op 0.91
altair processBlock - 250000 vs - 7PWei worstcase hashState 61.450 ms/op 63.014 ms/op 0.98
phase0 processBlock - 250000 vs - 7PWei normalcase 2.7236 ms/op 2.9320 ms/op 0.93
phase0 processBlock - 250000 vs - 7PWei worstcase 32.789 ms/op 35.484 ms/op 0.92
altair processEth1Data - 250000 vs - 7PWei normalcase 507.89 us/op 524.58 us/op 0.97
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 14.643 us/op 13.922 us/op 1.05
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 85.007 us/op 64.296 us/op 1.32
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 23.453 us/op 26.633 us/op 0.88
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 14.164 us/op 15.749 us/op 0.90
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 183.59 us/op 185.68 us/op 0.99
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.1981 ms/op 1.2897 ms/op 0.93
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.9251 ms/op 1.6697 ms/op 1.15
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.6695 ms/op 1.7306 ms/op 0.96
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 3.4862 ms/op 3.8216 ms/op 0.91
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.9255 ms/op 2.4946 ms/op 1.17
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 6.2651 ms/op 5.4996 ms/op 1.14
Tree 40 250000 create 434.61 ms/op 327.86 ms/op 1.33
Tree 40 250000 get(125000) 222.23 ns/op 195.38 ns/op 1.14
Tree 40 250000 set(125000) 1.0525 us/op 927.44 ns/op 1.13
Tree 40 250000 toArray() 23.319 ms/op 19.707 ms/op 1.18
Tree 40 250000 iterate all - toArray() + loop 22.193 ms/op 19.624 ms/op 1.13
Tree 40 250000 iterate all - get(i) 76.021 ms/op 67.983 ms/op 1.12
MutableVector 250000 create 12.210 ms/op 11.760 ms/op 1.04
MutableVector 250000 get(125000) 6.7970 ns/op 6.4400 ns/op 1.06
MutableVector 250000 set(125000) 311.94 ns/op 271.57 ns/op 1.15
MutableVector 250000 toArray() 4.2461 ms/op 3.9245 ms/op 1.08
MutableVector 250000 iterate all - toArray() + loop 4.5658 ms/op 3.6221 ms/op 1.26
MutableVector 250000 iterate all - get(i) 1.6577 ms/op 2.2808 ms/op 0.73
Array 250000 create 3.8972 ms/op 3.1185 ms/op 1.25
Array 250000 clone - spread 1.2949 ms/op 1.0688 ms/op 1.21
Array 250000 get(125000) 0.63700 ns/op 0.55400 ns/op 1.15
Array 250000 set(125000) 0.71100 ns/op 0.61200 ns/op 1.16
Array 250000 iterate all - loop 111.74 us/op 85.013 us/op 1.31
effectiveBalanceIncrements clone Uint8Array 300000 45.696 us/op 26.006 us/op 1.76
effectiveBalanceIncrements clone MutableVector 300000 366.00 ns/op 266.00 ns/op 1.38
effectiveBalanceIncrements rw all Uint8Array 300000 184.91 us/op 176.05 us/op 1.05
effectiveBalanceIncrements rw all MutableVector 300000 104.42 ms/op 77.562 ms/op 1.35
phase0 afterProcessEpoch - 250000 vs - 7PWei 128.33 ms/op 114.55 ms/op 1.12
phase0 beforeProcessEpoch - 250000 vs - 7PWei 35.611 ms/op 39.465 ms/op 0.90
altair processEpoch - mainnet_e81889 339.09 ms/op 328.53 ms/op 1.03
mainnet_e81889 - altair beforeProcessEpoch 68.325 ms/op 64.115 ms/op 1.07
mainnet_e81889 - altair processJustificationAndFinalization 23.393 us/op 16.646 us/op 1.41
mainnet_e81889 - altair processInactivityUpdates 8.0593 ms/op 6.6369 ms/op 1.21
mainnet_e81889 - altair processRewardsAndPenalties 70.942 ms/op 62.707 ms/op 1.13
mainnet_e81889 - altair processRegistryUpdates 3.6750 us/op 2.8460 us/op 1.29
mainnet_e81889 - altair processSlashings 562.00 ns/op 500.00 ns/op 1.12
mainnet_e81889 - altair processEth1DataReset 666.00 ns/op 968.00 ns/op 0.69
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2997 ms/op 1.2629 ms/op 1.03
mainnet_e81889 - altair processSlashingsReset 4.7800 us/op 5.9110 us/op 0.81
mainnet_e81889 - altair processRandaoMixesReset 5.4180 us/op 6.2900 us/op 0.86
mainnet_e81889 - altair processHistoricalRootsUpdate 711.00 ns/op 1.2690 us/op 0.56
mainnet_e81889 - altair processParticipationFlagUpdates 2.2990 us/op 5.6690 us/op 0.41
mainnet_e81889 - altair processSyncCommitteeUpdates 621.00 ns/op 690.00 ns/op 0.90
mainnet_e81889 - altair afterProcessEpoch 128.82 ms/op 128.72 ms/op 1.00
phase0 processEpoch - mainnet_e58758 383.19 ms/op 368.79 ms/op 1.04
mainnet_e58758 - phase0 beforeProcessEpoch 165.97 ms/op 154.91 ms/op 1.07
mainnet_e58758 - phase0 processJustificationAndFinalization 21.213 us/op 19.338 us/op 1.10
mainnet_e58758 - phase0 processRewardsAndPenalties 67.714 ms/op 68.610 ms/op 0.99
mainnet_e58758 - phase0 processRegistryUpdates 16.289 us/op 12.727 us/op 1.28
mainnet_e58758 - phase0 processSlashings 922.00 ns/op 969.00 ns/op 0.95
mainnet_e58758 - phase0 processEth1DataReset 829.00 ns/op 1.1830 us/op 0.70
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.1380 ms/op 1.1064 ms/op 1.03
mainnet_e58758 - phase0 processSlashingsReset 3.4690 us/op 5.3060 us/op 0.65
mainnet_e58758 - phase0 processRandaoMixesReset 4.5070 us/op 8.7590 us/op 0.51
mainnet_e58758 - phase0 processHistoricalRootsUpdate 848.00 ns/op 1.0030 us/op 0.85
mainnet_e58758 - phase0 processParticipationRecordUpdates 5.3050 us/op 8.5650 us/op 0.62
mainnet_e58758 - phase0 afterProcessEpoch 109.10 ms/op 104.49 ms/op 1.04
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2777 ms/op 1.5469 ms/op 0.83
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.5089 ms/op 3.2045 ms/op 0.47
altair processInactivityUpdates - 250000 normalcase 28.352 ms/op 31.277 ms/op 0.91
altair processInactivityUpdates - 250000 worstcase 27.084 ms/op 31.317 ms/op 0.86
phase0 processRegistryUpdates - 250000 normalcase 13.476 us/op 17.927 us/op 0.75
phase0 processRegistryUpdates - 250000 badcase_full_deposits 408.78 us/op 402.67 us/op 1.02
phase0 processRegistryUpdates - 250000 worstcase 0.5 140.55 ms/op 147.23 ms/op 0.95
altair processRewardsAndPenalties - 250000 normalcase 77.511 ms/op 75.593 ms/op 1.03
altair processRewardsAndPenalties - 250000 worstcase 75.560 ms/op 81.253 ms/op 0.93
phase0 getAttestationDeltas - 250000 normalcase 8.9028 ms/op 10.568 ms/op 0.84
phase0 getAttestationDeltas - 250000 worstcase 10.161 ms/op 9.9074 ms/op 1.03
phase0 processSlashings - 250000 worstcase 2.7233 ms/op 3.1168 ms/op 0.87
altair processSyncCommitteeUpdates - 250000 183.36 ms/op 159.87 ms/op 1.15
BeaconState.hashTreeRoot - No change 279.00 ns/op 274.00 ns/op 1.02
BeaconState.hashTreeRoot - 1 full validator 56.774 us/op 60.422 us/op 0.94
BeaconState.hashTreeRoot - 32 full validator 637.67 us/op 538.15 us/op 1.18
BeaconState.hashTreeRoot - 512 full validator 6.9185 ms/op 7.9376 ms/op 0.87
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 66.272 us/op 75.984 us/op 0.87
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.0114 ms/op 1.0513 ms/op 0.96
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 14.017 ms/op 14.768 ms/op 0.95
BeaconState.hashTreeRoot - 1 balances 52.648 us/op 61.713 us/op 0.85
BeaconState.hashTreeRoot - 32 balances 462.77 us/op 504.06 us/op 0.92
BeaconState.hashTreeRoot - 512 balances 4.8070 ms/op 5.7792 ms/op 0.83
BeaconState.hashTreeRoot - 250000 balances 74.783 ms/op 89.688 ms/op 0.83
aggregationBits - 2048 els - zipIndexesInBitList 21.643 us/op 32.307 us/op 0.67
regular array get 100000 times 34.541 us/op 52.063 us/op 0.66
wrappedArray get 100000 times 41.417 us/op 47.911 us/op 0.86
arrayWithProxy get 100000 times 15.503 ms/op 16.590 ms/op 0.93
ssz.Root.equals 259.00 ns/op 263.00 ns/op 0.98
byteArrayEquals 262.00 ns/op 265.00 ns/op 0.99
shuffle list - 16384 els 7.2650 ms/op 8.0025 ms/op 0.91
shuffle list - 250000 els 109.29 ms/op 114.89 ms/op 0.95
processSlot - 1 slots 9.5940 us/op 9.7010 us/op 0.99
processSlot - 32 slots 1.4345 ms/op 1.5307 ms/op 0.94
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 60.378 ms/op 62.691 ms/op 0.96
getCommitteeAssignments - req 1 vs - 250000 vc 2.6129 ms/op 2.5854 ms/op 1.01
getCommitteeAssignments - req 100 vs - 250000 vc 3.8214 ms/op 4.0397 ms/op 0.95
getCommitteeAssignments - req 1000 vs - 250000 vc 4.2228 ms/op 4.3747 ms/op 0.97
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.3400 ns/op 5.4100 ns/op 0.99
state getBlockRootAtSlot - 250000 vs - 7PWei 614.49 ns/op 607.47 ns/op 1.01
computeProposers - vc 250000 9.6094 ms/op 9.7727 ms/op 0.98
computeEpochShuffling - vc 250000 115.80 ms/op 115.47 ms/op 1.00
getNextSyncCommittee - vc 250000 170.18 ms/op 175.91 ms/op 0.97
computeSigningRoot for AttestationData 14.179 us/op 14.766 us/op 0.96
hash AttestationData serialized data then Buffer.toString(base64) 2.3931 us/op 2.4623 us/op 0.97
toHexString serialized data 1.1853 us/op 1.2102 us/op 0.98
Buffer.toString(base64) 246.71 ns/op 238.80 ns/op 1.03

by benchmarkbot/action

@twoeths twoeths marked this pull request as ready for review July 12, 2023 07:04
@twoeths twoeths requested a review from a team as a code owner July 12, 2023 07:04
const startNs = process.hrtime.bigint();
const pubkey = bls.PublicKey.aggregate(sets.map((set) => set.publicKey));
// validate signature = true
const signatures = sets.map((set) => bls.Signature.fromBytes(set.signature, CoordType.affine, true));
Copy link
Contributor

Choose a reason for hiding this comment

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

Watch out, this can throw here and should be handled on a per-item basis

Copy link
Contributor

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

Looks good! Can you add some tests for invalid signature format? Such that it throws an error on the fromBytes call for both worker and main thread, default and sameMessage

@twoeths twoeths force-pushed the tuyen/verifyManySignatureSetsSameMessage-lion-take branch from b8491c7 to 52785b0 Compare July 17, 2023 08:40
Comment on lines 468 to 477
// Create new jobs for each pubkey set, and Promise.all all the results
for (const j of jobItemSameMessageToMultiSet(job)) {
if (j.opts.priority) {
this.jobs.unshift(j);
} else {
this.jobs.push(j);
}
}
this.metrics?.blsThreadPool.sameMessageRetryJobs.inc(1);
this.metrics?.blsThreadPool.sameMessageRetrySets.inc(job.sets.length);
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth pulling this into a method since this block is repeated? eg: retryJobItemSameMessage

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 extracted it to new method retryJobItemSameMessage

@twoeths
Copy link
Contributor Author

twoeths commented Jul 19, 2023

Tested on a mainnet node subscribing to all subnets

  • With useWorker=false, this PR does not have stable mesh peers
  • With useWorker=true, mesh peers are stable
Screenshot 2023-07-19 at 18 01 23
  • beacon_attestation job time is a bit better (~131ms vs ~178ms on unstable)
Screenshot 2023-07-19 at 18 02 28
  • beacon_attestation job wait time is way better than unstable (~821ms vs ~2.5s)
Screenshot 2023-07-19 at 18 03 18
  • cpu time is better than unstable (~200% vs > 300ms) because we send way less signature sets through worker threads
Screenshot 2023-07-19 at 18 06 51

we'll likely have a flag to turn this batch attestation feature on/off later (to be done on another PR)

wemeetagain
wemeetagain previously approved these changes Jul 20, 2023
Copy link
Contributor

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

Looks great! Pushed a commit with mostly cosmetic changes

@dapplion dapplion enabled auto-merge (squash) July 20, 2023 14:29
@dapplion dapplion merged commit 50551d3 into unstable Jul 21, 2023
@dapplion dapplion deleted the tuyen/verifyManySignatureSetsSameMessage-lion-take branch July 21, 2023 01:22
@wemeetagain
Copy link
Member

🎉 This PR is included in v1.10.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