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

Merge bsc upstrem #4

Merged
merged 62 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
727c071
cmd/jsutils: add a tool to get performance between a range of blocks …
NathanBSC Jun 28, 2024
f1a85ec
go.mod: update missing dependency (#2546)
zzzckck Jun 28, 2024
51e27f9
nancy: ignore [email protected] in .nancy-ignore (#2559)
zzzckck Jul 2, 2024
88225c1
chore: update greenfield cometbft version (#2556)
keefel Jul 3, 2024
971c0fa
tests: fix unstable test (#2561)
MatusKysel Jul 4, 2024
a5810fe
fix: fix state inspect error after pruned state (#2557)
flywukong Jul 4, 2024
bc970e5
fix: delete unexpected block (#2562)
jingjunLi Jul 8, 2024
e8456c2
cmd/jsutils: add a tool to get slash count (#2569)
zlacfzy Jul 8, 2024
90e6797
core: clearup testflag for Cancun and Haber (#2572)
NathanBSC Jul 9, 2024
863fdea
core: avoid to cache block before wroten into db (#2566)
buddh0 Jul 10, 2024
a00ffa7
fix: fix statedb copy (#2567)
will-2012 Jul 10, 2024
c3d6155
cmd/utils: support use NetworkId to distinguish chapel when do syncin…
NathanBSC Jul 10, 2024
a04e287
feat: enhance bid comparison and reply bidding results && detail logs…
Jolly23 Jul 11, 2024
27d8694
core: adapt highestVerifiedHeader to FastFinality (#2574)
buddh0 Jul 11, 2024
c96fab0
core/vote: not vote if too late for next in turn validator (#2568)
NathanBSC Jul 11, 2024
21fc2d3
cmd/jsutill: add log about validator name (#2583)
zlacfzy Jul 16, 2024
d35b57a
chore: fix some comments (#2581)
stellrust Jul 16, 2024
6d5b4ad
miner/worker: broadcast block immediately once sealed (#2576)
buddh0 Jul 16, 2024
c6af481
freezer: Opt freezer env checking (#2580)
galaio Jul 16, 2024
13d4547
fix: pruneancient freeze from the previous position when the first ti…
jingjunLi Jul 16, 2024
87e622e
fix: the bug of blobsidecars and downloader with multi-database (#2564)
jingjunLi Jul 16, 2024
a262acf
fix: remove delete and dangling side chains in prunefreezer (#2582)
jingjunLi Jul 17, 2024
21e6dcf
release: prepare for release v1.4.12 (#2585)
zzzckck Jul 17, 2024
900cf26
Merge branch 'master' into master_2_develop
zzzckck Jul 17, 2024
26b236f
Merge pull request #2586 from bnb-chain/master_2_develop
zzzckck Jul 17, 2024
74078e1
consensus/parlia: add GetJustifiedNumber and GetFinalizedNumber (#2591)
buddh0 Jul 19, 2024
7b8d28b
core/vote: vote before committing state and writing block (#2589)
buddh0 Jul 19, 2024
4f38c78
BEP-402: Complete Missing Fields in Block Header to Generate Signatur…
buddh0 Jul 19, 2024
3cade73
BEP-404: Clear Miner History when Switching Validators Set (#2558)
buddh0 Jul 19, 2024
b844958
core: improve the network stability when double sign happens (#2596)
buddh0 Jul 22, 2024
222e108
core: cache block after wroten into db
NathanBSC Jul 22, 2024
c6cb43b
Revert "miner/worker: broadcast block immediately once sealed (#2576)"
NathanBSC Jul 22, 2024
a44b6d8
core: cache block after wroten into db (#2600)
NathanBSC Jul 22, 2024
6260a26
fix: prune-state when specify `--triesInMemory 32` (#2602)
jingjunLi Jul 23, 2024
17e0e45
BEP-341: Validators can produce consecutive blocks (#2482)
NathanBSC Jul 23, 2024
cabd0f8
feat: add bohr upgrade contracts bytecode (#2605)
cosinlink Jul 24, 2024
99e4e95
Merge branch 'master' into develop
buddh0 Jul 25, 2024
3134494
consensus/parlia: modify mining time for last block in one turn (#2608)
NathanBSC Jul 25, 2024
7f3c5ce
cmd/utils: add new flag OverridePassedForkTime (#2611)
buddh0 Jul 25, 2024
c94fc29
Merge pull request #2612 from buddh0/merge_master_into_develop
zzzckck Jul 25, 2024
f532da6
chore: fix some comments (#2597)
yuhangcangqian Jul 25, 2024
46b88d1
fix: only take non-mempool tx to calculate bid price (#2579)
irrun Jul 26, 2024
27f618f
fix: update stakehub bytecode after zero address agent issue fixed (#…
cosinlink Jul 26, 2024
00cac12
faucet: rate limit initial implementation (#2603)
emailtovamos Jul 29, 2024
7d90701
tests: fix evm-test CI (#2622)
NathanBSC Jul 31, 2024
987b8c1
consensus/parlia: exclude inturn validator when calculate backoffTime…
NathanBSC Jul 31, 2024
9e34366
core: not record `zero hash` beacon block root with Parlia engine (#2…
NathanBSC Jul 31, 2024
df16ab9
Makefile: use docker compose v2 instead of v1 (#2628)
buddh0 Aug 5, 2024
b61128b
utils: add GetTopAddr to analyse large traffic (#2629)
zzzckck Aug 5, 2024
b7e678e
config: setup Testnet Bohr hardfork date (#2634)
zzzckck Aug 7, 2024
2cce9dd
release: prepare for release v1.4.13 (#2632)
zzzckck Aug 7, 2024
e988d15
consensus/parlia: support recovery when snapshot of parlia gone in di…
buddh0 Aug 8, 2024
b1f0a3c
core: fix cache for receipts (#2643)
buddh0 Aug 13, 2024
3adcfab
core/systemcontracts: use vm.StateDB in UpgradeBuildInSystemContract …
easyfold Aug 13, 2024
99a2dd5
internal/debug: remove memsize (#2649)
buddh0 Aug 15, 2024
5d19f21
internal/ethapi: make GetFinalizedHeader monotonically increasing (#2…
buddh0 Aug 20, 2024
3bd9a23
core: improve readability of the fork choice logic (#2658)
buddh0 Aug 20, 2024
6cb4be4
fix: when dataset is pruned and pruneancient is set, the offset is er…
jingjunLi Aug 21, 2024
c46d7e8
ethclient: fix BlobSidecars api (#2656)
jhgdike Aug 22, 2024
ec2d7e0
config: setup Mainnet 2 hardfork date: HaberFix & Bohr (#2661)
zzzckck Aug 23, 2024
86406c0
release: prepare for release v1.4.14
zzzckck Aug 27, 2024
d72682e
feat: merge bsc upstream
alexgao001 Aug 28, 2024
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
37 changes: 0 additions & 37 deletions .github/workflows/nancy.yml

This file was deleted.

1 change: 1 addition & 0 deletions .nancy-ignore
Original file line number Diff line number Diff line change
@@ -1 +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 [email protected], it is only used in cmd devp2p, impact is limited. will upgrade to v0.7.7 later
1,083 changes: 0 additions & 1,083 deletions CHANGELOG.md

This file was deleted.

10 changes: 0 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ all:
test: all
$(GORUN) build/ci.go test -timeout 1h

truffle-test:
docker build . -f ./docker/Dockerfile --target bsc-genesis -t bsc-genesis
docker build . -f ./docker/Dockerfile --target bsc -t bsc
docker build . -f ./docker/Dockerfile.truffle -t truffle-test
docker-compose -f ./tests/truffle/docker-compose.yml up genesis
docker-compose -f ./tests/truffle/docker-compose.yml up -d bsc-rpc bsc-validator1
sleep 30
docker-compose -f ./tests/truffle/docker-compose.yml up --exit-code-from truffle-test truffle-test
docker-compose -f ./tests/truffle/docker-compose.yml down

#? lint: Run certain pre-selected linters
lint: ## Run linters.
$(GORUN) build/ci.go lint
Expand Down
108 changes: 0 additions & 108 deletions cmd/extradump/extradump_test.go

This file was deleted.

16 changes: 15 additions & 1 deletion cmd/extradump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
BLSPublicKeyLength = 48

// follow order in extra field
// |---Extra Vanity---|---Validators Number and Validators Bytes (or Empty)---|---Vote Attestation (or Empty)---|---Extra Seal---|
// |---Extra Vanity---|---Validators Number and Validators Bytes (or Empty)---|---Turn Length (or Empty)---|---Vote Attestation (or Empty)---|---Extra Seal---|
extraVanityLength = 32 // Fixed number of extra-data prefix bytes reserved for signer vanity
validatorNumberSize = 1 // Fixed number of extra prefix bytes reserved for validator number after Luban
validatorBytesLength = common.AddressLength + types.BLSPublicKeyLength
Expand All @@ -35,6 +35,7 @@ type Extra struct {
ExtraVanity string
ValidatorSize uint8
Validators validatorsAscending
TurnLength *uint8
*types.VoteAttestation
ExtraSeal []byte
}
Expand Down Expand Up @@ -113,6 +114,15 @@ func parseExtra(hexData string) (*Extra, error) {
sort.Sort(extra.Validators)
data = data[validatorBytesTotalLength-validatorNumberSize:]
dataLength = len(data)

// parse TurnLength
if dataLength > 0 {
if data[0] != '\xf8' {
extra.TurnLength = &data[0]
data = data[1:]
dataLength = len(data)
}
}
}

// parse Vote Attestation
Expand Down Expand Up @@ -148,6 +158,10 @@ func prettyExtra(extra Extra) {
}
}

if extra.TurnLength != nil {
fmt.Printf("TurnLength : %d\n", *extra.TurnLength)
}

if extra.VoteAttestation != nil {
fmt.Printf("Attestation :\n")
fmt.Printf("\tVoteAddressSet : %b, %d\n", extra.VoteAddressSet, bitset.From([]uint64{uint64(extra.VoteAddressSet)}).Count())
Expand Down
65 changes: 47 additions & 18 deletions cmd/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/gorilla/websocket"
"golang.org/x/time/rate"
)

var (
Expand Down Expand Up @@ -216,6 +217,8 @@ type faucet struct {

bep2eInfos map[string]bep2eInfo
bep2eAbi abi.ABI

limiter *IPRateLimiter
}

// wsConn wraps a websocket connection with a write mutex as the underlying
Expand All @@ -235,6 +238,12 @@ func newFaucet(genesis *core.Genesis, url string, ks *keystore.KeyStore, index [
return nil, err
}

// Allow 1 request per minute with burst of 5, and cache up to 1000 IPs
limiter, err := NewIPRateLimiter(rate.Limit(1.0), 5, 1000)
if err != nil {
return nil, err
}

return &faucet{
config: genesis.Config,
client: client,
Expand All @@ -245,6 +254,7 @@ func newFaucet(genesis *core.Genesis, url string, ks *keystore.KeyStore, index [
update: make(chan struct{}, 1),
bep2eInfos: bep2eInfos,
bep2eAbi: bep2eAbi,
limiter: limiter,
}, nil
}

Expand Down Expand Up @@ -272,6 +282,20 @@ func (f *faucet) webHandler(w http.ResponseWriter, r *http.Request) {

// apiHandler handles requests for Ether grants and transaction statuses.
func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
ip := r.RemoteAddr
if len(r.Header.Get("X-Forwarded-For")) > 0 {
ips := strings.Split(r.Header.Get("X-Forwarded-For"), ",")
if len(ips) > 0 {
ip = strings.TrimSpace(ips[len(ips)-1])
}
}

if !f.limiter.GetLimiter(ip).Allow() {
log.Warn("Too many requests from client: ", "client", ip)
http.Error(w, "Too many requests", http.StatusTooManyRequests)
return
}

upgrader := websocket.Upgrader{CheckOrigin: func(r *http.Request) bool { return true }}
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
Expand Down Expand Up @@ -625,24 +649,27 @@ func (f *faucet) loop() {
balance := new(big.Int).Div(f.balance, ether)

for _, conn := range f.conns {
if err := send(conn, map[string]interface{}{
"funds": balance,
"funded": f.nonce,
"requests": f.reqs,
}, time.Second); err != nil {
log.Warn("Failed to send stats to client", "err", err)
conn.conn.Close()
continue
}
if err := send(conn, head, time.Second); err != nil {
log.Warn("Failed to send header to client", "err", err)
conn.conn.Close()
}
go func(conn *wsConn) {
if err := send(conn, map[string]interface{}{
"funds": balance,
"funded": f.nonce,
"requests": f.reqs,
}, time.Second); err != nil {
log.Warn("Failed to send stats to client", "err", err)
conn.conn.Close()
return // Exit the goroutine if the first send fails
}

if err := send(conn, head, time.Second); err != nil {
log.Warn("Failed to send header to client", "err", err)
conn.conn.Close()
}
}(conn)
}
f.lock.RUnlock()
}
}()
// Wait for various events and assing to the appropriate background threads
// Wait for various events and assign to the appropriate background threads
for {
select {
case head := <-heads:
Expand All @@ -656,10 +683,12 @@ func (f *faucet) loop() {
// Pending requests updated, stream to clients
f.lock.RLock()
for _, conn := range f.conns {
if err := send(conn, map[string]interface{}{"requests": f.reqs}, time.Second); err != nil {
log.Warn("Failed to send requests to client", "err", err)
conn.conn.Close()
}
go func(conn *wsConn) {
if err := send(conn, map[string]interface{}{"requests": f.reqs}, time.Second); err != nil {
log.Warn("Failed to send requests to client", "err", err)
conn.conn.Close()
}
}(conn)
}
f.lock.RUnlock()
}
Expand Down
44 changes: 44 additions & 0 deletions cmd/faucet/rate_limiter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package main

import (
lru "github.com/hashicorp/golang-lru"
"golang.org/x/time/rate"
)

type IPRateLimiter struct {
ips *lru.Cache // LRU cache to store IP addresses and their associated rate limiters
r rate.Limit // the rate limit, e.g., 5 requests per second
b int // the burst size, e.g., allowing a burst of 10 requests at once. The rate limiter gets into action
// only after this number exceeds
}

func NewIPRateLimiter(r rate.Limit, b int, size int) (*IPRateLimiter, error) {
cache, err := lru.New(size)
if err != nil {
return nil, err
}

i := &IPRateLimiter{
ips: cache,
r: r,
b: b,
}

return i, nil
}

func (i *IPRateLimiter) addIP(ip string) *rate.Limiter {
limiter := rate.NewLimiter(i.r, i.b)

i.ips.Add(ip, limiter)

return limiter
}

func (i *IPRateLimiter) GetLimiter(ip string) *rate.Limiter {
if limiter, exists := i.ips.Get(ip); exists {
return limiter.(*rate.Limiter)
}

return i.addIP(ip)
}
Loading
Loading