Skip to content

Commit

Permalink
Merge branch 'master' into feature/mainNode
Browse files Browse the repository at this point in the history
  • Loading branch information
swlfigo committed Apr 8, 2023
2 parents 01ad7ab + 6e06ed1 commit 52cc37d
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 24 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Changelog
## v1.1.21
FEATURE
* [\#1389](https://github.com/bnb-chain/bsc/pull/1389) upgrade: update the fork height of planck upgrade on mainnet

BUGFIX
* [\#1354](https://github.com/bnb-chain/bsc/pull/1354) fix: add some boundary check for security
* [\#1373](https://github.com/bnb-chain/bsc/pull/1373) tracer: enable withLog for TraceCall
* [\#1377](https://github.com/bnb-chain/bsc/pull/1377) miner: add fallthrough for switch cases

## v1.1.20
FEATURE
* [\#1322](https://github.com/bnb-chain/bsc/pull/1322) cmd/utils/flags.go: --diffsync flag is deprecate
Expand All @@ -15,7 +24,7 @@ IMPROVEMENT
* [\#1333](https://github.com/bnb-chain/bsc/pull/1333) sec: add proof ops check and key checker

BUGFIX
* [\#1348](https://github.com/bnb-chain/bsc/pull/1348) (HEAD, bnb-chain/develop) core/txpool: implement additional DoS defenses
* [\#1348](https://github.com/bnb-chain/bsc/pull/1348) core/txpool: implement additional DoS defenses

## v1.1.19
FEATURE
Expand Down
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
2 changes: 2 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,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
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
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 1 // Minor version component of the current release
VersionPatch = 20 // Patch version component of the current release
VersionPatch = 21 // Patch version component of the current release
VersionMeta = "" // Version metadata to append to the version string
)

Expand Down

0 comments on commit 52cc37d

Please sign in to comment.