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

admin.addPeer() doesn't add 'permament' static nodes #2766

Closed
wawrzek opened this issue Jul 1, 2016 · 15 comments
Closed

admin.addPeer() doesn't add 'permament' static nodes #2766

wawrzek opened this issue Jul 1, 2016 · 15 comments

Comments

@wawrzek
Copy link

wawrzek commented Jul 1, 2016

System information

Geth version: geth version
OS & Version: Windows/Linux/OSX
Commit hash : (if develop)

Expected behaviour

Based on documentation

You can also add static nodes at runtime via the js console using admin.addPeer():

from Connecting to the network
I expect that node added with admin.addPeer() will be reconnected after geth restart.

Actual behaviour

After restart there are not connected nodes ('--bootnodes' is broken as well - see 2708)

Steps to reproduce the behaviour

  • attach to geth
  • check the peers with admin.peers
  • add node with admin.addnode('enode://node_address')
  • confirm the peer was added (with admin.peers`)
  • restart geth
  • check peers again - the added peer won't be there
@karalabe
Copy link
Member

karalabe commented Jul 1, 2016

admin.addPeer adds static nodes only ephemerally, not permanently. A restart will flush out all of these nodes. The reason behind this is because people often use addPeer manually to debug stuff, and leaving all those peers in there ad infinitum would be more problem than help.

Permanent static nodes are also possible, but they have to be manually configured in a config file: https://github.com/ethereum/go-ethereum/wiki/Connecting-to-the-network#static-nodes

@wawrzek
Copy link
Author

wawrzek commented Jul 6, 2016

@karalabe Could you add 'Private Network' label please.

@karalabe
Copy link
Member

@fjl Could we perhaps extend the addPeer API with a flag whether to add the peer permanently? By default it could be ephemeral and if the second bool flag is specified to true, we could embed it into the datadir static-peers.json.

@wawrzek wawrzek changed the title admin.addPeer() doesn't add static nodes admin.addPeer() doesn't add 'permament' static nodes Aug 23, 2016
@zelig zelig mentioned this issue Aug 29, 2016
17 tasks
@galladivya
Copy link

But this link https://github.com/ethereum/go-ethereum/wiki/Connecting-to-the-network#static-nodes shows to add the static-nodes.json the folder which contains both keystore and chaindata folder, but in geth version 1.9 those those files/folders reside in two different folders.Then
how and where to add the static-nodes.json file

@fjl
Copy link
Contributor

fjl commented Sep 21, 2017

@galladivya Thanks, the wiki page is updated now.

@GaikwadPratik
Copy link

GaikwadPratik commented Oct 9, 2017

+1 for @karalabe’s suggestion of adding flag to allow addition of static peers during runtime.

@fjl,

As per the documentation at https://github.com/ethereum/go-ethereum/wiki/Connecting-to-the-network#static-nodes static-nodes.json needs to be present in datadir/geth directory. But I accidentally put it in datadir directory and all the static nodes were shown in peer list. Is this expected behavior or is this a bug?

@galladivya
Copy link

Hey can someone tell, how to connect/add other peers when a node is connected.I have used admin.addPeers() but the added nodes are temporary.I used --bootnodes command for the other nodes to connect,but no output.

@GaikwadPratik
Copy link

@galladivya ,
Why don't you use static-node.json file? you will have to reconnect the node. but that is quickest way to add peers as of now. Just mention enode address of the nodes you want to add as a peer with json file. And put that file in directory of each node you want to connect with each other.

@galladivya
Copy link

My node is not connecting with any peer even I added static-nodes.json file to the data directory folder.
net.listening returns true

@GaikwadPratik
Copy link

Is your folder structure after creating node is like as below:
image

If yes, can you please provide the contents of the static-nodes.json file? Also make sure the static-nodes json has values in array(comma separated) as below:

image

@galladivya
Copy link

galladivya commented Nov 8, 2017

@fjl
@karalabe
[
“enode://dc3e4f23315f90bb62c9096df01b7f07c4040a8520f046801e2fa6812aa4402d70f6073f6226779a9183137cb789e98492d197db1380784fd0d213c30e9651ec@192.168.1.11:30331”,
“enode://1c745b2459129ca07b1345487fedda6b8516194a4208d93bd696f3684b44cbf16a5cdddb99cc1753b1ba43884d93c5d27403dce0c6638787f74a40428a7c9543@192.168.1.17:30332”,
“enode://be0c22a7a8451766c2894cd11143bc3128d5840cca161ad91b2bd9078d1dde56ddc19d0258e86e51cf7b7e9cda43b900a20ef392925ae8a19ab24c4cf016d69c@192.168.1.26:30333”,
“enode://1e07a29f0c94617d045dcf4f0d8597fd07757cbf8e48f66e78b72b142bf9b61d0d7bcce8fe21479ad0bd02bff945a8c062f2af03c0e1be670e1452b845fa420e@192.168.1.15:30334”
]

@galladivya
Copy link

galladivya commented Nov 8, 2017

@fjl @karalabe
That's my static-nodes.json file and i encountered this error
ERROR[11-08|15:14:59] Can't load node file /usr/local/Cellar/test1/static-nodes.json: JSON syntax error at /usr/local/Cellar/test1/static-nodes.json:2: invalid character 'â' looking for beginning of value

@GaikwadPratik
Copy link

@galladivya ,

I am not sure. The only thing I can suggest you is to copy the contents of JSON file into a notepad or something where special characters will be discarded and try again. Because I don't see 'â' anywhere. Or may be someone else can suggest something.

@CryptoKiddies
Copy link

CryptoKiddies commented Jun 2, 2018

@fjl using statis-nodes.json results in tens of minutes to connect to my other peers. Is this normal? Also, has the trusted-nodes feature been deprecated? Is there any difference between the two in recent Geth versions? Thanks

@holiman
Copy link
Contributor

holiman commented Jan 22, 2019

The functionality already exists in the form of static nodes json file, I'm closing this

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

No branches or pull requests

8 participants