This repo contains an end-to-end reference implementation of L1 inclusion preconfs. It's meant to serve as a stepping stone to simplify working with Fabric's Constraints API and Commitments API specs. This is not audited and subject to change, use at your own risk!
- Gateway:
- Hosts a
GatewayRpcserver that implements the Commitments spec and specifically accepts commitment requests forInclusionPayloadtypes. - Runs a
DelegationManagertask that periodically queries the relay using itsHttpConstraintsClientto fetch any upcoming delegations. - Runs a
ConstraintManagertask that postsSignedConstraintsto the relay right before the target slot.
- Hosts a
- Relay:
- Hosts a
RelayServerthat implements the Constraints spec. To avoid fully re-implementing a relay from scratch, all non-constraints spec calls are proxied and passed to a configured downstream relay. - Runs a
LookaheadManagertask that tracks the beacon chain lookahead to know if aSignedDelegationis valid for a slot.
- Hosts a
- Proposer:
- Runs a
DelegationManagertask that signs tracks the beacon chain lookahead. If their proposer key is scheduled, they will post aSignedDelegationto the relay via theirHttpConstraintsClient.
- Runs a
- Constraints Builder:
- Runs a modified rbuilder that appends inclusion preconf transactions to the bottom of the block.
- Relay only accepts one valid
SignedDelegationper slot - Relay only accepts one valid
SignedConstraintsper slot - After the target slot has elapsed, the relay no longer enforces the whitelist for
GET /constraints
gateway.rs- Launches theGatewayRpc,DelegationManager, andConstraintManager.proposer.rs- Launches theDelegationManagerrelay.rs- Launches theRelayServerandLookaheadManager.spammer.rs- Spams theGatewayRpcwith inclusion commitments requestslocal-signer-module.rs- Local Commit-Boost signing module for development and testingbeacon-mock.rs- Mock beacon node that exposes the lookahead for local testingsimulation-setup.rs- Generates config and .env files for the above binaries from a central config file for consistency.
-
commitments/- Commitments API implementation- types
- JSON-RPC client implementation
- JSON-RPC server trait
-
common/- Shared infrastructure- minimal DB lib (RocksDB)
-
constraints/- Constraints API implementation- types
- rest client implementation
- rest server trait
-
lookahead/- Beacon chain utils- minimal beacon node client implementation
- slot timing utils
-
signing/- BLS/ECDSA signing utils- minimal wrapper around the Commit-Boost
SignerClient
- minimal wrapper around the Commit-Boost
-
proposer/- Proposer delegation module- service to sign delegations based on lookahead
-
urc/- Universal Registry Contract utils- bindings for the URC contract
- hashing utils for signing data s.t., URC contracts can verify
- Task coordinator
-
inclusion/- Reference implementation of inclusion preconfs- types
- merkle inclusion proof utils
- gateway implementation
- relay implementation
- Rust (stable) - Install from rustup.rs
- Just - Task runner (GitHub)
- Foundry - For URC contract bindings (optional, only if modifying contracts)
- Kurtosis CLI - See installation guide
git submodule init
git submodule updateIf you need to regenerate the Rust bindings for URC contracts:
# Install Foundry if not already installed
curl -L https://foundry.paradigm.xyz | bash
foundryup
# Initialize submodules
git submodule update --init --recursive
# Generate bindings
cd ./vendor/urc
forge bind --crate-name urc --overwrite --bindings-path ../../crates/urc/src/bindingsThe following commands build the Docker images expected by Kurtosis.
export VERSION=dev
# Build local Commit-Boost Signer Module Docker image
just build-signer $VERSION
# Build Gateway Docker image
just build-gateway $VERSION
# Build Relay Docker image
just build-relay $VERSION
# Build Proposer Module Docker image
just build-proposer $VERSION
# Build Spammer Module Docker image
just build-spammer $VERSION
# Build Constraints Builder Docker image
just build-builder $VERSIONThe Kurtosis config is defined at ./kurtosis/config/kurtosis-network-params.yaml. By default, it launches two full nodes, each running two validators, a MEV-Boost relay, a transaction spammer, and blocker explorer utilities.
The ./kurtosis/config/docker-compose.yml and ./kurtosis/scripts files work together so that the Kurtosis network members can communicate with the Dockerized fabric members, i.e., so the Constraint Builder's node can sync with the network.
The following will launch the Kurtosis network with all of the Fabric services locally. It's recommended that your computer has sufficient disk space.
# Tears down and relaunches everything
just restart-testnet
# Stops everything
just stop-testnet
# Only restarts the Docker containers
# (Useful for developing)
just restart-testnet-docker
# Prints the URLs of every Kurtosis member
just inspect-testnet
# Prints the URL of the block explorer
just block-explorer- It takes a while (dozens of slots) for the MEV-Boost Relay to supply the Constraints Builder with registration data. This means it'll be delayed before posting blocks.
- If any Kurtosis services crash it's recommended to restart everything
just restart-testnet - The Spammer service will only update it's nonce after its inclusion transcation lands on-chain. Since inclusion requests happen earlier than the block inclusion, expect to see some errors like:
"Failed to submit blocks with proofs: Constraint types length mismatch, received 0 constraints, expected 1. The reason is the builder will exclude transactions with failed nonces by default. Once the inclusion lands on-chain, the Spammer will update the nonce and the simulation will progress.
This project implements the following Ethereum preconfirmation specifications:
- Commitments API - User-facing API for requesting preconfirmations
- Constraints API - Builder/relay coordination API
- Gateway Specification - Gateway architecture and behavior
See LICENSE file for details.