Skip to content

Commit 3e4087c

Browse files
authored
Merge pull request bnb-chain#3129 from bnb-chain/develop
draft release v1.5.14
2 parents 256d881 + cb61d72 commit 3e4087c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+350
-123
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
# Changelog
2+
## v1.5.14
3+
### FEATURE
4+
[\#3130](https://github.com/bnb-chain/bsc/pull/3130) config: update BSC Mainnet hardfork time: Maxwell
5+
6+
### BUGFIX
7+
[\#3117](https://github.com/bnb-chain/bsc/pull/3117) core, ethdb: introduce database sync function (#31703)
8+
[\#3122](https://github.com/bnb-chain/bsc/pull/3122) freezer: implement tail method in prunedfreezer
9+
[\#3121](https://github.com/bnb-chain/bsc/pull/3121) miner: discard outdated bids before simulation
10+
11+
### IMPROVEMENT
12+
[\#3105](https://github.com/bnb-chain/bsc/pull/3105) parlia.go: adjust timeForMining to 4/5 second
13+
[\#3112](https://github.com/bnb-chain/bsc/pull/3112) feat: add storagechange object pool for better performance
14+
[\#3110](https://github.com/bnb-chain/bsc/pull/3110) refactor: use the built-in max/min to simplify the code
15+
[\#3120](https://github.com/bnb-chain/bsc/pull/3120) tx_pool: remove one non-necessary allocation
16+
[\#3123](https://github.com/bnb-chain/bsc/pull/3123) refactor: use maps.copy for cleaner map handling
17+
[\#3126](https://github.com/bnb-chain/bsc/pull/3126) jsutils: update getKeyParameters
18+
219
## v1.5.13
320
### FEATURE
421
[\#3019](https://github.com/bnb-chain/bsc/pull/3019) BEP-524: Short Block Interval Phase Two: 0.75 seconds

cmd/geth/dbcmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ func hbss2pbss(ctx *cli.Context) error {
12821282
defer stack.Close()
12831283

12841284
db := utils.MakeChainDatabase(ctx, stack, false, false)
1285-
db.BlockStore().Sync()
1285+
db.BlockStore().SyncAncient()
12861286
stateDiskDb := db.StateStore()
12871287
defer db.Close()
12881288

cmd/jsutils/getchainstatus.js

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ function printUsage() {
2929
console.log(" GetLargeTxs: get large txs of a block range");
3030
console.log("\nOptions:");
3131
console.log(" --rpc specify the url of RPC endpoint");
32+
console.log(" mainnet: https://bsc-mainnet.nodereal.io/v1/454e504917db4f82b756bd0cf6317dce");
33+
console.log(" testnet: https://bsc-testnet-dataseed.bnbchain.org");
3234
console.log(" --startNum the start block number");
3335
console.log(" --endNum the end block number");
3436
console.log(" --miner the miner address");
3537
console.log(" --num the number of blocks to be checked");
3638
console.log(" --topNum the topNum of blocks to be checked");
3739
console.log(" --blockNum the block number to be checked");
3840
console.log("\nExample:");
39-
// mainnet https://bsc-mainnet.nodereal.io/v1/454e504917db4f82b756bd0cf6317dce
4041
console.log(" node getchainstatus.js GetMaxTxCountInBlockRange --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000005");
41-
console.log(" node getchainstatus.js GetBinaryVersion --rpc https://bsc-testnet-dataseed.bnbchain.org --num 21 --turnLength 4");
42+
console.log(" node getchainstatus.js GetBinaryVersion --rpc https://bsc-testnet-dataseed.bnbchain.org --num 21 --turnLength 8");
4243
console.log(" node getchainstatus.js GetTopAddr --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000010 --topNum 10");
4344
console.log(" node getchainstatus.js GetSlashCount --rpc https://bsc-testnet-dataseed.bnbchain.org --blockNum 40000001"); // default: latest block
4445
console.log(" node getchainstatus.js GetPerformanceData --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000010");
@@ -59,6 +60,7 @@ const addrValidatorSet = "0x0000000000000000000000000000000000001000";
5960
const addrSlash = "0x0000000000000000000000000000000000001001";
6061
const addrStakeHub = "0x0000000000000000000000000000000000002002";
6162
const addrGovernor = "0x0000000000000000000000000000000000002004";
63+
const TimelockContract = "0x0000000000000000000000000000000000002006";
6264

6365
const validatorSetAbi = [
6466
"function validatorExtraSet(uint256 offset) external view returns (uint256, bool, bytes)",
@@ -92,17 +94,25 @@ const stakeHubAbi = [
9294
"function felonySlashAmount() public view returns (uint256)", // default 200BNB, valid: > max(100, downtimeSlashAmount)
9395
"function downtimeJailTime() public view returns (uint256)", // default 2days,
9496
"function felonyJailTime() public view returns (uint256)", // default 30days,
95-
];
97+
"function getValidators(uint256, uint256) external view returns(address[], address[], uint256)",
98+
"function getNodeIDs(address[] validatorsToQuery) external view returns(address[], bytes32[][])",
99+
];
100+
96101

97102
const governorAbi = [
98103
"function votingPeriod() public view returns (uint256)",
99104
"function lateQuorumVoteExtension() public view returns (uint64)", // it represents minPeriodAfterQuorum
100105
];
101106

107+
const timelockAbi = [
108+
"function getMinDelay() public view returns (uint256)",
109+
];
110+
102111
const validatorSet = new ethers.Contract(addrValidatorSet, validatorSetAbi, provider);
103112
const slashIndicator = new ethers.Contract(addrSlash, slashAbi, provider);
104113
const stakeHub = new ethers.Contract(addrStakeHub, stakeHubAbi, provider);
105114
const governor = new ethers.Contract(addrGovernor, governorAbi, provider);
115+
const timelock = new ethers.Contract(TimelockContract, timelockAbi, provider);
106116

107117
const validatorMap = new Map([
108118
// BSC mainnet
@@ -279,7 +289,7 @@ async function getMaxTxCountInBlockRange() {
279289
// node getchainstatus.js GetBinaryVersion \
280290
// --rpc https://bsc-testnet-dataseed.bnbchain.org \
281291
// --num(optional): default 21, the number of blocks that will be checked
282-
// --turnLength(optional): default 4, the consecutive block length
292+
// --turnLength(optional): default 8, the consecutive block length
283293
async function getBinaryVersion() {
284294
const blockNum = await provider.getBlockNumber();
285295
let turnLength = program.turnLength;
@@ -408,7 +418,7 @@ async function getPerformanceData() {
408418
let gasUsedTotal = 0;
409419
let inturnBlocks = 0;
410420
let justifiedBlocks = 0;
411-
let turnLength = 4;
421+
let turnLength = 8;
412422
let lastTimestamp = null;
413423
let parliaEnabled = true;
414424

@@ -621,21 +631,40 @@ async function getKeyParameters() {
621631
let validatorTable = [];
622632
for (let i = 0; i < totalLength; i++) {
623633
validatorTable.push({
624-
addr: consensusAddrs[i],
634+
consensusAddr: consensusAddrs[i],
625635
votingPower: Number(votingPowers[i] / BigInt(10 ** 18)),
626636
voteAddr: voteAddrs[i],
627637
moniker: await getValidatorMoniker(consensusAddrs[i], blockNum),
628638
});
629639
}
630640
validatorTable.sort((a, b) => b.votingPower - a.votingPower);
631641
console.table(validatorTable);
642+
// get EVN node ids
643+
let validators = await stakeHub.getValidators(0, 1000, { blockTag: blockNum });
644+
let operatorAddrs = validators[0];
645+
let nodeIdss = await stakeHub.getNodeIDs(Array.from(operatorAddrs), { blockTag: blockNum });
646+
let consensusAddrs2 = nodeIdss[0];
647+
let nodeIdArr = nodeIdss[1];
648+
for (let i = 0; i < consensusAddrs2.length; i++) {
649+
let addr = consensusAddrs2[i];
650+
let nodeId = nodeIdArr[i];
651+
if (nodeId.length > 0) {
652+
console.log("consensusAddr:", addr, "nodeId:", nodeId);
653+
}
654+
}
655+
632656

633657
// part 4: governance
634658
let votingPeriod = await governor.votingPeriod({ blockTag: blockNum });
635659
let minPeriodAfterQuorum = await governor.lateQuorumVoteExtension({ blockTag: blockNum });
636660
console.log("\n##==== GovernorContract: 0x0000000000000000000000000000000000002004")
637661
console.log("\tvotingPeriod", Number(votingPeriod));
638662
console.log("\tminPeriodAfterQuorum", Number(minPeriodAfterQuorum));
663+
664+
// part 5: timelock
665+
let minDelay = await timelock.getMinDelay({ blockTag: blockNum });
666+
console.log("\n##==== TimelockContract: 0x0000000000000000000000000000000000002006")
667+
console.log("\tminDelay", Number(minDelay));
639668
}
640669

641670
// 9.cmd: "getEip7623", usage:

common/fdlimit/fdlimit_darwin.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,14 @@ const hardlimit = 10240
2424
// Raise tries to maximize the file descriptor allowance of this process
2525
// to the maximum hard-limit allowed by the OS.
2626
// Returns the size it was set to (may differ from the desired 'max')
27-
func Raise(max uint64) (uint64, error) {
27+
func Raise(maxVal uint64) (uint64, error) {
2828
// Get the current limit
2929
var limit syscall.Rlimit
3030
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
3131
return 0, err
3232
}
3333
// Try to update the limit to the max allowance
34-
limit.Cur = limit.Max
35-
if limit.Cur > max {
36-
limit.Cur = max
37-
}
34+
limit.Cur = min(limit.Max, maxVal)
3835
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
3936
return 0, err
4037
}

consensus/parlia/parlia.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ func (p *Parlia) Delay(chain consensus.ChainReader, header *types.Header, leftOv
16681668
// The blocking time should be no more than half of period when snap.TurnLength == 1
16691669
timeForMining := time.Duration(snap.BlockInterval) * time.Millisecond / 2
16701670
if !snap.lastBlockInOneTurn(header.Number.Uint64()) {
1671-
timeForMining = time.Duration(snap.BlockInterval) * time.Millisecond * 2 / 3
1671+
timeForMining = time.Duration(snap.BlockInterval) * time.Millisecond * 4 / 5
16721672
}
16731673
if delay > timeForMining {
16741674
delay = timeForMining

core/bench_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) {
183183
if !disk {
184184
db = rawdb.NewMemoryDatabase()
185185
} else {
186-
pdb, err := pebble.New(b.TempDir(), 128, 128, "", false, true)
186+
pdb, err := pebble.New(b.TempDir(), 128, 128, "", false)
187187
if err != nil {
188188
b.Fatalf("cannot create temporary database: %v", err)
189189
}
@@ -304,7 +304,7 @@ func makeChainForBench(db ethdb.Database, genesis *Genesis, full bool, count uin
304304
func benchWriteChain(b *testing.B, full bool, count uint64) {
305305
genesis := &Genesis{Config: params.AllEthashProtocolChanges}
306306
for i := 0; i < b.N; i++ {
307-
pdb, err := pebble.New(b.TempDir(), 1024, 128, "", false, true)
307+
pdb, err := pebble.New(b.TempDir(), 1024, 128, "", false)
308308
if err != nil {
309309
b.Fatalf("error opening database: %v", err)
310310
}
@@ -317,7 +317,7 @@ func benchWriteChain(b *testing.B, full bool, count uint64) {
317317
func benchReadChain(b *testing.B, full bool, count uint64) {
318318
dir := b.TempDir()
319319

320-
pdb, err := pebble.New(dir, 1024, 128, "", false, true)
320+
pdb, err := pebble.New(dir, 1024, 128, "", false)
321321
if err != nil {
322322
b.Fatalf("error opening database: %v", err)
323323
}
@@ -333,7 +333,7 @@ func benchReadChain(b *testing.B, full bool, count uint64) {
333333
b.ResetTimer()
334334

335335
for i := 0; i < b.N; i++ {
336-
pdb, err = pebble.New(dir, 1024, 128, "", false, true)
336+
pdb, err = pebble.New(dir, 1024, 128, "", false)
337337
if err != nil {
338338
b.Fatalf("error opening database: %v", err)
339339
}

core/blockchain.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,17 +1119,16 @@ func (bc *BlockChain) setHeadBeyondRoot(head uint64, time uint64, root common.Ha
11191119
// Ignore the error here since light client won't hit this path
11201120
frozen, _ := bc.db.BlockStore().Ancients()
11211121
if num+1 <= frozen {
1122-
// Truncate all relative data(header, total difficulty, body, receipt
1123-
// and canonical hash) from ancient store.
1124-
if _, err := bc.db.BlockStore().TruncateHead(num); err != nil {
1125-
log.Crit("Failed to truncate ancient data", "number", num, "err", err)
1126-
}
1127-
// Remove the hash <-> number mapping from the active store.
1128-
rawdb.DeleteHeaderNumber(db, hash)
1122+
// The chain segment, such as the block header, canonical hash,
1123+
// body, and receipt, will be removed from the ancient store
1124+
// in one go.
1125+
//
1126+
// The hash-to-number mapping in the key-value store will be
1127+
// removed by the hc.SetHead function.
11291128
} else {
1130-
// Remove relative body and receipts from the active store.
1131-
// The header, total difficulty and canonical hash will be
1132-
// removed in the hc.SetHead function.
1129+
// Remove the associated body and receipts from the key-value store.
1130+
// The header, hash-to-number mapping, and canonical hash will be
1131+
// removed by the hc.SetHead function.
11331132
rawdb.DeleteBody(db, hash, num)
11341133
rawdb.DeleteBlobSidecars(db, hash, num)
11351134
rawdb.DeleteReceipts(db, hash, num)
@@ -1599,7 +1598,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
15991598
size += writeSize
16001599

16011600
// Sync the ancient store explicitly to ensure all data has been flushed to disk.
1602-
if err := bc.db.BlockStore().Sync(); err != nil {
1601+
if err := bc.db.BlockStore().SyncAncient(); err != nil {
16031602
return 0, err
16041603
}
16051604
// Update the current snap block because all block data is now present in DB.

core/blockchain_repair_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ func testRepairWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme s
17671767
datadir := t.TempDir()
17681768
ancient := filepath.Join(datadir, "ancient")
17691769

1770-
pdb, err := pebble.New(datadir, 0, 0, "", false, true)
1770+
pdb, err := pebble.New(datadir, 0, 0, "", false)
17711771
if err != nil {
17721772
t.Fatalf("Failed to create persistent key-value database: %v", err)
17731773
}
@@ -1861,7 +1861,7 @@ func testRepairWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme s
18611861
chain.stopWithoutSaving()
18621862

18631863
// Start a new blockchain back up and see where the repair leads us
1864-
pdb, err = pebble.New(datadir, 0, 0, "", false, true)
1864+
pdb, err = pebble.New(datadir, 0, 0, "", false)
18651865
if err != nil {
18661866
t.Fatalf("Failed to reopen persistent key-value database: %v", err)
18671867
}
@@ -1926,7 +1926,7 @@ func testIssue23496(t *testing.T, scheme string) {
19261926
datadir := t.TempDir()
19271927
ancient := filepath.Join(datadir, "ancient")
19281928

1929-
pdb, err := pebble.New(datadir, 0, 0, "", false, true)
1929+
pdb, err := pebble.New(datadir, 0, 0, "", false)
19301930
if err != nil {
19311931
t.Fatalf("Failed to create persistent key-value database: %v", err)
19321932
}
@@ -1984,7 +1984,7 @@ func testIssue23496(t *testing.T, scheme string) {
19841984
chain.stopWithoutSaving()
19851985

19861986
// Start a new blockchain back up and see where the repair leads us
1987-
pdb, err = pebble.New(datadir, 0, 0, "", false, true)
1987+
pdb, err = pebble.New(datadir, 0, 0, "", false)
19881988
if err != nil {
19891989
t.Fatalf("Failed to reopen persistent key-value database: %v", err)
19901990
}

core/blockchain_sethead_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ func testSetHeadWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme
19711971
datadir := t.TempDir()
19721972
ancient := filepath.Join(datadir, "ancient")
19731973

1974-
pdb, err := pebble.New(datadir, 0, 0, "", false, true)
1974+
pdb, err := pebble.New(datadir, 0, 0, "", false)
19751975
if err != nil {
19761976
t.Fatalf("Failed to create persistent key-value database: %v", err)
19771977
}

core/blockchain_snapshot_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (basic *snapshotTestBasic) prepare(t *testing.T) (*BlockChain, []*types.Blo
6666
datadir := t.TempDir()
6767
ancient := filepath.Join(datadir, "ancient")
6868

69-
pdb, err := pebble.New(datadir, 0, 0, "", false, true)
69+
pdb, err := pebble.New(datadir, 0, 0, "", false)
7070
if err != nil {
7171
t.Fatalf("Failed to create persistent key-value database: %v", err)
7272
}
@@ -257,7 +257,7 @@ func (snaptest *crashSnapshotTest) test(t *testing.T) {
257257
chain.triedb.Close()
258258

259259
// Start a new blockchain back up and see where the repair leads us
260-
pdb, err := pebble.New(snaptest.datadir, 0, 0, "", false, true)
260+
pdb, err := pebble.New(snaptest.datadir, 0, 0, "", false)
261261
if err != nil {
262262
t.Fatalf("Failed to create persistent key-value database: %v", err)
263263
}

0 commit comments

Comments
 (0)