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

Fix TTD precision #4090

Merged
merged 2 commits into from
May 31, 2022
Merged

Fix TTD precision #4090

merged 2 commits into from
May 31, 2022

Conversation

dapplion
Copy link
Contributor

@dapplion dapplion commented May 31, 2022

Motivation

The number 100000000000000000000000 is over 53 bits, so the bits set to 1 over that get "clipped" and set to 0. Then the value that actually seen from JS is not 100000000000000000000000 but a bit less.

Description

Added the "no-loss-of-precision": "error" rule to prevent this from happening accidentally. However the rule doesn't seem to work.

  • Fix precision in TERMINAL_TOTAL_DIFFICULTY config
  • Ignore TERMINAL_TOTAL_DIFFICULTY in config check

@dapplion dapplion requested a review from a team as a code owner May 31, 2022 03:19
@dapplion dapplion force-pushed the dapplion/fix-ttd-precision branch from eee0d6e to 5969436 Compare May 31, 2022 03:22
@github-actions
Copy link
Contributor

github-actions bot commented May 31, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 1ae9adf Previous: 510f310 Ratio
BeaconState.hashTreeRoot - No change 824.00 ns/op 420.00 ns/op 1.96
BeaconState.hashTreeRoot - 1 full validator 78.285 us/op 55.337 us/op 1.41
BeaconState.hashTreeRoot - 32 full validator 745.27 us/op 545.76 us/op 1.37
BeaconState.hashTreeRoot - 512 full validator 8.0467 ms/op 5.9435 ms/op 1.35
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 98.636 us/op 70.046 us/op 1.41
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.3468 ms/op 951.10 us/op 1.42
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 18.103 ms/op 12.881 ms/op 1.41
BeaconState.hashTreeRoot - 1 balances 74.029 us/op 48.115 us/op 1.54
BeaconState.hashTreeRoot - 32 balances 631.93 us/op 464.34 us/op 1.36
BeaconState.hashTreeRoot - 512 balances 6.3023 ms/op 4.0975 ms/op 1.54
BeaconState.hashTreeRoot - 250000 balances 123.73 ms/op 90.674 ms/op 1.36
processSlot - 1 slots 15.732 us/op 9.2070 us/op 1.71
processSlot - 32 slots 2.2290 ms/op 1.3485 ms/op 1.65
getCommitteeAssignments - req 1 vs - 250000 vc 5.6783 ms/op 4.6565 ms/op 1.22
getCommitteeAssignments - req 100 vs - 250000 vc 8.3723 ms/op 6.4106 ms/op 1.31
getCommitteeAssignments - req 1000 vs - 250000 vc 8.5699 ms/op 6.9282 ms/op 1.24
computeProposers - vc 250000 20.157 ms/op 15.568 ms/op 1.29
computeEpochShuffling - vc 250000 188.02 ms/op 164.21 ms/op 1.14
getNextSyncCommittee - vc 250000 346.21 ms/op 256.69 ms/op 1.35
altair processAttestation - 250000 vs - 7PWei normalcase 5.2658 ms/op 3.3036 ms/op 1.59
altair processAttestation - 250000 vs - 7PWei worstcase 7.5995 ms/op 4.8726 ms/op 1.56
altair processAttestation - setStatus - 1/6 committees join 242.56 us/op 169.93 us/op 1.43
altair processAttestation - setStatus - 1/3 committees join 434.67 us/op 330.49 us/op 1.32
altair processAttestation - setStatus - 1/2 committees join 626.75 us/op 516.45 us/op 1.21
altair processAttestation - setStatus - 2/3 committees join 818.74 us/op 596.73 us/op 1.37
altair processAttestation - setStatus - 4/5 committees join 1.1603 ms/op 885.51 us/op 1.31
altair processAttestation - setStatus - 100% committees join 1.3759 ms/op 958.32 us/op 1.44
altair processBlock - 250000 vs - 7PWei normalcase 34.296 ms/op 21.823 ms/op 1.57
altair processBlock - 250000 vs - 7PWei normalcase hashState 44.236 ms/op 32.437 ms/op 1.36
altair processBlock - 250000 vs - 7PWei worstcase 91.020 ms/op 64.818 ms/op 1.40
altair processBlock - 250000 vs - 7PWei worstcase hashState 122.40 ms/op 96.834 ms/op 1.26
altair processEth1Data - 250000 vs - 7PWei normalcase 932.75 us/op 673.27 us/op 1.39
altair processEpoch - mainnet_e81889 671.04 ms/op 435.23 ms/op 1.54
mainnet_e81889 - altair beforeProcessEpoch 166.85 ms/op 132.24 ms/op 1.26
mainnet_e81889 - altair processJustificationAndFinalization 73.492 us/op 21.191 us/op 3.47
mainnet_e81889 - altair processInactivityUpdates 13.698 ms/op 9.5052 ms/op 1.44
mainnet_e81889 - altair processRewardsAndPenalties 158.87 ms/op 121.45 ms/op 1.31
mainnet_e81889 - altair processRegistryUpdates 16.706 us/op 3.4280 us/op 4.87
mainnet_e81889 - altair processSlashings 4.7280 us/op 838.00 ns/op 5.64
mainnet_e81889 - altair processEth1DataReset 5.1370 us/op 885.00 ns/op 5.80
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.8329 ms/op 2.5348 ms/op 1.12
mainnet_e81889 - altair processSlashingsReset 21.464 us/op 4.6120 us/op 4.65
mainnet_e81889 - altair processRandaoMixesReset 26.222 us/op 5.3080 us/op 4.94
mainnet_e81889 - altair processHistoricalRootsUpdate 4.7390 us/op 924.00 ns/op 5.13
mainnet_e81889 - altair processParticipationFlagUpdates 12.685 us/op 2.3250 us/op 5.46
mainnet_e81889 - altair processSyncCommitteeUpdates 4.2990 us/op 888.00 ns/op 4.84
mainnet_e81889 - altair afterProcessEpoch 218.41 ms/op 178.50 ms/op 1.22
altair processInactivityUpdates - 250000 normalcase 44.348 ms/op 31.012 ms/op 1.43
altair processInactivityUpdates - 250000 worstcase 37.518 ms/op 24.841 ms/op 1.51
altair processRewardsAndPenalties - 250000 normalcase 153.85 ms/op 121.09 ms/op 1.27
altair processRewardsAndPenalties - 250000 worstcase 118.94 ms/op 110.44 ms/op 1.08
altair processSyncCommitteeUpdates - 250000 362.26 ms/op 242.91 ms/op 1.49
Tree 40 250000 create 1.1492 s/op 662.64 ms/op 1.73
Tree 40 250000 get(125000) 340.41 ns/op 288.87 ns/op 1.18
Tree 40 250000 set(125000) 3.3834 us/op 2.2968 us/op 1.47
Tree 40 250000 toArray() 37.829 ms/op 31.037 ms/op 1.22
Tree 40 250000 iterate all - toArray() + loop 37.769 ms/op 31.469 ms/op 1.20
Tree 40 250000 iterate all - get(i) 141.95 ms/op 108.98 ms/op 1.30
MutableVector 250000 create 19.669 ms/op 13.973 ms/op 1.41
MutableVector 250000 get(125000) 14.468 ns/op 14.574 ns/op 0.99
MutableVector 250000 set(125000) 898.68 ns/op 646.24 ns/op 1.39
MutableVector 250000 toArray() 8.7888 ms/op 6.0223 ms/op 1.46
MutableVector 250000 iterate all - toArray() + loop 8.2951 ms/op 6.1865 ms/op 1.34
MutableVector 250000 iterate all - get(i) 3.3668 ms/op 3.0317 ms/op 1.11
Array 250000 create 7.7781 ms/op 5.8547 ms/op 1.33
Array 250000 clone - spread 4.6189 ms/op 2.3586 ms/op 1.96
Array 250000 get(125000) 2.1340 ns/op 1.1010 ns/op 1.94
Array 250000 set(125000) 2.0630 ns/op 1.1170 ns/op 1.85
Array 250000 iterate all - loop 153.91 us/op 169.22 us/op 0.91
effectiveBalanceIncrements clone Uint8Array 300000 139.82 us/op 61.243 us/op 2.28
effectiveBalanceIncrements clone MutableVector 300000 1.5610 us/op 741.00 ns/op 2.11
effectiveBalanceIncrements rw all Uint8Array 300000 302.40 us/op 252.52 us/op 1.20
effectiveBalanceIncrements rw all MutableVector 300000 330.43 ms/op 160.84 ms/op 2.05
aggregationBits - 2048 els - zipIndexesInBitList 44.567 us/op 25.993 us/op 1.71
regular array get 100000 times 58.327 us/op 67.406 us/op 0.87
wrappedArray get 100000 times 58.886 us/op 67.438 us/op 0.87
arrayWithProxy get 100000 times 36.238 ms/op 27.817 ms/op 1.30
ssz.Root.equals 622.00 ns/op 454.00 ns/op 1.37
byteArrayEquals 653.00 ns/op 450.00 ns/op 1.45
phase0 processBlock - 250000 vs - 7PWei normalcase 5.2231 ms/op 3.1956 ms/op 1.63
phase0 processBlock - 250000 vs - 7PWei worstcase 58.448 ms/op 44.269 ms/op 1.32
phase0 afterProcessEpoch - 250000 vs - 7PWei 206.69 ms/op 178.40 ms/op 1.16
phase0 beforeProcessEpoch - 250000 vs - 7PWei 82.419 ms/op 66.562 ms/op 1.24
phase0 processEpoch - mainnet_e58758 653.79 ms/op 478.25 ms/op 1.37
mainnet_e58758 - phase0 beforeProcessEpoch 323.67 ms/op 204.76 ms/op 1.58
mainnet_e58758 - phase0 processJustificationAndFinalization 63.097 us/op 20.632 us/op 3.06
mainnet_e58758 - phase0 processRewardsAndPenalties 91.846 ms/op 110.77 ms/op 0.83
mainnet_e58758 - phase0 processRegistryUpdates 33.410 us/op 9.1440 us/op 3.65
mainnet_e58758 - phase0 processSlashings 3.9660 us/op 848.00 ns/op 4.68
mainnet_e58758 - phase0 processEth1DataReset 3.8210 us/op 727.00 ns/op 5.26
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.1217 ms/op 1.7827 ms/op 1.19
mainnet_e58758 - phase0 processSlashingsReset 19.883 us/op 4.8510 us/op 4.10
mainnet_e58758 - phase0 processRandaoMixesReset 25.299 us/op 5.2970 us/op 4.78
mainnet_e58758 - phase0 processHistoricalRootsUpdate 4.9130 us/op 705.00 ns/op 6.97
mainnet_e58758 - phase0 processParticipationRecordUpdates 24.393 us/op 5.1840 us/op 4.71
mainnet_e58758 - phase0 afterProcessEpoch 172.96 ms/op 142.16 ms/op 1.22
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.4586 ms/op 2.9280 ms/op 0.84
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.6088 ms/op 2.5789 ms/op 1.01
phase0 processRegistryUpdates - 250000 normalcase 26.803 us/op 7.6110 us/op 3.52
phase0 processRegistryUpdates - 250000 badcase_full_deposits 519.94 us/op 360.48 us/op 1.44
phase0 processRegistryUpdates - 250000 worstcase 0.5 267.87 ms/op 199.15 ms/op 1.35
phase0 getAttestationDeltas - 250000 normalcase 14.504 ms/op 12.812 ms/op 1.13
phase0 getAttestationDeltas - 250000 worstcase 14.703 ms/op 13.471 ms/op 1.09
phase0 processSlashings - 250000 worstcase 6.9343 ms/op 4.8027 ms/op 1.44
shuffle list - 16384 els 12.202 ms/op 10.893 ms/op 1.12
shuffle list - 250000 els 183.69 ms/op 161.33 ms/op 1.14
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 451.48 us/op 417.53 us/op 1.08
pass gossip attestations to forkchoice per slot 4.6768 ms/op 2.8351 ms/op 1.65
computeDeltas 5.0248 ms/op 3.0290 ms/op 1.66
computeProposerBoostScoreFromBalances 918.14 us/op 872.04 us/op 1.05
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.9313 ms/op 1.6821 ms/op 1.74
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 92.254 us/op 71.623 us/op 1.29
BLS verify - blst-native 2.3501 ms/op 1.8569 ms/op 1.27
BLS verifyMultipleSignatures 3 - blst-native 4.6934 ms/op 3.8087 ms/op 1.23
BLS verifyMultipleSignatures 8 - blst-native 10.473 ms/op 8.1957 ms/op 1.28
BLS verifyMultipleSignatures 32 - blst-native 37.558 ms/op 29.667 ms/op 1.27
BLS aggregatePubkeys 32 - blst-native 49.216 us/op 39.317 us/op 1.25
BLS aggregatePubkeys 128 - blst-native 190.26 us/op 153.82 us/op 1.24
getAttestationsForBlock 70.220 ms/op 59.578 ms/op 1.18
isKnown best case - 1 super set check 663.00 ns/op 435.00 ns/op 1.52
isKnown normal case - 2 super set checks 632.00 ns/op 436.00 ns/op 1.45
isKnown worse case - 16 super set checks 618.00 ns/op 427.00 ns/op 1.45
CheckpointStateCache - add get delete 14.686 us/op 9.9580 us/op 1.47
validate gossip signedAggregateAndProof - struct 5.3230 ms/op 4.2581 ms/op 1.25
validate gossip attestation - struct 2.5196 ms/op 2.0270 ms/op 1.24
altair verifyImport mainnet_s3766816:31 7.7047 s/op 5.4834 s/op 1.41
pickEth1Vote - no votes 2.6014 ms/op 1.7993 ms/op 1.45
pickEth1Vote - max votes 34.084 ms/op 21.278 ms/op 1.60
pickEth1Vote - Eth1Data hashTreeRoot value x2048 15.772 ms/op 10.075 ms/op 1.57
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 29.076 ms/op 20.048 ms/op 1.45
pickEth1Vote - Eth1Data fastSerialize value x2048 1.9984 ms/op 1.4917 ms/op 1.34
pickEth1Vote - Eth1Data fastSerialize tree x2048 23.593 ms/op 10.862 ms/op 2.17
bytes32 toHexString 1.4300 us/op 826.00 ns/op 1.73
bytes32 Buffer.toString(hex) 888.00 ns/op 551.00 ns/op 1.61
bytes32 Buffer.toString(hex) from Uint8Array 1.1580 us/op 726.00 ns/op 1.60
bytes32 Buffer.toString(hex) + 0x 864.00 ns/op 574.00 ns/op 1.51
Object access 1 prop 0.49500 ns/op 0.27700 ns/op 1.79
Map access 1 prop 0.35600 ns/op 0.25700 ns/op 1.39
Object get x1000 17.746 ns/op 16.085 ns/op 1.10
Map get x1000 1.0600 ns/op 0.86600 ns/op 1.22
Object set x1000 138.26 ns/op 91.058 ns/op 1.52
Map set x1000 97.684 ns/op 54.730 ns/op 1.78
Return object 10000 times 0.44440 ns/op 0.32330 ns/op 1.37
Throw Error 10000 times 7.8106 us/op 5.0426 us/op 1.55
enrSubnets - fastDeserialize 64 bits 3.7250 us/op 2.0530 us/op 1.81
enrSubnets - ssz BitVector 64 bits 959.00 ns/op 588.00 ns/op 1.63
enrSubnets - fastDeserialize 4 bits 508.00 ns/op 299.00 ns/op 1.70
enrSubnets - ssz BitVector 4 bits 1.0010 us/op 600.00 ns/op 1.67
prioritizePeers score -10:0 att 32-0.1 sync 2-0 134.34 us/op 74.078 us/op 1.81
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 161.20 us/op 114.06 us/op 1.41
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 311.03 us/op 173.26 us/op 1.80
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 648.68 us/op 341.74 us/op 1.90
prioritizePeers score 0:0 att 64-1 sync 4-1 593.53 us/op 406.97 us/op 1.46
RateTracker 1000000 limit, 1 obj count per request 224.61 ns/op 153.15 ns/op 1.47
RateTracker 1000000 limit, 2 obj count per request 169.28 ns/op 116.29 ns/op 1.46
RateTracker 1000000 limit, 4 obj count per request 139.73 ns/op 96.061 ns/op 1.45
RateTracker 1000000 limit, 8 obj count per request 125.14 ns/op 85.247 ns/op 1.47
RateTracker with prune 7.0230 us/op 3.1770 us/op 2.21
array of 16000 items push then shift 5.2778 us/op 2.7250 us/op 1.94
LinkedList of 16000 items push then shift 31.535 ns/op 20.089 ns/op 1.57
array of 16000 items push then pop 289.30 ns/op 184.28 ns/op 1.57
LinkedList of 16000 items push then pop 27.092 ns/op 17.597 ns/op 1.54
array of 24000 items push then shift 8.2755 us/op 4.0085 us/op 2.06
LinkedList of 24000 items push then shift 31.546 ns/op 20.234 ns/op 1.56
array of 24000 items push then pop 263.23 ns/op 162.29 ns/op 1.62
LinkedList of 24000 items push then pop 26.388 ns/op 18.081 ns/op 1.46
intersect bitArray bitLen 8 12.737 ns/op 10.378 ns/op 1.23
intersect array and set length 8 197.35 ns/op 130.63 ns/op 1.51
intersect bitArray bitLen 128 75.397 ns/op 63.485 ns/op 1.19
intersect array and set length 128 2.4313 us/op 1.8309 us/op 1.33

by benchmarkbot/action

@dapplion dapplion enabled auto-merge (squash) May 31, 2022 03:50
@dapplion dapplion merged commit d5d3d6b into unstable May 31, 2022
@dapplion dapplion deleted the dapplion/fix-ttd-precision branch May 31, 2022 04:08
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