TxGraph:: apply_changeset ignores ChangeSet::first_seen
メンテナーはふだん 2 日以内に返信
@evanlinjin がすでに取り組んでいます。
2026年10月18日 から。
評価
調査の方向性
TxGraph::apply_changeset と initial_changeset から始め、SQLite の再読み込みパスを確認する前に、issue に記載されたメモリ内のラウンドトリップを再現します。完了の条件は、changeset の適用後も first_seen の値が保持され、再読み込み後も未確認トランザクションの順序が変わらないことです。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
TxGraph::apply_changeset loops over txs, txouts, anchors, last_seen and last_evicted but not first_seen. Meanwhile initial_changeset() does write first_seen out, so persist and apply don't match up.
the value doesn't just come back as None apply_changeset still replays last_seen via insert_seen_at, which calls update_first_seen internally, and on an empty graph that entry is vacant so it just takes the last_seen value So after a reload every tx ends up with first_seen == last_seen.
SQLite isn't the problem the changeset that comes back off disk has the right values. They get thrown away when it's applied to the graph.
first_seen is the primary sort key for unconfirmed txs in ChainPosition::Ord Once it equals last_seen the ordering can change across a restart, without anything else changing.
To Reproduce
Two unconfirmed txs where first_seen and last_seen disagree on order, through a real sqlite file (write, close, reopen, apply):
before: A = (100, 500) B = (200, 300) order = [A, B]
changeset off disk: first_seen = {A: 100, B: 200} <- fine
last_seen = {A: 500, B: 300}
after apply_changeset: A = (500, 500) B = (300, 300) order = [B, A]
Also reproduces with no database at all:
let mut reloaded = TxGraph::<BlockId>::default();
reloaded.apply_changeset(graph.initial_changeset());
// first_seen is now last_seen
Expected behavior
initial_changeset() to apply_changeset() should round-trip, and unconfirmed ordering shouldn't change just because you restarted.
Build environment
- BDK tag/commit:
337e9d68,bdk_chain0.23.2 (apply_changesetis the same onmaster) - OS+version: Windows 11
- Rust/Cargo version: 1.97.1
- Rust/Cargo target: x86_64-pc-windows-msvc
Which backend(s) are relevant (if any)?
- Electrum
- Esplora
- Bitcoin Core RPC
- None / not backend-related (e.g.
bdk_chain,bdk_core) - Other (please specify):
____
Is this blocking production use?
- Yes
- No
Additional context
first_seen was added in #1947/#1950 and persisted in #1965/#1966, so it's computed and stored on purpose it just never gets read back. #1966's test checks the reloaded changeset has first_seen but never applies it to a graph, which is why this slipped through
- 主要言語
- Rust
- スター
- 1.1k
- フォーク
- 521
- 平均マージ
- 4日 1時間
- マージ済み PR(30日)
- 21
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bitcoindevkit/bdk のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
bitcoindevkit/bdk#2432 ·
メンテナーはふだん 2 日以内に返信
-
static/bdk.svg still shows the old logo (bdk.png has the new one)再び着手できるかも @notmandatory が 35 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug chore
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
bitcoindevkit/bdk#2326 · コメント 5 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
file_store: `Store::append` through a second handle overwrites changesets appended via another handle再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
bitcoindevkit/bdk#2308 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
file_store: `Store::load` never terminates when a changeset entry decodes to zero bytes対応中かも @nymius が 81 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
bitcoindevkit/bdk#2307 · コメント 5 件 ·
メンテナーはふだん 2 日以内に返信
-
Document trust requirements for floating-prevout accounting再び着手できるかも @Anandb71 が 15 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
bitcoindevkit/bdk#2287 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
bitcoindevkit/bdk の issue をすべて見る
似ている issue
-
parity priority: low
難易度 2/5 半日 初心者へのやさしさ 65/100
storytold/vectorcraft#5421 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug enchantments Java Edition protocol
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
Pumpkin-MC/Pumpkin#4465 ·
メンテナーはふだん 1 日以内に返信
-
docs(metrics): replace stale src/metrics.rs line anchors in dashboard-metrics.md with symbol namesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
ci-cd desktop size:low telemetry-improvement telemetry-round-1
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
vfarcic/dot-agent-deck#2079 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
fraiseql/fraisier-core#148 ·
メンテナーはふだん 1 日以内に返信