Ci lmdb - reduce memory usage (#762)

This commit is contained in:
Alex Sharov 2020-07-21 08:58:00 +07:00 committed by GitHub
parent 1faa9dbcd4
commit 621e3a2074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 8 deletions

View File

@ -38,11 +38,15 @@ import (
"github.com/ledgerwatch/turbo-geth/params"
)
const OwerwriteBlockCacheItems = 1024
const OwerwriteMaxForkAncestry = 3000
// Reduce some of the parameters to make the tester faster.
func init() {
maxForkAncestry = 10000
blockCacheItems = 1024
fsHeaderContCheck = 500 * time.Millisecond
maxForkAncestry = OwerwriteMaxForkAncestry
blockCacheItems = OwerwriteBlockCacheItems
fsHeaderSafetyNet = 256
fsHeaderContCheck = 50 * time.Millisecond
}
// downloadTester is a test simulator for mocking out local block chain.
@ -1020,7 +1024,7 @@ func testInvalidHeaderRollback(t *testing.T, protocol int, mode SyncMode) {
defer tester.peerDb.Close()
// Create a small enough block chain to download
targetBlocks := 3*fsHeaderSafetyNet + 256 + fsMinFullBlocks
targetBlocks := 2*fsHeaderSafetyNet + 256 + fsMinFullBlocks
chain := testChainBase.shorten(targetBlocks)
// Attempt to sync with an attacker that feeds junk during the fast sync phase.
@ -1040,7 +1044,7 @@ func testInvalidHeaderRollback(t *testing.T, protocol int, mode SyncMode) {
// Attempt to sync with an attacker that feeds junk during the block import phase.
// This should result in both the last fsHeaderSafetyNet number of headers being
// rolled back, and also the pivot point being reverted to a non-block status.
missing = 3*fsHeaderSafetyNet + MaxHeaderFetch + 1
missing = 2*fsHeaderSafetyNet + MaxHeaderFetch + 1
blockAttackChain := chain.shorten(chain.len())
delete(fastAttackChain.headerm, fastAttackChain.chain[missing]) // Make sure the fast-attacker doesn't fill in
delete(blockAttackChain.headerm, blockAttackChain.chain[missing])

View File

@ -43,13 +43,13 @@ var (
)
// The common prefix of all test chains:
var testChainBase = newTestChain(blockCacheItems+200, testDb, testGenesis)
var testChainBase = newTestChain(OwerwriteBlockCacheItems+200, testDb, testGenesis)
// Different forks on top of the base chain:
var testChainForkLightA, testChainForkLightB, testChainForkHeavy *testChain
func TestMain(m *testing.M) {
var forkLen = int(maxForkAncestry + 50)
var forkLen = OwerwriteMaxForkAncestry + 50
var wg sync.WaitGroup
wg.Add(3)
go func() { testChainForkLightA = testChainBase.makeFork(forkLen, false, 1); wg.Done() }()

View File

@ -50,7 +50,7 @@ func (opts lmdbOpts) Open() (KV, error) {
var logger log.Logger
if opts.inMem {
err = env.SetMapSize(64 << 20) // 64MB
err = env.SetMapSize(32 << 20) // 32MB
logger = log.New("lmdb", "inMem")
if err != nil {
return nil, err