feat: create node with identity from provided key#1183
Conversation
WalkthroughUpdates tn-node startup in deployments/infra/stacks/docker-compose.template.yml: adds .env support, revises initialization logs, and introduces conditional override of generated node identity using TN_PRIVATE_KEY with validation and nodekey.json creation, while preserving existing-config detection and subsequent node start sequence. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User/.env
participant DC as docker-compose
participant C as tn-node Container
participant FS as Persistent Storage
participant KW as kwild
DC->>C: Start service (env_file: .env)
C->>FS: Check existing node configuration
alt Config exists
C->>C: Log "Using existing node configuration from persistent storage."
else No config
C->>C: Log "No existing configuration found. Generating new node configuration..."
alt TN_PRIVATE_KEY provided
U-->>C: TN_PRIVATE_KEY
C->>C: Validate 64-hex
C->>FS: Write /root/.kwild/nodekey.json (type: secp256k1)
C->>FS: Set permissions
C->>C: Log "Node identity set from provided private key."
else No TN_PRIVATE_KEY
C->>C: Generate node identity
C->>C: Log "Using generated node identity."
end
end
C->>KW: Start node
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
Comment |
Time Submission Status
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
deployments/infra/stacks/docker-compose.template.yml(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: acceptance-test
🔇 Additional comments (5)
deployments/infra/stacks/docker-compose.template.yml (5)
25-26: LGTM!Adding
.envfile support is a standard approach for injecting environment variables likeTN_PRIVATE_KEYinto the container.
45-45: LGTM!The updated log message more accurately reflects that the entire node configuration is being generated, not just the identity.
59-59: LGTM!The comment accurately describes the initialization step.
69-72: Validation is format-only, not cryptographic.The hex format validation ensures the key is 64 characters, but doesn't verify that it's a valid secp256k1 private key. This is acceptable since kwild will reject invalid keys at startup, providing fail-fast behavior.
79-81: LGTM!The updated message is consistent with the terminology changes elsewhere and accurately describes the else branch behavior.
resolves: https://github.com/trufnetwork/truf-network/issues/1244
Summary by CodeRabbit
New Features
Chores