From f32d1972cba01e4d29b7d5b5cedcf6345679e3e4 Mon Sep 17 00:00:00 2001 From: Joshua Gutow Date: Mon, 15 Apr 2024 14:59:27 -0700 Subject: [PATCH] Add OP Plasma to devnet (#9844) * Add OP Plasma to devnet * Update CCI config * Re-add plasma ope2e * Add da-server to docker build * Fixes * Add tickets to TODOs * Update after merge --- .circleci/config.yml | 34 +++++++++++++++++++++++++-- bedrock-devnet/devnet/__init__.py | 10 ++++++++ docker-bake.hcl | 13 +++++++++++ op-node/rollup/types.go | 2 +- op-plasma/Dockerfile | 34 +++++---------------------- op-plasma/cmd/daserver/entrypoint.go | 2 ++ op-plasma/daserver.go | 1 + ops-bedrock/docker-compose.yml | 35 ++++++++++++++++++++++++++++ ops/docker/op-stack-go/Dockerfile | 3 +++ 9 files changed, 103 insertions(+), 31 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6e7ad0f322b4..60b1eddf759d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1146,6 +1146,7 @@ jobs: DEVNET_NO_BUILD: 'true' # Default value; Can be overridden. DEVNET_FPAC: 'false' + DEVNET_PLASMA: 'false' steps: - checkout - when: @@ -1155,6 +1156,13 @@ jobs: - run: name: Set DEVNET_FPAC = true command: echo 'export DEVNET_FPAC=true' >> $BASH_ENV + - when: + condition: + equal: ['plasma', <>] + steps: + - run: + name: Set DEVNET_PLASMA = true + command: echo 'export DEVNET_PLASMA=true' >> $BASH_ENV - check-changed: patterns: op-(.+),packages,ops-bedrock,bedrock-devnet - run: @@ -1202,6 +1210,14 @@ jobs: command: make submodules - attach_workspace: at: "." + - when: + condition: + not: + equal: ['legacy', <>] + steps: + - run: + name: Use non-legacy devnet allocs + command: rm -r .devnet && mv .devnet-<> .devnet - run: name: Load and tag docker images command: | @@ -1211,11 +1227,13 @@ jobs: docker load < "./op-node.tar" docker load < "./op-proposer.tar" docker load < "./op-batcher.tar" + docker load < "./da-server.tar" # rename to the tags that the docker-compose of the devnet expects docker tag "$IMAGE_BASE_PREFIX/op-stack-go:<>" "$IMAGE_BASE_PREFIX/op-stack-go:devnet" docker tag "$IMAGE_BASE_PREFIX/op-node:<>" "$IMAGE_BASE_PREFIX/op-node:devnet" docker tag "$IMAGE_BASE_PREFIX/op-proposer:<>" "$IMAGE_BASE_PREFIX/op-proposer:devnet" docker tag "$IMAGE_BASE_PREFIX/op-batcher:<>" "$IMAGE_BASE_PREFIX/op-batcher:devnet" + docker tag "$IMAGE_BASE_PREFIX/da-server:<>" "$IMAGE_BASE_PREFIX/da-server:devnet" - run: name: pnpm i command: | @@ -1258,6 +1276,11 @@ jobs: command: | docker logs ops-bedrock-op-challenger-1 || echo "No logs." when: on_fail + - run: + name: Dump da-server logs + command: | + docker logs ops-bedrock-da-server-1 || echo "No logs." + when: on_fail - run: name: Log deployment artifact command: | @@ -1663,7 +1686,7 @@ workflows: name: op-e2e-action-tests<< matrix.fpac >> matrix: parameters: - fpac: ["", "-fault-proofs"] + fpac: ["", "-fault-proofs", "-plasma"] module: op-e2e target: test-actions parallelism: 1 @@ -1772,18 +1795,25 @@ workflows: docker_tags: <>,<> requires: ['op-stack-go-docker-build'] save_image_tag: <> # for devnet later + - docker-build: + name: da-server-docker-build + docker_name: da-server + docker_tags: <>,<> + requires: ['op-stack-go-docker-build'] + save_image_tag: <> # for devnet later - cannon-prestate: requires: - go-mod-download - devnet: matrix: parameters: - fpac: ["legacy", "fault-proofs"] + fpac: ["legacy", "fault-proofs", "plasma"] requires: - pnpm-monorepo - op-batcher-docker-build - op-proposer-docker-build - op-node-docker-build + - da-server-docker-build - cannon-prestate - docker-build: name: indexer-docker-build diff --git a/bedrock-devnet/devnet/__init__.py b/bedrock-devnet/devnet/__init__.py index 84e18d6a74e9..7e10a216c9ae 100644 --- a/bedrock-devnet/devnet/__init__.py +++ b/bedrock-devnet/devnet/__init__.py @@ -235,6 +235,11 @@ def devnet_deploy(paths): else: docker_env['L2OO_ADDRESS'] = l2_output_oracle + if DEVNET_PLASMA: + docker_env['PLASMA_ENABLED'] = 'true' + else: + docker_env['PLASMA_ENABLED'] = 'false' + # Bring up the rest of the services. log.info('Bringing up `op-node`, `op-proposer` and `op-batcher`.') run_command(['docker', 'compose', 'up', '-d', 'op-node', 'op-proposer', 'op-batcher', 'artifact-server'], cwd=paths.ops_bedrock_dir, env=docker_env) @@ -244,6 +249,11 @@ def devnet_deploy(paths): log.info('Bringing up `op-challenger`.') run_command(['docker', 'compose', 'up', '-d', 'op-challenger'], cwd=paths.ops_bedrock_dir, env=docker_env) + # Optionally bring up OP Plasma. + if DEVNET_PLASMA: + log.info('Bringing up `da-server`, `sentinel`.') # TODO(10141): We don't have public sentinel images yet + run_command(['docker', 'compose', 'up', '-d', 'da-server'], cwd=paths.ops_bedrock_dir, env=docker_env) + # Fin. log.info('Devnet ready.') diff --git a/docker-bake.hcl b/docker-bake.hcl index 027f2adff683..af34337a8b28 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -132,6 +132,19 @@ target "op-heartbeat" { tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/op-heartbeat:${tag}"] } +target "da-server" { + dockerfile = "Dockerfile" + context = "./op-plasma" + args = { + OP_STACK_GO_BUILDER = "op-stack-go" + } + contexts = { + op-stack-go: "target:op-stack-go" + } + platforms = split(",", PLATFORMS) + tags = [for tag in split(",", IMAGE_TAGS) : "${REGISTRY}/${REPOSITORY}/da-server:${tag}"] +} + target "op-program" { dockerfile = "Dockerfile" context = "./op-program" diff --git a/op-node/rollup/types.go b/op-node/rollup/types.go index 1ad45272e8aa..b31d7edbb546 100644 --- a/op-node/rollup/types.go +++ b/op-node/rollup/types.go @@ -110,7 +110,7 @@ type Config struct { ProtocolVersionsAddress common.Address `json:"protocol_versions_address,omitempty"` // L1 DataAvailabilityChallenge contract proxy address - DAChallengeAddress common.Address `json:"da_challenge_address,omitempty"` + DAChallengeAddress common.Address `json:"da_challenge_contract_address,omitempty"` // DA challenge window value set on the DAC contract. Used in plasma mode // to compute when a commitment can no longer be challenged. diff --git a/op-plasma/Dockerfile b/op-plasma/Dockerfile index 3daa52eca3f3..122e8b09644a 100644 --- a/op-plasma/Dockerfile +++ b/op-plasma/Dockerfile @@ -1,31 +1,9 @@ -FROM --platform=$BUILDPLATFORM golang:1.21.3-alpine3.18 as builder - -RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash - -# We copy the go.mod/sum first, so the `go mod download` does not have to re-run if dependencies do not change. -COPY ./go.mod /app/go.mod -COPY ./go.sum /app/go.sum - -WORKDIR /app - -RUN echo "go mod cache: $(go env GOMODCACHE)" -RUN echo "go build cache: $(go env GOCACHE)" - -RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go mod download - -# NOTE: the Dockerfile.dockerignore file effectively describes all dependencies -COPY . /app - -ARG GIT_COMMIT -ARG GIT_DATE - -ARG DASERVER_VERSION=v0.0.0 - -ARG TARGETOS TARGETARCH - -RUN --mount=type=cache,target=/root/.cache/go-build cd op-plasma && make da-server \ - GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE VERSION="$DASERVER_VERSION" +ARG OP_STACK_GO_BUILDER=us-docker.pkg.dev/oplabs-tools-artifacts/images/op-stack-go:latest +FROM $OP_STACK_GO_BUILDER as builder +# See "make golang-docker" and /ops/docker/op-stack-go FROM alpine:3.18 -COPY --from=builder /app/op-plasma/bin/da-server /usr/local/bin/ +COPY --from=builder /usr/local/bin/da-server /usr/local/bin/da-server + +CMD ["da-server"] diff --git a/op-plasma/cmd/daserver/entrypoint.go b/op-plasma/cmd/daserver/entrypoint.go index 7efa0d6bab55..e70058f962ea 100644 --- a/op-plasma/cmd/daserver/entrypoint.go +++ b/op-plasma/cmd/daserver/entrypoint.go @@ -45,6 +45,8 @@ func StartDAServer(cliCtx *cli.Context) error { if err := server.Start(); err != nil { return fmt.Errorf("failed to start the DA server") + } else { + l.Info("Started DA Server") } defer func() { diff --git a/op-plasma/daserver.go b/op-plasma/daserver.go index be1ce4ceb682..0a3307b80be8 100644 --- a/op-plasma/daserver.go +++ b/op-plasma/daserver.go @@ -138,6 +138,7 @@ func (d *DAServer) HandlePut(w http.ResponseWriter, r *http.Request) { } if err := d.store.Put(r.Context(), comm, input); err != nil { + d.log.Info("Failed to store commitment to the DA server", "err", err, "key", key) w.WriteHeader(http.StatusInternalServerError) return } diff --git a/ops-bedrock/docker-compose.yml b/ops-bedrock/docker-compose.yml index 8206a6fb518b..e0ee50c320b3 100644 --- a/ops-bedrock/docker-compose.yml +++ b/ops-bedrock/docker-compose.yml @@ -7,6 +7,7 @@ version: '3.4' volumes: l1_data: l2_data: + da_data: op_log: @@ -89,6 +90,8 @@ services: --metrics.port=7300 --pprof.enabled --rpc.enable-admin + --plasma.enabled=${PLASMA_ENABLED} + --plasma.da-server=http://da-server:3100 ports: - "7545:8545" - "9003:9003" @@ -163,6 +166,8 @@ services: OP_BATCHER_METRICS_ENABLED: "true" OP_BATCHER_RPC_ENABLE_ADMIN: "true" OP_BATCHER_BATCH_TYPE: 0 + OP_BATCHER_PLASMA_ENABLED: "${PLASMA_ENABLED}" + OP_BATCHER_PLASMA_DA_SERVER: "http://da-server:3100" op-challenger: depends_on: @@ -199,6 +204,36 @@ services: OP_CHALLENGER_HD_PATH: "m/44'/60'/0'/0/4" OP_CHALLENGER_NUM_CONFIRMATIONS: 1 + da-server: + image: us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:devnet + build: + context: ../ + dockerfile: ./op-plasma/Dockerfile + command: > + da-server + --file.path=/data + --addr=0.0.0.0 + --port=3100 + --log.level=debug + ports: + - "3100:3100" + volumes: + - "l2_data:/data" + + sentinel: + image: quarry/sentinel # TODO(10141): We need a public image for this (sentinel is out of repo) + volumes: + - "${PWD}/../.devnet/rollup.json:/rollup.json" + # private-key is mnemonic index 5 of the test mnemonic. + command: > + sentinel + --datadir=data + --l1-rpc-http=http://l1:8545 + --l1-rpc-ws=ws://l1:8546 + --da-storage-uri=http://da-server:3100 + --private-key=0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba + --config=/rollup.json + artifact-server: depends_on: - l1 diff --git a/ops/docker/op-stack-go/Dockerfile b/ops/docker/op-stack-go/Dockerfile index ee3cbc95e383..1272e107c1c2 100644 --- a/ops/docker/op-stack-go/Dockerfile +++ b/ops/docker/op-stack-go/Dockerfile @@ -71,6 +71,8 @@ RUN --mount=type=cache,target=/root/.cache/go-build cd op-proposer && make op-pr GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE VERSION="$OP_PROPOSER_VERSION" RUN --mount=type=cache,target=/root/.cache/go-build cd op-conductor && make op-conductor \ GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE VERSION="$OP_CONDUCTOR_VERSION" +RUN --mount=type=cache,target=/root/.cache/go-build cd op-plasma && make da-server \ + GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE FROM alpine:3.18 @@ -87,3 +89,4 @@ COPY --from=builder /app/op-dispute-mon/bin/op-dispute-mon /usr/local/bin/ COPY --from=builder /app/op-batcher/bin/op-batcher /usr/local/bin/ COPY --from=builder /app/op-proposer/bin/op-proposer /usr/local/bin/ COPY --from=builder /app/op-conductor/bin/op-conductor /usr/local/bin/ +COPY --from=builder /app/op-plasma/bin/da-server /usr/local/bin/