Skip to content

Repair authorization payloads left naming a ticker - #343

Open
F-OBrien wants to merge 3 commits into
ethTransactfrom
auth-asset
Open

Repair authorization payloads left naming a ticker#343
F-OBrien wants to merge 3 commits into
ethTransactfrom
auth-asset

Conversation

@F-OBrien

Copy link
Copy Markdown
Contributor

Description

authorizations.data records the payload the AuthorizationAdded event carried at creation. The
chain's v6 → v7 ticker_migrations rewrote TransferAssetOwnership and BecomeAgent payloads from
tickers to asset ids, but emitted no event, so every row indexed before that upgrade still names a
ticker. Resolving that ticker today can point at a different asset than accepting the authorization
would actually transfer, because a ticker can be unlinked and relinked in between.

The migration is deterministic — AssetId::from(ticker) is
blake2_128(("legacy_ticker", ticker)) normalised to a v8 UUID — and the ticker is already stored,
so the asset id is derived locally. Neither the repair nor the backfill reads chain state.

Verified against live testnet authorization 54631: the stored ticker derives to
0x7edf86b7e651823cb21c2574e61c6ff3, which is the value the chain holds. That vector is pinned in
the unit tests.

Changes

  • repairAuthorizationsAfterUpgrade (src/mappings/entities/identities/repairAuthorizations.ts):
    rewrites still-pending TransferAssetOwnership/BecomeAgent rows whose payload is a 12 byte
    ticker rather than a 16 byte asset id. Wired into the existing mapChainUpgrade hook alongside
    the multiSig repair, gated on 7.x and later — the transaction version bumped 4 → 7 at v7.0.0, so
    a genesis resync repairs itself when it crosses that upgrade block.
  • scripts/backfill/authorization-payloads.ts: same logic for instances that indexed past the
    upgrade before this ships. Dry run by default, --apply to write. Runs entirely against the
    database — no chain connection and no archive node required.
  • Shared nextFetchSize / printDryRun / resumeFrom helpers extracted into
    scripts/backfill/historical.ts, now used by both backfills.
  • tsconfig.json: ts-node.files so scripts see SubQuery's injected globals. Without it
    authorization-payloads.ts does not compile at all — a pre-existing gap the eth-transact backfill
    had been working around with a local declare global.

Notes

  • No schema or table changes, and no SQL migration. Only current _block_range revisions are read
    and written, so the pre-repair payload stays queryable at its own block height.
  • Idempotent by construction: a repaired row no longer holds a 12 byte payload, so it is not a
    candidate on a later pass.
  • Stacked on Index Ethereum transactions submitted through revive.ethTransact #342 and based on ethTransact. Retarget to alpha once that merges.

Testing

yarn lint && yarn build && yarn test:unit green (198 tests). New unit suite covers payload
parsing, the BecomeAgent pair case, the repair decision, idempotency, the pre-7.x no-op, and the
staging chain that migrated without UUID normalisation.

Breaking Changes

None.

JIRA Link

Checklist

  • Updated the Readme.md (if required) ?

ts-node ignores tsconfig `include` unless `files` is set, so the injected
`api`/`store`/`logger` types never reached scripts. authorization-payloads.ts
could not compile at all; eth-transact-senders.ts papered over it with a local
`declare global`, which now conflicts and is removed.
Moves nextFetchSize, printDryRun and a new resumeFrom into historical.ts so both
backfills use one implementation instead of each carrying its own.
The chain's v6 to v7 ticker_migrations rewrote TransferAssetOwnership and
BecomeAgent payloads to asset ids without emitting an event, so rows indexed
before that upgrade still name a ticker. The asset id is derivable from the
ticker, so both the upgrade-time repair and the backfill run offline.
@F-OBrien
F-OBrien requested a review from a team as a code owner August 25, 2026 13:59
@sonarqubecloud

Copy link
Copy Markdown

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