Compare commits
20 Commits
v1.0.1-bet
...
v1.0.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed10dfa6bf | ||
|
|
3da36e6a55 | ||
|
|
c2feabad39 | ||
|
|
b0fcc0a663 | ||
|
|
58a91af56c | ||
|
|
cca7667dcd | ||
|
|
1a50838431 | ||
|
|
d52d8a5f05 | ||
|
|
935c9e3c6a | ||
|
|
cb1afd2b14 | ||
|
|
7bd1c1f23d | ||
|
|
537c5db510 | ||
|
|
40620b478c | ||
|
|
e81c728ff6 | ||
|
|
bfb73f8068 | ||
|
|
397f6f6108 | ||
|
|
b242e890d2 | ||
|
|
ba0152fea9 | ||
|
|
844ed90c28 | ||
|
|
f94b7de003 |
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,5 +1,24 @@
|
||||
# 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
|
||||
* [\#36](https://github.com/binance-chain/bsc/pull/36) add max gas allwance calculation
|
||||
|
||||
## v1.0.2
|
||||
|
||||
IMPROVEMENT
|
||||
* [\#29](https://github.com/binance-chain/bsc/pull/29) eth/tracers: revert reason in call_tracer + error for failed internal…
|
||||
|
||||
## v1.0.1-beta
|
||||
|
||||
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 ...
|
||||
@@ -1,10 +1,3 @@
|
||||
## Disclaimer
|
||||
|
||||
**The software and related documentation are under active development,
|
||||
all subject to potential future change without notification and not ready for production use.
|
||||
The code and security audit have not been fully completed and not ready for any bug bounty.
|
||||
We advise you to be careful and experiment on the network at your own risk. Stay safe out there.**
|
||||
|
||||
## Binance Smart Chain
|
||||
|
||||
The goal of Binance Smart Chain is to bring programmability and interoperability to Binance Chain. In order to embrace the existing popular community and advanced technology, it will bring huge benefits by staying compatible with all the existing smart contracts on Ethereum and Ethereum tooling. And to achieve that, the easiest solution is to develop based on go-ethereum fork, as we respect the great work of Ethereum very much.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -63,6 +63,7 @@ var DefaultConfig = Config{
|
||||
GPO: gasprice.Config{
|
||||
Blocks: 20,
|
||||
Percentile: 60,
|
||||
OracleThreshold: 1000,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ type Config struct {
|
||||
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
|
||||
}
|
||||
@@ -66,10 +70,12 @@ func NewOracle(backend ethapi.Backend, params Config) *Oracle {
|
||||
return &Oracle{
|
||||
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,6 +158,7 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
|
||||
}
|
||||
|
||||
type getBlockPricesResult struct {
|
||||
number int
|
||||
price *big.Int
|
||||
err error
|
||||
}
|
||||
@@ -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
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -132,14 +132,13 @@
|
||||
// If the call was a contract call, retrieve the gas usage and output
|
||||
if (call.gas !== undefined) {
|
||||
call.gasUsed = '0x' + bigInt(call.gasIn - call.gasCost + call.gas - log.getGas()).toString(16);
|
||||
|
||||
}
|
||||
var ret = log.stack.peek(0);
|
||||
if (!ret.equals(0)) {
|
||||
call.output = toHex(log.memory.slice(call.outOff, call.outOff + call.outLen));
|
||||
} else if (call.error === undefined) {
|
||||
call.error = "internal failure"; // TODO(karalabe): surface these faults somehow
|
||||
}
|
||||
}
|
||||
delete call.gasIn; delete call.gasCost;
|
||||
delete call.outOff; delete call.outLen;
|
||||
}
|
||||
@@ -208,7 +207,7 @@
|
||||
} else if (ctx.error !== undefined) {
|
||||
result.error = ctx.error;
|
||||
}
|
||||
if (result.error !== undefined) {
|
||||
if (result.error !== undefined && (result.error !== "execution reverted" || result.output ==="0x")) {
|
||||
delete result.output;
|
||||
}
|
||||
return this.finalize(result);
|
||||
|
||||
72
eth/tracers/testdata/call_tracer_inner_instafail.json
vendored
Normal file
72
eth/tracers/testdata/call_tracer_inner_instafail.json
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"genesis": {
|
||||
"difficulty": "117067574",
|
||||
"extraData": "0xd783010502846765746887676f312e372e33856c696e7578",
|
||||
"gasLimit": "4712380",
|
||||
"hash": "0xe05db05eeb3f288041ecb10a787df121c0ed69499355716e17c307de313a4486",
|
||||
"miner": "0x0c062b329265c965deef1eede55183b3acb8f611",
|
||||
"mixHash": "0xb669ae39118a53d2c65fd3b1e1d3850dd3f8c6842030698ed846a2762d68b61d",
|
||||
"nonce": "0x2b469722b8e28c45",
|
||||
"number": "24973",
|
||||
"stateRoot": "0x532a5c3f75453a696428db078e32ae283c85cb97e4d8560dbdf022adac6df369",
|
||||
"timestamp": "1479891145",
|
||||
"totalDifficulty": "1892250259406",
|
||||
"alloc": {
|
||||
"0x6c06b16512b332e6cd8293a2974872674716ce18": {
|
||||
"balance": "0x0",
|
||||
"nonce": "1",
|
||||
"code": "0x60606040526000357c0100000000000000000000000000000000000000000000000000000000900480632e1a7d4d146036575b6000565b34600057604e60048080359060200190919050506050565b005b3373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051809050600060405180830381858888f19350505050505b5056",
|
||||
"storage": {}
|
||||
},
|
||||
"0x66fdfd05e46126a07465ad24e40cc0597bc1ef31": {
|
||||
"balance": "0x229ebbb36c3e0f20",
|
||||
"nonce": "3",
|
||||
"code": "0x",
|
||||
"storage": {}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"chainId": 3,
|
||||
"homesteadBlock": 0,
|
||||
"daoForkSupport": true,
|
||||
"eip150Block": 0,
|
||||
"eip150Hash": "0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d",
|
||||
"eip155Block": 10,
|
||||
"eip158Block": 10,
|
||||
"byzantiumBlock": 1700000,
|
||||
"constantinopleBlock": 4230000,
|
||||
"petersburgBlock": 4939394,
|
||||
"istanbulBlock": 6485846,
|
||||
"muirGlacierBlock": 7117117,
|
||||
"ethash": {}
|
||||
}
|
||||
},
|
||||
"context": {
|
||||
"number": "24974",
|
||||
"difficulty": "117067574",
|
||||
"timestamp": "1479891162",
|
||||
"gasLimit": "4712388",
|
||||
"miner": "0xc822ef32e6d26e170b70cf761e204c1806265914"
|
||||
},
|
||||
"input": "0xf889038504a81557008301f97e946c06b16512b332e6cd8293a2974872674716ce1880a42e1a7d4d00000000000000000000000000000000000000000000000014d1120d7b1600002aa0e2a6558040c5d72bc59f2fb62a38993a314c849cd22fb393018d2c5af3112095a01bdb6d7ba32263ccc2ecc880d38c49d9f0c5a72d8b7908e3122b31356d349745",
|
||||
"result": {
|
||||
"type": "CALL",
|
||||
"from": "0x66fdfd05e46126a07465ad24e40cc0597bc1ef31",
|
||||
"to": "0x6c06b16512b332e6cd8293a2974872674716ce18",
|
||||
"value": "0x0",
|
||||
"gas": "0x1a466",
|
||||
"gasUsed": "0x1dc6",
|
||||
"input": "0x2e1a7d4d00000000000000000000000000000000000000000000000014d1120d7b160000",
|
||||
"output": "0x",
|
||||
"calls": [
|
||||
{
|
||||
"type": "CALL",
|
||||
"from": "0x6c06b16512b332e6cd8293a2974872674716ce18",
|
||||
"to": "0x66fdfd05e46126a07465ad24e40cc0597bc1ef31",
|
||||
"value": "0x14d1120d7b160000",
|
||||
"error":"internal failure",
|
||||
"input": "0x"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
64
eth/tracers/testdata/call_tracer_revert_reason.json
vendored
Normal file
64
eth/tracers/testdata/call_tracer_revert_reason.json
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -269,9 +269,31 @@ func TestCallTracer(t *testing.T) {
|
||||
t.Fatalf("failed to unmarshal trace result: %v", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(ret, test.Result) {
|
||||
if !jsonEqual(ret, test.Result) {
|
||||
// uncomment this for easier debugging
|
||||
//have, _ := json.MarshalIndent(ret, "", " ")
|
||||
//want, _ := json.MarshalIndent(test.Result, "", " ")
|
||||
//t.Fatalf("trace mismatch: \nhave %+v\nwant %+v", string(have), string(want))
|
||||
t.Fatalf("trace mismatch: \nhave %+v\nwant %+v", ret, test.Result)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// jsonEqual is similar to reflect.DeepEqual, but does a 'bounce' via json prior to
|
||||
// comparison
|
||||
func jsonEqual(x, y interface{}) bool {
|
||||
xTrace := new(callTrace)
|
||||
yTrace := new(callTrace)
|
||||
if xj, err := json.Marshal(x); err == nil {
|
||||
json.Unmarshal(xj, xTrace)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
if yj, err := json.Marshal(y); err == nil {
|
||||
json.Unmarshal(yj, yTrace)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
return reflect.DeepEqual(xTrace, yTrace)
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -887,6 +887,11 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
|
||||
hi uint64
|
||||
cap uint64
|
||||
)
|
||||
// Use zero address if sender unspecified.
|
||||
if args.From == nil {
|
||||
return 0, fmt.Errorf("missing from address")
|
||||
}
|
||||
// Determine the highest gas limit can be used during the estimation.
|
||||
if args.Gas != nil && uint64(*args.Gas) >= params.TxGas {
|
||||
hi = uint64(*args.Gas)
|
||||
} else {
|
||||
@@ -897,16 +902,40 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
|
||||
}
|
||||
hi = block.GasLimit()
|
||||
}
|
||||
// Recap the highest gas limit with account's available balance.
|
||||
if args.GasPrice != nil && args.GasPrice.ToInt().BitLen() != 0 {
|
||||
state, _, err := b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
balance := state.GetBalance(*args.From) // from can't be nil
|
||||
available := new(big.Int).Set(balance)
|
||||
if args.Value != nil {
|
||||
if args.Value.ToInt().Cmp(available) >= 0 {
|
||||
return 0, errors.New("insufficient funds for transfer")
|
||||
}
|
||||
available.Sub(available, args.Value.ToInt())
|
||||
}
|
||||
allowance := new(big.Int).Div(available, args.GasPrice.ToInt())
|
||||
|
||||
// If the allowance is larger than maximum uint64, skip checking
|
||||
if allowance.IsUint64() && hi > allowance.Uint64() {
|
||||
transfer := args.Value
|
||||
if transfer == nil {
|
||||
transfer = new(hexutil.Big)
|
||||
}
|
||||
log.Warn("Gas estimation capped by limited funds", "original", hi, "balance", balance,
|
||||
"sent", transfer.ToInt(), "gasprice", args.GasPrice.ToInt(), "fundable", allowance)
|
||||
hi = allowance.Uint64()
|
||||
}
|
||||
}
|
||||
// Recap the highest gas allowance with specified gascap.
|
||||
if gasCap != nil && hi > gasCap.Uint64() {
|
||||
log.Warn("Caller gas above allowance, capping", "requested", hi, "cap", gasCap)
|
||||
hi = gasCap.Uint64()
|
||||
}
|
||||
cap = hi
|
||||
|
||||
// Use zero address if sender unspecified.
|
||||
if args.From == nil {
|
||||
args.From = new(common.Address)
|
||||
}
|
||||
// Create a helper to check if a gas allowance results in an executable transaction
|
||||
executable := func(gas uint64) bool {
|
||||
args.Gas = (*hexutil.Uint64)(&gas)
|
||||
|
||||
@@ -23,8 +23,8 @@ import (
|
||||
const (
|
||||
VersionMajor = 1 // Major version component of the current release
|
||||
VersionMinor = 0 // Minor version component of the current release
|
||||
VersionPatch = 1 // Patch version component of the current release
|
||||
VersionMeta = "beta.2" // Version metadata to append to the version string
|
||||
VersionPatch = 4 // 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