fix: safely allow unbounded mappings in cnight observation pallet#1423
Open
ozgb wants to merge 19 commits into
Open
fix: safely allow unbounded mappings in cnight observation pallet#1423ozgb wants to merge 19 commits into
ozgb wants to merge 19 commits into
Conversation
Uses two new maps to replace the previous single `Mappings` storage map - avoids encoding/decoding an unbounded vec in runtime Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Klapeyron
reviewed
Apr 27, 2026
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
LGLO
reviewed
Apr 27, 2026
LGLO
reviewed
Apr 27, 2026
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
…ture Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Contributor
Author
|
/bot rebuild-metadata |
Contributor
|
❌ Metadata rebuild failed. Check the workflow logs for details. |
Klapeyron
reviewed
Apr 28, 2026
Replaces the OnRuntimeUpgrade-style migration with a SteppedMigration so v0 -> v1 storage drains incrementally over many blocks rather than in the upgrade block. Per-step weight is bounded by MAX_ENTRIES_PER_ADDR (observed worst case across networks). Storage version is bumped inline on completion since pallet_migrations does not bump it for us. Wires the migration into pallet_migrations::Config::Migrations and removes it from the executive Migrations tuple. Tests drive SteppedMigration::step directly against the existing mock. Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
These changes came from switching the pallet to use sidechain_domain::UtxoId Changed genesis to keep the previous utxo_tx_hash and utxo_index split Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
The mock previously used `type DbWeight = ()`, which yields zero per-step weight and prevents exercising the SteppedMigration paths that depend on WeightMeter pressure. Replace with a `parameter_types! pub static` so the default is non-zero and tests can override per-test via MockDbWeight::set. Adds two tests now feasible against the v0->v1 migration: that an empty meter surfaces InsufficientWeight, and that step returns a resume cursor when the meter exhausts mid-migration. Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Contributor
Author
|
/bot rebuild-metadata |
Contributor
|
✅ Metadata rebuild complete! Changes have been committed. |
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Contributor
Author
|
/bot rebuild-metadata |
Contributor
|
✅ Metadata rebuild complete! Changes have been committed. |
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
justinfrevert
approved these changes
May 6, 2026
Contributor
|
/bot rebuild-metadata |
Contributor
|
✅ Metadata rebuild complete. No changes detected. |
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.
Overview
Replaces the single
Mappingsstorage map with a newMappingdouble storage mapWe were storing mappings for each Cardano address in an unbounded
Vec- every time we add/remove a registration thisVecis loaded into memory - if it gets too big, this could cause allocation failures and liveness issues.🗹 TODO before merging
📌 Submission Checklist
git commit -s) for the DCO🧪 Testing Evidence
Please describe any additional testing aside from CI:
🔱 Fork Strategy
Links
Fixes https://github.com/midnightntwrk/midnight-security/issues/116