Skip to content

Commit 0ca4bc1

Browse files
committed
Merge branch 'develop' into separate-node
2 parents 6fffa8e + fed2f35 commit 0ca4bc1

Some content is hidden

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

46 files changed

+909
-421
lines changed

.github/release.env

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
MAINNET_FILE_URL="https://github.com/binance-chain/bsc/releases/download/v1.1.6/mainnet.zip"
2-
TESTNET_FILE_URL="https://github.com/binance-chain/bsc/releases/download/v1.1.6/testnet.zip"
1+
MAINNET_FILE_URL="https://github.com/binance-chain/bsc/releases/download/v1.1.7/mainnet.zip"
2+
TESTNET_FILE_URL="https://github.com/binance-chain/bsc/releases/download/v1.1.7/testnet.zip"

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## v1.1.8
4+
FEATURES
5+
* [\#668](https://github.com/binance-chain/bsc/pull/668) implement State Verification && Snapshot Commit pipeline
6+
* [\#581](https://github.com/binance-chain/bsc/pull/581) implement geth native trace
7+
* [\#543](https://github.com/binance-chain/bsc/pull/543) implement offline block prune tools
8+
9+
IMPROVEMENT
10+
* [\#704](https://github.com/binance-chain/bsc/pull/704) prefetch state by applying the transactions within one block
11+
* [\#713](https://github.com/binance-chain/bsc/pull/713) add ARM binaries for release pipeline
12+
13+
BUGFIX
14+
* [\#667](https://github.com/binance-chain/bsc/pull/667) trie: reject deletions when verifying range proofs #667
15+
* [\#643](https://github.com/binance-chain/bsc/pull/643) add timeout for stopping p2p server to fix can not gracefully shutdown issue
16+
* [\#740](https://github.com/binance-chain/bsc/pull/740) update discord link which won't expire
17+
318
## v1.1.7
419

520
BUGFIX

PULL_REQUEST_TEMPLATE

-14
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,3 @@ add an example CLI or API response...
1515
Notable changes:
1616
* add each change in a bullet point here
1717
* ...
18-
19-
### Preflight checks
20-
21-
- [ ] build passed (`make build`)
22-
- [ ] tests passed (`make test`)
23-
- [ ] manual transaction test passed
24-
25-
### Already reviewed by
26-
27-
...
28-
29-
### Related issues
30-
31-
... reference related issue #'s here ...

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Binance Smart Chain starts its development based on go-ethereum fork. So you may
77
[![API Reference](
88
https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667
99
)](https://pkg.go.dev/github.com/ethereum/go-ethereum?tab=doc)
10-
[![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.gg/5Z3C3SdxDw)
10+
[![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.gg/z2VpC455eU)
1111

1212
But from that baseline of EVM compatible, Binance Smart Chain introduces a system of 21 validators with Proof of Staked Authority (PoSA) consensus that can support short block time and lower fees. The most bonded validator candidates of staking will become validators and produce blocks. The double-sign detection and other slashing logic guarantee security, stability, and chain finality.
1313

@@ -203,7 +203,7 @@ from anyone on the internet, and are grateful for even the smallest of fixes!
203203

204204
If you'd like to contribute to bsc, please fork, fix, commit and send a pull request
205205
for the maintainers to review and merge into the main code base. If you wish to submit
206-
more complex changes though, please check up with the core devs first on [our discord channel](https://discord.gg/5Z3C3SdxDw)
206+
more complex changes though, please check up with the core devs first on [our discord channel](https://discord.gg/z2VpC455eU)
207207
to ensure those changes are in line with the general philosophy of the project and/or get
208208
some early feedback which can make both your efforts much lighter as well as our review
209209
and merge procedures quick and simple.

cmd/evm/internal/t8ntool/execution.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
223223
statedb.AddBalance(pre.Env.Coinbase, minerReward)
224224
}
225225
// Commit block
226-
root, _, err := statedb.Commit(chainConfig.IsEIP158(vmContext.BlockNumber))
226+
statedb.Finalise(chainConfig.IsEIP158(vmContext.BlockNumber))
227+
statedb.AccountsIntermediateRoot()
228+
root, _, err := statedb.Commit(nil)
227229
if err != nil {
228230
fmt.Fprintf(os.Stderr, "Could not commit state: %v", err)
229231
return nil, nil, NewError(ErrorEVM, fmt.Errorf("could not commit state: %v", err))
@@ -252,7 +254,9 @@ func MakePreState(db ethdb.Database, accounts core.GenesisAlloc) *state.StateDB
252254
}
253255
}
254256
// Commit and re-open to start with a clean state.
255-
root, _, _ := statedb.Commit(false)
257+
statedb.Finalise(false)
258+
statedb.AccountsIntermediateRoot()
259+
root, _, _ := statedb.Commit(nil)
256260
statedb, _ = state.New(root, sdb, nil)
257261
return statedb
258262
}

cmd/evm/runner.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ func runCmd(ctx *cli.Context) error {
268268
output, leftOverGas, stats, err := timedExec(bench, execFunc)
269269

270270
if ctx.GlobalBool(DumpFlag.Name) {
271-
statedb.Commit(true)
271+
statedb.Finalise(true)
272+
statedb.AccountsIntermediateRoot()
273+
statedb.Commit(nil)
272274
statedb.IntermediateRoot(true)
273275
fmt.Println(string(statedb.Dump(false, false, true)))
274276
}

cmd/evm/staterunner.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ func stateTestCmd(ctx *cli.Context) error {
101101
_, state, err := test.Run(st, cfg, false)
102102
// print state root for evmlab tracing
103103
if ctx.GlobalBool(MachineFlag.Name) && state != nil {
104-
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%x\"}\n", state.IntermediateRoot(false))
104+
root := state.IntermediateRoot(false)
105+
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%x\"}\n", root)
105106
}
106107
if err != nil {
107108
// Test failed, mark as so and dump any state to aid debugging

cmd/geth/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ var (
7272
utils.DirectBroadcastFlag,
7373
utils.DisableSnapProtocolFlag,
7474
utils.DiffSyncFlag,
75+
utils.PipeCommitFlag,
7576
utils.RangeLimitFlag,
7677
utils.USBFlag,
7778
utils.SmartCardDaemonPathFlag,

cmd/utils/flags.go

+7
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ var (
127127
Usage: "Enable diffy sync, Please note that enable diffsync will improve the syncing speed, " +
128128
"but will degrade the security to light client level",
129129
}
130+
PipeCommitFlag = cli.BoolFlag{
131+
Name: "pipecommit",
132+
Usage: "Enable MPT pipeline commit, it will improve syncing performance. It is an experimental feature(default is false)",
133+
}
130134
RangeLimitFlag = cli.BoolFlag{
131135
Name: "rangelimit",
132136
Usage: "Enable 5000 blocks limit for range query",
@@ -1636,6 +1640,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
16361640
if ctx.GlobalIsSet(DiffSyncFlag.Name) {
16371641
cfg.DiffSync = ctx.GlobalBool(DiffSyncFlag.Name)
16381642
}
1643+
if ctx.GlobalIsSet(PipeCommitFlag.Name) {
1644+
cfg.PipeCommit = ctx.GlobalBool(PipeCommitFlag.Name)
1645+
}
16391646
if ctx.GlobalIsSet(RangeLimitFlag.Name) {
16401647
cfg.RangeLimit = ctx.GlobalBool(RangeLimitFlag.Name)
16411648
}

consensus/clique/clique.go

+4
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,11 @@ func (c *Clique) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
560560
func (c *Clique) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB,
561561
txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, []*types.Receipt, error) {
562562
// No block rewards in PoA, so the state remains as is and uncles are dropped
563+
var err error
563564
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
565+
if err != nil {
566+
return nil, nil, err
567+
}
564568
header.UncleHash = types.CalcUncleHash(nil)
565569

566570
// Assemble and return the final block for sealing

core/block_validator.go

+22-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package core
1818

1919
import (
2020
"fmt"
21+
"time"
2122

2223
"github.com/ethereum/go-ethereum/consensus"
2324
"github.com/ethereum/go-ethereum/core/state"
@@ -26,6 +27,8 @@ import (
2627
"github.com/ethereum/go-ethereum/trie"
2728
)
2829

30+
const badBlockCacheExpire = 30 * time.Second
31+
2932
// BlockValidator is responsible for validating block headers, uncles and
3033
// processed state.
3134
//
@@ -54,6 +57,9 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
5457
if v.bc.HasBlockAndState(block.Hash(), block.NumberU64()) {
5558
return ErrKnownBlock
5659
}
60+
if v.bc.isCachedBadBlock(block) {
61+
return ErrKnownBadBlock
62+
}
5763
// Header validity is known at this point, check the uncles and transactions
5864
header := block.Header()
5965
if err := v.engine.VerifyUncles(v.bc, block); err != nil {
@@ -100,7 +106,7 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
100106
// transition, such as amount of used gas, the receipt roots and the state root
101107
// itself. ValidateState returns a database batch if the validation was a success
102108
// otherwise nil and an error is returned.
103-
func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateDB, receipts types.Receipts, usedGas uint64) error {
109+
func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateDB, receipts types.Receipts, usedGas uint64, skipHeavyVerify bool) error {
104110
header := block.Header()
105111
if block.GasUsed() != usedGas {
106112
return fmt.Errorf("invalid gas used (remote: %d local: %d)", block.GasUsed(), usedGas)
@@ -119,17 +125,26 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
119125
receiptSha := types.DeriveSha(receipts, trie.NewStackTrie(nil))
120126
if receiptSha != header.ReceiptHash {
121127
return fmt.Errorf("invalid receipt root hash (remote: %x local: %x)", header.ReceiptHash, receiptSha)
122-
} else {
123-
return nil
124128
}
129+
return nil
125130
},
126-
func() error {
131+
}
132+
if skipHeavyVerify {
133+
validateFuns = append(validateFuns, func() error {
134+
if err := statedb.WaitPipeVerification(); err != nil {
135+
return err
136+
}
137+
statedb.Finalise(v.config.IsEIP158(header.Number))
138+
statedb.AccountsIntermediateRoot()
139+
return nil
140+
})
141+
} else {
142+
validateFuns = append(validateFuns, func() error {
127143
if root := statedb.IntermediateRoot(v.config.IsEIP158(header.Number)); header.Root != root {
128144
return fmt.Errorf("invalid merkle root (remote: %x local: %x)", header.Root, root)
129-
} else {
130-
return nil
131145
}
132-
},
146+
return nil
147+
})
133148
}
134149
validateRes := make(chan error, len(validateFuns))
135150
for _, f := range validateFuns {

0 commit comments

Comments
 (0)