Skip to content
Open
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
153 changes: 153 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: CI

on:
push:
branches: ["main"]
pull_request:

permissions:
contents: read

jobs:
validate:
name: Validate Scripts, Compose, and Config Consistency
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check POSIX shell syntax
run: |
for f in morph-node/*.sh; do
echo "Checking syntax: $f"
sh -n "$f"
done

- name: Run shellcheck
run: shellcheck -S warning morph-node/*.sh

- name: Validate Docker Compose configs
run: |
docker compose -f morph-node/docker-compose.yml --env-file morph-node/.env config -q
docker compose -f morph-node/docker-compose.yml --env-file morph-node/.env_hoodi config -q
docker compose -f morph-node/docker-compose.reth.yml --env-file morph-node/.env config -q
docker compose -f morph-node/docker-compose.reth.yml --env-file morph-node/.env_hoodi config -q

- name: Dry-run Makefile targets
run: |
make -C morph-node -n generate-jwt generate-jwt-hoodi \
download-and-decompress-mainnet-snapshot download-and-decompress-hoodi-snapshot \
download-and-decompress-mainnet-reth-snapshot download-and-decompress-hoodi-reth-snapshot \
clean-mainnet-binary clean-hoodi-binary clean-mainnet-reth clean-hoodi-reth \
stop-reth-node rm-reth-node stop-hoodi-reth-node rm-hoodi-reth-node \
stop-binary >/dev/null

- name: Verify JSON, versions, snapshots, and data.zip consistency
run: |
python3 - <<'PY'
import json
import pathlib
import re
import zipfile

root = pathlib.Path(".")

# 1. Validate JSON files
json_files = [
"mainnet/reth-data/static-nodes.json",
"hoodi/reth-data/static-nodes.json",
"mainnet/geth-data/static-nodes.json",
"hoodi/geth-data/static-nodes.json",
"mainnet/geth-data/genesis.json",
"hoodi/geth-data/genesis.json",
"mainnet/node-data/config/genesis.json",
"hoodi/node-data/config/genesis.json",
]
for rel in json_files:
with (root / rel).open() as fh:
json.load(fh)
print(f"Validated {len(json_files)} JSON files.")

# 2. Check Docker image tag & Makefile/README RETH_VERSION alignment
compose_geth = (root / "morph-node/docker-compose.yml").read_text()
compose_reth = (root / "morph-node/docker-compose.reth.yml").read_text()
makefile = (root / "morph-node/Makefile").read_text()
readme = (root / "README.md").read_text()

node_geth = re.search(r"ghcr\.io/morph-l2/node:([0-9A-Za-z._-]+)", compose_geth)
node_reth = re.search(r"ghcr\.io/morph-l2/node:([0-9A-Za-z._-]+)", compose_reth)
assert node_geth and node_reth, "Missing morph-l2/node image tag"
assert node_geth.group(1) == node_reth.group(1), (
f"Node image tag mismatch: docker-compose.yml={node_geth.group(1)} "
f"vs docker-compose.reth.yml={node_reth.group(1)}"
)

reth_img = re.search(r"ghcr\.io/morph-l2/morph-reth:v([0-9A-Za-z._-]+)", compose_reth)
reth_mk = re.search(r"^RETH_VERSION\s*\?=\s*([0-9A-Za-z._-]+)", makefile, re.M)
assert reth_img and reth_mk, "Missing morph-reth version"
assert reth_img.group(1) == reth_mk.group(1), (
f"Reth version mismatch: docker-compose.reth.yml=v{reth_img.group(1)} "
f"vs Makefile={reth_mk.group(1)}"
)
assert f"(default `{reth_img.group(1)}`, kept in sync with the image in" in readme, (
f"README.md default RETH_VERSION out of sync with v{reth_img.group(1)}"
)
print(f"Versions aligned: node={node_geth.group(1)}, morph-reth=v{reth_img.group(1)}.")

# 3. Parse README snapshot tables and verify .env / .env_hoodi defaults match
table_rows = {}
row_re = re.compile(
r"^\|\s*\[([^\]]+)\]\(([^)]+)\)\s*\|\s*(\d+)\s*\|\s*(\d+)\s*\|\s*(\d+)\s*\|$",
re.M,
)
for name, url, deriv, l1msg, l2base in row_re.findall(readme):
net = "mainnet" if "/mainnet/" in url else "hoodi"
table_rows[(net, name)] = (deriv, l1msg, l2base)

def parse_env(path: pathlib.Path) -> dict[str, str]:
env = {}
for line in path.read_text().splitlines():
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
k, v = line.split("=", 1)
env[k.strip()] = v.strip()
return env

env_mainnet = parse_env(root / "morph-node/.env")
env_hoodi = parse_env(root / "morph-node/.env_hoodi")

checks = [
("mainnet", env_mainnet["MAINNET_SNAPSHOT_NAME"],
(env_mainnet["DERIVATION_START_HEIGHT"], env_mainnet["L1_MSG_START_HEIGHT"], env_mainnet["L2_BASE_HEIGHT"])),
("mainnet", env_mainnet["MAINNET_RETH_SNAPSHOT_NAME"],
(env_mainnet["RETH_DERIVATION_START_HEIGHT"], env_mainnet["RETH_L1_MSG_START_HEIGHT"], env_mainnet["RETH_L2_BASE_HEIGHT"])),
("hoodi", env_hoodi["HOODI_SNAPSHOT_NAME"],
(env_hoodi["DERIVATION_START_HEIGHT"], env_hoodi["L1_MSG_START_HEIGHT"], env_hoodi["L2_BASE_HEIGHT"])),
("hoodi", env_hoodi["HOODI_RETH_SNAPSHOT_NAME"],
(env_hoodi["RETH_DERIVATION_START_HEIGHT"], env_hoodi["RETH_L1_MSG_START_HEIGHT"], env_hoodi["RETH_L2_BASE_HEIGHT"])),
]
for net, snap, heights in checks:
assert (net, snap) in table_rows, f"{net} snapshot {snap} from env file is not listed in README.md"
assert table_rows[(net, snap)] == heights, (
f"Height mismatch for {net}/{snap}: env={heights} vs README={table_rows[(net, snap)]}"
)
print("All .env / .env_hoodi default snapshots and heights match README.md.")

# 4. Verify data.zip archives are clean and up to date with tracked files
for net in ("mainnet", "hoodi"):
zpath = root / net / "data.zip"
with zipfile.ZipFile(zpath) as zf:
names = zf.namelist()
assert not any(".DS_Store" in n or "__MACOSX" in n for n in names), f"Junk metadata in {zpath}"
for member in (
"node-data/config/config.toml",
"node-data/config/genesis.json",
"reth-data/static-nodes.json",
):
assert member in names, f"Missing {member} in {zpath}"
assert zf.read(member) == (root / net / member).read_bytes(), (
f"{zpath}:{member} diverges from {net}/{member}"
)
print("Verified mainnet/data.zip and hoodi/data.zip match tracked configs.")
PY
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.idea/
.idea/
morph-node/.geth.pid
morph-node/.reth.pid
morph-node/.node.pid
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "morph"]
path = morph
url = https://github.com/morph-l2/morph.git
[submodule "morph-reth"]
path = morph-reth
url = https://github.com/morph-l2/morph-reth.git
Loading
Loading