Feat/issue 37 cold storage#164
Merged
JerryIdoko merged 2 commits intoVesting-Vault:mainfrom Mar 23, 2026
Merged
Conversation
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.
Summary
Resolves Issue #37: [Database] Cold Storage for Completed Vaults.
As the protocol grows, active database tables will accumulate 100% claimed and completed vaults, which can eventually degrade query performance for active vaults. This PR introduces a cold storage archival system. It safely moves fully completed vaults (where claimable balance is 0 and the vesting end time has passed) into a dedicated
archived_vaultstable via a weekly scheduled job.Acceptance Criteria Met
archived_vaultstable.claimable_balance == 0andend_timehas passed to the archive table.Changes Made
vaultArchivalJob.js:archived_vaultstable on application boot.0 2 * * 0).claimable_balanceof<= 0and an expiredend_time.archived_vaultstable inside a database transaction.SubSchedule,Notification) from the active tables to free up indexing space.index.js:VaultArchivalJobinto the main application startup sequence.How to Test
npm run devordocker-compose up).archived_vaultstable has been automatically created.vaultArchivalJob.jsfrom'0 2 * * 0'to'* * * * *'(every minute) and set an active vault's end date to the past with a 0 balance to watch it get automatically archived in real-time.Labels
databaseoptimizationFixes #37