Skip to content

Fix GXS Identity propagation and local cache invalidation#253

Open
jolavillette wants to merge 2 commits intoRetroShare:masterfrom
jolavillette:GxsIdDisplayAndPropagation
Open

Fix GXS Identity propagation and local cache invalidation#253
jolavillette wants to merge 2 commits intoRetroShare:masterfrom
jolavillette:GxsIdDisplayAndPropagation

Conversation

@jolavillette
Copy link
Contributor

Code and comment by Antigravity

Fix GXS Identity propagation and local cache invalidation
This PR addresses two critical issues preventing peer avatar updates (GXS Identities) from propagating to the network and updating locally.

  1. Fix Network Propagation
  • Issue: p3IdService::updateIdentity modified identity data (e.g., avatar) but failed to update the mPublishTs (timestamp). Peers rejected these updates as duplicates.
  • Fix: Explicitly set group.mMeta.mPublishTs = time(NULL); when updating an identity to ensure a new version number is broadcast.
  1. Fix Local Cache Staleness
  • Issue: The internal mKeyCache was not invalidated on update. Local service calls continued to return stale data even after the database was updated.
  • Fix: In p3IdService::notifyChanges(), we now invalidate the cache entry (mKeyCache.erase()) upon receiving TYPE_UPDATED or TYPE_PUBLISHED events.
  • Note: Invalidation is performed in [notifyChanges] (after signing/storage) rather than updateIdentity to prevent remove the Private Key before the signing process completes.

group.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PUBLIC;

// Fixed: Explicitly update timestamp to ensure network propagation
group.mMeta.mPublishTs = time(NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useless: publishGrps() will update this when signing the new group data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests show that when we remove set group.mMeta.mPublishTs = time(NULL); the modified avatar stops propagating to the gxsid list in People and to the participants list in Chats

here is the reason why (Antigravity)

"While it is true that RsGenExchange::publishGrps updates the timestamp in the metadata, it does so AFTER the group data has already been serialized into the binary payload (grp->grp.setBinData).
If we rely solely on publishGrps, the serialized payload will contain the old timestamp, while the outer metadata has the new one. This mismatch causes peers to treat the data as stale or invalid, preventing the update (e.g., new avatar) from propagating correctly.
Therefore, explicitly updating mPublishTs in p3idservice.cc before the serialization starts is mandatory to ensure the payload carries the correct timestamp"

Copy link
Contributor

@csoler csoler Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that after rsgenexchange.cc:2798 (in the original code just after service_createGroup() ) you can update the publish TS (which will happen before serialization):
grpItem->meta.mPublishTs = time(NULL);
This change will be inherited by all GXS services, not just p3identity. Some other service do not update the publish ts in their update() methods (e.g. channels doesn't do it in editChannel()).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix GXS Identity propagation and local cache invalidation

  • Move mPublishTs update to RsGenExchange::publishGrps to ensure the signed payload timestamp matches the metadata.
  • Remove aggressive mKeyCache.erase() in p3IdService::updateGroup to prevent unnecessary cache invalidation.
  • Remove redundant mPublishTs assignment in p3IdService.

@jolavillette jolavillette force-pushed the GxsIdDisplayAndPropagation branch 2 times, most recently from 36a0c61 to 3621318 Compare January 27, 2026 06:34
@jolavillette jolavillette force-pushed the GxsIdDisplayAndPropagation branch from 3621318 to 2891221 Compare January 27, 2026 21:24
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