Skip to content

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
shiling/update
Mar 25, 2026
Merged

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
shilingwang merged 6 commits intomainfrom
shiling/update

Conversation

@shilingwang
Copy link
Contributor

@shilingwang shilingwang commented Mar 24, 2026

#NODE-1911

Summary

Replaces the hand-rolled NNS state-tree parsing for subnet types and canister ranges with Agent::fetch_subnet_by_id from ic-agent.
Before: SubnetsInfoFetcher performed three distinct NNS round trips per cycle:

  • Read NNS /subnet to get all subnet IDs and their types (hand-parsed from the hash tree)
  • Read NNS /canister_ranges/ once per subnet (CBOR-decoded manually)

After: The fetcher still reads NNS /subnet to discover subnet IDs, then calls agent.fetch_subnet_by_id concurrently 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 by ic-agent.

Changes

  • fetch_subnetsfetch_subnet_ids: now only extracts subnet IDs from the NNS /subnet subtree; type extraction removed
  • fetch_canister_ranges removed: replaced by agent.fetch_subnet_by_id calls inlined into fetch()
  • map_subnet_type added: thin free function mapping ic-agent's SubnetType to the local enum, keeping the local type Copy and the public API decoupled from ic-agent internals
  • From<&[u8]> for SubnetType removed: no longer needed since raw byte parsing is handled by ic-agent
  • Test fixtures removed: testdata/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 exercises SubnetsInfo::newArcSwapOption::storeloadsubnet_type() directly.

@shilingwang shilingwang marked this pull request as ready for review March 24, 2026 12:29
@shilingwang shilingwang requested a review from a team as a code owner March 24, 2026 12:29
@shilingwang shilingwang enabled auto-merge March 25, 2026 08:51
@shilingwang shilingwang merged commit dead2cb into main Mar 25, 2026
6 checks passed
@shilingwang shilingwang deleted the shiling/update branch March 25, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants