feat: Add subnet-node-diff command to dre CLI #1567
Draft
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.
This commit introduces a new command
subnet-node-diffto thedreCLI tool.The command takes two registry versions (
--version1and--version2) as input and an optional output file path (-oor--output). It then calculates the number of nodes assigned to each subnet for every registry version fromversion1 + 1up toversion2.If the node count for a subnet changes at a particular version (compared to the immediately preceding version), or if a subnet is newly added or removed, this change is recorded.
The output is a JSON array, where each element represents a subnet that experienced at least one change in its node count within the specified version range. Each subnet object includes its ID and a list of "changes," where each change entry specifies the registry version and the new node count at that version.
Key changes:
rs/cli/src/commands/subnet_node_diff.rsimplementing the command logic.SubnetNodeDiff,ChangeEntry, andSubnetChangeLogstructs for command arguments and JSON serialization.get_subnet_node_countshelper to fetch and count nodes per subnet for a given registry version.rs/cli/src/commands/mod.rsandrs/cli/src/commands/main_command.rs.DreContextandLocalStoreImplto validate various scenarios, including node count changes, subnet additions/removals, and error conditions.