Skip to content

EIP-4844: Add verifyKzgCommitmentsAgainstTransactions#4842

Merged
dapplion merged 1 commit intounstablefrom
dapplion/eip-4844-validateBlobsAndKzgCommitments
Dec 6, 2022
Merged

EIP-4844: Add verifyKzgCommitmentsAgainstTransactions#4842
dapplion merged 1 commit intounstablefrom
dapplion/eip-4844-validateBlobsAndKzgCommitments

Conversation

@dapplion
Copy link
Contributor

@dapplion dapplion commented Dec 5, 2022

Motivation

Description

Adding this function in stand-alone PR since it contains tricky byte manipulation logic, please review.

  • Add verifyKzgCommitmentsAgainstTransactions, to be used in block validation

@dapplion dapplion requested a review from a team as a code owner December 5, 2022 07:42
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

Performance Report

✔️ no performance regression detected

🚀🚀 Significant benchmark improvement detected

Benchmark suite Current: d57ed66 Previous: 1fde79d Ratio
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 6.5220 us/op 20.075 us/op 0.32
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 6.8290 us/op 21.210 us/op 0.32
Full benchmark results
Benchmark suite Current: d57ed66 Previous: 1fde79d Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.7267 ms/op 2.3952 ms/op 0.72
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 60.503 us/op 79.363 us/op 0.76
BLS verify - blst-native 2.1720 ms/op 1.9986 ms/op 1.09
BLS verifyMultipleSignatures 3 - blst-native 4.4959 ms/op 4.2332 ms/op 1.06
BLS verifyMultipleSignatures 8 - blst-native 9.7079 ms/op 8.8027 ms/op 1.10
BLS verifyMultipleSignatures 32 - blst-native 35.290 ms/op 34.314 ms/op 1.03
BLS aggregatePubkeys 32 - blst-native 46.453 us/op 48.821 us/op 0.95
BLS aggregatePubkeys 128 - blst-native 182.21 us/op 163.45 us/op 1.11
getAttestationsForBlock 79.916 ms/op 102.00 ms/op 0.78
isKnown best case - 1 super set check 485.00 ns/op 436.00 ns/op 1.11
isKnown normal case - 2 super set checks 474.00 ns/op 421.00 ns/op 1.13
isKnown worse case - 16 super set checks 475.00 ns/op 442.00 ns/op 1.07
CheckpointStateCache - add get delete 8.7550 us/op 9.4070 us/op 0.93
validate gossip signedAggregateAndProof - struct 5.0499 ms/op 4.7969 ms/op 1.05
validate gossip attestation - struct 2.3765 ms/op 2.0977 ms/op 1.13
pickEth1Vote - no votes 2.1285 ms/op 2.0058 ms/op 1.06
pickEth1Vote - max votes 18.157 ms/op 21.064 ms/op 0.86
pickEth1Vote - Eth1Data hashTreeRoot value x2048 12.240 ms/op 11.254 ms/op 1.09
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 20.063 ms/op 21.036 ms/op 0.95
pickEth1Vote - Eth1Data fastSerialize value x2048 1.4515 ms/op 1.6766 ms/op 0.87
pickEth1Vote - Eth1Data fastSerialize tree x2048 12.263 ms/op 15.477 ms/op 0.79
bytes32 toHexString 926.00 ns/op 1.1290 us/op 0.82
bytes32 Buffer.toString(hex) 716.00 ns/op 746.00 ns/op 0.96
bytes32 Buffer.toString(hex) from Uint8Array 989.00 ns/op 1.0470 us/op 0.94
bytes32 Buffer.toString(hex) + 0x 750.00 ns/op 688.00 ns/op 1.09
Object access 1 prop 0.33700 ns/op 0.34100 ns/op 0.99
Map access 1 prop 0.30300 ns/op 0.27500 ns/op 1.10
Object get x1000 11.031 ns/op 13.368 ns/op 0.83
Map get x1000 0.97500 ns/op 0.75700 ns/op 1.29
Object set x1000 72.046 ns/op 85.592 ns/op 0.84
Map set x1000 47.678 ns/op 63.109 ns/op 0.76
Return object 10000 times 0.43240 ns/op 0.39670 ns/op 1.09
Throw Error 10000 times 6.0847 us/op 6.4669 us/op 0.94
fastMsgIdFn sha256 / 200 bytes 4.8460 us/op 5.1520 us/op 0.94
fastMsgIdFn h32 xxhash / 200 bytes 547.00 ns/op 579.00 ns/op 0.94
fastMsgIdFn h64 xxhash / 200 bytes 779.00 ns/op 721.00 ns/op 1.08
fastMsgIdFn sha256 / 1000 bytes 15.278 us/op 14.306 us/op 1.07
fastMsgIdFn h32 xxhash / 1000 bytes 703.00 ns/op 667.00 ns/op 1.05
fastMsgIdFn h64 xxhash / 1000 bytes 941.00 ns/op 881.00 ns/op 1.07
fastMsgIdFn sha256 / 10000 bytes 133.94 us/op 120.15 us/op 1.11
fastMsgIdFn h32 xxhash / 10000 bytes 2.5890 us/op 2.2780 us/op 1.14
fastMsgIdFn h64 xxhash / 10000 bytes 1.8650 us/op 1.7690 us/op 1.05
enrSubnets - fastDeserialize 64 bits 2.7050 us/op 2.7610 us/op 0.98
enrSubnets - ssz BitVector 64 bits 821.00 ns/op 861.00 ns/op 0.95
enrSubnets - fastDeserialize 4 bits 361.00 ns/op 364.00 ns/op 0.99
enrSubnets - ssz BitVector 4 bits 831.00 ns/op 695.00 ns/op 1.20
prioritizePeers score -10:0 att 32-0.1 sync 2-0 81.649 us/op 90.494 us/op 0.90
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 118.57 us/op 122.51 us/op 0.97
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 194.78 us/op 228.55 us/op 0.85
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 399.49 us/op 498.16 us/op 0.80
prioritizePeers score 0:0 att 64-1 sync 4-1 439.48 us/op 482.54 us/op 0.91
RateTracker 1000000 limit, 1 obj count per request 185.72 ns/op 163.35 ns/op 1.14
RateTracker 1000000 limit, 2 obj count per request 133.87 ns/op 116.16 ns/op 1.15
RateTracker 1000000 limit, 4 obj count per request 110.04 ns/op 97.823 ns/op 1.12
RateTracker 1000000 limit, 8 obj count per request 96.574 ns/op 89.142 ns/op 1.08
RateTracker with prune 4.0410 us/op 4.0900 us/op 0.99
array of 16000 items push then shift 51.612 us/op 4.2745 us/op 12.07
LinkedList of 16000 items push then shift 12.270 ns/op 14.993 ns/op 0.82
array of 16000 items push then pop 205.00 ns/op 212.11 ns/op 0.97
LinkedList of 16000 items push then pop 11.989 ns/op 13.661 ns/op 0.88
array of 24000 items push then shift 77.384 us/op 6.3622 us/op 12.16
LinkedList of 24000 items push then shift 12.650 ns/op 16.140 ns/op 0.78
array of 24000 items push then pop 189.52 ns/op 203.90 ns/op 0.93
LinkedList of 24000 items push then pop 12.142 ns/op 14.571 ns/op 0.83
intersect bitArray bitLen 8 10.655 ns/op 9.7590 ns/op 1.09
intersect array and set length 8 132.37 ns/op 152.06 ns/op 0.87
intersect bitArray bitLen 128 57.806 ns/op 57.488 ns/op 1.01
intersect array and set length 128 1.7461 us/op 1.7687 us/op 0.99
Buffer.concat 32 items 1.8550 ns/op 1.8720 ns/op 0.99
pass gossip attestations to forkchoice per slot 5.1962 ms/op 3.5583 ms/op 1.46
computeDeltas 4.7461 ms/op 5.1914 ms/op 0.91
computeProposerBoostScoreFromBalances 804.43 us/op 712.25 us/op 1.13
altair processAttestation - 250000 vs - 7PWei normalcase 3.3117 ms/op 3.7455 ms/op 0.88
altair processAttestation - 250000 vs - 7PWei worstcase 5.1337 ms/op 5.8901 ms/op 0.87
altair processAttestation - setStatus - 1/6 committees join 181.36 us/op 200.75 us/op 0.90
altair processAttestation - setStatus - 1/3 committees join 357.10 us/op 402.99 us/op 0.89
altair processAttestation - setStatus - 1/2 committees join 522.34 us/op 575.29 us/op 0.91
altair processAttestation - setStatus - 2/3 committees join 675.99 us/op 757.32 us/op 0.89
altair processAttestation - setStatus - 4/5 committees join 948.23 us/op 1.0110 ms/op 0.94
altair processAttestation - setStatus - 100% committees join 1.1564 ms/op 1.3092 ms/op 0.88
altair processBlock - 250000 vs - 7PWei normalcase 24.986 ms/op 26.738 ms/op 0.93
altair processBlock - 250000 vs - 7PWei normalcase hashState 40.022 ms/op 43.711 ms/op 0.92
altair processBlock - 250000 vs - 7PWei worstcase 78.388 ms/op 79.531 ms/op 0.99
altair processBlock - 250000 vs - 7PWei worstcase hashState 114.86 ms/op 98.296 ms/op 1.17
phase0 processBlock - 250000 vs - 7PWei normalcase 3.1641 ms/op 3.5202 ms/op 0.90
phase0 processBlock - 250000 vs - 7PWei worstcase 50.770 ms/op 43.190 ms/op 1.18
altair processEth1Data - 250000 vs - 7PWei normalcase 706.03 us/op 734.92 us/op 0.96
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 6.5220 us/op 20.075 us/op 0.32
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 21.375 us/op 45.087 us/op 0.47
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 8.9060 us/op 25.600 us/op 0.35
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 6.8290 us/op 21.210 us/op 0.32
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 91.965 us/op 134.01 us/op 0.69
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 909.40 us/op 1.1139 ms/op 0.82
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 141069 12.614 ms/op 13.075 ms/op 0.96
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 250000 22.492 ms/op 23.415 ms/op 0.96
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 250000 73.463 ms/op 76.872 ms/op 0.96
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 250000 42.039 ms/op 44.208 ms/op 0.95
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 250000 120.36 ms/op 123.31 ms/op 0.98
Tree 40 250000 create 725.48 ms/op 757.50 ms/op 0.96
Tree 40 250000 get(125000) 235.43 ns/op 257.99 ns/op 0.91
Tree 40 250000 set(125000) 2.6920 us/op 2.1617 us/op 1.25
Tree 40 250000 toArray() 28.535 ms/op 32.374 ms/op 0.88
Tree 40 250000 iterate all - toArray() + loop 27.937 ms/op 32.960 ms/op 0.85
Tree 40 250000 iterate all - get(i) 114.31 ms/op 108.83 ms/op 1.05
MutableVector 250000 create 15.140 ms/op 13.369 ms/op 1.13
MutableVector 250000 get(125000) 11.175 ns/op 11.575 ns/op 0.97
MutableVector 250000 set(125000) 595.31 ns/op 545.94 ns/op 1.09
MutableVector 250000 toArray() 5.8865 ms/op 6.2579 ms/op 0.94
MutableVector 250000 iterate all - toArray() + loop 6.1919 ms/op 6.2043 ms/op 1.00
MutableVector 250000 iterate all - get(i) 2.6821 ms/op 2.6749 ms/op 1.00
Array 250000 create 5.9413 ms/op 5.6554 ms/op 1.05
Array 250000 clone - spread 3.5304 ms/op 3.1076 ms/op 1.14
Array 250000 get(125000) 1.5550 ns/op 1.3990 ns/op 1.11
Array 250000 set(125000) 1.5670 ns/op 1.3240 ns/op 1.18
Array 250000 iterate all - loop 151.17 us/op 119.56 us/op 1.26
effectiveBalanceIncrements clone Uint8Array 300000 151.34 us/op 64.298 us/op 2.35
effectiveBalanceIncrements clone MutableVector 300000 671.00 ns/op 934.00 ns/op 0.72
effectiveBalanceIncrements rw all Uint8Array 300000 247.64 us/op 242.30 us/op 1.02
effectiveBalanceIncrements rw all MutableVector 300000 142.69 ms/op 192.29 ms/op 0.74
phase0 afterProcessEpoch - 250000 vs - 7PWei 186.32 ms/op 165.34 ms/op 1.13
phase0 beforeProcessEpoch - 250000 vs - 7PWei 58.506 ms/op 99.949 ms/op 0.59
altair processEpoch - mainnet_e81889 540.37 ms/op 538.90 ms/op 1.00
mainnet_e81889 - altair beforeProcessEpoch 115.59 ms/op 130.98 ms/op 0.88
mainnet_e81889 - altair processJustificationAndFinalization 16.738 us/op 69.371 us/op 0.24
mainnet_e81889 - altair processInactivityUpdates 8.7108 ms/op 9.3178 ms/op 0.93
mainnet_e81889 - altair processRewardsAndPenalties 77.293 ms/op 89.595 ms/op 0.86
mainnet_e81889 - altair processRegistryUpdates 2.5160 us/op 14.945 us/op 0.17
mainnet_e81889 - altair processSlashings 643.00 ns/op 4.1410 us/op 0.16
mainnet_e81889 - altair processEth1DataReset 701.00 ns/op 4.3760 us/op 0.16
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.9390 ms/op 1.9670 ms/op 0.99
mainnet_e81889 - altair processSlashingsReset 3.9170 us/op 27.487 us/op 0.14
mainnet_e81889 - altair processRandaoMixesReset 4.1280 us/op 25.159 us/op 0.16
mainnet_e81889 - altair processHistoricalRootsUpdate 731.00 ns/op 3.9940 us/op 0.18
mainnet_e81889 - altair processParticipationFlagUpdates 2.3240 us/op 15.278 us/op 0.15
mainnet_e81889 - altair processSyncCommitteeUpdates 560.00 ns/op 3.5080 us/op 0.16
mainnet_e81889 - altair afterProcessEpoch 198.60 ms/op 172.46 ms/op 1.15
phase0 processEpoch - mainnet_e58758 480.55 ms/op 493.85 ms/op 0.97
mainnet_e58758 - phase0 beforeProcessEpoch 197.57 ms/op 260.13 ms/op 0.76
mainnet_e58758 - phase0 processJustificationAndFinalization 15.822 us/op 63.352 us/op 0.25
mainnet_e58758 - phase0 processRewardsAndPenalties 103.41 ms/op 112.07 ms/op 0.92
mainnet_e58758 - phase0 processRegistryUpdates 8.0480 us/op 34.207 us/op 0.24
mainnet_e58758 - phase0 processSlashings 592.00 ns/op 3.9930 us/op 0.15
mainnet_e58758 - phase0 processEth1DataReset 643.00 ns/op 3.8360 us/op 0.17
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.6144 ms/op 1.9498 ms/op 0.83
mainnet_e58758 - phase0 processSlashingsReset 3.4100 us/op 19.124 us/op 0.18
mainnet_e58758 - phase0 processRandaoMixesReset 4.4060 us/op 26.058 us/op 0.17
mainnet_e58758 - phase0 processHistoricalRootsUpdate 681.00 ns/op 4.3150 us/op 0.16
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.5530 us/op 24.125 us/op 0.15
mainnet_e58758 - phase0 afterProcessEpoch 162.93 ms/op 134.75 ms/op 1.21
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.9410 ms/op 1.9822 ms/op 0.98
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.1800 ms/op 2.2041 ms/op 0.99
altair processInactivityUpdates - 250000 normalcase 40.712 ms/op 47.645 ms/op 0.85
altair processInactivityUpdates - 250000 worstcase 34.056 ms/op 55.703 ms/op 0.61
phase0 processRegistryUpdates - 250000 normalcase 6.3480 us/op 29.695 us/op 0.21
phase0 processRegistryUpdates - 250000 badcase_full_deposits 389.83 us/op 448.64 us/op 0.87
phase0 processRegistryUpdates - 250000 worstcase 0.5 170.73 ms/op 228.74 ms/op 0.75
altair processRewardsAndPenalties - 250000 normalcase 74.263 ms/op 135.80 ms/op 0.55
altair processRewardsAndPenalties - 250000 worstcase 106.92 ms/op 80.118 ms/op 1.33
phase0 getAttestationDeltas - 250000 normalcase 11.544 ms/op 11.512 ms/op 1.00
phase0 getAttestationDeltas - 250000 worstcase 11.561 ms/op 11.690 ms/op 0.99
phase0 processSlashings - 250000 worstcase 5.6281 ms/op 5.8091 ms/op 0.97
altair processSyncCommitteeUpdates - 250000 289.66 ms/op 267.40 ms/op 1.08
BeaconState.hashTreeRoot - No change 520.00 ns/op 460.00 ns/op 1.13
BeaconState.hashTreeRoot - 1 full validator 70.175 us/op 61.382 us/op 1.14
BeaconState.hashTreeRoot - 32 full validator 650.05 us/op 624.11 us/op 1.04
BeaconState.hashTreeRoot - 512 full validator 7.4471 ms/op 6.7505 ms/op 1.10
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 90.320 us/op 84.040 us/op 1.07
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.3155 ms/op 1.1719 ms/op 1.12
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 16.544 ms/op 14.657 ms/op 1.13
BeaconState.hashTreeRoot - 1 balances 70.440 us/op 58.336 us/op 1.21
BeaconState.hashTreeRoot - 32 balances 658.62 us/op 561.78 us/op 1.17
BeaconState.hashTreeRoot - 512 balances 6.3477 ms/op 5.7629 ms/op 1.10
BeaconState.hashTreeRoot - 250000 balances 101.07 ms/op 88.042 ms/op 1.15
aggregationBits - 2048 els - zipIndexesInBitList 26.368 us/op 21.679 us/op 1.22
regular array get 100000 times 63.146 us/op 45.457 us/op 1.39
wrappedArray get 100000 times 61.036 us/op 46.295 us/op 1.32
arrayWithProxy get 100000 times 28.466 ms/op 27.715 ms/op 1.03
ssz.Root.equals 472.00 ns/op 466.00 ns/op 1.01
byteArrayEquals 482.00 ns/op 413.00 ns/op 1.17
shuffle list - 16384 els 11.269 ms/op 9.1569 ms/op 1.23
shuffle list - 250000 els 168.22 ms/op 137.88 ms/op 1.22
processSlot - 1 slots 13.764 us/op 13.045 us/op 1.06
processSlot - 32 slots 2.0126 ms/op 1.8176 ms/op 1.11
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 372.29 us/op 357.18 us/op 1.04
getCommitteeAssignments - req 1 vs - 250000 vc 5.4182 ms/op 4.2755 ms/op 1.27
getCommitteeAssignments - req 100 vs - 250000 vc 8.0161 ms/op 6.1270 ms/op 1.31
getCommitteeAssignments - req 1000 vs - 250000 vc 8.5556 ms/op 6.4460 ms/op 1.33
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 7.7200 ns/op 7.8900 ns/op 0.98
state getBlockRootAtSlot - 250000 vs - 7PWei 988.44 ns/op 924.44 ns/op 1.07
computeProposers - vc 250000 17.370 ms/op 15.780 ms/op 1.10
computeEpochShuffling - vc 250000 170.39 ms/op 144.12 ms/op 1.18
getNextSyncCommittee - vc 250000 288.83 ms/op 268.06 ms/op 1.08

by benchmarkbot/action

@dapplion dapplion changed the title Add verifyKzgCommitmentsAgainstTransactions EIP-4844: Add verifyKzgCommitmentsAgainstTransactions Dec 5, 2022
@dapplion dapplion added the spec-deneb 🐡 Issues targeting the Deneb spec version label Dec 5, 2022
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.

lgtm!

@dapplion dapplion merged commit 4d76345 into unstable Dec 6, 2022
@dapplion dapplion deleted the dapplion/eip-4844-validateBlobsAndKzgCommitments branch December 6, 2022 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spec-deneb 🐡 Issues targeting the Deneb spec version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants