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

Run forkChoice to get correct head for proposal #4058

Merged
merged 3 commits into from
May 26, 2022

Conversation

g11tech
Copy link
Contributor

@g11tech g11tech commented May 25, 2022

Motivation
Run forkchoice update pre assembleBlock

Description
Runs updateTime and updateHead to process any queued attestations to find the correct head for the proposal slot.

Context Discussion/specs PR:
ethereum/consensus-specs#2878
ethereum/consensus-specs#2897

@g11tech g11tech requested a review from a team as a code owner May 25, 2022 10:19
@g11tech g11tech mentioned this pull request May 25, 2022
22 tasks
@github-actions
Copy link
Contributor

github-actions bot commented May 25, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 1a53a6b Previous: f4619af Ratio
BeaconState.hashTreeRoot - No change 422.00 ns/op 506.00 ns/op 0.83
BeaconState.hashTreeRoot - 1 full validator 55.760 us/op 68.512 us/op 0.81
BeaconState.hashTreeRoot - 32 full validator 546.30 us/op 636.28 us/op 0.86
BeaconState.hashTreeRoot - 512 full validator 6.1332 ms/op 7.0666 ms/op 0.87
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 71.416 us/op 82.872 us/op 0.86
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 963.47 us/op 1.1006 ms/op 0.88
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 11.884 ms/op 15.271 ms/op 0.78
BeaconState.hashTreeRoot - 1 balances 47.827 us/op 64.836 us/op 0.74
BeaconState.hashTreeRoot - 32 balances 421.42 us/op 573.20 us/op 0.74
BeaconState.hashTreeRoot - 512 balances 4.1494 ms/op 5.4720 ms/op 0.76
BeaconState.hashTreeRoot - 250000 balances 86.858 ms/op 115.08 ms/op 0.75
processSlot - 1 slots 9.4680 us/op 12.682 us/op 0.75
processSlot - 32 slots 1.3752 ms/op 1.9734 ms/op 0.70
getCommitteeAssignments - req 1 vs - 250000 vc 4.6371 ms/op 6.3139 ms/op 0.73
getCommitteeAssignments - req 100 vs - 250000 vc 6.4028 ms/op 8.7843 ms/op 0.73
getCommitteeAssignments - req 1000 vs - 250000 vc 6.8376 ms/op 9.3659 ms/op 0.73
computeProposers - vc 250000 14.236 ms/op 17.857 ms/op 0.80
computeEpochShuffling - vc 250000 146.36 ms/op 193.58 ms/op 0.76
getNextSyncCommittee - vc 250000 244.15 ms/op 314.50 ms/op 0.78
altair processAttestation - 250000 vs - 7PWei normalcase 3.4856 ms/op 4.2799 ms/op 0.81
altair processAttestation - 250000 vs - 7PWei worstcase 5.2438 ms/op 6.2925 ms/op 0.83
altair processAttestation - setStatus - 1/6 committees join 188.25 us/op 214.75 us/op 0.88
altair processAttestation - setStatus - 1/3 committees join 366.09 us/op 429.36 us/op 0.85
altair processAttestation - setStatus - 1/2 committees join 448.95 us/op 592.73 us/op 0.76
altair processAttestation - setStatus - 2/3 committees join 589.59 us/op 733.46 us/op 0.80
altair processAttestation - setStatus - 4/5 committees join 798.93 us/op 1.0585 ms/op 0.75
altair processAttestation - setStatus - 100% committees join 1.0806 ms/op 1.2946 ms/op 0.83
altair processBlock - 250000 vs - 7PWei normalcase 28.400 ms/op 28.586 ms/op 0.99
altair processBlock - 250000 vs - 7PWei normalcase hashState 35.057 ms/op 42.917 ms/op 0.82
altair processBlock - 250000 vs - 7PWei worstcase 67.266 ms/op 90.321 ms/op 0.74
altair processBlock - 250000 vs - 7PWei worstcase hashState 102.14 ms/op 109.91 ms/op 0.93
altair processEth1Data - 250000 vs - 7PWei normalcase 763.60 us/op 892.58 us/op 0.86
altair processEpoch - mainnet_e81889 520.82 ms/op 643.70 ms/op 0.81
mainnet_e81889 - altair beforeProcessEpoch 138.25 ms/op 153.13 ms/op 0.90
mainnet_e81889 - altair processJustificationAndFinalization 34.547 us/op 34.789 us/op 0.99
mainnet_e81889 - altair processInactivityUpdates 11.595 ms/op 13.300 ms/op 0.87
mainnet_e81889 - altair processRewardsAndPenalties 125.68 ms/op 152.63 ms/op 0.82
mainnet_e81889 - altair processRegistryUpdates 6.5300 us/op 6.8250 us/op 0.96
mainnet_e81889 - altair processSlashings 1.2920 us/op 2.1110 us/op 0.61
mainnet_e81889 - altair processEth1DataReset 1.2810 us/op 2.0330 us/op 0.63
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.5666 ms/op 3.3328 ms/op 0.77
mainnet_e81889 - altair processSlashingsReset 8.2830 us/op 9.3280 us/op 0.89
mainnet_e81889 - altair processRandaoMixesReset 9.6780 us/op 12.804 us/op 0.76
mainnet_e81889 - altair processHistoricalRootsUpdate 1.9320 us/op 1.8890 us/op 1.02
mainnet_e81889 - altair processParticipationFlagUpdates 7.2790 us/op 5.5870 us/op 1.30
mainnet_e81889 - altair processSyncCommitteeUpdates 1.3610 us/op 1.6800 us/op 0.81
mainnet_e81889 - altair afterProcessEpoch 170.23 ms/op 223.17 ms/op 0.76
altair processInactivityUpdates - 250000 normalcase 31.557 ms/op 38.407 ms/op 0.82
altair processInactivityUpdates - 250000 worstcase 26.348 ms/op 32.143 ms/op 0.82
altair processRewardsAndPenalties - 250000 normalcase 112.88 ms/op 153.33 ms/op 0.74
altair processRewardsAndPenalties - 250000 worstcase 103.20 ms/op 111.69 ms/op 0.92
altair processSyncCommitteeUpdates - 250000 250.52 ms/op 322.35 ms/op 0.78
Tree 40 250000 create 717.68 ms/op 891.95 ms/op 0.80
Tree 40 250000 get(125000) 262.06 ns/op 322.11 ns/op 0.81
Tree 40 250000 set(125000) 2.4098 us/op 2.4907 us/op 0.97
Tree 40 250000 toArray() 30.581 ms/op 37.195 ms/op 0.82
Tree 40 250000 iterate all - toArray() + loop 31.092 ms/op 37.333 ms/op 0.83
Tree 40 250000 iterate all - get(i) 101.18 ms/op 125.85 ms/op 0.80
MutableVector 250000 create 14.673 ms/op 17.417 ms/op 0.84
MutableVector 250000 get(125000) 11.530 ns/op 15.124 ns/op 0.76
MutableVector 250000 set(125000) 646.26 ns/op 704.33 ns/op 0.92
MutableVector 250000 toArray() 7.1277 ms/op 7.7358 ms/op 0.92
MutableVector 250000 iterate all - toArray() + loop 7.1902 ms/op 8.1732 ms/op 0.88
MutableVector 250000 iterate all - get(i) 3.4623 ms/op 4.0121 ms/op 0.86
Array 250000 create 6.2098 ms/op 6.9821 ms/op 0.89
Array 250000 clone - spread 2.0167 ms/op 3.8166 ms/op 0.53
Array 250000 get(125000) 0.94500 ns/op 1.6990 ns/op 0.56
Array 250000 set(125000) 0.94500 ns/op 1.6490 ns/op 0.57
Array 250000 iterate all - loop 145.90 us/op 194.10 us/op 0.75
effectiveBalanceIncrements clone Uint8Array 300000 60.950 us/op 93.104 us/op 0.65
effectiveBalanceIncrements clone MutableVector 300000 625.00 ns/op 1.2180 us/op 0.51
effectiveBalanceIncrements rw all Uint8Array 300000 221.44 us/op 291.23 us/op 0.76
effectiveBalanceIncrements rw all MutableVector 300000 154.95 ms/op 226.88 ms/op 0.68
aggregationBits - 2048 els - zipIndexesInBitList 26.559 us/op 35.704 us/op 0.74
regular array get 100000 times 59.254 us/op 77.715 us/op 0.76
wrappedArray get 100000 times 58.701 us/op 78.557 us/op 0.75
arrayWithProxy get 100000 times 26.057 ms/op 34.889 ms/op 0.75
ssz.Root.equals 401.00 ns/op 538.00 ns/op 0.75
byteArrayEquals 392.00 ns/op 574.00 ns/op 0.68
phase0 processBlock - 250000 vs - 7PWei normalcase 3.2559 ms/op 4.2421 ms/op 0.77
phase0 processBlock - 250000 vs - 7PWei worstcase 40.652 ms/op 53.405 ms/op 0.76
phase0 afterProcessEpoch - 250000 vs - 7PWei 161.40 ms/op 214.13 ms/op 0.75
phase0 beforeProcessEpoch - 250000 vs - 7PWei 72.566 ms/op 75.393 ms/op 0.96
phase0 processEpoch - mainnet_e58758 480.72 ms/op 589.63 ms/op 0.82
mainnet_e58758 - phase0 beforeProcessEpoch 225.23 ms/op 272.40 ms/op 0.83
mainnet_e58758 - phase0 processJustificationAndFinalization 32.672 us/op 41.055 us/op 0.80
mainnet_e58758 - phase0 processRewardsAndPenalties 121.88 ms/op 89.593 ms/op 1.36
mainnet_e58758 - phase0 processRegistryUpdates 14.390 us/op 23.748 us/op 0.61
mainnet_e58758 - phase0 processSlashings 1.2630 us/op 2.1910 us/op 0.58
mainnet_e58758 - phase0 processEth1DataReset 1.3160 us/op 2.0680 us/op 0.64
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.1641 ms/op 2.3518 ms/op 0.92
mainnet_e58758 - phase0 processSlashingsReset 9.1040 us/op 11.213 us/op 0.81
mainnet_e58758 - phase0 processRandaoMixesReset 7.9410 us/op 14.356 us/op 0.55
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.3810 us/op 2.4360 us/op 0.57
mainnet_e58758 - phase0 processParticipationRecordUpdates 8.1680 us/op 12.215 us/op 0.67
mainnet_e58758 - phase0 afterProcessEpoch 142.81 ms/op 176.61 ms/op 0.81
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.6773 ms/op 3.2776 ms/op 0.82
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.6791 ms/op 3.7571 ms/op 0.71
phase0 processRegistryUpdates - 250000 normalcase 13.807 us/op 20.498 us/op 0.67
phase0 processRegistryUpdates - 250000 badcase_full_deposits 513.26 us/op 595.25 us/op 0.86
phase0 processRegistryUpdates - 250000 worstcase 0.5 200.98 ms/op 236.44 ms/op 0.85
phase0 getAttestationDeltas - 250000 normalcase 12.816 ms/op 14.413 ms/op 0.89
phase0 getAttestationDeltas - 250000 worstcase 13.165 ms/op 14.420 ms/op 0.91
phase0 processSlashings - 250000 worstcase 4.7357 ms/op 6.5227 ms/op 0.73
shuffle list - 16384 els 9.7448 ms/op 12.527 ms/op 0.78
shuffle list - 250000 els 141.49 ms/op 185.50 ms/op 0.76
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 327.87 us/op 384.74 us/op 0.85
pass gossip attestations to forkchoice per slot 2.8994 ms/op 3.5797 ms/op 0.81
computeDeltas 3.4624 ms/op 3.9494 ms/op 0.88
computeProposerBoostScoreFromBalances 805.25 us/op 1.0566 ms/op 0.76
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.1256 ms/op 2.3354 ms/op 0.91
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 77.706 us/op 94.399 us/op 0.82
BLS verify - blst-native 1.6384 ms/op 2.1271 ms/op 0.77
BLS verifyMultipleSignatures 3 - blst-native 3.3666 ms/op 4.4113 ms/op 0.76
BLS verifyMultipleSignatures 8 - blst-native 7.2112 ms/op 9.4691 ms/op 0.76
BLS verifyMultipleSignatures 32 - blst-native 26.255 ms/op 34.150 ms/op 0.77
BLS aggregatePubkeys 32 - blst-native 35.530 us/op 44.497 us/op 0.80
BLS aggregatePubkeys 128 - blst-native 135.55 us/op 173.84 us/op 0.78
getAttestationsForBlock 60.664 ms/op 77.543 ms/op 0.78
isKnown best case - 1 super set check 390.00 ns/op 519.00 ns/op 0.75
isKnown normal case - 2 super set checks 377.00 ns/op 509.00 ns/op 0.74
isKnown worse case - 16 super set checks 377.00 ns/op 495.00 ns/op 0.76
CheckpointStateCache - add get delete 9.8570 us/op 12.877 us/op 0.77
validate gossip signedAggregateAndProof - struct 3.7124 ms/op 4.9566 ms/op 0.75
validate gossip attestation - struct 1.7906 ms/op 2.3282 ms/op 0.77
altair verifyImport mainnet_s3766816:31 5.5661 s/op 7.2082 s/op 0.77
pickEth1Vote - no votes 1.8633 ms/op 2.4548 ms/op 0.76
pickEth1Vote - max votes 25.184 ms/op 29.896 ms/op 0.84
pickEth1Vote - Eth1Data hashTreeRoot value x2048 10.424 ms/op 14.231 ms/op 0.73
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 21.549 ms/op 25.524 ms/op 0.84
pickEth1Vote - Eth1Data fastSerialize value x2048 1.4020 ms/op 1.9663 ms/op 0.71
pickEth1Vote - Eth1Data fastSerialize tree x2048 16.753 ms/op 18.992 ms/op 0.88
bytes32 toHexString 942.00 ns/op 1.1870 us/op 0.79
bytes32 Buffer.toString(hex) 652.00 ns/op 813.00 ns/op 0.80
bytes32 Buffer.toString(hex) from Uint8Array 824.00 ns/op 1.0680 us/op 0.77
bytes32 Buffer.toString(hex) + 0x 638.00 ns/op 808.00 ns/op 0.79
Object access 1 prop 0.32000 ns/op 0.42000 ns/op 0.76
Map access 1 prop 0.27100 ns/op 0.33500 ns/op 0.81
Object get x1000 15.198 ns/op 20.381 ns/op 0.75
Map get x1000 0.91200 ns/op 1.1410 ns/op 0.80
Object set x1000 102.38 ns/op 139.29 ns/op 0.74
Map set x1000 63.944 ns/op 83.426 ns/op 0.77
Return object 10000 times 0.32950 ns/op 0.43790 ns/op 0.75
Throw Error 10000 times 5.1009 us/op 6.8287 us/op 0.75
enrSubnets - fastDeserialize 64 bits 2.3780 us/op 3.0810 us/op 0.77
enrSubnets - ssz BitVector 64 bits 668.00 ns/op 898.00 ns/op 0.74
enrSubnets - fastDeserialize 4 bits 338.00 ns/op 466.00 ns/op 0.73
enrSubnets - ssz BitVector 4 bits 668.00 ns/op 853.00 ns/op 0.78
prioritizePeers score -10:0 att 32-0.1 sync 2-0 82.363 us/op 109.08 us/op 0.76
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 110.14 us/op 159.44 us/op 0.69
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 183.10 us/op 254.11 us/op 0.72
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 406.18 us/op 448.89 us/op 0.90
prioritizePeers score 0:0 att 64-1 sync 4-1 406.72 us/op 524.69 us/op 0.78
RateTracker 1000000 limit, 1 obj count per request 172.34 ns/op 214.53 ns/op 0.80
RateTracker 1000000 limit, 2 obj count per request 131.35 ns/op 164.35 ns/op 0.80
RateTracker 1000000 limit, 4 obj count per request 112.47 ns/op 136.74 ns/op 0.82
RateTracker 1000000 limit, 8 obj count per request 102.21 ns/op 124.77 ns/op 0.82
RateTracker with prune 4.2070 us/op 5.1760 us/op 0.81
array of 16000 items push then shift 2.8236 us/op 3.7115 us/op 0.76
LinkedList of 16000 items push then shift 25.999 ns/op 27.366 ns/op 0.95
array of 16000 items push then pop 229.41 ns/op 311.91 ns/op 0.74
LinkedList of 16000 items push then pop 20.894 ns/op 23.630 ns/op 0.88
array of 24000 items push then shift 4.0063 us/op 5.4140 us/op 0.74
LinkedList of 24000 items push then shift 24.957 ns/op 27.983 ns/op 0.89
array of 24000 items push then pop 172.79 ns/op 234.14 ns/op 0.74
LinkedList of 24000 items push then pop 21.499 ns/op 23.773 ns/op 0.90
intersect bitArray bitLen 8 10.146 ns/op 14.064 ns/op 0.72
intersect array and set length 8 144.35 ns/op 206.46 ns/op 0.70
intersect bitArray bitLen 128 61.869 ns/op 74.275 ns/op 0.83
intersect array and set length 128 1.9948 us/op 2.7633 us/op 0.72

by benchmarkbot/action

// Process the queued attestations in the forkchoice for correct head estimation
// forkChoice.updateTime() might have already been called by the onSlot clock
// handler, in which case this should just return.
chain.forkChoice.updateTime(slot);
Copy link
Contributor

Choose a reason for hiding this comment

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

calling forkChoice.updateTime() multiple times would calling processAttestationQueue() multiple times.

I think we should do early return in forkChoice.updateTime(slot) if this.fcStore.currentSlot >= slot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, updating! 👍

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.

2 participants