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

Implement cli tool to handle key material #2453

Merged
merged 9 commits into from
Mar 11, 2022

Conversation

demfabris
Copy link
Contributor

@demfabris demfabris commented Jan 27, 2022

So for decoding, if I understood correctly we are reading from a IPFS config file passed as argument.
Do we check for this file under IPFS_PATH as well?

For encoding are we reusing this implementation: peer-id-generator ?

@mxinden
Refs: #482

@mxinden
Copy link
Member

mxinden commented Jan 31, 2022

Thanks for following up here @fabricio7p!

Do we check for this file under IPFS_PATH as well?

I would require passing a config file path for now. I would argue that libp2p shouldn't depend on IPFS concepts much. While we would depend on their file-format, at least we wouldn't depend on their filesystem conventions or environment variables. Does that make sense?

For encoding are we reusing this implementation: peer-id-generator ?

Something along those lines. In my eyes, by default it should just generate a random identity. The feature of choosing a custom prefix should be a nice-to-have.

@mxinden
Copy link
Member

mxinden commented Feb 1, 2022

I think the ipfs key XXX subcommand is a good guiding example (thanks @lidel for the pointer). No need to thrive for feature parity though. The rust-libp2p client should be a lot more minimalist and without the IPFS related concepts (IPNS).

@demfabris
Copy link
Contributor Author

I think the ipfs key XXX subcommand is a good guiding example (thanks @lidel for the pointer). No need to thrive for feature parity though. The rust-libp2p client should be a lot more minimalist and without the IPFS related concepts (IPNS).

Sure thing, I'll post updates soon.
Thanks for the investigation

misc/keygen/src/main.rs Show resolved Hide resolved
misc/keygen/src/main.rs Show resolved Hide resolved
@demfabris
Copy link
Contributor Author

I choose to use argh to be way way lighter than clap/structopt.
Did a couple of changes to your peer-id-generator logic because it was hanging on my PC, check review

cli api

# Gen random key material, with prefix at your option
keygen rand [--prefix <prefix>]

# Gen key material from IPFS config
keygen from --config <path>

@demfabris demfabris marked this pull request as ready for review February 4, 2022 11:37
Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Great. Thanks for the work here!

I choose to use argh to be way way lighter than clap/structopt

We use structopt in all other examples across the project. I don't really have a strong opinion on which one to use, but as a maintainer I would prefer being consistent.

Unless you feel strongly about it, I would prefer if this one would use structopt as well.

Cargo.toml Outdated Show resolved Hide resolved
misc/keygen/src/cli.rs Outdated Show resolved Hide resolved
@demfabris
Copy link
Contributor Author

Added --json flag to output json formatted. Exactly the way it's on the IPFS config file
Using structopt

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

3 more comments. Otherwise this is good to go. Thanks for the new tool!

misc/keygen/Cargo.toml Outdated Show resolved Hide resolved
misc/keygen/Cargo.toml Outdated Show resolved Hide resolved
misc/keygen/src/main.rs Outdated Show resolved Hide resolved
misc/keygen/Cargo.toml Outdated Show resolved Hide resolved
@demfabris
Copy link
Contributor Author

All points addressed 👍🏻

ready to go?

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks @demfabris. This tool will be helpful going forward.

@mxinden
Copy link
Member

mxinden commented Mar 11, 2022

Unrelated test failure:

---- test_dial_error stdout ----
thread 'test_dial_error' panicked at 'Unexpected swarm event: Behaviour(InboundProbe(Error { probe_id: ProbeId(0), peer: PeerId("12D3KooWL97LtsmyDtSbDxJ8675kG5Ne49hZX41y5Na7h64RXZNz"), error: Response(DialError) })).', protocols/autonat/tests/test_server.rs:257:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

https://github.com/libp2p/rust-libp2p/runs/5510014225?check_suite_focus=true

//CC @elenaf9

@mxinden mxinden merged commit e38eb09 into libp2p:master Mar 11, 2022
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.

2 participants