Skip to content

Commit 0449349

Browse files
authored
Merge pull request bnb-chain#2930 from bnb-chain/develop
2 parents 847cef9 + 552010b commit 0449349

34 files changed

+465
-121
lines changed

CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
# Changelog
2+
## v1.5.7
3+
v1.5.7 conduct small upstream code merge to follow the latest pectra hard fork and apply some bug fix. There are two PR for the code merge:
4+
* [\#2897](https://github.com/bnb-chain/bsc/pull/2897) upstream: merge tag 'geth-v1.15.1' into bsc-develop
5+
* [\#2926](https://github.com/bnb-chain/bsc/pull/2926) upstream: pick bug fix from latest geth
6+
7+
Besides code merge, there are also several important bugfix/improvements, and setup mainnet Pascal hard fork time:
8+
### FEATURE
9+
* [\#2928](https://github.com/bnb-chain/bsc/pull/2928) config: update BSC Mainnet hardfork date: Pascal & Praque
10+
11+
### BUGFIX
12+
* [\#2907](https://github.com/bnb-chain/bsc/pull/0000) go.mod: downgrade bls-eth-go-binary to make it same as the prysm-v5.0.0
13+
14+
### IMPROVEMENT
15+
* [\#2896](https://github.com/bnb-chain/bsc/pull/2896) consensus/parlia: estimate gas reserved for systemTxs
16+
* [\#2912](https://github.com/bnb-chain/bsc/pull/2912) consensus/parlia: improve performance of func IsSystemTransaction
17+
* [\#2916](https://github.com/bnb-chain/bsc/pull/2916) miner: avoid to collect requests when getting pending blocks
18+
* [\#2913](https://github.com/bnb-chain/bsc/pull/2913) core/vm: add basic test cases for blsSignatureVerify
19+
* [\#2918](https://github.com/bnb-chain/bsc/pull/2918) core/txpool/legacypool/legacypool.go: add gasTip check when reset
20+
221
## v1.5.6
322
v1.5.6 performed another small code sync with Geth upstream, mainly sync the 7702 tx type txpool update, refer: https://github.com/bnb-chain/bsc/pull/2888/
423

cmd/evm/testdata/evmrun/3.out.1.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"root": "b444481d1367188172f8c6091e948aaa68bae763fd26d6b9e994306a66bf69f9",
33
"accounts": {
4-
"pre(0x30d7a0694cb29af31b982480e11d7ebb003a3fca4026939149071f014689b142)": {
4+
"0x0000000000000000000000007265636569766572": {
55
"balance": "0",
66
"nonce": 0,
77
"root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
88
"codeHash": "0x3e48ef54b89079a075f3b8fc253c657a86b110a7aed3568c1517b10edf2c3eb6",
99
"code": "0x6040",
10+
"address": "0x0000000000000000000000007265636569766572",
1011
"key": "0x30d7a0694cb29af31b982480e11d7ebb003a3fca4026939149071f014689b142"
1112
}
1213
}

cmd/evm/testdata/evmrun/4.out.1.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"root": "b444481d1367188172f8c6091e948aaa68bae763fd26d6b9e994306a66bf69f9",
33
"accounts": {
4-
"pre(0x30d7a0694cb29af31b982480e11d7ebb003a3fca4026939149071f014689b142)": {
4+
"0x0000000000000000000000007265636569766572": {
55
"balance": "0",
66
"nonce": 0,
77
"root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
88
"codeHash": "0x3e48ef54b89079a075f3b8fc253c657a86b110a7aed3568c1517b10edf2c3eb6",
99
"code": "0x6040",
10+
"address": "0x0000000000000000000000007265636569766572",
1011
"key": "0x30d7a0694cb29af31b982480e11d7ebb003a3fca4026939149071f014689b142"
1112
}
1213
}

cmd/geth/chaincmd.go

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var (
6464
utils.OverridePassedForkTime,
6565
utils.OverridePascal,
6666
utils.OverridePrague,
67+
utils.OverrideLorentz,
6768
utils.OverrideVerkle,
6869
utils.MultiDataBaseFlag,
6970
}, utils.DatabaseFlags),
@@ -268,6 +269,10 @@ func initGenesis(ctx *cli.Context) error {
268269
v := ctx.Uint64(utils.OverridePrague.Name)
269270
overrides.OverridePrague = &v
270271
}
272+
if ctx.IsSet(utils.OverrideLorentz.Name) {
273+
v := ctx.Uint64(utils.OverrideLorentz.Name)
274+
overrides.OverrideLorentz = &v
275+
}
271276
if ctx.IsSet(utils.OverrideVerkle.Name) {
272277
v := ctx.Uint64(utils.OverrideVerkle.Name)
273278
overrides.OverrideVerkle = &v

cmd/geth/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
213213
v := ctx.Uint64(utils.OverridePrague.Name)
214214
cfg.Eth.OverridePrague = &v
215215
}
216+
if ctx.IsSet(utils.OverrideLorentz.Name) {
217+
v := ctx.Uint64(utils.OverrideLorentz.Name)
218+
cfg.Eth.OverrideLorentz = &v
219+
}
216220
if ctx.IsSet(utils.OverrideVerkle.Name) {
217221
v := ctx.Uint64(utils.OverrideVerkle.Name)
218222
cfg.Eth.OverrideVerkle = &v

cmd/geth/main.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ var (
7676
utils.OverridePassedForkTime,
7777
utils.OverridePascal,
7878
utils.OverridePrague,
79+
utils.OverrideLorentz,
7980
utils.OverrideVerkle,
8081
utils.OverrideFullImmutabilityThreshold,
8182
utils.OverrideMinBlocksForBlobRequests,
@@ -466,8 +467,8 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, isCon
466467
// Start auxiliary services if enabled
467468
ethBackend, ok := backend.(*eth.EthAPIBackend)
468469
gasCeil := ethBackend.Miner().GasCeil()
469-
if gasCeil > params.SystemTxsGas {
470-
ethBackend.TxPool().SetMaxGas(gasCeil - params.SystemTxsGas)
470+
if gasCeil > params.SystemTxsGasSoftLimit {
471+
ethBackend.TxPool().SetMaxGas(gasCeil - params.SystemTxsGasSoftLimit)
471472
}
472473
if ctx.Bool(utils.MiningEnabledFlag.Name) {
473474
// Mining only makes sense if a full Ethereum node is running

cmd/jsutils/getchainstatus.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ program.option("--startNum <startNum>", "start num")
66
program.option("--endNum <endNum>", "end num")
77
program.option("--miner <miner>", "miner", "")
88
program.option("--num <Num>", "validator num", 21)
9+
program.option("--turnLength <Num>", "the consecutive block length", 4)
910
program.option("--topNum <Num>", "top num of address to be displayed", 20)
1011
program.option("--blockNum <Num>", "block num", 0)
1112
program.option("-h, --help", "")
@@ -34,7 +35,7 @@ function printUsage() {
3435
console.log("\nExample:");
3536
// mainnet https://bsc-mainnet.nodereal.io/v1/454e504917db4f82b756bd0cf6317dce
3637
console.log(" node getchainstatus.js GetMaxTxCountInBlockRange --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000005")
37-
console.log(" node getchainstatus.js GetBinaryVersion --rpc https://bsc-testnet-dataseed.bnbchain.org --num 21")
38+
console.log(" node getchainstatus.js GetBinaryVersion --rpc https://bsc-testnet-dataseed.bnbchain.org --num 21 --turnLength 4")
3839
console.log(" node getchainstatus.js GetTopAddr --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000010 --topNum 10")
3940
console.log(" node getchainstatus.js GetSlashCount --rpc https://bsc-testnet-dataseed.bnbchain.org --blockNum 40000001") // default: latest block
4041
console.log(" node getchainstatus.js GetPerformanceData --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000010")
@@ -193,12 +194,13 @@ async function getMaxTxCountInBlockRange() {
193194
// 2.cmd: "GetBinaryVersion", usage:
194195
// node getchainstatus.js GetBinaryVersion \
195196
// --rpc https://bsc-testnet-dataseed.bnbchain.org \
196-
// --num(optional): defualt 21, the number of blocks that will be checked
197+
// --num(optional): default 21, the number of blocks that will be checked
198+
// --turnLength(optional): default 4, the consecutive block length
197199
async function getBinaryVersion() {
198200
const blockNum = await provider.getBlockNumber();
199-
console.log(blockNum);
201+
let turnLength = program.turnLength
200202
for (let i = 0; i < program.num; i++) {
201-
let blockData = await provider.getBlock(blockNum - i);
203+
let blockData = await provider.getBlock(blockNum - i*turnLength);
202204
// 1.get Geth client version
203205
let major = ethers.toNumber(ethers.dataSlice(blockData.extraData, 2, 3))
204206
let minor = ethers.toNumber(ethers.dataSlice(blockData.extraData, 3, 4))
@@ -215,7 +217,8 @@ async function getBinaryVersion() {
215217
lastGasPrice = txData.gasPrice
216218
break
217219
}
218-
console.log(blockData.miner, "version =", major + "." + minor + "." + patch, " MinGasPrice = " + lastGasPrice)
220+
var moniker = await getValidatorMoniker(blockData.miner, blockNum)
221+
console.log(blockNum - i*turnLength, blockData.miner, "version =", major + "." + minor + "." + patch, " MinGasPrice = " + lastGasPrice, moniker)
219222
}
220223
};
221224

cmd/utils/flags.go

+5
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ var (
311311
Usage: "Manually specify the Prague fork timestamp, overriding the bundled setting",
312312
Category: flags.EthCategory,
313313
}
314+
OverrideLorentz = &cli.Uint64Flag{
315+
Name: "override.lorentz",
316+
Usage: "Manually specify the Lorentz fork timestamp, overriding the bundled setting",
317+
Category: flags.EthCategory,
318+
}
314319
OverrideVerkle = &cli.Uint64Flag{
315320
Name: "override.verkle",
316321
Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting",

consensus/parlia/parlia.go

+43-6
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,17 @@ func (p *Parlia) Period() uint64 {
321321
}
322322

323323
func (p *Parlia) IsSystemTransaction(tx *types.Transaction, header *types.Header) (bool, error) {
324-
// deploy a contract
325-
if tx.To() == nil {
324+
if tx.To() == nil || !isToSystemContract(*tx.To()) {
325+
return false, nil
326+
}
327+
if tx.GasPrice().Sign() != 0 {
326328
return false, nil
327329
}
328330
sender, err := types.Sender(p.signer, tx)
329331
if err != nil {
330332
return false, errors.New("UnAuthorized transaction")
331333
}
332-
if sender == header.Coinbase && isToSystemContract(*tx.To()) && tx.GasPrice().Cmp(big.NewInt(0)) == 0 {
333-
return true, nil
334-
}
335-
return false, nil
334+
return sender == header.Coinbase, nil
336335
}
337336

338337
func (p *Parlia) IsSystemContract(to *common.Address) bool {
@@ -1258,6 +1257,44 @@ func (p *Parlia) distributeFinalityReward(chain consensus.ChainHeaderReader, sta
12581257
return p.applyTransaction(msg, state, header, cx, txs, receipts, systemTxs, usedGas, mining, tracer)
12591258
}
12601259

1260+
func (p *Parlia) EstimateGasReservedForSystemTxs(chain consensus.ChainHeaderReader, header *types.Header) uint64 {
1261+
parent := chain.GetHeaderByHash(header.ParentHash)
1262+
if parent != nil {
1263+
// Mainnet and Chapel have both passed Feynman. Now, simplify the logic before and during the Feynman hard fork.
1264+
if p.chainConfig.IsFeynman(header.Number, header.Time) &&
1265+
!p.chainConfig.IsOnFeynman(header.Number, parent.Time, header.Time) {
1266+
// const (
1267+
// the following values represent the maximum values found in the most recent blocks on the mainnet
1268+
// depositTxGas = uint64(60_000)
1269+
// slashTxGas = uint64(140_000)
1270+
// finalityRewardTxGas = uint64(350_000)
1271+
// updateValidatorTxGas = uint64(12_160_000)
1272+
// )
1273+
// suggestReservedGas := depositTxGas
1274+
// if header.Difficulty.Cmp(diffInTurn) != 0 {
1275+
// snap, err := p.snapshot(chain, header.Number.Uint64()-1, header.ParentHash, nil)
1276+
// if err != nil || !snap.SignRecently(snap.inturnValidator()) {
1277+
// suggestReservedGas += slashTxGas
1278+
// }
1279+
// }
1280+
// if header.Number.Uint64()%p.config.Epoch == 0 {
1281+
// suggestReservedGas += finalityRewardTxGas
1282+
// }
1283+
// if isBreatheBlock(parent.Time, header.Time) {
1284+
// suggestReservedGas += updateValidatorTxGas
1285+
// }
1286+
// return suggestReservedGas * 150 / 100
1287+
if !isBreatheBlock(parent.Time, header.Time) {
1288+
// params.SystemTxsGasSoftLimit > (depositTxGas+slashTxGas+finalityRewardTxGas)*150/100
1289+
return params.SystemTxsGasSoftLimit
1290+
}
1291+
}
1292+
}
1293+
1294+
// params.SystemTxsGasHardLimit > (depositTxGas+slashTxGas+finalityRewardTxGas+updateValidatorTxGas)*150/100
1295+
return params.SystemTxsGasHardLimit
1296+
}
1297+
12611298
// Finalize implements consensus.Engine, ensuring no uncles are set, nor block
12621299
// rewards given.
12631300
func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state vm.StateDB, txs *[]*types.Transaction,

core/genesis.go

+9
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ type ChainOverrides struct {
266266
OverridePassedForkTime *uint64
267267
OverridePascal *uint64
268268
OverridePrague *uint64
269+
OverrideLorentz *uint64
269270
OverrideVerkle *uint64
270271
}
271272

@@ -290,6 +291,9 @@ func (o *ChainOverrides) apply(cfg *params.ChainConfig) error {
290291
if o.OverridePrague != nil {
291292
cfg.PragueTime = o.OverridePrague
292293
}
294+
if o.OverrideLorentz != nil {
295+
cfg.LorentzTime = o.OverrideLorentz
296+
}
293297
if o.OverrideVerkle != nil {
294298
cfg.VerkleTime = o.OverrideVerkle
295299
}
@@ -387,6 +391,11 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
387391
}
388392
newCfg := genesis.chainConfigOrDefault(ghash, storedCfg)
389393

394+
// Sanity-check the new configuration.
395+
if err := newCfg.CheckConfigForkOrder(); err != nil {
396+
return nil, common.Hash{}, nil, err
397+
}
398+
390399
// TODO(rjl493456442) better to define the comparator of chain config
391400
// and short circuit if the chain config is not changed.
392401
compatErr := storedCfg.CheckCompatible(newCfg, head.Number.Uint64(), head.Time)

core/rawdb/freezer_table.go

+7
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,13 @@ func (t *freezerTable) repairIndex() error {
420420
// If legacy metadata is detected, attempt to recover the offset from the
421421
// index file to avoid clearing the entire table.
422422
if t.metadata.version == freezerTableV1 {
423+
// Skip truncation if the legacy metadata is opened in read-only mode.
424+
// Since all items in the legacy index file were forcibly synchronized,
425+
// data integrity is guaranteed. Therefore, it's safe to leave any extra
426+
// items untruncated in this special scenario.
427+
if t.readonly {
428+
return nil
429+
}
423430
t.logger.Info("Recovering freezer flushOffset for legacy table", "offset", size)
424431
return t.metadata.setFlushOffset(size, true)
425432
}

core/txpool/errors.go

-13
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ var (
5151
// making the transaction invalid, rather a DOS protection.
5252
ErrOversizedData = errors.New("oversized data")
5353

54-
// ErrFutureReplacePending is returned if a future transaction replaces a pending
55-
// one. Future transactions should only be able to replace other future transactions.
56-
ErrFutureReplacePending = errors.New("future transaction tries to replace pending")
57-
5854
// ErrAlreadyReserved is returned if the sender address has a pending transaction
5955
// in a different subpool. For example, this error is returned in response to any
6056
// input transaction of non-blob type when a blob transaction from this sender
@@ -63,13 +59,4 @@ var (
6359

6460
// ErrInBlackList is returned if the transaction send by banned address
6561
ErrInBlackList = errors.New("sender or to in black list")
66-
67-
// ErrAuthorityReserved is returned if a transaction has an authorization
68-
// signed by an address which already has in-flight transactions known to the
69-
// pool.
70-
ErrAuthorityReserved = errors.New("authority already reserved")
71-
72-
// ErrAuthorityNonce is returned if a transaction has an authorization with
73-
// a nonce that is not currently valid for the authority.
74-
ErrAuthorityNonceTooLow = errors.New("authority nonce too low")
7562
)

0 commit comments

Comments
 (0)