core: fix too many goroutines in InitSignerInTransactions, close XFN-75 (#1662)

This commit is contained in:
Daniel Liu 2025-10-31 14:56:22 +08:00 committed by GitHub
parent a5e68b9c52
commit 336d1f9f34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -569,7 +569,10 @@ func ApplyEmptyTransaction(config *params.ChainConfig, statedb *state.StateDB, b
}
func InitSignerInTransactions(config *params.ChainConfig, header *types.Header, txs types.Transactions) {
nWorker := runtime.NumCPU()
if txs.Len() == 0 {
return
}
nWorker := min(runtime.NumCPU(), txs.Len())
signer := types.MakeSigner(config, header.Number)
chunkSize := txs.Len() / nWorker
if txs.Len()%nWorker != 0 {