Try   HackMD

ERC-4337 Account Abstraction - Silius (bundler implementation in Rust)

The following document provides architecture, design, and specifications for the ERC-4337 (Account Abstraction - AA) bundler implementation in Rust - Silius. This project was started in the Ethereum Protocol Fellowship - The Third Cohort but is still being actively developed.

One of the essential components of the ERC-4337 AA is bundlers, which play the infrastructure or node/client role. Most of the heavy processing and calculations are done by them, and they have several responsibilities:

  • receiving user operations from smart contract wallets,
  • verifying and simulating user operations,
  • managing the reputation of different entities - accounts, factories, paymasters, signature aggregators,
  • maintaining public mempool of user operations over a P2P network with other bundlers,
  • bundling multiple user operations into transactions and submitting them to execution clients.

GitHub repository: https://github.com/Vid201/silius/
Contributors: Vid Kersic, WillQ

High-level architecture

The architecture and its decomposition are heavily inspired by the Erigon architecture (and here). All main components, i.e., ETH RPC API server, user operation mempool (named UoPool), and Bundler Core, are separable components and can be run as standalone processes. Bundler is implemented in a way that supports multiple entry points and mempools.

Only the ETH RPC API server is exposed to the public internet.


Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

  1. Users send user operations from ERC-4337 compatible wallets to the RPC API endpoint as JSON-RPC requests. They can also retrieve supported entry points, chain id, estimate user operation gas, etc.
  2. ETH RPC API connects to UoPool to add new user operations to mempool, retrieve supported entry points, chain id, estimate user operation gas, etc.
  3. UoPool connects to the ETH client to retrieve information about Ethereum accounts (balances, stake/deposit info, etc.). ETH client should have debug namespace enabled since calls to debug_traceCall are necessary for simulating user operation. UoPool also connects to other bundlers in the P2P network to broadcast received user operations and retrieve other user operations.
  4. The Bundler Core component retrieves user operations from UoPool over gRPC to create bundles of user operations.
  5. The Bundler Core connects to the ETH Client to fetch information about the accounts and the Ethereum network.
  6. The Bundler Core component sends constructed bundles (regular Ethereum transactions) to the ETH client, a block producer, or sends them to Flashbots services. In the production, bundles should not be directly inserted into the public tx pool due to the front-running.

Bundlers are standalone node components that can be spun up and operated without running Ethereum execution/consensus clients (bundlers connect to the ETH clients over gRPC). Possible tighter integrations into Rust-based execution clients are being considered (such as Reth), either running alongside Reth or reusing some of its components/packages (e.g., P2P library for listening for included user operations in the blocks).

Specification

ETH RPC API endpoints

JSON-RPC API Method Input Output Description
eth_chainId / chain ID ID of the chain the bundler is operating on. E.g., 1 for mainnet.
eth_supportedEntryPoints / List<Address> List of smart contracts addresses of supported entry points. E.g., ["0x0576a174D229E3cFA37253523E645A78A0C91B57"].
eth_sendUserOperation User operation and entry point Response (user operation hash or failure reason) Endpoint for sending user operations. User operation is added to the mempool if it passes sanity checks and simulation.
eth_estimateUserOperationGas User operation and entry point preVerificationGas, verificationGasLimit, callGasLimit Endpoint for estimating the gas values for user operations.
eth_getUserOperationReceipt User operation hash Response(user operation receipt or null) Endpoint for retrieving receipt for user operations based on their hash (which is returned by the endpoint eth_sendUserOperation).
eth_getUserOperationByHash User operation hash Response(user operation (with the addition of entry point, block number, block hash, and transaction hash) or null) Endpoint for retrieving user operations based on their hash (which is returned by the endpoint eth_sendUserOperation).

There are also several DEBUG RPC API endpoints, but they are not described due to being used only for testing purposes.

UoPool gRPC methods

gRPC Method Input Output Description
Add User operation and entry point Response (user operation hash or failure reason) User operation is added to the mempool if it passes sanity checks and simulation. The same method is also used for replacing user operations (user operation with the same nonce but higher gas prices).
Get sorted Entry point and count List<UserOperations> Returns the list of user operations sorted by max priority fee per gas.
Remove User operation hash Response (result=true/false) Removes user operation from the mempool.
Chain id / chain ID ID of the chain the bundler is operating on. E.g., 1 for mainnet.
Supported entry points / List<Address> List of smart contracts addresses of supported entry points. E.g., ["0x0576a174D229E3cFA37253523E645A78A0C91B57"].
Estimate user operation gas User operation and entry point preVerificationGas, verificationGasLimit, callGasLimit Method for estimating the gas values for user operations.

There are also several DEBUG gRPC endpoints, but they are not described due to being used only for testing purposes.

Status/roadmap

  • Entrypoint versions
    • v0.6.0
    • v0.7.0
  • ETH RPC API endpoints
    • eth Namespace
      • eth_chainId
      • eth_supportedEntryPoints
      • eth_sendUserOperation
      • eth_estimateUserOperationGas
      • eth_getUserOperationReceipt
      • eth_getUserOperationByHash
    • debug Namespace
      • debug_bundler_clearState
      • debug_bundler_dumpMempool
      • debug_bundler_sendBundleNow
      • debug_bundler_setBundlingMode
      • debug_bundler_setReputation
      • debug_bundler_dumpReputation
      • debug_bundler_addUserOps
  • UoPool
    • Add
      • Sanity checks
      • Simulation validation
    • Get sorted
    • Remove
    • Chain id
    • Supported entry points
    • Estimate user operation gas
    • Memory mempool
    • Database mempool
    • P2P
    • Alternative mempools with custom sanity checks and simulation validation
    • Support different versions (smart contracts) of the entry point
  • Bundler Core
    • Wallet
    • Signature aggregation
    • Bundling
      • Based on max priority fee per gas
      • Custom logic
    • Submitting bundles
      • ETH execution client - public transaction pool
      • Flashbots integration
      • Conditional RPC endpoint
  • Networks (tested)
    • Mainnet
    • Goerli
    • Sepolia
    • Polygon
    • Polygon Mumbai
    • Arbitrum
    • Optimism
    • Base
    • Linea
    • Avalanche
    • Blast
    • Binance Smart Chain
    • Mode

Additional enhancements:

Resources

ERC-4337: Account Abstraction Using Alt Mempool
ERC-4337 website
ERC-4337 Twitter
GitHub ETH Infinitism
Bundler spec
Bundler spec tests
Bundler test executor
Bundler spec tests results
Ethereum Protocol Fellowship - The Third Cohort (project description)