Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nlordell committed Mar 7, 2024
1 parent e907b6c commit 9bb05db
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/4337-local-bundler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ERC-4337 Local Bundler

This repository contains tools for setting up and using a local ERC-4337 bundler for testing. While on-chain compatibility with the ERC-4337 `EntryPoint` contract is important, arguably the most challenging part of being compatible with the standard is ensuring that the account follows the user operation validation and account deployment rules that are enforced by the off-chain bundlers. As such, this repository provides tools to run a local development node with the reference ERC-4337 bundler for testing purposes.
13 changes: 13 additions & 0 deletions packages/4337-local-bundler/bundler/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM docker.io/library/node:18

# v0.7.0
ARG TAG=26e4f4c

RUN git clone https://github.com/eth-infinitism/bundler /src/bundler
WORKDIR /src/bundler
RUN git checkout ${TAG}
RUN git submodule init && git submodule update

RUN yarn && yarn preprocess
ENTRYPOINT ["yarn", "bundler"]
CMD []
35 changes: 35 additions & 0 deletions packages/4337-local-bundler/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3.8'

services:
geth:
image: docker.io/ethereum/client-go:stable
restart: always
environment:
GETH_DEV: 'true'
GETH_HTTP: 'true'
GETH_HTTP_ADDR: '0.0.0.0'
GETH_HTTP_API: 'personal,eth,net,web3,debug'
GETH_HTTP_VHOSTS: '*'
GETH_RPC_ALLOW_UNPROTECTED_TXS: 'true'
ports:
- 8545:8545

bundler:
build:
context: .
dockerfile: docker/bundler/Dockerfile
restart: always
command: ['--auto', '--network=http://geth:8545']
ports:
- 3000:3000

bundler-upstream:
build:
context: .
dockerfile: docker/bundler/Dockerfile
args:
TAG: main
restart: always
command: ['--auto', '--network=http://geth:8545']
ports:
- 3000:3000
10 changes: 10 additions & 0 deletions packages/4337-local-bundler/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@safe-global/safe-4337-local-bundler",
"version": "0.0.0",
"private": true,
"license": "LGPL-3.0-only",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
}
}
29 changes: 29 additions & 0 deletions packages/4337-local-bundler/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

DOCKER="${DOCKER:-docker}"

bundler_container="bundler"
if [[ -n "$USE_UPSTREAM_BUNDLER" ]]; then
bundler_container="bundler-upstream"
fi

"$DOCKER" compose up -d geth "$bundler_container"

# wait for containers to start up
SECONDS=0
until curl -fs http://localhost:8545 >/dev/null && curl -fs http://localhost:3000 >/dev/null; do
if [[ $SECONDS -gt 30 ]]; then
echo "ERROR: timeout waiting for local node and bundler to start"
"$DOCKER" compose logs
exit 1
fi
sleep 1
done

hardhat test --deploy-fixture --network localhost --grep '@4337'
success=$?

"$DOCKER" compose down

# exit with the E2E test's exit code
exit $success

0 comments on commit 9bb05db

Please sign in to comment.