Merge pull request #11391 from filecoin-project/asr/fix-invariants-calib
fix: shed: make invariants checker work with splitstore
This commit is contained in:
commit
9a37ce0fc8
@ -3,7 +3,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -21,6 +22,8 @@ import (
|
|||||||
v9 "github.com/filecoin-project/go-state-types/builtin/v9"
|
v9 "github.com/filecoin-project/go-state-types/builtin/v9"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/blockstore"
|
"github.com/filecoin-project/lotus/blockstore"
|
||||||
|
badgerbs "github.com/filecoin-project/lotus/blockstore/badger"
|
||||||
|
"github.com/filecoin-project/lotus/blockstore/splitstore"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/consensus"
|
"github.com/filecoin-project/lotus/chain/consensus"
|
||||||
"github.com/filecoin-project/lotus/chain/consensus/filcns"
|
"github.com/filecoin-project/lotus/chain/consensus/filcns"
|
||||||
@ -73,24 +76,52 @@ var invariantsCmd = &cli.Command{
|
|||||||
|
|
||||||
defer lkrepo.Close() //nolint:errcheck
|
defer lkrepo.Close() //nolint:errcheck
|
||||||
|
|
||||||
bs, err := lkrepo.Blockstore(ctx, repo.UniversalBlockstore)
|
cold, err := lkrepo.Blockstore(ctx, repo.UniversalBlockstore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to open blockstore: %w", err)
|
return fmt.Errorf("failed to open universal blockstore %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
path, err := lkrepo.SplitstorePath()
|
||||||
if c, ok := bs.(io.Closer); ok {
|
if err != nil {
|
||||||
if err := c.Close(); err != nil {
|
return err
|
||||||
log.Warnf("failed to close blockstore: %s", err)
|
}
|
||||||
}
|
|
||||||
}
|
path = filepath.Join(path, "hot.badger")
|
||||||
}()
|
if err := os.MkdirAll(path, 0755); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
opts, err := repo.BadgerBlockstoreOptions(repo.HotBlockstore, path, lkrepo.Readonly())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
hot, err := badgerbs.Open(opts)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
mds, err := lkrepo.Datastore(context.Background(), "/metadata")
|
mds, err := lkrepo.Datastore(context.Background(), "/metadata")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg := &splitstore.Config{
|
||||||
|
MarkSetType: "map",
|
||||||
|
DiscardColdBlocks: true,
|
||||||
|
}
|
||||||
|
ss, err := splitstore.Open(path, mds, hot, cold, cfg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err := ss.Close(); err != nil {
|
||||||
|
log.Warnf("failed to close blockstore: %s", err)
|
||||||
|
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
bs := ss
|
||||||
|
|
||||||
cs := store.NewChainStore(bs, bs, mds, filcns.Weight, nil)
|
cs := store.NewChainStore(bs, bs, mds, filcns.Weight, nil)
|
||||||
defer cs.Close() //nolint:errcheck
|
defer cs.Close() //nolint:errcheck
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user