Skip to content

Commit e7b198c

Browse files
authored
Merge pull request bnb-chain#3253 from bnb-chain/develop
Draft release v1.5.19
2 parents 651069f + c363b7e commit e7b198c

File tree

10 files changed

+45
-28
lines changed

10 files changed

+45
-28
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# Changelog
2+
## v1.5.19
3+
### BUGFIX
4+
[\#3251](https://github.com/bnb-chain/bsc/pull/3251) freezer: change freeze batch size
5+
6+
### IMPROVEMENT
7+
[\#3243](https://github.com/bnb-chain/bsc/pull/3178) build(deps): bump golang.org/x/oauth2 from 0.24.0 to 0.27.0
8+
[\#3235](https://github.com/bnb-chain/bsc/pull/3178) refactor: use maps.Copy for cleaner map handling
9+
210
## v1.5.18
311
### FEATURE
412
[\#3158](https://github.com/bnb-chain/bsc/pull/3158) feat: blind bid serves the validator's best interest

core/blockchain_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"crypto/ecdsa"
2222
"errors"
2323
"fmt"
24+
"maps"
2425
gomath "math"
2526
"math/big"
2627
"math/rand"
@@ -3128,9 +3129,7 @@ func testDeleteRecreateSlotsAcrossManyBlocks(t *testing.T, scheme string) {
31283129
var exp = new(expectation)
31293130
exp.blocknum = i + 1
31303131
exp.values = make(map[int]int)
3131-
for k, v := range current.values {
3132-
exp.values[k] = v
3133-
}
3132+
maps.Copy(exp.values, current.values)
31343133
exp.exist = current.exist
31353134

31363135
b.SetCoinbase(common.Address{1})

core/rawdb/chain_freezer.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ const (
4040

4141
// freezerBatchLimit is the maximum number of blocks to freeze in one batch
4242
// before doing an fsync and deleting it from the key-value store.
43-
freezerBatchLimit = 30000
43+
// TODO(galaio): For BSC, the 0.75 interval and freezing of 30,000 blocks will seriously affect performance.
44+
// It is temporarily adjusted to 100, and improves the freezing performance later.
45+
freezerBatchLimit = 100
4446
)
4547

4648
var (
@@ -175,7 +177,7 @@ func (f *chainFreezer) freezeThreshold(db ethdb.Reader) (uint64, error) {
175177
//
176178
// This functionality is deliberately broken off from block importing to avoid
177179
// incurring additional data shuffling delays on block propagation.
178-
func (f *chainFreezer) freeze(db ethdb.KeyValueStore) {
180+
func (f *chainFreezer) freeze(db ethdb.KeyValueStore, continueFreeze bool) {
179181
var (
180182
backoff bool
181183
triggered chan struct{} // Used in tests
@@ -409,6 +411,12 @@ func (f *chainFreezer) freeze(db ethdb.KeyValueStore) {
409411
}
410412
f.tryPruneHistoryBlock(*number)
411413

414+
// TODO(galaio): Temporarily comment that the current BSC is suitable for small-volume writes,
415+
// and then the large-volume mode will be enabled after optimizing the freeze performance of ancient.
416+
if !continueFreeze {
417+
backoff = true
418+
continue
419+
}
412420
// Avoid database thrashing with tiny writes
413421
if frozen-first < freezerBatchLimit {
414422
backoff = true
@@ -427,6 +435,18 @@ func (f *chainFreezer) tryPruneBlobAncientTable(env *ethdb.FreezerEnv, num uint6
427435
return
428436
}
429437
expectTail := num - reserveThreshold
438+
439+
// check if the head is larger than expectTail, it occurs when a large number of historical blocks are not frozen in time
440+
// expect: blobAncientTail < expectTail < ancientHead
441+
ancientHead, err := f.Ancients()
442+
if err != nil {
443+
log.Error("Cannot get ancients", "err", err)
444+
return
445+
}
446+
if ancientHead <= expectTail {
447+
return
448+
}
449+
430450
start := time.Now()
431451
if _, err := f.TruncateTableTail(ChainFreezerBlobSidecarTable, expectTail); err != nil {
432452
log.Error("Cannot prune blob ancient", "block", num, "expectTail", expectTail, "err", err)

core/rawdb/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ func NewDatabaseWithFreezer(db ethdb.KeyValueStore, ancient string, namespace st
502502
if !disableFreeze && !readonly {
503503
frdb.wg.Add(1)
504504
go func() {
505-
frdb.freeze(db)
505+
frdb.freeze(db, false)
506506
frdb.wg.Done()
507507
}()
508508
}

core/state/snapshot/difflayer.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,7 @@ func (dl *diffLayer) flatten() snapshot {
408408
if parent.stale.Swap(true) {
409409
panic("parent diff layer is stale") // we've flattened into the same parent from two children, boo
410410
}
411-
for hash, data := range dl.accountData {
412-
parent.accountData[hash] = data
413-
}
411+
maps.Copy(parent.accountData, dl.accountData)
414412
// Overwrite all the updated storage slots (individually)
415413
for accountHash, storage := range dl.storageData {
416414
// If storage didn't exist (or was deleted) in the parent, overwrite blindly

core/state/snapshot/difflayer_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package snapshot
1919
import (
2020
"bytes"
2121
crand "crypto/rand"
22+
"maps"
2223
"math/rand"
2324
"testing"
2425

@@ -30,19 +31,15 @@ import (
3031

3132
func copyAccounts(accounts map[common.Hash][]byte) map[common.Hash][]byte {
3233
copy := make(map[common.Hash][]byte)
33-
for hash, blob := range accounts {
34-
copy[hash] = blob
35-
}
34+
maps.Copy(copy, accounts)
3635
return copy
3736
}
3837

3938
func copyStorage(storage map[common.Hash]map[common.Hash][]byte) map[common.Hash]map[common.Hash][]byte {
4039
copy := make(map[common.Hash]map[common.Hash][]byte)
4140
for accHash, slots := range storage {
4241
copy[accHash] = make(map[common.Hash][]byte)
43-
for slotHash, blob := range slots {
44-
copy[accHash][slotHash] = blob
45-
}
42+
maps.Copy(copy[accHash], slots)
4643
}
4744
return copy
4845
}

core/txpool/txpool.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package txpool
1919
import (
2020
"errors"
2121
"fmt"
22+
"maps"
2223
"math/big"
2324
"sync"
2425

@@ -385,9 +386,7 @@ func (p *TxPool) Add(txs []*types.Transaction, sync bool) []error {
385386
func (p *TxPool) Pending(filter PendingFilter) map[common.Address][]*LazyTransaction {
386387
txs := make(map[common.Address][]*LazyTransaction)
387388
for _, subpool := range p.subpools {
388-
for addr, set := range subpool.Pending(filter) {
389-
txs[addr] = set
390-
}
389+
maps.Copy(txs, subpool.Pending(filter))
391390
}
392391
return txs
393392
}
@@ -456,12 +455,8 @@ func (p *TxPool) Content() (map[common.Address][]*types.Transaction, map[common.
456455
for _, subpool := range p.subpools {
457456
run, block := subpool.Content()
458457

459-
for addr, txs := range run {
460-
runnable[addr] = txs
461-
}
462-
for addr, txs := range block {
463-
blocked[addr] = txs
464-
}
458+
maps.Copy(runnable, run)
459+
maps.Copy(blocked, block)
465460
}
466461
return runnable, blocked
467462
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ require (
305305
go.uber.org/zap v1.27.0 // indirect
306306
golang.org/x/mod v0.23.0 // indirect
307307
golang.org/x/net v0.38.0 // indirect
308-
golang.org/x/oauth2 v0.24.0 // indirect
308+
golang.org/x/oauth2 v0.27.0 // indirect
309309
golang.org/x/term v0.30.0 // indirect
310310
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect
311311
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ
13811381
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
13821382
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
13831383
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
1384-
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
1385-
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
1384+
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
1385+
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
13861386
golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw=
13871387
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
13881388
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ package version
1919
const (
2020
Major = 1 // Major version component of the current release
2121
Minor = 5 // Minor version component of the current release
22-
Patch = 18 // Patch version component of the current release
22+
Patch = 19 // Patch version component of the current release
2323
Meta = "" // Version metadata to append to the version string
2424
)

0 commit comments

Comments
 (0)