-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #317 This PR adds a new `docker-compose` file for running a local Geth node (based on the Optimism Geth node) with RIP-7212 precompile support in order verify that the Safe WebAuthn verifier actually works with the [ER]IP-7212 precompile. In particular, we just use the `@bench` tests which are already run in CI and would give us a rough idea on how much gas a Passkey signature verification will take with the precompile (spoiler - its just 15k gas, which is reasonable). I did not create a dedicated E2E test, as I felt it didn't have much value.
- Loading branch information
Showing
13 changed files
with
309 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { ethers } from 'ethers' | ||
import childProcess, { SpawnOptions } from 'node:child_process' | ||
import path from 'node:path' | ||
|
||
const { DOCKER } = process.env | ||
|
||
const root = path.join(__dirname, '..') | ||
|
||
const docker = DOCKER || 'docker' | ||
|
||
async function exec(command: string, args: string[], options: Omit<SpawnOptions, 'stdio'> = {}) { | ||
const process = childProcess.spawn(command, args, { ...options, stdio: 'inherit' }) | ||
await new Promise((resolve, reject) => { | ||
process.on('exit', (code) => { | ||
if (code === 0) { | ||
resolve(undefined) | ||
} else { | ||
reject(new Error(`'${command}' process exited with code ${code}`)) | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
async function checkRpc(...urls: string[]) { | ||
const statuses = await Promise.all( | ||
urls.map(async (url) => { | ||
try { | ||
await new ethers.JsonRpcProvider(url).getNetwork() | ||
return true | ||
} catch { | ||
return false | ||
} | ||
}), | ||
) | ||
return statuses.every((ok) => ok) | ||
} | ||
|
||
async function main() { | ||
console.log('==> Starting docker containers...') | ||
await exec(docker, ['compose', 'up', '-d'], { cwd: root }) | ||
|
||
console.log('==> Waiting for Ethereum JSON RPC endpoint') | ||
const start = Date.now() | ||
const timeout = 60 * 1000 | ||
while (!(await checkRpc('http://localhost:8545'))) { | ||
if (Date.now() - start > timeout) { | ||
throw new Error('timeout waiting for local node and bundler to start') | ||
} | ||
} | ||
|
||
try { | ||
console.log('==> Running tests') | ||
await exec('hardhat', ['test', '--network', 'localhost', '--grep', '@bench']) | ||
} finally { | ||
console.log('==> Shutting down') | ||
await exec(docker, ['compose', 'down'], { cwd: root }) | ||
} | ||
} | ||
|
||
main().catch((err) => { | ||
console.error('ERROR: ', err) | ||
if (err.stderr) { | ||
console.log(err.stderr) | ||
} | ||
process.exitCode = 1 | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: '3.8' | ||
|
||
services: | ||
geth: | ||
build: | ||
context: . | ||
dockerfile: docker/geth/Dockerfile | ||
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_OVERRIDE_FJORD: '0' | ||
GETH_RPC_ALLOW_UNPROTECTED_TXS: 'true' | ||
ports: | ||
- 8545:8545 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM docker.io/library/golang:latest AS builder | ||
|
||
# The Geth fork that was easiest to get running with the RIP-7212 | ||
# precompile was the Optimism Geth node. Note that we still need to apply a | ||
# small patch, as the precompile is only enabled with Optimism consensus which | ||
# is not enabled in Dev mode. | ||
RUN git clone --depth 1 --branch v1.101315.1 https://github.com/ethereum-optimism/op-geth /src | ||
|
||
WORKDIR /src | ||
COPY docker/geth/geth.patch . | ||
RUN git apply geth.patch && make geth | ||
|
||
FROM docker.io/library/debian:bookworm-slim | ||
|
||
COPY --from=builder /src/build/bin/geth /usr/local/bin/geth | ||
|
||
ENTRYPOINT ["geth"] | ||
CMD [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/params/config.go b/params/config.go | ||
index b3a96a96a..166243692 100644 | ||
--- a/params/config.go | ||
+++ b/params/config.go | ||
@@ -1078,6 +1078,6 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules | ||
IsOptimismBedrock: isMerge && c.IsOptimismBedrock(num), | ||
IsOptimismRegolith: isMerge && c.IsOptimismRegolith(timestamp), | ||
IsOptimismCanyon: isMerge && c.IsOptimismCanyon(timestamp), | ||
- IsOptimismFjord: isMerge && c.IsOptimismFjord(timestamp), | ||
+ IsOptimismFjord: c.IsFjord(timestamp), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.