Skip to content

Commit

Permalink
Merge pull request #1596 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: draft release v1.2.2
  • Loading branch information
brilliant-lx authored May 9, 2023
2 parents 542bb5b + b90b1f5 commit e22989f
Show file tree
Hide file tree
Showing 49 changed files with 558 additions and 223 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
tags:
- 'pre-*'

env:
CGO_CFLAGS: "-O -D__BLST_PORTABLE__"
CGO_CFLAGS_ALLOW: "-O -D__BLST_PORTABLE__"

jobs:
build:
name: Build Release
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# Publish `v1.2.3` tags as releases.
tags:
- v*
env:
CGO_CFLAGS: "-O -D__BLST_PORTABLE__"
CGO_CFLAGS_ALLOW: "-O -D__BLST_PORTABLE__"

jobs:
build:
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
# Changelog
## v1.2.2
FEATURE
* [\#1574](https://github.com/bnb-chain/bsc/pull/1574) upgrade: update PlatoUpgrade contracts code
* [\#1594](https://github.com/bnb-chain/bsc/pull/1594) upgrade: block height of Plato on testnet

IMPROVEMENT
* [\#866](https://github.com/bnb-chain/bsc/pull/866) code: x = append(y) is equivalent to x = y
* [\#1488](https://github.com/bnb-chain/bsc/pull/1488) eth/tracers, core/vm: remove `time` from trace output and tracing interface
* [\#1547](https://github.com/bnb-chain/bsc/pull/1547) fix: recently signed check when slashing unavailable validator
* [\#1573](https://github.com/bnb-chain/bsc/pull/1573) feat: remove supports for legacy proof type
* [\#1576](https://github.com/bnb-chain/bsc/pull/1576) fix: support golang 1.20 by upgrading prysm to v4
* [\#1578](https://github.com/bnb-chain/bsc/pull/1578) fix: output an error log when bsc extension fail to handshake
* [\#1583](https://github.com/bnb-chain/bsc/pull/1583) metrics: add a counter for validator to check work status of voting

BUGFIX
* [\#1566](https://github.com/bnb-chain/bsc/pull/1566) fix: config for VoteJournalDir and BLSWalletDir
* [\#1572](https://github.com/bnb-chain/bsc/pull/1572) fix: remove dynamic metric labels about fast finality
* [\#1575](https://github.com/bnb-chain/bsc/pull/1575) fix: make BLST PORTABLE for release binary
* [\#1590](https://github.com/bnb-chain/bsc/pull/1590) fix: fix snap flaky tests

## v1.2.1
IMPROVEMENT
* [\#1527](https://github.com/bnb-chain/bsc/pull/1527) log: revert a log back to trace level

## v1.2.0
FEATURE
* [\#936](https://github.com/bnb-chain/bsc/pull/936) BEP-126: Introduce Fast Finality Mechanism
Expand Down
39 changes: 24 additions & 15 deletions cmd/bootnode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,21 @@ import (

func main() {
var (
listenAddr = flag.String("addr", ":30301", "listen address")
genKey = flag.String("genkey", "", "generate a node key")
writeAddr = flag.Bool("writeaddress", false, "write out the node's public key and quit")
nodeKeyFile = flag.String("nodekey", "", "private key filename")
nodeKeyHex = flag.String("nodekeyhex", "", "private key as hex (for testing)")
natdesc = flag.String("nat", "none", "port mapping mechanism (any|none|upnp|pmp|extip:<IP>)")
netrestrict = flag.String("netrestrict", "", "restrict network communication to the given IP networks (CIDR masks)")
runv5 = flag.Bool("v5", false, "run a v5 topic discovery bootnode")
verbosity = flag.Int("verbosity", int(log.LvlInfo), "log verbosity (0-5)")
vmodule = flag.String("vmodule", "", "log verbosity pattern")

nodeKey *ecdsa.PrivateKey
err error
listenAddr = flag.String("addr", ":30301", "listen address")
genKey = flag.String("genkey", "", "generate a node key")
writeAddr = flag.Bool("writeaddress", false, "write out the node's public key and quit")
nodeKeyFile = flag.String("nodekey", "", "private key filename")
nodeKeyHex = flag.String("nodekeyhex", "", "private key as hex (for testing)")
natdesc = flag.String("nat", "none", "port mapping mechanism (any|none|upnp|pmp|extip:<IP>)")
netrestrict = flag.String("netrestrict", "", "restrict network communication to the given IP networks (CIDR masks)")
runv5 = flag.Bool("v5", false, "run a v5 topic discovery bootnode")
verbosity = flag.Int("verbosity", int(log.LvlInfo), "log verbosity (0-5)")
vmodule = flag.String("vmodule", "", "log verbosity pattern")
networkFilter = flag.String("network", "", "<bsc/chapel/rialto> filters nodes by eth ENR entry")

nodeKey *ecdsa.PrivateKey
filterFunction discover.NodeFilterFunc
err error
)
flag.Parse()

Expand Down Expand Up @@ -86,6 +88,12 @@ func main() {
}
}

if *networkFilter != "" {
if filterFunction, err = discover.ParseEthFilter(*networkFilter); err != nil {
utils.Fatalf("-network: %v", err)
}
}

if *writeAddr {
fmt.Printf("%x\n", crypto.FromECDSAPub(&nodeKey.PublicKey)[1:])
os.Exit(0)
Expand Down Expand Up @@ -123,8 +131,9 @@ func main() {
db, _ := enode.OpenDB("")
ln := enode.NewLocalNode(db, nodeKey)
cfg := discover.Config{
PrivateKey: nodeKey,
NetRestrict: restrictList,
PrivateKey: nodeKey,
NetRestrict: restrictList,
FilterFunction: filterFunction,
}
if *runv5 {
if _, err := discover.ListenV5(conn, ln, cfg); err != nil {
Expand Down
20 changes: 10 additions & 10 deletions cmd/geth/blsaccountcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import (

"github.com/google/uuid"
"github.com/logrusorgru/aurora"
"github.com/prysmaticlabs/prysm/v3/crypto/bls"
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/v3/io/prompt"
"github.com/prysmaticlabs/prysm/v3/proto/eth/service"
"github.com/prysmaticlabs/prysm/v3/validator/accounts"
"github.com/prysmaticlabs/prysm/v3/validator/accounts/iface"
"github.com/prysmaticlabs/prysm/v3/validator/accounts/petnames"
"github.com/prysmaticlabs/prysm/v3/validator/accounts/wallet"
"github.com/prysmaticlabs/prysm/v3/validator/keymanager"
"github.com/prysmaticlabs/prysm/v3/validator/keymanager/local"
"github.com/prysmaticlabs/prysm/v4/crypto/bls"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/v4/io/prompt"
"github.com/prysmaticlabs/prysm/v4/proto/eth/service"
"github.com/prysmaticlabs/prysm/v4/validator/accounts"
"github.com/prysmaticlabs/prysm/v4/validator/accounts/iface"
"github.com/prysmaticlabs/prysm/v4/validator/accounts/petnames"
"github.com/prysmaticlabs/prysm/v4/validator/accounts/wallet"
"github.com/prysmaticlabs/prysm/v4/validator/keymanager"
"github.com/prysmaticlabs/prysm/v4/validator/keymanager/local"
keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4"
"gopkg.in/urfave/cli.v1"

Expand Down
4 changes: 2 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ func setVoteJournalDir(ctx *cli.Context, cfg *node.Config) {
dataDir := cfg.DataDir
if ctx.GlobalIsSet(VoteJournalDirFlag.Name) {
cfg.VoteJournalDir = ctx.GlobalString(VoteJournalDirFlag.Name)
} else {
} else if cfg.VoteJournalDir == "" {
cfg.VoteJournalDir = filepath.Join(dataDir, "voteJournal")
}
}
Expand All @@ -1412,7 +1412,7 @@ func setBLSWalletDir(ctx *cli.Context, cfg *node.Config) {
dataDir := cfg.DataDir
if ctx.GlobalIsSet(BLSWalletDirFlag.Name) {
cfg.BLSWalletDir = ctx.GlobalString(BLSWalletDirFlag.Name)
} else {
} else if cfg.BLSWalletDir == "" {
cfg.BLSWalletDir = filepath.Join(dataDir, "bls/wallet")
}
}
Expand Down
75 changes: 33 additions & 42 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"time"

lru "github.com/hashicorp/golang-lru"
"github.com/prysmaticlabs/prysm/v3/crypto/bls"
"github.com/prysmaticlabs/prysm/v4/crypto/bls"
"github.com/willf/bitset"
"golang.org/x/crypto/sha3"

Expand Down Expand Up @@ -75,9 +75,10 @@ var (
diffInTurn = big.NewInt(2) // Block difficulty for in-turn signatures
diffNoTurn = big.NewInt(1) // Block difficulty for out-of-turn signatures
// 100 native token
maxSystemBalance = new(big.Int).Mul(big.NewInt(100), big.NewInt(params.Ether))
verifyVoteAttestationFailedGauge = metrics.NewRegisteredGauge("parlia/verifyVoteAttestationFailed", nil)
updateAttestationFailedGauge = metrics.NewRegisteredGauge("parlia/updateAttestationFailed", nil)
maxSystemBalance = new(big.Int).Mul(big.NewInt(100), big.NewInt(params.Ether))
verifyVoteAttestationErrorCounter = metrics.NewRegisteredCounter("parlia/verifyVoteAttestation/error", nil)
updateAttestationErrorCounter = metrics.NewRegisteredCounter("parlia/updateAttestation/error", nil)
validVotesfromSelfCounter = metrics.NewRegisteredCounter("parlia/VerifyVote/self", nil)

systemContracts = map[common.Address]bool{
common.HexToAddress(systemcontracts.ValidatorContract): true,
Expand Down Expand Up @@ -599,7 +600,7 @@ func (p *Parlia) verifyCascadingFields(chain consensus.ChainHeaderReader, header

// Verify vote attestation for fast finality.
if err := p.verifyVoteAttestation(chain, header, parents); err != nil {
verifyVoteAttestationFailedGauge.Inc(1)
verifyVoteAttestationErrorCounter.Inc(1)
if chain.Config().IsPlato(header.Number) {
return err
}
Expand Down Expand Up @@ -754,13 +755,8 @@ func (p *Parlia) verifySeal(chain consensus.ChainHeaderReader, header *types.Hea
return errUnauthorizedValidator
}

for seen, recent := range snap.Recents {
if recent == signer {
// Signer is among recents, only fail if the current block doesn't shift it out
if limit := uint64(len(snap.Validators)/2 + 1); seen > number-limit {
return errRecentlySigned
}
}
if snap.SignRecently(signer) {
return errRecentlySigned
}

// Ensure that the difficulty corresponds to the turn-ness of the signer
Expand Down Expand Up @@ -1065,12 +1061,17 @@ func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
if header.Difficulty.Cmp(diffInTurn) != 0 {
spoiledVal := snap.supposeValidator()
signedRecently := false
for _, recent := range snap.Recents {
if recent == spoiledVal {
signedRecently = true
break
if p.chainConfig.IsPlato(header.Number) {
signedRecently = snap.SignRecently(spoiledVal)
} else {
for _, recent := range snap.Recents {
if recent == spoiledVal {
signedRecently = true
break
}
}
}

if !signedRecently {
log.Trace("slash validator", "block hash", header.Hash(), "address", spoiledVal)
err = p.slash(spoiledVal, state, header, cx, txs, receipts, systemTxs, usedGas, false)
Expand Down Expand Up @@ -1123,10 +1124,14 @@ func (p *Parlia) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *
}
spoiledVal := snap.supposeValidator()
signedRecently := false
for _, recent := range snap.Recents {
if recent == spoiledVal {
signedRecently = true
break
if p.chainConfig.IsPlato(header.Number) {
signedRecently = snap.SignRecently(spoiledVal)
} else {
for _, recent := range snap.Recents {
if recent == spoiledVal {
signedRecently = true
break
}
}
}
if !signedRecently {
Expand Down Expand Up @@ -1216,8 +1221,11 @@ func (p *Parlia) VerifyVote(chain consensus.ChainHeaderReader, vote *types.VoteE

validators := snap.Validators
voteAddress := vote.VoteAddress
for _, validator := range validators {
for addr, validator := range validators {
if validator.VoteAddress == voteAddress {
if addr == p.val {
validVotesfromSelfCounter.Inc(1)
}
return nil
}
}
Expand Down Expand Up @@ -1294,14 +1302,9 @@ func (p *Parlia) Seal(chain consensus.ChainHeaderReader, block *types.Block, res
}

// If we're amongst the recent signers, wait for the next block
for seen, recent := range snap.Recents {
if recent == val {
// Signer is among recents, only wait if the current block doesn't shift it out
if limit := uint64(len(snap.Validators)/2 + 1); number < limit || seen > number-limit {
log.Info("Signed recently, must wait for others")
return nil
}
}
if snap.SignRecently(val) {
log.Info("Signed recently, must wait for others")
return nil
}

// Sweet, the protocol permits us to sign the block, wait for our time
Expand Down Expand Up @@ -1408,19 +1411,7 @@ func (p *Parlia) SignRecently(chain consensus.ChainReader, parent *types.Block)
return true, errUnauthorizedValidator
}

// If we're amongst the recent signers, wait for the next block
number := parent.NumberU64() + 1
for seen, recent := range snap.Recents {
if recent != p.val {
continue
}

// Signer is among recents, only wait if the current block doesn't shift it out
if limit := uint64(len(snap.Validators)/2 + 1); number < limit || seen > number-limit {
return true, nil
}
}
return false, nil
return snap.SignRecently(p.val), nil
}

// CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty
Expand Down
13 changes: 12 additions & 1 deletion consensus/parlia/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (s *Snapshot) updateAttestation(header *types.Header, chainConfig *params.C
if targetHash != header.ParentHash || targetNumber+1 != header.Number.Uint64() {
log.Warn("updateAttestation failed", "error", fmt.Errorf("invalid attestation, target mismatch, expected block: %d, hash: %s; real block: %d, hash: %s",
header.Number.Uint64()-1, header.ParentHash, targetNumber, targetHash))
updateAttestationFailedGauge.Inc(1)
updateAttestationErrorCounter.Inc(1)
return
}

Expand All @@ -207,6 +207,17 @@ func (s *Snapshot) updateAttestation(header *types.Header, chainConfig *params.C
}
}

func (s *Snapshot) SignRecently(validator common.Address) bool {
for seen, recent := range s.Recents {
if recent == validator {
if limit := uint64(len(s.Validators)/2 + 1); s.Number+1 < limit || seen > s.Number+1-limit {
return true
}
}
}
return false
}

func (s *Snapshot) apply(headers []*types.Header, chain consensus.ChainHeaderReader, parents []*types.Header, chainConfig *params.ChainConfig) (*Snapshot, error) {
// Allow passing in no headers for cleaner code
if len(headers) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func blockReceiptsKey(number uint64, hash common.Hash) []byte {

// diffLayerKey = diffLayerKeyPrefix + hash
func diffLayerKey(hash common.Hash) []byte {
return append(append(diffLayerPrefix, hash.Bytes()...))
return append(diffLayerPrefix, hash.Bytes()...)
}

// txLookupKey = txLookupPrefix + hash
Expand Down
54 changes: 54 additions & 0 deletions core/systemcontracts/upgrade.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/types/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"sync/atomic"

"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v3/crypto/bls"
"github.com/prysmaticlabs/prysm/v4/crypto/bls"

"github.com/ethereum/go-ethereum/common"
)
Expand Down
Loading

0 comments on commit e22989f

Please sign in to comment.