Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions .devcontainer/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,22 @@ export PATH := foundry_path

# Clone the Optimism repository
op-clone:
git clone https://github.com/ethereum-optimism/optimism.git ~/optimism || echo skipping clone
git --git-dir ~/optimism/.git --work-tree ~/optimism checkout v1.9.4
# The op-devnet sometimes breaks with the error `t=2024-10-22T23:38:03+0000 lvl=crit msg="Application failed" message="failed to fetch startBlock from SystemConfig: failed to call startBlock: failed to unpack result: failed to unpack data: abi: attempting to unmarshal an empty string while arguments are expected"`
# This is true across 1.9.3, 1.9.4, and develop, but it appears to happen
# less frequently on develop. We'll change this to use the latest release
# once it's fixed
# If you encounter this error, you can try running `op-clean` to clean up
# and re-clone the repository
git clone --branch develop --single-branch --depth 1 https://github.com/ethereum-optimism/optimism.git ~/optimism || echo skipping clone

op-clean:
rm -rf ~/optimism

op-reclone: op-down op-clean op-clone

go-install:
go install /workspaces/metabased-rollup/op-translator
# go install /workspaces/metabased-rollup/metabased-publisher/cmd

# Install Foundry
# Based on https://book.getfoundry.sh/getting-started/installation
Expand All @@ -20,12 +34,12 @@ foundry-update:
foundryup

# Initialize op-devnet
op-devnet-up:
op-up:
PATH={{foundry_path}} make --directory ~/optimism devnet-up
@echo "OP Devnet initialized"

# Shut down devnet
op-devnet-down:
op-down:
PATH={{foundry_path}} make --directory ~/optimism devnet-down
@echo "OP Devnet shut down"

Expand All @@ -34,14 +48,19 @@ create-aliases:
#!/bin/bash
for rc_file in ~/.bashrc ~/.zshrc; do
if [[ -f "$rc_file" ]]; then
echo "# BEGIN Metabased Rollup Dev Container aliases" >> "$rc_file"
echo "# Foundry PATH" >> "$rc_file"
echo "export PATH=\"\$PATH:\$HOME/.foundry/bin\"" >> "$rc_file"
echo "# Foundry aliases" >> "$rc_file"
echo "alias foundry-install='just -f {{justfile()}} foundry-install'" >> "$rc_file"
echo "alias foundry-update='just -f {{justfile()}} foundry-update'" >> "$rc_file"
echo "# Metabased DevNet aliases" >> "$rc_file"
echo "alias op-up='just -f {{justfile()}} op-devnet-up'" >> "$rc_file"
echo "alias op-down='just -f {{justfile()}} op-devnet-down'" >> "$rc_file"
echo "# Local Devnet aliases" >> "$rc_file"
echo "alias op-up='just -f {{justfile()}} op-up'" >> "$rc_file"
echo "alias op-down='just -f {{justfile()}} op-down'" >> "$rc_file"
echo "alias op-clean='just -f {{justfile()}} op-clean'" >> "$rc_file"
echo "alias op-reclone='just -f {{justfile()}} op-reclone'" >> "$rc_file"
echo "alias go-install='just -f {{justfile()}} go-install'" >> "$rc_file"
echo "# END Metabased Rollup Dev Container aliases" >> "$rc_file"
echo "Aliases created in $rc_file"
else
echo "Warning: $rc_file does not exist. Skipping."
Expand All @@ -52,5 +71,5 @@ create-aliases:
# OP Devnet setup based on https://docs.optimism.io/chain/testing/dev-node
# We initialize and then spin down the devnet to get the initialization time out
# of the way upfront
all: op-clone foundry-install foundry-update op-devnet-up create-aliases
all: op-clone foundry-install foundry-update create-aliases
@echo "Post-create script completed successfully"
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# Metabased Rollup Monorepo

The monorepo for the Metabased rollup stack. Containers the sequencer, smart contracts, RPC node, dev environments, and more!

## Setting up the development environment

You can use the Dev Container in your IDE to get started. Clone the repo and choose "Open in Dev Container" from the command palette of your editor.

The Dev Container will auto-install all needed tooling. This includes Go, Rust, Foundry, Optimism tools, and more.

After creating the Dev Container, the following commands will be available:

- `op-up`: Start the Optimism devnet
- `op-down`: Stop the Optimism devnet
- `go-install`: Install all Go dependencies in the Dev Container

If these aliases don't work immediately, you may need to open a new terminal in the Dev Container. If they still don't work, you can run `just --justfile /workspaces/metabased-rollup/.devcontainer/justfile create-aliases` to create them manually.

### Sharing git ssh credentials with the Dev Container

You can share your local git ssh credentials with the Dev Container via the ssh-add command.

On the host machine, run: `ssh-add ~/.ssh/id_ed25519` (or the path to your ssh key)

This will automatically make the key available in the Dev Container. To confirm that the key is available, on the Dev Container, run: `ssh-add -l`

### Running in GitHub Codespaces

If you would like, you can run the Dev Container in GitHub Codespaces. This is useful for long-running tasks or development in a browser away from your local machine. To launch a Codespace, navigate to the branch you want to use, click the "Code" button (where repo cloning typically is) and then click "Create codespace on \[branch-name]".

GitHub Codespaces are compatible with VS Code and JetBrains, but not Cursor. You don't need to handle ssh credentials in Codespaces, as GitHub Codespaces handles authentication for you.