Skip to content

feat(claims): index setactlimit/seedmbrclm and mirror mbrclaim into member_action_claims - #80

Merged
lucca65 merged 2 commits into
masterfrom
feat/claim-limits
Oct 18, 2026
Merged

lucca65 merged 2 commits into
masterfrom
feat/claim-limits

Conversation

@lucca65

@lucca65 lucca65 commented Oct 18, 2026

Copy link
Copy Markdown
Member

Summary

Claim limits, rollout step 4 (plan Task 7). event-source indexes the two new cambiatus.cm actions and keeps the backend's member_action_claims table in step with the contract's mbrclaim table.

  • src/claim_mirror.js applies the contract's own arithmetic and decides nothing:
    • claimaction adds 1 to pending.
    • The first verifyclaim that moves a claim from pending to final closes it. pending goes down by 1 (never below 0); then approved goes up by 1, or last_rejected_at becomes the block's whole second. A replay finds the claim already final and skips it.
    • reward adds 1 to approved.
    • seedmbrclm overwrites the row.
    • Every write runs on the block transaction, after the existing replay guards and after any ResolveError path.
  • setactlimit writes actions.max_claims_per_account and reclaim_cooldown_seconds; max 0 clears both. An action that isn't indexed raises ResolveError (skip and page).
  • src/config/lane.js points at the lane chain (:8899) and cambiatus_lane_cpa. It refuses :8888 and the shared DBs.
  • scripts/compare-claim-mirror.sh <chain> <db> <account>... compares chain mbrclaim with Postgres for each account.

The S3 contract (live since 2026-10-17) and the backend table (#546, on backend main) are already in place. Rows written on chain before this deploy are filled by the S4 backfill (seedmbrclm), which this PR indexes.

Merge after #79. Without #79 the indexer can drop the second part of a split block, and the mirror would drift with it (a lane run without #79 lost 7 claims).

Test plan

  • Lane, this PR plus fix(indexer): apply the rest of a block delivered in two parts #79 (fresh chain :8899 on the committed prod wasm 5f661569, fresh DB):
    • test_community 97/97 and test_claim_limits 81/81 generate the activity;
    • compare-claim-mirror.sh prints OK for alice, bob, carol, dave and eve (exit 0);
    • 7 actions have a limit;
    • 0 error lines in the event-source log;
    • claims (325) and checks (16) match chain exactly.
  • yarn format is clean.
  • Task review (spec + quality): approved, no Critical or Important findings. The Minor lane-guard item is fixed (it also refuses cambiatus_mirror and cambiatus_review).
  • code-simplifier: no changes.

Known and pre-existing, not changed here: resolveCreatedActionId reads the current chain, so an action created and deleted before it is indexed shifts later create ids. The lane test does this in one block; in prod it would need both inside one 500 ms poll.

Deploy (needs a go)

On the box: git status (clean?), git pull --ff-only origin master, pm2 restart event-source. Then watch that restart_time stays stable. No yarn install is needed.

🤖 Generated with Claude Code

lucca65 and others added 2 commits October 18, 2026 14:30
…ember_action_claims

- claim_mirror.js applies the contract's mbrclaim arithmetic to member_action_claims:
  claimaction opens (+1 pending), the first pending → final verifyclaim closes
  (saturating pending, +1 approved or last_rejected_at = block second), reward adds
  approved, seedmbrclm overwrites. All writes run on the block-level transaction.
- setactlimit writes actions.max_claims_per_account / reclaim_cooldown_seconds
  (max 0 clears both); an action that isn't indexed is a ResolveError (skip + page).
- src/config/lane.js: lane chain :8899 + cambiatus_lane_cpa, refuses :8888 and the
  shared DBs.
- scripts/compare-claim-mirror.sh: chain mbrclaim vs Postgres, per account.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lucca65
lucca65 merged commit 42e0646 into master Oct 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant