Skip to content

Commit b224f9d

Browse files
authored
Merge pull request #265 from bnb-chain/develop
chore: merge develp code to main for release v0.5.6
2 parents c7a29ca + 1534953 commit b224f9d

File tree

34 files changed

+1149
-217
lines changed

34 files changed

+1149
-217
lines changed

.github/workflows/docker-release.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v3
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v3
20+
with:
21+
image: tonistiigi/binfmt:qemu-v9.2.0
1822
- name: Set up Docker Buildx
1923
uses: docker/setup-buildx-action@v2
2024
- name: Login to GHCR

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,40 @@
11
# Changelog
22

3+
## v0.5.6
4+
5+
This is a minor release for opBNB Mainnet and Testnet.
6+
7+
It includes several performance optimizations and improvements, primarily focused on transaction pool enhancements and block mining efficiency.
8+
Key improvements include tuning snapshot bloom filters for higher TPS, optimizing block mining overhead with a new engine API, and multiple transaction pool optimizations such as cache management, truncation efficiency, direct transaction broadcasting, stale transaction filtering, and asynchronous pricing.
9+
Metrics have also been added to monitor these optimizations.
10+
11+
Upgrading is optional.
12+
13+
### What's Changed
14+
* perf: tune snapshot bloom for higher tps by @bnoieh in https://github.com/bnb-chain/op-geth/pull/230
15+
* perf: support new api engine_opSealPayload and optimize overheads of block mining by @bnoieh in https://github.com/bnb-chain/op-geth/pull/193
16+
* Txpool optimization: disable cache if --mine is not enabled by @andyzhang2023 in https://github.com/bnb-chain/op-geth/pull/245
17+
* Txpool optimization: optimize truncate by @andyzhang2023 in https://github.com/bnb-chain/op-geth/pull/241
18+
* Txpool optimization: broadcast transaction body directly to peer by @andyzhang2023 in https://github.com/bnb-chain/op-geth/pull/243
19+
* Txpool optimization: filter out staled transactions of "nonce too low" when providing all pending list to miner by @andyzhang2023 in https://github.com/bnb-chain/op-geth/pull/244
20+
* Txpool opt async priced by @andyzhang2023 in https://github.com/bnb-chain/op-geth/pull/246
21+
* chore: txpool optimization metrics by @andyzhang2023 in https://github.com/bnb-chain/op-geth/pull/247
22+
23+
### Docker Images
24+
ghcr.io/bnb-chain/op-geth:v0.5.6
25+
26+
**Full Changelog**: https://github.com/bnb-chain/op-geth/compare/v0.5.5...v0.5.6
27+
328
## v0.5.5
429

530
This is a hot fix release, the detail about this fix will be revealed later.
631
Please upgrade your node to this version if your node is exposed to the public network via p2p.
732

33+
### Docker Images
34+
ghcr.io/bnb-chain/op-geth:v0.5.5
35+
36+
**Full Changelog**: https://github.com/bnb-chain/op-geth/compare/v0.5.4...v0.5.5
37+
838
## v0.5.4
939

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

accounts/abi/bind/util_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ func TestWaitDeployed(t *testing.T) {
8383

8484
// Send and mine the transaction.
8585
backend.Client().SendTransaction(ctx, tx)
86-
time.Sleep(500 * time.Millisecond) //wait for the tx to be mined
8786
backend.Commit()
8887

8988
select {
@@ -118,7 +117,6 @@ func TestWaitDeployedCornerCases(t *testing.T) {
118117
ctx, cancel := context.WithCancel(context.Background())
119118
defer cancel()
120119
backend.Client().SendTransaction(ctx, tx)
121-
time.Sleep(500 * time.Millisecond) //wait for the tx to be mined
122120
backend.Commit()
123121
notContractCreation := errors.New("tx is not contract creation")
124122
if _, err := bind.WaitDeployed(ctx, backend.Client(), tx); err.Error() != notContractCreation.Error() {
@@ -137,6 +135,5 @@ func TestWaitDeployedCornerCases(t *testing.T) {
137135
}()
138136

139137
backend.Client().SendTransaction(ctx, tx)
140-
time.Sleep(500 * time.Millisecond) //wait for the tx to be mined
141138
cancel()
142139
}

beacon/engine/errors.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ func (e *EngineAPIError) With(err error) *EngineAPIError {
4949
}
5050
}
5151

52+
// SetStage sets error stage in seal payload
53+
func (e *EngineAPIError) SetStage(stage string) {
54+
e.msg = stage + e.msg
55+
}
56+
5257
var (
5358
_ rpc.Error = new(EngineAPIError)
5459
_ rpc.DataError = new(EngineAPIError)

beacon/engine/types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ import (
3030
// building of the payload to commence.
3131
type PayloadVersion byte
3232

33+
const (
34+
GetPayloadStage = "sealApiGetPayloadErrStage"
35+
NewPayloadStage = "sealApiNewPayloadErrStage"
36+
ForkchoiceUpdatedStage = "sealApiForkchoiceUpdatedErrStage"
37+
)
38+
3339
var (
3440
PayloadV1 PayloadVersion = 0x1
3541
PayloadV2 PayloadVersion = 0x2
@@ -181,6 +187,12 @@ type ForkchoiceStateV1 struct {
181187
FinalizedBlockHash common.Hash `json:"finalizedBlockHash"`
182188
}
183189

190+
type OpSealPayloadResponse struct {
191+
ErrStage string `json:"errStage"`
192+
PayloadStatus PayloadStatusV1 `json:"payloadStatus"`
193+
Payload *ExecutionPayloadEnvelope `json:"payload"`
194+
}
195+
184196
func encodeTransactions(txs []*types.Transaction) [][]byte {
185197
var enc = make([][]byte, len(txs))
186198
for i, tx := range txs {

cmd/geth/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
219219
cfg.Eth.OverrideVerkle = &v
220220
}
221221

222+
if ctx.Bool(utils.MiningEnabledFlag.Name) {
223+
cfg.Eth.TxPool.EnableCache = true
224+
}
225+
222226
backend, eth := utils.RegisterEthService(stack, &cfg.Eth)
223227

224228
// Create gauge with geth system and build information

cmd/geth/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ var (
7979
utils.TxPoolRejournalFlag,
8080
utils.TxPoolPriceLimitFlag,
8181
utils.TxPoolPriceBumpFlag,
82+
utils.TxPoolEnableAsyncPricedFlag,
8283
utils.TxPoolAccountSlotsFlag,
8384
utils.TxPoolGlobalSlotsFlag,
8485
utils.TxPoolAccountQueueFlag,

cmd/utils/flags.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,12 @@ var (
410410
Value: ethconfig.Defaults.TxPool.PriceBump,
411411
Category: flags.TxPoolCategory,
412412
}
413+
TxPoolEnableAsyncPricedFlag = &cli.BoolFlag{
414+
Name: "txpool.asyncpriced",
415+
Usage: "enable async-priced-sorted list for txpool",
416+
Value: false,
417+
Category: flags.TxPoolCategory,
418+
}
413419
TxPoolAccountSlotsFlag = &cli.Uint64Flag{
414420
Name: "txpool.accountslots",
415421
Usage: "Minimum number of executable transaction slots guaranteed per account",
@@ -1723,6 +1729,9 @@ func setTxPool(ctx *cli.Context, cfg *legacypool.Config) {
17231729
if ctx.IsSet(TxPoolPriceBumpFlag.Name) {
17241730
cfg.PriceBump = ctx.Uint64(TxPoolPriceBumpFlag.Name)
17251731
}
1732+
if ctx.IsSet(TxPoolEnableAsyncPricedFlag.Name) {
1733+
cfg.EnableAsyncPriced = ctx.Bool(TxPoolEnableAsyncPricedFlag.Name)
1734+
}
17261735
if ctx.IsSet(TxPoolAccountSlotsFlag.Name) {
17271736
cfg.AccountSlots = ctx.Uint64(TxPoolAccountSlotsFlag.Name)
17281737
}

consensus/beacon/consensus.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,17 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
399399
// Finalize and assemble the block.
400400
beacon.Finalize(chain, header, state, txs, uncles, withdrawals)
401401

402-
// Assign the final state root to header.
403-
header.Root = state.IntermediateRoot(true)
402+
rootCh := make(chan common.Hash)
403+
go func() {
404+
rootCh <- state.IntermediateRoot(true)
405+
}()
406+
407+
block := types.NewBlockWithWithdrawals(header, txs, uncles, receipts, withdrawals, trie.NewStackTrie(nil))
408+
headerWithRoot := block.Header()
409+
headerWithRoot.Root = <-rootCh
404410

405411
// Assemble and return the final block.
406-
return types.NewBlockWithWithdrawals(header, txs, uncles, receipts, withdrawals, trie.NewStackTrie(nil)), nil
412+
return block.WithSeal(headerWithRoot), nil
407413
}
408414

409415
// Seal generates a new sealing request for the given input block and pushes

core/block_validator.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
162162

163163
// ValidateState validates the various changes that happen after a state transition,
164164
// such as amount of used gas, the receipt roots and the state root itself.
165-
func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateDB, receipts types.Receipts, usedGas uint64) error {
165+
func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateDB, receipts types.Receipts, usedGas uint64, skipRoot bool) error {
166166
header := block.Header()
167167
if block.GasUsed() != usedGas {
168168
return fmt.Errorf("invalid gas used (remote: %d local: %d)", block.GasUsed(), usedGas)
@@ -186,14 +186,16 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
186186
}
187187
return nil
188188
},
189-
func() error {
189+
}
190+
if !skipRoot {
191+
validateFuns = append(validateFuns, func() error {
190192
// Validate the state root against the received state root and throw
191193
// an error if they don't match.
192194
if root := statedb.IntermediateRoot(v.config.IsEIP158(header.Number)); header.Root != root {
193195
return fmt.Errorf("invalid merkle root (remote: %x local: %x) dberr: %w", header.Root, root, statedb.Error())
194196
}
195197
return nil
196-
},
198+
})
197199
}
198200
validateRes := make(chan error, len(validateFuns))
199201
for _, f := range validateFuns {

0 commit comments

Comments
 (0)