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

File path support for p2p private key #1904

Closed
wants to merge 2 commits into from
Closed

Conversation

weiihann
Copy link
Contributor

@weiihann weiihann commented Jun 12, 2024

Description

This PR adds filepath support to two existing P2P-related tools and flags, namely genp2pkeypair and --p2p-private-key.

Example

Command: juno genp2pkeypair --file nodekey

  • This would generate a file containing the key pairs information.
  • Note that users can still do juno genp2pkeypair just like before.

Command: juno --p2p-private-key nodekey

  • This would read the private key given in the nodekey file.
  • Note that users can also just parse the private key (i.e. juno --p2p-private-key <private-key>) just like before.
  • The content of the file should either be just the private key or contains the "P2P Private Key:" prefix. Examples are shown below:
# Example 1: Pure private key
<private-key>

# Example 2: With prefix
P2P Private Key: <private-key>

Rationale

It's more of a UX nicety to allow users to generate key pairs in a file and parse the file to use as a private key, rather than having to copy pasting manually.

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 70.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 75.44%. Comparing base (a30d388) to head (2abdcd9).
Report is 41 commits behind head on main.

Files Patch % Lines
cmd/juno/juno.go 53.33% 4 Missing and 3 partials ⚠️
cmd/juno/genp2pkeypair.go 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1904      +/-   ##
==========================================
- Coverage   75.51%   75.44%   -0.08%     
==========================================
  Files         100      100              
  Lines        8982     9003      +21     
==========================================
+ Hits         6783     6792       +9     
- Misses       1599     1605       +6     
- Partials      600      606       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

cmd/juno/juno.go Outdated
@@ -148,7 +149,7 @@ const (
"These peers can be either Feeder or regular nodes."
p2pFeederNodeUsage = "EXPERIMENTAL: Run juno as a feeder node which will only sync from feeder gateway and gossip the new" +
" blocks to the network."
p2pPrivateKeyUsage = "EXPERIMENTAL: Hexadecimal representation of a private key on the Ed25519 elliptic curve."
p2pPrivateKeyUsage = "EXPERIMENTAL: Hexadecimal representation of a private key on the Ed25519 elliptic curve. Also accepts a file path."
Copy link
Contributor

Choose a reason for hiding this comment

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

I am unsure whether it is a good idea to have a flag accept 2 different input types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. My thought process is having one flag can abstract out the input process.

That could be confusing. Perhaps it's better to have a separate flag to accept file path for private key. Let me work on that.

Copy link
Contributor

@derrix060 derrix060 left a comment

Choose a reason for hiding this comment

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

There are some conflicts... @weiihann could you rebase and fix those ? :)

@weiihann weiihann force-pushed the weiihann/p2p-cli branch 2 times, most recently from ce3e6ac to 804257b Compare August 5, 2024 08:58
@weiihann weiihann changed the title cmd/juno: add filepath support for p2p CLI File path support for p2p private key Aug 5, 2024
@derrix060 derrix060 dismissed their stale review August 5, 2024 11:21

fixed conflicts

@weiihann
Copy link
Contributor Author

On a second thought, I find this feature irrelevant as users can just use environment variables.

@weiihann weiihann closed this Aug 22, 2024
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.

None yet

3 participants