Skip to content

Commit

Permalink
Merge branch 'main' into feat/cdk-erigon-node-3
Browse files Browse the repository at this point in the history
  • Loading branch information
leovct committed Apr 30, 2024
2 parents 372e761 + af99bdf commit 4bf56da
Show file tree
Hide file tree
Showing 17 changed files with 436 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: deploy
name: Deploy

on:
pull_request:
Expand Down
118 changes: 118 additions & 0 deletions .github/workflows/docker-image-builder-cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
name: Docker Image Builder Cron

on:
schedule:
- cron: '0 6 * * 1' # Every Monday at 6 AM Paris time (UTC+2).
workflow_dispatch:
pull_request: # TODO: Remove this. This is just for testing purposes.

concurrency:
group: docker-image-builder-cron-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
ZKEVM_BRIDGE_UI_BRANCH: develop
POLYCLI_VERSION: main

jobs:
zkevm-contracts:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
fork:
- id: fork4
branch: v1.1.0-fork.4
- id: fork5
branch: v2.0.0-fork.5
- id: fork6
branch: v3.0.0-fork.6
- id: fork7
branch: v4.0.0-fork.7
- id: fork8
branch: v5.0.1-rc.2-fork.8
- id: fork9
branch: v6.0.0-rc.1-fork.9
- id: develop
branch: develop

steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v5
with:
file: docker/zkevm-contracts.Dockerfile
build-args: |
ZKEVM_CONTRACTS_BRANCH=${{ matrix.fork.branch }}
POLYCLI_VERSION=${{ env.POLYCLI_VERSION }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/zkevm-contracts:${{ matrix.fork.id }}
platforms: linux/amd64,linux/arm64
push: true

zkevm-bridge-ui:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Clone zkevm-bridge-ui repository
run: |
mkdir /opt/zkevm-bridge-ui
git clone --branch ${{ env.ZKEVM_BRIDGE_UI_BRANCH }} https://github.com/0xPolygonHermez/zkevm-bridge-ui /opt/zkevm-bridge-ui
- name: Apply patches
working-directory: /opt/zkevm-bridge-ui
run: |
patch -p1 -i ${{ github.workspace }}/docker/zkevm-bridge-ui/deploy.sh.diff
patch -p1 -i ${{ github.workspace }}/docker/zkevm-bridge-ui/env.ts.diff
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: /opt/zkevm-bridge-ui
file: /opt/zkevm-bridge-ui/Dockerfile
tags: ${{ secrets.DOCKERHUB_USERNAME }}/zkevm-bridge-ui:multi-network
platforms: linux/amd64,linux/arm64
push: true

workload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v5
with:
file: docker/workload.Dockerfile
build-args: |
POLYCLI_VERSION=${{ env.POLYCLI_VERSION }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/workload:0.0.1
platforms: linux/amd64,linux/arm64
push: true
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: lint
name: Lint

on:
pull_request:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
run: yamllint --config-file ${{ github.workspace }}/.yamllint.yml .

- name: Run hadolint
run: find . -type f -name 'Dockerfile*' | sort | xargs -I {} hadolint --config ${{ github.workspace }}/.hadolint.yml {}
run: find . -type f -name '*.Dockerfile' | sort | xargs -I {} hadolint --config ${{ github.workspace }}/.hadolint.yml {}

- name: Run shellcheck
run: find . -type f -name '*.sh' | sort | xargs -I {} shellcheck {}
3 changes: 2 additions & 1 deletion .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: regression-tests
---
name: Regression Tests

on:
workflow_dispatch:
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion doc-drafts/trigger-a-reorg/network-helper.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ WORKDIR /opt/polygon-cli
RUN git clone https://github.com/maticnetwork/polygon-cli.git . \
&& CGO_ENABLED=0 go build -o polycli main.go

FROM nicolaka/netshoot:latest
FROM nicolaka/netshoot:v0.12
LABEL author="[email protected]"
LABEL description="Helper image to debug network issues"
COPY --from=polycli-builder /opt/polygon-cli/polycli /usr/local/bin/polycli
28 changes: 0 additions & 28 deletions doc-drafts/zkevm-contracts-images-builder.sh

This file was deleted.

72 changes: 72 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Custom Docker Images for Kurtosis CDK

We maintain a suite of custom Docker images tailored specifically for deploying the CDK stack. These images serve various purposes, including hosting distinct zkEVM contracts (each fork tagged separately), adapting the bridge UI to support relative URLs, and applying specific workloads.

We ensure the continuous availability of our custom Docker images through an automated build process. A [cron](../.github/workflows/docker-image-builder-cron.yml) job is configured to run weekly, automatically triggering the build and push of these images. This ensures that the images are regularly updated with the latest changes and dependencies. Moreover, should immediate updates or manual initiation of the image building process be required, users can access the GitHub UI for manual triggering. Alternatively, the images can be built locally by following the provided guide.

## Local Image Building

If you ever need to build these images locally, here's a brief guide.

### zkEVM Contracts

To build a local image containing all npm dependencies and zkEVM contracts compiled for fork ID 9, follow these steps:

```bash
docker build . \
--tag local/zkevm-contracts:fork9 \
--build-arg ZKEVM_CONTRACTS_BRANCH=v6.0.0-rc.1-fork.9 \
--build-arg POLYCLI_VERSION=main \
--file zkevm-contracts.Dockerfile
```

```bash
$ docker images --filter "reference=local/zkevm-contracts"
REPOSITORY TAG IMAGE ID CREATED SIZE
local/zkevm-contracts fork9 54d894c6a5bd 10 minutes ago 2.3GB
```

Here's a quick reference matrix for mapping fork IDs to branches/releases:

| Fork ID | Branch |
| ------- | ------------------ |
| fork4 | v1.1.0-fork.4 |
| fork5 | v2.0.0-fork.5 |
| fork6 | v3.0.0-fork.6 |
| fork7 | v4.0.0-fork.7 |
| fork8 | v5.0.1-rc.2-fork.8 |
| fork9 | develop |

## zkEVM Bridge UI

To build the zkEVM Bridge UI image locally, use the following command:

```bash
docker build zkevm-bridge-ui \
--tag local/zkevm-bridge-ui:multi-network \
--build-arg ZKEVM_BRIDGE_UI_TAG=develop \
--file zkevm-bridge-ui/zkevm-bridge-ui.Dockerfile
```

```bash
$ docker images --filter "reference=local/zkevm-bridge-ui"
REPOSITORY TAG IMAGE ID CREATED SIZE
local/zkevm-bridge-ui multi-network 040905e1cabe 28 seconds ago 377MB
```

## Workload

To build the workload image locally, use the following command:

```bash
docker build . \
--tag local/workload:0.0.1 \
--build-arg POLYCLI_VERSION=main \
--file workload.Dockerfile
```

```bash
$ docker images --filter "reference=local/workload"
REPOSITORY TAG IMAGE ID CREATED SIZE
local/workload 0.0.1 3f85f026aaf9 2 seconds ago 490MB
```
5 changes: 3 additions & 2 deletions doc-drafts/workload.Dockerfile → docker/workload.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ LABEL description="Helper image capable of executing diverse workloads"

COPY --from=polycli-builder /opt/polygon-cli/polycli /usr/bin/polycli
# WARNING (DL3008): Pin versions in apt get install.
# WARNING (DL3013): Pin versions in pip.
# WARNING (DL4006): Set the SHELL option -o pipefail before RUN with a pipe in it
# WARNING (SC1091): (Sourced) file not included in mock.
# hadolint ignore=DL3008,DL4006,SC1091
# hadolint ignore=DL3008,DL3013,DL4006,SC1091
RUN apt-get update \
&& apt-get install --yes --no-install-recommends curl jq git python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install yq \
&& pip3 install --no-cache-dir yq \
&& curl --silent --location --proto "=https" https://foundry.paradigm.xyz | bash \
&& /root/.foundry/bin/foundryup \
&& cp /root/.foundry/bin/* /usr/local/bin
13 changes: 13 additions & 0 deletions docker/zkevm-bridge-ui/deploy.sh.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/scripts/deploy.sh b/scripts/deploy.sh
index 22e5b09..00da634 100644
--- a/scripts/deploy.sh
+++ b/scripts/deploy.sh
@@ -21,6 +21,9 @@ echo "VITE_POLYGON_ZK_EVM_NETWORK_ID=$POLYGON_ZK_EVM_NETWORK_ID" >> $ENV_FILENAM
# BRIDGE API env vars
echo "VITE_BRIDGE_API_URL=$BRIDGE_API_URL" >> $ENV_FILENAME

+# Support for relative URLS
+echo "VITE_RESOLVE_RELATIVE_URLS=$RESOLVE_RELATIVE_URLS" >> $ENV_FILENAME
+
# FIAT EXCHANGE RATES API env vars
echo "VITE_ENABLE_FIAT_EXCHANGE_RATES=$ENABLE_FIAT_EXCHANGE_RATES" >> $ENV_FILENAME
100 changes: 100 additions & 0 deletions docker/zkevm-bridge-ui/env.ts.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
diff --git a/src/adapters/env.ts b/src/adapters/env.ts
index 034b982..bfa5d93 100644
--- a/src/adapters/env.ts
+++ b/src/adapters/env.ts
@@ -31,6 +31,7 @@ interface Env {
VITE_REPORT_FORM_PLATFORM_ENTRY?: string;
VITE_REPORT_FORM_URL?: string;
VITE_REPORT_FORM_URL_ENTRY?: string;
+ VITE_RESOLVE_RELATIVE_URLS?: string;
}

type GetFiatExchangeRatesEnvParams = Pick<
@@ -180,6 +181,7 @@ const envToDomain = ({
VITE_REPORT_FORM_PLATFORM_ENTRY,
VITE_REPORT_FORM_URL,
VITE_REPORT_FORM_URL_ENTRY,
+ VITE_RESOLVE_RELATIVE_URLS,
}: Env): Promise<domain.Env> => {
const polygonZkEVMNetworkId = z.coerce.number().positive().parse(VITE_POLYGON_ZK_EVM_NETWORK_ID);
const isOutdatedNetworkModalEnabled = stringBooleanParser.parse(
@@ -188,7 +190,30 @@ const envToDomain = ({
const forceUpdateGlobalExitRootForL1 = stringBooleanParser.parse(
VITE_ETHEREUM_FORCE_UPDATE_GLOBAL_EXIT_ROOT
);
- const bridgeApiUrl = VITE_BRIDGE_API_URL;
+
+ const isSupportForRelativeUrlsEnabled = stringBooleanParser.parse(VITE_RESOLVE_RELATIVE_URLS);
+
+ let bridgeApiUrl: string;
+ if (isSupportForRelativeUrlsEnabled) {
+ bridgeApiUrl = window.location.origin + VITE_BRIDGE_API_URL;
+ } else {
+ bridgeApiUrl = VITE_BRIDGE_API_URL;
+ }
+
+ let ethereumRpcUrl: string;
+ if (isSupportForRelativeUrlsEnabled) {
+ ethereumRpcUrl = window.location.origin + VITE_ETHEREUM_RPC_URL;
+ } else {
+ ethereumRpcUrl = VITE_ETHEREUM_RPC_URL;
+ }
+
+ let zkevmRpcUrl: string;
+ if (isSupportForRelativeUrlsEnabled) {
+ zkevmRpcUrl = window.location.origin + VITE_POLYGON_ZK_EVM_RPC_URL;
+ } else {
+ zkevmRpcUrl = VITE_POLYGON_ZK_EVM_RPC_URL;
+ }
+
const outdatedNetworkModal: domain.Env["outdatedNetworkModal"] = isOutdatedNetworkModalEnabled
? {
isEnabled: true,
@@ -208,13 +233,13 @@ const envToDomain = ({
explorerUrl: VITE_ETHEREUM_EXPLORER_URL,
poeContractAddress: VITE_ETHEREUM_PROOF_OF_EFFICIENCY_CONTRACT_ADDRESS,
rollupManagerAddress: VITE_ETHEREUM_ROLLUP_MANAGER_ADDRESS,
- rpcUrl: VITE_ETHEREUM_RPC_URL,
+ rpcUrl: ethereumRpcUrl,
},
polygonZkEVM: {
bridgeContractAddress: VITE_POLYGON_ZK_EVM_BRIDGE_CONTRACT_ADDRESS,
explorerUrl: VITE_POLYGON_ZK_EVM_EXPLORER_URL,
networkId: polygonZkEVMNetworkId,
- rpcUrl: VITE_POLYGON_ZK_EVM_RPC_URL,
+ rpcUrl: zkevmRpcUrl,
},
}).then((chains) => {
const ethereumChain = chains.find((chain) => chain.key === "ethereum");
@@ -250,7 +275,7 @@ const envToDomain = ({
const envParser = StrictSchema<Env, domain.Env>()(
z
.object({
- VITE_BRIDGE_API_URL: z.string().url(),
+ VITE_BRIDGE_API_URL: z.string(),
VITE_ENABLE_DEPOSIT_WARNING: z.string(),
VITE_ENABLE_FIAT_EXCHANGE_RATES: z.string(),
VITE_ENABLE_OUTDATED_NETWORK_MODAL: z.string().optional(),
@@ -260,7 +285,7 @@ const envParser = StrictSchema<Env, domain.Env>()(
VITE_ETHEREUM_FORCE_UPDATE_GLOBAL_EXIT_ROOT: z.string(),
VITE_ETHEREUM_PROOF_OF_EFFICIENCY_CONTRACT_ADDRESS: z.string().length(42),
VITE_ETHEREUM_ROLLUP_MANAGER_ADDRESS: z.string().length(42),
- VITE_ETHEREUM_RPC_URL: z.string().url(),
+ VITE_ETHEREUM_RPC_URL: z.string(),
VITE_FIAT_EXCHANGE_RATES_API_KEY: z.string().optional(),
VITE_FIAT_EXCHANGE_RATES_API_URL: z.string().url().optional(),
VITE_FIAT_EXCHANGE_RATES_ETHEREUM_USDC_ADDRESS: z.string().length(42).optional(),
@@ -271,11 +296,12 @@ const envParser = StrictSchema<Env, domain.Env>()(
VITE_POLYGON_ZK_EVM_BRIDGE_CONTRACT_ADDRESS: z.string().length(42),
VITE_POLYGON_ZK_EVM_EXPLORER_URL: z.string().url(),
VITE_POLYGON_ZK_EVM_NETWORK_ID: z.string(),
- VITE_POLYGON_ZK_EVM_RPC_URL: z.string().url(),
+ VITE_POLYGON_ZK_EVM_RPC_URL: z.string(),
VITE_REPORT_FORM_ERROR_ENTRY: z.string().optional(),
VITE_REPORT_FORM_PLATFORM_ENTRY: z.string().optional(),
VITE_REPORT_FORM_URL: z.string().optional(),
VITE_REPORT_FORM_URL_ENTRY: z.string().optional(),
+ VITE_RESOLVE_RELATIVE_URLS: z.string().optional(),
})
.transform(envToDomain)
);
Loading

0 comments on commit 4bf56da

Please sign in to comment.