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

Populate eth1 deposit cache with remote follow distance timed based #4111

Merged
merged 1 commit into from
Jun 3, 2022

Conversation

dapplion
Copy link
Contributor

@dapplion dapplion commented Jun 3, 2022

Motivation

Description

Make ETH1_FOLLOW_DISTANCE dynamic, bounded by spec value config.ETH1_FOLLOW_DISTANCE and ETH_MIN_FOLLOW_DISTANCE.

If the block fetcher detects that the timestamp of the downloaded block differs from the expected value, it will increase or reduce ETH1_FOLLOW_DISTANCE with educated guesses iteratively.

Closes #4109

@github-actions
Copy link
Contributor

github-actions bot commented Jun 3, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 3d61521 Previous: 86b95a7 Ratio
BeaconState.hashTreeRoot - No change 521.00 ns/op 515.00 ns/op 1.01
BeaconState.hashTreeRoot - 1 full validator 65.116 us/op 65.796 us/op 0.99
BeaconState.hashTreeRoot - 32 full validator 652.87 us/op 660.50 us/op 0.99
BeaconState.hashTreeRoot - 512 full validator 7.1097 ms/op 7.3084 ms/op 0.97
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 84.938 us/op 79.745 us/op 1.07
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.1430 ms/op 1.0972 ms/op 1.04
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 15.341 ms/op 15.323 ms/op 1.00
BeaconState.hashTreeRoot - 1 balances 63.925 us/op 62.076 us/op 1.03
BeaconState.hashTreeRoot - 32 balances 546.95 us/op 548.87 us/op 1.00
BeaconState.hashTreeRoot - 512 balances 5.5748 ms/op 5.3819 ms/op 1.04
BeaconState.hashTreeRoot - 250000 balances 122.26 ms/op 116.03 ms/op 1.05
processSlot - 1 slots 12.722 us/op 12.942 us/op 0.98
processSlot - 32 slots 1.8605 ms/op 1.9841 ms/op 0.94
getCommitteeAssignments - req 1 vs - 250000 vc 6.3353 ms/op 6.2772 ms/op 1.01
getCommitteeAssignments - req 100 vs - 250000 vc 8.6665 ms/op 8.6507 ms/op 1.00
getCommitteeAssignments - req 1000 vs - 250000 vc 9.3044 ms/op 9.1810 ms/op 1.01
computeProposers - vc 250000 18.842 ms/op 19.107 ms/op 0.99
computeEpochShuffling - vc 250000 195.57 ms/op 210.06 ms/op 0.93
getNextSyncCommittee - vc 250000 308.13 ms/op 309.98 ms/op 0.99
altair processAttestation - 250000 vs - 7PWei normalcase 4.1115 ms/op 4.7383 ms/op 0.87
altair processAttestation - 250000 vs - 7PWei worstcase 5.9070 ms/op 6.3026 ms/op 0.94
altair processAttestation - setStatus - 1/6 committees join 219.69 us/op 227.32 us/op 0.97
altair processAttestation - setStatus - 1/3 committees join 436.77 us/op 441.80 us/op 0.99
altair processAttestation - setStatus - 1/2 committees join 609.73 us/op 596.45 us/op 1.02
altair processAttestation - setStatus - 2/3 committees join 785.13 us/op 828.06 us/op 0.95
altair processAttestation - setStatus - 4/5 committees join 1.0675 ms/op 1.0903 ms/op 0.98
altair processAttestation - setStatus - 100% committees join 1.2709 ms/op 1.3160 ms/op 0.97
altair processBlock - 250000 vs - 7PWei normalcase 38.670 ms/op 30.952 ms/op 1.25
altair processBlock - 250000 vs - 7PWei normalcase hashState 41.446 ms/op 40.485 ms/op 1.02
altair processBlock - 250000 vs - 7PWei worstcase 86.091 ms/op 85.306 ms/op 1.01
altair processBlock - 250000 vs - 7PWei worstcase hashState 115.27 ms/op 126.02 ms/op 0.91
altair processEth1Data - 250000 vs - 7PWei normalcase 759.60 us/op 909.56 us/op 0.84
altair processEpoch - mainnet_e81889 653.74 ms/op 651.49 ms/op 1.00
mainnet_e81889 - altair beforeProcessEpoch 149.08 ms/op 157.90 ms/op 0.94
mainnet_e81889 - altair processJustificationAndFinalization 51.147 us/op 33.658 us/op 1.52
mainnet_e81889 - altair processInactivityUpdates 12.154 ms/op 13.104 ms/op 0.93
mainnet_e81889 - altair processRewardsAndPenalties 149.78 ms/op 104.28 ms/op 1.44
mainnet_e81889 - altair processRegistryUpdates 7.9860 us/op 7.5380 us/op 1.06
mainnet_e81889 - altair processSlashings 2.6600 us/op 2.2950 us/op 1.16
mainnet_e81889 - altair processEth1DataReset 2.5890 us/op 2.3240 us/op 1.11
mainnet_e81889 - altair processEffectiveBalanceUpdates 3.3967 ms/op 2.7126 ms/op 1.25
mainnet_e81889 - altair processSlashingsReset 13.568 us/op 10.037 us/op 1.35
mainnet_e81889 - altair processRandaoMixesReset 12.790 us/op 13.174 us/op 0.97
mainnet_e81889 - altair processHistoricalRootsUpdate 2.3620 us/op 2.1010 us/op 1.12
mainnet_e81889 - altair processParticipationFlagUpdates 7.1690 us/op 6.1290 us/op 1.17
mainnet_e81889 - altair processSyncCommitteeUpdates 2.5970 us/op 1.8440 us/op 1.41
mainnet_e81889 - altair afterProcessEpoch 227.13 ms/op 226.60 ms/op 1.00
altair processInactivityUpdates - 250000 normalcase 37.192 ms/op 38.096 ms/op 0.98
altair processInactivityUpdates - 250000 worstcase 31.321 ms/op 31.543 ms/op 0.99
altair processRewardsAndPenalties - 250000 normalcase 146.62 ms/op 99.393 ms/op 1.48
altair processRewardsAndPenalties - 250000 worstcase 113.87 ms/op 93.426 ms/op 1.22
altair processSyncCommitteeUpdates - 250000 322.82 ms/op 333.86 ms/op 0.97
Tree 40 250000 create 839.25 ms/op 975.02 ms/op 0.86
Tree 40 250000 get(125000) 332.82 ns/op 340.98 ns/op 0.98
Tree 40 250000 set(125000) 2.8476 us/op 3.1945 us/op 0.89
Tree 40 250000 toArray() 36.288 ms/op 37.672 ms/op 0.96
Tree 40 250000 iterate all - toArray() + loop 36.765 ms/op 37.941 ms/op 0.97
Tree 40 250000 iterate all - get(i) 131.81 ms/op 133.60 ms/op 0.99
MutableVector 250000 create 17.620 ms/op 23.223 ms/op 0.76
MutableVector 250000 get(125000) 15.620 ns/op 16.242 ns/op 0.96
MutableVector 250000 set(125000) 741.10 ns/op 877.98 ns/op 0.84
MutableVector 250000 toArray() 8.0083 ms/op 8.5196 ms/op 0.94
MutableVector 250000 iterate all - toArray() + loop 7.1190 ms/op 8.7385 ms/op 0.81
MutableVector 250000 iterate all - get(i) 3.8886 ms/op 3.9928 ms/op 0.97
Array 250000 create 6.4742 ms/op 7.6094 ms/op 0.85
Array 250000 clone - spread 2.7120 ms/op 4.0493 ms/op 0.67
Array 250000 get(125000) 1.2710 ns/op 1.8290 ns/op 0.69
Array 250000 set(125000) 1.2780 ns/op 1.7980 ns/op 0.71
Array 250000 iterate all - loop 199.20 us/op 201.35 us/op 0.99
effectiveBalanceIncrements clone Uint8Array 300000 84.782 us/op 114.41 us/op 0.74
effectiveBalanceIncrements clone MutableVector 300000 772.00 ns/op 869.00 ns/op 0.89
effectiveBalanceIncrements rw all Uint8Array 300000 293.81 us/op 303.03 us/op 0.97
effectiveBalanceIncrements rw all MutableVector 300000 185.07 ms/op 210.38 ms/op 0.88
aggregationBits - 2048 els - zipIndexesInBitList 29.385 us/op 32.846 us/op 0.89
regular array get 100000 times 80.108 us/op 80.877 us/op 0.99
wrappedArray get 100000 times 79.788 us/op 81.040 us/op 0.98
arrayWithProxy get 100000 times 40.806 ms/op 45.026 ms/op 0.91
ssz.Root.equals 514.00 ns/op 607.00 ns/op 0.85
byteArrayEquals 547.00 ns/op 618.00 ns/op 0.89
phase0 processBlock - 250000 vs - 7PWei normalcase 3.9405 ms/op 4.1795 ms/op 0.94
phase0 processBlock - 250000 vs - 7PWei worstcase 53.081 ms/op 53.770 ms/op 0.99
phase0 afterProcessEpoch - 250000 vs - 7PWei 214.72 ms/op 220.68 ms/op 0.97
phase0 beforeProcessEpoch - 250000 vs - 7PWei 76.709 ms/op 79.551 ms/op 0.96
phase0 processEpoch - mainnet_e58758 579.68 ms/op 666.93 ms/op 0.87
mainnet_e58758 - phase0 beforeProcessEpoch 266.87 ms/op 258.91 ms/op 1.03
mainnet_e58758 - phase0 processJustificationAndFinalization 34.935 us/op 34.877 us/op 1.00
mainnet_e58758 - phase0 processRewardsAndPenalties 81.441 ms/op 83.616 ms/op 0.97
mainnet_e58758 - phase0 processRegistryUpdates 23.800 us/op 18.388 us/op 1.29
mainnet_e58758 - phase0 processSlashings 2.4510 us/op 2.7160 us/op 0.90
mainnet_e58758 - phase0 processEth1DataReset 2.3520 us/op 2.0120 us/op 1.17
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.3524 ms/op 2.4321 ms/op 0.97
mainnet_e58758 - phase0 processSlashingsReset 12.257 us/op 9.3210 us/op 1.31
mainnet_e58758 - phase0 processRandaoMixesReset 16.018 us/op 12.438 us/op 1.29
mainnet_e58758 - phase0 processHistoricalRootsUpdate 3.1150 us/op 2.5550 us/op 1.22
mainnet_e58758 - phase0 processParticipationRecordUpdates 13.679 us/op 13.797 us/op 0.99
mainnet_e58758 - phase0 afterProcessEpoch 189.02 ms/op 195.10 ms/op 0.97
phase0 processEffectiveBalanceUpdates - 250000 normalcase 3.5019 ms/op 3.5495 ms/op 0.99
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 3.6841 ms/op 3.6973 ms/op 1.00
phase0 processRegistryUpdates - 250000 normalcase 18.329 us/op 13.942 us/op 1.31
phase0 processRegistryUpdates - 250000 badcase_full_deposits 597.16 us/op 505.10 us/op 1.18
phase0 processRegistryUpdates - 250000 worstcase 0.5 273.10 ms/op 278.81 ms/op 0.98
phase0 getAttestationDeltas - 250000 normalcase 14.966 ms/op 17.523 ms/op 0.85
phase0 getAttestationDeltas - 250000 worstcase 15.246 ms/op 17.899 ms/op 0.85
phase0 processSlashings - 250000 worstcase 6.4639 ms/op 6.4321 ms/op 1.00
shuffle list - 16384 els 13.048 ms/op 13.133 ms/op 0.99
shuffle list - 250000 els 191.38 ms/op 192.99 ms/op 0.99
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 431.51 us/op 433.91 us/op 0.99
pass gossip attestations to forkchoice per slot 3.8249 ms/op 3.8408 ms/op 1.00
computeDeltas 3.5482 ms/op 3.6020 ms/op 0.99
computeProposerBoostScoreFromBalances 1.0922 ms/op 1.1210 ms/op 0.97
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.3068 ms/op 2.5824 ms/op 0.89
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 97.631 us/op 111.94 us/op 0.87
BLS verify - blst-native 2.2312 ms/op 2.2240 ms/op 1.00
BLS verifyMultipleSignatures 3 - blst-native 4.5542 ms/op 4.5386 ms/op 1.00
BLS verifyMultipleSignatures 8 - blst-native 9.8360 ms/op 9.7893 ms/op 1.00
BLS verifyMultipleSignatures 32 - blst-native 35.606 ms/op 35.034 ms/op 1.02
BLS aggregatePubkeys 32 - blst-native 47.679 us/op 46.239 us/op 1.03
BLS aggregatePubkeys 128 - blst-native 183.33 us/op 179.38 us/op 1.02
getAttestationsForBlock 62.647 ms/op 82.324 ms/op 0.76
isKnown best case - 1 super set check 515.00 ns/op 524.00 ns/op 0.98
isKnown normal case - 2 super set checks 509.00 ns/op 525.00 ns/op 0.97
isKnown worse case - 16 super set checks 505.00 ns/op 526.00 ns/op 0.96
CheckpointStateCache - add get delete 11.892 us/op 12.250 us/op 0.97
validate gossip signedAggregateAndProof - struct 5.0581 ms/op 4.9065 ms/op 1.03
validate gossip attestation - struct 2.4038 ms/op 2.3180 ms/op 1.04
altair verifyImport mainnet_s3766816:31 7.2299 s/op 7.3280 s/op 0.99
pickEth1Vote - no votes 2.4113 ms/op 2.5187 ms/op 0.96
pickEth1Vote - max votes 27.340 ms/op 29.992 ms/op 0.91
pickEth1Vote - Eth1Data hashTreeRoot value x2048 13.294 ms/op 14.832 ms/op 0.90
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 24.309 ms/op 28.578 ms/op 0.85
pickEth1Vote - Eth1Data fastSerialize value x2048 1.7267 ms/op 1.8334 ms/op 0.94
pickEth1Vote - Eth1Data fastSerialize tree x2048 19.162 ms/op 21.276 ms/op 0.90
bytes32 toHexString 1.2160 us/op 1.3660 us/op 0.89
bytes32 Buffer.toString(hex) 798.00 ns/op 851.00 ns/op 0.94
bytes32 Buffer.toString(hex) from Uint8Array 1.0770 us/op 1.1050 us/op 0.97
bytes32 Buffer.toString(hex) + 0x 782.00 ns/op 856.00 ns/op 0.91
Object access 1 prop 0.41000 ns/op 0.47500 ns/op 0.86
Map access 1 prop 0.34300 ns/op 0.36100 ns/op 0.95
Object get x1000 20.818 ns/op 21.542 ns/op 0.97
Map get x1000 1.1770 ns/op 1.2450 ns/op 0.95
Object set x1000 133.51 ns/op 141.30 ns/op 0.94
Map set x1000 79.085 ns/op 88.881 ns/op 0.89
Return object 10000 times 0.44880 ns/op 0.45030 ns/op 1.00
Throw Error 10000 times 6.9052 us/op 6.9518 us/op 0.99
enrSubnets - fastDeserialize 64 bits 3.0620 us/op 3.3340 us/op 0.92
enrSubnets - ssz BitVector 64 bits 891.00 ns/op 957.00 ns/op 0.93
enrSubnets - fastDeserialize 4 bits 432.00 ns/op 505.00 ns/op 0.86
enrSubnets - ssz BitVector 4 bits 876.00 ns/op 921.00 ns/op 0.95
prioritizePeers score -10:0 att 32-0.1 sync 2-0 105.94 us/op 122.95 us/op 0.86
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 143.09 us/op 165.28 us/op 0.87
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 242.33 us/op 278.93 us/op 0.87
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 536.72 us/op 455.75 us/op 1.18
prioritizePeers score 0:0 att 64-1 sync 4-1 542.59 us/op 547.81 us/op 0.99
RateTracker 1000000 limit, 1 obj count per request 233.25 ns/op 230.06 ns/op 1.01
RateTracker 1000000 limit, 2 obj count per request 178.90 ns/op 175.22 ns/op 1.02
RateTracker 1000000 limit, 4 obj count per request 149.70 ns/op 146.08 ns/op 1.02
RateTracker 1000000 limit, 8 obj count per request 135.77 ns/op 133.36 ns/op 1.02
RateTracker with prune 4.9890 us/op 5.7440 us/op 0.87
array of 16000 items push then shift 3.7389 us/op 3.7519 us/op 1.00
LinkedList of 16000 items push then shift 26.675 ns/op 28.946 ns/op 0.92
array of 16000 items push then pop 266.68 ns/op 266.81 ns/op 1.00
LinkedList of 16000 items push then pop 23.117 ns/op 23.583 ns/op 0.98
array of 24000 items push then shift 5.3350 us/op 5.4226 us/op 0.98
LinkedList of 24000 items push then shift 26.140 ns/op 29.516 ns/op 0.89
array of 24000 items push then pop 217.99 ns/op 251.06 ns/op 0.87
LinkedList of 24000 items push then pop 23.625 ns/op 24.650 ns/op 0.96
intersect bitArray bitLen 8 13.907 ns/op 13.915 ns/op 1.00
intersect array and set length 8 188.06 ns/op 213.87 ns/op 0.88
intersect bitArray bitLen 128 73.911 ns/op 86.012 ns/op 0.86
intersect array and set length 128 2.5564 us/op 2.8186 us/op 0.91

by benchmarkbot/action

@dapplion
Copy link
Contributor Author

dapplion commented Jun 3, 2022

Before this PR

Screenshot from 2022-06-03 19-34-57

Last fetched block timestamp is out of the range we need to correctly vote

With this PR

Screenshot from 2022-06-03 19-50-55

Last fetched block is in the range (above counts), so we can correctly vote

Screenshot from 2022-06-03 19-52-02

The dynamic follow distance is ~640, which is a correct guess. Average block times in 44 sec, while the assumed time is 14.

  • 2048 / 640 = 3.2
  • 44 / 14 = 3.14

@dapplion dapplion marked this pull request as ready for review June 3, 2022 12:56
@dapplion dapplion requested a review from a team as a code owner June 3, 2022 12:56
@dapplion dapplion enabled auto-merge (squash) June 3, 2022 12:57
@dapplion dapplion merged commit 2f0c2d7 into unstable Jun 3, 2022
@dapplion dapplion deleted the dapplion/eth1-cache-time-based-simpler branch June 3, 2022 13:18
@dapplion
Copy link
Contributor Author

dapplion commented Jun 4, 2022

After running for ~24h some more metrics that showcase correct behavior of this PR when deployed:

Screenshot from 2022-06-04 13-32-23

Also nice to double check that the block time estimation is correct

Screenshot from 2022-06-04 13-46-43

wemeetagain added a commit that referenced this pull request Jun 7, 2022
* v0.38.0

* Populate eth1 deposit cache with remote follow distance timed based (#4111)

* Fix HttpClient event handler leak (#4107)

Fix leak in signalGlobal event listeners

* Add Eth1DepositTracker metrics (#4110)

* Add Eth1DepositTracker metrics

* Add Eth1DepositTracker metrics

* Remove duplicate line

* Fix publish stable workflow (#4130)

Co-authored-by: harkamal <gajinder@g11.in>
Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.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.

eth1 deposit tracker cache populate flawed in slow networks
2 participants