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

Produce block: ignore old attestations #4745

Merged
merged 3 commits into from
Nov 11, 2022
Merged

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Nov 10, 2022

Motivation

Failed to produce attestations, this happens if the produceBlock function try to include an old attestation (which rarely happens), for the scenario in #4743:

  • Lodestar call produceBlock for slot 5099734
  • We try to include an attestation of an old slot (suppose it < 5099712)
  • It tried to get dependent root at 5099647
  • But finalized slot is at 5099648

Description

  • For v1.1.x, findAttesterDependentRoot() returns null in this case
  • For v1.2.0, due to Replace findAttesterDependentRoot with getDependantRoot #4555, the new function getDependentRoot() throws error instead
  • The fix is to catch the error and simply ignore that attestation data
  • Also add a new metric to track number of aggregated attestations in lodestar blocks

Closes #4555

@twoeths twoeths requested a review from a team as a code owner November 10, 2022 06:58
@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: bbf7ce0 Previous: 07e02aa Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.3055 ms/op 2.8455 ms/op 0.81
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 75.019 us/op 96.290 us/op 0.78
BLS verify - blst-native 1.8564 ms/op 2.5063 ms/op 0.74
BLS verifyMultipleSignatures 3 - blst-native 3.8082 ms/op 4.8977 ms/op 0.78
BLS verifyMultipleSignatures 8 - blst-native 8.1944 ms/op 10.905 ms/op 0.75
BLS verifyMultipleSignatures 32 - blst-native 29.697 ms/op 39.516 ms/op 0.75
BLS aggregatePubkeys 32 - blst-native 39.413 us/op 52.639 us/op 0.75
BLS aggregatePubkeys 128 - blst-native 153.41 us/op 200.27 us/op 0.77
getAttestationsForBlock 90.012 ms/op 122.14 ms/op 0.74
isKnown best case - 1 super set check 446.00 ns/op 524.00 ns/op 0.85
isKnown normal case - 2 super set checks 437.00 ns/op 519.00 ns/op 0.84
isKnown worse case - 16 super set checks 433.00 ns/op 517.00 ns/op 0.84
CheckpointStateCache - add get delete 8.8580 us/op 11.490 us/op 0.77
validate gossip signedAggregateAndProof - struct 4.2833 ms/op 5.3917 ms/op 0.79
validate gossip attestation - struct 2.0336 ms/op 2.5389 ms/op 0.80
pickEth1Vote - no votes 2.2119 ms/op 2.6315 ms/op 0.84
pickEth1Vote - max votes 20.629 ms/op 24.523 ms/op 0.84
pickEth1Vote - Eth1Data hashTreeRoot value x2048 11.114 ms/op 14.428 ms/op 0.77
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 20.571 ms/op 26.184 ms/op 0.79
pickEth1Vote - Eth1Data fastSerialize value x2048 1.6066 ms/op 1.9085 ms/op 0.84
pickEth1Vote - Eth1Data fastSerialize tree x2048 14.804 ms/op 17.885 ms/op 0.83
bytes32 toHexString 1.1230 us/op 1.3600 us/op 0.83
bytes32 Buffer.toString(hex) 713.00 ns/op 876.00 ns/op 0.81
bytes32 Buffer.toString(hex) from Uint8Array 978.00 ns/op 1.1930 us/op 0.82
bytes32 Buffer.toString(hex) + 0x 708.00 ns/op 870.00 ns/op 0.81
Object access 1 prop 0.39500 ns/op 0.47800 ns/op 0.83
Map access 1 prop 0.30200 ns/op 0.40000 ns/op 0.75
Object get x1000 17.020 ns/op 17.088 ns/op 1.00
Map get x1000 0.99700 ns/op 1.0080 ns/op 0.99
Object set x1000 120.22 ns/op 126.46 ns/op 0.95
Map set x1000 75.745 ns/op 89.343 ns/op 0.85
Return object 10000 times 0.36750 ns/op 0.43060 ns/op 0.85
Throw Error 10000 times 5.9355 us/op 7.2314 us/op 0.82
fastMsgIdFn sha256 / 200 bytes 4.3130 us/op 5.2730 us/op 0.82
fastMsgIdFn h32 xxhash / 200 bytes 584.00 ns/op 660.00 ns/op 0.88
fastMsgIdFn h64 xxhash / 200 bytes 816.00 ns/op 931.00 ns/op 0.88
fastMsgIdFn sha256 / 1000 bytes 13.139 us/op 17.035 us/op 0.77
fastMsgIdFn h32 xxhash / 1000 bytes 720.00 ns/op 832.00 ns/op 0.87
fastMsgIdFn h64 xxhash / 1000 bytes 886.00 ns/op 922.00 ns/op 0.96
fastMsgIdFn sha256 / 10000 bytes 112.35 us/op 148.28 us/op 0.76
fastMsgIdFn h32 xxhash / 10000 bytes 2.4000 us/op 2.8570 us/op 0.84
fastMsgIdFn h64 xxhash / 10000 bytes 1.7800 us/op 2.2020 us/op 0.81
enrSubnets - fastDeserialize 64 bits 2.9250 us/op 3.3670 us/op 0.87
enrSubnets - ssz BitVector 64 bits 819.00 ns/op 908.00 ns/op 0.90
enrSubnets - fastDeserialize 4 bits 434.00 ns/op 497.00 ns/op 0.87
enrSubnets - ssz BitVector 4 bits 822.00 ns/op 890.00 ns/op 0.92
prioritizePeers score -10:0 att 32-0.1 sync 2-0 98.311 us/op 130.28 us/op 0.75
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 123.16 us/op 181.89 us/op 0.68
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 226.13 us/op 315.44 us/op 0.72
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 482.49 us/op 544.43 us/op 0.89
prioritizePeers score 0:0 att 64-1 sync 4-1 451.70 us/op 591.46 us/op 0.76
RateTracker 1000000 limit, 1 obj count per request 194.39 ns/op 240.39 ns/op 0.81
RateTracker 1000000 limit, 2 obj count per request 144.32 ns/op 196.77 ns/op 0.73
RateTracker 1000000 limit, 4 obj count per request 121.94 ns/op 177.45 ns/op 0.69
RateTracker 1000000 limit, 8 obj count per request 110.27 ns/op 155.97 ns/op 0.71
RateTracker with prune 4.8900 us/op 5.8190 us/op 0.84
array of 16000 items push then shift 3.2020 us/op 5.4755 us/op 0.58
LinkedList of 16000 items push then shift 17.532 ns/op 22.182 ns/op 0.79
array of 16000 items push then pop 247.80 ns/op 272.21 ns/op 0.91
LinkedList of 16000 items push then pop 16.602 ns/op 19.823 ns/op 0.84
array of 24000 items push then shift 4.5605 us/op 8.4101 us/op 0.54
LinkedList of 24000 items push then shift 20.901 ns/op 22.063 ns/op 0.95
array of 24000 items push then pop 213.43 ns/op 263.20 ns/op 0.81
LinkedList of 24000 items push then pop 18.095 ns/op 21.461 ns/op 0.84
intersect bitArray bitLen 8 11.756 ns/op 13.736 ns/op 0.86
intersect array and set length 8 172.22 ns/op 227.41 ns/op 0.76
intersect bitArray bitLen 128 62.011 ns/op 74.827 ns/op 0.83
intersect array and set length 128 2.4509 us/op 2.6332 us/op 0.93
Buffer.concat 32 items 1.9450 ns/op 2.6130 ns/op 0.74
pass gossip attestations to forkchoice per slot 7.7005 ms/op 4.9057 ms/op 1.57
computeDeltas 5.4560 ms/op 6.0144 ms/op 0.91
computeProposerBoostScoreFromBalances 907.78 us/op 922.26 us/op 0.98
altair processAttestation - 250000 vs - 7PWei normalcase 3.7017 ms/op 5.6397 ms/op 0.66
altair processAttestation - 250000 vs - 7PWei worstcase 5.7774 ms/op 8.6437 ms/op 0.67
altair processAttestation - setStatus - 1/6 committees join 216.50 us/op 264.85 us/op 0.82
altair processAttestation - setStatus - 1/3 committees join 413.28 us/op 507.23 us/op 0.81
altair processAttestation - setStatus - 1/2 committees join 574.97 us/op 773.80 us/op 0.74
altair processAttestation - setStatus - 2/3 committees join 741.71 us/op 991.17 us/op 0.75
altair processAttestation - setStatus - 4/5 committees join 1.0247 ms/op 1.3991 ms/op 0.73
altair processAttestation - setStatus - 100% committees join 1.2035 ms/op 1.7224 ms/op 0.70
altair processBlock - 250000 vs - 7PWei normalcase 28.092 ms/op 34.806 ms/op 0.81
altair processBlock - 250000 vs - 7PWei normalcase hashState 41.144 ms/op 47.570 ms/op 0.86
altair processBlock - 250000 vs - 7PWei worstcase 78.109 ms/op 115.74 ms/op 0.67
altair processBlock - 250000 vs - 7PWei worstcase hashState 109.19 ms/op 124.54 ms/op 0.88
phase0 processBlock - 250000 vs - 7PWei normalcase 3.4819 ms/op 4.9403 ms/op 0.70
phase0 processBlock - 250000 vs - 7PWei worstcase 45.937 ms/op 60.052 ms/op 0.76
altair processEth1Data - 250000 vs - 7PWei normalcase 812.81 us/op 1.2626 ms/op 0.64
Tree 40 250000 create 800.39 ms/op 1.1945 s/op 0.67
Tree 40 250000 get(125000) 302.47 ns/op 371.96 ns/op 0.81
Tree 40 250000 set(125000) 2.8426 us/op 4.0476 us/op 0.70
Tree 40 250000 toArray() 33.053 ms/op 42.410 ms/op 0.78
Tree 40 250000 iterate all - toArray() + loop 33.692 ms/op 40.752 ms/op 0.83
Tree 40 250000 iterate all - get(i) 114.43 ms/op 145.98 ms/op 0.78
MutableVector 250000 create 17.925 ms/op 23.207 ms/op 0.77
MutableVector 250000 get(125000) 14.775 ns/op 15.328 ns/op 0.96
MutableVector 250000 set(125000) 662.45 ns/op 1.0265 us/op 0.65
MutableVector 250000 toArray() 7.5441 ms/op 8.5082 ms/op 0.89
MutableVector 250000 iterate all - toArray() + loop 7.8993 ms/op 8.9368 ms/op 0.88
MutableVector 250000 iterate all - get(i) 3.4378 ms/op 3.6026 ms/op 0.95
Array 250000 create 7.0850 ms/op 7.6602 ms/op 0.92
Array 250000 clone - spread 3.9506 ms/op 4.1724 ms/op 0.95
Array 250000 get(125000) 1.6270 ns/op 1.7700 ns/op 0.92
Array 250000 set(125000) 1.6240 ns/op 1.8860 ns/op 0.86
Array 250000 iterate all - loop 170.19 us/op 153.49 us/op 1.11
effectiveBalanceIncrements clone Uint8Array 300000 85.203 us/op 373.05 us/op 0.23
effectiveBalanceIncrements clone MutableVector 300000 691.00 ns/op 920.00 ns/op 0.75
effectiveBalanceIncrements rw all Uint8Array 300000 252.64 us/op 317.85 us/op 0.79
effectiveBalanceIncrements rw all MutableVector 300000 168.00 ms/op 264.34 ms/op 0.64
phase0 afterProcessEpoch - 250000 vs - 7PWei 184.80 ms/op 223.93 ms/op 0.83
phase0 beforeProcessEpoch - 250000 vs - 7PWei 72.194 ms/op 87.259 ms/op 0.83
altair processEpoch - mainnet_e81889 580.42 ms/op 715.39 ms/op 0.81
mainnet_e81889 - altair beforeProcessEpoch 152.98 ms/op 192.91 ms/op 0.79
mainnet_e81889 - altair processJustificationAndFinalization 21.575 us/op 68.126 us/op 0.32
mainnet_e81889 - altair processInactivityUpdates 10.602 ms/op 13.011 ms/op 0.81
mainnet_e81889 - altair processRewardsAndPenalties 90.732 ms/op 111.30 ms/op 0.82
mainnet_e81889 - altair processRegistryUpdates 3.6700 us/op 15.945 us/op 0.23
mainnet_e81889 - altair processSlashings 791.00 ns/op 4.4540 us/op 0.18
mainnet_e81889 - altair processEth1DataReset 818.00 ns/op 3.8330 us/op 0.21
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.4241 ms/op 2.9580 ms/op 0.82
mainnet_e81889 - altair processSlashingsReset 5.1600 us/op 27.699 us/op 0.19
mainnet_e81889 - altair processRandaoMixesReset 5.5010 us/op 23.508 us/op 0.23
mainnet_e81889 - altair processHistoricalRootsUpdate 807.00 ns/op 4.0280 us/op 0.20
mainnet_e81889 - altair processParticipationFlagUpdates 2.6940 us/op 16.394 us/op 0.16
mainnet_e81889 - altair processSyncCommitteeUpdates 667.00 ns/op 3.1710 us/op 0.21
mainnet_e81889 - altair afterProcessEpoch 195.76 ms/op 220.48 ms/op 0.89
phase0 processEpoch - mainnet_e58758 521.00 ms/op 635.43 ms/op 0.82
mainnet_e58758 - phase0 beforeProcessEpoch 226.97 ms/op 289.16 ms/op 0.78
mainnet_e58758 - phase0 processJustificationAndFinalization 19.954 us/op 66.200 us/op 0.30
mainnet_e58758 - phase0 processRewardsAndPenalties 135.74 ms/op 143.55 ms/op 0.95
mainnet_e58758 - phase0 processRegistryUpdates 9.9620 us/op 33.258 us/op 0.30
mainnet_e58758 - phase0 processSlashings 721.00 ns/op 2.8530 us/op 0.25
mainnet_e58758 - phase0 processEth1DataReset 727.00 ns/op 3.2360 us/op 0.22
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.1252 ms/op 2.1805 ms/op 0.97
mainnet_e58758 - phase0 processSlashingsReset 5.0590 us/op 15.247 us/op 0.33
mainnet_e58758 - phase0 processRandaoMixesReset 5.9420 us/op 26.856 us/op 0.22
mainnet_e58758 - phase0 processHistoricalRootsUpdate 814.00 ns/op 4.1070 us/op 0.20
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.4340 us/op 23.454 us/op 0.19
mainnet_e58758 - phase0 afterProcessEpoch 160.51 ms/op 188.83 ms/op 0.85
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.5438 ms/op 2.7515 ms/op 0.92
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 3.4720 ms/op 2.9189 ms/op 1.19
altair processInactivityUpdates - 250000 normalcase 38.833 ms/op 57.854 ms/op 0.67
altair processInactivityUpdates - 250000 worstcase 38.002 ms/op 56.430 ms/op 0.67
phase0 processRegistryUpdates - 250000 normalcase 8.2010 us/op 27.803 us/op 0.29
phase0 processRegistryUpdates - 250000 badcase_full_deposits 409.06 us/op 540.21 us/op 0.76
phase0 processRegistryUpdates - 250000 worstcase 0.5 203.89 ms/op 276.12 ms/op 0.74
altair processRewardsAndPenalties - 250000 normalcase 89.091 ms/op 155.61 ms/op 0.57
altair processRewardsAndPenalties - 250000 worstcase 102.38 ms/op 103.78 ms/op 0.99
phase0 getAttestationDeltas - 250000 normalcase 12.412 ms/op 15.512 ms/op 0.80
phase0 getAttestationDeltas - 250000 worstcase 12.320 ms/op 12.593 ms/op 0.98
phase0 processSlashings - 250000 worstcase 5.7582 ms/op 6.6947 ms/op 0.86
altair processSyncCommitteeUpdates - 250000 278.17 ms/op 337.26 ms/op 0.82
BeaconState.hashTreeRoot - No change 526.00 ns/op 623.00 ns/op 0.84
BeaconState.hashTreeRoot - 1 full validator 65.243 us/op 78.307 us/op 0.83
BeaconState.hashTreeRoot - 32 full validator 596.52 us/op 932.54 us/op 0.64
BeaconState.hashTreeRoot - 512 full validator 5.9292 ms/op 7.4954 ms/op 0.79
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 76.849 us/op 106.41 us/op 0.72
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.1766 ms/op 1.5379 ms/op 0.77
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 15.532 ms/op 19.239 ms/op 0.81
BeaconState.hashTreeRoot - 1 balances 62.481 us/op 80.140 us/op 0.78
BeaconState.hashTreeRoot - 32 balances 567.61 us/op 702.72 us/op 0.81
BeaconState.hashTreeRoot - 512 balances 5.9217 ms/op 7.0935 ms/op 0.83
BeaconState.hashTreeRoot - 250000 balances 90.997 ms/op 119.78 ms/op 0.76
aggregationBits - 2048 els - zipIndexesInBitList 28.188 us/op 30.292 us/op 0.93
regular array get 100000 times 67.441 us/op 57.484 us/op 1.17
wrappedArray get 100000 times 67.413 us/op 57.141 us/op 1.18
arrayWithProxy get 100000 times 28.894 ms/op 35.213 ms/op 0.82
ssz.Root.equals 481.00 ns/op 545.00 ns/op 0.88
byteArrayEquals 477.00 ns/op 572.00 ns/op 0.83
shuffle list - 16384 els 11.242 ms/op 12.279 ms/op 0.92
shuffle list - 250000 els 165.46 ms/op 175.17 ms/op 0.94
processSlot - 1 slots 12.341 us/op 17.404 us/op 0.71
processSlot - 32 slots 1.7141 ms/op 2.3752 ms/op 0.72
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 396.73 us/op 477.09 us/op 0.83
getCommitteeAssignments - req 1 vs - 250000 vc 5.3355 ms/op 5.4700 ms/op 0.98
getCommitteeAssignments - req 100 vs - 250000 vc 7.4465 ms/op 7.6391 ms/op 0.97
getCommitteeAssignments - req 1000 vs - 250000 vc 7.8374 ms/op 8.3653 ms/op 0.94
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 9.7900 ns/op 9.8100 ns/op 1.00
state getBlockRootAtSlot - 250000 vs - 7PWei 1.0973 us/op 1.3289 us/op 0.83
computeProposers - vc 250000 16.721 ms/op 22.573 ms/op 0.74
computeEpochShuffling - vc 250000 169.66 ms/op 177.12 ms/op 0.96
getNextSyncCommittee - vc 250000 275.45 ms/op 364.40 ms/op 0.76

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.

lgtm!

@twoeths
Copy link
Contributor Author

twoeths commented Nov 10, 2022

there are some failed tests that not related to this PR

@wemeetagain wemeetagain enabled auto-merge (squash) November 10, 2022 20:19
@wemeetagain wemeetagain merged commit 649a587 into unstable Nov 11, 2022
@wemeetagain wemeetagain deleted the tuyen/produce_block branch November 11, 2022 01:35
@twoeths twoeths mentioned this pull request Nov 11, 2022
wemeetagain added a commit that referenced this pull request Nov 11, 2022
* Produce block: ignore old attestations

* Skip flaky tests

Co-authored-by: Cayman <caymannava@gmail.com>
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.

None yet

3 participants