(registry) implement schema versioning to support soroban contract upgrades and wasm updates#140
Merged
Conversation
…upport-Soroban-contract-upgrades-and-WASM-updates
Collaborator
|
@ChukwuemekaP1 resolve conflicts |
…upport-Soroban-contract-upgrades-and-WASM-updates
Contributor
Author
|
GM @Osuochasam I just fixed this issue , pls review |
Collaborator
|
@ChukwuemekaP1 GN, you still have conflicts |
…upport-Soroban-contract-upgrades-and-WASM-updates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Translation Registry Evolution: Historical Event Translation System
Closes #103
Summary
This PR redesigns the Translation Registry into a Historical Event Translation System that supports contract upgrades while preserving complete historical accuracy.
Previously, the registry stored only a single schema per
contract_id. This caused historical events to fail decoding after contract upgrades and made accurate blockchain replay impossible.The new architecture introduces versioned schemas indexed by ledger ranges, ensuring that every event is decoded using the exact schema that was active when it was emitted.
Problem Statement
Soroban contracts can upgrade their logic using
update_current_contract_wasm. The previous registry design could not handle schema evolution correctly because:Solution
Implemented a Versioned Resolution Engine with ledger-aware schema selection and runtime upgrade support.
Core Enhancements
Versioned Schema Resolution
Resolution Cache
RESOLUTION_CACHEfor O(1) lookup performance.Runtime Upgrades
registerUpgrade()for zero-downtime contract evolution.Declarative Event Mapping
Files Updated
Core Engine
lib/translator/registry.tsTypes
lib/translator/types.tsContractSchemaContractRegistryEntryRegistry Schema
lib/translator/registry.schema.jsonschemas[]valid_from_ledgervalid_to_ledgerRegistry Data
lib/translator/registry.jsonDocumentation
ARCHITECTURE.mdTests
lib/translator/registry.versioning.test.tsKey Features
Ledger-Based Schema Resolution
This guarantees that historical events are always decoded with the schema that was active at that point in time.
Zero-Downtime Upgrades
Contracts can upgrade at runtime without restarting the indexer:
Impact
Before
After
Performance & Reliability
O(1) schema resolution through compound-key caching.
100% backward compatibility for historical events.
Full SAC family migrated to versioned schemas.
Integration tests cover edge cases including:
Testing
Ready for review 🚀