Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .nancy-ignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
CVE-2024-34478 # "CWE-754: Improper Check for Unusual or Exceptional Conditions." This vulnerability is BTC only, BSC does not have the issue.
CVE-2024-6104 # "CWE-532: Information Exposure Through Log Files" This is caused by the vulnerabilities go-retryablehttp@v0.7.4, it is only used in cmd devp2p, impact is limited. will upgrade to v0.7.7 later
CVE-2024-8421 # "CWE-400: Uncontrolled Resource Consumption (Resource Exhaustion)" This vulnerability is caused by issues in the golang.org/x/net package. Even the latest version(v0.29.0) has not yet addressed it, but we will continue to monitor updates closely.
CVE-2024-51744 # "CWE-347: Improper Verification of Cryptographic Signature" & "CWE-755: Improper Handling of Exceptional Conditions" This vulnerability is caused mishandling of JWT error code, BSC does not have the issue as it does not check the detail error code.
CVE-2025-22872 # "CWE-1286: github.com/golang/net - Improper Validation of Syntactic Correctness of Input", golang/golang.org/x/net@v0.36.0 was indirectly dependency by devp2p, can be will upgraded in the future
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Changelog
## v1.5.11
### FEATURE
[\#3008](https://github.com/bnb-chain/bsc/pull/3008) params: add MaxwellTime
[\#3025](https://github.com/bnb-chain/bsc/pull/3025) config.toml: default value of [Eth.Miner] and [Eth.Miner.Mev]
[\#3026](https://github.com/bnb-chain/bsc/pull/3026) mev: include MaxBidsPerBuilder in MevParams
[\#3027](https://github.com/bnb-chain/bsc/pull/3027) mev: update two default mev paramater for 1.5s block interval

### BUGFIX
[\#3007](https://github.com/bnb-chain/bsc/pull/3007) metrics: fix panic for cocurrently accessing label

### IMPROVEMENT
[\#3006](https://github.com/bnb-chain/bsc/pull/3006) jsutil: update getKeyParameters
[\#3018](https://github.com/bnb-chain/bsc/pull/3018) nancy: update nancy ignore
[\#3021](https://github.com/bnb-chain/bsc/pull/3021) chore: remove duplicate package imports

## v1.5.10
### FEATURE
[\#3015](https://github.com/bnb-chain/bsc/pull/3015) config: update BSC Mainnet hardfork time: Lorentz
Expand Down Expand Up @@ -138,7 +153,7 @@ _in bsc, this feature only enabled with multi-database_

#### New EIPs
[core/vm: enable bls-precompiles for Prague (](https://github.com/ethereum/go-ethereum/commit/823719b9e1b72174cd8245ae9e6f6f7d7072a8d6)[#29552](https://github.com/ethereum/go-ethereum/pull/29552)[)](https://github.com/ethereum/go-ethereum/commit/823719b9e1b72174cd8245ae9e6f6f7d7072a8d6)
[EIP-2935: Serve historical block hashes from state](https://eips.ethereum.org/EIPS/eip-2935) ([#29465](https://github.com/ethereum/go-ethereum/pull/29465))
[EIP-2935: Serve historical block hashes from state](https://eips.ethereum.org/EIPS/eip-2935) ([#29465](https://github.com/ethereum/go-ethereum/pull/29465))

#### Clear Up
[eth, eth/downloader: remove references to LightChain, LightSync (#29711)](https://github.com/ethereum/go-ethereum/pull/29711)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ BNB Smart Chain starts its development based on go-ethereum fork. So you may see
[![API Reference](
https://pkg.go.dev/badge/github.com/ethereum/go-ethereum
)](https://pkg.go.dev/github.com/ethereum/go-ethereum?tab=doc)
[![Build Test](https://github.com/bnb-chain/bsc/actions/workflows/build-test.yml/badge.svg)](https://github.com/bnb-chain/bsc/actions)
[![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.gg/z2VpC455eU)

But from that baseline of EVM compatible, BNB Smart Chain introduces a system of 21 validators with Proof of Staked Authority (PoSA) consensus that can support short block time and lower fees. The most bonded validator candidates of staking will become validators and produce blocks. The double-sign detection and other slashing logic guarantee security, stability, and chain finality.
Expand Down
5 changes: 5 additions & 0 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var (
utils.CachePreimagesFlag,
utils.OverridePassedForkTime,
utils.OverrideLorentz,
utils.OverrideMaxwell,
utils.OverrideVerkle,
utils.MultiDataBaseFlag,
}, utils.DatabaseFlags),
Expand Down Expand Up @@ -263,6 +264,10 @@ func initGenesis(ctx *cli.Context) error {
v := ctx.Uint64(utils.OverrideLorentz.Name)
overrides.OverrideLorentz = &v
}
if ctx.IsSet(utils.OverrideMaxwell.Name) {
v := ctx.Uint64(utils.OverrideMaxwell.Name)
overrides.OverrideMaxwell = &v
}
if ctx.IsSet(utils.OverrideVerkle.Name) {
v := ctx.Uint64(utils.OverrideVerkle.Name)
overrides.OverrideVerkle = &v
Expand Down
7 changes: 7 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ func loadBaseConfig(ctx *cli.Context) gethConfig {
if err := loadConfig(file, &cfg); err != nil {
utils.Fatalf("%v", err)
}
// some default options could be overwritten after `loadConfig()`
// apply the default value if the options are not specified in config.toml file.
ethconfig.ApplyDefaultEthConfig(&cfg.Eth)
}

scheme := cfg.Eth.StateScheme
Expand Down Expand Up @@ -209,6 +212,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
v := ctx.Uint64(utils.OverrideLorentz.Name)
cfg.Eth.OverrideLorentz = &v
}
if ctx.IsSet(utils.OverrideMaxwell.Name) {
v := ctx.Uint64(utils.OverrideMaxwell.Name)
cfg.Eth.OverrideMaxwell = &v
}
if ctx.IsSet(utils.OverrideVerkle.Name) {
v := ctx.Uint64(utils.OverrideVerkle.Name)
cfg.Eth.OverrideVerkle = &v
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ var (
utils.RialtoHash,
utils.OverridePassedForkTime,
utils.OverrideLorentz,
utils.OverrideMaxwell,
utils.OverrideVerkle,
utils.OverrideFullImmutabilityThreshold,
utils.OverrideMinBlocksForBlobRequests,
Expand Down
66 changes: 53 additions & 13 deletions cmd/jsutils/getchainstatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const provider = new ethers.JsonRpcProvider(program.rpc);
const addrValidatorSet = "0x0000000000000000000000000000000000001000";
const addrSlash = "0x0000000000000000000000000000000000001001";
const addrStakeHub = "0x0000000000000000000000000000000000002002";
const addrGovernor = "0x0000000000000000000000000000000000002004";

const validatorSetAbi = [
"function validatorExtraSet(uint256 offset) external view returns (uint256, bool, bytes)",
Expand All @@ -69,7 +70,12 @@ const validatorSetAbi = [
"function burnRatio() external view returns (uint256)", // default: 10%
"function systemRewardBaseRatio() external view returns (uint256)", // default: 1/16
];
const slashAbi = ["function getSlashIndicator(address validatorAddr) external view returns (uint256, uint256)"];
const slashAbi = [
"function getSlashIndicator(address validatorAddr) external view returns (uint256, uint256)",
"function misdemeanorThreshold() external view returns (uint256)",
"function felonyThreshold() external view returns (uint256)",
"function felonySlashScope() external view returns (uint256)",
];

// https://github.com/bnb-chain/bsc-genesis-contract/blob/master/contracts/StakeHub.sol
const stakeHubAbi = [
Expand All @@ -85,9 +91,15 @@ const stakeHubAbi = [
"function felonyJailTime() public view returns (uint256)", // default 30days,
];

const governorAbi = [
"function votingPeriod() public view returns (uint256)",
"function lateQuorumVoteExtension() public view returns (uint64)", // it represents minPeriodAfterQuorum
];

const validatorSet = new ethers.Contract(addrValidatorSet, validatorSetAbi, provider);
const slashIndicator = new ethers.Contract(addrSlash, slashAbi, provider);
const stakeHub = new ethers.Contract(addrStakeHub, stakeHubAbi, provider);
const governor = new ethers.Contract(addrGovernor, governorAbi, provider);

const validatorMap = new Map([
// BSC mainnet
Expand Down Expand Up @@ -136,6 +148,10 @@ const validatorMap = new Map([
["0xd849d1dF66bFF1c2739B4399425755C2E0fAbbAb", "Nexa"],
["0xA015d9e9206859c13201BB3D6B324d6634276534", "Star"],
["0x5ADde0151BfAB27f329e5112c1AeDeed7f0D3692", "Veri"],
["0xd6Ab358AD430F65EB4Aa5a1598FF2c34489dcfdE", "Saturn"],
["0x0dC5e1CAe4d364d0C79C9AE6BDdB5DA49b10A7d9", "ListaDAO"],
["0xE554F591cCFAc02A84Cf9a5165DDF6C1447Cc67D", "ListaDAO2"],
["0x059a8BFd798F29cE665816D12D56400Fa47DE028", "ListaDAO3"],
// Chapel
["0x08265dA01E1A65d62b903c7B34c08cB389bF3D99", "Ararat"],
["0x7f5f2cF1aec83bF0c74DF566a41aa7ed65EA84Ea", "Kita"],
Expand All @@ -160,6 +176,13 @@ const validatorMap = new Map([
["0xEe22F03961b407bCBae66499a029Be4cA0AF4ab4", "AB4"],
["0x1AE5f5C3Cb452E042b0B7b9DC60596C9CD84BaF6", "Jake"],
["0xfA4d592F9B152f7a10B5DE9bE24C27a74BCE431A", "MyTWFMM"],
["0x26Ba9aB44feb5D8eE47aDeaa46a472f71E50fbce", "Lime"],
["0xC8824e38440893b62CaDC4d1BD05e33895B25d74", "Skynet3k"],
["0x9a2da2Ce5Eda5E0b4914720c3A798521956E1009", "Musala"],
["0x9270fF2EaA8ef253B57011A5b7505D948784E2be", "Vihren"],
["0x86eb31b90566a9f4F3AB85138c78A000EBA81685", "GucciOp3k"],
["0x28D70c3756d4939DCBdEB3f0fFF5B4B36E6e327F", "OmegaV"],
["0x6a5470a3B7959ab064d6815e349eD4aE2dE5210d", "Skynet10k"],
]);

const builderMap = new Map([
Expand Down Expand Up @@ -553,27 +576,37 @@ async function getKeyParameters() {
numOfCabinets = 21;
}
// let maxNumOfCandidates = await validatorSet.maxNumOfCandidates({blockTag:blockNum}) // deprecated
// let turnLength = await validatorSet.turnLength({blockTag:blockNum})
let turnLength = await validatorSet.turnLength({blockTag:blockNum})
let maxNumOfWorkingCandidates = await validatorSet.maxNumOfWorkingCandidates({ blockTag: blockNum });
let maintainSlashScale = await validatorSet.maintainSlashScale({ blockTag: blockNum });
console.log(
"numOfCabinets",
Number(numOfCabinets),
"maxNumOfWorkingCandidates",
Number(maxNumOfWorkingCandidates),
"maintainSlashScale",
maintainSlashScale
);

// part 2: staking
console.log("##==== ValidatorContract: 0x0000000000000000000000000000000000001000");
console.log("\tturnLength", Number(turnLength));
console.log("\tnumOfCabinets", Number(numOfCabinets));
console.log("\tmaxNumOfWorkingCandidates", Number(maxNumOfWorkingCandidates));
console.log("\tmaintainSlashScale", Number(maintainSlashScale));

// part 2: slash
let misdemeanorThreshold = await slashIndicator.misdemeanorThreshold({blockTag:blockNum})
let felonyThreshold = await slashIndicator.felonyThreshold({blockTag:blockNum})
let felonySlashScope = await slashIndicator.felonySlashScope({blockTag:blockNum})
console.log("##==== SlashContract: 0x0000000000000000000000000000000000001001");
console.log("\tmisdemeanorThreshold", Number(misdemeanorThreshold));
console.log("\tfelonyThreshold", Number(felonyThreshold));
console.log("\tfelonySlashScope", Number(felonySlashScope));


// part 3: staking
// let minSelfDelegationBNB = await stakeHub.minSelfDelegationBNB({blockTag:blockNum})/BigInt(10**18)
let maxElectedValidators = await stakeHub.maxElectedValidators({ blockTag: blockNum });
let validatorElectionInfo = await stakeHub.getValidatorElectionInfo(0, 0, { blockTag: blockNum });
let consensusAddrs = validatorElectionInfo[0];
let votingPowers = validatorElectionInfo[1];
let voteAddrs = validatorElectionInfo[2];
let totalLength = validatorElectionInfo[3];
console.log("maxElectedValidators", Number(maxElectedValidators), "Registered", Number(totalLength));

console.log("\n##==== StakeHubContract: 0x0000000000000000000000000000000000002002")
console.log("\tmaxElectedValidators", Number(maxElectedValidators));
console.log("\tRegistered", Number(totalLength));
let validatorTable = [];
for (let i = 0; i < totalLength; i++) {
validatorTable.push({
Expand All @@ -585,6 +618,13 @@ async function getKeyParameters() {
}
validatorTable.sort((a, b) => b.votingPower - a.votingPower);
console.table(validatorTable);

// part 4: governance
let votingPeriod = await governor.votingPeriod({ blockTag: blockNum });
let minPeriodAfterQuorum = await governor.lateQuorumVoteExtension({ blockTag: blockNum });
console.log("\n##==== GovernorContract: 0x0000000000000000000000000000000000002004")
console.log("\tvotingPeriod", Number(votingPeriod));
console.log("\tminPeriodAfterQuorum", Number(minPeriodAfterQuorum));
}

// 9.cmd: "getEip7623", usage:
Expand Down
10 changes: 8 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ var (
Usage: "Manually specify the Lorentz fork timestamp, overriding the bundled setting",
Category: flags.EthCategory,
}
OverrideMaxwell = &cli.Uint64Flag{
Name: "override.maxwell",
Usage: "Manually specify the Maxwell fork timestamp, overriding the bundled setting",
Category: flags.EthCategory,
}
OverrideVerkle = &cli.Uint64Flag{
Name: "override.verkle",
Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting",
Expand Down Expand Up @@ -642,7 +647,7 @@ var (
MinerDelayLeftoverFlag = &cli.DurationFlag{
Name: "miner.delayleftover",
Usage: "Time reserved to finalize a block",
Value: ethconfig.Defaults.Miner.DelayLeftOver,
Value: *ethconfig.Defaults.Miner.DelayLeftOver,
Category: flags.MinerCategory,
}

Expand Down Expand Up @@ -1860,7 +1865,8 @@ func setMiner(ctx *cli.Context, cfg *minerconfig.Config) {
cfg.Recommit = ctx.Duration(MinerRecommitIntervalFlag.Name)
}
if ctx.IsSet(MinerDelayLeftoverFlag.Name) {
cfg.DelayLeftOver = ctx.Duration(MinerDelayLeftoverFlag.Name)
minerDelayLeftover := ctx.Duration(MinerDelayLeftoverFlag.Name)
cfg.DelayLeftOver = &minerDelayLeftover
}
if ctx.Bool(VotingEnabledFlag.Name) {
cfg.VoteEnable = true
Expand Down
2 changes: 1 addition & 1 deletion consensus/misc/eip4844/eip4844.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func CalcExcessBlobGas(config *params.ChainConfig, parent *types.Header, headTim
func CalcBlobFee(config *params.ChainConfig, header *types.Header) *big.Int {
var frac uint64
switch config.LatestFork(header.Time) {
case forks.Lorentz, forks.Prague:
case forks.Maxwell, forks.Lorentz, forks.Prague:
frac = config.BlobScheduleConfig.Prague.UpdateFraction
case forks.Cancun:
frac = config.BlobScheduleConfig.Cancun.UpdateFraction
Expand Down
4 changes: 4 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func (e *GenesisMismatchError) Error() string {
type ChainOverrides struct {
OverridePassedForkTime *uint64
OverrideLorentz *uint64
OverrideMaxwell *uint64
OverrideVerkle *uint64
}

Expand All @@ -288,6 +289,9 @@ func (o *ChainOverrides) apply(cfg *params.ChainConfig) error {
if o.OverrideLorentz != nil {
cfg.LorentzTime = o.OverrideLorentz
}
if o.OverrideMaxwell != nil {
cfg.MaxwellTime = o.OverrideMaxwell
}
if o.OverrideVerkle != nil {
cfg.VerkleTime = o.OverrideVerkle
}
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/prunedfreezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type prunedfreezer struct {
closeOnce sync.Once
}

// newNoDataFreezer creates a chain freezer that deletes data enough ‘old’.
// newPrunedFreezer creates a chain freezer that deletes data enough ‘old’.
func newPrunedFreezer(datadir string, db ethdb.KeyValueStore, offset uint64) (*prunedfreezer, error) {
if info, err := os.Lstat(datadir); !os.IsNotExist(err) {
if info.Mode()&os.ModeSymlink != 0 {
Expand Down
1 change: 1 addition & 0 deletions core/types/bid.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ type MevParams struct {
ValidatorCommission uint64 // 100 means 1%
BidSimulationLeftOver time.Duration
NoInterruptLeftOver time.Duration
MaxBidsPerBuilder uint32 // Maximum number of bids allowed per builder per block
GasCeil uint64
GasPrice *big.Int // Minimum avg gas price for bid block
BuilderFeeCeil *big.Int
Expand Down
4 changes: 4 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
chainConfig.LorentzTime = config.OverrideLorentz
overrides.OverrideLorentz = config.OverrideLorentz
}
if config.OverrideMaxwell != nil {
chainConfig.MaxwellTime = config.OverrideMaxwell
overrides.OverrideMaxwell = config.OverrideMaxwell
}
if config.OverrideVerkle != nil {
chainConfig.VerkleTime = config.OverrideVerkle
overrides.OverrideVerkle = config.OverrideVerkle
Expand Down
12 changes: 12 additions & 0 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ type Config struct {
// OverrideLorentz (TODO: remove after the fork)
OverrideLorentz *uint64 `toml:",omitempty"`

// OverrideMaxwell (TODO: remove after the fork)
OverrideMaxwell *uint64 `toml:",omitempty"`

// OverrideVerkle (TODO: remove after the fork)
OverrideVerkle *uint64 `toml:",omitempty"`

Expand All @@ -212,3 +215,12 @@ func CreateConsensusEngine(config *params.ChainConfig, db ethdb.Database, ee *et
}
return beacon.New(ethash.NewFaker()), nil
}

func ApplyDefaultEthConfig(cfg *Config) {
if cfg == nil {
log.Warn("ApplyDefaultEthConfig cfg == nil")
return
}

minerconfig.ApplyDefaultMinerConfig(&cfg.Miner)
}
6 changes: 6 additions & 0 deletions eth/ethconfig/gen_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/ethereum/go-ethereum/common/gopool"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
cmath "github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/core"
Expand Down Expand Up @@ -544,9 +543,9 @@ func (api *BlockChainAPI) getFinalizedNumber(ctx context.Context, verifiedValida
}
valLen := len(curValidators)
if verifiedValidatorNum == -1 {
verifiedValidatorNum = int64(cmath.CeilDiv(valLen, 2))
verifiedValidatorNum = int64(math.CeilDiv(valLen, 2))
} else if verifiedValidatorNum == -2 {
verifiedValidatorNum = int64(cmath.CeilDiv(valLen*2, 3))
verifiedValidatorNum = int64(math.CeilDiv(valLen*2, 3))
} else if verifiedValidatorNum == -3 {
verifiedValidatorNum = int64(valLen)
} else if verifiedValidatorNum < 1 || verifiedValidatorNum > int64(valLen) {
Expand Down
2 changes: 1 addition & 1 deletion metrics/exp/exp.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (exp *exp) publishResettingTimer(name string, metric *metrics.ResettingTime
}

func (exp *exp) publishLabel(name string, metric *metrics.Label) {
labels := metric.Value()
labels := metric.Snapshot().Value()
for k, v := range labels {
exp.getMap(name).Set(k, exp.interfaceToExpVal(v))
}
Expand Down
Loading