Skip to content

Commit

Permalink
Merge pull request #6218 from filecoin-project/opt/remove-cache-store
Browse files Browse the repository at this point in the history
opt: remove CachedBlockstore
  • Loading branch information
LinZexiao authored Nov 28, 2023
2 parents 56c199b + 5e02608 commit 8733a7e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 38 deletions.
27 changes: 14 additions & 13 deletions pkg/fork/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,20 @@ func (mockFork *MockFork) HasExpensiveForkBetween(parent, height abi.ChainEpoch)

func (mockFork *MockFork) GetForkUpgrade() *config.ForkUpgradeConfig {
return &config.ForkUpgradeConfig{
UpgradeSmokeHeight: -1,
UpgradeBreezeHeight: -1,
UpgradeIgnitionHeight: -1,
UpgradeLiftoffHeight: -1,
UpgradeAssemblyHeight: -1,
UpgradeRefuelHeight: -1,
UpgradeTapeHeight: -1,
UpgradeKumquatHeight: -1,
BreezeGasTampingDuration: -1,
UpgradeCalicoHeight: -1,
UpgradePersianHeight: -1,
UpgradeOrangeHeight: -1,
UpgradeClausHeight: -1,
UpgradeSmokeHeight: -1,
UpgradeBreezeHeight: -1,
UpgradeIgnitionHeight: -1,
UpgradeLiftoffHeight: -1,
UpgradeAssemblyHeight: -1,
UpgradeRefuelHeight: -1,
UpgradeTapeHeight: -1,
UpgradeKumquatHeight: -1,
BreezeGasTampingDuration: -1,
UpgradeCalicoHeight: -1,
UpgradePersianHeight: -1,
UpgradeOrangeHeight: -1,
UpgradeClausHeight: -1,
UpgradeWatermelonFixHeight: -1,
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/gen/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ func VerifyPreSealedData(ctx context.Context, cs *chain.Store, stateroot cid.Cid
Bsstore: cs.Blockstore(),
SysCallsImpl: mkFakedSigSyscalls(syscalls),
GasPriceSchedule: gasPriceSchedule,
Fork: fork.NewMockFork(),
}

vm, err := fvm.NewVM(ctx, vmopt)
Expand Down
12 changes: 3 additions & 9 deletions pkg/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,7 @@ func MakeGenesis(ctx context.Context, rep repo.Repo, outFile, genesisTemplate st
template.Timestamp = uint64(constants.Clock.Now().Unix())
}

// TODO potentially replace this cached blockstore by a CBOR cache.
cbs, err := blockstoreutil.CachedBlockstore(ctx, bs, blockstoreutil.DefaultCacheOpts())
if err != nil {
return nil, err
}

b, err := genesis2.MakeGenesisBlock(context.TODO(), rep, cbs, template, para)
b, err := genesis2.MakeGenesisBlock(context.TODO(), rep, bs, template, para)
if err != nil {
return nil, fmt.Errorf("make genesis block: %w", err)
}
Expand All @@ -87,8 +81,8 @@ func MakeGenesis(ctx context.Context, rep repo.Repo, outFile, genesisTemplate st
return nil, err
}

offl := offline.Exchange(cbs)
blkserv := blockservice.New(cbs, offl)
offl := offline.Exchange(bs)
blkserv := blockservice.New(bs, offl)
dserv := merkledag.NewDAGService(blkserv)

if err := car.WriteCarWithWalker(context.TODO(), dserv, []cid.Cid{b.Genesis.Cid()}, f, gen.CarWalkFunc); err != nil {
Expand Down
16 changes: 0 additions & 16 deletions venus-shared/blockstore/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,6 @@ var (
NewGCBlockstore = blockstore.NewGCBlockstore
)

func DefaultCacheOpts() CacheOpts {
return CacheOpts{
HasBloomFilterSize: 0,
HasBloomFilterHashes: 0,
HasARCCacheSize: 512 << 10,
}
}

func CachedBlockstore(ctx context.Context, bs blockstore.Blockstore, opts CacheOpts) (Blockstore, error) {
bsTmp, err := blockstore.CachedBlockstore(ctx, bs, opts)
if err != nil {
return nil, err
}
return WrapIDStore(bsTmp), nil
}

type adaptedBlockstore struct {
blockstore.Blockstore
}
Expand Down

0 comments on commit 8733a7e

Please sign in to comment.