Skip to content

refactor(state): apply ironwood-migration polish from review of #1379#1384

Open
zancas wants to merge 1 commit into
devfrom
ironwood_migration_polish
Open

refactor(state): apply ironwood-migration polish from review of #1379#1384
zancas wants to merge 1 commit into
devfrom
ironwood_migration_polish

Conversation

@zancas

@zancas zancas commented Jul 7, 2026

Copy link
Copy Markdown
Member

Fixes #1382.

This applies the six non-blocking polish items surfaced in review of #1379, in one commit:

  1. Backfill errors carry remediation advice. When the v1.2.1 → v1.3.0 migration cannot refetch a post-NU6.3 block, the error now 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.
  2. No per-height allocations in put_idempotent. The helper takes a lazy describe closure, so the per-row success path allocates nothing; the previous version formatted two messages per height.
  3. put_idempotent hoisted to module scope and reused at all three sites that inlined the NO_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.
  4. Activation heights resolved in one place. A new PoolActivationHeights struct in finalised_state.rs is shared by write_blocks_to_height and the migration, so the two call sites cannot drift apart.
  5. Visibility narrowed. FinalisedSource::start_validator, both ironwood_db accessors, and DbV1::start_validator go from pub(crate) to pub(super) — the minimum that compiles.
  6. multi_thread flavor 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, and cargo fmt are clean (the one clippy warning is pre-existing in an untouched file), and all six finalised-state migration tests pass under cargo nextest run -p zaino-state migrations:: — including the crash-resume and txid_location-rebuild tests that exercise the shared put_idempotent at every call site.

🤖 Generated with Claude Code

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>
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.

Follow-ups from #1379 review: ironwood migration polish (errors, DRY, visibility, test flavor)

1 participant