Skip to content

Feat/channel invitation workflow part 4#808

Open
Pranav-d33 wants to merge 5 commits into
hyperledger-cello:mainfrom
Pranav-d33:feat/channel-invitation-workflow-part-4
Open

Feat/channel invitation workflow part 4#808
Pranav-d33 wants to merge 5 commits into
hyperledger-cello:mainfrom
Pranav-d33:feat/channel-invitation-workflow-part-4

Conversation

@Pranav-d33

@Pranav-d33 Pranav-d33 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Adds the Fabric agent endpoint for generating unsigned channel update artifacts during the invitation workflow.

Changes

  • channel/views.py — Add POST /channels/{name}/invitations/definition endpoint (returns binary artifact)
  • channel/serializers.pyInvitationDefinitionSerializer accepts organization_msp_ids
  • channel/service.pygenerate_invitation_definition() fetches current channel config via peer channel fetch, appends new org MSP definitions via configtxlator compute_update, wraps in envelope; includes _build_org_group(), _read_crypto_config(), _read_b64()
  • channel/tests.py — 7 tests covering serializer validation, artifact generation, temp file cleanup, subprocess error handling

Test Plan

  • python manage.py test channel.tests — 7 tests, all passing
  • Serializer validates organization_msp_ids is required
  • Service constructs correct Fabric commands and produces a valid envelope
  • Temporary files cleaned up on success and failure
  • subprocess.CalledProcessError surfaces predictably

Notes

  • Operates statelessly — no data stored on the agent; artifact bytes returned directly
  • Temp files cleaned up in finally block
  • Expects MSP IDs matching the local crypto config (e.g., Org1MSP)

Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
Adds invitation endpoints to the Channel API — replaces the one-step `add_organization` flow with a proper Fabric channel update workflow.

### New Endpoints

- GET /invitations - List invitations visible to org (any member)
- POST /invitations - Create invitation + generate artifact (admin)
- GET /invitations/{id} - Retrieve invitation details (visibility-gated)
- POST /invitations/{id}/cancel - Cancel invitation (member-admin only)

### Design Decisions

- Admin-only mutations: create/cancel require is_admin
- Signature threshold: all current members by default, overridable
- Cancelable states: DRAFT, SIGNING, FAILED, READY
- Cancel vs Reject (PR 6): Cancel hard-stops the whole invitation. Reject is per-invitee decline.
- Who can cancel: Channel member admin only
- Duplicate protection: Rejects if invitee has PENDING invitee on active invitation
- Reinvite allowed after CANCELED or REJECTED

### Files

views.py: 3 @action methods + helpers
serializers.py: create calls agent, CancelSerializer, duplicate validation
service.py: create_invitation_artifact() agent call
tests.py: 12 endpoint tests (APIClient+JWT), 13 model tests with mocks

Test: 32/32 pass, flake8 clean.

Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
@Pranav-d33 Pranav-d33 requested a review from a team as a code owner June 18, 2026 18:53
- Add msp_id field to Organization (auto-derives from name as fallback)
- Update create_invitation_artifact to pass o.msp_id instead of str(o.id)
- Update auth serializer and org service to accept msp_id
- Fix pre-existing enum metaclass crash on Python 3.13
- Fix missing max_length on Organization and Chaincode CharFields
- Add proper error handling for agent failures in view

Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
Adds POST /channels/{channel_name}/invitations/definition on the Fabric agent.

Service generates unsigned channel update artifact:
  1. Fetch + decode channel config
  2. Build org group entries (MSP + AnchorPeers) with base64 PEM certs
  3. Compute config update diff via configtxlator
  4. Wrap in unsigned envelope, encode to protobuf
  5. Return bytes, clean up temp files

Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
@Pranav-d33 Pranav-d33 force-pushed the feat/channel-invitation-workflow-part-4 branch from 13ea09b to 0534fb0 Compare June 18, 2026 18:59
@yeasy yeasy requested a review from YoungHypo June 30, 2026 12:06
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