Skip to content

fix: --p2p-secret-key silently reverts to default location if file is not found (#2498)#2508

Closed
mightypenguin wants to merge 2 commits intoparadigmxyz:mainfrom
mightypenguin:main
Closed

fix: --p2p-secret-key silently reverts to default location if file is not found (#2498)#2508
mightypenguin wants to merge 2 commits intoparadigmxyz:mainfrom
mightypenguin:main

Conversation

@mightypenguin
Copy link

Resolves #2498

@mightypenguin mightypenguin requested a review from onbjerg as a code owner May 1, 2023 19:45
@codecov-commenter
Copy link

codecov-commenter commented May 1, 2023

Codecov Report

Merging #2508 (97ef884) into main (6a55f70) will decrease coverage by 0.06%.
The diff coverage is 0.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main    #2508      +/-   ##
==========================================
- Coverage   71.68%   71.63%   -0.06%     
==========================================
  Files         489      489              
  Lines       61020    61088      +68     
==========================================
+ Hits        43744    43761      +17     
- Misses      17276    17327      +51     
Flag Coverage Δ
integration-tests 17.97% <0.00%> (-0.04%) ⬇️
unit-tests 66.66% <0.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
bin/reth/src/args/secret_key.rs 0.00% <0.00%> (ø)
bin/reth/src/node/mod.rs 11.09% <0.00%> (-0.34%) ⬇️

... and 8 files with indirect coverage changes

@mightypenguin
Copy link
Author

Not sure if we want to make changes to other places that use secret_key.rs?
src/stage/mod.rs
src/p2p/mod.rs

@mightypenguin mightypenguin marked this pull request as draft May 1, 2023 23:44
@mightypenguin mightypenguin marked this pull request as ready for review May 3, 2023 02:50
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would like to see some tests for this, unclear how this fixes it because it looks like the function still behaves exactly as before.

Comment on lines +235 to +238
let mut secret_key_path = secret_key_path.as_path();
if secret_key_path.to_str() == Some("") {
secret_key_path = default_secret_key_path.as_path();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reasoning for this here?

Copy link
Author

@mightypenguin mightypenguin May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current code always returns the default secret_key_path and does NOT use the --p2p-secret-key parameter if set.
My changes use "p2p-secret-key" if specified, else, use default value.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, perhaps I misunderstood

so the actual bug here is that the user input is ignored?

silently reverts to default location if file is not found

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how exactly does your change fix

Setup Reth so that the default location for the p2p secret key is not accessible (e.g. systemd ProtectHome=True).
Set --p2p-secret-key to a non existent file.
This results in the following very confusing failure:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problems Address here:

  1. User input is ignored.
    This is a new problem introduced the the last couple days that I ran across and tried to fix here.
    Blame Commit:
    feat: use chain-specific data dirs (feat: use chain-specific data dirs #2495)
    ecc7ae9

  2. Original problem
    The --p2p-path-key set by user.
    If the file does not exist, then the default_path is silently used/created without erroring.

This PR Addresses 2 cases:

  1. If p2p-secret-key IS set, try to load it, if it doesn't exist, create it.
  2. If p2p-secret-key is NOT set, use default path, if it doesn't exist create it.

@mightypenguin mightypenguin requested a review from mattsse May 3, 2023 21:56
@mattsse mattsse requested a review from Rjected May 3, 2023 22:07
@mattsse mattsse added the A-cli Related to the reth CLI label May 3, 2023
@mightypenguin
Copy link
Author

would like to see some tests for this, unclear how this fixes it because it looks like the function still behaves exactly as before.

I believe the reported issue is OBE now.
A new issue needs to be created addressing that the p2p-secret-key flag is no longer respected.
And then this fix should apply for that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Related to the reth CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

----p2p-secret-key silently reverts to default location if file is not found

3 participants