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

Add assertions for the head and finality #4573

Merged
merged 9 commits into from Sep 23, 2022

Conversation

nazarhussain
Copy link
Contributor

@nazarhussain nazarhussain commented Sep 20, 2022

Motivation

Add assertions for the head and finality tracking per slot.

Resolves #4276, Closes: #4547

@nazarhussain nazarhussain requested a review from a team as a code owner September 20, 2022 11:50
@nazarhussain nazarhussain self-assigned this Sep 20, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 20, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: e3ee5d2 Previous: fd8e335 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.8870 ms/op 2.1053 ms/op 0.90
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 65.805 us/op 71.008 us/op 0.93
BLS verify - blst-native 2.1657 ms/op 1.9182 ms/op 1.13
BLS verifyMultipleSignatures 3 - blst-native 4.4734 ms/op 4.0199 ms/op 1.11
BLS verifyMultipleSignatures 8 - blst-native 9.6666 ms/op 8.6175 ms/op 1.12
BLS verifyMultipleSignatures 32 - blst-native 35.265 ms/op 29.900 ms/op 1.18
BLS aggregatePubkeys 32 - blst-native 46.488 us/op 38.948 us/op 1.19
BLS aggregatePubkeys 128 - blst-native 181.61 us/op 159.21 us/op 1.14
getAttestationsForBlock 79.130 ms/op 94.012 ms/op 0.84
isKnown best case - 1 super set check 476.00 ns/op 437.00 ns/op 1.09
isKnown normal case - 2 super set checks 464.00 ns/op 412.00 ns/op 1.13
isKnown worse case - 16 super set checks 468.00 ns/op 416.00 ns/op 1.13
CheckpointStateCache - add get delete 9.2650 us/op 9.4750 us/op 0.98
validate gossip signedAggregateAndProof - struct 5.0275 ms/op 4.3962 ms/op 1.14
validate gossip attestation - struct 2.3671 ms/op 2.1398 ms/op 1.11
pickEth1Vote - no votes 2.1685 ms/op 2.2435 ms/op 0.97
pickEth1Vote - max votes 19.166 ms/op 18.706 ms/op 1.02
pickEth1Vote - Eth1Data hashTreeRoot value x2048 13.029 ms/op 11.886 ms/op 1.10
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 20.396 ms/op 19.559 ms/op 1.04
pickEth1Vote - Eth1Data fastSerialize value x2048 1.4645 ms/op 1.4902 ms/op 0.98
pickEth1Vote - Eth1Data fastSerialize tree x2048 13.299 ms/op 13.780 ms/op 0.97
bytes32 toHexString 948.00 ns/op 1.0510 us/op 0.90
bytes32 Buffer.toString(hex) 812.00 ns/op 706.00 ns/op 1.15
bytes32 Buffer.toString(hex) from Uint8Array 1.1070 us/op 936.00 ns/op 1.18
bytes32 Buffer.toString(hex) + 0x 826.00 ns/op 636.00 ns/op 1.30
Object access 1 prop 0.37400 ns/op 0.32800 ns/op 1.14
Map access 1 prop 0.32000 ns/op 0.30000 ns/op 1.07
Object get x1000 10.867 ns/op 15.918 ns/op 0.68
Map get x1000 0.93600 ns/op 0.87000 ns/op 1.08
Object set x1000 72.016 ns/op 99.581 ns/op 0.72
Map set x1000 48.234 ns/op 66.585 ns/op 0.72
Return object 10000 times 0.44140 ns/op 0.36750 ns/op 1.20
Throw Error 10000 times 5.9390 us/op 6.8930 us/op 0.86
enrSubnets - fastDeserialize 64 bits 2.6410 us/op 2.5590 us/op 1.03
enrSubnets - ssz BitVector 64 bits 858.00 ns/op 693.00 ns/op 1.24
enrSubnets - fastDeserialize 4 bits 385.00 ns/op 352.00 ns/op 1.09
enrSubnets - ssz BitVector 4 bits 869.00 ns/op 653.00 ns/op 1.33
prioritizePeers score -10:0 att 32-0.1 sync 2-0 83.309 us/op 95.063 us/op 0.88
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 127.71 us/op 141.10 us/op 0.91
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 211.51 us/op 238.09 us/op 0.89
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 337.28 us/op 469.67 us/op 0.72
prioritizePeers score 0:0 att 64-1 sync 4-1 407.98 us/op 475.82 us/op 0.86
RateTracker 1000000 limit, 1 obj count per request 183.25 ns/op 164.49 ns/op 1.11
RateTracker 1000000 limit, 2 obj count per request 132.72 ns/op 123.46 ns/op 1.08
RateTracker 1000000 limit, 4 obj count per request 107.87 ns/op 104.68 ns/op 1.03
RateTracker 1000000 limit, 8 obj count per request 94.711 ns/op 92.408 ns/op 1.02
RateTracker with prune 3.9540 us/op 4.2700 us/op 0.93
array of 16000 items push then shift 51.572 us/op 4.5058 us/op 11.45
LinkedList of 16000 items push then shift 12.554 ns/op 16.882 ns/op 0.74
array of 16000 items push then pop 213.10 ns/op 212.73 ns/op 1.00
LinkedList of 16000 items push then pop 12.355 ns/op 16.201 ns/op 0.76
array of 24000 items push then shift 77.357 us/op 6.7287 us/op 11.50
LinkedList of 24000 items push then shift 13.144 ns/op 17.366 ns/op 0.76
array of 24000 items push then pop 199.73 ns/op 228.20 ns/op 0.88
LinkedList of 24000 items push then pop 12.441 ns/op 16.313 ns/op 0.76
intersect bitArray bitLen 8 10.708 ns/op 10.632 ns/op 1.01
intersect array and set length 8 138.81 ns/op 162.46 ns/op 0.85
intersect bitArray bitLen 128 58.308 ns/op 60.167 ns/op 0.97
intersect array and set length 128 1.8887 us/op 2.0027 us/op 0.94
Buffer.concat 32 items 2.0490 ns/op 2.0070 ns/op 1.02
pass gossip attestations to forkchoice per slot 2.9020 ms/op 3.4069 ms/op 0.85
computeDeltas 3.2288 ms/op 3.7056 ms/op 0.87
computeProposerBoostScoreFromBalances 807.83 us/op 755.33 us/op 1.07
altair processAttestation - 250000 vs - 7PWei normalcase 3.4244 ms/op 4.5200 ms/op 0.76
altair processAttestation - 250000 vs - 7PWei worstcase 5.5096 ms/op 6.1768 ms/op 0.89
altair processAttestation - setStatus - 1/6 committees join 183.10 us/op 254.59 us/op 0.72
altair processAttestation - setStatus - 1/3 committees join 354.20 us/op 447.04 us/op 0.79
altair processAttestation - setStatus - 1/2 committees join 513.63 us/op 596.71 us/op 0.86
altair processAttestation - setStatus - 2/3 committees join 679.31 us/op 864.70 us/op 0.79
altair processAttestation - setStatus - 4/5 committees join 949.23 us/op 1.0846 ms/op 0.88
altair processAttestation - setStatus - 100% committees join 1.1534 ms/op 1.2786 ms/op 0.90
altair processBlock - 250000 vs - 7PWei normalcase 25.435 ms/op 27.676 ms/op 0.92
altair processBlock - 250000 vs - 7PWei normalcase hashState 34.691 ms/op 42.615 ms/op 0.81
altair processBlock - 250000 vs - 7PWei worstcase 82.214 ms/op 77.641 ms/op 1.06
altair processBlock - 250000 vs - 7PWei worstcase hashState 110.56 ms/op 110.67 ms/op 1.00
phase0 processBlock - 250000 vs - 7PWei normalcase 3.2925 ms/op 3.8516 ms/op 0.85
phase0 processBlock - 250000 vs - 7PWei worstcase 51.387 ms/op 48.038 ms/op 1.07
altair processEth1Data - 250000 vs - 7PWei normalcase 731.86 us/op 937.05 us/op 0.78
Tree 40 250000 create 739.62 ms/op 727.71 ms/op 1.02
Tree 40 250000 get(125000) 232.88 ns/op 271.73 ns/op 0.86
Tree 40 250000 set(125000) 2.1415 us/op 2.3897 us/op 0.90
Tree 40 250000 toArray() 27.924 ms/op 33.452 ms/op 0.83
Tree 40 250000 iterate all - toArray() + loop 27.975 ms/op 33.854 ms/op 0.83
Tree 40 250000 iterate all - get(i) 118.63 ms/op 115.97 ms/op 1.02
MutableVector 250000 create 12.996 ms/op 17.070 ms/op 0.76
MutableVector 250000 get(125000) 11.753 ns/op 12.387 ns/op 0.95
MutableVector 250000 set(125000) 521.57 ns/op 743.94 ns/op 0.70
MutableVector 250000 toArray() 6.1416 ms/op 6.8728 ms/op 0.89
MutableVector 250000 iterate all - toArray() + loop 6.2751 ms/op 6.6127 ms/op 0.95
MutableVector 250000 iterate all - get(i) 2.6914 ms/op 3.6767 ms/op 0.73
Array 250000 create 6.0352 ms/op 6.5225 ms/op 0.93
Array 250000 clone - spread 3.2403 ms/op 4.1642 ms/op 0.78
Array 250000 get(125000) 1.4170 ns/op 1.5630 ns/op 0.91
Array 250000 set(125000) 1.4370 ns/op 1.6130 ns/op 0.89
Array 250000 iterate all - loop 150.93 us/op 123.30 us/op 1.22
effectiveBalanceIncrements clone Uint8Array 300000 45.762 us/op 200.59 us/op 0.23
effectiveBalanceIncrements clone MutableVector 300000 993.00 ns/op 691.00 ns/op 1.44
effectiveBalanceIncrements rw all Uint8Array 300000 247.05 us/op 242.56 us/op 1.02
effectiveBalanceIncrements rw all MutableVector 300000 164.88 ms/op 177.85 ms/op 0.93
phase0 afterProcessEpoch - 250000 vs - 7PWei 189.90 ms/op 165.11 ms/op 1.15
phase0 beforeProcessEpoch - 250000 vs - 7PWei 60.864 ms/op 69.601 ms/op 0.87
altair processEpoch - mainnet_e81889 548.15 ms/op 557.61 ms/op 0.98
mainnet_e81889 - altair beforeProcessEpoch 138.88 ms/op 152.55 ms/op 0.91
mainnet_e81889 - altair processJustificationAndFinalization 17.905 us/op 64.080 us/op 0.28
mainnet_e81889 - altair processInactivityUpdates 8.8165 ms/op 9.8942 ms/op 0.89
mainnet_e81889 - altair processRewardsAndPenalties 79.783 ms/op 95.865 ms/op 0.83
mainnet_e81889 - altair processRegistryUpdates 2.7560 us/op 14.358 us/op 0.19
mainnet_e81889 - altair processSlashings 676.00 ns/op 3.8690 us/op 0.17
mainnet_e81889 - altair processEth1DataReset 679.00 ns/op 4.3300 us/op 0.16
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.1701 ms/op 2.1014 ms/op 1.03
mainnet_e81889 - altair processSlashingsReset 4.6440 us/op 26.327 us/op 0.18
mainnet_e81889 - altair processRandaoMixesReset 3.9900 us/op 26.834 us/op 0.15
mainnet_e81889 - altair processHistoricalRootsUpdate 791.00 ns/op 4.2210 us/op 0.19
mainnet_e81889 - altair processParticipationFlagUpdates 2.3210 us/op 15.046 us/op 0.15
mainnet_e81889 - altair processSyncCommitteeUpdates 628.00 ns/op 3.5700 us/op 0.18
mainnet_e81889 - altair afterProcessEpoch 197.85 ms/op 176.14 ms/op 1.12
phase0 processEpoch - mainnet_e58758 489.57 ms/op 520.30 ms/op 0.94
mainnet_e58758 - phase0 beforeProcessEpoch 182.82 ms/op 232.77 ms/op 0.79
mainnet_e58758 - phase0 processJustificationAndFinalization 16.325 us/op 61.176 us/op 0.27
mainnet_e58758 - phase0 processRewardsAndPenalties 116.51 ms/op 142.88 ms/op 0.82
mainnet_e58758 - phase0 processRegistryUpdates 10.060 us/op 32.989 us/op 0.30
mainnet_e58758 - phase0 processSlashings 722.00 ns/op 3.1600 us/op 0.23
mainnet_e58758 - phase0 processEth1DataReset 638.00 ns/op 3.6220 us/op 0.18
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.9321 ms/op 1.9563 ms/op 0.99
mainnet_e58758 - phase0 processSlashingsReset 3.6070 us/op 13.425 us/op 0.27
mainnet_e58758 - phase0 processRandaoMixesReset 4.1640 us/op 25.836 us/op 0.16
mainnet_e58758 - phase0 processHistoricalRootsUpdate 734.00 ns/op 4.1650 us/op 0.18
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.2440 us/op 23.535 us/op 0.18
mainnet_e58758 - phase0 afterProcessEpoch 162.98 ms/op 149.72 ms/op 1.09
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.0011 ms/op 2.0507 ms/op 0.98
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.2341 ms/op 2.6758 ms/op 0.83
altair processInactivityUpdates - 250000 normalcase 41.104 ms/op 45.441 ms/op 0.90
altair processInactivityUpdates - 250000 worstcase 34.188 ms/op 56.453 ms/op 0.61
phase0 processRegistryUpdates - 250000 normalcase 6.7110 us/op 26.806 us/op 0.25
phase0 processRegistryUpdates - 250000 badcase_full_deposits 382.32 us/op 445.25 us/op 0.86
phase0 processRegistryUpdates - 250000 worstcase 0.5 173.75 ms/op 254.27 ms/op 0.68
altair processRewardsAndPenalties - 250000 normalcase 78.815 ms/op 135.74 ms/op 0.58
altair processRewardsAndPenalties - 250000 worstcase 76.806 ms/op 88.725 ms/op 0.87
phase0 getAttestationDeltas - 250000 normalcase 12.222 ms/op 12.589 ms/op 0.97
phase0 getAttestationDeltas - 250000 worstcase 12.725 ms/op 13.696 ms/op 0.93
phase0 processSlashings - 250000 worstcase 5.2562 ms/op 5.2926 ms/op 0.99
altair processSyncCommitteeUpdates - 250000 297.63 ms/op 292.97 ms/op 1.02
BeaconState.hashTreeRoot - No change 546.00 ns/op 531.00 ns/op 1.03
BeaconState.hashTreeRoot - 1 full validator 72.455 us/op 67.877 us/op 1.07
BeaconState.hashTreeRoot - 32 full validator 741.96 us/op 847.29 us/op 0.88
BeaconState.hashTreeRoot - 512 full validator 6.8384 ms/op 6.8674 ms/op 1.00
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 86.597 us/op 84.350 us/op 1.03
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.3717 ms/op 1.2740 ms/op 1.08
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 17.780 ms/op 16.080 ms/op 1.11
BeaconState.hashTreeRoot - 1 balances 71.522 us/op 70.387 us/op 1.02
BeaconState.hashTreeRoot - 32 balances 635.44 us/op 620.83 us/op 1.02
BeaconState.hashTreeRoot - 512 balances 6.6230 ms/op 5.8802 ms/op 1.13
BeaconState.hashTreeRoot - 250000 balances 109.06 ms/op 96.995 ms/op 1.12
aggregationBits - 2048 els - zipIndexesInBitList 33.654 us/op 29.152 us/op 1.15
regular array get 100000 times 62.539 us/op 48.500 us/op 1.29
wrappedArray get 100000 times 60.590 us/op 49.849 us/op 1.22
arrayWithProxy get 100000 times 28.994 ms/op 29.262 ms/op 0.99
ssz.Root.equals 538.00 ns/op 524.00 ns/op 1.03
byteArrayEquals 541.00 ns/op 519.00 ns/op 1.04
shuffle list - 16384 els 11.612 ms/op 11.679 ms/op 0.99
shuffle list - 250000 els 168.11 ms/op 144.16 ms/op 1.17
processSlot - 1 slots 14.256 us/op 12.931 us/op 1.10
processSlot - 32 slots 2.0372 ms/op 1.9784 ms/op 1.03
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 390.02 us/op 372.21 us/op 1.05
getCommitteeAssignments - req 1 vs - 250000 vc 5.3895 ms/op 4.6527 ms/op 1.16
getCommitteeAssignments - req 100 vs - 250000 vc 7.8779 ms/op 6.7033 ms/op 1.18
getCommitteeAssignments - req 1000 vs - 250000 vc 8.4501 ms/op 6.7332 ms/op 1.26
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 8.0700 ns/op 8.5100 ns/op 0.95
state getBlockRootAtSlot - 250000 vs - 7PWei 1.3326 us/op 1.2590 us/op 1.06
computeProposers - vc 250000 18.827 ms/op 16.538 ms/op 1.14
computeEpochShuffling - vc 250000 171.12 ms/op 146.49 ms/op 1.17
getNextSyncCommittee - vc 250000 296.41 ms/op 299.83 ms/op 0.99

by benchmarkbot/action

@@ -428,7 +428,8 @@ export function isValidAttestationData(
if (!ssz.phase0.Checkpoint.equals(data.source, justifiedCheckpoint)) return false;

// Shuffling can't have changed if we're in the first few epochs
if (stateEpoch < 2) {
// Also we can't look back 2 epochs if target epoch is 1 or less
if (stateEpoch < 2 || targetEpoch < 2) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The following issue #4547 is fixed with above change.

Copy link
Contributor

@twoeths twoeths left a comment

Choose a reason for hiding this comment

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

@nazarhussain the simulation tests look great!

@nazarhussain nazarhussain merged commit bfeb48a into unstable Sep 23, 2022
@nazarhussain nazarhussain deleted the nh/4276-assertions-participation-per-slot branch September 23, 2022 07:40
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.

isValidAttestationData returns invalid result for earlier epochs Add assertions to sim tests
2 participants