MCPcopy Index your code
hub / github.com/cairoeth/preconfirmations

github.com/cairoeth/preconfirmations @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
736 symbols 1,905 edges 85 files 363 documented · 49%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

🔌 Preconfirmations

All protocol components Goreport status License: AGPL v3

Preconfirmation protocol allowing users to get sub-second transaction confirmations on Ethereum.

This is experimental software and is provided on an "as is" and "as available" basis. We do not give any warranties and will not be liable for any losses incurred through any use of this code base.

🌱 Background

Ethereum preconfirmations, or "preconfs" for short, are a proposed mechanism to enable faster transaction confirmation and improve the user experience on Ethereum, and subsequently, layer 2 rollups and validiums. The key idea is to have Ethereum block proposers, known as "preconfers," issue signed promises to users guaranteeing that their transactions will be included and executed within a certain timeframe. Users pay a tip to preconfers for this service. By acquiring preconf promises from upcoming block proposers, users can get assurance of speedy execution, with latencies as low as 100ms.

This project leverages EigenLayer as the key piece of infrastructure to secure preconfer guarantees via a slashing mechanism. Operators that run the AVS software (preconf-operator) on top of EigenLayer must be block proposers that can include preconfirmation transactions. If preconfirmation promises by operators are not fulfilled, they are subject to on-chain slashing with proofs, verified with Relic Protocol.

In order to match users with preconfers, the preconf-share middleware acts as a matchmaker, receiving user requests with hints that are gossiped to operators. Operators can decide to promise a preconfirmation or not based on hints and tip. Promises are ranked by preconf-share according to the user's validation preferences (desired block, etc).

As preconf-share requires users to pass arguments and extra parameters, rpc is a JSON-RPC wrapper that simplifies this interaction for usage on wallets (like Metamask).

Read more here.

🧱 Structure

preconf-share — "Matchmaker middleware that connects user requests with block proposers"
├─ preconshare — "Main backend to receive requests, gossip hints, rank preconfirmations, and publish signed preconfirmations"
preconf-operator — "AVS (Actively Validated Services) infrastructure that receives and reponds to preconfirmation requests"
├─ core — "Configuration and utilities to interact with on-chain smart contracts"
├─ receiverapi — "Endpoint for preconf-share callback to receive and include raw transactions"
rpc — "JSON-RPC wrapper on top of preconf-share for wallets"
├─ cmd — "Launcher of components to run the RPC server and decode transactions"
├─ server — "Logic for request handlers, processors, and forwarders"
contracts
├─ PreconfChallengeManager — "Manager that allows to raise and resolves challenges for signed preconfirmations"
├─ PreconfServiceManager — "Primary entrypoint for procuring services for preconfirmations"

👷 Setup

Requires Go 1.18+, Docker and Foundry.

git clone https://github.com/cairoeth/preconfirmations.git

cd preconfirmations

make build-all

🔧 Usage

To run the protocol, you must start the following components: - anvil: Local network with EigenLayer and preconfirmation contracts. - preconf-share: Middleware software. Requires network. - preconf-operator: AVS software. Requires network and preconf-share. - rpc: JSON-RPC wrapper (optional). Requires preconf-share.

You can run all the protocol components concurrently with:

make run-all

Alternatively, you can run each component individually:

Anvil

Anvil (part of Foundry), creates a local testnet node for deploying and testing smart contracts. You can start it with the state that already contains the required contracts, or manually deploy them using the script.

To run with the pre-defined state:

make run-anvil

Preconf-Share

Preconf-Share is the middleware that connects users with block proposers. It receives user requests, gossips hints, ranks preconfirmations, and publishes signed preconfirmations. You can read more here.

make run-share

Preconf-Operator

Preconf-Operator is the AVS infrastructure that receives and responds to preconfirmation requests. It interacts with on-chain smart contracts to provide preconfirmation services. You can read more here.

make run-operator

RPC

RPC is a JSON-RPC wrapper on top of Preconf-Share for wallets. It simplifies the interaction for users to pass arguments and extra parameters.

make run-rpc

🧪 Test

After running all the components, make sure to wait around 10 seconds for the AVS sofware to register the operator. Once everything is ready, you can test the protocol with the JSON-RPC wrapper, or by running the Python example. You must have Python installed:

# Install dependencies
pip install -r requirements.txt

python test_tx.py

This example generates a random transaction that transfers Ether to itself. Check the protocol logs to see how the transaction is preconfirmed and included in the next block.

🙏🏼 Acknowledgements

This repository is inspired by or directly modified from many sources, primarily:

🫡 Contributing

Check out the Contribution Guidelines!

Extension points exported contracts — how you extend this code

SimulationResult (Interface)
SimulationResult is responsible for processing simulation results NOTE: That error should be returned only if simulation [1 …
preconf-share/preconshare/sim_result_backend.go
Store (Interface)
(no doc) [3 implementers]
rpc/database/store.go
SSEClient (Interface)
SSEClient is the SSE Client abstraction [1 implementers]
preconf-operator/sse/backend.go
AvsReaderer (Interface)
(no doc) [2 implementers]
preconf-operator/core/chainio/avs_reader.go
Queue (Interface)
(no doc) [1 implementers]
preconf-share/simqueue/queue.go
Fetcher (Interface)
(no doc) [1 implementers]
rpc/application/builder_info.go
BuilderNameProvider (Interface)
(no doc) [1 implementers]
rpc/server/server.go
AggregatorRPCClienter (Interface)
(no doc) [1 implementers]
preconf-operator/rpc_client.go

Core symbols most depended-on inside this repo

Error
called by 187
rpc/types/types.go
String
called by 86
preconf-share/preconshare/backend.go
NewJSONRPCRequest
called by 51
rpc/types/types.go
UpdateBlock
called by 22
preconf-share/simqueue/queue.go
Push
called by 22
preconf-share/simqueue/queue.go
HasHint
called by 20
preconf-share/preconshare/types.go
writeRPCError
called by 17
rpc/server/request_processor.go
Add
called by 14
preconf-share/preconshare/cancellation_cache.go

Shape

Method 343
Function 220
Struct 151
Interface 17
TypeAlias 4
FuncType 1

Languages

Go100%
Python1%

Modules by API surface

contracts/bindings/PreconfServiceManager/binding.go120 symbols
contracts/bindings/PreconfChallengeManager/binding.go74 symbols
contracts/bindings/ERC20Mock/binding.go74 symbols
rpc/tests/e2e_test.go27 symbols
rpc/server/redisstate.go25 symbols
rpc/types/types.go19 symbols
preconf-share/preconshare/types.go19 symbols
preconf-share/simqueue/queue.go18 symbols
rpc/server/util.go15 symbols
rpc/server/server.go15 symbols
preconf-share/simqueue/queue_test.go14 symbols
preconf-share/preconshare/api.go14 symbols

Datastores touched

postgresDatabase · 1 repos

For agents

$ claude mcp add preconfirmations \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact