Skip to content

Commit

Permalink
Shared Local Bundler E2E Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
nlordell committed Mar 7, 2024
1 parent 9bb05db commit e310c0e
Show file tree
Hide file tree
Showing 44 changed files with 315 additions and 789 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci_4337.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
node-version: 20.x
cache: npm
cache-dependency-path: package-lock.json
- run: npm ci
- run: npm run build -w modules/4337 && npm run build:ts -w modules/4337
- run: npm run coverage -w modules/4337
- run: |
npm ci
npm run coverage -w modules/4337
- name: Coveralls
uses: coverallsapp/github-action@master
with:
Expand All @@ -33,7 +33,7 @@ jobs:
cache-dependency-path: package-lock.json
- run: |
npm ci
npm run test:e2e -w modules/4337
npm run test:4337 -w modules/4337
lint:
runs-on: ubuntu-latest
steps:
Expand All @@ -43,6 +43,7 @@ jobs:
node-version: 20.x
cache: npm
cache-dependency-path: package-lock.json
- run: npm ci
- run: npm run lint -w modules/4337
- run: npm run fmt:check -w modules/4337
- run: |
npm ci
npm run lint -w modules/4337
npm run fmt:check -w modules/4337
9 changes: 5 additions & 4 deletions .github/workflows/ci_4337_gas_metering.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
node-version: 20.x
cache: npm
cache-dependency-path: package-lock.json
- run: npm ci
- run: npm run fmt:check -w examples/4337-gas-metering
- run: npm run lint -w examples/4337-gas-metering
- run: npm run build -w examples/4337-gas-metering
- run: |
npm ci
npm run fmt:check -w examples/4337-gas-metering
npm run lint -w examples/4337-gas-metering
npm run build -w examples/4337-gas-metering
19 changes: 19 additions & 0 deletions .github/workflows/ci_4337_local_bundler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: safe-modules-4337-local-bundler
on:
push:
paths:
- 'packages/4337-local-bundler/**'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
cache-dependency-path: package-lock.json
- run: |
npm ci
npm run lint
8 changes: 6 additions & 2 deletions .github/workflows/ci_4337_upstream_bundler.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 4337 Module End-to-End Tests With Upstream Bundler
name: 4337 End-to-End Tests With Upstream Bundler
on:
schedule:
# * is a special character in YAML so you have to quote this string
Expand All @@ -7,6 +7,9 @@ on:
push:
paths:
- 'modules/4337/**'
- 'modules/passkey/**'
- 'packages/4337-local-bundler/**'


jobs:
e2e-upstream-bundler:
Expand All @@ -20,4 +23,5 @@ jobs:
cache-dependency-path: package-lock.json
- run: |
npm ci
npm run test:e2e:upstream -w modules/4337
npm run test:4337:upstream -w modules/4337
npm run test:4337:upstream -w modules/passkey
4 changes: 0 additions & 4 deletions .github/workflows/ci_passkey_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ jobs:
cache: npm
cache-dependency-path: package-lock.json
- run: |
npm ci
# Build the 4337 module so the app can use the artifacts
npm run build -w modules/4337
# Reinstall the dependencies so the 4337 dependency includes artifacts
npm ci
npm run lint -w examples/4337-passkeys
npm run build -w examples/4337-passkeys
Expand Down
35 changes: 0 additions & 35 deletions modules/4337/docker-compose.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions modules/4337/docker/bundler/Dockerfile

This file was deleted.

8 changes: 4 additions & 4 deletions modules/4337/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ const userConfig: HardhatUserConfig = {
networks: {
localhost: {
url: 'http://localhost:8545',
tags: ['dev', 'safe'],
tags: ['dev', 'entrypoint', 'safe'],
},
hardhat: {
gasPrice: 10000000000,
tags: ['test'],
tags: ['test', 'entrypoint', 'safe'],
},
mainnet: {
...sharedNetworkConfig,
Expand All @@ -88,12 +88,12 @@ const userConfig: HardhatUserConfig = {
sepolia: {
...sharedNetworkConfig,
url: `https://sepolia.infura.io/v3/${INFURA_KEY}`,
tags: ['dev'],
tags: ['dev', 'entrypoint'],
},
amoy: {
...sharedNetworkConfig,
url: `https://polygon-amoy.infura.io/v3/${INFURA_KEY}`,
tags: ['dev'],
tags: ['dev', 'entrypoint'],
},
...customNetwork,
},
Expand Down
11 changes: 6 additions & 5 deletions modules/4337/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"build:ts": "npx rimraf dist && tsc",
"build:sol": "npx rimraf build && hardhat compile",
"test": "hardhat test --deploy-fixture",
"test:e2e": "./test/e2e/run.sh",
"test:e2e:upstream": "USE_UPSTREAM_BUNDLER=1 ./test/e2e/run.sh",
"test:all": "npm run test && npm run test:e2e",
"test:4337": "4337-local-bundler-test",
"test:4337:upstream": "USE_UPSTREAM_BUNDLER=1 4337-local-bundler-test",
"test:all": "npm run test && npm run test:4337",
"coverage": "hardhat coverage",
"codesize": "hardhat codesize",
"benchmark": "npm run test benchmark/*.ts",
Expand Down Expand Up @@ -54,6 +54,7 @@
"@noble/curves": "^1.3.0",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@openzeppelin/contracts": "^5.0.2",
"@safe-global/safe-4337-local-bundler": "^0.0.0",
"@simplewebauthn/server": "9.0.0",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
Expand All @@ -63,8 +64,8 @@
"debug": "^4.3.4",
"dotenv": "^16.4.4",
"ethers": "^6.11.1",
"hardhat": "^2.20.1",
"hardhat-deploy": "0.11.45",
"hardhat": "^2.21.0",
"hardhat-deploy": "^0.12.1",
"husky": "^9.0.11",
"solc": "^0.8.24",
"solhint": "^4.1.1",
Expand Down
26 changes: 2 additions & 24 deletions modules/4337/src/deploy/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
import EntryPoint from '@account-abstraction/contracts/artifacts/EntryPoint.json'
import { DeployFunction } from 'hardhat-deploy/types'
import { deployEntryPoint } from '@safe-global/safe-4337-local-bundler'

const ENTRY_POINT = process.env.DEPLOYMENT_ENTRY_POINT_ADDRESS

const deploy: DeployFunction = async ({ deployments, getNamedAccounts, network }) => {
const { deployer } = await getNamedAccounts()
const { deploy } = deployments

if (network.tags.dev || network.tags.test) {
await deploy('EntryPoint', {
from: deployer,
contract: EntryPoint,
args: [],
log: true,
deterministicDeployment: '0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3',
})
} else if (!ENTRY_POINT) {
throw new Error('DEPLOYMENT_ENTRY_POINT_ADDRESS must be set')
}
}

deploy.tags = ['entrypoint']

export default deploy
export default deployEntryPoint
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const deploy: DeployFunction = async ({ deployments, getNamedAccounts, network }
const { deployer } = await getNamedAccounts()
const { deploy } = deployments

const entryPoint = await deployments.get('EntryPoint')

const p256Verifier = await deploy('P256Verifier', {
from: deployer,
args: [],
Expand All @@ -28,6 +30,15 @@ const deploy: DeployFunction = async ({ deployments, getNamedAccounts, network }
log: true,
deterministicDeployment: true,
})

await deploy('SafeSignerLaunchpad', {
from: deployer,
args: [entryPoint.address],
log: true,
deterministicDeployment: true,
})
}

deploy.dependencies = ['entrypoint']

export default deploy
2 changes: 0 additions & 2 deletions modules/4337/src/deploy/libraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ const deploy: DeployFunction = async ({ deployments, getNamedAccounts }) => {
})
}

deploy.tags = ['libraries']

export default deploy
1 change: 0 additions & 1 deletion modules/4337/src/deploy/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ const deploy: DeployFunction = async ({ deployments, getNamedAccounts, network }
}

deploy.dependencies = ['entrypoint']
deploy.tags = ['mock']

export default deploy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ const deploy: DeployFunction = async ({ deployments, getNamedAccounts }) => {
}

deploy.dependencies = ['entrypoint']
deploy.tags = ['modules']

export default deploy
40 changes: 2 additions & 38 deletions modules/4337/src/deploy/safe.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
import MultiSend from '@safe-global/safe-contracts/build/artifacts/contracts/libraries/MultiSend.sol/MultiSend.json'
import SafeProxyFactory from '@safe-global/safe-contracts/build/artifacts/contracts/proxies/SafeProxyFactory.sol/SafeProxyFactory.json'
import SafeL2 from '@safe-global/safe-contracts/build/artifacts/contracts/SafeL2.sol/SafeL2.json'
import { DeployFunction } from 'hardhat-deploy/types'
import { deploySafe } from '@safe-global/safe-4337-local-bundler'

const deploy: DeployFunction = async ({ deployments, getNamedAccounts, network }) => {
if (!network.tags.safe && !network.tags.test) {
return
}

const { deployer } = await getNamedAccounts()
const { deploy } = deployments

await deploy('MultiSend', {
from: deployer,
contract: MultiSend,
args: [],
log: true,
deterministicDeployment: true,
})
await deploy('SafeL2', {
from: deployer,
contract: SafeL2,
args: [],
log: true,
deterministicDeployment: true,
})
await deploy('SafeProxyFactory', {
from: deployer,
contract: SafeProxyFactory,
args: [],
log: true,
deterministicDeployment: true,
})
}

deploy.tags = ['safe']

export default deploy
export default deploySafe
2 changes: 1 addition & 1 deletion modules/4337/test/e2e/4337NestedSafe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const buildNestedSafeOp = async (
)
}

describe('E2E - Nested Safes With An Execution Initiated by a Leaf 4337 Safe', () => {
describe('Nested Safes With An Execution Initiated by a Leaf 4337 Safe [@4337]', () => {
before(function () {
if (network.name !== 'localhost') {
this.skip()
Expand Down
2 changes: 1 addition & 1 deletion modules/4337/test/e2e/LocalBundler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { chainId, timestamp } from '../utils/encoding'
import { Safe4337 } from '../../src/utils/safe'
import { bundlerRpc, prepareAccounts, waitForUserOp } from '../utils/e2e'

describe('E2E - Local Bundler', () => {
describe('Local Bundler [@4337]', () => {
before(function () {
if (network.name !== 'localhost') {
this.skip()
Expand Down
2 changes: 1 addition & 1 deletion modules/4337/test/e2e/SingletonSigners.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../src/utils/userOp'
import { bundlerRpc, encodeMultiSendTransactions, prepareAccounts, waitForUserOp } from '../utils/e2e'

describe('E2E - Singleton Signers', () => {
describe('Singleton Signers [@4337]', () => {
before(function () {
if (network.name !== 'localhost') {
this.skip()
Expand Down
2 changes: 1 addition & 1 deletion modules/4337/test/e2e/UniqueSigner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { bundlerRpc, prepareAccounts, waitForUserOp } from '../utils/e2e'
import { chainId } from '../utils/encoding'
import { packGasParameters, unpackUserOperation } from '../../src/utils/userOp'

describe('E2E - Unique Signers', () => {
describe('Unique Signers [@4337]', () => {
before(function () {
if (network.name !== 'localhost') {
this.skip()
Expand Down
2 changes: 1 addition & 1 deletion modules/4337/test/e2e/WebAuthnSigner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '../utils/webauthn'
import { packGasParameters, unpackUserOperation } from '../../src/utils/userOp'

describe('E2E - WebAuthn Signers', () => {
describe('WebAuthn Signers [@4337]', () => {
before(function () {
if (network.name !== 'localhost') {
this.skip()
Expand Down
2 changes: 1 addition & 1 deletion modules/4337/test/e2e/WebAuthnSingletonSigner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '../../src/utils/userOp'
import { buildSignatureBytes } from '../../src/utils/execution'

describe('E2E - WebAuthn Singleton Signers', () => {
describe('WebAuthn Singleton Signers [@4337]', () => {
before(function () {
if (network.name !== 'localhost') {
this.skip()
Expand Down
Loading

0 comments on commit e310c0e

Please sign in to comment.