Compare commits
8 Commits
v1.1.1-bet
...
v1.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03f7b318d9 | ||
|
|
a3320d6f6e | ||
|
|
504424dc7c | ||
|
|
8d5f2ba90d | ||
|
|
29707b9252 | ||
|
|
6fcce0dce9 | ||
|
|
955c78bde0 | ||
|
|
3bd4e29954 |
26
CHANGELOG.md
26
CHANGELOG.md
@@ -1,17 +1,29 @@
|
||||
# Changelog
|
||||
|
||||
## v1.1.1
|
||||
IMPROVEMENT
|
||||
* [\#355](https://github.com/binance-chain/bsc/pull/355) miner should propose block on a proper fork
|
||||
|
||||
BUGFIX
|
||||
* [\#350](https://github.com/binance-chain/bsc/pull/350) flag: fix TriesInmemory specified but not work
|
||||
* [\#358](https://github.com/binance-chain/bsc/pull/358) miner: fix null pending block
|
||||
* [\#360](https://github.com/binance-chain/bsc/pull/360) pruner: fix state bloom sync permission in Windows
|
||||
* [\#366](https://github.com/binance-chain/bsc/pull/366) fix double close channel of subfetcher
|
||||
|
||||
|
||||
## v1.1.1-beta
|
||||
*[\#333](https://github.com/binance-chain/bsc/pull/333) improve block fetcher efficiency
|
||||
*[\#326](https://github.com/binance-chain/bsc/pull/326) eth/tracers: improve tracing performance
|
||||
*[\#257](https://github.com/binance-chain/bsc/pull/257) performance improvement in many aspects
|
||||
* [\#333](https://github.com/binance-chain/bsc/pull/333) improve block fetcher efficiency
|
||||
* [\#326](https://github.com/binance-chain/bsc/pull/326) eth/tracers: improve tracing performance
|
||||
* [\#257](https://github.com/binance-chain/bsc/pull/257) performance improvement in many aspects
|
||||
|
||||
|
||||
## v1.1.0
|
||||
*[\#282](https://github.com/binance-chain/bsc/pull/282) update discord link
|
||||
*[\#280](https://github.com/binance-chain/bsc/pull/280) update discord link
|
||||
*[\#227](https://github.com/binance-chain/bsc/pull/227) use more aggressive write cache policy
|
||||
* [\#282](https://github.com/binance-chain/bsc/pull/282) update discord link
|
||||
* [\#280](https://github.com/binance-chain/bsc/pull/280) update discord link
|
||||
* [\#227](https://github.com/binance-chain/bsc/pull/227) use more aggressive write cache policy
|
||||
|
||||
## v1.1.0-beta
|
||||
*[\#152](https://github.com/binance-chain/bsc/pull/152) upgrade to go-ethereum 1.10.3
|
||||
* [\#152](https://github.com/binance-chain/bsc/pull/152) upgrade to go-ethereum 1.10.3
|
||||
|
||||
## v1.0.7-hf.2
|
||||
BUGFIX
|
||||
|
||||
@@ -1598,6 +1598,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||
if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheGCFlag.Name) {
|
||||
cfg.TrieDirtyCache = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100
|
||||
}
|
||||
if ctx.GlobalIsSet(TriesInMemoryFlag.Name) {
|
||||
cfg.TriesInMemory = ctx.GlobalUint64(TriesInMemoryFlag.Name)
|
||||
}
|
||||
if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheSnapshotFlag.Name) {
|
||||
cfg.SnapshotCache = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheSnapshotFlag.Name) / 100
|
||||
}
|
||||
@@ -1924,6 +1927,9 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
|
||||
if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheGCFlag.Name) {
|
||||
cache.TrieDirtyLimit = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100
|
||||
}
|
||||
if ctx.GlobalIsSet(TriesInMemoryFlag.Name) {
|
||||
cache.TriesInMemory = ctx.GlobalUint64(TriesInMemoryFlag.Name)
|
||||
}
|
||||
vmcfg := vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)}
|
||||
|
||||
// TODO(rjl493456442) disable snapshot generation/wiping if the chain is read only.
|
||||
|
||||
@@ -140,4 +140,5 @@ type PoSA interface {
|
||||
IsSystemTransaction(tx *types.Transaction, header *types.Header) (bool, error)
|
||||
IsSystemContract(to *common.Address) bool
|
||||
EnoughDistance(chain ChainReader, header *types.Header) bool
|
||||
IsLocalBlock(header *types.Header) bool
|
||||
}
|
||||
|
||||
@@ -882,6 +882,34 @@ func (p *Parlia) EnoughDistance(chain consensus.ChainReader, header *types.Heade
|
||||
return snap.enoughDistance(p.val, header)
|
||||
}
|
||||
|
||||
func (p *Parlia) IsLocalBlock(header *types.Header) bool {
|
||||
return p.val == header.Coinbase
|
||||
}
|
||||
|
||||
func (p *Parlia) SignRecently(chain consensus.ChainReader, parent *types.Header) (bool, error) {
|
||||
snap, err := p.snapshot(chain, parent.Number.Uint64(), parent.ParentHash, nil)
|
||||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
// Bail out if we're unauthorized to sign a block
|
||||
if _, authorized := snap.Validators[p.val]; !authorized {
|
||||
return true, errUnauthorizedValidator
|
||||
}
|
||||
|
||||
// If we're amongst the recent signers, wait for the next block
|
||||
number := parent.Number.Uint64() + 1
|
||||
for seen, recent := range snap.Recents {
|
||||
if recent == p.val {
|
||||
// Signer is among recents, only wait if the current block doesn't shift it out
|
||||
if limit := uint64(len(snap.Validators)/2 + 1); number < limit || seen > number-limit {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty
|
||||
// that a new block should have based on the previous blocks in the chain and the
|
||||
// current signer.
|
||||
|
||||
@@ -217,6 +217,9 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
|
||||
if cacheConfig == nil {
|
||||
cacheConfig = defaultCacheConfig
|
||||
}
|
||||
if cacheConfig.TriesInMemory != 128 {
|
||||
log.Warn("TriesInMemory isn't the default value(128), you need specify exact same TriesInMemory when prune data", "triesInMemory", cacheConfig.TriesInMemory)
|
||||
}
|
||||
bodyCache, _ := lru.New(bodyCacheLimit)
|
||||
bodyRLPCache, _ := lru.New(bodyCacheLimit)
|
||||
receiptsCache, _ := lru.New(receiptsCacheLimit)
|
||||
@@ -1578,7 +1581,9 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
|
||||
if !reorg && externTd.Cmp(localTd) == 0 {
|
||||
// Split same-difficulty blocks by number, then preferentially select
|
||||
// the block generated by the local miner as the canonical block.
|
||||
if block.NumberU64() < currentBlock.NumberU64() {
|
||||
if block.NumberU64() < currentBlock.NumberU64() || block.Time() < currentBlock.Time() {
|
||||
reorg = true
|
||||
} else if p, ok := bc.engine.(consensus.PoSA); ok && p.IsLocalBlock(currentBlock.Header()) {
|
||||
reorg = true
|
||||
} else if block.NumberU64() == currentBlock.NumberU64() {
|
||||
var currentPreserve, blockPreserve bool
|
||||
|
||||
@@ -90,7 +90,7 @@ func (bloom *stateBloom) Commit(filename, tempname string) error {
|
||||
return err
|
||||
}
|
||||
// Ensure the file is synced to disk
|
||||
f, err := os.Open(tempname)
|
||||
f, err := os.OpenFile(tempname, os.O_RDWR, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
)
|
||||
|
||||
const abortChanSize = 64
|
||||
|
||||
var (
|
||||
// triePrefetchMetricsPrefix is the prefix under which to publis the metrics.
|
||||
triePrefetchMetricsPrefix = "trie/prefetch/"
|
||||
@@ -41,6 +43,9 @@ type triePrefetcher struct {
|
||||
fetches map[common.Hash]Trie // Partially or fully fetcher tries
|
||||
fetchers map[common.Hash]*subfetcher // Subfetchers for each trie
|
||||
|
||||
abortChan chan *subfetcher
|
||||
closeChan chan struct{}
|
||||
|
||||
deliveryMissMeter metrics.Meter
|
||||
accountLoadMeter metrics.Meter
|
||||
accountDupMeter metrics.Meter
|
||||
@@ -56,9 +61,11 @@ type triePrefetcher struct {
|
||||
func newTriePrefetcher(db Database, root common.Hash, namespace string) *triePrefetcher {
|
||||
prefix := triePrefetchMetricsPrefix + namespace
|
||||
p := &triePrefetcher{
|
||||
db: db,
|
||||
root: root,
|
||||
fetchers: make(map[common.Hash]*subfetcher), // Active prefetchers use the fetchers map
|
||||
db: db,
|
||||
root: root,
|
||||
fetchers: make(map[common.Hash]*subfetcher), // Active prefetchers use the fetchers map
|
||||
abortChan: make(chan *subfetcher, abortChanSize),
|
||||
closeChan: make(chan struct{}),
|
||||
|
||||
deliveryMissMeter: metrics.GetOrRegisterMeter(prefix+"/deliverymiss", nil),
|
||||
accountLoadMeter: metrics.GetOrRegisterMeter(prefix+"/account/load", nil),
|
||||
@@ -70,14 +77,34 @@ func newTriePrefetcher(db Database, root common.Hash, namespace string) *triePre
|
||||
storageSkipMeter: metrics.GetOrRegisterMeter(prefix+"/storage/skip", nil),
|
||||
storageWasteMeter: metrics.GetOrRegisterMeter(prefix+"/storage/waste", nil),
|
||||
}
|
||||
go p.abortLoop()
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *triePrefetcher) abortLoop() {
|
||||
for {
|
||||
select {
|
||||
case fetcher := <-p.abortChan:
|
||||
fetcher.abort()
|
||||
case <-p.closeChan:
|
||||
// drain fetcher channel
|
||||
for {
|
||||
select {
|
||||
case fetcher := <-p.abortChan:
|
||||
fetcher.abort()
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// close iterates over all the subfetchers, aborts any that were left spinning
|
||||
// and reports the stats to the metrics subsystem.
|
||||
func (p *triePrefetcher) close() {
|
||||
for _, fetcher := range p.fetchers {
|
||||
fetcher.abort() // safe to do multiple times
|
||||
p.abortChan <- fetcher // safe to do multiple times
|
||||
|
||||
if metrics.Enabled {
|
||||
if fetcher.root == p.root {
|
||||
@@ -101,6 +128,7 @@ func (p *triePrefetcher) close() {
|
||||
}
|
||||
}
|
||||
}
|
||||
close(p.closeChan)
|
||||
// Clear out all fetchers (will crash on a second call, deliberate)
|
||||
p.fetchers = nil
|
||||
}
|
||||
@@ -174,7 +202,7 @@ func (p *triePrefetcher) trie(root common.Hash) Trie {
|
||||
}
|
||||
// Interrupt the prefetcher if it's by any chance still running and return
|
||||
// a copy of any pre-loaded trie.
|
||||
fetcher.abort() // safe to do multiple times
|
||||
p.abortChan <- fetcher // safe to do multiple times
|
||||
|
||||
trie := fetcher.peek()
|
||||
if trie == nil {
|
||||
|
||||
@@ -184,19 +184,21 @@ func (miner *Miner) SetRecommitInterval(interval time.Duration) {
|
||||
// Pending returns the currently pending block and associated state.
|
||||
func (miner *Miner) Pending() (*types.Block, *state.StateDB) {
|
||||
if miner.worker.isRunning() {
|
||||
return miner.worker.pending()
|
||||
} else {
|
||||
// fallback to latest block
|
||||
block := miner.worker.chain.CurrentBlock()
|
||||
if block == nil {
|
||||
return nil, nil
|
||||
pendingBlock, pendingState := miner.worker.pending()
|
||||
if pendingState != nil && pendingBlock != nil {
|
||||
return pendingBlock, pendingState
|
||||
}
|
||||
stateDb, err := miner.worker.chain.StateAt(block.Root())
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
return block, stateDb
|
||||
}
|
||||
// fallback to latest block
|
||||
block := miner.worker.chain.CurrentBlock()
|
||||
if block == nil {
|
||||
return nil, nil
|
||||
}
|
||||
stateDb, err := miner.worker.chain.StateAt(block.Root())
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
return block, stateDb
|
||||
}
|
||||
|
||||
// PendingBlock returns the currently pending block.
|
||||
@@ -206,11 +208,13 @@ func (miner *Miner) Pending() (*types.Block, *state.StateDB) {
|
||||
// change between multiple method calls
|
||||
func (miner *Miner) PendingBlock() *types.Block {
|
||||
if miner.worker.isRunning() {
|
||||
return miner.worker.pendingBlock()
|
||||
} else {
|
||||
// fallback to latest block
|
||||
return miner.worker.chain.CurrentBlock()
|
||||
pendingBlock := miner.worker.pendingBlock()
|
||||
if pendingBlock != nil {
|
||||
return pendingBlock
|
||||
}
|
||||
}
|
||||
// fallback to latest block
|
||||
return miner.worker.chain.CurrentBlock()
|
||||
}
|
||||
|
||||
func (miner *Miner) SetEtherbase(addr common.Address) {
|
||||
|
||||
@@ -389,6 +389,17 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
|
||||
}
|
||||
clearPending(head.Block.NumberU64())
|
||||
timestamp = time.Now().Unix()
|
||||
if p, ok := w.engine.(*parlia.Parlia); ok {
|
||||
signedRecent, err := p.SignRecently(w.chain, head.Block.Header())
|
||||
if err != nil {
|
||||
log.Info("Not allowed to propose block", "err", err)
|
||||
continue
|
||||
}
|
||||
if signedRecent {
|
||||
log.Info("Signed recently, must wait")
|
||||
continue
|
||||
}
|
||||
}
|
||||
commit(true, commitInterruptNewHead)
|
||||
|
||||
case <-timer.C:
|
||||
|
||||
@@ -21,10 +21,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
VersionMajor = 1 // Major version component of the current release
|
||||
VersionMinor = 1 // Minor version component of the current release
|
||||
VersionPatch = 1 // Patch version component of the current release
|
||||
VersionMeta = "beta" // Version metadata to append to the version string
|
||||
VersionMajor = 1 // Major version component of the current release
|
||||
VersionMinor = 1 // Minor version component of the current release
|
||||
VersionPatch = 1 // Patch version component of the current release
|
||||
VersionMeta = "" // Version metadata to append to the version string
|
||||
)
|
||||
|
||||
// Version holds the textual version string.
|
||||
|
||||
Reference in New Issue
Block a user