Skip to content

SemaphoreViem.getGroupMembers skips events with zero member indexes #1095

Open

Description

@somasoil

Describe the bug
SemaphoreViem.getGroupMembers() uses truthiness checks for MemberUpdated.args.index, MemberRemoved.args.index, and MembersAdded.args.startIndex. Since 0n is falsy, it skips updates/removals for the first leaf and the initial batch addition to an empty group. This returns missing or stale members.

To Reproduce

  1. Create an empty Semaphore group.
  2. Add two valid identity commitments using addMembers. The contract emits MembersAdded with startIndex = 0.
  3. Call SemaphoreViem.getGroupMembers(groupId). It returns [] instead of the two commitments.
  4. Separately, add a member using addMember, then update or remove the member at index zero. getGroupMembers() returns the original commitment instead of the updated commitment or "0".

Expected behavior
Process zero-valued indexes: return all batch-added commitments, apply updates to the first leaf, and represent a removed leaf as "0".

Screenshots
Not applicable; covered by automated regression tests.

Technologies (please complete the following information):

  • Node.js version: v25.8.1 (local test environment)
  • NPM version: 11.11.0 (project uses Yarn 4.1.0)
  • Solidity version: Not applicable to the mocked TypeScript reproduction
  • Package: @semaphore-protocol/data 4.14.3; viem 2.23.7

Additional context
Open PR #1036 already changes these guards, but does not include regression tests. This report tracks the concrete zero-index failure and its test coverage; please coordinate with #1036 before submitting overlapping implementation changes. PR #985 is merged, but the truthiness checks remain in upstream main at the time of inspection.

Local regression verification: five zero-index cases fail against the original implementation and pass with explicit presence checks. All 99 data-package tests pass with the fix.

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

    bug 🐛Something isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions