MemoryStore should evict claims once their challenge expires

Open
#25 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java

Research direction

Review the Store interface and MemoryStore implementation, then trace TempoChargeIntent.matchTransferLogs and its verified challenge flow. Confirm how transaction memos can bind a payment to one challenge before changing claim handling. Done means expired claims can be discarded without permitting replay attacks, with the interface and payment flow remaining consistent.

Written by the indexing model from the issue text.

Description

Bind replay claims to challenge expiry. Ex. tryClaim(key, expiresAt).

Background

Store.tryClaim(key) (added in #24) retains transaction-hash claims forever. Every verified payment leaves a permanent entry, so any durable store grows without bound.

The typescript mppx SDK solved this by storing a marker that lapses at the challenge's expiry. One a challenge has expired, there's no reason to keep a cache entry for its associated transaction as it can no longer be claimed by an agent.

Using an expiry/TTL is safe in the typescript SDK because it cryptographically binds on-chain transaction memos to to a specific challenge. Therefore, a settled transaction can only satisfy exactly one challenge.

The mpp-java SDK has no such binding. TempoChargeIntent.matchTransferLogs compares only
currency, recipient, amount, and sender. Adding claim expiry would be a regression and make servers susceptible to replay attacks.

Proposed change

Implement memo binding between on-chain transactions and challenges. Then, once memo binding is in place, update the Store interface:

@FunctionalInterface
public interface Store {
    boolean tryClaim(String key);

    /** Claims {@code key} until {@code expiresAt}, after which the claim may be dropped. */
    default boolean tryClaim(String key, Instant expiresAt) {
        return tryClaim(key);
    }
}

TempoChargeIntent should pass the verified challenge's expires as expiresAt.

Why?

  • Prevents unbound growth in MemoryStore
  • Achieves parity with other SDKs
Dominant language
Java
Stars
7
Forks
8
Avg merge
18h 11m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.