Skip to content

Commit

Permalink
feat: try to reduce the use of memory of ci
Browse files Browse the repository at this point in the history
  • Loading branch information
diwufeiwen committed Mar 16, 2023
1 parent 49a027a commit 2b25b21
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pkg/chain/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,28 @@ import (
"math/rand"
"testing"

"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
cbor "github.com/ipfs/go-ipld-cbor"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/filecoin-project/venus/pkg/chain"
"github.com/filecoin-project/venus/pkg/repo"
"github.com/filecoin-project/venus/pkg/testhelpers"
tf "github.com/filecoin-project/venus/pkg/testhelpers/testflags"
"github.com/filecoin-project/venus/pkg/util/test"
"github.com/filecoin-project/venus/venus-shared/types"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func init() {
chain.DefaultChainIndexCacheSize = 32 << 10
}

type CborBlockStore struct {
*chain.Store
cborStore cbor.IpldStore
Expand Down Expand Up @@ -62,11 +69,6 @@ func requirePutTestChain(ctx context.Context, t *testing.T, cborStore *CborBlock
}
}

type HeadAndTipsetGetter interface {
GetHead() types.TipSetKey
GetTipSet(types.TipSetKey) (types.TipSet, error)
}

func requirePutBlocksToCborStore(t *testing.T, cst cbor.IpldStore, blocks ...*types.BlockHeader) {
for _, block := range blocks {
_, err := cst.Put(context.Background(), block)
Expand Down
1 change: 1 addition & 0 deletions pkg/chain/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func NewBuilderWithDeps(t *testing.T, miner address.Address, sb StateBuilder, st
b.tipStateCids[types.NewTipSetKey().String()] = nullState

// create a fixed genesis
DefaultChainIndexCacheSize = 32 << 10
b.genesis = b.GeneratorGenesis()
b.store = NewStore(ds, bs, b.genesis.At(0).Cid(), NewMockCirculatingSupplyCalculator())

Expand Down
2 changes: 2 additions & 0 deletions pkg/chainsync/syncer/syncer_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func TestLoadFork(t *testing.T) {

// Load a new chain bsstore on the underlying data. It will only compute state for the
// left (heavy) branch. It has a fetcher that can't provide blocks.

chain.DefaultChainIndexCacheSize = 32 << 10
newStore := chain.NewStore(builder.Repo().ChainDatastore(), builder.BlockStore(), genesis.At(0).Cid(), chain.NewMockCirculatingSupplyCalculator())
newStore.SetCheckPoint(genesis.Key())
require.NoError(t, newStore.Load(ctx))
Expand Down

0 comments on commit 2b25b21

Please sign in to comment.