forked from ethereum/hive
-
Notifications
You must be signed in to change notification settings - Fork 22
add simulator: optimism devnet #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,44 @@ | ||
| FROM ethereum/client-go:v1.10.16 AS base | ||
|
|
||
| RUN apk add --no-cache jq yarn git linux-headers gcompat | ||
| RUN /usr/local/bin/geth console --exec 'console.log(admin.nodeInfo.name)' --maxpeers=0 --nodiscover --dev 2>/dev/null | head -1 > /version.txt | ||
| ENV GLIBC_KEY=https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub | ||
| ENV GLIBC_KEY_FILE=/etc/apk/keys/sgerrand.rsa.pub | ||
| ENV GLIBC_RELEASE=https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r0/glibc-2.35-r0.apk | ||
| RUN wget -q -O ${GLIBC_KEY_FILE} ${GLIBC_KEY} \ | ||
| && wget -O glibc.apk ${GLIBC_RELEASE} \ | ||
| && apk add glibc.apk --force | ||
|
|
||
| # copy forge | ||
| FROM ghcr.io/foundry-rs/foundry:latest as foundry | ||
| FROM base | ||
| COPY --from=foundry /usr/local/bin/forge /usr/local/bin/forge | ||
|
|
||
| # Regenerate the L1 genesis file | ||
| RUN mkdir /hive | ||
| ADD genesis.json /genesis.json | ||
| RUN date +%s | xargs printf "0x%x" > /hive/genesis_timestamp | ||
| RUN GENESIS_TIMESTAMP=$(cat /hive/genesis_timestamp); jq ". | .timestamp = \"$GENESIS_TIMESTAMP\" " < ./genesis.json > /hive/genesis-l1.json | ||
|
|
||
| # Inject the startup script | ||
| ADD entrypoint.sh /entrypoint.sh | ||
| RUN chmod +x /entrypoint.sh | ||
|
|
||
| # Deploy contracts using Hardhat | ||
| RUN git clone https://github.com/ethereum-optimism/optimistic-specs /opt | ||
| RUN cd /opt && git submodule init && git submodule update | ||
| RUN cp -r /opt/packages/contracts /hive/contracts | ||
| # Defer until L1 rpc server is up; called from devnet.go | ||
| ADD deploy.sh /hive-bin/deploy.sh | ||
| RUN chmod +x /hive-bin/deploy.sh | ||
|
|
||
| # Helper scripts; called from devnet.go | ||
| ADD cat.sh /hive-bin/cat.sh | ||
mslipper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| RUN chmod +x /hive-bin/cat.sh | ||
|
|
||
| VOLUME ["/db"] | ||
|
|
||
| EXPOSE 8545/tcp | ||
| EXPOSE 8546/tcp | ||
|
|
||
| ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] | ||
This file contains hidden or 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,3 @@ | ||
| #!/bin/sh | ||
|
|
||
| cat $1 |
This file contains hidden or 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,10 @@ | ||
| #!/bin/sh | ||
|
|
||
| cd /hive/contracts | ||
| yarn | ||
| yarn build | ||
| export L2OO_STARTING_BLOCK_TIMESTAMP=$(cat /hive/genesis_timestamp) | ||
| echo "L2OO_STARTING_BLOCK_TIMESTAMP=$L2OO_STARTING_BLOCK_TIMESTAMP" | ||
| yarn hardhat --network devnetL1 deploy | ||
|
|
||
| echo "Deployed L1 contracts" |
This file contains hidden or 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,61 @@ | ||
| #!/bin/sh | ||
| set -exu | ||
|
|
||
| VERBOSITY=${GETH_VERBOSITY:-3} | ||
| GETH_DATA_DIR=/db | ||
| GETH_CHAINDATA_DIR="$GETH_DATA_DIR/geth/chaindata" | ||
| GETH_KEYSTORE_DIR="$GETH_DATA_DIR/keystore" | ||
| CHAIN_ID=$(cat /hive/genesis-l1.json | jq -r .config.chainId) | ||
| BLOCK_SIGNER_PRIVATE_KEY="3e4bde571b86929bf08e2aaad9a6a1882664cd5e65b96fff7d03e1c4e6dfa15c" | ||
| BLOCK_SIGNER_ADDRESS="0xca062b0fd91172d89bcd4bb084ac4e21972cc467" | ||
|
|
||
| if [ ! -d "$GETH_KEYSTORE_DIR" ]; then | ||
| echo "$GETH_KEYSTORE_DIR missing, running account import" | ||
| echo -n "pwd" > "$GETH_DATA_DIR"/password | ||
| echo -n "$BLOCK_SIGNER_PRIVATE_KEY" | sed 's/0x//' > "$GETH_DATA_DIR"/block-signer-key | ||
| geth account import \ | ||
| --datadir="$GETH_DATA_DIR" \ | ||
| --password="$GETH_DATA_DIR"/password \ | ||
| "$GETH_DATA_DIR"/block-signer-key | ||
| else | ||
| echo "$GETH_KEYSTORE_DIR exists." | ||
| fi | ||
|
|
||
| if [ ! -d "$GETH_CHAINDATA_DIR" ]; then | ||
| echo "$GETH_CHAINDATA_DIR missing, running init" | ||
| echo "Initializing genesis." | ||
| geth --verbosity="$VERBOSITY" init \ | ||
| --datadir="$GETH_DATA_DIR" \ | ||
| "/hive/genesis-l1.json" | ||
| else | ||
| echo "$GETH_CHAINDATA_DIR exists." | ||
| fi | ||
|
|
||
| # Warning: Archive mode is required, otherwise old trie nodes will be | ||
| # pruned within minutes of starting the devnet. | ||
|
|
||
| exec geth \ | ||
| --datadir="$GETH_DATA_DIR" \ | ||
| --verbosity="$VERBOSITY" \ | ||
| --http \ | ||
| --http.corsdomain="*" \ | ||
| --http.vhosts="*" \ | ||
| --http.addr=0.0.0.0 \ | ||
| --http.port=8545 \ | ||
| --http.api=web3,debug,eth,txpool,net,engine \ | ||
| --ws \ | ||
| --ws.addr=0.0.0.0 \ | ||
| --ws.port=8546 \ | ||
| --ws.origins="*" \ | ||
| --ws.api=debug,eth,txpool,net,engine \ | ||
| --syncmode=full \ | ||
| --nodiscover \ | ||
| --maxpeers=1 \ | ||
| --networkid=$CHAIN_ID \ | ||
| --unlock=$BLOCK_SIGNER_ADDRESS \ | ||
| --mine \ | ||
| --miner.etherbase=$BLOCK_SIGNER_ADDRESS \ | ||
| --password="$GETH_DATA_DIR"/password \ | ||
| --allow-insecure-unlock \ | ||
| --gcmode=archive \ | ||
| "$@" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.