NethermindEth / nethermind

A robust execution client for Ethereum node operators.
https://nethermind.io/nethermind-client
GNU General Public License v3.0
1.28k stars 445 forks source link

Nethermind client should log when it auto-generates jwt-secret file #7747

Closed obasekiosa closed 3 days ago

obasekiosa commented 2 weeks ago

Is your feature request related to a problem? Please describe.

Right now the client only logs on start up when it doesn't see a keystore directory in the data directory and generates one.

It should log when it also generates a new jwt-secret file.

MarekM25 commented 1 week ago

https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.Core/Authentication/JwtAuthentication.cs#L48

Do we need something more?

obasekiosa commented 4 days ago

https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.Core/Authentication/JwtAuthentication.cs#L48

Do we need something more?

When i ran the code, it seemed to silently do this, when it sees a keystore dir but no jwt-secret file. it does log when there's no keystore dir

obasekiosa commented 4 days ago

@ssonthal want to try this?

ssonthal commented 4 days ago

Sure. Will work on this.

obasekiosa commented 4 days ago

Sure. Will work on this.

@ssonthal

so. the first step is to reproduce the issue, especially because @MarekM25 thinks it's not an issue since there's reference code that should perform the expected action.

To reproduce: 1) ensure keystore directory is deleted

2) simply start a nethermind client (no need for consensus client, no need for change of data directory or setting JWTSecretFile option in config)

3) check that the jwt-secret file is created and theres a log on console showing that.

4) now shutdown the client and go into the keystore directory, delete the jwt-secret file.

5) restart the client and repeat the check line 3.

PS: it's easier to search the log by dumping it into a file using <start_up_command> 2>&1 log_dump.log should work on most *unix shells and windows.

it could also be hard to keep track of when the logs get to the point of attempting sync, since you are redirecting the output to a file. so you could just open another terminal and follow the dump file tail -f log-dump.log.

then search the file.

ssonthal commented 3 days ago

Hey @MarekM25 / @obasekiosa

I could reproduce this issue locally. Here's a screenshot of the logs after:

  1. running the client
  2. verifying that jwt-secret file exists at Nethermind.Runner/keystore path.
  3. shutting down the client
  4. deleting the jwt-secret file at keystore
  5. restarting the client.

Screenshot 2024-11-22 at 10 54 24 PM

As you can see the jwt-secret was auto-generated by the client but no warning logs appeared.

obasekiosa commented 3 days ago

Hey @MarekM25 / @obasekiosa

I could reproduce this issue locally. Here's a screenshot of the logs after:

  1. running the client
  2. verifying that jwt-secret file exists at Nethermind.Runner/keystore path.
  3. shutting down the client
  4. deleting the jwt-secret file at keystore
  5. restarting the client.

Screenshot 2024-11-22 at 10 54 24 PM

As you can see the jwt-secret was auto-generated by the client but no warning logs appeared.

Nice!

So the expected log level should be info not warning.

The default level of logs displayed by the client is info

now that you know this and can reproduce it, you could attempt finding out what the issue is then how to fix it. could start by looking for the code that regenerates the file, and then also the link @MarekM25 posted

another place to check is the location of the code that logs the "Reading authentication secret..." line of the logs.

good luck.

ssonthal commented 3 days ago

Hey @obasekiosa , I must have done something wrong the prev time. I tried multiple time to reproduce that issue again. but it seems to be logging the msgs fine. Tried thrice after the first attempt.

Screenshot 2024-11-22 at 11 28 28 PM

obasekiosa commented 3 days ago

Hey @obasekiosa , I must have done something wrong the prev time. I tried multiple time to reproduce that issue again. but it seems to be logging the msgs fine. Tried thrice after the first attempt.

Screenshot 2024-11-22 at 11 28 28 PM

@ssonthal looking at your log, i can see what the issue is.

its being logged as a warning. (colored) Seems your log level is now higher than info.

in the mean time wanna try 7748

I'll close this as closed

obasekiosa commented 3 days ago

closing this.