Skip to content

Commit bc622a4

Browse files
fix parallel Num (bnb-chain#36)
* refine log to use debug for conflict detail * fix: adjust parallelNum to use CpuNum-1 by default --------- Co-authored-by: Sunny <sunny2022.za@gmail.com>
1 parent 808d048 commit bc622a4

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

cmd/utils/flags.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -2018,10 +2018,8 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
20182018
}
20192019
} else if numCpu == 1 {
20202020
parallelNum = 1 // single CPU core
2021-
} else if numCpu < 10 {
2022-
parallelNum = numCpu - 1
20232021
} else {
2024-
parallelNum = 8
2022+
parallelNum = numCpu - 1
20252023
}
20262024
cfg.ParallelTxNum = parallelNum
20272025
}

core/parallel_state_processor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ func (p *ParallelStateProcessor) toConfirmTxIndex(targetTxIndex int, isStage2 bo
441441
func (p *ParallelStateProcessor) toConfirmTxIndexResult(txResult *ParallelTxResult, isStage2 bool) bool {
442442
txReq := txResult.txReq
443443
if p.hasConflict(txResult, isStage2) {
444-
log.Warn(fmt.Sprintf("HasConflict!! block: %d, txIndex: %d\n", txResult.txReq.block.NumberU64(), txResult.txReq.txIndex))
444+
log.Info(fmt.Sprintf("HasConflict!! block: %d, txIndex: %d\n", txResult.txReq.block.NumberU64(), txResult.txReq.txIndex))
445445
return false
446446
}
447447
if isStage2 { // not its turn

core/state/parallel_statedb.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func hasKvConflict(slotDB *ParallelStateDB, addr common.Address, key common.Hash
4646
}
4747
if valUnconfirm, ok := slotDB.getKVFromUnconfirmedDB(addr, key); ok {
4848
if !bytes.Equal(val.Bytes(), valUnconfirm.Bytes()) {
49-
log.Warn("IsSlotDBReadsValid KV read is invalid in unconfirmed", "addr", addr,
49+
log.Debug("IsSlotDBReadsValid KV read is invalid in unconfirmed", "addr", addr,
5050
"valSlot", val, "valUnconfirm", valUnconfirm,
5151
"SlotIndex", slotDB.parallel.SlotIndex,
5252
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
@@ -57,7 +57,7 @@ func hasKvConflict(slotDB *ParallelStateDB, addr common.Address, key common.Hash
5757
valMain := mainDB.GetStateNoUpdate(addr, key)
5858

5959
if !bytes.Equal(val.Bytes(), valMain.Bytes()) {
60-
log.Warn("hasKvConflict is invalid", "addr", addr,
60+
log.Debug("hasKvConflict is invalid", "addr", addr,
6161
"key", key, "valSlot", val,
6262
"valMain", valMain, "SlotIndex", slotDB.parallel.SlotIndex,
6363
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex,
@@ -1288,7 +1288,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
12881288
}
12891289
if nonceUnconfirm, ok := slotDB.getNonceFromUnconfirmedDB(addr); ok {
12901290
if nonceSlot != nonceUnconfirm {
1291-
log.Warn("IsSlotDBReadsValid nonce read is invalid in unconfirmed", "addr", addr,
1291+
log.Debug("IsSlotDBReadsValid nonce read is invalid in unconfirmed", "addr", addr,
12921292
"nonceSlot", nonceSlot, "nonceUnconfirm", nonceUnconfirm, "SlotIndex", slotDB.parallel.SlotIndex,
12931293
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
12941294
return false
@@ -1301,7 +1301,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
13011301
nonceMain = mainObj.Nonce()
13021302
}
13031303
if nonceSlot != nonceMain {
1304-
log.Warn("IsSlotDBReadsValid nonce read is invalid", "addr", addr,
1304+
log.Debug("IsSlotDBReadsValid nonce read is invalid", "addr", addr,
13051305
"nonceSlot", nonceSlot, "nonceMain", nonceMain, "SlotIndex", slotDB.parallel.SlotIndex,
13061306
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex,
13071307
"mainIndex", mainDB.txIndex)
@@ -1331,7 +1331,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
13311331
}
13321332

13331333
if balanceSlot.Cmp(balanceMain) != 0 {
1334-
log.Warn("IsSlotDBReadsValid balance read is invalid", "addr", addr,
1334+
log.Debug("IsSlotDBReadsValid balance read is invalid", "addr", addr,
13351335
"balanceSlot", balanceSlot, "balanceMain", balanceMain, "SlotIndex", slotDB.parallel.SlotIndex,
13361336
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex,
13371337
"mainIndex", mainDB.txIndex)
@@ -1422,7 +1422,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
14221422
codeMain = object.Code()
14231423
}
14241424
if !bytes.Equal(codeSlot, codeMain) {
1425-
log.Warn("IsSlotDBReadsValid code read is invalid", "addr", addr,
1425+
log.Debug("IsSlotDBReadsValid code read is invalid", "addr", addr,
14261426
"len codeSlot", len(codeSlot), "len codeMain", len(codeMain), "SlotIndex", slotDB.parallel.SlotIndex,
14271427
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex,
14281428
"mainIndex", mainDB.txIndex)
@@ -1437,7 +1437,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
14371437
codeHashMain = common.BytesToHash(object.CodeHash())
14381438
}
14391439
if !bytes.Equal(codeHashSlot.Bytes(), codeHashMain.Bytes()) {
1440-
log.Warn("IsSlotDBReadsValid codehash read is invalid", "addr", addr,
1440+
log.Debug("IsSlotDBReadsValid codehash read is invalid", "addr", addr,
14411441
"codeHashSlot", codeHashSlot, "codeHashMain", codeHashMain, "SlotIndex", slotDB.parallel.SlotIndex,
14421442
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex, "mainIndex", mainDB.txIndex)
14431443
return false
@@ -1450,7 +1450,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
14501450
stateMain = true // addr exist in main DB
14511451
}
14521452
if stateSlot != stateMain {
1453-
log.Warn("IsSlotDBReadsValid addrState read invalid(true: exist, false: not exist)",
1453+
log.Debug("IsSlotDBReadsValid addrState read invalid(true: exist, false: not exist)",
14541454
"addr", addr, "stateSlot", stateSlot, "stateMain", stateMain,
14551455
"SlotIndex", slotDB.parallel.SlotIndex,
14561456
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex, "mainIndex", mainDB.txIndex)
@@ -1461,7 +1461,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
14611461
for addr, destructRead := range slotDB.parallel.addrSnapDestructsReadsInSlot {
14621462
mainObj := mainDB.getDeletedStateObjectNoUpdate(addr)
14631463
if mainObj == nil {
1464-
log.Warn("IsSlotDBReadsValid snapshot destructs read invalid, address should exist",
1464+
log.Debug("IsSlotDBReadsValid snapshot destructs read invalid, address should exist",
14651465
"addr", addr, "destruct", destructRead,
14661466
"SlotIndex", slotDB.parallel.SlotIndex,
14671467
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex)
@@ -1471,7 +1471,7 @@ func (slotDB *ParallelStateDB) IsParallelReadsValid(isStage2 bool) bool {
14711471
_, destructMain := mainDB.snapDestructs[addr] // addr not exist
14721472
slotDB.snapParallelLock.RUnlock()
14731473
if destructRead != destructMain && addr.Hex() != "0x0000000000000000000000000000000000000001" {
1474-
log.Warn("IsSlotDBReadsValid snapshot destructs read invalid",
1474+
log.Debug("IsSlotDBReadsValid snapshot destructs read invalid",
14751475
"addr", addr, "destructRead", destructRead, "destructMain", destructMain,
14761476
"SlotIndex", slotDB.parallel.SlotIndex,
14771477
"txIndex", slotDB.txIndex, "baseTxIndex", slotDB.parallel.baseTxIndex,

0 commit comments

Comments
 (0)