Skip to content

[explorer/puller] fix: recover Symbol metadata state during rollback - #2465

Merged
daoka merged 4 commits into
devfrom
explorer/metadata-rollback-recovery-relation
Aug 4, 2026
Merged

[explorer/puller] fix: recover Symbol metadata state during rollback#2465
daoka merged 4 commits into
devfrom
explorer/metadata-rollback-recovery-relation

Conversation

@daoka

@daoka daoka commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What is the current behavior?

Symbol Metadata rollback recovery derives natural keys only from current
symbol_metadata rows updated at or after the fork height.

Mosaic Metadata transactions preserve the unresolved target mosaic ID in their
body, but do not persist the resolved target ID needed to reconstruct the
canonical Metadata natural key.

This is a follow-up to #2463.

What's the issue?

An orphaned Metadata update can leave an empty value. Symbol core removes the current Metadata entry in that case.

If the Explorer current-state row has already been removed, rollback recovery has no natural key with which to query the canonical Node state. The missing Metadata entry therefore cannot be restored from current rows alone.

Mosaic aliases require additional handling because the raw transaction body contains the unresolved mosaic ID, while the Metadata natural key uses the resolved mosaic ID.

How have you changed the behavior?

This change persists the resolved Mosaic Metadata target as a private
symbol_transaction_mosaics relation:

  • role = 'metadata_target'
  • amount = 0
  • position = 0
  • exactly one relation for each Mosaic Metadata transaction

Account and Namespace Metadata transactions do not create this relation. The unresolved values in body and raw_payload remain unchanged.

Rollback recovery now:

  1. Collects Metadata keys from current-state rows.
  2. Reconstructs Metadata keys from confirmed transactions at or after the fork height.
  3. Uses the private resolved relation for Mosaic Metadata instead of the raw body.targetMosaicId.
  4. Canonicalizes scoped Metadata keys and non-null target IDs to uppercase 16-character hexadecimal strings.
  5. Deduplicates both key sources using the complete Metadata natural key.
  6. Fetches all canonical state before invoking the existing atomic rollback repair.

Malformed transaction bodies, missing or duplicate target relations, invalid sentinels, and malformed hexadecimal identifiers fail deterministically before rollback writes begin.

The exactly-one relation contract is enforced by application validation rather than a partial unique index. The existing relation primary key permits different mosaic IDs for the same transaction and role, and retaining application validation allows malformed persisted state to be detected and tested explicitly.

metadata_target is private persistence state. It must not be exposed through public transferMosaicId searches or Mosaic-detail transaction results.

There is no public API breaking change. This updates the pre-release declarative schema without adding an ALTER TYPE compatibility shim. Existing development databases with the old enum or non-canonical Metadata keys must be recreated.

REST, frontend, NEM, and the merged Lock synchronization behavior are unchanged.

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.36%. Comparing base (d73599a) to head (2293d4a).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #2465      +/-   ##
==========================================
- Coverage   95.63%   95.36%   -0.28%     
==========================================
  Files         719      679      -40     
  Lines       53893    50630    -3263     
  Branches     1405     1405              
==========================================
- Hits        51540    48282    -3258     
+ Misses       2295     2290       -5     
  Partials       58       58              
Flag Coverage Δ
explorer-puller ?
explorer-rest ?
wallet-mobile-symbol 94.18% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 40 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@daoka
daoka marked this pull request as ready for review August 2, 2026 23:21
@daoka
daoka requested review from Jaguar0625 and Wayonb and removed request for Jaguar0625 August 2, 2026 23:21

@Jaguar0625 Jaguar0625 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread explorer/puller/tests/model/symbol/test_Metadata.py Outdated
Comment thread explorer/puller/tests/model/symbol/test_Metadata.py
Comment thread explorer/puller/tests/model/symbol/test_Metadata.py
Comment thread explorer/puller/puller/facade/SymbolPuller.py Outdated
Comment thread explorer/puller/tests/db/test_SymbolDatabase.py
Comment thread explorer/puller/tests/facade/symbol/test_PullerMetadata.py
Comment thread explorer/puller/tests/facade/symbol/test_PullerRollback.py
Comment thread explorer/puller/tests/facade/symbol/test_PullerRollback.py
@daoka
daoka requested a review from Jaguar0625 August 4, 2026 03:04

@Jaguar0625 Jaguar0625 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@daoka
daoka enabled auto-merge (squash) August 4, 2026 12:57
@daoka
daoka merged commit 03f0aa1 into dev Aug 4, 2026
7 checks passed
@daoka
daoka deleted the explorer/metadata-rollback-recovery-relation branch August 4, 2026 13:09
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.

2 participants