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

There might be a little confuse when I boot a local node and unknown nodes added to my init config #30901

Open
yyuze opened this issue Dec 12, 2024 · 2 comments
Labels

Comments

@yyuze
Copy link

yyuze commented Dec 12, 2024

System information

Geth version: geth version 1.14.11-stable-f3c696fa
CL client & version: none
OS & Version: Linux
Commit hash : f3c696f

I'm try building a local ethereum node, and I noticed there are sometimes unknown nodes appear at output of terminal command

admin.peers()

To figure out why, I added log at p2p/enode/node.go:81, (at the end of function newNodeWithID)

fmt.Printf("[YYUZE] new node: %+v\n", n);

Then when I use init command:

geth init --datadir ${PATH_TO_DATADIR} ${PATH_TO_GENESIS}

I got the following output:

[YYUZE] new node: enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303
[YYUZE] new node: enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303
[YYUZE] new node: enode://2b252ab6a1d0f971d9722cb839a42cb81db019ba44c08754628ab4a823487071b5695317c8ccd085219c3a03af063495b2f1da8d18218da2d6a82981b45e6ffc@65.108.70.101:30303
[YYUZE] new node: enode://4aeb4ab6c14b23e2c4cfdce879c04b0748a20d8e9b59e25ded2a08143e265c6c25936e74cbc8e641e3312ca288673d91f2f93f8e277de3cfa444ecdaaf982052@157.90.35.166:30303
[YYUZE] new node: enr:-KG4QMOEswP62yzDjSwWS4YEjtTZ5PO6r65CPqYBkgTTkrpaedQ8uEUo1uMALtJIvb2w_WWEVmg5yt1UAuK1ftxUU7QDhGV0aDKQu6TalgMAAAD__________4JpZIJ2NIJpcIQEnfA2iXNlY3AyNTZrMaEDfol8oLr6XJ7FsdAYE7lpJhKMls4G_v6qQOGKJUWGb_uDdGNwgiMog3VkcIIjKA
[YYUZE] new node: enr:-KG4QF4B5WrlFcRhUU6dZETwY5ZzAXnA0vGC__L1Kdw602nDZwXSTs5RFXFIFUnbQJmhNGVU6OIX7KVrCSTODsz1tK4DhGV0aDKQu6TalgMAAAD__________4JpZIJ2NIJpcIQExNYEiXNlY3AyNTZrMaECQmM9vp7KhaXhI-nqL_R0ovULLCFSFTa9CPPSdb1zPX6DdGNwgiMog3VkcIIjKA
[YYUZE] new node: enr:-Ku4QImhMc1z8yCiNJ1TyUxdcfNucje3BGwEHzodEZUan8PherEo4sF7pPHPSIB1NNuSg5fZy7qFsjmUKs2ea1Whi0EBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhBLf22SJc2VjcDI1NmsxoQOVphkDqal4QzPMksc5wnpuC3gvSC8AfbFOnZY_On34wIN1ZHCCIyg                  
[YYUZE] new node: enr:-Ku4QP2xDnEtUXIjzJ_DhlCRN9SN99RYQPJL92TMlSv7U5C1YnYLjwOQHgZIUXw6c-BvRg2Yc2QsZxxoS_pPRVe0yK8Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhBLf22SJc2VjcDI1NmsxoQMeFF5GrS7UZpAH2Ly84aLK-TyvH-dRo0JM1i8yygH50YN1ZHCCJxA                  
[YYUZE] new node: enr:-Ku4QPp9z1W4tAO8Ber_NQierYaOStqhDqQdOPY3bB3jDgkjcbk6YrEnVYIiCBbTxuar3CzS528d2iE7TdJsrL-dEKoBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhBLf22SJc2VjcDI1NmsxoQMw5fqqkw2hHC4F5HZZDPsNmPdB1Gi8JPQK7pRc9XHh-oN1ZHCCKvg
[YYUZE] new node: enr:-Le4QPUXJS2BTORXxyx2Ia-9ae4YqA_JWX3ssj4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qBJspJjIsB91LTOleFmyWWrFVATGngBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpC1MD8qAAAAAP__________gmlkgnY0gmlwhAMRHkWJc2VjcDI1NmsxoQKLVXFOhp2uX6jeT0DvvDpPcU8FWMjQdR4wMuORMhpX24N1ZHCCIyg
[YYUZE] new node: enr:-Ku4QG-2_Md3sZIAUebGYT6g0SMskIml77l6yR-M_JXc-UdNHCmHQeOiMLbylPejyJsdAPsTHJyjJB2sYGDLe0dn8uYBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpC1MD8qAAAAAP__________gmlkgnY0gmlwhBLY-NyJc2VjcDI1NmsxoQORcM6e19T1T9gi7jxEZjk_sjVLGFscUNqAY9obgZaxbIN1ZHCCIyg
[YYUZE] new node: enr:-Ku4QPn5eVhcoF1opaFEvg1b6JNFD2rqVkHQ8HApOKK61OIcIXD127bKWgAtbwI7pnxx6cDyk_nI88TrZKQaGMZj0q0Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpC1MD8qAAAAAP__________gmlkgnY0gmlwhDayLMaJc2VjcDI1NmsxoQK2sBOLGcUb4AwuYzFuAVCaNHA-dy24UuEKkeFNgCVCsIN1ZHCCIyg
[YYUZE] new node: enr:-Ku4QEWzdnVtXc2Q0ZVigfCGggOVB2Vc1ZCPEc6j21NIFLODSJbvNaef1g4PxhPwl_3kax86YPheFUSLXPRs98vvYsoBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpC1MD8qAAAAAP__________gmlkgnY0gmlwhDZBrP2Jc2VjcDI1NmsxoQM6jr8Rb1ktLEsVcKAPa08wCsKUmvoQ8khiOl_SLozf9IN1ZHCCIyg
[YYUZE] new node: enr:-LK4QA8FfhaAjlb_BXsXxSfiysR7R52Nhi9JBt4F8SPssu8hdE1BXQQEtVDC3qStCW60LSO7hEsVHv5zm8_6Vnjhcn0Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpC1MD8qAAAAAP__________gmlkgnY0gmlwhAN4aBKJc2VjcDI1NmsxoQJerDhsJ-KxZ8sHySMOCmTO6sHM3iCFQ6VMvLTe948MyYN0Y3CCI4yDdWRwgiOM
[YYUZE] new node: enr:-LK4QKWrXTpV9T78hNG6s8AM6IO4XH9kFT91uZtFg1GcsJ6dKovDOr1jtAAFPnS2lvNltkOGA9k29BUN7lFh_sjuc9QBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpC1MD8qAAAAAP__________gmlkgnY0gmlwhANAdd-Jc2VjcDI1NmsxoQLQa6ai7y9PMN5hpLe5HmiJSlYzMuzP7ZhwRiwHvqNXdoN0Y3CCI4yDdWRwgiOM

I checked the code, and find that's because default nodes are added to cfg.BootstrapNodes at cmd/utils/flags.go:1035

1034 func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {                                                              
1035     urls := params.MainnetBootnodes                                                                                      
1036     if ctx.IsSet(BootnodesFlag.Name) {                                                                                   
1037         urls = SplitAndTrim(ctx.String(BootnodesFlag.Name))                                                              
1038     } else {                                                                                                             
1039         if cfg.BootstrapNodes != nil {                                                                                   
1040             return // Already set by config file, don't apply defaults.                                                  
1041         }                                                                                                                
1042         switch {                                                                                                         
1043         case ctx.Bool(HoleskyFlag.Name):                                                                                 
1044             urls = params.HoleskyBootnodes                                                                               
1045         case ctx.Bool(SepoliaFlag.Name):                                                                                 
1046             urls = params.SepoliaBootnodes                                                                               
1047         }                                                                                                                
1048     }                                                                                                                    
1049     cfg.BootstrapNodes = mustParseBootnodes(urls)                                                                                                                                                                                                                         
1050 }

Expected behaviour

Maybe it's better that default urls is empty when configuring a totally new blockchain instead of adding some default nodes of mainnet?

Actual behaviour

no default nodes from mainnet

Steps to reproduce the behaviour

genesis.json:

{                                                                                                                           
  "config": {                                                                                                               
    "chainId"                           : 113,                                                                              
    "homesteadBlock"                    : 0,                                                                                
    "eip150Block"                       : 0,                                                                                
    "eip155Block"                       : 0,                                                                                
    "eip158Block"                       : 0,                                                                                
    "byzantiumBlock"                    : 0,                                                                                
    "constantinopleBlock"               : 0,                                                                                
    "petersburgBlock"                   : 0,                                                                                
    "istanbulBlock"                     : 0,                                                                                
    "berlinBlock"                       : 0,                                                                                
    "londonBlock"                       : 0,                                                                                
    "ethash"                            : {},                                                                               
    "terminalTotalDifficultyPassed"     : true                                                                              
  },                                                                                                                        
  "alloc": {                                                                                                                
    "0x0000000000000000000000000000000000000001": {                                                                         
      "balance": "111111111"                                                                                                
    },                                                                                                                      
    "0x0000000000000000000000000000000000000002": {                                                                         
      "balance": "222222222"                                                                                                
    }                                                                                                                       
  },                                                                                                                        
  "coinbase"                            : "0x0000000000000000000000000000000000000000",                                     
  "difficulty"                          : "0x20000",                                                                        
  "extraData"                           : "",                                                                               
  "gasLimit"                            : "0x2fefd8",                                                                       
  "nonce"                               : "0x0000000000000042",                                                             
  "mixhash"                             : "0x0000000000000000000000000000000000000000000000000000000000000000",                                                                                                                                                                
  "parentHash"                          : "0x0000000000000000000000000000000000000000000000000000000000000000",             
  "timestamp"                           : "0x00"                                                                            
}

reproduce command

geth init genesis.json

Backtrace

none

@yyuze yyuze added the type:bug label Dec 12, 2024
@yyuze
Copy link
Author

yyuze commented Dec 12, 2024

beside, geth init is not support option '--bootnodes' or '--config', hence there is no way to make params.MainnetBootnodes be overrided by user-defined nodes

@fjl
Copy link
Contributor

fjl commented Dec 16, 2024

The bootstrap nodes are not a part of the genesis configuration. They are just a node configuration setting.
Please note that discovery nodes and peers are not the same thing. The discovery system is not tied to a particular blockchain and works across all chains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants