feat: load chain spec from file via --chain-spec CLI flag#794
Merged
anshalshukla merged 13 commits intoMay 7, 2026
Conversation
--chain-spec CLI flag
Comment on lines
+189
to
+194
| const chain_spec = if (self.options.chain_spec) |path| | ||
| std.fs.cwd().readFileAlloc(allocator, path, 1024 * 1024) catch |err| { | ||
| self.logger.err("failed to load chain spec at '{s}': {any}", .{ path, err }); | ||
| return err; | ||
| } | ||
| else |
Collaborator
There was a problem hiding this comment.
I think after reading from the file we should do some validation checks to confirm that all the fields are present and are of valid types or it might fall back to default values and might cause issues later.
Contributor
Author
There was a problem hiding this comment.
Thanks for the feedback, will make sure to add those.
Contributor
Author
There was a problem hiding this comment.
Added the checks.
Contributor
Author
|
Adapted to the |
Contributor
|
@markolazic01 can you pls resolve conflicts. We can merge this PR later today. |
Contributor
Author
|
@ch4r10t33r Resolved now |
anshalshukla
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: load chain spec from file via
--chain-specCLI flagCloses #677
Problem
The chain spec was hardcoded as an inline JSON string in
NodeRunner.init, meaning the chain name and preset couldn't be changed without recompiling.Solution
Added a
--chain-spec <path>CLI flag that loads the chain specification from a JSON file at startup. If the flag is not provided, the existing hardcoded default is used as a fallback.Changes
chain-specoption toNodeCommandinmain.zigwith help textchain_specfield toNodeOptionsinnode.zigbuildStartOptionsNode.init, reads the file viareadFileAllocwhen the flag is set, with error logging on failureThe issue also mentions loading from config YAML (# 2) and bundled preset names (# 3) as possible approaches — those could be follow-ups if desired.