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

fix: chainstore: store tipsetkeys in the blockstore #9904

Merged
merged 1 commit into from
Dec 23, 2022

Conversation

arajasek
Copy link
Contributor

Related Issues

filecoin-project/ref-fvm#1053

Proposed Changes

  • Introduce a new PersistTipset method that replacs PersistBlockHeaders at all callsites (it's what we always want to do)
  • Store the TSK in the PersistTipset method
  • Drop unused AddBlock method

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

@@ -971,7 +969,24 @@ func (cs *ChainStore) AddToTipSetTracker(ctx context.Context, b *types.BlockHead
return nil
}

func (cs *ChainStore) PersistBlockHeaders(ctx context.Context, b ...*types.BlockHeader) error {
func (cs *ChainStore) PersistTipset(ctx context.Context, ts *types.TipSet) error {
Copy link
Member

Choose a reason for hiding this comment

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

Not something we want to refactor now, but PutTipSet and PersistTipSet are confusing.

err = xerrors.Errorf("failed to persist synced blocks to the chainstore: %w", err)
ss.Error(err)
return err
if err := syncer.store.PersistTipset(ctx, ts); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This may have performance implications (although it may also have been a premature optimization?).

Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

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

Noting that we were already storing the tipset key here:

lotus/chain/store/store.go

Lines 653 to 663 in f438b1c

tskBlk, err := ts.Key().ToStorageBlock()
if err != nil {
log.Errorf("failed to create a block from tsk: %s", ts.Key())
return err
}
err = cs.chainLocalBlockstore.Put(ctx, tskBlk)
if err != nil {
log.Errorf("failed to put block for tsk: %s", ts.Key())
return err
}

Feel free to merge this as it looks strictly cleaner, but should probably remove the original write.

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.

3 participants