This repository contains smart contracts for bribery attacks in Ethereum's Proof-of-Stake consensus mechanism. The project implements multiple types of bribery attacks to conduct research on their efficiency. eprint
This project explores potential vulnerabilities in Ethereum's consensus layer by implementing various bribery attack vectors:
- PayToExit: Incentivizes validators to voluntarily exit the network
- PayToAttest: Bribes validators to attest to specific beacon chain data
- PayToBias: Manipulates RANDAO randomness by incentivizing specific validator behavior
src/
├── IBribe.sol # Unified bribery interface
├── PayToExit.sol # Validator exit bribery attacks
├── PayToAttest.sol # Attestation manipulation attacks
├── PayToBias.sol # RANDAO randomness manipulation
├── BLSVerify.sol # BLS signature verification utilities
├── HeaderVerify.sol # Block header verification utilities
└── Utils.sol # Common utility functions
test/
├── PayToExit.t.sol # Exit bribery tests
├── PayToAttest.t.sol # Attestation tests
├── PayToBias.t.sol # RANDAO bias tests
├── BLSVerify.t.sol # BLS verification tests
├── HeaderVerify.t.sol # Header verification tests
└── BLSVerifyGas.t.sol # Gas optimization tests
- Foundry (latest version)
- Git
- Python 3.8+
-
Clone the repository:
git clone https://github.com/0xSooki/bribery-zoo.git cd bribery-zoo -
Install dependencies:
git submodule update --init --recursive forge install
-
Build the contracts:
forge build
-
Run tests:
forge test
The project includes test coverage.
forge testforge test --gas-reportforge test --match-contract PayToExitTest
forge test --match-contract PayToAttestTest
forge test --match-contract PayToBiasTestforge test --match-test testWithGeneratedData-
Start a local Ethereum node:
anvil
-
Deploy contracts (in a new terminal):
# Deploy BLS verification library first forge create src/BLSVerify.sol:BLSVerify \ --rpc-url http://localhost:8545 \ --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 # Deploy PayToExit (replace BLS_ADDRESS with actual deployed address) forge create src/PayToExit.sol:PayToExit \ --constructor-args "BLS_ADDRESS" \ --rpc-url http://localhost:8545 \ --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
For testnet deployment, update the RPC URL and private key:
# Example for Sepolia testnet
forge create src/BLSVerify.sol:BLSVerify \
--rpc-url https://rpc.sepolia.org \
--private-key YOUR_PRIVATE_KEY \
--verify --etherscan-api-key YOUR_ETHERSCAN_API_KEY
# Deploy other contracts with BLS address
forge create src/PayToExit.sol:PayToExit \
--constructor-args "DEPLOYED_BLS_ADDRESS" \
--rpc-url https://rpc.sepolia.org \
--private-key YOUR_PRIVATE_KEY \
--verify --etherscan-api-key YOUR_ETHERSCAN_API_KEYCreate a deployment script in script/Deploy.s.sol:
Run with:
forge script script/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast