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

feat: miner: --peer-id-keyfile flag for lotus-miner init #11474

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

svilenkov
Copy link

Related Issues

Proposed Changes

This PR introduces the --peer-id-keyfile option to miner initialization, allowing users to import pre-existing or deterministic libp2p peer IDs. This feature is particularly useful in integration tests where consistent peer IDs are required.

By enabling the import of specific peer IDs, we streamline testing processes and enhance the predictability of test outcomes.

Additional Info

sample lib2p-12D3KooWQooJ1ytSud5qTJSeG49kx5o38k1PbZHs4kMfP4QVXq1R.key

echo -n "7b2254797065223a226c69627032702d686f7374222c22507269766174654b6579223a224341455351474b655a42397453375774686b6e624c48716f4a75392f396d667a5661436179355954653773734c35323933726f6836573138637632393039556370576f4a5971466c4f2b744c4f2b347a7a656777686832664d6d673d227d" > lib2p-12D3KooWQooJ1ytSud5qTJSeG49kx5o38k1PbZHs4kMfP4QVXq1R.key

It can be inspected for debugging puproses like this:

ᛝ cat lib2p-12D3KooWQooJ1ytSud5qTJSeG49kx5o38k1PbZHs4kMfP4QVXq1R.key | xxd -p -r | jq
{
  "Type": "libp2p-host",
  "PrivateKey": "CAESQGKeZB9tS7WthknbLHqoJu9/9mfzVaCay5YTe7ssL5293roh6W18cv2909UcpWoJYqFlO+tLO+4zzegwhh2fMmg="
}

In the end it should match with the private key generated in the ~/.miner/keystore/NRUWE4BSOAWWQ33TOQ file:

{"Type":"libp2p-host","PrivateKey":"CAESQGKeZB9tS7WthknbLHqoJu9/9mfzVaCay5YTe7ssL5293roh6W18cv2909UcpWoJYqFlO+tLO+4zzegwhh2fMmg="}%

Affected log output lines on miner init by this change look like this:

2023-12-03T13:57:32.937+0100	INFO	main	lotus-miner/init.go:215	Initializing repo
2023-12-03T13:57:32.937+0100	INFO	repo	repo/fsrepo.go:266	Initializing repo at '/Users/igor/.miner'
2023-12-03T13:57:38.773+0100	INFO	main	lotus-miner/init.go:435	Importing prvoided libp2p host keyfile: /Users/igor/zgroth-labs/lib2p-12D3KooWQooJ1ytSud5qTJSeG49kx5o38k1PbZHs4kMfP4QVXq1R.key
2023-12-03T13:57:41.743+0100	INFO	main	lotus-miner/init.go:447	initialized libp2p peerid: 12D3KooWQooJ1ytSud5qTJSeG49kx5o38k1PbZHs4kMfP4QVXq1R

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • If the PR affects users (e.g., new feature, bug fix, system requirements change), update the CHANGELOG.md and add details to the UNRELEASED section.
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

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.

1 participant