Skip to content

Commit 470f64e

Browse files
authored
Merge pull request #275 from bnb-chain/develop
feat: merge for releasing v0.5.7
2 parents b224f9d + f6eb879 commit 470f64e

File tree

25 files changed

+248
-62
lines changed

25 files changed

+248
-62
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
# Changelog
22

3+
## v0.5.7
4+
5+
This release introduces the implementation of [BEP-543](https://github.com/bnb-chain/BEPs/blob/master/BEPs/BEP-543.md), effectively reducing the block time from 1 second to an impressive 500 milliseconds.
6+
This enhancement significantly improves transaction efficiency and overall network performance, allowing for faster processing and a more seamless experience for users.
7+
8+
It is set to be activated on both the opBNB Mainnet and Testnet environments according to the following schedule:
9+
10+
- Testnet: Apr-02-2025 03:00 AM +UTC
11+
- Mainnet: Mid-Apr-2025
12+
13+
All mainnet and testnet nodes must upgrade to this release before the hardfork time.
14+
15+
### What's Changed
16+
17+
#### FEATURE
18+
* [\#269](https://github.com/bnb-chain/op-geth/pull/269) change block internal to 500ms
19+
* [\#273](https://github.com/bnb-chain/op-geth/pull/273) add millisecond to rpc field
20+
21+
### BUGFIX
22+
* [\#270](https://github.com/bnb-chain/op-geth/pull/270) concurrent issue of local account set in legacypool
23+
24+
### Docker Images
25+
ghcr.io/bnb-chain/op-geth:v0.5.7
26+
27+
**Full Changelog**: https://github.com/bnb-chain/op-geth/compare/v0.5.6...v0.5.7
28+
329
## v0.5.6
430

531
This is a minor release for opBNB Mainnet and Testnet.

beacon/engine/types.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package engine
1818

1919
import (
2020
"fmt"
21+
"github.com/holiman/uint256"
2122
"math/big"
2223

2324
"github.com/ethereum/go-ethereum/common"
@@ -26,6 +27,11 @@ import (
2627
"github.com/ethereum/go-ethereum/trie"
2728
)
2829

30+
var (
31+
OldBlockMillisecondsInterval uint64 = 1000
32+
NewBlockMillisecondsInterval uint64 = 500
33+
)
34+
2935
// PayloadVersion denotes the version of PayloadAttributes used to request the
3036
// building of the payload to commence.
3137
type PayloadVersion byte
@@ -64,12 +70,22 @@ type PayloadAttributes struct {
6470

6571
// JSON type overrides for PayloadAttributes.
6672
type payloadAttributesMarshaling struct {
67-
Timestamp hexutil.Uint64
73+
TempTimestamp hexutil.Uint64 // temp change 'Timestamp' to 'TempTimestamp' for debugging
74+
Random hexutil.Bytes // Random store the milliseconds
6875

6976
Transactions []hexutil.Bytes
7077
GasLimit *hexutil.Uint64
7178
}
7279

80+
func (p *PayloadAttributes) millisecondes() uint64 {
81+
if p.Random == (common.Hash{}) {
82+
return 0
83+
}
84+
return uint256.NewInt(0).SetBytes2(p.Random[:2]).Uint64()
85+
}
86+
87+
func (p *PayloadAttributes) MilliTimestamp() uint64 { return p.Timestamp*1000 + p.millisecondes() }
88+
7389
//go:generate go run github.com/fjl/gencodec -type ExecutableData -field-override executableDataMarshaling -out gen_ed.go
7490

7591
// ExecutableData is the data necessary to execute an EL payload.
@@ -99,6 +115,7 @@ type executableDataMarshaling struct {
99115
GasLimit hexutil.Uint64
100116
GasUsed hexutil.Uint64
101117
Timestamp hexutil.Uint64
118+
Random hexutil.Bytes // Random store the milliseconds
102119
BaseFeePerGas *hexutil.Big
103120
ExtraData hexutil.Bytes
104121
LogsBloom hexutil.Bytes

consensus/beacon/consensus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
255255
return errInvalidUncleHash
256256
}
257257
// Verify the timestamp
258-
if header.Time <= parent.Time {
258+
if header.MilliTimestamp() <= parent.MilliTimestamp() {
259259
return errInvalidTimestamp
260260
}
261261
// Verify the block's difficulty to ensure it's the default constant

consensus/ethash/consensus.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
230230
return consensus.ErrFutureBlock
231231
}
232232
}
233-
if header.Time <= parent.Time {
233+
if header.MilliTimestamp() <= parent.MilliTimestamp() {
234234
return errOlderBlockTime
235235
}
236236
// Verify the block's difficulty based on its timestamp and parent's difficulty
@@ -539,6 +539,7 @@ func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
539539
header.GasLimit,
540540
header.GasUsed,
541541
header.Time,
542+
header.MixDigest,
542543
header.Extra,
543544
}
544545
if header.BaseFee != nil {

core/blockchain.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -642,16 +642,16 @@ func (bc *BlockChain) loadLastState() error {
642642
blockTd = bc.GetTd(headBlock.Hash(), headBlock.NumberU64())
643643
)
644644
if headHeader.Hash() != headBlock.Hash() {
645-
log.Info("Loaded most recent local header", "number", headHeader.Number, "hash", headHeader.Hash(), "td", headerTd, "age", common.PrettyAge(time.Unix(int64(headHeader.Time), 0)))
645+
log.Info("Loaded most recent local header", "number", headHeader.Number, "hash", headHeader.Hash(), "td", headerTd, "age", common.PrettyAge(time.Unix(int64(headHeader.MilliTimestamp()), 0)))
646646
}
647-
log.Info("Loaded most recent local block", "number", headBlock.Number(), "hash", headBlock.Hash(), "td", blockTd, "age", common.PrettyAge(time.Unix(int64(headBlock.Time()), 0)))
647+
log.Info("Loaded most recent local block", "number", headBlock.Number(), "hash", headBlock.Hash(), "td", blockTd, "age", common.PrettyAge(time.Unix(int64(headBlock.MilliTimestamp()), 0)))
648648
if headBlock.Hash() != currentSnapBlock.Hash() {
649649
snapTd := bc.GetTd(currentSnapBlock.Hash(), currentSnapBlock.Number.Uint64())
650-
log.Info("Loaded most recent local snap block", "number", currentSnapBlock.Number, "hash", currentSnapBlock.Hash(), "td", snapTd, "age", common.PrettyAge(time.Unix(int64(currentSnapBlock.Time), 0)))
650+
log.Info("Loaded most recent local snap block", "number", currentSnapBlock.Number, "hash", currentSnapBlock.Hash(), "td", snapTd, "age", common.PrettyAge(time.Unix(int64(currentSnapBlock.MilliTimestamp()), 0)))
651651
}
652652
if currentFinalBlock != nil {
653653
finalTd := bc.GetTd(currentFinalBlock.Hash(), currentFinalBlock.Number.Uint64())
654-
log.Info("Loaded most recent local finalized block", "number", currentFinalBlock.Number, "hash", currentFinalBlock.Hash(), "td", finalTd, "age", common.PrettyAge(time.Unix(int64(currentFinalBlock.Time), 0)))
654+
log.Info("Loaded most recent local finalized block", "number", currentFinalBlock.Number, "hash", currentFinalBlock.Hash(), "td", finalTd, "age", common.PrettyAge(time.Unix(int64(currentFinalBlock.MilliTimestamp()), 0)))
655655
}
656656
if pivot := rawdb.ReadLastPivotNumber(bc.db); pivot != nil {
657657
log.Info("Loaded last snap-sync pivot marker", "number", *pivot)
@@ -1461,7 +1461,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
14611461
head = blockChain[len(blockChain)-1]
14621462
context = []interface{}{
14631463
"count", stats.processed, "elapsed", common.PrettyDuration(time.Since(start)),
1464-
"number", head.Number(), "hash", head.Hash(), "age", common.PrettyAge(time.Unix(int64(head.Time()), 0)),
1464+
"number", head.Number(), "hash", head.Hash(), "age", common.PrettyAge(time.Unix(int64(head.MilliTimestamp()), 0)),
14651465
"size", common.StorageSize(size),
14661466
}
14671467
)
@@ -1684,7 +1684,7 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types
16841684
func (bc *BlockChain) addFutureBlock(block *types.Block) error {
16851685
max := uint64(time.Now().Unix() + maxTimeFutureBlocks)
16861686
if block.Time() > max {
1687-
return fmt.Errorf("future block timestamp %v > allowed %v", block.Time(), max)
1687+
return fmt.Errorf("future block timestamp %v > allowed %v", block.MilliTimestamp(), max)
16881688
}
16891689
if block.Difficulty().Cmp(common.Big0) == 0 {
16901690
// Never add PoS blocks into the future queue
@@ -2083,7 +2083,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
20832083
if bc.snaps != nil && !minerMode {
20842084
snapDiffItems, snapBufItems = bc.snaps.Size()
20852085
}
2086-
2086+
20872087
var trieDiffNodes, trieBufNodes, trieImmutableBufNodes common.StorageSize
20882088
if !minerMode {
20892089
trieDiffNodes, trieBufNodes, trieImmutableBufNodes, _ = bc.triedb.Size()

core/blockchain_insert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (st *insertStats) report(chain []*types.Block, index int, snapDiffItems, sn
6060
"blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000,
6161
"elapsed", common.PrettyDuration(elapsed), "mgasps", float64(st.usedGas) * 1000 / float64(elapsed),
6262
}
63-
mgaspsGauge.Update(int64(st.usedGas)*1000/int64(elapsed))
63+
mgaspsGauge.Update(int64(st.usedGas) * 1000 / int64(elapsed))
6464
if timestamp := time.Unix(int64(end.Time()), 0); time.Since(timestamp) > time.Minute {
6565
context = append(context, []interface{}{"age", common.PrettyAge(timestamp)}...)
6666
}

core/chain_makers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ func (b *BlockGen) TxNonce(addr common.Address) uint64 {
217217
func (b *BlockGen) AddUncle(h *types.Header) {
218218
// The uncle will have the same timestamp and auto-generated difficulty
219219
h.Time = b.header.Time
220+
h.MixDigest = b.header.MixDigest
220221

221222
var parent *types.Header
222223
for i := b.i - 1; i >= 0; i-- {

core/headerchain.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ import (
3838
)
3939

4040
const (
41-
headerCacheLimit = 512
42-
tdCacheLimit = 1024
41+
headerCacheLimit = 1280
42+
tdCacheLimit = 1280
4343
numberCacheLimit = 2048
4444
)
4545

core/txpool/blobpool/blobpool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserve txpool.Addres
401401
p.recheck(addr, nil)
402402
}
403403
var (
404-
basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), p.head, p.head.Time+1))
404+
basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), p.head, p.head.NextSecondsTimestamp()))
405405
blobfee = uint256.NewInt(params.BlobTxMinBlobGasprice)
406406
)
407407
if p.head.ExcessBlobGas != nil {
@@ -822,7 +822,7 @@ func (p *BlobPool) Reset(oldHead, newHead *types.Header) {
822822
}
823823
// Reset the price heap for the new set of basefee/blobfee pairs
824824
var (
825-
basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), newHead, newHead.Time+1))
825+
basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), newHead, newHead.NextSecondsTimestamp()))
826826
blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinBlobGasprice))
827827
)
828828
if newHead.ExcessBlobGas != nil {

core/txpool/legacypool/cache_for_miner.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var (
1717
type pendingCache interface {
1818
add(types.Transactions, types.Signer)
1919
del(types.Transactions, types.Signer)
20-
dump() map[common.Address]types.Transactions
20+
dump() (map[common.Address]types.Transactions, map[common.Address]bool)
2121
markLocal(common.Address)
2222
flattenLocals() []common.Address
2323
}
@@ -75,8 +75,9 @@ func (pc *cacheForMiner) del(txs types.Transactions, signer types.Signer) {
7575
}
7676
}
7777

78-
func (pc *cacheForMiner) dump() map[common.Address]types.Transactions {
78+
func (pc *cacheForMiner) dump() (map[common.Address]types.Transactions, map[common.Address]bool) {
7979
pending := make(map[common.Address]types.Transactions)
80+
locals := make(map[common.Address]bool, len(pc.locals))
8081
pc.txLock.Lock()
8182
for addr, txlist := range pc.pending {
8283
pending[addr] = make(types.Transactions, 0, len(txlist))
@@ -85,11 +86,16 @@ func (pc *cacheForMiner) dump() map[common.Address]types.Transactions {
8586
}
8687
}
8788
pc.txLock.Unlock()
89+
pc.addrLock.Lock()
90+
for addr := range pc.locals {
91+
locals[addr] = true
92+
}
93+
pc.addrLock.Unlock()
8894
for _, txs := range pending {
8995
// sorted by nonce
9096
sort.Sort(types.TxByNonce(txs))
9197
}
92-
return pending
98+
return pending, locals
9399
}
94100

95101
func (pc *cacheForMiner) markLocal(addr common.Address) {

0 commit comments

Comments
 (0)