Repository navigation
fix(chain): restore first seen timestamps in TxGraph - #2346
Open
NaitikVerma6776 wants to merge 2 commits into
Open
NaitikVerma6776 wants to merge 2 commits into
NaitikVerma6776 wants to merge 2 commits into
Conversation
NaitikVerma6776
requested review from
evanlinjin and
oleonardolima
as code owners
October 6, 2026 02:20
evanlinjin
requested changes
Oct 6, 2026
evanlinjin
left a comment
Member
There was a problem hiding this comment.
Please also sign your commits.
Comment on lines
987
to
994
| // Restore first_seen and last_seen independently. Replaying last_seen via | ||
| // `insert_seen_at` on an empty graph would set first_seen to last_seen. | ||
| for (txid, seen_at) in changeset.first_seen { | ||
| let _ = self.update_first_seen(txid, seen_at); | ||
| } | ||
| for (txid, seen_at) in changeset.last_seen { | ||
| let _ = self.insert_seen_at(txid, seen_at); | ||
| let _ = self.update_last_seen(txid, seen_at); | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| // Restore first_seen and last_seen independently. Replaying last_seen via | |
| // `insert_seen_at` on an empty graph would set first_seen to last_seen. | |
| for (txid, seen_at) in changeset.first_seen { | |
| let _ = self.update_first_seen(txid, seen_at); | |
| } | |
| for (txid, seen_at) in changeset.last_seen { | |
| let _ = self.insert_seen_at(txid, seen_at); | |
| let _ = self.update_last_seen(txid, seen_at); | |
| } | |
| // Restore first_seen and last_seen independently. Replaying last_seen via | |
| // `insert_seen_at` on an empty graph would set first_seen to last_seen. | |
| for (txid, seen_at) in changeset.first_seen { | |
| let _ = self.insert_seen_at(txid, seen_at); | |
| } | |
| for (txid, seen_at) in changeset.last_seen { | |
| let _ = self.insert_seen_at(txid, seen_at); | |
| } |
It's safer to call insert_seen_at for both changeset fields to avoid the last_seen >= first_seen contract from being violated.
Author
|
@evanlinjin Please review the changes |
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 #2270.
TxGraph::apply_changesetwas restoringlast_seenbut notfirst_seen. Replayinglast_seenthroughinsert_seen_atcould therefore incorrectly setfirst_seento thelast_seentimestamp.This change restores
first_seenandlast_seenindependently when applying aChangeSet.A regression test was added to verify that distinct
first_seenandlast_seentimestamps survive applying and reloading a changeset.Tests
cargo +nightly fmt --all -- --check— passedgit diff --check— passedlink.exelinker installed.Contribution checklist