Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chainstore: Fix raw blocks getting scanned for links during snapshots #10684

Merged
merged 1 commit into from
Apr 21, 2023

Conversation

hsanjuan
Copy link
Contributor

@hsanjuan hsanjuan commented Apr 18, 2023

We have to save raw blocks to the snapshot, but we should not be scanning them for additional links as if they were CBOR blocks.

This cleans the logic a bit (we were checking that the parent was a CBOR block before queueing up the children, but then scanning the children... it was weird).

Additionally, more verbose logging is added for the next time ScanForLinks fails (currently very little info was given).

Our ScanForLinks callback should only enqueue CBOR for further processing.

Related Issues

#10672

Proposed Changes

Fixes raw blocks being scanned for links as if they were CBOR.

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

We have to save raw blocks to the snapshot, but we should not be scanning them
for additional links as if they were CBOR blocks.

This cleans the logic a bit (we were checking that the parent was a CBOR block
before queueing up the children, but then scanning the children... it was weird).

Additionally, more verbose logging is added for the next time ScanForLinks
fails (currently very little info was given).

Our ScanForLinks callback should only enqueue CBOR for further processing.
@hsanjuan hsanjuan requested a review from a team as a code owner April 18, 2023 13:31
@hsanjuan hsanjuan linked an issue Apr 18, 2023 that may be closed by this pull request
11 tasks
@hsanjuan
Copy link
Contributor Author

@ognots do you have a way to test this on the problematic epoch? (2764810)

@ognots
Copy link
Contributor

ognots commented Apr 18, 2023

@ognots do you have a way to test this on the problematic epoch? (2764810)

yeah, I can find an older snapshot to restore from, and I'll test it.
so far testing has been 👍 on a recent epoch

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

👍

// We exported the ipld block. If it wasn't a CBOR block, there's nothing
// else to do and we can bail out early as it won't have any links
// etc.
if t.c.Prefix().Codec != cid.DagCBOR || t.c.Prefix().MhType == mh.IDENTITY {
Copy link
Member

Choose a reason for hiding this comment

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

While it likely doesn't matter (at the moment, we should scan for links in "identity" blocks. In theory, I can inline dag-cbor into an identity hash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Stebalien I never knew the reasons to skip identity hashes, it was something inherited from @frrist code. I can't say if there's an instance of an identity hash in the whole chain history (? genesis or something?)

Copy link
Member

Choose a reason for hiding this comment

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

Hm. So, we shouldn't include blocks for identity hashes, but we should technically be traversing them and including their children, if any.

On the other hand, I can guarantee that this won't make a difference in practice (at the moment, at least). So we should be good to merge this as-os.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, happy to send follow-up in a few days.

Copy link
Member

Choose a reason for hiding this comment

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

fwiw I inherited it from:

// Don't include identity CIDs.

// We exported the ipld block. If it wasn't a CBOR block, there's nothing
// else to do and we can bail out early as it won't have any links
// etc.
if t.c.Prefix().Codec != cid.DagCBOR || t.c.Prefix().MhType == mh.IDENTITY {
Copy link
Member

Choose a reason for hiding this comment

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

Hm. So, we shouldn't include blocks for identity hashes, but we should technically be traversing them and including their children, if any.

On the other hand, I can guarantee that this won't make a difference in practice (at the moment, at least). So we should be good to merge this as-os.

@Stebalien Stebalien merged commit 875c098 into master Apr 21, 2023
@Stebalien Stebalien deleted the fix/10672-export-eof branch April 21, 2023 22:16
hsanjuan added a commit to hsanjuan/lotus that referenced this pull request Apr 24, 2023
…filecoin-project#10684)

We have to save raw blocks to the snapshot, but we should not be scanning them
for additional links as if they were CBOR blocks.

This cleans the logic a bit (we were checking that the parent was a CBOR block
before queueing up the children, but then scanning the children... it was weird).

Additionally, more verbose logging is added for the next time ScanForLinks
fails (currently very little info was given).

Our ScanForLinks callback should only enqueue CBOR for further processing.
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.

Chain ExportRangeInternal returns an EOF error when exporting stateroots
4 participants