refactor: Replaces the hand-rolled NNS state-tree parsing for subnet types and canister ranges with Agent::fetch_subnet_by_id from ic-agent#191
Merged
shilingwang merged 6 commits intomainfrom Mar 25, 2026
Conversation
blind-oracle
approved these changes
Mar 24, 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.
#NODE-1911
Summary
Replaces the hand-rolled NNS state-tree parsing for subnet types and canister ranges with
Agent::fetch_subnet_by_idfromic-agent.Before:
SubnetsInfoFetcherperformed three distinct NNS round trips per cycle:After: The fetcher still reads NNS /subnet to discover subnet IDs, then calls
agent.fetch_subnet_by_idconcurrently for each subnet, which retrieves both the type and canister ranges from each subnet's own state tree in a single round trip per subnet — with all certificate verification and tree parsing handled byic-agent.Changes
fetch_subnets→fetch_subnet_ids: now only extracts subnet IDs from the NNS /subnet subtree; type extraction removedfetch_canister_rangesremoved: replaced byagent.fetch_subnet_by_idcalls inlined intofetch()map_subnet_type added: thin free function mappingic-agent'sSubnetTypeto the local enum, keeping the local type Copy and the public API decoupled from ic-agent internalsFrom<&[u8]> for SubnetTyperemoved: no longer needed since raw byte parsing is handled byic-agenttestdata/subnet.bin,testdata/nns_canister_ranges.bin, and all related test infrastructure (TESTNET_ROOT_KEY,read_state_response, the extended ingress-expiry workaround). Tests that required real BLS-signed certificates are replaced by a pure in-memory subnet_type_lookup test that exercisesSubnetsInfo::new→ArcSwapOption::store→load→subnet_type()directly.