fix(context): bootstrap group metadata on join when not replicated locally#2092
Closed
fix(context): bootstrap group metadata on join when not replicated locally#2092
Conversation
…cally
When a group is created without contexts, the joiner's node has no way
to receive the group metadata via P2P replication before attempting to
join. Previously this was a hard bail ("group metadata is missing
locally"), making it impossible to accept group invitations when the
group had no contexts.
Now, when group metadata is missing locally during join_group, we
bootstrap stub metadata (mirroring the pattern in join_context.rs),
add the inviter as admin, and subscribe to the group topic. The
JoinWithInvitationClaim governance op is signed with a zero state hash
so the admin's node accepts it without a state-hash mismatch.
Co-authored-by: Sandi Fatic <chefsale@users.noreply.github.com>
There was a problem hiding this comment.
🤖 AI Code Reviewer
Reviewed by 1 agents | Quality score: 32% | Review time: 99.7s
💡 1 suggestions. See inline comments.
🤖 Generated by AI Code Reviewer | Review ID: review-d74331e2
|
|
||
| if let Err(e) = | ||
| group_store::apply_local_signed_group_op(&datastore, &signed_op) | ||
| { |
There was a problem hiding this comment.
💡 Warning log missing group_id for correlation
The warning includes joiner_identity and error but omits group_id, making it harder to correlate with other group-related logs.
Suggested fix:
Add `%group_id` to the warn! fields: `warn!(%group_id, %joiner_identity, %e, "failed to apply...")`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[context] Fix group invitation join when group metadata is not replicated locally
Description
Fixes an edge case where joining a group via invitation fails when the joiner's node does not have the group metadata replicated locally. This commonly happens when:
Previously,
join_groupwould immediately bail with:This was a dead end — the joiner couldn't subscribe to receive group state because they weren't a member yet, and they couldn't become a member because they didn't have the group state.
The fix follows the same bootstrap pattern already used by
join_context(lines 210-233 ofjoin_context.rs):GroupMetaValuewith the inviter as adminJoinWithInvitationClaimgovernance op with a zero state hash (since the stub metadata won't match the admin's real state), which the receiving nodes accept per the existing zero-hash bypass inapply_local_signed_group_opFor the non-bootstrapped case (group metadata already replicated), the existing
sign_apply_and_publishflow with real state hash is preserved.Test plan
cargo check -p calimero-context— passescargo clippy -p calimero-context -- -A warnings— passescargo fmt --check— passesManual verification scenario:
Documentation update
None — this is a bug fix to an internal handler with no public API changes.