Skip to content

[CRITICAL] processRewardClaim has no DB transaction — reward lost or double-spent #25

Description

@DeFiVC

Description

processRewardClaim in src/modules/rewards/reward.service.ts:67-78 marks rewardClaimed: true (line 67-70), then separately increments credits (line 72-77) with two independent DB calls (no transaction wrapping).

If the process crashes or the second update fails after the first succeeds:

  • rewardClaimed is true but credits never added → user permanently loses the reward (retry sees rewardClaimed === true on line 37 and skips)
  • If on-chain claim succeeded but DB update fails → retry attempts second on-chain claim → double-spend

Impact

Inconsistent state between on-chain and DB with no recovery path.

File

src/modules/rewards/reward.service.ts:67-78

Suggested Fix

Wrap the rewardClaimed update and credit increment in a single DB transaction using db.transaction().

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't workingcritical

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions