Skip to content

Ledger drift checks: CheckLocalCompleteness re-parses full transaction history every sweep #2425

Description

@atharrva01

CheckLocalCompleteness (token/services/storage/db/common/checks.go) walks every confirmed transaction on each sweep and, for each one, rebuilds the token request, resolves its metadata, and re-derives the expected outputs. There is no persisted watermark of how far a previous sweep got.

With the default config (ScanInterval=1h, TransactionWindow=0, i.e. whole history), a node with a long transaction history redoes this parsing and crypto work for its entire history every hour, even though only the transactions since the last sweep are new. The cost grows without bound as the chain grows.

transactionWindow exists today as a way to bound this by wall-clock recency, but it trades away completeness: a history-walking check that never looks at an older transaction can't close findings for it, so narrowing the window isn't a free fix.

The real fix is a persisted "last verified transaction" watermark per TMS/role, so a steady-state sweep only does work proportional to new transactions rather than total history. That needs a storage-layer addition (schema + migration) across both the SQLite and Postgres backends, which is why it's being tracked separately rather than folded into an already large PR.

Raised during review of #2323.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions