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

Disallow usage of console.log #4585

Merged
merged 10 commits into from
Oct 2, 2022
Merged

Disallow usage of console.log #4585

merged 10 commits into from
Oct 2, 2022

Conversation

dadepo
Copy link
Contributor

@dadepo dadepo commented Sep 21, 2022

Motivation

Recent changes leads to the having warnings like above when the lint task is run:

  lodestar git:(dadepo/fix-lint-warnings) ✗ yarn lint
yarn run v1.22.19
$ eslint --color --ext .ts packages/*/src packages/*/test

/Users/dadepoaderemi/Documents/work/chainsafe/official/lodestar/packages/cli/test/simulation/simulation.test.ts
  50:5  warning  Unexpected console statement  no-console

/~/ExternalSignerServer.ts
  61:5  warning  Unexpected console statement  no-console
  63:5  warning  Unexpected console statement  no-console
  67:5  warning  Unexpected console statement  no-console
  69:5  warning  Unexpected console statement  no-console

/~/LodestarBeaconNodeProcess.ts
  106:5  warning  Unexpected console statement  no-console
  115:5  warning  Unexpected console statement  no-console
  125:5  warning  Unexpected console statement  no-console
...
✖ 16 problems (0 errors, 16 warnings)

Description

This PR is to remove the console warnings. It does this by using /* eslint-disable no-console */ as needed. But other solutions could be:

  1. Use logging library in tests instead of console?
  2. If console logging is deemed acceptable in tests, then configure it that way in the .eslintrc file?

If any of these two other solutions is preferred, then let me know in the comments and I can update the PR accordingly.

@dadepo dadepo requested a review from a team as a code owner September 21, 2022 18:46
@github-actions
Copy link
Contributor

github-actions bot commented Sep 21, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: fdf5fe0 Previous: 7ebe81e Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.3964 ms/op 2.5026 ms/op 0.96
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 87.002 us/op 90.387 us/op 0.96
BLS verify - blst-native 2.1748 ms/op 2.2221 ms/op 0.98
BLS verifyMultipleSignatures 3 - blst-native 4.4419 ms/op 4.5560 ms/op 0.97
BLS verifyMultipleSignatures 8 - blst-native 9.6814 ms/op 9.7144 ms/op 1.00
BLS verifyMultipleSignatures 32 - blst-native 34.732 ms/op 35.432 ms/op 0.98
BLS aggregatePubkeys 32 - blst-native 45.754 us/op 46.716 us/op 0.98
BLS aggregatePubkeys 128 - blst-native 179.09 us/op 182.08 us/op 0.98
getAttestationsForBlock 103.77 ms/op 107.27 ms/op 0.97
isKnown best case - 1 super set check 528.00 ns/op 542.00 ns/op 0.97
isKnown normal case - 2 super set checks 499.00 ns/op 544.00 ns/op 0.92
isKnown worse case - 16 super set checks 511.00 ns/op 522.00 ns/op 0.98
CheckpointStateCache - add get delete 10.215 us/op 10.860 us/op 0.94
validate gossip signedAggregateAndProof - struct 4.8721 ms/op 5.0377 ms/op 0.97
validate gossip attestation - struct 2.2833 ms/op 2.3868 ms/op 0.96
pickEth1Vote - no votes 2.4914 ms/op 2.6868 ms/op 0.93
pickEth1Vote - max votes 23.034 ms/op 26.308 ms/op 0.88
pickEth1Vote - Eth1Data hashTreeRoot value x2048 12.829 ms/op 14.354 ms/op 0.89
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 23.870 ms/op 25.552 ms/op 0.93
pickEth1Vote - Eth1Data fastSerialize value x2048 1.7731 ms/op 1.8246 ms/op 0.97
pickEth1Vote - Eth1Data fastSerialize tree x2048 14.945 ms/op 17.186 ms/op 0.87
bytes32 toHexString 1.2060 us/op 1.3570 us/op 0.89
bytes32 Buffer.toString(hex) 814.00 ns/op 843.00 ns/op 0.97
bytes32 Buffer.toString(hex) from Uint8Array 1.1100 us/op 1.1090 us/op 1.00
bytes32 Buffer.toString(hex) + 0x 820.00 ns/op 861.00 ns/op 0.95
Object access 1 prop 0.43700 ns/op 0.46800 ns/op 0.93
Map access 1 prop 0.35200 ns/op 0.34100 ns/op 1.03
Object get x1000 20.294 ns/op 22.172 ns/op 0.92
Map get x1000 1.2080 ns/op 1.1610 ns/op 1.04
Object set x1000 133.66 ns/op 148.45 ns/op 0.90
Map set x1000 79.441 ns/op 90.478 ns/op 0.88
Return object 10000 times 0.42430 ns/op 0.44850 ns/op 0.95
Throw Error 10000 times 6.5585 us/op 6.8601 us/op 0.96
enrSubnets - fastDeserialize 64 bits 3.0300 us/op 3.4050 us/op 0.89
enrSubnets - ssz BitVector 64 bits 862.00 ns/op 906.00 ns/op 0.95
enrSubnets - fastDeserialize 4 bits 449.00 ns/op 481.00 ns/op 0.93
enrSubnets - ssz BitVector 4 bits 851.00 ns/op 897.00 ns/op 0.95
prioritizePeers score -10:0 att 32-0.1 sync 2-0 111.45 us/op 115.99 us/op 0.96
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 141.09 us/op 166.58 us/op 0.85
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 248.75 us/op 276.71 us/op 0.90
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 539.55 us/op 454.96 us/op 1.19
prioritizePeers score 0:0 att 64-1 sync 4-1 536.84 us/op 543.32 us/op 0.99
RateTracker 1000000 limit, 1 obj count per request 218.71 ns/op 235.30 ns/op 0.93
RateTracker 1000000 limit, 2 obj count per request 160.70 ns/op 177.16 ns/op 0.91
RateTracker 1000000 limit, 4 obj count per request 134.24 ns/op 148.88 ns/op 0.90
RateTracker 1000000 limit, 8 obj count per request 128.67 ns/op 138.90 ns/op 0.93
RateTracker with prune 4.9080 us/op 5.8380 us/op 0.84
array of 16000 items push then shift 3.7114 us/op 3.6963 us/op 1.00
LinkedList of 16000 items push then shift 20.120 ns/op 20.527 ns/op 0.98
array of 16000 items push then pop 262.98 ns/op 273.66 ns/op 0.96
LinkedList of 16000 items push then pop 19.040 ns/op 19.248 ns/op 0.99
array of 24000 items push then shift 5.2340 us/op 5.5916 us/op 0.94
LinkedList of 24000 items push then shift 21.837 ns/op 23.756 ns/op 0.92
array of 24000 items push then pop 235.20 ns/op 249.87 ns/op 0.94
LinkedList of 24000 items push then pop 20.428 ns/op 20.673 ns/op 0.99
intersect bitArray bitLen 8 13.524 ns/op 13.845 ns/op 0.98
intersect array and set length 8 193.17 ns/op 222.28 ns/op 0.87
intersect bitArray bitLen 128 71.417 ns/op 74.497 ns/op 0.96
intersect array and set length 128 2.6278 us/op 2.7257 us/op 0.96
Buffer.concat 32 items 2.6580 ns/op 2.7450 ns/op 0.97
pass gossip attestations to forkchoice per slot 4.7903 ms/op 4.8147 ms/op 0.99
computeDeltas 6.1473 ms/op 7.5025 ms/op 0.82
computeProposerBoostScoreFromBalances 1.0765 ms/op 1.0867 ms/op 0.99
altair processAttestation - 250000 vs - 7PWei normalcase 4.6821 ms/op 4.8324 ms/op 0.97
altair processAttestation - 250000 vs - 7PWei worstcase 7.5264 ms/op 7.8345 ms/op 0.96
altair processAttestation - setStatus - 1/6 committees join 253.57 us/op 259.09 us/op 0.98
altair processAttestation - setStatus - 1/3 committees join 490.98 us/op 480.55 us/op 1.02
altair processAttestation - setStatus - 1/2 committees join 687.45 us/op 676.32 us/op 1.02
altair processAttestation - setStatus - 2/3 committees join 901.38 us/op 870.32 us/op 1.04
altair processAttestation - setStatus - 4/5 committees join 1.2139 ms/op 1.2449 ms/op 0.98
altair processAttestation - setStatus - 100% committees join 1.4253 ms/op 1.4294 ms/op 1.00
altair processBlock - 250000 vs - 7PWei normalcase 31.577 ms/op 33.507 ms/op 0.94
altair processBlock - 250000 vs - 7PWei normalcase hashState 41.381 ms/op 46.502 ms/op 0.89
altair processBlock - 250000 vs - 7PWei worstcase 103.75 ms/op 98.666 ms/op 1.05
altair processBlock - 250000 vs - 7PWei worstcase hashState 115.14 ms/op 118.72 ms/op 0.97
phase0 processBlock - 250000 vs - 7PWei normalcase 4.3669 ms/op 4.5935 ms/op 0.95
phase0 processBlock - 250000 vs - 7PWei worstcase 55.039 ms/op 54.833 ms/op 1.00
altair processEth1Data - 250000 vs - 7PWei normalcase 1.1734 ms/op 1.1160 ms/op 1.05
Tree 40 250000 create 903.75 ms/op 1.0030 s/op 0.90
Tree 40 250000 get(125000) 344.47 ns/op 334.94 ns/op 1.03
Tree 40 250000 set(125000) 3.0203 us/op 2.9257 us/op 1.03
Tree 40 250000 toArray() 36.562 ms/op 36.793 ms/op 0.99
Tree 40 250000 iterate all - toArray() + loop 37.329 ms/op 36.825 ms/op 1.01
Tree 40 250000 iterate all - get(i) 130.35 ms/op 128.72 ms/op 1.01
MutableVector 250000 create 18.466 ms/op 19.467 ms/op 0.95
MutableVector 250000 get(125000) 17.471 ns/op 18.014 ns/op 0.97
MutableVector 250000 set(125000) 763.83 ns/op 765.42 ns/op 1.00
MutableVector 250000 toArray() 8.6547 ms/op 8.8939 ms/op 0.97
MutableVector 250000 iterate all - toArray() + loop 13.659 ms/op 9.0989 ms/op 1.50
MutableVector 250000 iterate all - get(i) 4.1071 ms/op 4.0621 ms/op 1.01
Array 250000 create 7.1523 ms/op 8.3768 ms/op 0.85
Array 250000 clone - spread 2.9539 ms/op 4.7948 ms/op 0.62
Array 250000 get(125000) 1.3240 ns/op 2.0240 ns/op 0.65
Array 250000 set(125000) 1.2960 ns/op 2.0380 ns/op 0.64
Array 250000 iterate all - loop 194.79 us/op 202.16 us/op 0.96
effectiveBalanceIncrements clone Uint8Array 300000 82.699 us/op 116.27 us/op 0.71
effectiveBalanceIncrements clone MutableVector 300000 850.00 ns/op 1.5150 us/op 0.56
effectiveBalanceIncrements rw all Uint8Array 300000 301.65 us/op 303.31 us/op 0.99
effectiveBalanceIncrements rw all MutableVector 300000 188.26 ms/op 275.83 ms/op 0.68
phase0 afterProcessEpoch - 250000 vs - 7PWei 213.26 ms/op 228.67 ms/op 0.93
phase0 beforeProcessEpoch - 250000 vs - 7PWei 77.636 ms/op 114.71 ms/op 0.68
altair processEpoch - mainnet_e81889 680.06 ms/op 691.00 ms/op 0.98
mainnet_e81889 - altair beforeProcessEpoch 175.21 ms/op 152.45 ms/op 1.15
mainnet_e81889 - altair processJustificationAndFinalization 41.992 us/op 32.044 us/op 1.31
mainnet_e81889 - altair processInactivityUpdates 12.204 ms/op 13.596 ms/op 0.90
mainnet_e81889 - altair processRewardsAndPenalties 106.36 ms/op 109.75 ms/op 0.97
mainnet_e81889 - altair processRegistryUpdates 7.8220 us/op 8.0730 us/op 0.97
mainnet_e81889 - altair processSlashings 2.0470 us/op 2.1560 us/op 0.95
mainnet_e81889 - altair processEth1DataReset 2.3180 us/op 2.2550 us/op 1.03
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.7091 ms/op 2.7725 ms/op 0.98
mainnet_e81889 - altair processSlashingsReset 11.294 us/op 11.191 us/op 1.01
mainnet_e81889 - altair processRandaoMixesReset 12.304 us/op 12.852 us/op 0.96
mainnet_e81889 - altair processHistoricalRootsUpdate 1.8330 us/op 1.9620 us/op 0.93
mainnet_e81889 - altair processParticipationFlagUpdates 6.6860 us/op 8.2030 us/op 0.82
mainnet_e81889 - altair processSyncCommitteeUpdates 2.1900 us/op 1.7090 us/op 1.28
mainnet_e81889 - altair afterProcessEpoch 223.98 ms/op 241.27 ms/op 0.93
phase0 processEpoch - mainnet_e58758 606.61 ms/op 723.47 ms/op 0.84
mainnet_e58758 - phase0 beforeProcessEpoch 259.93 ms/op 279.21 ms/op 0.93
mainnet_e58758 - phase0 processJustificationAndFinalization 37.953 us/op 33.397 us/op 1.14
mainnet_e58758 - phase0 processRewardsAndPenalties 165.70 ms/op 161.22 ms/op 1.03
mainnet_e58758 - phase0 processRegistryUpdates 19.814 us/op 18.150 us/op 1.09
mainnet_e58758 - phase0 processSlashings 1.8940 us/op 1.8390 us/op 1.03
mainnet_e58758 - phase0 processEth1DataReset 1.9080 us/op 1.9360 us/op 0.99
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.5900 ms/op 3.4403 ms/op 0.75
mainnet_e58758 - phase0 processSlashingsReset 10.682 us/op 9.4870 us/op 1.13
mainnet_e58758 - phase0 processRandaoMixesReset 14.636 us/op 12.221 us/op 1.20
mainnet_e58758 - phase0 processHistoricalRootsUpdate 2.2220 us/op 2.1530 us/op 1.03
mainnet_e58758 - phase0 processParticipationRecordUpdates 11.971 us/op 11.409 us/op 1.05
mainnet_e58758 - phase0 afterProcessEpoch 187.92 ms/op 198.83 ms/op 0.95
phase0 processEffectiveBalanceUpdates - 250000 normalcase 3.0430 ms/op 3.0521 ms/op 1.00
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 4.1316 ms/op 4.2518 ms/op 0.97
altair processInactivityUpdates - 250000 normalcase 46.528 ms/op 48.548 ms/op 0.96
altair processInactivityUpdates - 250000 worstcase 56.824 ms/op 59.971 ms/op 0.95
phase0 processRegistryUpdates - 250000 normalcase 17.026 us/op 17.493 us/op 0.97
phase0 processRegistryUpdates - 250000 badcase_full_deposits 556.18 us/op 494.79 us/op 1.12
phase0 processRegistryUpdates - 250000 worstcase 0.5 249.31 ms/op 261.24 ms/op 0.95
altair processRewardsAndPenalties - 250000 normalcase 145.06 ms/op 150.20 ms/op 0.97
altair processRewardsAndPenalties - 250000 worstcase 99.976 ms/op 102.10 ms/op 0.98
phase0 getAttestationDeltas - 250000 normalcase 16.061 ms/op 16.953 ms/op 0.95
phase0 getAttestationDeltas - 250000 worstcase 17.093 ms/op 18.045 ms/op 0.95
phase0 processSlashings - 250000 worstcase 6.6480 ms/op 6.5052 ms/op 1.02
altair processSyncCommitteeUpdates - 250000 340.22 ms/op 343.02 ms/op 0.99
BeaconState.hashTreeRoot - No change 570.00 ns/op 608.00 ns/op 0.94
BeaconState.hashTreeRoot - 1 full validator 73.736 us/op 73.679 us/op 1.00
BeaconState.hashTreeRoot - 32 full validator 792.52 us/op 948.76 us/op 0.84
BeaconState.hashTreeRoot - 512 full validator 7.9733 ms/op 8.2860 ms/op 0.96
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 95.544 us/op 92.644 us/op 1.03
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.3782 ms/op 1.4288 ms/op 0.96
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 18.270 ms/op 19.078 ms/op 0.96
BeaconState.hashTreeRoot - 1 balances 70.073 us/op 70.350 us/op 1.00
BeaconState.hashTreeRoot - 32 balances 706.95 us/op 666.84 us/op 1.06
BeaconState.hashTreeRoot - 512 balances 6.9122 ms/op 6.8800 ms/op 1.00
BeaconState.hashTreeRoot - 250000 balances 115.15 ms/op 112.68 ms/op 1.02
aggregationBits - 2048 els - zipIndexesInBitList 34.547 us/op 38.388 us/op 0.90
regular array get 100000 times 80.205 us/op 79.912 us/op 1.00
wrappedArray get 100000 times 80.246 us/op 83.971 us/op 0.96
arrayWithProxy get 100000 times 32.840 ms/op 35.618 ms/op 0.92
ssz.Root.equals 562.00 ns/op 598.00 ns/op 0.94
byteArrayEquals 561.00 ns/op 592.00 ns/op 0.95
shuffle list - 16384 els 13.181 ms/op 13.915 ms/op 0.95
shuffle list - 250000 els 189.12 ms/op 195.90 ms/op 0.97
processSlot - 1 slots 14.512 us/op 14.789 us/op 0.98
processSlot - 32 slots 2.0499 ms/op 2.1355 ms/op 0.96
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 486.27 us/op 446.29 us/op 1.09
getCommitteeAssignments - req 1 vs - 250000 vc 6.3703 ms/op 6.2232 ms/op 1.02
getCommitteeAssignments - req 100 vs - 250000 vc 8.2849 ms/op 8.8066 ms/op 0.94
getCommitteeAssignments - req 1000 vs - 250000 vc 9.1557 ms/op 9.4464 ms/op 0.97
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 11.480 ns/op 13.260 ns/op 0.87
state getBlockRootAtSlot - 250000 vs - 7PWei 1.3353 us/op 1.4920 us/op 0.89
computeProposers - vc 250000 20.135 ms/op 21.073 ms/op 0.96
computeEpochShuffling - vc 250000 191.48 ms/op 201.29 ms/op 0.95
getNextSyncCommittee - vc 250000 329.77 ms/op 339.49 ms/op 0.97

by benchmarkbot/action

twoeths
twoeths previously approved these changes Sep 23, 2022
@dadepo dadepo requested a review from twoeths September 27, 2022 11:01
@wemeetagain
Copy link
Member

I think ideally your idea 2 can be used.

@dadepo dadepo changed the title Silence console warnings Allow console in test files Sep 27, 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.

IMO console.log usage is not acceptable anywhere including tests. We may use it sometimes if it's really useful but usage must be discouraged in tests, and (potentially) forbidden in src code.

@dadepo dadepo changed the title Allow console in test files Disallow usage of console.log Sep 30, 2022
@dapplion dapplion merged commit 3df7e2b into unstable Oct 2, 2022
@dapplion dapplion deleted the dadepo/fix-lint-warnings branch October 2, 2022 17:48
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.

4 participants