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

Comments

@wawrzek
Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

commented Jul 6, 2016

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

@karalabe

This comment has been minimized.

Copy link
Member

commented Jul 12, 2016

@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 referenced this issue Aug 29, 2016
7 of 17 tasks complete
@galladivya

This comment has been minimized.

Copy link

commented Sep 21, 2017

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

This comment has been minimized.

Copy link
Contributor

commented Sep 21, 2017

@galladivya Thanks, the wiki page is updated now.

@GaikwadPratik

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Nov 3, 2017

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

This comment has been minimized.

Copy link

commented Nov 4, 2017

@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

This comment has been minimized.

Copy link

commented Nov 7, 2017

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

This comment has been minimized.

Copy link

commented Nov 8, 2017

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Nov 9, 2017

@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.

@GeeeCoin

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor

commented Jan 22, 2019

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

@holiman holiman closed this Jan 22, 2019

@fjl fjl removed status:triage labels Jan 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.