A high-performance Byzantine Fault Tolerant (BFT) consensus implementation based on QBFT, built on top of Reth. This implementation includes a native ETH-wrapping ERC20 contract and comprehensive testing infrastructure.
- QBFT Consensus: Standards-compliant QBFT implementation with RLPx peer-to-peer networking
- Reth Integration: Built on Reth for high-performance block execution
- Native ERC20: QBFTErc20 contract that wraps native ETH balances
- Dynamic Validators: Add/remove validators through smart contract interactions
- Comprehensive Testing: Automated testnet with transaction load testing and contract verification
- Rust 1.93 or later (with nightly for formatting)
- Git
- Make
- Linux or macOS (Windows via WSL)
- Clone the repository:
git clone https://github.com/raylsnetwork/rbft.git
cd rbft- Build the project:
cargo build --releaseStart a 4-node testnet with a single command:
make testnet_startThis will:
- Generate validator keys and genesis configuration
- Start 4 validator nodes (HTTP ports 8545-8548)
- Deploy the QBFTValidatorSet contract
- Begin producing blocks every 500ms
The nodes will log to ~/.rbft/testnet/logs/ and store data in ~/.rbft/testnet/db/.
Cast is a useful tool for interacting with the blockchain:
curl -L https://foundry.paradigm.xyz | bash
foundryupVerify installation:
cast --versionThe testnet command will show the block heights of the nodes in the validator set and should increase at a rate of around two blocks a second.
Switch to another terminal to interact with the chain via commands.
Using cast
cast bnUsing curl:
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'For local testing, provide a dev-only key via environment variable:
export RBFT_ADMIN_KEY=0x<dev-private-key>To derive the corresponding address:
cast wallet address --private-key "$RBFT_ADMIN_KEY"Send ETH using cast:
cast send 0x1234567890123456789012345678901234567890 \
--value 1ether \
--private-key "$RBFT_ADMIN_KEY" \
--rpc-url http://localhost:8545cast balance 0x<address-derived-from-RBFT_ADMIN_KEY>Or with curl:
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf", "latest"],
"id": 1
}'Run make help to see all available commands:
testnet_start- Start a local testnet (default: 4 nodes)testnet_load_test- Start testnet with transaction load testing and auto-exittest-erc20-contract- Test ERC20 contract (funds, mints, verifies balanceOf)genesis- Generate a genesis filevalidator_status- Display QBFTValidatorSet contract statusadd-validator- Add a test validator to the contract
Manages the validator set with features:
- Add/remove validators (admin only)
- Query active validators
- Epoch-based validator set updates
Contract address: 0x0000000000000000000000000000000000001001
cargo testmake testnet_load_testThis starts a testnet with automated transaction generation and exits after reaching a target block height.
make test-erc20-contractThis runs automated tests that:
- Fund the ERC20 contract
- Mint tokens to a test address
- Verify
balanceOf()matches native balance - Exit with success/failure status
- Rust formatting is enforced with
cargo +nightly fmt(100 column width viarustfmt.toml) - CI runs
scripts/check_line_length.pyto cap code/config lines at 100 characters - Pre-commit hooks available for local validation:
pip install pre-commit pre-commit install
┌─────────────────┐
│ RPC Interface │ (HTTP on ports 8545+)
└────────┬────────┘
│
┌────────▼────────┐
│ Reth Engine │ (Block execution, state management)
└────────┬────────┘
│
┌────────▼────────┐
│ RBFT Consensus │ (QBFT protocol, validator rotation)
└────────┬────────┘
│
┌────────▼────────┐
│ RLPx Network │ (P2P messaging between validators)
└─────────────────┘
Configure the testnet with environment variables:
RBFT_NUM_NODES- Number of validators (default: 4)RBFT_EXIT_AFTER_BLOCK- Exit testnet after reaching this blockRBFT_TEST_ERC20- Enable ERC20 contract testing at block 10RBFT_RUN_MEGATX- Run transaction load generatorRBFT_ADD_AT_BLOCKS- Add validators at specific blocks (e.g., "10,20,30")RBFT_REGISTRY- Container registry for Docker images (required formake docker-push)
Example:
RBFT_NUM_NODES=7 RBFT_EXIT_AFTER_BLOCK=100 make testnet_startWe welcome contributions! Please see CONTRIBUTING.md for guidelines on:
- Code style and formatting
- Testing requirements
- Pull request process
- Development workflow
This project is licensed under the Apache License, Version 2.0. See LICENSE.md for details.
This project incorporates or derives from the following third-party works:
| Dependency | License | Copyright |
|---|---|---|
| reth | Apache-2.0 OR MIT | Copyright (c) 2022–2024 Paradigm |
| OpenZeppelin Contracts | MIT | Copyright (c) 2016–2024 OpenZeppelin |
Full license texts for these dependencies are available in their respective
repositories or in the target/forge_dependencies/ directory.
- IBFT Paper — The Istanbul BFT Consensus Algorithm
- QBFT Formal Specification (ConsenSys)
- Monitoring Setup
- Open an issue on GitHub
- Read the documentation
Note: This is a development build. Do not use in production without thorough security auditing.