Skip to content

perf(subgraph): remove dead SumTree maintenance from piece handlers #135

Description

@silent-cipher

Problem

sumTreeAdd / sumTreeRemove run for every piece in handlePiecesAdded (subgraph/src/pdp-verifier.ts:1139-1140) and handlePiecesRemoved (subgraph/src/pdp-verifier.ts:1295-1302). Each call performs O(log n) SumTreeCount entity loads plus at least one write (subgraph/src/sumTree.ts).

Nothing consumes this data today:

  • The only reader is findChallengedRoots in subgraph/src/pdp-service.ts, whose handleFaultRecord is not wired into the manifest — there is no PDPService data source in subgraph.yaml or templates/subgraph.template.yaml.
  • The client never queries sumTreeCounts.

So on the hottest backfill path (piece ingest) we pay O(log n) store reads + writes per piece for state that is never read.

Proposal

  1. Decide: is FaultRecord / PDPService support coming back?
    • No / not soon: delete the SumTree calls from both handlers, the SumTreeCount entity from schema.graphql, and src/sumTree.ts (git history preserves it).
    • Yes: remove the calls now anyway and reintroduce them in the same PR that adds the PDPService data source, so we don't pay the cost while nothing consumes it.
  2. Update Matchstick tests accordingly.

Acceptance criteria

  • No SumTreeCount loads/writes during PiecesAdded / PiecesRemoved handling
  • graph build for both networks + tests pass
  • Decision on FaultRecord reintroduction recorded in this issue
  • Remove stale heatmap from subgraph-client

Notes

Current Heatmap shows no faults at all and this is because FaultRecord/PDPService isn't wired in manifest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    🐱 Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions