Skip to content

Commit

Permalink
Add OP Plasma to devnet (ethereum-optimism#9844)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
trianglesphere authored Apr 15, 2024
1 parent 4a157b4 commit f32d197
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 31 deletions.
34 changes: 32 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ jobs:
DEVNET_NO_BUILD: 'true'
# Default value; Can be overridden.
DEVNET_FPAC: 'false'
DEVNET_PLASMA: 'false'
steps:
- checkout
- when:
Expand All @@ -1155,6 +1156,13 @@ jobs:
- run:
name: Set DEVNET_FPAC = true
command: echo 'export DEVNET_FPAC=true' >> $BASH_ENV
- when:
condition:
equal: ['plasma', <<parameters.fpac>>]
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:
Expand Down Expand Up @@ -1202,6 +1210,14 @@ jobs:
command: make submodules
- attach_workspace:
at: "."
- when:
condition:
not:
equal: ['legacy', <<parameters.fpac>>]
steps:
- run:
name: Use non-legacy devnet allocs
command: rm -r .devnet && mv .devnet-<<parameters.fpac>> .devnet
- run:
name: Load and tag docker images
command: |
Expand All @@ -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:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-stack-go:devnet"
docker tag "$IMAGE_BASE_PREFIX/op-node:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-node:devnet"
docker tag "$IMAGE_BASE_PREFIX/op-proposer:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-proposer:devnet"
docker tag "$IMAGE_BASE_PREFIX/op-batcher:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-batcher:devnet"
docker tag "$IMAGE_BASE_PREFIX/da-server:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/da-server:devnet"
- run:
name: pnpm i
command: |
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1772,18 +1795,25 @@ workflows:
docker_tags: <<pipeline.git.revision>>,<<pipeline.git.branch>>
requires: ['op-stack-go-docker-build']
save_image_tag: <<pipeline.git.revision>> # for devnet later
- docker-build:
name: da-server-docker-build
docker_name: da-server
docker_tags: <<pipeline.git.revision>>,<<pipeline.git.branch>>
requires: ['op-stack-go-docker-build']
save_image_tag: <<pipeline.git.revision>> # 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
Expand Down
10 changes: 10 additions & 0 deletions bedrock-devnet/devnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.')

Expand Down
13 changes: 13 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion op-node/rollup/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
34 changes: 6 additions & 28 deletions op-plasma/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 2 additions & 0 deletions op-plasma/cmd/daserver/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions op-plasma/daserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
35 changes: 35 additions & 0 deletions ops-bedrock/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ version: '3.4'
volumes:
l1_data:
l2_data:
da_data:
op_log:


Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions ops/docker/op-stack-go/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/

0 comments on commit f32d197

Please sign in to comment.