Skip to content

Add transaction deduplication using idempotency keys #543

Description

@sshdopey

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}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions