Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
WIP Add default bundler to local dev script
Browse files Browse the repository at this point in the history
  • Loading branch information
jacque006 committed Sep 20, 2023
1 parent dfd5c1e commit af09f03
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 28 deletions.
16 changes: 2 additions & 14 deletions account-integrations/safe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,13 @@ To run the hardhat tests, you'll need to run a node and a bundler as some of the
cp .env.example .env
```

2. Start a geth node, fund accounts and deploy Safe contracts:
2. Start a geth node, fund accounts, deploy Safe contracts, and start a bundler:

```bash
./script/start.sh
```

3. Setup and run an external bundler (make sure the values in `.env` match up with the bundler and node you're running).

```bash
# If using the eth-infinitism bundler, checkout to this commmit. The latest version of the bundler has started breaking the integration tests. This is a previous commit where the integration tests still pass
git checkout 1b154c9
```

```bash
# If using the eth-infinitism bundler
yarn run bundler
```

4. Run the plugin tests:
3. Run the plugin tests:

```bash
yarn hardhat test
Expand Down
13 changes: 13 additions & 0 deletions account-integrations/safe/config/bundler.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"gasFactor": "1",
"port": "3000",
"entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"beneficiary": "0xd21934eD8eAf27a67f0A70042Af50A1D6d195E81",
"minBalance": "1",
"mnemonic": "./workdir/mnemonic.txt",
"maxBundleGas": 5e6,
"minStake": "1" ,
"minUnstakeDelay": 0 ,
"autoBundleInterval": 3,
"autoBundleMempoolSize": 10
}
1 change: 1 addition & 0 deletions account-integrations/safe/config/mnemonic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test test test test test test test test test test test junk
42 changes: 31 additions & 11 deletions account-integrations/safe/script/start.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
#!/bin/bash

DOCKER_NETWORK=account-integrations-safe-docker-network

GETH_IMAGE=ethereum/client-go:v1.13.1
BUNDLER_IMAGE=accountabstraction/bundler:0.6.0

GETH_CONTAINER=geth${RANDOM}
BUNDLER_CONTAINER=bundler${RANDOM}

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

set -meuo pipefail

# Cleanup on script exit
function cleanup {
docker stop $CONTAINER || true
docker stop ${GETH_CONTAINER} || true
docker stop ${BUNDLER_CONTAINER} || true
docker network rm ${DOCKER_NETWORK} || true
jobs -p | xargs kill
}

trap cleanup EXIT
trap cleanup INT

docker pull ethereum/client-go:v1.10.26
# Create docker network
docker network create ${DOCKER_NETWORK}

CONTAINER=geth$RANDOM
# Start geth rpc container
docker pull ${GETH_IMAGE}

docker run --rm -i --name $CONTAINER -p 8545:8545 ethereum/client-go:v1.10.26 \
docker run --rm -i --name ${GETH_CONTAINER} -p 8545:8545 --network=${DOCKER_NETWORK} ${GETH_IMAGE} \
--miner.gaslimit 100000000 \
--http \
--http.api personal,eth,net,web3,debug \
--http.vhosts '*,localhost,host.docker.internal' \
--http.corsdomain='*' \
--http.addr "0.0.0.0" \
--ignore-legacy-receipts \
--allow-insecure-unlock \
--rpc.allow-unprotected-txs \
--rpc.txfeecap 2 \
Expand All @@ -32,18 +44,26 @@ docker run --rm -i --name $CONTAINER -p 8545:8545 ethereum/client-go:v1.10.26 \
--nodiscover \
--maxpeers 0 \
--mine \
--miner.threads 1 \
--networkid 1337 \
&

echo $SCRIPT_DIR
echo ${SCRIPT_DIR}

"$SCRIPT_DIR/wait-for-rpc.sh"
"${SCRIPT_DIR}/wait-for-rpc.sh"

docker exec $CONTAINER geth \
--exec "$(cat "$SCRIPT_DIR/fundAccounts.js")" \
# Fund initial accounts
docker exec ${GETH_CONTAINER} geth \
--exec "$(cat "${SCRIPT_DIR}/fundAccounts.js")" \
attach 'http://localhost:8545'

yarn hardhat run "$SCRIPT_DIR/deploy_all.ts" --network localhost
# Deploy common contracts
yarn hardhat run "${SCRIPT_DIR}/deploy_all.ts" --network localhost

# Start ERC-4337 bundler
docker pull ${BUNDLER_IMAGE}

docker run --rm -i --name ${BUNDLER_CONTAINER} -p 3000:3000 -v ./config:/app/workdir:ro --network=${DOCKER_NETWORK} ${BUNDLER_IMAGE} \
--network http://${GETH_CONTAINER}:8545 /
&

fg
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ describe("SafeWebAuthnPlugin", () => {
);

const safeVerificationGasLimit =
BigInt(gasEstimate.verificationGasLimit) +
BigInt(gasEstimate.verificationGasLimit) / 10n; // + 10%
BigInt(gasEstimate.verificationGas) +
BigInt(gasEstimate.verificationGas) / 10n; // + 10%

const safePreVerificationGas =
BigInt(gasEstimate.preVerificationGas) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const MNEMONIC = process.env.MNEMONIC;

const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

describe("SafeZKPPasswordPlugin", () => {
// TODO Remove skip
describe.skip("SafeZKPPasswordPlugin", () => {
const setupTests = async () => {
const factory = await hre.ethers.getContractFactory("SafeProxyFactory");
const singleton = await hre.ethers.getContractFactory("Safe");
Expand Down

0 comments on commit af09f03

Please sign in to comment.