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

Added command line option --static-nodes-file (#1414) #1644

Merged
merged 8 commits into from
Jan 4, 2021

Conversation

terrencecooke
Copy link
Contributor

@terrencecooke terrencecooke commented Dec 1, 2020

Now able to inject static nodes by explicitly specifying
a static nodes JSON file (.json) on the command line

Signed-off-by: Terrence Cooke terrence.s.cooke@gmail.com

PR description

Fixed Issue(s)

Changelog

@RatanRSur
Copy link
Contributor

Thanks for the contribution! We need to add a test in BesuCommandTest that makes sure StaticNodesParser.fromPath(staticNodesPath, getEnodeDnsConfiguration()); gets called with the correct values when the option is absent and present with a value. You should be able to copy and edit a test from that class that does something similar.

@terrencecooke
Copy link
Contributor Author

Sure, I'll get on it.

@RatanRSur
Copy link
Contributor

Also, before I forget, this is going to need a line in the changelog as well.

@terrencecooke
Copy link
Contributor Author

I added three test methods to class BesuCommandTest. One tests a valid file is used, a second test when an ill-formed JSON file is specified, and a third tests when the option is used but no parameter is specified.

I attempted to test when an file that does not exist is given as a parameter:
--static-nodes-file=some-file-that-does-not-exist

But no message was returned at all during the test build. This is contrary to running besu manually, you'll get the message:

| main | INFO | StaticNodesParser | StaticNodes file /home/tcooke/code/gitprojs/besu/build/install/besu/staticdir/some-file-that-does-not-exist does not exist, no static connections will be created.

Any suggestions on how I should proceed?
I was considering omitting this particularly test. What do you think?

@terrencecooke
Copy link
Contributor Author

As far as adding a line to the changelog, what should be added: the tests and the added cli option, or just the tests?

@terrencecooke
Copy link
Contributor Author

I've decided that the best test for when a file does not exist is to make sure no error message was returned. The commantOutput will be ignored for now.

As for the changelog, I'll simply add the line from the commit message:
Added command line option --static-nodes-file (#1414)

Now able to inject static nodes by explicitly specifying
a static nodes JSON file (.json) on the command line

Signed-off-by: Terrence Cooke <terrence.s.cooke@gmail.com>
Three methods added to BesuCommandTest to test newly added
--static-nodes-file cli option

Signed-off-by: Terrence Cooke <terrence.s.cooke@gmail.com>
Signed-off-by: Terrence Cooke <terrence.s.cooke@gmail.com>
* hyperledger#1644

Signed-off-by: Terrence Cooke <terrence.s.cooke@gmail.com>
@terrencecooke
Copy link
Contributor Author

Added tests to BesuCommand and a line to CHANGELOG.md

@RatanRSur RatanRSur self-assigned this Dec 16, 2020
@RatanRSur RatanRSur merged commit 9d22d03 into hyperledger:master Jan 4, 2021
@how2applyIT
Copy link

how2applyIT commented Mar 30, 2021

Running besu as a background service fails with "unable to parse static nodes file". Using a config.toml to start. Loads fine from TCL and does not require a static nodes jason. I don't have a jason to parse. Why is besu failing?

brad@tiny:~/besu-21.1.3$ sudo journalctl -fu besu.service
-- Logs begin at Mon 2021-03-29 13:07:26 EDT. --
Mar 30 09:45:03 tiny besu[67434]: ANTLR Tool version 4.7.1 used for code generation does not match the current runtime version 4.8ANTLR Runtime version 4.7.1 used for parser compilation does not match the current runtime version 4.8ANTLR Tool version 4.7.1 used for code generation does not match the current runtime version 4.8ANTLR Runtime version 4.7.1 used for parser compilation does not match the current runtime version 4.82021-03-30 09:45:03.522-04:00 | main | INFO | AbstractAltBnPrecompiledContract | Using LibEthPairings native alt bn128
Mar 30 09:45:04 tiny besu[67434]: 2021-03-30 09:45:04.173-04:00 | main | INFO | SECP256K1 | Using native secp256k1
Mar 30 09:45:04 tiny besu[67434]: 2021-03-30 09:45:04.178-04:00 | main | INFO | Besu | Starting Besu version: besu/v21.1.3/linux-x86_64/openjdk-java-11
Mar 30 09:45:04 tiny besu[67434]: 2021-03-30 09:45:04.342-04:00 | main | INFO | Besu | Static Nodes file = /media/brad/Ether/mainnet/static-nodes.json
Mar 30 09:45:04 tiny besu[67434]: 2021-03-30 09:45:04.343-04:00 | main | INFO | StaticNodesParser | Unable to parse static nodes file (/media/brad/Ether/mainnet/static-nodes.json)
Mar 30 09:45:04 tiny besu[67434]: /media/brad/Ether/mainnet/static-nodes.json
Mar 30 09:45:04 tiny besu[67434]: To display full help:
Mar 30 09:45:04 tiny besu[67434]: besu [COMMAND] --help
Mar 30 09:45:04 tiny systemd[1]: besu.service: Main process exited, code=exited, status=1/FAILURE
Mar 30 09:45:04 tiny systemd[1]: besu.service: Failed with result 'exit-code'.
Mar 30 09:45:09 tiny systemd[1]: besu.service: Scheduled restart job, restart counter is at 214.

@RatanRSur
Copy link
Contributor

Does the file /media/brad/Ether/mainnet/static-nodes.json exist? If so, what are its contents?

@how2applyIT
Copy link

I don't have one. I can start besu using a config.toml from command line with no problem. but when I start besu as a background service, using the same config.toml file, it fails wanting a static file. what am I doing wrong?

@RatanRSur
Copy link
Contributor

Can you provide the config.toml and tell me which user you're running the service as?

@how2applyIT
Copy link

here is config.toml
miner-enabled=false
graphql-http-enabled=false
sync-mode="FAST"
rpc-http-host="127.0.0.1"
pruning-enabled=false
rpc-ws-enabled=false
data-path="/media/brad/Ether/goerli"
rpc-http-enabled=true
rpc-http-apis=["ETH", "NET", "WEB3"]
network="goerli"
rpc-http-port="8545"

@how2applyIT
Copy link

how2applyIT commented Mar 30, 2021

running service with a new user and group named: besu

created user / group with: sudo chown -R besu:besu /dev/sda1

@RatanRSur
Copy link
Contributor

and the besu.service file as well please :)

@how2applyIT
Copy link

sure!
[Unit]
Description=Ethereum besu client
After=network.target
Wants=network.target
[Service]
User=besu
Group=besu
Type=simple
Restart=always
RestartSec=5
ExecStart=/home/brad/besu-21.1.3/bin/besu --config-file=/home/brad/besu-21.1.3/>
[Install]
WantedBy=default.target

@RatanRSur
Copy link
Contributor

It's odd because clearly your service is using /media/brad/Ether/mainnet as its data path but your config.toml specifies data-path="/media/brad/Ether/goerli". What's going on at the end of this line ExecStart=/home/brad/besu-21.1.3/bin/besu --config-file=/home/brad/besu-21.1.3/> ? That > is suspicious

@how2applyIT
Copy link

how2applyIT commented Mar 30, 2021

I didn't copy all of ExecStart:
ExecStart=/home/brad/besu-21.1.3/bin/besu --config-file=/home/brad/besu-21.1.3/config.toml

ugh... right. After i could not get the background to work on mainnet I reset the config to goerli and restarted. So the config and service are running goerli while the initial error was previous settings to mainnet

@how2applyIT
Copy link

restarted service with current settings:

brad@tiny:~/besu-21.1.3$ sudo journalctl -fu besu.service
-- Logs begin at Mon 2021-03-29 13:07:26 EDT. --
Mar 30 11:19:12 tiny besu[88740]: ANTLR Tool version 4.7.1 used for code generation does not match the current runtime version 4.8ANTLR Runtime version 4.7.1 used for parser compilation does not match the current runtime version 4.8ANTLR Tool version 4.7.1 used for code generation does not match the current runtime version 4.8ANTLR Runtime version 4.7.1 used for parser compilation does not match the current runtime version 4.82021-03-30 11:19:12.974-04:00 | main | INFO | AbstractAltBnPrecompiledContract | Using LibEthPairings native alt bn128
Mar 30 11:19:13 tiny besu[88740]: 2021-03-30 11:19:13.661-04:00 | main | INFO | SECP256K1 | Using native secp256k1
Mar 30 11:19:13 tiny besu[88740]: 2021-03-30 11:19:13.665-04:00 | main | INFO | Besu | Starting Besu version: besu/v21.1.3/linux-x86_64/openjdk-java-11
Mar 30 11:19:13 tiny besu[88740]: 2021-03-30 11:19:13.834-04:00 | main | INFO | Besu | Static Nodes file = /media/brad/Ether/goerli/static-nodes.json
Mar 30 11:19:13 tiny besu[88740]: 2021-03-30 11:19:13.835-04:00 | main | INFO | StaticNodesParser | Unable to parse static nodes file (/media/brad/Ether/goerli/static-nodes.json)
Mar 30 11:19:13 tiny besu[88740]: /media/brad/Ether/goerli/static-nodes.json
Mar 30 11:19:13 tiny besu[88740]: To display full help:
Mar 30 11:19:13 tiny besu[88740]: besu [COMMAND] --help
Mar 30 11:19:13 tiny systemd[1]: besu.service: Main process exited, code=exited, status=1/FAILURE
Mar 30 11:19:13 tiny systemd[1]: besu.service: Failed with result 'exit-code'.
^C

eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
…erledger#1644)

Now able to inject static nodes by explicitly specifying
a static nodes JSON file (.json) on the command line

Co-authored-by: Ratan (Rai) Sur <ratan.r.sur@gmail.com>
Signed-off-by: Terrence Cooke <terrence.s.cooke@gmail.com>
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.

3 participants