Skip to content

Commit

Permalink
keep headers hot when running with a noop splitstore
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Jul 4, 2021
1 parent 7c814cd commit 997f2c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
32 changes: 21 additions & 11 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ type Config struct {
//
// Supported values are: "bloom" (default if omitted), "bolt".
MarkSetType string

// HotHeaders indicates whether to keep chain block headers in hotstore or not.
// This is necessary, and automatically set by DI in lotus node construction, if
// you are running with a noop coldstore.
HotHeaders bool
}

// ChainAccessor allows the Splitstore to access the chain. It will most likely
Expand All @@ -112,6 +117,8 @@ type SplitStore struct {
critsection int32 // compaction critical section
closing int32 // the split store is closing

cfg *Config

baseEpoch abi.ChainEpoch
syncGapEpoch abi.ChainEpoch
warmupEpoch abi.ChainEpoch
Expand Down Expand Up @@ -154,6 +161,7 @@ func Open(path string, ds dstore.Datastore, hot, cold bstore.Blockstore, cfg *Co

// and now we can make a SplitStore
ss := &SplitStore{
cfg: cfg,
ds: ds,
hot: hot,
cold: cold,
Expand Down Expand Up @@ -859,27 +867,29 @@ func (s *SplitStore) walk(ts *types.TipSet, boundary abi.ChainEpoch, inclMsgs bo
return xerrors.Errorf("error unmarshaling block header (cid: %s): %w", c, err)
}

// don't walk under the boundary
if hdr.Height < boundary {
// don't walk under the boundary, unless we are keeping the headers hot
if hdr.Height < boundary && !s.cfg.HotHeaders {
return nil
}

if err := f(c); err != nil {
return err
}

if inclMsgs {
if err := s.walkLinks(hdr.Messages, walked, f); err != nil {
return xerrors.Errorf("error walking messages (cid: %s): %w", hdr.Messages, err)
}
if hdr.Height >= boundary {
if inclMsgs {
if err := s.walkLinks(hdr.Messages, walked, f); err != nil {
return xerrors.Errorf("error walking messages (cid: %s): %w", hdr.Messages, err)
}

if err := s.walkLinks(hdr.ParentMessageReceipts, walked, f); err != nil {
return xerrors.Errorf("error walking message receipts (cid: %s): %w", hdr.ParentMessageReceipts, err)
if err := s.walkLinks(hdr.ParentMessageReceipts, walked, f); err != nil {
return xerrors.Errorf("error walking message receipts (cid: %s): %w", hdr.ParentMessageReceipts, err)
}
}
}

if err := s.walkLinks(hdr.ParentStateRoot, walked, f); err != nil {
return xerrors.Errorf("error walking state root (cid: %s): %w", hdr.ParentStateRoot, err)
if err := s.walkLinks(hdr.ParentStateRoot, walked, f); err != nil {
return xerrors.Errorf("error walking state root (cid: %s): %w", hdr.ParentStateRoot, err)
}
}

toWalk = append(toWalk, hdr.Parents...)
Expand Down
1 change: 1 addition & 0 deletions node/modules/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func SplitBlockstore(cfg *config.Chainstore) func(lc fx.Lifecycle, r repo.Locked
cfg := &splitstore.Config{
TrackingStoreType: cfg.Splitstore.TrackingStoreType,
MarkSetType: cfg.Splitstore.MarkSetType,
HotHeaders: cfg.Splitstore.ColdStoreType == "noop",
}
ss, err := splitstore.Open(path, ds, hot, cold, cfg)
if err != nil {
Expand Down

0 comments on commit 997f2c0

Please sign in to comment.