Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: draft release v1.1.21 #1390

Merged
merged 10 commits into from
Mar 27, 2023
9 changes: 3 additions & 6 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -1301,17 +1301,14 @@ func (p *Parlia) backOffTime(snap *Snapshot, header *types.Header, val common.Ad
recentsMap[recent] = seen
}

// if the validator has recently signed, it is unexpected, stop here.
if seen, ok := recentsMap[val]; ok {
log.Error("unreachable code, validator signed recently",
"block", header.Number, "address", val,
"seen", seen, "len(snap.Recents)", len(snap.Recents))
// The backOffTime does not matter when a validator has signed recently.
if _, ok := recentsMap[val]; ok {
return 0
}

inTurnAddr := validators[(snap.Number+1)%uint64(len(validators))]
if _, ok := recentsMap[inTurnAddr]; ok {
log.Info("in turn validator has recently signed, skip initialBackOffTime",
log.Debug("in turn validator has recently signed, skip initialBackOffTime",
"inTurnAddr", inTurnAddr)
delay = 0
}
Expand Down
10 changes: 6 additions & 4 deletions core/tx_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ func (h *nonceHeap) Push(x interface{}) {

func (h *nonceHeap) Pop() interface{} {
old := *h
n := len(old)
x := old[n-1]
*h = old[0 : n-1]
return x
if n := len(old); n > 0 {
x := old[n-1]
*h = old[0 : n-1]
return x
}
return nil
}

// txSortedMap is a nonce->transaction hash map with a heap based index to allow
Expand Down
5 changes: 5 additions & 0 deletions core/vm/contracts_lightclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ const (
// 32 bytes | | |
func decodeTendermintHeaderValidationInput(input []byte) (*lightclient.ConsensusState, *lightclient.Header, error) {
csLen := binary.BigEndian.Uint64(input[consensusStateLengthBytesLength-uint64TypeLength : consensusStateLengthBytesLength])

if consensusStateLengthBytesLength+csLen < consensusStateLengthBytesLength {
return nil, nil, fmt.Errorf("integer overflow, csLen: %d", csLen)
}

if uint64(len(input)) <= consensusStateLengthBytesLength+csLen {
return nil, nil, fmt.Errorf("expected payload size %d, actual size: %d", consensusStateLengthBytesLength+csLen, len(input))
}
Expand Down
13 changes: 9 additions & 4 deletions core/vm/lightclient/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,18 @@ func DecodeKeyValueMerkleProof(input []byte) (*KeyValueMerkleProof, error) {
inputLength := uint64(len(input))
pos := uint64(0)

if inputLength <= storeNameLengthBytesLength+keyLengthBytesLength+valueLengthBytesLength+appHashLength {
return nil, fmt.Errorf("input length should be no less than %d", storeNameLengthBytesLength+keyLengthBytesLength+valueLengthBytesLength+appHashLength)
fixedSize := storeNameLengthBytesLength + keyLengthBytesLength + valueLengthBytesLength + appHashLength
if inputLength <= fixedSize {
return nil, fmt.Errorf("input length should be no less than %d", fixedSize)
}
storeName := string(bytes.Trim(input[pos:pos+storeNameLengthBytesLength], "\x00"))
pos += storeNameLengthBytesLength

keyLength := binary.BigEndian.Uint64(input[pos+keyLengthBytesLength-8 : pos+keyLengthBytesLength])
pos += keyLengthBytesLength

if inputLength <= storeNameLengthBytesLength+keyLengthBytesLength+keyLength+valueLengthBytesLength {
fixedSize = storeNameLengthBytesLength + keyLengthBytesLength + valueLengthBytesLength
if inputLength <= fixedSize+keyLength || fixedSize+keyLength < fixedSize {
return nil, fmt.Errorf("invalid input, keyLength %d is too long", keyLength)
}
key := input[pos : pos+keyLength]
Expand All @@ -288,7 +290,10 @@ func DecodeKeyValueMerkleProof(input []byte) (*KeyValueMerkleProof, error) {
valueLength := binary.BigEndian.Uint64(input[pos+valueLengthBytesLength-8 : pos+valueLengthBytesLength])
pos += valueLengthBytesLength

if inputLength <= storeNameLengthBytesLength+keyLengthBytesLength+keyLength+valueLengthBytesLength+valueLength+appHashLength {
fixedSize = storeNameLengthBytesLength + keyLengthBytesLength + valueLengthBytesLength + appHashLength
if inputLength <= fixedSize+keyLength+valueLength ||
fixedSize+keyLength < fixedSize ||
fixedSize+keyLength+valueLength < valueLength {
return nil, fmt.Errorf("invalid input, valueLength %d is too long", valueLength)
}
value := input[pos : pos+valueLength]
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FROM ethereum/solc:0.6.4-alpine as bsc-genesis
RUN apk add --d --no-cache ca-certificates npm nodejs bash alpine-sdk

RUN git clone https://github.com/binance-chain/bsc-genesis-contract.git /root/genesis \
&& rm /root/genesis/package-lock.json && cd /root/genesis && npm install
&& cd /root/genesis && npm install

COPY docker/init_holders.template /root/genesis/init_holders.template

Expand Down
7 changes: 1 addition & 6 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -882,12 +882,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc

var traceConfig *TraceConfig
if config != nil {
traceConfig = &TraceConfig{
Config: config.Config,
Tracer: config.Tracer,
Timeout: config.Timeout,
Reexec: config.Reexec,
}
traceConfig = &config.TraceConfig
}
return api.traceTx(ctx, msg, new(Context), vmctx, statedb, traceConfig)
}
Expand Down
13 changes: 11 additions & 2 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,12 @@ LOOP:
// subscribe before fillTransactions
txsCh := make(chan core.NewTxsEvent, txChanSize)
sub := w.eth.TxPool().SubscribeNewTxsEvent(txsCh)
defer sub.Unsubscribe()
// if TxPool has been stopped, `sub` would be nil, it could happen on shutdown.
if sub == nil {
log.Info("commitWork SubscribeNewTxsEvent return nil")
} else {
defer sub.Unsubscribe()
}

// Fill pending transactions from the txpool
fillStart := time.Now()
Expand All @@ -1137,7 +1142,9 @@ LOOP:
log.Debug("commitWork abort", "err", err)
return
case errors.Is(err, errBlockInterruptedByRecommit):
fallthrough
case errors.Is(err, errBlockInterruptedByTimeout):
fallthrough
case errors.Is(err, errBlockInterruptedByOutOfGas):
// break the loop to get the best work
log.Debug("commitWork finish", "reason", err)
Expand Down Expand Up @@ -1196,7 +1203,9 @@ LOOP:
}
// if sub's channel if full, it will block other NewTxsEvent subscribers,
// so unsubscribe ASAP and Unsubscribe() is re-enterable, safe to call several time.
sub.Unsubscribe()
if sub != nil {
sub.Unsubscribe()
}
}
// get the most profitable work
bestWork := workList[0]
Expand Down
2 changes: 1 addition & 1 deletion params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var (
NanoBlock: big.NewInt(21962149),
MoranBlock: big.NewInt(22107423),
GibbsBlock: big.NewInt(23846001),
PlanckBlock: nil,
PlanckBlock: big.NewInt(27281024),

Parlia: &ParliaConfig{
Period: 3,
Expand Down