We implement BPE on Ethereum (Base L2) using Superfluid's General Distribution Agreement (GDA) (Superfluid, 2024). The architecture comprises four contracts.
BPE protocol architecture. Solid arrows denote read dependencies; the dashed arrow represents the auto-slash feedback path from CompletionTracker to StakeManager.
Sinks deposit ERC-20 tokens to stake. The capacity cap is computed as where is the stake unit parameter (set to ). This concave function implements Sybil resistance: splitting stake into sinks yields total capacity for , strictly less than the capacity from a single identity. A minimum per-sink stake further penalizes splitting.
The registry manages task type creation, sink registration, and capacity signaling. Capacity updates use a two-phase commit-reveal protocol for MEV resistance:
Commit: Sink submits .
Reveal: Within 20 blocks, sink reveals . The contract verifies the hash, applies the stake cap, and computes the EWMA update: .
The registry maintains an aggregate totalCapacity per task type, updated atomically on each reveal.
For each task type, the pool creates a Superfluid GDA pool and acts as its admin. On rebalance, it reads all sink capacities from the registry and sets each sink's pool units proportional to their smoothed capacity: .
Sources create Constant Flow Agreement (CFA) streams to the pool address. The GDA automatically distributes incoming flows to members proportional to their units, achieving capacity-proportional payment routing without centralized scheduling.
Rebalance is permissionless: any address may call it. A 5% threshold (measured in basis points of total capacity change) prevents unnecessary gas expenditure.
When all sinks in a task type are at capacity, excess payments are deposited into the buffer. The drain function distributes buffered funds proportionally to current sink capacities. A configurable bufferMax caps the buffer size; when full, sources must pause.
For multi-stage agent pipelines, the Pipeline contract chains BackpressurePools. The key mechanism is upstream propagation: each stage's effective capacity is constrained by its downstream stage:
Rebalance proceeds back-to-front, ensuring downstream congestion propagates upstream before any stage is rebalanced.