Skip to content

fix!: index the treasury settlement chain (bps floor referrer fees) - #5

Merged
MehranMazhar merged 1 commit into
mainfrom
treasury-break
Jul 30, 2026
Merged

fix!: index the treasury settlement chain (bps floor referrer fees)#5
MehranMazhar merged 1 commit into
mainfrom
treasury-break

Conversation

@MehranMazhar

Copy link
Copy Markdown
Member

Companion to clutchprotocol/clutch-node#9. Merge alongside it.

The surprise: almost nothing needed changing

The expectation going in was that the indexer would break at genesis, because the new chain puts a ChainInit transaction (RLP tag 9) in block 0 and adds chain_id to every transaction, alongside two new types (Mint tag 6, Burn tag 7) and four new balance-effect kinds.

It doesn't. Verified by inspection rather than assumed:

  • ingestion.rs stores function_call_type as a raw string with an unwrap_or fallback — no exhaustive match to break.
  • is_ride_function is a boolean matches!, so unknown types are simply "not ride-related".
  • referrer.rs already has a tolerant _ => {} arm.
  • activity.rs records unknown effect kinds with their raw string, and effect_label falls back to "Balance change".
  • There is no deny_unknown_fields anywhere, so the new chain_id field is ignored.

So ChainInit/Mint/Burn and chain_id all ingest with zero parser changes. That tolerance was worth confirming explicitly, because the alternative — an enum that must be kept in lockstep with the node — would have made every future node release a two-repo change.

What actually changed

referrer.rs fee arithmetic: ceiling percent → floor basis points, using the identical formula to the node's referrer_fee_floor:

(fare as u128 * bps as u128 / 10_000) as u64

That cross-repo agreement is the point — the explorer displays the fee split, so divergent rounding would make the UI quietly disagree with on-chain state. The old ceiling rule turned 2% of a 3-unit fare into 33%; it existed only because the chain had no decimals, and it is repealed.

Plus the u8u16 config rename (ride_*_referrer_fee_percent_bps) and its plumbing.

Verification

cargo test — 10/10 pass.

Note the tests were run on Rust 1.89, matching this repo's own backend/Dockerfile (ARG RUST_VERSION=1.89); 1.86 fails here because a transitive dependency requires ≥1.88, and that failure reproduces on unmodified main. Worth flagging separately: this repo commits no Cargo.lock, so its builds float on dependency resolution.

Not covered here

Live end-to-end indexing of a real Mint block needs a running treasury-break node stack; that is verified in the full-stack smoke, not in this source-only change.

🤖 Generated with Claude Code

clutch-node's treasury-break release moved RidePay referrer fees from
whole-percent ceiling division to basis-points floor division (2% ->
200 bps). Renames referrer_fee_ceiling -> referrer_fee_bps and the
ride_*_referrer_fee_percent config fields -> ride_*_referrer_fee_bps
(u8 -> u16) so the explorer's display-only fee math matches the chain.

Verified via source inspection (see .superpowers/sdd/task-2-report.md)
that the rest of the parser already tolerates the new ChainInit/Mint/
Burn transaction types and chain_id field without code changes: raw
string function_call_type with unwrap_or fallback, a boolean matches!
for is_ride_function, a tolerant `_ => {}` match arm in referrer.rs,
and no deny_unknown_fields anywhere. No changes needed there.
@MehranMazhar
MehranMazhar merged commit 92aa4c6 into main Jul 30, 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