Skip to content

Commit

Permalink
Merge pull request bnb-chain#1056 from bnb-chain/develop
Browse files Browse the repository at this point in the history
prepare for release v1.1.13
  • Loading branch information
unclezoro committed Sep 2, 2022
2 parents 723863e + aa835e0 commit 6f6bbcf
Show file tree
Hide file tree
Showing 106 changed files with 3,827 additions and 1,050 deletions.
44 changes: 44 additions & 0 deletions .github/commitlint.config.js
@@ -0,0 +1,44 @@
const validateTypeNums = (parsedCommit) => {
const mergePrefix = "Merge pull request"
if (parsedCommit.raw.startsWith(mergePrefix)) {
console.log('this is a merge commit:' + parsedCommit.raw)
return [true,'']
}

if (!parsedCommit.type) {
return [false, 'invalid commit message, should be like "name: descriptions.", yours: "' + parsedCommit.raw + '"']
}

const types = parsedCommit.type.split(' ')
for (var i=0;i<types.length;i++){
if ((types[i].toLowerCase() == "wip") || (types[i].toLowerCase() == "r4r")) {
return [false, 'R4R or WIP is not acceptable, no matter upper case or lower case']
}
}
return [true,'']
}


module.exports = {
parserPreset: {
parserOpts: {
headerPattern: /^(.*):.*/,
}
},
extends: ['@commitlint/config-conventional'],
plugins: ['commitlint-plugin-function-rules'],
rules: {
'subject-empty':[2, 'always'],
'scope-empty':[2, 'always'],
'type-enum': [2, 'never'],
'type-case': [0, 'always'],
'function-rules/type-case': [2, 'always', validateTypeNums],
'header-max-length': [
2,
'always',
72,
],
},
helpUrl:
'https://github.com/bnb-chain/bsc/tree/develop/docs/lint/commit.md',
}
45 changes: 45 additions & 0 deletions .github/workflows/commit-lint.yml
@@ -0,0 +1,45 @@
name: Lint Commit Messages

on:
push:
branches:
- master
- develop

pull_request:
branches:
- master
- develop

jobs:
commitlint:
strategy:
matrix:
node-version: [14.x]
os: [ubuntu-18.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v3
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Deps
run: |
npm install -g commitlint-plugin-function-rules @commitlint/cli
npm install --save-dev commitlint-plugin-function-rules @commitlint/cli
- uses: wagoid/commitlint-github-action@v5
id: commitlint
env:
NODE_PATH: ${{ github.workspace }}/node_modules
with:
configFile: /github/workspace/.github/commitlint.config.js
20 changes: 20 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,25 @@
# Changelog

## v1.1.13

FEATURE
* [\#1051](https://github.com/bnb-chain/bsc/pull/1051) Implement BEP153: Native Staking
* [\#1066](https://github.com/bnb-chain/bsc/pull/1066) Upgrade cross chain logic of native staking

IMPROVEMENT
* [\#952](https://github.com/bnb-chain/bsc/pull/952) Improve trie prefetch
* [\#975](https://github.com/bnb-chain/bsc/pull/975) broadcast block before commit block and add metrics
* [\#992](https://github.com/bnb-chain/bsc/pull/992) Pipecommit enable trie prefetcher
* [\#996](https://github.com/bnb-chain/bsc/pull/996) Trie prefetch on state pretch

BUGFIX
* [\#1053](https://github.com/bnb-chain/bsc/pull/1053) state: fix offline tool start failed when start with pruneancient
* [\#1060](https://github.com/bnb-chain/bsc/pull/1060) consensus: fix the GasLimitBoundDivisor
* [\#1061](https://github.com/bnb-chain/bsc/pull/1061) fix: upstream patches from go-ethereum
* [\#1067](https://github.com/bnb-chain/bsc/pull/1067) fix:fix potential goroutine leak
* [\#1068](https://github.com/bnb-chain/bsc/pull/1068) core trie rlp: patches from go-ethereum
* [\#1070](https://github.com/bnb-chain/bsc/pull/1070) txpool: reheap the priced list if london fork not enabled

## v1.1.12

FEATURE
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -13,7 +13,7 @@ environment:
GETH_MINGW: 'C:\msys64\mingw32'

install:
- git submodule update --init --depth 1
- git submodule update --init --depth 1 --recursive
- go version

for:
Expand Down
13 changes: 9 additions & 4 deletions build/ci.go
Expand Up @@ -311,7 +311,7 @@ func doTest(cmdline []string) {
packages := []string{"./accounts/...", "./common/...", "./consensus/...", "./console/...", "./core/...",
"./crypto/...", "./eth/...", "./ethclient/...", "./ethdb/...", "./event/...", "./graphql/...", "./les/...",
"./light/...", "./log/...", "./metrics/...", "./miner/...", "./mobile/...", "./node/...",
"./p2p/...", "./params/...", "./rlp/...", "./rpc/...", "./tests/...", "./trie/..."}
"./p2p/...", "./params/...", "./rlp/...", "./rpc/...", "./tests/...", "./trie/...", "./cmd/geth/..."}
if len(flag.CommandLine.Args()) > 0 {
packages = flag.CommandLine.Args()
}
Expand Down Expand Up @@ -342,12 +342,17 @@ func downloadLinter(cachedir string) string {

csdb := build.MustLoadChecksums("build/checksums.txt")
arch := runtime.GOARCH
if arch == "arm" {
ext := ".tar.gz"

if runtime.GOOS == "windows" {
ext = ".zip"
}
if arch == "arm" {
arch += "v" + os.Getenv("GOARM")
}
base := fmt.Sprintf("golangci-lint-%s-%s-%s", version, runtime.GOOS, arch)
url := fmt.Sprintf("https://github.com/golangci/golangci-lint/releases/download/v%s/%s.tar.gz", version, base)
archivePath := filepath.Join(cachedir, base+".tar.gz")
url := fmt.Sprintf("https://github.com/golangci/golangci-lint/releases/download/v%s/%s%s", version, base, ext)
archivePath := filepath.Join(cachedir, base+ext)
if err := csdb.DownloadFile(url, archivePath); err != nil {
log.Fatal(err)
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/geth/pruneblock_test.go
Expand Up @@ -49,8 +49,8 @@ var (
blockPruneBackUpBlockNumber = 128
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
balance = big.NewInt(10000000)
gspec = &core.Genesis{Config: params.TestChainConfig, Alloc: core.GenesisAlloc{address: {Balance: balance}}}
balance = big.NewInt(100000000000000000)
gspec = &core.Genesis{Config: params.TestChainConfig, Alloc: core.GenesisAlloc{address: {Balance: balance}}, BaseFee: big.NewInt(params.InitialBaseFee)}
signer = types.LatestSigner(gspec.Config)
config = &core.CacheConfig{
TrieCleanLimit: 256,
Expand Down Expand Up @@ -93,7 +93,7 @@ func testOfflineBlockPruneWithAmountReserved(t *testing.T, amountReserved uint64
t.Fatalf("Failed to back up block: %v", err)
}

dbBack, err := rawdb.NewLevelDBDatabaseWithFreezer(chaindbPath, 0, 0, newAncientPath, "", false, true, false, false)
dbBack, err := rawdb.NewLevelDBDatabaseWithFreezer(chaindbPath, 0, 0, newAncientPath, "", false, true, false, false, true)
if err != nil {
t.Fatalf("failed to create database with ancient backend")
}
Expand Down Expand Up @@ -139,7 +139,7 @@ func testOfflineBlockPruneWithAmountReserved(t *testing.T, amountReserved uint64

func BlockchainCreator(t *testing.T, chaindbPath, AncientPath string, blockRemain uint64) (ethdb.Database, []*types.Block, []*types.Block, []types.Receipts, []*big.Int, uint64, *core.BlockChain) {
//create a database with ancient freezer
db, err := rawdb.NewLevelDBDatabaseWithFreezer(chaindbPath, 0, 0, AncientPath, "", false, false, false, false)
db, err := rawdb.NewLevelDBDatabaseWithFreezer(chaindbPath, 0, 0, AncientPath, "", false, false, false, false, true)
if err != nil {
t.Fatalf("failed to create database with ancient backend")
}
Expand All @@ -154,7 +154,7 @@ func BlockchainCreator(t *testing.T, chaindbPath, AncientPath string, blockRemai
// Make chain starting from genesis
blocks, _ := core.GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 500, func(i int, block *core.BlockGen) {
block.SetCoinbase(common.Address{0: byte(canonicalSeed), 19: byte(i)})
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{0x00}, big.NewInt(1000), params.TxGas, nil, nil), signer, key)
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{0x00}, big.NewInt(1000), params.TxGas, big.NewInt(params.InitialBaseFee), nil), signer, key)
if err != nil {
panic(err)
}
Expand Down
13 changes: 5 additions & 8 deletions cmd/geth/snapshot.go
Expand Up @@ -601,8 +601,7 @@ func traverseState(ctx *cli.Context) error {
}
}
if !bytes.Equal(acc.CodeHash, emptyCode) {
code := rawdb.ReadCode(chaindb, common.BytesToHash(acc.CodeHash))
if len(code) == 0 {
if !rawdb.HasCode(chaindb, common.BytesToHash(acc.CodeHash)) {
log.Error("Code is missing", "hash", common.BytesToHash(acc.CodeHash))
return errors.New("missing code")
}
Expand Down Expand Up @@ -673,11 +672,10 @@ func traverseRawState(ctx *cli.Context) error {
nodes += 1
node := accIter.Hash()

// Check the present for non-empty hash node(embedded node doesn't
// have their own hash).
if node != (common.Hash{}) {
// Check the present for non-empty hash node(embedded node doesn't
// have their own hash).
blob := rawdb.ReadTrieNode(chaindb, node)
if len(blob) == 0 {
if !rawdb.HasTrieNode(chaindb, node) {
log.Error("Missing trie node(account)", "hash", node)
return errors.New("missing account")
}
Expand Down Expand Up @@ -721,8 +719,7 @@ func traverseRawState(ctx *cli.Context) error {
}
}
if !bytes.Equal(acc.CodeHash, emptyCode) {
code := rawdb.ReadCode(chaindb, common.BytesToHash(acc.CodeHash))
if len(code) == 0 {
if !rawdb.HasCode(chaindb, common.BytesToHash(acc.CodeHash)) {
log.Error("Code is missing", "account", common.BytesToHash(accIter.LeafKey()))
return errors.New("missing code")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/utils/flags.go
Expand Up @@ -2020,7 +2020,7 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly, disableFree
chainDb, err = stack.OpenDatabase(name, cache, handles, "", readonly)
} else {
name := "chaindata"
chainDb, err = stack.OpenDatabaseWithFreezer(name, cache, handles, ctx.GlobalString(AncientFlag.Name), "", readonly, disableFreeze, false, false)
chainDb, err = stack.OpenDatabaseWithFreezer(name, cache, handles, ctx.GlobalString(AncientFlag.Name), "", readonly, disableFreeze, false, false, true)
}
if err != nil {
Fatalf("Could not open database: %v", err)
Expand Down
92 changes: 46 additions & 46 deletions consensus/misc/eip1559_test.go
Expand Up @@ -58,53 +58,53 @@ func config() *params.ChainConfig {

// TestBlockGasLimits tests the gasLimit checks for blocks both across
// the EIP-1559 boundary and post-1559 blocks
func TestBlockGasLimits(t *testing.T) {
initial := new(big.Int).SetUint64(params.InitialBaseFee)
// func TestBlockGasLimits(t *testing.T) {
// initial := new(big.Int).SetUint64(params.InitialBaseFee)

for i, tc := range []struct {
pGasLimit uint64
pNum int64
gasLimit uint64
ok bool
}{
// Transitions from non-london to london
{10000000, 4, 20000000, true}, // No change
{10000000, 4, 20019530, true}, // Upper limit
{10000000, 4, 20019531, false}, // Upper +1
{10000000, 4, 19980470, true}, // Lower limit
{10000000, 4, 19980469, false}, // Lower limit -1
// London to London
{20000000, 5, 20000000, true},
{20000000, 5, 20019530, true}, // Upper limit
{20000000, 5, 20019531, false}, // Upper limit +1
{20000000, 5, 19980470, true}, // Lower limit
{20000000, 5, 19980469, false}, // Lower limit -1
{40000000, 5, 40039061, true}, // Upper limit
{40000000, 5, 40039062, false}, // Upper limit +1
{40000000, 5, 39960939, true}, // lower limit
{40000000, 5, 39960938, false}, // Lower limit -1
} {
parent := &types.Header{
GasUsed: tc.pGasLimit / 2,
GasLimit: tc.pGasLimit,
BaseFee: initial,
Number: big.NewInt(tc.pNum),
}
header := &types.Header{
GasUsed: tc.gasLimit / 2,
GasLimit: tc.gasLimit,
BaseFee: initial,
Number: big.NewInt(tc.pNum + 1),
}
err := VerifyEip1559Header(config(), parent, header)
if tc.ok && err != nil {
t.Errorf("test %d: Expected valid header: %s", i, err)
}
if !tc.ok && err == nil {
t.Errorf("test %d: Expected invalid header", i)
}
}
}
// for i, tc := range []struct {
// pGasLimit uint64
// pNum int64
// gasLimit uint64
// ok bool
// }{
// // Transitions from non-london to london
// {10000000, 4, 20000000, true}, // No change
// {10000000, 4, 20019530, true}, // Upper limit
// {10000000, 4, 20019531, false}, // Upper +1
// {10000000, 4, 19980470, true}, // Lower limit
// {10000000, 4, 19980469, false}, // Lower limit -1
// // London to London
// {20000000, 5, 20000000, true},
// {20000000, 5, 20019530, true}, // Upper limit
// {20000000, 5, 20019531, false}, // Upper limit +1
// {20000000, 5, 19980470, true}, // Lower limit
// {20000000, 5, 19980469, false}, // Lower limit -1
// {40000000, 5, 40039061, true}, // Upper limit
// {40000000, 5, 40039062, false}, // Upper limit +1
// {40000000, 5, 39960939, true}, // lower limit
// {40000000, 5, 39960938, false}, // Lower limit -1
// } {
// parent := &types.Header{
// GasUsed: tc.pGasLimit / 2,
// GasLimit: tc.pGasLimit,
// BaseFee: initial,
// Number: big.NewInt(tc.pNum),
// }
// header := &types.Header{
// GasUsed: tc.gasLimit / 2,
// GasLimit: tc.gasLimit,
// BaseFee: initial,
// Number: big.NewInt(tc.pNum + 1),
// }
// err := VerifyEip1559Header(config(), parent, header)
// if tc.ok && err != nil {
// t.Errorf("test %d: Expected valid header: %s", i, err)
// }
// if !tc.ok && err == nil {
// t.Errorf("test %d: Expected invalid header", i)
// }
// }
// }

// TestCalcBaseFee assumes all blocks are 1559-blocks
func TestCalcBaseFee(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion consensus/parlia/parlia.go
Expand Up @@ -420,7 +420,7 @@ func (p *Parlia) verifyCascadingFields(chain consensus.ChainHeaderReader, header
if diff < 0 {
diff *= -1
}
limit := parent.GasLimit / params.ParliaGasLimitBoundDivisor
limit := parent.GasLimit / params.GasLimitBoundDivisor

if uint64(diff) >= limit || header.GasLimit < params.MinGasLimit {
return fmt.Errorf("invalid gas limit: have %d, want %d += %d", header.GasLimit, parent.GasLimit, limit)
Expand Down
4 changes: 2 additions & 2 deletions core/block_validator_test.go
Expand Up @@ -377,8 +377,8 @@ func TestCalcGasLimit(t *testing.T) {
max uint64
min uint64
}{
{20000000, 20019530, 19980470},
{40000000, 40039061, 39960939},
{20000000, 20078124, 19921876},
{40000000, 40156249, 39843751},
} {
// Increase
if have, want := CalcGasLimit(tc.pGasLimit, 2*tc.pGasLimit), tc.max; have != want {
Expand Down

0 comments on commit 6f6bbcf

Please sign in to comment.