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

Connect to network discv5 boot enrs on start up #3672

Merged

Conversation

dadepo
Copy link
Contributor

@dadepo dadepo commented Jan 27, 2022

Motivation

While using the dev command it was realised that the documentation on how to start two nodes that connects to each other is outdated. This changes updates the documentation and also fixes the code to ensures nodes are connected as peers based on supplied discv5.boot.enrs values

Description

Updated the documentation for using the dev command.
Updated the code to ensure nodes are connected as peers based on supplied discv5.boot.enrs values.

Closes #3568

@codecov
Copy link

codecov bot commented Jan 27, 2022

Codecov Report

Merging #3672 (9c5362f) into master (7e1fb2f) will increase coverage by 0.36%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #3672      +/-   ##
==========================================
+ Coverage   37.16%   37.52%   +0.36%     
==========================================
  Files         321      322       +1     
  Lines        8689     8818     +129     
  Branches     1346     1379      +33     
==========================================
+ Hits         3229     3309      +80     
- Misses       5317     5368      +51     
+ Partials      143      141       -2     

@codeclimate
Copy link

codeclimate bot commented Jan 27, 2022

Code Climate has analyzed commit a8efda7 and detected 0 issues on this pull request.

View more on Code Climate.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 27, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: c7e8e02 Previous: 6a71301 Ratio
BeaconState.hashTreeRoot - No change 639.00 ns/op 688.00 ns/op 0.93
BeaconState.hashTreeRoot - 1 full validator 146.89 us/op 148.52 us/op 0.99
BeaconState.hashTreeRoot - 32 full validator 2.2735 ms/op 2.3894 ms/op 0.95
BeaconState.hashTreeRoot - 512 full validator 28.147 ms/op 31.238 ms/op 0.90
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 147.27 us/op 150.54 us/op 0.98
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.3573 ms/op 2.5309 ms/op 0.93
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 34.591 ms/op 34.603 ms/op 1.00
BeaconState.hashTreeRoot - 1 balances 108.80 us/op 110.31 us/op 0.99
BeaconState.hashTreeRoot - 32 balances 914.88 us/op 918.65 us/op 1.00
BeaconState.hashTreeRoot - 512 balances 9.4623 ms/op 8.9104 ms/op 1.06
BeaconState.hashTreeRoot - 250000 balances 154.43 ms/op 161.81 ms/op 0.95
processSlot - 1 slots 55.225 us/op 53.115 us/op 1.04
processSlot - 32 slots 3.4466 ms/op 3.3501 ms/op 1.03
getCommitteeAssignments - req 1 vs - 250000 vc 6.3967 ms/op 6.8090 ms/op 0.94
getCommitteeAssignments - req 100 vs - 250000 vc 8.8976 ms/op 8.7593 ms/op 1.02
getCommitteeAssignments - req 1000 vs - 250000 vc 9.3366 ms/op 9.3344 ms/op 1.00
computeProposers - vc 250000 25.161 ms/op 24.352 ms/op 1.03
computeEpochShuffling - vc 250000 210.71 ms/op 219.15 ms/op 0.96
getNextSyncCommittee - vc 250000 377.98 ms/op 400.80 ms/op 0.94
altair processAttestation - 250000 vs - 7PWei normalcase 48.913 ms/op 53.748 ms/op 0.91
altair processAttestation - 250000 vs - 7PWei worstcase 49.135 ms/op 53.456 ms/op 0.92
altair processAttestation - setStatus - 1/6 committees join 11.669 ms/op 15.185 ms/op 0.77
altair processAttestation - setStatus - 1/3 committees join 23.064 ms/op 31.687 ms/op 0.73
altair processAttestation - setStatus - 1/2 committees join 37.902 ms/op 44.926 ms/op 0.84
altair processAttestation - setStatus - 2/3 committees join 45.649 ms/op 60.513 ms/op 0.75
altair processAttestation - setStatus - 4/5 committees join 55.523 ms/op 73.919 ms/op 0.75
altair processAttestation - setStatus - 100% committees join 75.830 ms/op 89.113 ms/op 0.85
altair processAttestation - updateEpochParticipants - 1/6 committees join 12.899 ms/op 28.354 ms/op 0.45
altair processAttestation - updateEpochParticipants - 1/3 committees join 25.305 ms/op 25.976 ms/op 0.97
altair processAttestation - updateEpochParticipants - 1/2 committees join 36.948 ms/op 30.193 ms/op 1.22
altair processAttestation - updateEpochParticipants - 2/3 committees join 29.523 ms/op 34.394 ms/op 0.86
altair processAttestation - updateEpochParticipants - 4/5 committees join 32.394 ms/op 34.727 ms/op 0.93
altair processAttestation - updateEpochParticipants - 100% committees join 33.647 ms/op 45.572 ms/op 0.74
altair processAttestation - updateAllStatus 23.933 ms/op 25.782 ms/op 0.93
altair processBlock - 250000 vs - 7PWei normalcase 146.42 ms/op 55.448 ms/op 2.64
altair processBlock - 250000 vs - 7PWei worstcase 127.44 ms/op 148.10 ms/op 0.86
altair processEpoch - mainnet_e81889 1.2497 s/op 1.3484 s/op 0.93
mainnet_e81889 - altair beforeProcessEpoch 307.15 ms/op 303.72 ms/op 1.01
mainnet_e81889 - altair processJustificationAndFinalization 69.377 us/op 86.835 us/op 0.80
mainnet_e81889 - altair processInactivityUpdates 20.003 ms/op 20.977 ms/op 0.95
mainnet_e81889 - altair processRewardsAndPenalties 313.74 ms/op 332.42 ms/op 0.94
mainnet_e81889 - altair processRegistryUpdates 10.870 us/op 9.5550 us/op 1.14
mainnet_e81889 - altair processSlashings 3.5920 us/op 3.0970 us/op 1.16
mainnet_e81889 - altair processEth1DataReset 2.8170 us/op 2.9150 us/op 0.97
mainnet_e81889 - altair processEffectiveBalanceUpdates 13.676 ms/op 14.417 ms/op 0.95
mainnet_e81889 - altair processSlashingsReset 16.514 us/op 18.456 us/op 0.89
mainnet_e81889 - altair processRandaoMixesReset 19.917 us/op 23.506 us/op 0.85
mainnet_e81889 - altair processHistoricalRootsUpdate 3.8390 us/op 4.1070 us/op 0.93
mainnet_e81889 - altair processParticipationFlagUpdates 119.41 ms/op 158.06 ms/op 0.76
mainnet_e81889 - altair processSyncCommitteeUpdates 3.0910 us/op 2.4250 us/op 1.27
mainnet_e81889 - altair afterProcessEpoch 262.45 ms/op 299.54 ms/op 0.88
altair processInactivityUpdates - 250000 normalcase 80.753 ms/op 92.211 ms/op 0.88
altair processInactivityUpdates - 250000 worstcase 82.722 ms/op 82.003 ms/op 1.01
altair processParticipationFlagUpdates - 250000 anycase 110.98 ms/op 108.16 ms/op 1.03
altair processRewardsAndPenalties - 250000 normalcase 285.07 ms/op 255.81 ms/op 1.11
altair processRewardsAndPenalties - 250000 worstcase 285.65 ms/op 297.57 ms/op 0.96
altair processSyncCommitteeUpdates - 250000 418.23 ms/op 434.02 ms/op 0.96
Tree 40 250000 create 735.77 ms/op 941.36 ms/op 0.78
Tree 40 250000 get(125000) 376.59 ns/op 387.36 ns/op 0.97
Tree 40 250000 set(125000) 2.3756 us/op 2.0687 us/op 1.15
Tree 40 250000 toArray() 44.998 ms/op 51.878 ms/op 0.87
Tree 40 250000 iterate all - toArray() + loop 52.020 ms/op 43.942 ms/op 1.18
Tree 40 250000 iterate all - get(i) 141.23 ms/op 142.24 ms/op 0.99
MutableVector 250000 create 21.819 ms/op 31.168 ms/op 0.70
MutableVector 250000 get(125000) 16.231 ns/op 17.284 ns/op 0.94
MutableVector 250000 set(125000) 536.54 ns/op 588.70 ns/op 0.91
MutableVector 250000 toArray() 10.367 ms/op 10.279 ms/op 1.01
MutableVector 250000 iterate all - toArray() + loop 10.671 ms/op 10.271 ms/op 1.04
MutableVector 250000 iterate all - get(i) 4.2733 ms/op 3.7569 ms/op 1.14
Array 250000 create 7.5877 ms/op 6.3816 ms/op 1.19
Array 250000 clone - spread 2.2035 ms/op 2.6894 ms/op 0.82
Array 250000 get(125000) 1.1540 ns/op 1.2320 ns/op 0.94
Array 250000 set(125000) 1.1400 ns/op 1.2360 ns/op 0.92
Array 250000 iterate all - loop 218.79 us/op 201.62 us/op 1.09
aggregationBits - 2048 els - readonlyValues 263.79 us/op 277.51 us/op 0.95
aggregationBits - 2048 els - zipIndexesInBitList 46.567 us/op 47.437 us/op 0.98
regular array get 100000 times 82.573 us/op 80.941 us/op 1.02
wrappedArray get 100000 times 82.366 us/op 81.483 us/op 1.01
arrayWithProxy get 100000 times 36.081 ms/op 33.983 ms/op 1.06
ssz.Root.equals 1.3110 us/op 1.4450 us/op 0.91
ssz.Root.equals with valueOf() 1.6180 us/op 1.6930 us/op 0.96
byteArrayEquals with valueOf() 1.5210 us/op 1.6070 us/op 0.95
phase0 processBlock - 250000 vs - 7PWei normalcase 12.525 ms/op 13.067 ms/op 0.96
phase0 processBlock - 250000 vs - 7PWei worstcase 90.421 ms/op 91.215 ms/op 0.99
phase0 afterProcessEpoch - 250000 vs - 7PWei 241.19 ms/op 252.32 ms/op 0.96
phase0 beforeProcessEpoch - 250000 vs - 7PWei 634.66 ms/op 669.43 ms/op 0.95
phase0 processEpoch - mainnet_e58758 921.63 ms/op 1.0350 s/op 0.89
mainnet_e58758 - phase0 beforeProcessEpoch 536.61 ms/op 486.96 ms/op 1.10
mainnet_e58758 - phase0 processJustificationAndFinalization 81.637 us/op 72.787 us/op 1.12
mainnet_e58758 - phase0 processRewardsAndPenalties 181.63 ms/op 155.30 ms/op 1.17
mainnet_e58758 - phase0 processRegistryUpdates 52.352 us/op 52.753 us/op 0.99
mainnet_e58758 - phase0 processSlashings 5.1100 us/op 3.9980 us/op 1.28
mainnet_e58758 - phase0 processEth1DataReset 3.5750 us/op 2.9730 us/op 1.20
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 11.780 ms/op 11.176 ms/op 1.05
mainnet_e58758 - phase0 processSlashingsReset 14.632 us/op 13.537 us/op 1.08
mainnet_e58758 - phase0 processRandaoMixesReset 18.573 us/op 15.945 us/op 1.16
mainnet_e58758 - phase0 processHistoricalRootsUpdate 3.8050 us/op 3.8300 us/op 0.99
mainnet_e58758 - phase0 processParticipationRecordUpdates 13.472 us/op 14.405 us/op 0.94
mainnet_e58758 - phase0 afterProcessEpoch 220.48 ms/op 222.68 ms/op 0.99
phase0 processEffectiveBalanceUpdates - 250000 normalcase 13.407 ms/op 13.461 ms/op 1.00
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.5889 s/op 1.5236 s/op 1.04
phase0 processRegistryUpdates - 250000 normalcase 67.352 us/op 50.507 us/op 1.33
phase0 processRegistryUpdates - 250000 badcase_full_deposits 3.1651 ms/op 3.8647 ms/op 0.82
phase0 processRegistryUpdates - 250000 worstcase 0.5 1.8927 s/op 1.8687 s/op 1.01
phase0 getAttestationDeltas - 250000 normalcase 82.965 ms/op 91.591 ms/op 0.91
phase0 getAttestationDeltas - 250000 worstcase 82.651 ms/op 92.455 ms/op 0.89
phase0 processSlashings - 250000 worstcase 43.413 ms/op 47.346 ms/op 0.92
shuffle list - 16384 els 14.987 ms/op 15.417 ms/op 0.97
shuffle list - 250000 els 207.88 ms/op 219.68 ms/op 0.95
getEffectiveBalances - 250000 vs - 7PWei 11.663 ms/op 14.370 ms/op 0.81
pass gossip attestations to forkchoice per slot 17.328 ms/op 18.637 ms/op 0.93
computeDeltas 3.5535 ms/op 3.9620 ms/op 0.90
computeProposerBoostScoreFromBalances 381.76 us/op 404.96 us/op 0.94
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.3015 ms/op 2.4565 ms/op 0.94
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 681.19 us/op 828.07 us/op 0.82
BLS verify - blst-native 2.0672 ms/op 2.2320 ms/op 0.93
BLS verifyMultipleSignatures 3 - blst-native 4.1554 ms/op 4.5887 ms/op 0.91
BLS verifyMultipleSignatures 8 - blst-native 9.5550 ms/op 9.9119 ms/op 0.96
BLS verifyMultipleSignatures 32 - blst-native 32.346 ms/op 35.872 ms/op 0.90
BLS aggregatePubkeys 32 - blst-native 41.081 us/op 47.672 us/op 0.86
BLS aggregatePubkeys 128 - blst-native 180.86 us/op 184.39 us/op 0.98
getAttestationsForBlock 88.909 ms/op 91.308 ms/op 0.97
CheckpointStateCache - add get delete 20.115 us/op 22.593 us/op 0.89
validate gossip signedAggregateAndProof - struct 5.0323 ms/op 5.4391 ms/op 0.93
validate gossip signedAggregateAndProof - treeBacked 5.3410 ms/op 5.3025 ms/op 1.01
validate gossip attestation - struct 2.1500 ms/op 2.4944 ms/op 0.86
validate gossip attestation - treeBacked 2.2392 ms/op 2.5156 ms/op 0.89
bytes32 toHexString 1.5750 us/op 2.0300 us/op 0.78
bytes32 Buffer.toString(hex) 730.00 ns/op 833.00 ns/op 0.88
bytes32 Buffer.toString(hex) from Uint8Array 962.00 ns/op 1.1460 us/op 0.84
bytes32 Buffer.toString(hex) + 0x 788.00 ns/op 825.00 ns/op 0.96
Object access 1 prop 0.31800 ns/op 0.42000 ns/op 0.76
Map access 1 prop 0.29200 ns/op 0.33900 ns/op 0.86
Object get x1000 19.174 ns/op 20.780 ns/op 0.92
Map get x1000 1.0070 ns/op 1.1810 ns/op 0.85
Object set x1000 117.78 ns/op 133.73 ns/op 0.88
Map set x1000 67.792 ns/op 79.553 ns/op 0.85
Return object 10000 times 0.41340 ns/op 0.44170 ns/op 0.94
Throw Error 10000 times 6.4952 us/op 6.9653 us/op 0.93
enrSubnets - fastDeserialize 64 bits 1.2970 us/op 1.5670 us/op 0.83
enrSubnets - ssz BitVector 64 bits 16.708 us/op 19.053 us/op 0.88
enrSubnets - fastDeserialize 4 bits 439.00 ns/op 562.00 ns/op 0.78
enrSubnets - ssz BitVector 4 bits 3.1490 us/op 3.4900 us/op 0.90
RateTracker 1000000 limit, 1 obj count per request 194.94 ns/op 221.12 ns/op 0.88
RateTracker 1000000 limit, 2 obj count per request 140.46 ns/op 165.52 ns/op 0.85
RateTracker 1000000 limit, 4 obj count per request 111.56 ns/op 138.02 ns/op 0.81
RateTracker 1000000 limit, 8 obj count per request 101.98 ns/op 124.64 ns/op 0.82
RateTracker with prune 3.6480 us/op 4.6530 us/op 0.78

by benchmarkbot/action


```bash
./lodestar dev --genesisValidators 8 --reset
./lodestar dev --genesisValidators 8 --genesisTime 1578787200 --network prater --rootDir </path/to/node1> --reset
Copy link
Member

Choose a reason for hiding this comment

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

maybe remove --network prater here and below

I think this is a little confusing as an example in the docs, folks may think they are actually connecting to the prater testnet

Copy link
Contributor

Choose a reason for hiding this comment

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

may be network option can be removed from the dev cli options, so that it will throw error if someone even tries to specify

Copy link
Contributor Author

Choose a reason for hiding this comment

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

may be network option can be removed from the dev cli options, so that it will throw error if someone even tries to specify

Good tip. I'll see to 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.

@g11tech so I looked into your suggestion. The network option is a global option and hence the changes that will be required to make it not applicable when the dev cli option is used feels a bit out of scope to this PR. So I created a separate issue: #3695 for the suggestion to be implemented separately.

@@ -127,6 +127,8 @@ export class PeerDiscovery {
await this.discv5.start();
this.discv5StartMs = Date.now();
this.discv5.on("discovered", this.onDiscovered);
// on start, dial the discv5.bootEnrs that has been added to the routing table
Copy link
Member

Choose a reason for hiding this comment

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

I think we have two choices here:

  1. only do this if network.connectToDiscv5Bootnodes is true
  2. remove the network.connectToDiscv5Bootnodes option entirely

Copy link
Contributor

Choose a reason for hiding this comment

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

We are not supposed to connect to the Mainnet bootnodes, this has to be behind a cli flag and used only for local devnets

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added it behind the network.connectToDiscv5Bootnodes cli flag

--port 9001 \
--api.rest.port 9597 \
--network.discv5.bootEnrs <enr value>
--reset
Copy link
Contributor

@g11tech g11tech Feb 4, 2022

Choose a reason for hiding this comment

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

may be this will now need connectToDiscv5Bootnodes arg as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. Updated.

g11tech
g11tech previously approved these changes Feb 4, 2022
@dadepo dadepo merged commit fd65bc9 into master Feb 4, 2022
@dadepo dadepo deleted the dadepo/connect-to-network-discv5-bootEnrs-on-start-up branch February 4, 2022 17:59
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.

Documentation on how to run Lodestar on local testnet is no longer up to date
4 participants