Skip to content

fix(peerstore): load persisted keypairs on peerstore restore#1331

Open
bhuvan-somisetty wants to merge 9 commits into
libp2p:mainfrom
bhuvan-somisetty:fix/persistent-peerstore-keypair-load
Open

fix(peerstore): load persisted keypairs on peerstore restore#1331
bhuvan-somisetty wants to merge 9 commits into
libp2p:mainfrom
bhuvan-somisetty:fix/persistent-peerstore-keypair-load

Conversation

@bhuvan-somisetty
Copy link
Copy Markdown

Keypairs were being serialized and saved to the datastore correctly, but the deserialization path on restore was completely bypassed. Both the sync and async implementations had the loading code commented out with a pass placeholder and a TODO note, meaning every time a node restarted and the peerstore was rehydrated from SQLite, the peer's public and private keys would silently disappear. Addresses, metadata, and protocols came back fine, but keys did not.

This is a direct blocker for #312. A persistent peerstore that drops keypairs on restart can't actually provide persistent node identity, which is the whole point.

The fix calls deserialize_public_key and deserialize_private_key (already present in libp2p.crypto.serialization) when loading key data from the datastore. The serialization side was already correct; only the load path was missing. Both the sync SyncPersistentPeerStore and async AsyncPersistentPeerStore are updated symmetrically.

Three tests cover the new behavior: SQLite round-trip for sync, SQLite round-trip for async, and a sanity check that the memory backend correctly does not persist across instances.

seetadev and others added 9 commits November 6, 2025 11:47
Added a new issue template for the DMP 2026 project, including fields for project description, goals, setup, expected outcomes, acceptance criteria, implementation details, mockups, product name, organization name, governance domain, technical skills required, mentors, and categories.
Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
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