MemoryStore should evict claims once their challenge expires
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
objectionary/hone-maven-plugin#1061 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
spring-projects/spring-modulith#1895 ·