|
1 | 1 | # Rollup BSN Contracts
|
2 | 2 |
|
3 |
| -This repo contains the Wasm smart contract for rollup BSN integration. The |
4 |
| -contract is intended to be deployed on Babylon Genesis and will maintain |
5 |
| -finality signatures and block finalisation status of rollups. |
6 |
| - |
7 |
| -## Specification |
8 |
| - |
9 |
| -For detailed technical specifications and requirements of the finality contract, |
10 |
| -please see [SPEC.md](docs/SPEC.md). The spec document outlines the contract's |
11 |
| -interfaces, message handlers, queries, and provides guidance for integrators. |
12 |
| - |
13 |
| -## Development |
| 3 | +**Bitcoin-secured finality for rollups through Babylon's Bitcoin staking |
| 4 | +protocol.** |
| 5 | + |
| 6 | +This repository contains the finality contract that enables Ethereum Rollups to |
| 7 | +become Bitcoin Supercharged Networks (BSNs) by inheriting Bitcoin's economic |
| 8 | +security through Babylon's staking infrastructure. |
| 9 | + |
| 10 | +## What is Rollup BSN? |
| 11 | + |
| 12 | +**Bitcoin Supercharged Networks (BSNs)** are blockchain networks that leverage |
| 13 | +Bitcoin's economic security through Babylon's Bitcoin staking protocol. BSNs |
| 14 | +enhance their security by tapping into Bitcoin's massive economic security, |
| 15 | +where Bitcoin stakers delegate their BTC to provide cryptographic attestations |
| 16 | +for network finality. |
| 17 | + |
| 18 | +### How It Works |
| 19 | + |
| 20 | +1. **Deploy Contract** - Deploy this finality contract on Babylon Genesis chain |
| 21 | +2. **Register BSN** - Register your rollup as a Bitcoin Supercharged Network |
| 22 | +3. **BTC Delegation** - Bitcoin stakers delegate their BTC to finality providers |
| 23 | +4. **Block Finalization** - Finality providers sign rollup blocks and submit |
| 24 | + signatures to the contract |
| 25 | +5. **Cross-Chain Security** - Your rollup inherits Bitcoin's economic security |
| 26 | + through Babylon's infrastructure |
| 27 | + |
| 28 | +The finality contract acts as the bridge between your rollup and Babylon's |
| 29 | +Bitcoin staking protocol, maintaining an immutable record of block finalization |
| 30 | +and ensuring finality providers remain honest through economic incentives. |
| 31 | + |
| 32 | +> **Note:** To read finalized data from contracts on Babylon Genesis, you should |
| 33 | +> use an already built off-chain service or build your own. We have a |
| 34 | +> proof-of-concept available at |
| 35 | +> [rollup-finality-gadget](https://github.com/babylonlabs-io/rollup-finality-gadget). |
| 36 | +> |
| 37 | +> **Learn More:** To understand how finality providers work and how to become one, |
| 38 | +> visit the [finality-provider repository](https://github.com/babylonlabs-io/finality-provider). |
| 39 | +
|
| 40 | +### Security Through Cryptography |
| 41 | + |
| 42 | +The system uses **EOTS (Extractable One-Time Signatures)** to ensure finality |
| 43 | +provider honesty: |
| 44 | + |
| 45 | +- **Public Randomness Commitment** - Finality providers pre-commit to randomness |
| 46 | + values they'll use for signing |
| 47 | +- **Block Finality Signatures** - Finality providers sign rollup block data |
| 48 | + using their private keys |
| 49 | +- **One-Time Signatures** - Each signature uses unique randomness and can only |
| 50 | + be used once safely |
| 51 | +- **Automatic Slashing** - If a provider signs two different blocks at the same |
| 52 | + height (double-signing), the contract automatically extracts their private key |
| 53 | + and triggers slashing |
| 54 | + |
| 55 | +## Repository Structure |
| 56 | + |
| 57 | +- **`contracts/finality/`** - Core finality contract implementing BSN |
| 58 | + integration |
| 59 | +- **`docs/`** - Comprehensive technical specifications and guides |
| 60 | +- **`e2e/`** - End-to-end integration tests |
| 61 | +- **`scripts/`** - Development and deployment utilities |
| 62 | + |
| 63 | +## Quick Start |
14 | 64 |
|
15 | 65 | ### Prerequisites
|
16 | 66 |
|
17 |
| -Make sure you have `cargo-run-script` installed and docker running. |
18 |
| - |
19 | 67 | ```bash
|
| 68 | +# Install dependencies |
20 | 69 | cargo install cargo-run-script
|
21 | 70 | ```
|
22 | 71 |
|
23 |
| -### Clean the build |
24 |
| - |
25 |
| -```bash |
26 |
| -cargo clean |
27 |
| -``` |
28 |
| - |
29 |
| -### Build the contract |
| 72 | +### Build & Test |
30 | 73 |
|
31 | 74 | ```bash
|
| 75 | +# Build the contract |
32 | 76 | cargo build
|
33 |
| -``` |
34 |
| - |
35 |
| -### Formatting and Linting |
36 |
| - |
37 |
| -Check whether the code is formatted correctly. |
38 |
| - |
39 |
| -```bash |
40 |
| -cargo fmt --all -- --check |
41 |
| -cargo check |
42 |
| -cargo clippy --all-targets -- -D warnings |
43 |
| -``` |
44 |
| - |
45 |
| -Alternatively, you can run the following command to run all the checks at once. |
46 |
| - |
47 |
| -```bash |
48 |
| -cargo run-script lint |
49 |
| -``` |
50 | 77 |
|
51 |
| -### Build the optimized contract |
| 78 | +# Run tests |
| 79 | +cargo test --lib |
52 | 80 |
|
53 |
| -```bash |
| 81 | +# Build optimized version for deployment |
54 | 82 | cargo run-script optimize
|
55 | 83 | ```
|
56 | 84 |
|
57 |
| -## Tests |
| 85 | +### Deploy to Babylon |
58 | 86 |
|
59 |
| -### Unit tests |
| 87 | +1. **Upload Contract**: Deploy WASM bytecode to Babylon Genesis |
| 88 | +2. **Instantiate**: Configure your BSN parameters |
| 89 | +3. **Register BSN**: Register with Babylon's consumer registry |
| 90 | +4. **Go Live**: Start accepting finality signatures from Finality Providers |
60 | 91 |
|
61 |
| -Note: Requires the optimized contract to be built (`cargo optimize`) |
| 92 | +See our [Contract Management Guide](docs/contract-management.md) for detailed |
| 93 | +deployment instructions. |
62 | 94 |
|
63 |
| -Runs all the CI checks locally (in your actual toolchain). |
| 95 | +## Development Commands |
64 | 96 |
|
65 | 97 | ```bash
|
66 |
| -cargo test --lib |
67 |
| -``` |
| 98 | +# Linting & formatting |
| 99 | +cargo run-script lint |
68 | 100 |
|
69 |
| -### Integration tests |
| 101 | +# Integration tests (requires optimized build) |
| 102 | +cargo run-script integration |
70 | 103 |
|
71 |
| -Note: Requires the optimized contract to be built (`cargo optimize`) |
| 104 | +# End-to-end tests |
| 105 | +cargo run-script e2e |
72 | 106 |
|
73 |
| -```bash |
74 |
| -cargo test --test integration |
| 107 | +# Generate contract schema |
| 108 | +cargo run-script schema |
75 | 109 | ```
|
76 | 110 |
|
77 |
| -Alternatively, you can run the following command, that makes sure to build the |
78 |
| -optimized contract before running the integration tests. |
79 |
| - |
80 |
| -```bash |
81 |
| -cargo run-script integration |
82 |
| -``` |
| 111 | +## Contributing |
83 | 112 |
|
84 |
| -### End-to-End Tests |
| 113 | +We welcome contributions! This project follows the same guidelines as the |
| 114 | +[Babylon node repository](https://github.com/babylonlabs-io/babylon/blob/main/CONTRIBUTING.md). |
85 | 115 |
|
86 |
| -Note: Requires the optimized contract to be built (`cargo optimize`) |
| 116 | +--- |
87 | 117 |
|
88 |
| -Run the end-to-end tests for the contract. |
| 118 | +**Need Help?** Check our [documentation](docs/) or open an issue for support. |
89 | 119 |
|
90 |
| -```bash |
91 |
| -cargo run-script e2e |
92 |
| -``` |
| 120 | +**Learn More:** Visit [Babylon Labs](https://babylonlabs.io) to understand the |
| 121 | +broader Bitcoin staking ecosystem. |
0 commit comments