Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed10dfa6bf | ||
|
|
3da36e6a55 | ||
|
|
c2feabad39 | ||
|
|
b0fcc0a663 | ||
|
|
58a91af56c | ||
|
|
cca7667dcd | ||
|
|
1a50838431 | ||
|
|
d52d8a5f05 | ||
|
|
935c9e3c6a | ||
|
|
cb1afd2b14 | ||
|
|
7bd1c1f23d |
@@ -1,5 +1,14 @@
|
||||
# Changelog
|
||||
|
||||
## v1.0.4
|
||||
|
||||
IMPROVEMENT
|
||||
* [\#35](https://github.com/binance-chain/bsc/pull/35) use fixed gas price when network is idle
|
||||
* [\#38](https://github.com/binance-chain/bsc/pull/38) disable noisy log from consensus engine
|
||||
* [\#47](https://github.com/binance-chain/bsc/pull/47) upgrade to golang1.15.5
|
||||
* [\#49](https://github.com/binance-chain/bsc/pull/49) Create pull request template for all developer to follow
|
||||
|
||||
|
||||
## v1.0.3
|
||||
|
||||
IMPROVEMENT
|
||||
|
||||
11
Dockerfile
11
Dockerfile
@@ -1,7 +1,12 @@
|
||||
# Build Geth in a stock Go builder container
|
||||
FROM golang:1.14-alpine as builder
|
||||
FROM golang:1.15-alpine as builder
|
||||
|
||||
RUN apk add --no-cache make gcc musl-dev linux-headers git
|
||||
RUN apk add --no-cache make gcc musl-dev linux-headers git bash
|
||||
|
||||
# Temporarily pull a custom Go bundle
|
||||
ADD https://golang.org/dl/go1.15.5.src.tar.gz /tmp/go.tar.gz
|
||||
RUN (cd /tmp && tar -xf go.tar.gz)
|
||||
RUN (cd /tmp/go/src && ./make.bash)
|
||||
ENV PATH="/tmp/go/bin:${PATH}"
|
||||
|
||||
ADD . /go-ethereum
|
||||
RUN cd /go-ethereum && make geth
|
||||
|
||||
31
PULL_REQUEST_TEMPLATE
Normal file
31
PULL_REQUEST_TEMPLATE
Normal file
@@ -0,0 +1,31 @@
|
||||
### Description
|
||||
|
||||
add a description of your changes here...
|
||||
|
||||
### Rationale
|
||||
|
||||
tell us why we need these changes...
|
||||
|
||||
### Example
|
||||
|
||||
add an example CLI or API response...
|
||||
|
||||
### Changes
|
||||
|
||||
Notable changes:
|
||||
* add each change in a bullet point here
|
||||
* ...
|
||||
|
||||
### Preflight checks
|
||||
|
||||
- [ ] build passed (`make build`)
|
||||
- [ ] tests passed (`make test`)
|
||||
- [ ] manual transaction test passed
|
||||
|
||||
### Already reviewed by
|
||||
|
||||
...
|
||||
|
||||
### Related issues
|
||||
|
||||
... reference related issue #'s here ...
|
||||
@@ -680,7 +680,7 @@ func (p *Parlia) Finalize(chain consensus.ChainReader, header *types.Header, sta
|
||||
}
|
||||
}
|
||||
if !signedRecently {
|
||||
log.Info("slash validator", "block hash", header.Hash(), "address", spoiledVal)
|
||||
log.Trace("slash validator", "block hash", header.Hash(), "address", spoiledVal)
|
||||
err = p.slash(spoiledVal, state, header, cx, txs, receipts, systemTxs, usedGas, false)
|
||||
if err != nil {
|
||||
// it is possible that slash validator failed because of the slash channel is disabled.
|
||||
@@ -947,11 +947,11 @@ func (p *Parlia) distributeIncoming(val common.Address, state *state.StateDB, he
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Info("distribute to system reward pool", "block hash", header.Hash(), "amount", rewards)
|
||||
log.Trace("distribute to system reward pool", "block hash", header.Hash(), "amount", rewards)
|
||||
balance = balance.Sub(balance, rewards)
|
||||
}
|
||||
}
|
||||
log.Info("distribute to validator contract", "block hash", header.Hash(), "amount", balance)
|
||||
log.Trace("distribute to validator contract", "block hash", header.Hash(), "amount", balance)
|
||||
return p.distributeToValidator(balance, val, state, header, chain, txs, receipts, receivedTxs, usedGas, mining)
|
||||
}
|
||||
|
||||
@@ -999,7 +999,7 @@ func (p *Parlia) initContract(state *state.StateDB, header *types.Header, chain
|
||||
for _, c := range contracts {
|
||||
msg := p.getSystemMessage(header.Coinbase, common.HexToAddress(c), data, common.Big0)
|
||||
// apply message
|
||||
log.Info("init contract", "block hash", header.Hash(), "contract", c)
|
||||
log.Trace("init contract", "block hash", header.Hash(), "contract", c)
|
||||
err = p.applyTransaction(msg, state, header, chain, txs, receipts, receivedTxs, usedGas, mining)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -61,8 +61,9 @@ var DefaultConfig = Config{
|
||||
},
|
||||
TxPool: core.DefaultTxPoolConfig,
|
||||
GPO: gasprice.Config{
|
||||
Blocks: 20,
|
||||
Percentile: 60,
|
||||
Blocks: 20,
|
||||
Percentile: 60,
|
||||
OracleThreshold: 1000,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,10 @@ import (
|
||||
var maxPrice = big.NewInt(500 * params.GWei)
|
||||
|
||||
type Config struct {
|
||||
Blocks int
|
||||
Percentile int
|
||||
Default *big.Int `toml:",omitempty"`
|
||||
Blocks int
|
||||
Percentile int
|
||||
Default *big.Int `toml:",omitempty"`
|
||||
OracleThreshold int `toml:",omitempty"`
|
||||
}
|
||||
|
||||
// Oracle recommends gas prices based on the content of recent
|
||||
@@ -46,6 +47,9 @@ type Oracle struct {
|
||||
cacheLock sync.RWMutex
|
||||
fetchLock sync.Mutex
|
||||
|
||||
defaultPrice *big.Int
|
||||
sampleTxThreshold int
|
||||
|
||||
checkBlocks, maxEmpty, maxBlocks int
|
||||
percentile int
|
||||
}
|
||||
@@ -64,12 +68,14 @@ func NewOracle(backend ethapi.Backend, params Config) *Oracle {
|
||||
percent = 100
|
||||
}
|
||||
return &Oracle{
|
||||
backend: backend,
|
||||
lastPrice: params.Default,
|
||||
checkBlocks: blocks,
|
||||
maxEmpty: blocks / 2,
|
||||
maxBlocks: blocks * 5,
|
||||
percentile: percent,
|
||||
backend: backend,
|
||||
lastPrice: params.Default,
|
||||
defaultPrice: params.Default,
|
||||
checkBlocks: blocks,
|
||||
maxEmpty: blocks / 2,
|
||||
maxBlocks: blocks * 5,
|
||||
percentile: percent,
|
||||
sampleTxThreshold: params.OracleThreshold,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +109,7 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
|
||||
sent := 0
|
||||
exp := 0
|
||||
var blockPrices []*big.Int
|
||||
var totalTxSamples int
|
||||
for sent < gpo.checkBlocks && blockNum > 0 {
|
||||
go gpo.getBlockPrices(ctx, types.MakeSigner(gpo.backend.ChainConfig(), big.NewInt(int64(blockNum))), blockNum, ch)
|
||||
sent++
|
||||
@@ -118,6 +125,7 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
|
||||
exp--
|
||||
if res.price != nil {
|
||||
blockPrices = append(blockPrices, res.price)
|
||||
totalTxSamples = totalTxSamples + res.number
|
||||
continue
|
||||
}
|
||||
if maxEmpty > 0 {
|
||||
@@ -132,9 +140,11 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
|
||||
}
|
||||
}
|
||||
price := lastPrice
|
||||
if len(blockPrices) > 0 {
|
||||
if len(blockPrices) > 0 && totalTxSamples > gpo.sampleTxThreshold {
|
||||
sort.Sort(bigIntArray(blockPrices))
|
||||
price = blockPrices[(len(blockPrices)-1)*gpo.percentile/100]
|
||||
} else {
|
||||
price = gpo.defaultPrice
|
||||
}
|
||||
if price.Cmp(maxPrice) > 0 {
|
||||
price = new(big.Int).Set(maxPrice)
|
||||
@@ -148,8 +158,9 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
|
||||
}
|
||||
|
||||
type getBlockPricesResult struct {
|
||||
price *big.Int
|
||||
err error
|
||||
number int
|
||||
price *big.Int
|
||||
err error
|
||||
}
|
||||
|
||||
type transactionsByGasPrice []*types.Transaction
|
||||
@@ -163,7 +174,7 @@ func (t transactionsByGasPrice) Less(i, j int) bool { return t[i].GasPrice().Cmp
|
||||
func (gpo *Oracle) getBlockPrices(ctx context.Context, signer types.Signer, blockNum uint64, ch chan getBlockPricesResult) {
|
||||
block, err := gpo.backend.BlockByNumber(ctx, rpc.BlockNumber(blockNum))
|
||||
if block == nil {
|
||||
ch <- getBlockPricesResult{nil, err}
|
||||
ch <- getBlockPricesResult{0, nil, err}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -175,11 +186,11 @@ func (gpo *Oracle) getBlockPrices(ctx context.Context, signer types.Signer, bloc
|
||||
for _, tx := range txs {
|
||||
sender, err := types.Sender(signer, tx)
|
||||
if err == nil && sender != block.Coinbase() {
|
||||
ch <- getBlockPricesResult{tx.GasPrice(), nil}
|
||||
ch <- getBlockPricesResult{len(txs), tx.GasPrice(), nil}
|
||||
return
|
||||
}
|
||||
}
|
||||
ch <- getBlockPricesResult{nil, nil}
|
||||
ch <- getBlockPricesResult{0, nil, nil}
|
||||
}
|
||||
|
||||
type bigIntArray []*big.Int
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,6 +1,6 @@
|
||||
module github.com/ethereum/go-ethereum
|
||||
|
||||
go 1.13
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-pipeline-go v0.2.2 // indirect
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
const (
|
||||
VersionMajor = 1 // Major version component of the current release
|
||||
VersionMinor = 0 // Minor version component of the current release
|
||||
VersionPatch = 3 // Patch version component of the current release
|
||||
VersionPatch = 4 // Patch version component of the current release
|
||||
VersionMeta = "" // Version metadata to append to the version string
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user