Skip to content

Commit

Permalink
feat: add Dockerfiles for fraud proof poc
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs committed Feb 19, 2024
1 parent 2632fa5 commit 1d600b7
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/fraud_proof_poc/Dockerfile.dymd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:1.20.13-alpine

RUN apk add git alpine-sdk
RUN apk add linux-headers bash
RUN git clone https://github.com/dymensionxyz/dymension.git --branch 'fraud_proof_poc'

WORKDIR /go/dymension
RUN go mod tidy
RUN make install
RUN sh scripts/setup_local.sh
EXPOSE 36657

CMD ["dymd", "start"]
12 changes: 12 additions & 0 deletions scripts/fraud_proof_poc/Dockerfile.mock-da
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:1.21.7-alpine AS builder

RUN apk add git alpine-sdk
RUN apk add linux-headers

RUN git clone https://github.com/dymensionxyz/dymint.git
WORKDIR /go/dymint/da/grpc/mockserv/cmd
RUN go mod tidy

EXPOSE 7980

ENTRYPOINT ["go", "run", "main.go"]
43 changes: 43 additions & 0 deletions scripts/fraud_proof_poc/Dockerfile.rollapp-evm
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM golang:1.20.13 AS builder

RUN git clone 'https://github.com/dymensionxyz/rollapp-evm.git' --branch 'feat/fraudproofs'
WORKDIR /go/rollapp-evm
RUN go mod tidy
RUN make install

WORKDIR /go
RUN apt update && apt install sudo jq -y

RUN curl -L https://dymensionxyz.github.io/roller/install.sh | bash
RUN git clone https://github.com/dymensionxyz/roller.git
WORKDIR /go/roller
RUN make build
RUN mv build/roller /usr/local/bin

WORKDIR /go
COPY ./wait-for-hub.sh .
RUN sudo chmod +x ./wait-for-hub.sh

RUN rm -rf ./rollapp-evm/
RUN rm -rf ./roller/

FROM builder

# CACHEBUST invalidates the cache so that a new roller config is created on each build and new wallets are generated
# podman build -f Dockerfile.rollapp-evm --build-arg CACHEBUST=$(date +%s) -t dymension:fraud_proof_poc_rollapp
ARG CACHEBUST=1

ENV ROLLAPP_NAME "dummy"
ENV ROLLAPP_DENOM "dum"
ENV ROLLAPP_BINARY "/go/bin/rollapp-evm"

RUN ls -la /usr/local/bin
RUN roller config init ${ROLLAPP_NAME} ${ROLLAPP_DENOM} --hub local --da local --rollapp-binary ${ROLLAPP_BINARY} > rollapp_init
RUN sed -i 's/^batch_submit_max_time.*/batch_submit_max_time = "10s"/' ~/.roller/rollapp/config/dymint.toml
RUN sed -i 's/^da_layer.*/da_layer = "grpc"/' ~/.roller/rollapp/config/dymint.toml
RUN sed -i 's/^.*"min_gas_price".*/"min_gas_price": "0.0",/' ~/.roller/rollapp/config/genesis.json
RUN sed -i 's/^empty_blocks_max_time.*/empty_blocks_max_time = "2s"/' ~/.roller/rollapp/config/dymint.toml
RUN sed -i 's/^da_config.*/da_config = "{\\\"host\\\": \\\"mock-da\\\", \\\"port\\\": 7980}"/' ~/.roller/rollapp/config/dymint.toml
RUN roller config set hub-rpc "http://hub:36657"

CMD [ "sleep", "infinity" ]
47 changes: 47 additions & 0 deletions scripts/fraud_proof_poc/Dockerfile.rollepp-evm-fullnode
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM golang:1.20.13 AS builder

RUN apt update && apt install sudo dnsutils jq -y
RUN git clone 'https://github.com/dymensionxyz/rollapp-evm.git' --branch 'feat/fraudproofs'
WORKDIR /go/rollapp-evm
RUN go mod tidy
RUN make install

WORKDIR /go

RUN git clone 'https://github.com/dymensionxyz/dymension.git' --branch 'fraud_proof_poc'

RUN curl -L https://dymensionxyz.github.io/roller/install.sh | bash
RUN git clone https://github.com/dymensionxyz/roller.git
WORKDIR /go/roller
RUN make build
RUN mv build/roller /usr/local/bin

WORKDIR /go
COPY ./wait-for-hub.sh .
RUN sudo chmod +x ./wait-for-hub.sh

# RUN rm -rf ./rollapp-evm/
# RUN rm -rf ./roller/

FROM builder

# CACHEBUST invalidates the cache so that a new roller config is created on each build and new wallets are generated
# podman build -f Dockerfile.rollapp-evm --build-arg CACHEBUST=$(date +%s) -t dymension:fraud_proof_poc_rollapp
ARG CACHEBUST=1

ENV ROLLAPP_NAME "dummy"
ENV ROLLAPP_DENOM "dum"
ENV ROLLAPP_BINARY "/go/bin/rollapp-evm"

RUN roller config init ${ROLLAPP_NAME} ${ROLLAPP_DENOM} --hub local --da local --rollapp-binary ${ROLLAPP_BINARY} > rollapp_init
RUN sed -i 's/^da_layer.*/da_layer = "grpc"/' ~/.roller/rollapp/config/dymint.toml
RUN sed -i 's/^da_config.*/da_config = "{\\\"host\\\": \\\"mock-da\\\", \\\"port\\\": 7980}"/' ~/.roller/rollapp/config/dymint.toml
RUN sed -i 's/^aggregator.*/aggregator = "false"/' ~/.roller/rollapp/config/dymint.toml
RUN sed -i 's/^settlement_layer.*/settlement_layer = "dymension"/' ~/.roller/rollapp/config/dymint.toml
RUN sed -i 's/^node_address.*/node_address = \"http:\/\/hub:36657\"/' ~/.roller/rollapp/config/dymint.toml
RUN sed -i 's/^gas_limit.*/gas_limit = 0/' ~/.roller/rollapp/config/dymint.toml
RUN sed -i 's/^gas_prices.*/gas_prices = "100000000adym"/' ~/.roller/rollapp/config/dymint.toml
RUN sed -i 's/^gas_fees.*/gas_fees = ""/' ~/.roller/rollapp/config/dymint.toml
RUN roller config set hub-rpc "http://hub:36657"

CMD [ "sleep", "infinity" ]
79 changes: 79 additions & 0 deletions scripts/fraud_proof_poc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
this example can be executed using `podma` or `docker`

1. run `podman compose up`, this will spin up all the necessary infrastructure that includes a local hub, mock da layer, sequencer with `fraud proof` feature enabled and a full node

2. once you see `hub is ready with latest_block_height: 1` in the compose logs, you can attach to the nodes
and proceed with the following steps

### hub

`podman exec -it fraud_proof_poc_fraud_proof_poc_hub_1 /bin/sh`, the following commands are executed inside the hub container

```sh
# fund the wallets that were generated during rollapp initialization
# you can find the generated wallets inside /go/rollapp_init file on the rollapp-evm and rollapp-evm-fullnode containers
wallets=("dym1yk67wjkcu80fqegjskks3km9vz5xshknseqk4j" "dym1672tc2t0f7uq8kqlg2h8da6vm7mu5uhy08luu3" "dym1anfjre42pa7mtnqa0vce8cjpxk66d366v3gg7j" "dym137a5e6k5g2x9w5st2k2u9l80p565lx3qwl7uhp")

for wallet in "${wallets[@]}"; do
echo "funding ${wallet}"
dymd tx bank send local-user $wallet \
10dym --gas-prices 100000000adym --yes -b block --keyring-backend test
done

```

### Sequencer

`podman exec -it fraud_proof_poc_rollapp-evm_1 /bin/sh`, the following commands are executed inside the sequencer container

```sh
# register the rollapp
roller tx register

rollapp-evm dymint show-node-id --home ~/.roller/rollapp

# start the sequencer with fraud_proof enabled
rollapp-evm --home ~/.roller/rollapp start --dymint.simulate_fraud &

rollapp-evm --home ~/.roller/rollapp/ tx bank send \
rollapp_sequencer ethm1wss9w8e89ntkn73n25lm6c7ul36u282c4sq5qm 100000adum \
--keyring-backend test --broadcast-mode block -y --keyring-backend test
```


### Full Node

copy the `genesis.json` file from the sequencer to the full node

```sh
podman cp fraud_proof_poc_rollapp-evm_1:/root/.roller/rollapp/config/genesis.json \
fraud_proof_poc_rollapp-evm-fullnode_1:/root/.roller/rollapp/config/genesis.json

```

```sh
export ROLLAPP_CHAIN_ID="dummy_9361346-1"
export SEQUENCER_NODE_ID="12D3KooWQrNRe8ejp13aQauGze9UZw1kmgYR73K5iyzsKxVirLjz"

sed -i "s/^rollapp_id.*/rollapp_id = \"${ROLLAPP_CHAIN_ID}\"/" ~/.roller/rollapp/config/dymint.toml

sed -i "s/^seeds =.*/seeds = \"tcp:\/\/${SEQUENCER_NODE_ID}@$(dig +short rollapp-evm):26656\/\"/" ~/.roller/rollapp/config/config.toml

rollapp-evm --home ~/.roller/rollapp start

```

outside the container, run

```sh
# copy and submit the fraud proof
podman cp fraud_proof_poc_rollapp-evm-fullnode_1:/go/fraudProof_rollapp_with_tx.json \
fraud_proof_poc_hub_1:/go/fraudProof_rollapp_with_tx.json
```

```sh
# from hub node
dymd tx rollapp submit-fraud ${ROLLAPP_CHAIN_ID} \
/go/fraudProof_rollapp_with_tx.json --from local-user \
--gas 50000000 -b block
```
38 changes: 38 additions & 0 deletions scripts/fraud_proof_poc/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: '3.8'

services:
mock-da:
build:
context: .
dockerfile: Dockerfile.mock-da
ports:
- "7980:7980"

hub:
build:
context: .
dockerfile: Dockerfile.dymd
ports:
- "36657:36657"

rollapp-evm:
build:
context: .
dockerfile: Dockerfile.rollapp-evm
args:
CACHEBUST: ${CACHEBUST}
depends_on:
- mock-da
- dymd
command: [ "/go/wait-for-hub.sh", "sleep", "infinity" ]

rollapp-evm-fullnode:
build:
context: .
dockerfile: Dockerfile.rollepp-evm-fullnode
args:
CACHEBUST: ${CACHEBUST}
depends_on:
- mock-da
- dymd
command: [ "/go/wait-for-hub.sh", "sleep", "infinity" ]

0 comments on commit 1d600b7

Please sign in to comment.