Skip to content

Add transaction deduplication using idempotency keys #212

Description

@AbelOsaretin

What

The admin endpoint and cron job may submit duplicate Stellar transactions if retries trigger or the endpoint is called multiple times quickly. There is no deduplication mechanism.

Why

Duplicate transactions waste XLM on fees and may cause unexpected on-chain state changes.

Scope

  • Generate a unique idempotency key per score update
  • Store recent keys in memory with TTL
  • Reject duplicate submissions within the TTL window
  • Make the TTL configurable

Acceptance Criteria

  • Each updateImpactScore call generates a unique key
  • Duplicate keys within IDEMPOTENCY_TTL_MS are rejected
  • Key is based on projectId + hourSeed (deterministic per project per hour)
  • In-memory store with configurable TTL
  • Logs duplicate attempts

Technical Context

  • src/lib/registry.ts:18-41updateImpactScore function
  • src/routes/admin.ts:41-53 — admin loop
  • src/index.ts:29-38 — cron loop
  • Key formula: score:${projectId}:${hourSeed}

Metadata

Metadata

Assignees

No one assigned

    Labels

    highSignificant functionality broken, no workaround, affects multiple users

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions