Skip to content

Private chain 21 validators#131

Open
Taranpreet26311 wants to merge 14 commits intobnb-chain:mainfrom
getoptimum:private-chain-21-validators
Open

Private chain 21 validators#131
Taranpreet26311 wants to merge 14 commits intobnb-chain:mainfrom
getoptimum:private-chain-21-validators

Conversation

@Taranpreet26311
Copy link
Copy Markdown

No description provided.

IsaacTai13 and others added 13 commits March 26, 2026 13:35
- set useLatestBscClinet to true to compile geth with latest geth on
  github
- xargs -r to ignore error if no previous geth found
Add Dockerfile and environment setup for BSC cluster
- cause in local Pebble take too much of my storage space
- allow monitoring access from the host machine via Docker port forwarding.
…ics_access

Feat/storage optimized and metrics access
* fix: prevent OOM kills by geth cache limit

- Without this, geth implicitly bumps the default cache to 4096MB when treating the setup as mainnet, which instantly exhausts Docker's memory limit (~8GB) when spinning up a 4-node local cluster.

* Add comments to clarify code logic

* feat: new script for docker spin up

- modify p2p address from localhost to use docker internal DNS name
- only handle geth initialization, but not start the node

* feat: implement dynamic compose generation

- Introduce `NODE_TYPE` and `NODE_INDEX` environment variables to uniquely identify each container and correctly mount its respective data dir (`.local/nodeX`).

* feat: add docker entrypoint for bsc cluster

- Makefile for lifecycle
- docker initialization script "node_entrypoint.sh" for booting geth
  based on node type (validator, sentry, fullnode)

* fix: redirect geth logs to docker stdout

forces Geth to output logs to standard output instead of local files, enabling docker's default logging driver to capture

* feat: optimize geth build cache

- Replaced `mv` with `cp` when extracting the compiled geth binary.
  prevent redundant rebuilds.
- Removed unused `exit_previous` func
- Add cluster-restart for fast restart without wiping blockchain data or
  trigger re-initialization.

* docs: update readme with sequence diagram
…on flow (#5)

Improves the BSC load test environment, including validator registration automation and protocol alignment.
It ensures the BSC cluster can work smoothly with the load tester.
Add patch_for_private_chain() that pushes Plato/Luban to block 100M and
disables post-Plato time-based forks for genesis. Required for private
chains with more validators than the default 4-validator setup, where
fast-finality (BEP-126) panics during reorg at parlia/snapshot.go:411
when DoubleSign forks occur at block 2 due to multi-validator startup
race conditions on a WAN.

Also sort validators by consensusAddr ascending in validators.template
so genesis extraData matches Parlia's snapshot.validators() ordering
(otherwise block 1 sealing fails with "unauthorized validator" because
in-turn calculation uses sorted-ascending while extraData was unsorted).

Replace forge install --no-git with direct git clone of forge-std,
because forge install fails when the parent directory is itself a git
repo (submodule path lookup fails for forge-std's ds-test).

Toggle: DISABLE_FAST_FINALITY=true (default) applies the patches.
Set DISABLE_FAST_FINALITY=false in .env to preserve upstream 4-validator
behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 5, 2026

Pull Request Review

This PR introduces a Docker-first workflow for running a local/private BSC cluster, adding new infrastructure files (Dockerfile, Makefile, docker_cluster.sh, node_entrypoint.sh, and compose generation flow) and extending the README with end-to-end operational instructions. It also updates .env defaults for containerized execution (RPC host, fork timing, and latest BSC client build), and modifies startup behavior to expose RPC/WS/metrics/pprof endpoints broadly. In addition, the cluster/genesis preparation path now includes private-chain patching logic to delay/disable fast-finality-related forks for larger validator sets.

Sensitive Content

Blockchain Address:

  • 0x04d63aBCd2b9b1baa327f2Dda0f873F197ccd186 (Ethereum/BSC-style address) in .env and referenced by scripts — used as INIT_HOLDER/protector address

Security Issues

🔴 [CRITICAL] Unrestricted debug/telemetry exposure (pprof and metrics bound to 0.0.0.0)

File: bsc_cluster.sh, node_entrypoint.sh
The PR changes --metrics.addr and --pprof.addr from localhost to 0.0.0.0, and generated compose files publish these ports to the host. Exposed pprof endpoints can leak runtime internals and may enable denial-of-service or sensitive operational data disclosure; exposed metrics can leak node/state/network details useful for targeted attacks.
Recommendation: Bind metrics/pprof to 127.0.0.1 (or internal Docker network only), avoid publishing these ports externally by default, and gate any remote access behind firewall/authenticated proxy.

🔴 [CRITICAL] Insecure RPC configuration enables dangerous account operations over network

File: bsc_cluster.sh, node_entrypoint.sh
Nodes are started with --http.addr 0.0.0.0, --ws.addr 0.0.0.0, --allow-insecure-unlock, and permissive CORS (--http.corsdomain "*") while ports are exposed via Docker. This combination can permit remote abuse paths (including unauthorized transaction signing/unlock misuse depending on API exposure), representing a high-risk remote-compromise pattern.
Recommendation: Remove --allow-insecure-unlock, bind RPC/WS to localhost or private interfaces, restrict CORS origins, and ensure sensitive RPC namespaces are disabled unless strictly needed.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

… fix

The BNB Chain team confirmed the >9-validator fast-finality panic at
consensus/parlia/snapshot.go:411 and pushed a fix to the
'skip-execution' branch on bnb-chain/bsc:
https://github.com/bnb-chain/bsc/tree/skip-execution

Add BSC_GETH_BRANCH env var (default 'master') to control which bsc
branch prepare_bsc_client() builds. Use 'BSC_GETH_BRANCH=skip-execution'
to pull the fix. Once that branch lands in master, this can be reverted
to default.

Also handle the case where /workspace/bsc/Makefile already exists (from
a previous build) by fetching+checking out the requested branch instead
of just running git pull on whatever branch was already checked out.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 6, 2026

Pull Request Review

This PR introduces a full Docker-based workflow for running a local multi-validator BSC cluster, including a new Dockerfile, Makefile orchestration commands, dynamic docker-compose.cluster.yml generation, and a dedicated docker_cluster.sh preparation/registration pipeline. It also updates runtime behavior in .env and cluster scripts to support private-chain operation tweaks (e.g., hardfork timing overrides, optional latest BSC client builds, and fast-finality patching for larger validator sets). Additionally, node startup settings were changed to expose RPC/metrics/pprof interfaces more broadly and improve containerized observability/logging.

Sensitive Content

Blockchain Address:

  • 0x04d63aBCd2b9b1baa327f2Dda0f873F197ccd186 (Ethereum/BSC-style address) in .env and referenced by scripts/README — used as INIT_HOLDER/protector address

Security Issues

🔴 [CRITICAL] Unauthenticated debug and metrics endpoints exposed on all interfaces

File: bsc_cluster.sh, node_entrypoint.sh, generated docker-compose.cluster.yml behavior
The PR changes --metrics.addr and --pprof.addr from localhost to 0.0.0.0, and publishes these ports via Docker mappings. This exposes Go pprof and node metrics endpoints externally, which can leak sensitive runtime internals and in some deployments enable denial-of-service via profiling/debug surfaces.
Recommendation: Bind pprof/metrics to loopback (127.0.0.1) or internal Docker network only, and avoid publishing these ports publicly unless protected by firewall/authentication.

🔴 [CRITICAL] Node HTTP/WS RPC exposed with insecure unlock settings

File: bsc_cluster.sh, node_entrypoint.sh
Nodes are launched with --http.addr 0.0.0.0, --ws.addr 0.0.0.0, --allow-insecure-unlock, and --rpc.allow-unprotected-txs, while host ports are published. This combination significantly increases risk of unauthorized transaction submission/signing abuse if reachable outside trusted local environments.
Recommendation: Restrict RPC/WS bind addresses to trusted interfaces, remove --allow-insecure-unlock and --rpc.allow-unprotected-txs unless strictly required, and enforce API/module allowlists plus network ACLs.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants