Skip to content

Conversation

furszy
Copy link
Member

@furszy furszy commented Sep 7, 2023

Found it while reviewing #24230 (comment).

During a reorg, continuing execution when a block cannot be reversed leaves the
coinstats index in an inconsistent state.
This was surely overlooked when 'CustomRewind' was implemented.

During a reorg, continuing execution when a block cannot be
reversed leaves the coinstats index in an inconsistent state,
which was surely overlooked when 'CustomRewind' was implemented.
@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 7, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK ryanofsky
Stale ACK TheCharlatan

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #26966 (index: blockfilter initial sync speedup, parallelize process by furszy)
  • #24230 (indexes: Stop using node internal types and locking cs_main, improve sync logic by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@fanquake
Copy link
Member

fanquake commented Sep 7, 2023

cc @ryanofsky @mzumsande

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK eef5955

This seems like it should avoid corrupting the index if ReverseBlock fails, since it avoid writing the best block. It also could prevent assert failures because it avoids subsequent ReverseBlock calls.

It would be good to add [[nodiscard]] to Reverseblock and other functions in indexing code to prevent this problem from happening other places. Grepping a little for functions in src/index/ that write to the database and return bool I see TxIndex::DB::WriteTxs and CopyHeightIndexToHashIndex and there may be others.

Copy link
Contributor

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK eef5955

As said, adding nodiscard would be nice.

@fanquake
Copy link
Member

fanquake commented Sep 8, 2023

It would be good to add [[nodiscard]] to Reverseblock and other functions in indexing code to prevent this problem from happening other places. Grepping a little for functions in src/index/ that write to the database and return bool I see TxIndex::DB::WriteTxs and CopyHeightIndexToHashIndex and there may be others.

As said, adding nodiscard would be nice.

@furszy do you want to push an additional commit?

Copy link
Member Author

@furszy furszy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add [[nodiscard]] to Reverseblock and other functions in indexing code to prevent this problem from happening other places. Grepping a little for functions in src/index/ that write to the database and return bool I see TxIndex::DB::WriteTxs and CopyHeightIndexToHashIndex and there may be others.

As said, adding nodiscard would be nice.

@furszy do you want to push an additional commit?

yep, pushed. A bit late due time zone diff.

Thanks both!

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK c0bf667. Only change since last review is new commit adding [[nodiscard]]

@fanquake fanquake merged commit fd69ffb into bitcoin:master Sep 12, 2023
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Sep 16, 2023
During a reorg, continuing execution when a block cannot be
reversed leaves the coinstats index in an inconsistent state,
which was surely overlooked when 'CustomRewind' was implemented.

Github-Pull: bitcoin#28427
Rebased-From: eef5955
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Sep 19, 2023
…e reversed

c0bf667 index: add [nodiscard] attribute to functions writing to the db (furszy)
eef5955 index: coinstats reorg, fail when block cannot be reversed (furszy)

Pull request description:

  Found it while reviewing bitcoin#24230 (comment).

  During a reorg, continuing execution when a block cannot be reversed leaves the
  coinstats index in an inconsistent state.
  This was surely overlooked when 'CustomRewind' was implemented.

ACKs for top commit:
  ryanofsky:
    Code review ACK c0bf667. Only change since last review is new commit adding [[nodiscard]]

Tree-SHA512: f4fc8522508d23e4fff09a29c935971819b1bd3b2a260e08e2e2b72f9340980d74fbec742a58fe216baf61d27de057c7c8300e8fa075f8507cd1227f128af909
@bitcoin bitcoin locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants