FilOzone / FilOzone/pdp-explorer
perf(subgraph): slim EventLog/Transaction entities and drop unused counters
- Dominant language
- TypeScript
- Stars
- 3
- Forks
- 7
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 4
Description
## Problem
Every event writes an `EventLog` (and usually a `Transaction`). They're immutable (good), but each write carries avoidable weight:
- `eventLog.data` is a hand-built JSON string (e.g. the challenges loop in `subgraph/src/pdp-verifier.ts:605-613`) — arbitrary-precision `toString()` calls per event, stored as text that duplicates on-chain data.
- Duplicated fields: `EventLog.transactionHash` duplicates the id prefix, `Transaction.hash` duplicates the id, `setId`/`dataSetId` duplicate the `proofSet` relation.
- `DataSet.totalEventLogs` / `totalTransactions` counters are updated in every handler, widening the hottest mutable row.
The client does query `transactions` and `eventLogs` (subgraph-clien `utility/queries.ts:185,197`), so these entities stay — this issue is about shrinking them, not removing them.
## Proposal
- Audit which `EventLog`/`Transaction` fields and which `DataSet` counters the UI actually renders; drop the rest (`data` JSON is the main candidate — the name + linked entities may already cover the UI's needs).
- Where `data` is genuinely displayed, consider keeping only the minimal fields the UI formats, rather than pre-rendered JSON. OR completely eliminate `data` field and redirect users to block-explorer where contract is verified to see `data`.
## Acceptance criteria
- [ ] Field-usage audit of the client documented in this issue
- [ ] Unused fields removed from `schema.graphql` + mappings; client queries updated
- [ ] Tests pass; affected UI pages verified
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the client field usage around utility/queries.ts:185,197, then inspect schema.graphql and the subgraph mappings, including the event data construction in subgraph/src/pdp-verifier.ts:605-613. Document which fields and counters the UI uses, remove unused schema and mapping fields, update client queries, and confirm tests pass and affected UI pages still work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- databases, full-stack
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100