refactor(state): apply ironwood-migration polish from review of #1379#1384
Open
zancas wants to merge 1 commit into
Open
refactor(state): apply ironwood-migration polish from review of #1379#1384zancas wants to merge 1 commit into
zancas wants to merge 1 commit into
Conversation
This applies the six non-blocking follow-ups tracked in #1382. Backfill errors now carry remediation advice: when the v1.2.1 to v1.3.0 migration cannot refetch a post-NU6.3 block, the error tells the operator to ensure the backing validator serves the range from NU6.3 activation through the database tip, or to wipe and re-index. The idempotent-write helper is hoisted to module scope and reused at all three migration sites that previously inlined the NO_OVERWRITE plus verify-match pattern (the spent-batch flush, the txid_location rebuild, and the v1.3.0 commitment and ironwood writes). It now takes a lazy describe closure, so the per-row success path allocates nothing; the previous version formatted two messages per height on the success path. At the txid_location site the byte-for-byte comparison subsumes the old decode-and-checksum check, since a corrupt existing row cannot match the rebuilt bytes. The three shielded-pool activation heights are resolved through a new PoolActivationHeights struct in finalised_state.rs, shared by write_blocks_to_height and the migration so the two call sites cannot drift apart. The accessors introduced by #1379 (FinalisedSource::start_validator and the two ironwood_db accessors, plus DbV1::start_validator) narrow from pub(crate) to pub(super), the minimum visibility that compiles. The v1_2_1_cache_migrates_to_current_then_validates test gains a comment justifying its multi_thread flavor: the background validator runs blocking LMDB validation inline on its task, which would starve the test's status polling on a current-thread runtime. Fixes #1382. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #1382.
This applies the six non-blocking polish items surfaced in review of #1379, in one commit:
put_idempotent. The helper takes a lazydescribeclosure, so the per-row success path allocates nothing; the previous version formatted two messages per height.put_idempotenthoisted to module scope and reused at all three sites that inlined theNO_OVERWRITE+ verify-match pattern: the spent-batch flush, the txid_location rebuild, and the v1.3.0 commitment/ironwood writes. At the txid_location site the byte-for-byte comparison subsumes the old decode-and-checksum check, since a corrupt existing row cannot match the rebuilt bytes.PoolActivationHeightsstruct infinalised_state.rsis shared bywrite_blocks_to_heightand the migration, so the two call sites cannot drift apart.FinalisedSource::start_validator, bothironwood_dbaccessors, andDbV1::start_validatorgo frompub(crate)topub(super)— the minimum that compiles.multi_threadflavor justified in place. The regression test gains a comment explaining why it needs the multi-threaded runtime (the validator runs blocking LMDB validation inline on its task).Verification:
cargo check,cargo clippy --all-targets, andcargo fmtare clean (the one clippy warning is pre-existing in an untouched file), and all six finalised-state migration tests pass undercargo nextest run -p zaino-state migrations::— including the crash-resume and txid_location-rebuild tests that exercise the sharedput_idempotentat every call site.🤖 Generated with Claude Code