Skip to content

Conversation

@zeekay
Copy link
Member

@zeekay zeekay commented Dec 3, 2025

Summary

  • Fixes the gotcha where nodes don't track new subnets by default, causing blockchains to "disappear" after restart
  • Persists subnet tracking configuration in network_state.json alongside tmpnet data
  • Automatically restores track-subnets node flag on network restart/reload
  • Adds --dev-mode flag to enable automatic tracking of all subnets

Changes

  • pkg/localnet/state_persistence.go: New file for state persistence with tracking functions
  • pkg/localnet/helpers.go: Persist subnet ID after successful tracking via AddTrackedSubnet
  • pkg/localnet/localnet.go: Restore tracking config in CreateLocalNetwork and LoadLocalNetwork
  • cmd/networkcmd/start.go: Add --dev-mode flag for automatic subnet tracking

Test plan

  • Unit tests pass: go test -v ./pkg/localnet/...
  • Manual test: Deploy subnet, stop network, restart network, verify subnet is still tracked
  • Manual test: Start with --dev-mode, deploy multiple subnets, verify all are tracked

Problem: When a local network is stopped and restarted, nodes don't
track previously deployed subnets by default, causing blockchains to
"disappear" and requiring manual reconfiguration.

Solution:
- Add state persistence (network_state.json) to track deployed subnets
- Automatically persist subnet IDs when tracking a new subnet
- Restore track-subnets config on network restart/reload
- Add --dev-mode flag to track all subnets automatically

Files:
- pkg/localnet/state_persistence.go: State persistence for subnet tracking
- pkg/localnet/helpers.go: Persist subnet ID after successful tracking
- pkg/localnet/localnet.go: Restore tracking config on CreateLocalNetwork
  and LoadLocalNetwork
- cmd/networkcmd/start.go: Add --dev-mode flag for automatic tracking

Tests: pkg/localnet/state_persistence_test.go
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.

3 participants