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

Added the eslint rule to help with import order and ran the fix #3885

Merged
merged 10 commits into from
May 27, 2022

Conversation

dadepo
Copy link
Contributor

@dadepo dadepo commented Apr 5, 2022

Motivation

In a previous PR it was pointed out that the preferred order for imports should be:

  1. Non-chainsafe modules
  2. @ chainsafe modules
  3. Local paths

This PR enforces this via eslint to make it more applicable. It also updates existing import to adhere with the import rule

@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 618f214 Previous: 7f7ef80 Ratio
BeaconState.hashTreeRoot - No change 626.00 ns/op 551.00 ns/op 1.14
BeaconState.hashTreeRoot - 1 full validator 75.176 us/op 77.958 us/op 0.96
BeaconState.hashTreeRoot - 32 full validator 715.93 us/op 781.65 us/op 0.92
BeaconState.hashTreeRoot - 512 full validator 7.8042 ms/op 8.6023 ms/op 0.91
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 98.081 us/op 103.03 us/op 0.95
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.2930 ms/op 1.3774 ms/op 0.94
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 17.391 ms/op 19.412 ms/op 0.90
BeaconState.hashTreeRoot - 1 balances 71.660 us/op 75.473 us/op 0.95
BeaconState.hashTreeRoot - 32 balances 619.25 us/op 645.75 us/op 0.96
BeaconState.hashTreeRoot - 512 balances 5.9938 ms/op 6.4602 ms/op 0.93
BeaconState.hashTreeRoot - 250000 balances 131.65 ms/op 140.83 ms/op 0.93
processSlot - 1 slots 15.757 us/op 16.330 us/op 0.96
processSlot - 32 slots 2.1443 ms/op 2.2682 ms/op 0.95
getCommitteeAssignments - req 1 vs - 250000 vc 5.4832 ms/op 5.7924 ms/op 0.95
getCommitteeAssignments - req 100 vs - 250000 vc 7.9972 ms/op 8.1033 ms/op 0.99
getCommitteeAssignments - req 1000 vs - 250000 vc 8.6492 ms/op 8.6228 ms/op 1.00
computeProposers - vc 250000 20.992 ms/op 21.281 ms/op 0.99
computeEpochShuffling - vc 250000 186.41 ms/op 190.27 ms/op 0.98
getNextSyncCommittee - vc 250000 357.11 ms/op 350.66 ms/op 1.02
altair processAttestation - 250000 vs - 7PWei normalcase 5.3892 ms/op 5.1280 ms/op 1.05
altair processAttestation - 250000 vs - 7PWei worstcase 7.3769 ms/op 7.2564 ms/op 1.02
altair processAttestation - setStatus - 1/6 committees join 224.33 us/op 237.96 us/op 0.94
altair processAttestation - setStatus - 1/3 committees join 440.59 us/op 449.18 us/op 0.98
altair processAttestation - setStatus - 1/2 committees join 649.36 us/op 627.13 us/op 1.04
altair processAttestation - setStatus - 2/3 committees join 772.88 us/op 841.70 us/op 0.92
altair processAttestation - setStatus - 4/5 committees join 1.1047 ms/op 1.1764 ms/op 0.94
altair processAttestation - setStatus - 100% committees join 1.3587 ms/op 1.4324 ms/op 0.95
altair processBlock - 250000 vs - 7PWei normalcase 33.132 ms/op 29.702 ms/op 1.12
altair processBlock - 250000 vs - 7PWei normalcase hashState 44.510 ms/op 50.895 ms/op 0.87
altair processBlock - 250000 vs - 7PWei worstcase 91.139 ms/op 97.904 ms/op 0.93
altair processBlock - 250000 vs - 7PWei worstcase hashState 122.79 ms/op 131.98 ms/op 0.93
altair processEth1Data - 250000 vs - 7PWei normalcase 1.1455 ms/op 1.3319 ms/op 0.86
altair processEpoch - mainnet_e81889 662.34 ms/op 665.76 ms/op 0.99
mainnet_e81889 - altair beforeProcessEpoch 121.70 ms/op 174.68 ms/op 0.70
mainnet_e81889 - altair processJustificationAndFinalization 70.647 us/op 67.354 us/op 1.05
mainnet_e81889 - altair processInactivityUpdates 13.190 ms/op 12.433 ms/op 1.06
mainnet_e81889 - altair processRewardsAndPenalties 173.46 ms/op 154.21 ms/op 1.12
mainnet_e81889 - altair processRegistryUpdates 15.120 us/op 13.863 us/op 1.09
mainnet_e81889 - altair processSlashings 4.3230 us/op 4.8110 us/op 0.90
mainnet_e81889 - altair processEth1DataReset 4.3750 us/op 4.9120 us/op 0.89
mainnet_e81889 - altair processEffectiveBalanceUpdates 3.0443 ms/op 4.5243 ms/op 0.67
mainnet_e81889 - altair processSlashingsReset 20.266 us/op 21.683 us/op 0.93
mainnet_e81889 - altair processRandaoMixesReset 24.871 us/op 25.787 us/op 0.96
mainnet_e81889 - altair processHistoricalRootsUpdate 5.0660 us/op 4.4630 us/op 1.14
mainnet_e81889 - altair processParticipationFlagUpdates 12.648 us/op 15.730 us/op 0.80
mainnet_e81889 - altair processSyncCommitteeUpdates 4.0060 us/op 4.0350 us/op 0.99
mainnet_e81889 - altair afterProcessEpoch 225.57 ms/op 223.11 ms/op 1.01
altair processInactivityUpdates - 250000 normalcase 45.383 ms/op 43.957 ms/op 1.03
altair processInactivityUpdates - 250000 worstcase 37.925 ms/op 47.820 ms/op 0.79
altair processRewardsAndPenalties - 250000 normalcase 153.68 ms/op 130.08 ms/op 1.18
altair processRewardsAndPenalties - 250000 worstcase 136.49 ms/op 123.50 ms/op 1.11
altair processSyncCommitteeUpdates - 250000 365.65 ms/op 363.76 ms/op 1.01
Tree 40 250000 create 909.95 ms/op 1.3439 s/op 0.68
Tree 40 250000 get(125000) 338.58 ns/op 325.18 ns/op 1.04
Tree 40 250000 set(125000) 3.2118 us/op 3.5358 us/op 0.91
Tree 40 250000 toArray() 38.533 ms/op 35.596 ms/op 1.08
Tree 40 250000 iterate all - toArray() + loop 38.845 ms/op 35.680 ms/op 1.09
Tree 40 250000 iterate all - get(i) 138.95 ms/op 132.00 ms/op 1.05
MutableVector 250000 create 18.188 ms/op 17.401 ms/op 1.05
MutableVector 250000 get(125000) 14.741 ns/op 14.615 ns/op 1.01
MutableVector 250000 set(125000) 942.96 ns/op 961.96 ns/op 0.98
MutableVector 250000 toArray() 7.4545 ms/op 7.7093 ms/op 0.97
MutableVector 250000 iterate all - toArray() + loop 7.8031 ms/op 7.9307 ms/op 0.98
MutableVector 250000 iterate all - get(i) 3.6377 ms/op 3.6181 ms/op 1.01
Array 250000 create 11.497 ms/op 7.4011 ms/op 1.55
Array 250000 clone - spread 2.4825 ms/op 4.9499 ms/op 0.50
Array 250000 get(125000) 1.2010 ns/op 2.1310 ns/op 0.56
Array 250000 set(125000) 1.2290 ns/op 2.3590 ns/op 0.52
Array 250000 iterate all - loop 149.25 us/op 146.26 us/op 1.02
effectiveBalanceIncrements clone Uint8Array 300000 108.22 us/op 195.46 us/op 0.55
effectiveBalanceIncrements clone MutableVector 300000 778.00 ns/op 953.00 ns/op 0.82
effectiveBalanceIncrements rw all Uint8Array 300000 309.46 us/op 302.15 us/op 1.02
effectiveBalanceIncrements rw all MutableVector 300000 220.48 ms/op 269.80 ms/op 0.82
aggregationBits - 2048 els - zipIndexesInBitList 29.307 us/op 37.312 us/op 0.79
regular array get 100000 times 60.060 us/op 58.498 us/op 1.03
wrappedArray get 100000 times 61.828 us/op 58.379 us/op 1.06
arrayWithProxy get 100000 times 41.888 ms/op 41.435 ms/op 1.01
ssz.Root.equals 650.00 ns/op 593.00 ns/op 1.10
byteArrayEquals 629.00 ns/op 584.00 ns/op 1.08
phase0 processBlock - 250000 vs - 7PWei normalcase 4.3718 ms/op 4.7606 ms/op 0.92
phase0 processBlock - 250000 vs - 7PWei worstcase 56.023 ms/op 66.311 ms/op 0.84
phase0 afterProcessEpoch - 250000 vs - 7PWei 209.40 ms/op 212.15 ms/op 0.99
phase0 beforeProcessEpoch - 250000 vs - 7PWei 82.707 ms/op 83.938 ms/op 0.99
phase0 processEpoch - mainnet_e58758 625.22 ms/op 651.35 ms/op 0.96
mainnet_e58758 - phase0 beforeProcessEpoch 287.31 ms/op 310.26 ms/op 0.93
mainnet_e58758 - phase0 processJustificationAndFinalization 70.109 us/op 64.696 us/op 1.08
mainnet_e58758 - phase0 processRewardsAndPenalties 136.33 ms/op 144.58 ms/op 0.94
mainnet_e58758 - phase0 processRegistryUpdates 35.028 us/op 34.132 us/op 1.03
mainnet_e58758 - phase0 processSlashings 3.9710 us/op 4.3700 us/op 0.91
mainnet_e58758 - phase0 processEth1DataReset 3.7030 us/op 3.5450 us/op 1.04
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.8111 ms/op 4.3176 ms/op 0.65
mainnet_e58758 - phase0 processSlashingsReset 20.375 us/op 17.297 us/op 1.18
mainnet_e58758 - phase0 processRandaoMixesReset 25.682 us/op 24.392 us/op 1.05
mainnet_e58758 - phase0 processHistoricalRootsUpdate 4.6680 us/op 4.6140 us/op 1.01
mainnet_e58758 - phase0 processParticipationRecordUpdates 25.817 us/op 24.048 us/op 1.07
mainnet_e58758 - phase0 afterProcessEpoch 183.38 ms/op 182.92 ms/op 1.00
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.4425 ms/op 2.5518 ms/op 0.96
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.7279 ms/op 2.7716 ms/op 0.98
phase0 processRegistryUpdates - 250000 normalcase 30.764 us/op 27.698 us/op 1.11
phase0 processRegistryUpdates - 250000 badcase_full_deposits 520.31 us/op 531.15 us/op 0.98
phase0 processRegistryUpdates - 250000 worstcase 0.5 266.62 ms/op 260.59 ms/op 1.02
phase0 getAttestationDeltas - 250000 normalcase 15.467 ms/op 19.050 ms/op 0.81
phase0 getAttestationDeltas - 250000 worstcase 15.743 ms/op 19.756 ms/op 0.80
phase0 processSlashings - 250000 worstcase 7.8699 ms/op 6.7089 ms/op 1.17
shuffle list - 16384 els 12.912 ms/op 12.776 ms/op 1.01
shuffle list - 250000 els 189.55 ms/op 188.38 ms/op 1.01
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 468.83 us/op 429.34 us/op 1.09
pass gossip attestations to forkchoice per slot 7.6468 ms/op 3.8425 ms/op 1.99
computeDeltas 4.6136 ms/op 4.4403 ms/op 1.04
computeProposerBoostScoreFromBalances 934.36 us/op 900.62 us/op 1.04
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.6102 ms/op 2.8264 ms/op 0.92
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 92.292 us/op 103.62 us/op 0.89
BLS verify - blst-native 2.4275 ms/op 2.7294 ms/op 0.89
BLS verifyMultipleSignatures 3 - blst-native 4.8341 ms/op 5.6435 ms/op 0.86
BLS verifyMultipleSignatures 8 - blst-native 9.9932 ms/op 12.134 ms/op 0.82
BLS verifyMultipleSignatures 32 - blst-native 36.410 ms/op 44.286 ms/op 0.82
BLS aggregatePubkeys 32 - blst-native 51.032 us/op 60.568 us/op 0.84
BLS aggregatePubkeys 128 - blst-native 194.11 us/op 242.44 us/op 0.80
getAttestationsForBlock 72.474 ms/op 76.349 ms/op 0.95
isKnown best case - 1 super set check 592.00 ns/op 530.00 ns/op 1.12
isKnown normal case - 2 super set checks 567.00 ns/op 508.00 ns/op 1.12
isKnown worse case - 16 super set checks 556.00 ns/op 508.00 ns/op 1.09
CheckpointStateCache - add get delete 14.179 us/op 14.487 us/op 0.98
validate gossip signedAggregateAndProof - struct 5.4143 ms/op 6.3922 ms/op 0.85
validate gossip attestation - struct 2.5740 ms/op 3.0017 ms/op 0.86
altair verifyImport mainnet_s3766816:31 7.7314 s/op 8.6247 s/op 0.90
pickEth1Vote - no votes 2.7033 ms/op 2.5436 ms/op 1.06
pickEth1Vote - max votes 30.747 ms/op 32.552 ms/op 0.94
pickEth1Vote - Eth1Data hashTreeRoot value x2048 15.425 ms/op 16.755 ms/op 0.92
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 26.723 ms/op 29.574 ms/op 0.90
pickEth1Vote - Eth1Data fastSerialize value x2048 1.8528 ms/op 1.9269 ms/op 0.96
pickEth1Vote - Eth1Data fastSerialize tree x2048 22.012 ms/op 21.356 ms/op 1.03
bytes32 toHexString 1.3010 us/op 1.4280 us/op 0.91
bytes32 Buffer.toString(hex) 879.00 ns/op 876.00 ns/op 1.00
bytes32 Buffer.toString(hex) from Uint8Array 1.1510 us/op 1.2010 us/op 0.96
bytes32 Buffer.toString(hex) + 0x 876.00 ns/op 857.00 ns/op 1.02
Object access 1 prop 0.43200 ns/op 0.49300 ns/op 0.88
Map access 1 prop 0.35400 ns/op 0.36600 ns/op 0.97
Object get x1000 17.729 ns/op 17.121 ns/op 1.04
Map get x1000 1.1770 ns/op 1.0280 ns/op 1.14
Object set x1000 128.62 ns/op 138.56 ns/op 0.93
Map set x1000 91.798 ns/op 93.090 ns/op 0.99
Return object 10000 times 0.44840 ns/op 0.43770 ns/op 1.02
Throw Error 10000 times 7.7137 us/op 7.1964 us/op 1.07
enrSubnets - fastDeserialize 64 bits 3.2080 us/op 3.7000 us/op 0.87
enrSubnets - ssz BitVector 64 bits 996.00 ns/op 1.0830 us/op 0.92
enrSubnets - fastDeserialize 4 bits 478.00 ns/op 508.00 ns/op 0.94
enrSubnets - ssz BitVector 4 bits 1.0560 us/op 1.0810 us/op 0.98
prioritizePeers score -10:0 att 32-0.1 sync 2-0 126.14 us/op 128.25 us/op 0.98
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 159.88 us/op 152.02 us/op 1.05
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 299.20 us/op 294.73 us/op 1.02
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 661.96 us/op 641.64 us/op 1.03
prioritizePeers score 0:0 att 64-1 sync 4-1 592.55 us/op 679.62 us/op 0.87
RateTracker 1000000 limit, 1 obj count per request 221.47 ns/op 223.38 ns/op 0.99
RateTracker 1000000 limit, 2 obj count per request 165.70 ns/op 174.11 ns/op 0.95
RateTracker 1000000 limit, 4 obj count per request 139.20 ns/op 147.81 ns/op 0.94
RateTracker 1000000 limit, 8 obj count per request 126.82 ns/op 132.25 ns/op 0.96
RateTracker with prune 6.0060 us/op 6.6170 us/op 0.91
array of 16000 items push then shift 5.6965 us/op 5.5034 us/op 1.04
LinkedList of 16000 items push then shift 32.926 ns/op 28.591 ns/op 1.15
array of 16000 items push then pop 275.21 ns/op 288.08 ns/op 0.96
LinkedList of 16000 items push then pop 27.362 ns/op 24.789 ns/op 1.10
array of 24000 items push then shift 8.5527 us/op 8.2524 us/op 1.04
LinkedList of 24000 items push then shift 30.231 ns/op 28.990 ns/op 1.04
array of 24000 items push then pop 234.58 ns/op 265.35 ns/op 0.88
LinkedList of 24000 items push then pop 26.316 ns/op 24.654 ns/op 1.07
intersect bitArray bitLen 8 13.673 ns/op 12.878 ns/op 1.06
intersect array and set length 8 208.05 ns/op 235.74 ns/op 0.88
intersect bitArray bitLen 128 81.564 ns/op 73.132 ns/op 1.12
intersect array and set length 128 2.6185 us/op 2.7808 us/op 0.94

by benchmarkbot/action

import * as block from "./block";
import * as pool from "./pool";
import * as state from "./state";
import {RoutesData, ReturnTypes, reqEmpty, ContainerData} from "../../utils";
Copy link
Contributor

Choose a reason for hiding this comment

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

So we actually want the closest modules at the bottom, so the correct order would be the original one. @dadepo can you try to tweak the rule to achieve that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@codecov
Copy link

codecov bot commented Apr 5, 2022

Codecov Report

Merging #3885 (6b5ab34) into master (7f7ef80) will increase coverage by 36.60%.
The diff coverage is n/a.

❗ Current head 6b5ab34 differs from pull request most recent head 04b2158. Consider uploading reports for the commit 04b2158 to get more accurate results

@@             Coverage Diff             @@
##           master    #3885       +/-   ##
===========================================
+ Coverage        0   36.60%   +36.60%     
===========================================
  Files           0      325      +325     
  Lines           0     8975     +8975     
  Branches        0     1407     +1407     
===========================================
+ Hits            0     3285     +3285     
- Misses          0     5547     +5547     
- Partials        0      143      +143     

dapplion
dapplion previously approved these changes Apr 6, 2022
Copy link
Contributor

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

Let's goo! Thanks

twoeths
twoeths previously approved these changes Apr 7, 2022
@wemeetagain
Copy link
Member

Can we block this until we land ESM support? This will be a bit annoying for that PR by creating a bunch of confiicts.
If this rule can be auto-fixed, it should be very easy to rebase this on master after that.

@wemeetagain wemeetagain added the status-blocked This is blocked by another issue that requires resolving first. label Apr 7, 2022
@dapplion dapplion dismissed stale reviews from twoeths and themself April 7, 2022 15:07

blocked

@wemeetagain wemeetagain removed the status-blocked This is blocked by another issue that requires resolving first. label May 25, 2022
@wemeetagain
Copy link
Member

ready for rebase off master

…conflict. Still new to review if the eslint works as before
@dadepo dadepo requested a review from a team as a code owner May 25, 2022 16:52
wemeetagain
wemeetagain previously approved these changes May 25, 2022
@wemeetagain
Copy link
Member

tests still erroring

@wemeetagain
Copy link
Member

I think I made conflicts with #4064

wemeetagain
wemeetagain previously approved these changes May 26, 2022
get attnets(): BitArray {
return this._metadata.attnets;
}
set attnets(attnets: BitArray) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please preserve whitespace in all changes of this file. After each method and at least 1 new line

@@ -101,35 +130,6 @@ export class BeaconSync implements IBeaconSync {
return this.state === SyncState.Synced;
}

get state(): SyncState {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why all this changes in a PR that's clearly scoped to "import order"? Could you please revert this commit and do this changes if applicable? We have really never followed the member-ordering rule in Lodestar

@wemeetagain wemeetagain merged commit dfd4cdc into master May 27, 2022
@wemeetagain wemeetagain deleted the dadepo/dadepo/es-lint-import-latest branch May 27, 2022 00:32
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

4 participants