Skip to content

Conversation

@zeekay
Copy link
Member

@zeekay zeekay commented Dec 3, 2025

Summary

  • Add --no-snapshot flag to network start command for fresh starts
  • Add --dev-mode flag to enable automatic subnet tracking
  • Add localnet.SaveNetworkState() called on network stop to persist subnet registrations, validators, and network configuration
  • Add NetworkStateData struct with SubnetStateInfo and ValidatorStateInfo for comprehensive state tracking
  • Add unit tests for state persistence functionality

Problem

Loss of P-Chain state or custom subnet tracking on node restart. When running lux network start and lux network stop cycles, the P-Chain registrations, subnet data, validator sets, and balances were not being preserved.

Solution

This PR implements automatic state persistence by:

  1. Saving network state (subnets, validators, tracked subnets) to network_state.json during network stop
  2. Loading and restoring state during network start
  3. Providing --no-snapshot flag for users who want a clean start
  4. Providing --dev-mode flag for automatic subnet tracking

Test plan

  • Unit tests for NetworkStateData serialization
  • Unit tests for AddTrackedSubnet/RemoveTrackedSubnet
  • Unit tests for DevMode toggle
  • Unit tests for ClearNetworkState
  • Manual testing of network start/stop cycles with subnet deployments

This change fixes the loss of P-Chain state and custom subnet tracking
on node restart by implementing automatic snapshot save/load with
enhanced state tracking.

Changes:
- Add --no-snapshot flag to network start command for fresh starts
- Add --dev-mode flag to enable automatic subnet tracking
- Add localnet.SaveNetworkState() called on network stop to persist
  subnet registrations, validators, and network configuration
- Add NetworkStateData struct with SubnetStateInfo and ValidatorStateInfo
- Add comprehensive unit tests for state persistence functionality

The state is saved to network_state.json in the network data directory
and survives start/stop cycles, ensuring deployed subnets and validators
are tracked across restarts.
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