Skip to content

CometNet state becomes unloadable when a persisted PEX peer has an invalid address, causing stats to reset #636

Description

@zeusmaggy-web

Description

CometNet can permanently lose its persisted statistics after a restart when
one of the persisted PEX peers has an invalid/unusable WebSocket address.

In my case, the persisted peer was:

wss://comet2.042575.xyz/cometnet/ws

The peer was stored with:

source: pex

On restart, CometNet reports:

Failed to load CometNet state:
persisted peer address is invalid:
wss://comet2.042575.xyz/cometnet/ws

When this happens, the entire persisted CometNet state is rejected and CometNet
starts with fresh runtime statistics.

This caused my node's counters to reset from:

torrents_propagated: 125,917,242

to approximately:

torrents_propagated: 500,000

and later even lower after subsequent restarts.

Important details

The persistent state file itself is valid and contains the historical statistics.

The node identity is also unchanged:

Node ID: dbc091d5

The persistent data directory is:

/app/data/cometnet

The problematic peer is a PEX-discovered peer.

I manually removed only that peer from discovery.known_peers and regenerated
the state integrity signature using the existing node private key. After doing
that, CometNet successfully loaded the state and restored the 125,917,242
propagated counter.

Startup then showed:

Loaded reputation data for 173 peers
CometNet started - Node ID: dbc091d5

with no "Failed to load CometNet state" error.

However, the invalid peer was subsequently rediscovered through PEX, so the
problem can recur on a future restart.

Expected behavior

An invalid persisted peer should not cause the entire CometNet state to be
discarded.

Ideally CometNet should:

  1. Load the valid persisted state.
  2. Skip/remove the invalid peer.
  3. Continue loading the remaining peers, reputation, pools, and statistics.
  4. Save the cleaned state with a new valid integrity signature.

Alternatively, invalid peers could be rejected before they are persisted.

Actual behavior

One invalid PEX peer causes the entire persisted state load to fail:

Failed to load CometNet state:
persisted peer address is invalid: ...

CometNet then starts with fresh counters.

This makes a single bad PEX peer capable of resetting persistent CometNet
statistics after a normal Docker restart.

Environment

Comet Docker deployment
Persistent /app/data/cometnet bind mount
COMETNET_CONTRIBUTION_MODE=full
COMETNET_ALLOW_PRIVATE_PEX=true

The issue reproduces across normal scheduled Docker restarts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions