From aefe1483b40c06844db97bfb3a43ea596e4ab5a2 Mon Sep 17 00:00:00 2001 From: Elias Tazartes <66871571+Eikix@users.noreply.github.com> Date: Tue, 6 Feb 2024 18:05:59 +0100 Subject: [PATCH] Feat/fix deployer (#950) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Time spent on this PR: ## Pull request type Please check the type of change your PR introduces: - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [x] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? Resolves #948 - - - This change is [Reviewable](https://reviewable.io/reviews/kkrt-labs/kakarot/950) --- .dockerignore | 7 +- .trunk/trunk.yaml | 14 +- docker/ci/Dockerfile | 55 ---- docker/ci/README.md | 17 -- docker/ci/setup_16.x | 370 ----------------------- docker/deployer/Dockerfile | 45 ++- docker/devnet/Dockerfile | 9 - docker/devnet/run_and_deploy.py | 35 --- docker/katana/Dockerfile | 45 --- docker/katana/scripts/download_katana.sh | 11 - docker/katana/scripts/run.sh | 7 - docker/katana/scripts/wait_and_deploy.sh | 39 --- scripts/constants.py | 2 +- 13 files changed, 55 insertions(+), 601 deletions(-) delete mode 100644 docker/ci/Dockerfile delete mode 100644 docker/ci/README.md delete mode 100644 docker/ci/setup_16.x delete mode 100644 docker/devnet/Dockerfile delete mode 100755 docker/devnet/run_and_deploy.py delete mode 100644 docker/katana/Dockerfile delete mode 100644 docker/katana/scripts/download_katana.sh delete mode 100644 docker/katana/scripts/run.sh delete mode 100644 docker/katana/scripts/wait_and_deploy.sh diff --git a/.dockerignore b/.dockerignore index 2eea525d8..cc3d1ea1f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,6 @@ -.env \ No newline at end of file +.env +docs/ +coverage/ +.venv/ +blockchain-tests-skip.yml +.github/ diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 0a74f025a..3c2a5351e 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -27,26 +27,28 @@ lint: read_output_from: stdout run_linter_from: workspace enabled: + - osv-scanner@1.6.2 + - trivy@0.49.0 - cairo@SYSTEM - actionlint@1.6.26 - - black@23.12.1 - - checkov@3.1.63 + - black@24.1.1 + - checkov@3.2.5 - codespell@2.2.6 - git-diff-check - hadolint@2.12.0 - isort@5.13.2 - - markdownlint@0.38.0 + - markdownlint@0.39.0 - oxipng@9.0.0 - - prettier@3.2.3 - - ruff@0.1.13 + - prettier@3.2.5 + - ruff@0.2.1 - shellcheck@0.9.0 - shfmt@3.6.0 - taplo@0.8.1 - - terrascan@1.18.11 - yamllint@1.33.0 disabled: - trufflehog - bandit + - terrascan ignore: - linters: [bandit] paths: [tests, docker] diff --git a/docker/ci/Dockerfile b/docker/ci/Dockerfile deleted file mode 100644 index d8cf24774..000000000 --- a/docker/ci/Dockerfile +++ /dev/null @@ -1,55 +0,0 @@ -FROM ubuntu:22.04 -LABEL org.opencontainers.image.authors="p.tisserand@gmail.com" - -# ## Configuration for local user if needed -# ARG USER=rob -# ARG USER_ID=1000 -# ARG GROUP=starknet -# ARG GROUP_ID=1000 -# - -RUN apt-get update -# Set the locale -RUN apt-get install -y locales && \ - sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \ - locale-gen -ENV LANG en_US.UTF-8 -ENV LANGUAGE en_US:en -ENV LC_ALL en_US.UTF-8 - -RUN apt-get install -yq tzdata && \ - ln -fs /usr/share/zoneinfo/Europe/Paris /etc/localtime && \ - dpkg-reconfigure -f noninteractive tzdata -RUN apt-get install -y software-properties-common - -# nodejs 16.x is required by github actions -COPY ./setup_16.x /tmp -RUN bash /tmp/setup_16.x && \ - apt-get update && \ - apt-get install -y nodejs - - -RUN add-apt-repository -y ppa:deadsnakes/ppa -RUN apt-get install -y \ - build-essential \ - python3.9 \ - python3.9-venv \ - python3.9-dev \ - libgmp3-dev -# foundry dependencies -RUN apt-get install -y \ - git \ - zstd - -# # Create new user -# RUN \ -# addgroup --gid ${GROUP_ID} ${GROUP} && \ -# adduser --uid ${USER_ID} --ingroup ${GROUP} --disabled-password --gecos "" ${USER} -# -# USER ${USER} -# WORKDIR /home/${USER} -# RUN python3.9 -m venv venv -# ENV PATH /home/${USER}/venv/bin:$PATH -# RUN pip install --upgrade pip - - diff --git a/docker/ci/README.md b/docker/ci/README.md deleted file mode 100644 index 9ddfb756a..000000000 --- a/docker/ci/README.md +++ /dev/null @@ -1,17 +0,0 @@ -Dockerfile used to create image run by kakarot self hosted github runner: - -- `nodejs 16.x`: github action dependency -- `python 3.9`: kakarot dependency -- `git & zstd`: foundry dependencies - -To build the image: - -```bash -docker build -t YOUR_DOCKER_HUB_USER/kakarot-builder:latest . -``` - -To publish your image on docker hub: - -```bash -docker push YOUR_DOCKER_HUB_USER/kakarot-builder:latest -``` diff --git a/docker/ci/setup_16.x b/docker/ci/setup_16.x deleted file mode 100644 index 92b2f3bb0..000000000 --- a/docker/ci/setup_16.x +++ /dev/null @@ -1,370 +0,0 @@ -#!/bin/bash - -# Discussion, issues and change requests at: -# https://github.com/nodesource/distributions -# -# Script to install the NodeSource Node.js 16.x repo onto a -# Debian or Ubuntu system. -# -# Run as root or insert `sudo -E` before `bash`: -# -# curl -sL https://deb.nodesource.com/setup_16.x | bash - -# or -# wget -qO- https://deb.nodesource.com/setup_16.x | bash - -# -# CONTRIBUTIONS TO THIS SCRIPT -# -# This script is built from a template in -# https://github.com/nodesource/distributions/tree/master/deb/src -# please don't submit pull requests against the built scripts. -# - -export DEBIAN_FRONTEND=noninteractive -SCRSUFFIX="_16.x" -NODENAME="Node.js 16.x" -NODEREPO="node_16.x" -NODEPKG="nodejs" - -print_status() { - echo - echo "## $1" - echo -} - -if test -t 1; then # if terminal - ncolors=$(which tput >/dev/null && tput colors) # supports color - if test -n "${ncolors}" && test "${ncolors}" -ge 8; then - termcols=$(tput cols) - bold="$(tput bold)" - underline="$(tput smul)" - standout="$(tput smso)" - normal="$(tput sgr0)" - black="$(tput setaf 0)" - red="$(tput setaf 1)" - green="$(tput setaf 2)" - yellow="$(tput setaf 3)" - blue="$(tput setaf 4)" - magenta="$(tput setaf 5)" - cyan="$(tput setaf 6)" - white="$(tput setaf 7)" - fi -fi - -print_bold() { - title="$1" - text="$2" - - echo - echo "${red}================================================================================${normal}" - echo "${red}================================================================================${normal}" - echo - echo -e " ${bold}${yellow}${title}${normal}" - echo - echo -en " ${text}" - echo - echo "${red}================================================================================${normal}" - echo "${red}================================================================================${normal}" -} - -bail() { - echo 'Error executing command, exiting' - exit 1 -} - -exec_cmd_nobail() { - echo "+ $1" - bash -c "$1" -} - -exec_cmd() { - exec_cmd_nobail "$1" || bail -} - -node_deprecation_warning() { - if [[ "X${NODENAME}" == "Xio.js 1.x" || - "X${NODENAME}" == "Xio.js 2.x" || - "X${NODENAME}" == "Xio.js 3.x" || - "X${NODENAME}" == "XNode.js 0.10" || - "X${NODENAME}" == "XNode.js 0.12" || - "X${NODENAME}" == "XNode.js 4.x LTS Argon" || - "X${NODENAME}" == "XNode.js 5.x" || - "X${NODENAME}" == "XNode.js 6.x LTS Boron" || - "X${NODENAME}" == "XNode.js 7.x" || - "X${NODENAME}" == "XNode.js 8.x LTS Carbon" || - "X${NODENAME}" == "XNode.js 9.x" || - "X${NODENAME}" == "XNode.js 10.x" || - "X${NODENAME}" == "XNode.js 11.x" || - "X${NODENAME}" == "XNode.js 12.x" || - "X${NODENAME}" == "XNode.js 13.x" || - "X${NODENAME}" == "XNode.js 15.x" || - "X${NODENAME}" == "XNode.js 17.x" ]]; then - - print_bold \ - " DEPRECATION WARNING " "\ -${bold}${NODENAME} is no longer actively supported!${normal} - - ${bold}You will not receive security or critical stability updates${normal} for this version. - - You should migrate to a supported version of Node.js as soon as possible. - Use the installation script that corresponds to the version of Node.js you - wish to install. e.g. - - * ${green}https://deb.nodesource.com/setup_14.x — Node.js 14 \"Fermium\"${normal} - * ${green}https://deb.nodesource.com/setup_16.x — Node.js 16 \"Gallium\"${normal} - * ${green}https://deb.nodesource.com/setup_18.x — Node.js 18 LTS \"Hydrogen\"${normal} (recommended) - * ${green}https://deb.nodesource.com/setup_19.x — Node.js 19 \"Nineteen\"${normal} (current) - - Please see ${bold}https://github.com/nodejs/Release${normal} for details about which - version may be appropriate for you. - - The ${bold}NodeSource${normal} Node.js distributions repository contains - information both about supported versions of Node.js and supported Linux - distributions. To learn more about usage, see the repository: - ${bold}https://github.com/nodesource/distributions${normal} -" - echo - echo "Continuing in 20 seconds ..." - echo - sleep 20 - fi -} - -script_deprecation_warning() { - if [[ "X${SCRSUFFIX}" == "X" ]]; then - print_bold \ - " SCRIPT DEPRECATION WARNING " "\ -This script, located at ${bold}https://deb.nodesource.com/setup${normal}, used to - install Node.js 0.10, is deprecated and will eventually be made inactive. - - You should use the script that corresponds to the version of Node.js you - wish to install. e.g. - - * ${green}https://deb.nodesource.com/setup_14.x — Node.js 14 \"Fermium\"${normal} - * ${green}https://deb.nodesource.com/setup_16.x — Node.js 16 \"Gallium\"${normal} - * ${green}https://deb.nodesource.com/setup_18.x — Node.js 18 LTS \"Hydrogen\"${normal} (recommended) - * ${green}https://deb.nodesource.com/setup_19.x — Node.js 19 \"Nineteen\"${normal} (current) - - Please see ${bold}https://github.com/nodejs/Release${normal} for details about which - version may be appropriate for you. - - The ${bold}NodeSource${normal} Node.js Linux distributions GitHub repository contains - information about which versions of Node.js and which Linux distributions - are supported and how to use the install scripts. - ${bold}https://github.com/nodesource/distributions${normal} -" - - echo - echo "Continuing in 20 seconds (press Ctrl-C to abort) ..." - echo - sleep 20 - fi -} - -setup() { - - script_deprecation_warning - node_deprecation_warning - - print_status "Installing the NodeSource ${NODENAME} repo..." - - if $(uname -m | grep -Eq ^armv6); then - print_status "You appear to be running on ARMv6 hardware. Unfortunately this is not currently supported by the NodeSource Linux distributions. Please use the 'linux-armv6l' binary tarballs available directly from nodejs.org for Node.js 4 and later." - exit 1 - fi - - PRE_INSTALL_PKGS="" - - # Check that HTTPS transport is available to APT - # (Check snaked from: https://get.docker.io/ubuntu/) - - if [[ ! -e /usr/lib/apt/methods/https ]]; then - PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} apt-transport-https" - fi - - if [[ ! -x /usr/bin/lsb_release ]]; then - PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} lsb-release" - fi - - if [[ ! -x /usr/bin/curl ]] && [[ ! -x /usr/bin/wget ]]; then - PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} curl" - fi - - # Used by apt-key to add new keys - - if [[ ! -x /usr/bin/gpg ]]; then - PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} gnupg" - fi - - # Populating Cache - print_status "Populating apt-get cache..." - exec_cmd 'apt-get update' - - if [[ "X${PRE_INSTALL_PKGS}" != "X" ]]; then - print_status "Installing packages required for setup:${PRE_INSTALL_PKGS}..." - # This next command needs to be redirected to /dev/null or the script will bork - # in some environments - exec_cmd "apt-get install -y${PRE_INSTALL_PKGS} > /dev/null 2>&1" - fi - - IS_PRERELEASE=$( - lsb_release -d | grep 'Ubuntu .*development' >&/dev/null - echo $? - ) - if [[ ${IS_PRERELEASE} -eq 0 ]]; then - print_status "Your distribution, identified as \"$(lsb_release -d -s)\", is a pre-release version of Ubuntu. NodeSource does not maintain official support for Ubuntu versions until they are formally released. You can try using the manual installation instructions available at https://github.com/nodesource/distributions and use the latest supported Ubuntu version name as the distribution identifier, although this is not guaranteed to work." - exit 1 - fi - - DISTRO=$(lsb_release -c -s) - - check_alt() { - if [[ "X${DISTRO}" == "X${2}" ]]; then - echo - echo "## You seem to be using ${1} version ${DISTRO}." - echo "## This maps to ${3} \"${4}\"... Adjusting for you..." - DISTRO="${4}" - fi - } - - check_alt "Astra Linux" "orel" "Debian" "stretch" - check_alt "BOSS" "anokha" "Debian" "wheezy" - check_alt "BOSS" "anoop" "Debian" "jessie" - check_alt "BOSS" "drishti" "Debian" "stretch" - check_alt "BOSS" "unnati" "Debian" "buster" - check_alt "BOSS" "urja" "Debian" "bullseye" - check_alt "bunsenlabs" "bunsen-hydrogen" "Debian" "jessie" - check_alt "bunsenlabs" "helium" "Debian" "stretch" - check_alt "bunsenlabs" "lithium" "Debian" "buster" - check_alt "Devuan" "jessie" "Debian" "jessie" - check_alt "Devuan" "ascii" "Debian" "stretch" - check_alt "Devuan" "beowulf" "Debian" "buster" - check_alt "Devuan" "chimaera" "Debian" "bullseye" - check_alt "Devuan" "ceres" "Debian" "sid" - check_alt "Deepin" "panda" "Debian" "sid" - check_alt "Deepin" "unstable" "Debian" "sid" - check_alt "Deepin" "stable" "Debian" "buster" - check_alt "Deepin" "apricot" "Debian" "buster" - check_alt "elementaryOS" "luna" "Ubuntu" "precise" - check_alt "elementaryOS" "freya" "Ubuntu" "trusty" - check_alt "elementaryOS" "loki" "Ubuntu" "xenial" - check_alt "elementaryOS" "juno" "Ubuntu" "bionic" - check_alt "elementaryOS" "hera" "Ubuntu" "bionic" - check_alt "elementaryOS" "odin" "Ubuntu" "focal" - check_alt "elementaryOS" "jolnir" "Ubuntu" "focal" - check_alt "Kali" "sana" "Debian" "jessie" - check_alt "Kali" "kali-rolling" "Debian" "bullseye" - check_alt "Linux Mint" "maya" "Ubuntu" "precise" - check_alt "Linux Mint" "qiana" "Ubuntu" "trusty" - check_alt "Linux Mint" "rafaela" "Ubuntu" "trusty" - check_alt "Linux Mint" "rebecca" "Ubuntu" "trusty" - check_alt "Linux Mint" "rosa" "Ubuntu" "trusty" - check_alt "Linux Mint" "sarah" "Ubuntu" "xenial" - check_alt "Linux Mint" "serena" "Ubuntu" "xenial" - check_alt "Linux Mint" "sonya" "Ubuntu" "xenial" - check_alt "Linux Mint" "sylvia" "Ubuntu" "xenial" - check_alt "Linux Mint" "tara" "Ubuntu" "bionic" - check_alt "Linux Mint" "tessa" "Ubuntu" "bionic" - check_alt "Linux Mint" "tina" "Ubuntu" "bionic" - check_alt "Linux Mint" "tricia" "Ubuntu" "bionic" - check_alt "Linux Mint" "ulyana" "Ubuntu" "focal" - check_alt "Linux Mint" "ulyssa" "Ubuntu" "focal" - check_alt "Linux Mint" "uma" "Ubuntu" "focal" - check_alt "Linux Mint" "una" "Ubuntu" "focal" - check_alt "Linux Mint" "vanessa" "Ubuntu" "jammy" - check_alt "Linux Mint" "vera" "Ubuntu" "jammy" - check_alt "Liquid Lemur" "lemur-3" "Debian" "stretch" - check_alt "LMDE" "betsy" "Debian" "jessie" - check_alt "LMDE" "cindy" "Debian" "stretch" - check_alt "LMDE" "debbie" "Debian" "buster" - check_alt "LMDE" "elsie" "Debian" "bullseye" - check_alt "MX Linux 17" "Horizon" "Debian" "stretch" - check_alt "MX Linux 18" "Continuum" "Debian" "stretch" - check_alt "MX Linux 19" "patito feo" "Debian" "buster" - check_alt "MX Linux 21" "wildflower" "Debian" "bullseye" - check_alt "Pardus" "onyedi" "Debian" "stretch" - check_alt "Parrot" "ara" "Debian" "bullseye" - check_alt "PureOS" "green" "Debian" "sid" - check_alt "PureOS" "amber" "Debian" "buster" - check_alt "PureOS" "byzantium" "Debian" "bullseye" - check_alt "SolydXK" "solydxk-9" "Debian" "stretch" - check_alt "Sparky Linux" "Tyche" "Debian" "stretch" - check_alt "Sparky Linux" "Nibiru" "Debian" "buster" - check_alt "Sparky Linux" "Po-Tolo" "Debian" "bullseye" - check_alt "Tanglu" "chromodoris" "Debian" "jessie" - check_alt "Trisquel" "toutatis" "Ubuntu" "precise" - check_alt "Trisquel" "belenos" "Ubuntu" "trusty" - check_alt "Trisquel" "flidas" "Ubuntu" "xenial" - check_alt "Trisquel" "etiona" "Ubuntu" "bionic" - check_alt "Ubilinux" "dolcetto" "Debian" "stretch" - check_alt "Uruk GNU/Linux" "lugalbanda" "Ubuntu" "xenial" - - if [[ "X${DISTRO}" == "Xdebian" ]]; then - print_status "Unknown Debian-based distribution, checking /etc/debian_version..." - NEWDISTRO=$([[ -e /etc/debian_version ]] && cut -d/ -f1 /dev/null" - else - exec_cmd "wget -q -O - ${node_key_url} | gpg --dearmor | tee ${local_node_key} >/dev/null" - fi - - print_status "Creating apt sources list file for the NodeSource ${NODENAME} repo..." - - exec_cmd "echo 'deb [signed-by=${local_node_key}] https://deb.nodesource.com/${NODEREPO} ${DISTRO} main' > /etc/apt/sources.list.d/nodesource.list" - exec_cmd "echo 'deb-src [signed-by=${local_node_key}] https://deb.nodesource.com/${NODEREPO} ${DISTRO} main' >> /etc/apt/sources.list.d/nodesource.list" - - print_status 'Running `apt-get update` for you...' - - exec_cmd 'apt-get update' - - yarn_site='https://dl.yarnpkg.com/debian' - yarn_key_url="${yarn_site}/pubkey.gpg" - local_yarn_key="${keyring}/yarnkey.gpg" - - print_status """Run \`${bold}sudo apt-get install -y ${NODEPKG}${normal}\` to install ${NODENAME} and npm -## You may also need development tools to build native addons: - sudo apt-get install gcc g++ make -## To install the Yarn package manager, run: - curl -sL ${yarn_key_url} | gpg --dearmor | sudo tee ${local_yarn_key} >/dev/null - echo \"deb [signed-by=${local_yarn_key}] ${yarn_site} stable main\" | sudo tee /etc/apt/sources.list.d/yarn.list - sudo apt-get update && sudo apt-get install yarn -""" - -} - -## Defer setup until we have the complete script -setup diff --git a/docker/deployer/Dockerfile b/docker/deployer/Dockerfile index 2fa682737..65a2ea8a1 100644 --- a/docker/deployer/Dockerfile +++ b/docker/deployer/Dockerfile @@ -1,12 +1,10 @@ -# trunk-ignore-all(terrascan/AC_DOCKER_0047) # trunk-ignore-all(hadolint/DL4006) # trunk-ignore-all(checkov/CKV_DOCKER_3) -FROM python:3.9.13 +# trunk-ignore-all(hadolint/DL3008) +FROM python:3.9.13 as builder HEALTHCHECK NONE -# trunk-ignore(terrascan/AC_DOCKER_0002) -# trunk-ignore(hadolint/DL3008) RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ apt-transport-https \ @@ -26,7 +24,7 @@ ENV PATH="$PATH:/root/.local/bin" RUN poetry config virtualenvs.create false # install dependencies -WORKDIR /app/kakarot +WORKDIR /build COPY poetry.lock . COPY pyproject.toml . COPY scripts ./scripts @@ -37,5 +35,42 @@ RUN poetry install COPY . . RUN make setup && make build +FROM python:3.9.13-slim-bullseye + +WORKDIR /app/kakarot + +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + apt-transport-https \ + ca-certificates \ + gcc \ + libgmp-dev \ + python3-dev \ + && rm -rf /var/lib/apt/lists/* \ + && curl -sSL https://install.python-poetry.org | python3 - + +ENV PATH="$PATH:/root/.local/bin" +ENV PYTHONPATH="/app/kakarot" +RUN poetry config virtualenvs.create false + +# Copy poetry lock and toml +COPY --from=builder /build/poetry.lock . +COPY --from=builder /build/pyproject.toml . +RUN poetry install + +# Copy only necessary artifacts from the builder stage +# Correctly copy the deploy_kakarot.py script to its intended location +COPY --from=builder /build/scripts/ ./scripts/ +COPY --from=builder /build/build ./build/ +COPY --from=builder /build/Makefile . +COPY --from=builder /build/tests ./tests/ + +# Cairo Smart contracts are used in deploy_kakarot.py +# To limit the probability of this Dockerfile to break, we copy the entire src and not individual files +COPY --from=builder /build/src ./src/ + +# Copy foundry.toml +COPY --from=builder /build/foundry.toml . + # Deploy kakarot CMD ["python", "scripts/deploy_kakarot.py"] diff --git a/docker/devnet/Dockerfile b/docker/devnet/Dockerfile deleted file mode 100644 index 3f3fe7439..000000000 --- a/docker/devnet/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -ARG DEVNET_VERSION -FROM shardlabs/starknet-devnet:${DEVNET_VERSION} - -LABEL org.opencontainers.image.source=https://github.com/kkrt-labs/kakarot -LABEL org.opencontainers.image.description="A starknet-devnet with pre-deployed kakarot contract" -LABEL org.opencontainers.image.licenses=MIT - -COPY ./deployments/devnet/devnet.pkl devnet.pkl -ENTRYPOINT ["starknet-devnet", "--host", "0.0.0.0", "--port", "5050", "--load-path", "devnet.pkl", "--disable-rpc-request-validation", "--timeout", "300"] diff --git a/docker/devnet/run_and_deploy.py b/docker/devnet/run_and_deploy.py deleted file mode 100755 index 32b82ec89..000000000 --- a/docker/devnet/run_and_deploy.py +++ /dev/null @@ -1,35 +0,0 @@ -import logging -import subprocess -import time - -import requests - -logging.basicConfig() -logger = logging.getLogger(__name__) -logger.setLevel(logging.INFO) - -logger.info("⏳ Starting devnet in background") -devnet = subprocess.Popen( - ["make", "run"], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT -) - -alive = False -attempts = 0 -max_retries = 10 -while not alive and attempts < max_retries: - try: - response = requests.get("http://127.0.0.1:5050/is_alive") - alive = response.text == "Alive!!!" - # trunk-ignore(ruff/E722) - except: - time.sleep(1) - finally: - attempts += 1 - -logger.info("✅ starknet-devnet live") - -deploy = subprocess.run(["make", "deploy"]) -deploy.check_returncode() - -devnet.terminate() -devnet.wait() diff --git a/docker/katana/Dockerfile b/docker/katana/Dockerfile deleted file mode 100644 index 6015a498d..000000000 --- a/docker/katana/Dockerfile +++ /dev/null @@ -1,45 +0,0 @@ -FROM python:3.9.13-slim-bullseye - -HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ - CMD if [ "$(cat /root/.kakarot_deploy_status)" -eq 0 ]; then exit 0; else exit 1; fi - -COPY ./docker/katana/scripts /app/scripts - -WORKDIR /app - -RUN apt-get update && apt-get install -y build-essential coreutils libgmp3-dev wget curl - -RUN chmod +x scripts/download_katana.sh -RUN chmod +x scripts/run.sh -RUN chmod +x scripts/wait_and_deploy.sh - -# install poetry -RUN curl -sSL https://install.python-poetry.org | python3 - -ENV PATH="$PATH:/root/.local/bin" - -# install files required to install dependencies -COPY ./pyproject.toml /app/kakarot/pyproject.toml -COPY ./poetry.lock /app/kakarot/poetry.lock -COPY ./scripts /app/kakarot/scripts -COPY ./README.md /app/kakarot/README.md - -# install dependencies -WORKDIR /app/kakarot -RUN poetry install - -# download katana -RUN /app/scripts/download_katana.sh - -# compile kakarot -COPY . /app/kakarot - -# copy example env to env so deploy script has access to necessary environment variables -RUN cp .env.example .env - -RUN make build - -EXPOSE 5050 - -# run katana and deploy kakarot -WORKDIR /app/scripts -CMD [ "./run.sh" ] \ No newline at end of file diff --git a/docker/katana/scripts/download_katana.sh b/docker/katana/scripts/download_katana.sh deleted file mode 100644 index df1bbd960..000000000 --- a/docker/katana/scripts/download_katana.sh +++ /dev/null @@ -1,11 +0,0 @@ -# Conditionally download different binaries based on architecture -if [[ "$(uname -m)" == "x86_64" ]]; then - wget https://github.com/dojoengine/dojo/releases/download/nightly-e7abee5/dojo_nightly_linux_amd64.tar.gz - tar -xvf dojo_nightly_linux_amd64.tar.gz -C /app/ -elif [[ "$(uname -m)" == "aarch64" ]]; then - wget https://github.com/dojoengine/dojo/releases/download/nightly-e7abee5/dojo_nightly_linux_arm64.tar.gz - tar -xvf dojo_nightly_linux_arm64.tar.gz -C /app/ -else - echo "Unsupported architecture: ${BUILDARCH}" - exit 1 -fi diff --git a/docker/katana/scripts/run.sh b/docker/katana/scripts/run.sh deleted file mode 100644 index a68448786..000000000 --- a/docker/katana/scripts/run.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# run ./wait_and_deploy.sh in background -nohup ./wait_and_deploy.sh &>/dev/null - -# run katana -/app/katana diff --git a/docker/katana/scripts/wait_and_deploy.sh b/docker/katana/scripts/wait_and_deploy.sh deleted file mode 100644 index f46622d7d..000000000 --- a/docker/katana/scripts/wait_and_deploy.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -# Function to check if curl request is successful -function check_katana_status() { - local retries=10 - local delay=3 - - until [[ ${retries} -eq 0 ]]; do - if curl -s http://0.0.0.0:5050 \ - -H 'content-type: application/json' \ - --data-raw '{"method":"starknet_chainId","jsonrpc":"2.0","params":[],"id":0}' \ - --compressed >/dev/null; then - echo "curl request succeeded for katana" - return 0 - else - echo "curl request failed for katana, retrying" - sleep "${delay}" - retries=$((retries - 1)) - fi - done - - echo "curl request failed after retries. Exiting..." - return 1 -} - -check_katana_status || exit 1 - -cd ../kakarot || exit -poetry run python scripts/deploy_kakarot.py - -if [[ $? -eq 0 ]]; then - echo "Command executed successfully." - # Perform further actions -else - echo "Command failed with an error." - # Handle the error or exit the script -fi - -echo $? >/root/.kakarot_deploy_status diff --git a/scripts/constants.py b/scripts/constants.py index 94114a1bd..a87071402 100644 --- a/scripts/constants.py +++ b/scripts/constants.py @@ -79,7 +79,7 @@ "rpc_url": os.getenv("RPC_URL"), "explorer_url": "", "devnet": False, - "check_interval": float(os.getenv("CHECK_INTERVAL", 6)), + "check_interval": float(os.getenv("CHECK_INTERVAL", 0.1)), "max_wait": float(os.getenv("MAX_WAIT", 30)), }