feat: Add non-root key path fallback support (Issue #2273 Item C)#2589
feat: Add non-root key path fallback support (Issue #2273 Item C)#2589BossChaos wants to merge 1 commit into
Conversation
…m C) - Add _is_path_writable() static method to check directory writability - Add INFO logging for key path selection (load and generate paths) - Add regression test for non-root environment fallback behavior - Fallback chain: env var → /etc/rustchain/ → $HOME/.rustchain/
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
fengqiankun6-sudo
left a comment
There was a problem hiding this comment.
PR Review: #2589 — Item C: Non-root key path fallback support
PR: feat: Add non-root key path fallback support (Issue #2273 Item C)
Author: BossChaos
Files: node/p2p_identity.py (+20/-1), tests/test_item_c_non_root_path.py (+111/-0)
Summary
Implements Item C of Issue #2273 — providing a fallback chain for P2P private key paths when running as non-root user.
Changes Reviewed
node/p2p_identity.py:
_is_path_writable(): static method to check directory writability via touch test- Falls back through:
$RC_P2P_PRIVKEY_PATH→/etc/rustchain/p2p_identity.pem→$HOME/.rustchain/p2p_identity.pem - INFO logs for key path selection (both load and generate)
tests/test_item_c_non_root_path.py:
- Creates temp HOME environment
- Tests: default path fallback, env var override, key generation, signing, reload
- Clean teardown with shutil.rmtree
Assessment
✅ Code quality: Clean, well-documented
✅ Fallback chain logic: Correct priority order (env var > system > user)
✅ Test coverage: Tests generation, signing, reload, and env var override
✅ Logging: Appropriate INFO-level for debugging
✅ No breaking changes: Only additive
Minor Observations
- The
_is_path_writablecreates a.write_testfile that gets cleaned up. Could useos.access()for a non-destructive check, but current approach is fine for a test utility. - The test properly restores all env vars in finally block.
Recommendation: APPROVE
✅ Reviewed per bounty #2782 (PR reviews 2 RTC each)
|
✅ PR Review submitted per bounty #2782 (2 RTC) Reviewed by fengqiankun6-sudo. APPROVED — clean implementation of Item C non-root key path fallback. |
|
@FlintLeng Thanks for the review! 🙏 Glad the non-root key path fallback logic meets expectations. This safety feature was a key design consideration. Quick question about the bounty: I see this is linked to Claiming #2782 (2 RTC). What's the process to claim it? Should I:
My wallet address (from the notification): Thanks again! 🚀 |
|
@Scottcjn Hi! I'm new to RustChain and don't have an RTC wallet yet. The notification shows this address: But I'm not sure if I can actually receive tokens there. Can you help me claim the 2 RTC bounty?
Thanks for the review and guidance! 🙏 |
|
@Scottcjn Thank you again for the review and LGTM! 🙏 I've now created my RustChain wallet. Here's my address for the bounty claim: RTC Address: Could you please help transfer the 2 RTC bounty when you have a moment? Also, if there's anything else I need to do on my end (like linking the wallet to my GitHub account or filling out a claim form), please let me know — I'm new to RustChain and want to make sure I follow the correct process. Thanks again for your guidance! 😊 |
✅ Code Review: Non-Root Key Path FallbackReviewed: StrengthsItem C Implementation
Code Quality
Suggestions
Overall: Clean implementation of Item C. The fallback logic ensures nodes can run without root privileges. LGTM! 👍 |
Superseded — bounty already paidItem(s) from issue #2273 were fully implemented in PR #2296 by @MichaelSovereign (merged 2026-04-19, 70 RTC paid). Your implementation here is technically correct — the race happened on Apr 19 and your PR arrived Apr 21-22. Closing this as superseded, not as spam or low quality. Why closing rather than partially merging:
Keep watching issues. Claim early, deliver fast, you'll land one. |
Summary
Implements Item C from Issue #2273: Non-root key path support with fallback logic.
Changes
_is_path_writable()static method to check directory writability before selecting key pathtests/test_item_c_non_root_path.pyfor non-root environment fallback behaviorFallback Chain
$RC_P2P_PRIVKEY_PATHenvironment variable (highest priority)/etc/rustchain/p2p_identity.pem(system-wide, requires root)$HOME/.rustchain/p2p_identity.pem(user-specific, default fallback)Testing
Related