]> Untitled Git - bdk/commit
fix(chain)!: reject changesets that alter the genesis block
author志宇 <hello@evanlinjin.me>
Thu, 15 Oct 2026 09:46:13 +0000 (09:46 +0000)
committer志宇 <hello@evanlinjin.me>
Sun, 18 Oct 2026 07:17:37 +0000 (18:17 +1100)
commit4629f55138da1ee946bd49f7332ccbf0cd5af646
tree6357cf3b15652a05c0351a5f71493b27d2c1f2de
parent1fedce6eefae590ee002364cdc7d9b0512b4119f
fix(chain)!: reject changesets that alter the genesis block

`LocalChain::apply_changeset` could replace the genesis block when the
changeset contained a different block at height 0. Check genesis only
when there is no point of agreement below the changeset (the only path
that touches height 0) and extend from the existing genesis checkpoint.

`apply_changeset` now returns the new `ApplyChangeSetError`, since
`ApplyBlockError::MissingGenesis` does not apply to a chain that already
has a genesis. Replacing or removing genesis is reported as
`ApplyChangeSetError::CannotAlterGenesis`.

`from_changeset` now builds directly via `from_blocks`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
crates/chain/src/local_chain.rs
crates/chain/tests/test_local_chain.rs