From 93d04d329e30d0b3293d591c0c44587f5f74e419 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 24 Sep 2024 14:26:43 +0100 Subject: [PATCH 01/25] updated launcher --- scripts/launcher | 357 ++++++++++++++++++++++++++++------------------- 1 file changed, 214 insertions(+), 143 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index c0286472e..b3a9b9685 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -40,7 +40,7 @@ case "$OS" in *) echo "Unsupported OS: $OS"; exit 1;; esac -# Couleurs et styles +# Colors and styles GREEN=$(tput setaf 2) YELLOW=$(tput setaf 3) RED=$(tput setaf 1) @@ -50,11 +50,11 @@ BOLD=$(tput bold) UNDERLINE=$(tput smul) BLINK=$(tput blink) -# Icônes ASCII pour les liens sociaux +# ASCII Icons for social links GITHUB_ICON="🔗 GitHub: " DOCS_ICON="📄 Documentation: " -# Fonction pour la barre de progression +# Function for progress bar progress_bar() { local duration=${1} already_done() { for ((done=0; done<$elapsed; done++)); do printf "▇"; done } @@ -73,22 +73,22 @@ progress_bar() { # ASCII Art ascii_art() { echo -e "${RED} - ____ - / __ \___ ____ _ ____ _______ - / / / / _ \/ __ \| |/_/ / / / ___/ - / /_/ / __/ /_/ /> " INSTALL_DEPS - + if [ "$INSTALL_DEPS" != "yes" ]; then echo -e "\n${RED}Installation aborted.${NC}" exit 1 else echo -e "\n${GREEN}Installing missing dependencies...${NC}" if [ "$OS" == "Linux" ]; then - sudo apt update - for DEP in "${MISSING_DEPS[@]}"; do - if ! sudo apt install -y "$DEP"; then - echo -e "${RED}Failed to install $DEP.${NC}" - STILL_MISSING_DEPS+=("$DEP") - fi - done + sudo apt update + for DEP in "${MISSING_DEPS[@]}"; do + if [ "$DEP" == "docker" ]; then + echo -e "${GREEN}Installing Docker...${NC}" + curl -fsSL https://get.docker.com -o get-docker.sh + sudo sh get-docker.sh + rm get-docker.sh + sudo usermod -aG docker $USER + newgrp docker + else + if ! sudo apt install -y "$DEP"; then + echo -e "${RED}Failed to install $DEP.${NC}" + fi + fi + done elif [ "$OS" == "Mac" ]; then - for DEP in "${MISSING_DEPS[@]}"; do - if ! brew install "$DEP"; then - echo -e "${RED}Failed to install $DEP.${NC}" - STILL_MISSING_DEPS+=("$DEP") - fi - done - fi - fi - - # Re-check dependencies to ensure all are installed - echo -e "\n${GREEN}Verifying installation of dependencies...${NC}" - RECHECK_MISSING_DEPS=() - for DEP in "${MISSING_DEPS[@]}"; do - DEP_CHECK="${DEPENDENCIES[@]#*:}" - if ! check_dependency "$DEP_CHECK"; then - RECHECK_MISSING_DEPS+=("$DEP") + for DEP in "${MISSING_DEPS[@]}"; do + if [ "$DEP" == "docker" ]; then + echo -e "${GREEN}Please install Docker Desktop from https://www.docker.com/products/docker-desktop and run this script again.${NC}" + exit 1 + else + if ! brew install "$DEP"; then + echo -e "${RED}Failed to install $DEP.${NC}" + fi + fi + done fi - done - if [ ${#RECHECK_MISSING_DEPS[@]} -ne 0 ]; then - echo -e "\n${RED}The following dependencies could not be installed:${NC}" - for DEP in "${RECHECK_MISSING_DEPS[@]}"; do - echo -e "${RED}- $DEP${NC}" + # Re-check dependencies to ensure all are installed + echo -e "\n${GREEN}Verifying installation of dependencies...${NC}" + RECHECK_MISSING_DEPS=() + for DEP in "${DEPENDENCIES[@]}"; do + DEP_NAME="${DEP%%:*}" + DEP_CHECK="${DEP##*:}" + if ! check_dependency "$DEP_CHECK"; then + RECHECK_MISSING_DEPS+=("$DEP_NAME") + fi done - exit 1 - else - echo -e "\n${GREEN}All dependencies are successfully installed and verified.${NC}" + + if [ ${#RECHECK_MISSING_DEPS[@]} -ne 0 ]; then + echo -e "\n${RED}The following dependencies could not be installed:${NC}" + for DEP in "${RECHECK_MISSING_DEPS[@]}"; do + echo -e "${RED}- $DEP${NC}" + done + exit 1 + else + echo -e "\n${GREEN}All dependencies are successfully installed and verified.${NC}" + fi fi else echo -e "\n${GREEN}All dependencies are installed.${NC}" fi - -echo -e "\n${GREEN}We will now proceed with the download and installation of the binary from GitHub:${NC}" +echo -e "\n${GREEN}We will now proceed with the download of Madara from GitHub:${NC}" echo -e "${CYAN}${GITHUB_ICON}${UNDERLINE}https://github.com/madara-alliance/madara${NC}" -echo -e "\n${YELLOW}${BOLD}Do you want to proceed? (yes/no)${NC}" -read -p "> " PROCEED +# Ask for installation directory +echo -e "\n${YELLOW}${BOLD}Where would you like to install Madara? (default is current directory)${NC}" +read -p "> " INSTALL_DIR -tput rc -tput ed +# Set default directory if not provided +INSTALL_DIR=${INSTALL_DIR:-$(pwd)} -if [ "$PROCEED" != "yes" ]; then - echo -e "${RED}Operation aborted.${NC}" - exit 1 +# Clone the Madara repository +echo -e "\n${GREEN}Cloning the Madara repository into ${INSTALL_DIR}...${NC}" +if [ -d "${INSTALL_DIR}/madara" ]; then + echo -e "${YELLOW}Madara directory already exists. Updating...${NC}" + cd "${INSTALL_DIR}/madara" && git pull +else + git clone https://github.com/madara-alliance/madara.git "${INSTALL_DIR}/madara" + cd "${INSTALL_DIR}/madara" fi -# Function to check if a command exists -command_exists () { - type "$1" &> /dev/null ; -} - -# Check if curl is installed -if ! command_exists curl ; then - echo -e "${RED}Error: curl is not installed. Please install curl and try again.${NC}" - exit 1 -fi -# Check if rustup is installed -if ! command_exists rustup ; then - echo -e "${YELLOW}Installing rustup...${NC}" - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - source $HOME/.cargo/env -fi +tput rc +tput ed -# Check if cargo is installed -if ! command_exists cargo ; then - echo -e "${RED}Error: cargo is not installed. Please install Rust and try again.${NC}" - exit 1 -fi +# Build the Docker image +echo -e "\n${GREEN}Building the Docker image... (this operation will take a few minutes)${NC}" +# if ! docker build -t madara .; then +# echo -e "${RED}Docker image build failed. Please check the Dockerfile and try again.${NC}" +# exit 1 +# fi -# Install the binary from a given URL -BIN_URL="https://example.com/path/to/your/binary" # Replace with actual URL -BIN_NAME="madara" # Replace with the actual name of the binary +tput rc +tput ed -echo -e "\n${GREEN}Downloading the binary...${NC}" -curl -L $BIN_URL -o /usr/local/bin/$BIN_NAME -chmod +x /usr/local/bin/$BIN_NAME +# Choose the mode +echo -e "\n🕹️ ${YELLOW}${BOLD}On which mode would you like to run Madara? (Enter a number)${NC}\n" +echo "${YELLOW}1. Full Node${NC}" +echo "${YELLOW}2. Sequencer${NC}" +echo "${YELLOW}3. Devnet${NC}" +while true; do + read -p "> " MODE_CHOICE + case $MODE_CHOICE in + 1) MODE="full"; break ;; + 2) MODE="sequencer"; break ;; + 3) MODE="devnet"; break ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, or 3.${NC}" ;; + esac +done tput rc tput ed @@ -265,24 +263,79 @@ done tput rc tput ed -# Choose the network -echo -e "\n🌐 ${YELLOW}${BOLD}On which network? (Enter a number)${NC}\n" -echo "${YELLOW}1. Mainnet${NC}" -echo "${YELLOW}2. Testnet${NC}" -echo "${YELLOW}3. Integration${NC}" -while true; do - read -p "> " NETWORK_CHOICE - case $NETWORK_CHOICE in - 1) NETWORK="main"; break ;; - 2) NETWORK="test"; break ;; - 3) NETWORK="integration"; break ;; - *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, or 3.${NC}" ;; - esac -done +# Choose the network based on the mode +if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then + # For sequencer and devnet modes + echo -e "\n🌐 ${YELLOW}${BOLD}Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" + echo "${YELLOW}1. Starknet Mainnet${NC}" + echo "${YELLOW}2. Starknet Testnet${NC}" + echo "${YELLOW}3. Test${NC}" + echo "${YELLOW}4. Custom Chain config${NC}" + while true; do + read -p "> " NETWORK_CHOICE + case $NETWORK_CHOICE in + 1) PRESET="starknet_mainnet"; break ;; + 2) PRESET="starknet_testnet"; break ;; + 3) PRESET="test"; break ;; + 4) + echo -e "\n${YELLOW}Please provide the path to your custom chain config:${NC}" + read -p "> " CUSTOM_CHAIN_CONFIG + if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then + PRESET="$CUSTOM_CHAIN_CONFIG" + break + else + echo -e "${RED}File not found. Please provide a valid path.${NC}" + fi + ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; + esac + done +else + # For full node mode + echo -e "\n🌐 ${YELLOW}${BOLD}Please choose a Network or provide a custom Chain config path: (Enter a number)${NC}\n" + echo "${YELLOW}1. Starknet Mainnet${NC}" + echo "${YELLOW}2. Starknet Testnet${NC}" + echo "${YELLOW}3. Starknet Integration${NC}" + echo "${YELLOW}4. Custom Chain config${NC}" + while true; do + read -p "> " NETWORK_CHOICE + case $NETWORK_CHOICE in + 1) NETWORK="main"; break ;; + 2) NETWORK="test"; break ;; + 3) NETWORK="integration"; break ;; + 4) + echo -e "\n${YELLOW}Please provide the path to your custom chain config or preset:${NC}" + read -p "> " CUSTOM_CHAIN_CONFIG + if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then + NETWORK="$CUSTOM_CHAIN_CONFIG" + break + else + echo -e "${RED}File not found. Please provide a valid path.${NC}" + fi + ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; + esac + done +fi tput rc tput ed +# Set the chain config or network option +if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then + # Use --chain-config with PRESET + CHAIN_CONFIG_OPT="--chain-config=\"${PRESET}\"" +else + # For full node mode + if [ "$NETWORK_CHOICE" -eq 4 ]; then + # Custom chain config + CHAIN_CONFIG_OPT="--chain-config=\"${NETWORK}\"" + else + # Use --network + CHAIN_CONFIG_OPT="--network=\"${NETWORK}\"" + fi +fi + # Ask for the database path echo -e "\n💾 ${YELLOW}${BOLD}Where would you like to store your database? (default: /tmp/madara)${NC}" read -p "> " BASE_PATH @@ -291,6 +344,11 @@ BASE_PATH=${BASE_PATH:-/tmp/madara} tput rc tput ed +# Create the base path directory if it doesn't exist +if [ ! -d "$BASE_PATH" ]; then + mkdir -p "$BASE_PATH" +fi + # Ask for RPC access while true; do echo -e "\n🔌 ${YELLOW}${BOLD}Do you want to enable RPC access? (yes/no) ${NC}" @@ -306,12 +364,14 @@ tput ed if [ "$RPC_ACCESS" == "yes" ]; then RPC_OPTS="--rpc-cors '*' --rpc-external" - echo -e "\n🚪 ${YELLOW}${BOLD}On which port do you want RPC access? (default: 9933)${NC}" + echo -e "\n🚪 ${YELLOW}${BOLD}On which port do you want RPC access? (default: 9944)${NC}" read -p "> " RPC_PORT - RPC_PORT=${RPC_PORT:-9933} + RPC_PORT=${RPC_PORT:-9944} RPC_OPTS="$RPC_OPTS --rpc-port $RPC_PORT" + PORT_MAPPING="-p $RPC_PORT:$RPC_PORT" else RPC_OPTS="" + PORT_MAPPING="" fi tput rc @@ -319,7 +379,7 @@ tput ed # Ask for the L1 endpoint URL while true; do - echo -e "\n🔗 ${YELLOW}${BOLD}Enter the URL of the L1 endpoint:${NC}" + echo -e "\n🔗 ${YELLOW}${BOLD}Provide an L1 RPC endpoint (URL format):${NC}" read -p "> " L1_ENDPOINT if [[ $L1_ENDPOINT =~ ^https?:// ]]; then break @@ -331,34 +391,45 @@ done tput rc tput ed -# Synchronize via snapshot or genesis -echo -e "\n🔄 ${YELLOW}${BOLD}Which sync mode would you like? (Enter a number)${NC}\n" -echo "${YELLOW}1. Snap sync (fast)${NC}" -echo "${YELLOW}2. Full sync (safe)${NC}" -while true; do - read -p "> " SYNC_CHOICE - case $SYNC_CHOICE in - 1) SYNC_OPT="--snap"; break ;; - 2) SYNC_OPT=""; break ;; - *) echo -e "${YELLOW}Invalid choice, please enter 1 or 2.${NC}" ;; - esac -done - -tput rc -tput ed - -# Build the final command -COMMAND="/usr/local/bin/$BIN_NAME run --name $NODE_NAME --network=$NETWORK --base-path=$BASE_PATH $RPC_OPTS --l1-endpoint $L1_ENDPOINT $SYNC_OPT" - -echo -e "\n🔄 ${YELLOW}${BOLD}The following command will be executed:${NC}\n" -echo -e "${CYAN}$COMMAND${NC}" +# # Synchronize via snapshot or genesis +# echo -e "\n🔄 ${YELLOW}${BOLD}Which sync mode would you like? (Enter a number)${NC}\n" +# echo "${YELLOW}1. Snap sync (fast)${NC}" +# echo "${YELLOW}2. Full sync (safe)${NC}" +# while true; do +# read -p "> " SYNC_CHOICE +# case $SYNC_CHOICE in +# 1) SYNC_OPT="--snap"; break ;; +# 2) SYNC_OPT=""; break ;; +# *) echo -e "${YELLOW}Invalid choice, please enter 1 or 2.${NC}" ;; +# esac +# done + +# tput rc +# tput ed + +# Build the final Docker run command +DOCKER_COMMAND="docker run -d --name madara-node \ + -v ${BASE_PATH}:/data \ + ${PORT_MAPPING} \ + madara \ + run --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\" ${SYNC_OPT}" + +echo -e "\n🔄 ${YELLOW}${BOLD}The following Docker command will be executed:${NC}\n" +echo -e "${CYAN}$DOCKER_COMMAND${NC}" # Confirm before executing echo -e "\n${YELLOW}${BOLD}Do you want to proceed? (yes/no)${NC}\n" read -p "> " CONFIRM if [ "$CONFIRM" == "yes" ]; then - echo -e "\n${GREEN}Starting the node...${NC}" - eval $COMMAND + echo -e "\n${GREEN}Starting the Madara node via Docker...${NC}" + # Stop and remove any existing container with the same name + if docker ps -a --format '{{.Names}}' | grep -Eq "^madara-node\$"; then + echo -e "\n${YELLOW}A container named 'madara-node' already exists. Stopping and removing it...${NC}" + docker stop madara-node + docker rm madara-node + fi + eval $DOCKER_COMMAND + echo -e "\n${GREEN}Madara node is now running in Docker container 'madara-node'.${NC}" else echo -e "${RED}Command execution aborted.${NC}" fi From fbc246cf626cf41aba4c25a6d6e9b9d3873ca79f Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 24 Sep 2024 14:51:03 +0100 Subject: [PATCH 02/25] fixed more stuff --- scripts/launcher | 55 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index b3a9b9685..83f5610dd 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -207,7 +207,7 @@ read -p "> " INSTALL_DIR # Set default directory if not provided INSTALL_DIR=${INSTALL_DIR:-$(pwd)} -# Clone the Madara repository +# Clone the Madara repository (this step should be removed when we have images available remotly) echo -e "\n${GREEN}Cloning the Madara repository into ${INSTALL_DIR}...${NC}" if [ -d "${INSTALL_DIR}/madara" ]; then echo -e "${YELLOW}Madara directory already exists. Updating...${NC}" @@ -231,17 +231,19 @@ echo -e "\n${GREEN}Building the Docker image... (this operation will take a few tput rc tput ed +echo -e "\n${GREEN}Madara has been correctly installed here: ${BOLD}${INSTALL_DIR}${NC}${GREEN}.${NC}" + # Choose the mode -echo -e "\n🕹️ ${YELLOW}${BOLD}On which mode would you like to run Madara? (Enter a number)${NC}\n" +echo -e "\n🕹️ ${YELLOW}${BOLD} On which mode would you like to run Madara? (Enter a number)${NC}\n" echo "${YELLOW}1. Full Node${NC}" echo "${YELLOW}2. Sequencer${NC}" echo "${YELLOW}3. Devnet${NC}" while true; do read -p "> " MODE_CHOICE case $MODE_CHOICE in - 1) MODE="full"; break ;; - 2) MODE="sequencer"; break ;; - 3) MODE="devnet"; break ;; + 1) MODE="Full"; break ;; + 2) MODE="Sequencer"; break ;; + 3) MODE="Devnet"; break ;; *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, or 3.${NC}" ;; esac done @@ -249,6 +251,8 @@ done tput rc tput ed +echo -e "\n${GREEN}Madara will run in ${BOLD}${MODE}${NC}${GREEN} mode.${NC}" + # Ask for the node name while true; do echo -e "\n${YELLOW}${BOLD}👤 What name would you like to give this node?${NC}" @@ -263,6 +267,8 @@ done tput rc tput ed +echo -e "\n${GREEN}Your node has been correctly named: ${BOLD}${NODE_NAME}${NC}${GREEN}.${NC}" + # Choose the network based on the mode if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then # For sequencer and devnet modes @@ -304,14 +310,35 @@ else 2) NETWORK="test"; break ;; 3) NETWORK="integration"; break ;; 4) - echo -e "\n${YELLOW}Please provide the path to your custom chain config or preset:${NC}" - read -p "> " CUSTOM_CHAIN_CONFIG - if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then - NETWORK="$CUSTOM_CHAIN_CONFIG" - break - else - echo -e "${RED}File not found. Please provide a valid path.${NC}" - fi + tput rc + tput ed + + echo -e "\n${GREEN}You have choosed to run your node under a custom Chain config.${NC}" + + echo -e "\n${YELLOW}${BOLD}🌐 Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" + echo "${YELLOW}1. Starknet Mainnet${NC}" + echo "${YELLOW}2. Starknet Testnet${NC}" + echo "${YELLOW}3. Test${NC}" + echo "${YELLOW}4. Custom Chain config${NC}" + while true; do + read -p "> " NETWORK_CHOICE + case $NETWORK_CHOICE in + 1) PRESET="starknet_mainnet"; break ;; + 2) PRESET="starknet_testnet"; break ;; + 3) PRESET="test"; break ;; + 4) + echo -e "\n${YELLOW}Please provide the path to your custom chain config:${NC}" + read -p "> " CUSTOM_CHAIN_CONFIG + if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then + PRESET="$CUSTOM_CHAIN_CONFIG" + break + else + echo -e "${RED}File not found. Please provide a valid path.${NC}" + fi + ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; + esac + done ;; *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; esac @@ -321,6 +348,8 @@ fi tput rc tput ed +echo -e "\n${GREEN}You have choosed to run your node under: ${NETWORK}.${NC}" + # Set the chain config or network option if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then # Use --chain-config with PRESET From b84ee44101fc5d31b659b01560d321e3ba46b705 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 24 Sep 2024 15:53:45 +0100 Subject: [PATCH 03/25] added port security --- scripts/launcher | 203 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 137 insertions(+), 66 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index 83f5610dd..4acb12f4f 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -88,7 +88,7 @@ ascii_art echo -e "${GREEN}${BOLD}Welcome to the Madara Docker Launcher!${NC}" echo -e "${GREEN}This script allows you to easily launch a Madara instance using Docker with your desired parameters.${NC}" echo -e "${GREEN}For more information, please refer to our documentation:${NC}" -echo -e "${CYAN}${DOCS_ICON}${UNDERLINE}https://madara.io${NC}" +echo -e "${CYAN}${DOCS_ICON}${UNDERLINE}https://madara.build${NC}" # Save cursor position tput sc @@ -106,10 +106,9 @@ if [ "$PROCEED" != "yes" ]; then exit 1 fi -# Define dependencies and their check commands +# Define dependencies and their check commands (excluding Docker) DEPENDENCIES=( "curl:command -v curl" - "docker:command -v docker" "git:command -v git" ) @@ -118,6 +117,24 @@ check_dependency() { eval "$1" >/dev/null 2>&1 } +# Function to check if Docker is installed +check_docker_installed() { + if ! command -v docker >/dev/null 2>&1; then + return 1 + else + return 0 + fi +} + +# Function to check if Docker daemon is running +check_docker_running() { + if ! docker info >/dev/null 2>&1; then + return 1 + else + return 0 + fi +} + # Check dependencies MISSING_DEPS=() for DEP in "${DEPENDENCIES[@]}"; do @@ -128,12 +145,25 @@ for DEP in "${DEPENDENCIES[@]}"; do fi done +# Check for Docker +DOCKER_MISSING=false +DOCKER_NOT_RUNNING=false + +if ! check_docker_installed; then + DOCKER_MISSING=true +elif ! check_docker_running; then + DOCKER_NOT_RUNNING=true +fi + # Report missing dependencies -if [ ${#MISSING_DEPS[@]} -ne 0 ]; then - echo -e "${YELLOW}The following dependencies are missing:${NC}" +if [ ${#MISSING_DEPS[@]} -ne 0 ] || [ "$DOCKER_MISSING" = true ]; then + echo -e "${YELLOW}\nThe following dependencies are missing or not running:${NC}" for DEP in "${MISSING_DEPS[@]}"; do echo -e "${YELLOW}- $DEP${NC}" done + if [ "$DOCKER_MISSING" = true ]; then + echo -e "${YELLOW}- Docker${NC}" + fi echo -e "\n${YELLOW}${BOLD}Do you want to install the missing dependencies? (yes/no)${NC}" read -p "> " INSTALL_DEPS @@ -146,55 +176,94 @@ if [ ${#MISSING_DEPS[@]} -ne 0 ]; then if [ "$OS" == "Linux" ]; then sudo apt update for DEP in "${MISSING_DEPS[@]}"; do - if [ "$DEP" == "docker" ]; then - echo -e "${GREEN}Installing Docker...${NC}" - curl -fsSL https://get.docker.com -o get-docker.sh - sudo sh get-docker.sh - rm get-docker.sh - sudo usermod -aG docker $USER - newgrp docker - else - if ! sudo apt install -y "$DEP"; then - echo -e "${RED}Failed to install $DEP.${NC}" - fi + if ! sudo apt install -y "$DEP"; then + echo -e "${RED}Failed to install $DEP.${NC}" fi done + if [ "$DOCKER_MISSING" = true ]; then + echo -e "${GREEN}Installing Docker...${NC}" + curl -fsSL https://get.docker.com -o get-docker.sh + sudo sh get-docker.sh + rm get-docker.sh + sudo usermod -aG docker $USER + newgrp docker + sudo systemctl start docker + fi elif [ "$OS" == "Mac" ]; then for DEP in "${MISSING_DEPS[@]}"; do - if [ "$DEP" == "docker" ]; then - echo -e "${GREEN}Please install Docker Desktop from https://www.docker.com/products/docker-desktop and run this script again.${NC}" - exit 1 - else - if ! brew install "$DEP"; then - echo -e "${RED}Failed to install $DEP.${NC}" - fi + if ! brew install "$DEP"; then + echo -e "${RED}Failed to install $DEP.${NC}" fi done - fi - - # Re-check dependencies to ensure all are installed - echo -e "\n${GREEN}Verifying installation of dependencies...${NC}" - RECHECK_MISSING_DEPS=() - for DEP in "${DEPENDENCIES[@]}"; do - DEP_NAME="${DEP%%:*}" - DEP_CHECK="${DEP##*:}" - if ! check_dependency "$DEP_CHECK"; then - RECHECK_MISSING_DEPS+=("$DEP_NAME") + if [ "$DOCKER_MISSING" = true ]; then + echo -e "${GREEN}Installing Docker via Homebrew...${NC}" + if ! brew install --cask docker; then + echo -e "${RED}Failed to install Docker.${NC}" + else + echo -e "${GREEN}Docker installed.\nTrying to open /Applications/Docker.app to start the Docker daemon (you may need to do this step yourself if not located under /Applications/Docker.app).${NC}" + open /Applications/Docker.app + # Wait for Docker daemon to start + echo -e "${GREEN}Waiting for Docker daemon to start...${NC}" + while ! docker info >/dev/null 2>&1; do + sleep 1 + done + echo -e "${GREEN}Docker daemon is running.${NC}" + fi fi - done + fi + fi +fi - if [ ${#RECHECK_MISSING_DEPS[@]} -ne 0 ]; then - echo -e "\n${RED}The following dependencies could not be installed:${NC}" - for DEP in "${RECHECK_MISSING_DEPS[@]}"; do - echo -e "${RED}- $DEP${NC}" - done +# Check if Docker daemon is running +if [ "$DOCKER_NOT_RUNNING" = true ]; then + echo -e "\n${YELLOW}Docker is installed but not running.${NC}" + if [ "$OS" == "Linux" ]; then + echo -e "${GREEN}Starting Docker daemon...${NC}" + sudo systemctl start docker + if ! sudo systemctl is-active --quiet docker; then + echo -e "${RED}Failed to start Docker daemon.${NC}" exit 1 else - echo -e "\n${GREEN}All dependencies are successfully installed and verified.${NC}" + echo -e "${GREEN}Docker daemon is running.${NC}" fi + elif [ "$OS" == "Mac" ]; then + echo -e "${GREEN}Docker installed.\nTrying to open /Applications/Docker.app to start the Docker daemon (you may need to do this step yourself if not located under /Applications/Docker.app).${NC}" + open /Applications/Docker.app + # Wait for Docker daemon to start + echo -e "${GREEN}Waiting for Docker daemon to start...${NC}" + while ! docker info >/dev/null 2>&1; do + sleep 1 + done + echo -e "${GREEN}Docker daemon is running.${NC}" fi +fi + +# Re-check dependencies to ensure all are installed and running +echo -e "\n${GREEN}Verifying installation of dependencies...${NC}" +RECHECK_MISSING_DEPS=() +for DEP in "${DEPENDENCIES[@]}"; do + DEP_NAME="${DEP%%:*}" + DEP_CHECK="${DEP##*:}" + if ! check_dependency "$DEP_CHECK"; then + RECHECK_MISSING_DEPS+=("$DEP_NAME") + fi +done + +# Re-check Docker +if ! check_docker_installed; then + RECHECK_MISSING_DEPS+=("Docker") +elif ! check_docker_running; then + RECHECK_MISSING_DEPS+=("Docker daemon not running") +fi + +if [ ${#RECHECK_MISSING_DEPS[@]} -ne 0 ]; then + echo -e "\n${RED}The following dependencies could not be installed or are not running:${NC}" + for DEP in "${RECHECK_MISSING_DEPS[@]}"; do + echo -e "${RED}- $DEP${NC}" + done + exit 1 else - echo -e "\n${GREEN}All dependencies are installed.${NC}" + echo -e "\n${GREEN}All dependencies are successfully installed and verified.${NC}" fi echo -e "\n${GREEN}We will now proceed with the download of Madara from GitHub:${NC}" @@ -207,7 +276,7 @@ read -p "> " INSTALL_DIR # Set default directory if not provided INSTALL_DIR=${INSTALL_DIR:-$(pwd)} -# Clone the Madara repository (this step should be removed when we have images available remotly) +# Clone the Madara repository (this step should be removed when we have images available remotely) echo -e "\n${GREEN}Cloning the Madara repository into ${INSTALL_DIR}...${NC}" if [ -d "${INSTALL_DIR}/madara" ]; then echo -e "${YELLOW}Madara directory already exists. Updating...${NC}" @@ -217,7 +286,6 @@ else cd "${INSTALL_DIR}/madara" fi - tput rc tput ed @@ -270,7 +338,7 @@ tput ed echo -e "\n${GREEN}Your node has been correctly named: ${BOLD}${NODE_NAME}${NC}${GREEN}.${NC}" # Choose the network based on the mode -if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then +if [ "$MODE" == "Sequencer" ] || [ "$MODE" == "Devnet" ]; then # For sequencer and devnet modes echo -e "\n🌐 ${YELLOW}${BOLD}Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" echo "${YELLOW}1. Starknet Mainnet${NC}" @@ -313,7 +381,7 @@ else tput rc tput ed - echo -e "\n${GREEN}You have choosed to run your node under a custom Chain config.${NC}" + echo -e "\n${GREEN}You have chosen to run your node under a custom Chain config.${NC}" echo -e "\n${YELLOW}${BOLD}🌐 Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" echo "${YELLOW}1. Starknet Mainnet${NC}" @@ -348,10 +416,10 @@ fi tput rc tput ed -echo -e "\n${GREEN}You have choosed to run your node under: ${NETWORK}.${NC}" +echo -e "\n${GREEN}You have chosen to run your node under: ${NETWORK}.${NC}" # Set the chain config or network option -if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then +if [ "$MODE" == "Sequencer" ] || [ "$MODE" == "Devnet" ]; then # Use --chain-config with PRESET CHAIN_CONFIG_OPT="--chain-config=\"${PRESET}\"" else @@ -394,8 +462,27 @@ tput ed if [ "$RPC_ACCESS" == "yes" ]; then RPC_OPTS="--rpc-cors '*' --rpc-external" echo -e "\n🚪 ${YELLOW}${BOLD}On which port do you want RPC access? (default: 9944)${NC}" - read -p "> " RPC_PORT - RPC_PORT=${RPC_PORT:-9944} + + while true; do + read -p "> " RPC_PORT + RPC_PORT=${RPC_PORT:-9944} + + # Check if the port is a valid number between 1 and 65535 + if ! [[ "$RPC_PORT" =~ ^[0-9]+$ ]] || [ "$RPC_PORT" -lt 1 ] || [ "$RPC_PORT" -gt 65535 ]; then + echo -e "${RED}⚠️ Invalid port number. Please enter a valid port between 1 and 65535.${NC}" + continue + fi + + # Check if the port is already in use + if lsof -i :"$RPC_PORT" &>/dev/null; then + echo -e "${RED}⚠️ Port $RPC_PORT is already in use. Please choose another port.${NC}" + continue + fi + + # If everything is okay, break the loop + break + done + RPC_OPTS="$RPC_OPTS --rpc-port $RPC_PORT" PORT_MAPPING="-p $RPC_PORT:$RPC_PORT" else @@ -420,28 +507,12 @@ done tput rc tput ed -# # Synchronize via snapshot or genesis -# echo -e "\n🔄 ${YELLOW}${BOLD}Which sync mode would you like? (Enter a number)${NC}\n" -# echo "${YELLOW}1. Snap sync (fast)${NC}" -# echo "${YELLOW}2. Full sync (safe)${NC}" -# while true; do -# read -p "> " SYNC_CHOICE -# case $SYNC_CHOICE in -# 1) SYNC_OPT="--snap"; break ;; -# 2) SYNC_OPT=""; break ;; -# *) echo -e "${YELLOW}Invalid choice, please enter 1 or 2.${NC}" ;; -# esac -# done - -# tput rc -# tput ed - # Build the final Docker run command DOCKER_COMMAND="docker run -d --name madara-node \ -v ${BASE_PATH}:/data \ ${PORT_MAPPING} \ madara \ - run --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\" ${SYNC_OPT}" + run --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" echo -e "\n🔄 ${YELLOW}${BOLD}The following Docker command will be executed:${NC}\n" echo -e "${CYAN}$DOCKER_COMMAND${NC}" From 9fa90bc6268938ecf5fbdcb7c00df3940de14d8d Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 24 Sep 2024 17:05:10 +0100 Subject: [PATCH 04/25] small fix until docker image --- Dockerfile | 21 ++++++++++++++++++++- scripts/launcher | 6 +++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b7f53af18..84ad97a6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,25 @@ WORKDIR /usr/src/madara/ # Copy the source code into the container COPY Cargo.toml Cargo.lock ./ COPY crates crates +COPY cairo cairo +COPY cairo_0 cairo_0 + + +# Installing scarb, new since devnet integration +# Installation steps are taken from the scarb build script +# https://github.com/software-mansion/scarb/blob/main/install.sh +ENV SCARB_VERSION="v2.8.2" +ENV SHELL /bin/bash +RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- ${SCARB_VERSION} +ENV PATH="/root/.local/bin:${PATH}" +RUN scarb --version + +# Install runtime dependencies +RUN apt-get -y update && \ + apt-get install -y openssl ca-certificates busybox && \ + apt-get autoremove -y; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/* # Build the application in release mode RUN cargo build --release @@ -35,4 +54,4 @@ WORKDIR /usr/local/bin COPY --from=builder /usr/src/madara/target/release/madara . # Set the entrypoint -CMD ["./madara"] \ No newline at end of file +ENTRYPOINT ["./madara"] \ No newline at end of file diff --git a/scripts/launcher b/scripts/launcher index 4acb12f4f..6edc6ea25 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -50,7 +50,7 @@ BOLD=$(tput bold) UNDERLINE=$(tput smul) BLINK=$(tput blink) -# ASCII Icons for social links +# Icons for social links GITHUB_ICON="🔗 GitHub: " DOCS_ICON="📄 Documentation: " @@ -85,10 +85,10 @@ echo -e "${RED} # Welcome message clear ascii_art -echo -e "${GREEN}${BOLD}Welcome to the Madara Docker Launcher!${NC}" +echo -e "${GREEN}${BOLD}Welcome to the Madara Launcher!${NC}" echo -e "${GREEN}This script allows you to easily launch a Madara instance using Docker with your desired parameters.${NC}" echo -e "${GREEN}For more information, please refer to our documentation:${NC}" -echo -e "${CYAN}${DOCS_ICON}${UNDERLINE}https://madara.build${NC}" +echo -e "${CYAN}${DOCS_ICON}${UNDERLINE}https://docs.madara.build${NC}" # Save cursor position tput sc From 9083b7ce98e4a3576667cff764c897a8cd60eadc Mon Sep 17 00:00:00 2001 From: antiyro Date: Mon, 30 Sep 2024 14:26:23 +0100 Subject: [PATCH 05/25] fixed dockerfile --- Dockerfile | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1a2ba9ab2..d75185f7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,18 +17,21 @@ COPY crates crates COPY cairo cairo COPY cairo_0 cairo_0 -# Installing scarb, new since devnet integration -# Installation steps are taken from the scarb build script -# https://github.com/software-mansion/scarb/blob/main/install.sh -ENV SCARB_VERSION="v2.8.2" -ENV SCARB_REPO="https://github.com/software-mansion/scarb/releases/download" -ENV PLATFORM="x86_64-unknown-linux-gnu" -ENV SCARB_TARGET="/usr/src/scarb.tar.gz" - -RUN curl -fLS -o $SCARB_TARGET \ - $SCARB_REPO/$SCARB_VERSION/scarb-$SCARB_VERSION-$PLATFORM.tar.gz && \ - tar -xz -C /usr/src/ --strip-components=1 -f $SCARB_TARGET && \ - mv /usr/src/bin/scarb /bin +# Installing Scarb +# Dynamically detect the architecture +ARG SCARB_VERSION="v2.8.2" +ARG SCARB_REPO="https://github.com/software-mansion/scarb/releases/download" +RUN ARCH=$(uname -m); \ + if [ "$ARCH" = "x86_64" ]; then \ + PLATFORM="x86_64-unknown-linux-gnu"; \ + elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then \ + PLATFORM="aarch64-unknown-linux-gnu"; \ + else \ + echo "Unsupported architecture: $ARCH"; exit 1; \ + fi && \ + curl -fLS -o /usr/src/scarb.tar.gz \ + $SCARB_REPO/$SCARB_VERSION/scarb-$SCARB_VERSION-$PLATFORM.tar.gz && \ + tar -xz -C /usr/local --strip-components=1 -f /usr/src/scarb.tar.gz # Build the application in release mode RUN cargo build --release @@ -49,7 +52,7 @@ WORKDIR /usr/local/bin # Copy the compiled binary from the builder stage COPY --from=builder /usr/src/madara/target/release/madara . -# chain presets to be monted at startup +# Chain presets to be mounted at startup VOLUME crates/primitives/chain_config/presets VOLUME crates/primitives/chain_config/resources From 3f86de7281835da880d4b849ad469ceb980bb2cc Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 11:09:38 +0100 Subject: [PATCH 06/25] added release and docker build workflows --- scripts/launcher | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index 6edc6ea25..a8d849117 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -283,6 +283,7 @@ if [ -d "${INSTALL_DIR}/madara" ]; then cd "${INSTALL_DIR}/madara" && git pull else git clone https://github.com/madara-alliance/madara.git "${INSTALL_DIR}/madara" + git checkout fix/launcher-script cd "${INSTALL_DIR}/madara" fi @@ -309,9 +310,9 @@ echo "${YELLOW}3. Devnet${NC}" while true; do read -p "> " MODE_CHOICE case $MODE_CHOICE in - 1) MODE="Full"; break ;; - 2) MODE="Sequencer"; break ;; - 3) MODE="Devnet"; break ;; + 1) MODE="full"; break ;; + 2) MODE="sequencer"; break ;; + 3) MODE="devnet"; break ;; *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, or 3.${NC}" ;; esac done @@ -512,7 +513,7 @@ DOCKER_COMMAND="docker run -d --name madara-node \ -v ${BASE_PATH}:/data \ ${PORT_MAPPING} \ madara \ - run --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" + run --${MODE} --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" echo -e "\n🔄 ${YELLOW}${BOLD}The following Docker command will be executed:${NC}\n" echo -e "${CYAN}$DOCKER_COMMAND${NC}" From 7381ac9af420d244213fab64d1d5d340b34f1f82 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 11:12:24 +0100 Subject: [PATCH 07/25] added release and docker build workflows --- .github/workflows/docker-build.yml | 40 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 25 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 .github/workflows/docker-build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 000000000..6e017f0bb --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,40 @@ +name: Build and Push Docker Image to GitHub Container Registry + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image to GitHub Container Registry + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: | + ghcr.io/${{ github.repository_owner }}/madara:latest + ghcr.io/${{ github.repository_owner }}/madara:${{ github.event.release.tag_name }} + labels: | + org.opencontainers.image.source=${{ github.repository.html_url }} + org.opencontainers.image.version=${{ github.event.release.tag_name }} + + - name: Post successful message + run: echo "Docker image built and pushed successfully" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..d412f8aa6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +name: Create Release + +on: + push: + tags: + - 'v*.*.*' # Triggers on version tags like v1.0.0 + +jobs: + create_release: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Create GitHub Release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + name: Release ${{ github.ref_name }} + commit: ${{ github.sha }} + draft: false + prerelease: false + generateReleaseNotes: true From 80e6623eda7cce34f098441a8d0235db40d1e55f Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 11:17:02 +0100 Subject: [PATCH 08/25] changelog --- .github/workflows/release.yml | 2 +- CHANGELOG.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d412f8aa6..c0ad6b369 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Create Release on: push: tags: - - 'v*.*.*' # Triggers on version tags like v1.0.0 + - "v*.*.*" # Triggers on version tags like v1.0.0 jobs: create_release: diff --git a/CHANGELOG.md b/CHANGELOG.md index 506f81160..9f6756451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Next release +- feat(cli): launcher script and release workflows - fix: cleaned cli settings for sequencer, devnet and full - feat: move to karnot runner - fix: docker file fixes for devnet From a01f2dcb7873eaa0c1f5ab5e234621150b086dbd Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 11:37:59 +0100 Subject: [PATCH 09/25] updated release workflow --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c0ad6b369..179c1af26 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,9 @@ on: tags: - "v*.*.*" # Triggers on version tags like v1.0.0 +permissions: + contents: write # Add this line to grant write permissions to contents + jobs: create_release: runs-on: ubuntu-latest From 7866af55cea5e3e5e71d626ec5b5146a92f23144 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 12:21:13 +0100 Subject: [PATCH 10/25] updated release workflow --- .github/workflows/release.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2dfec8b99..a5c07eee5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,13 +5,11 @@ on: tags: - "v*.*.*" # Triggers on version tags like v1.0.0 -permissions: - contents: write - jobs: create_release: runs-on: ubuntu-latest - + permissions: + contents: write steps: - name: Checkout repository uses: actions/checkout@v3 @@ -19,10 +17,10 @@ jobs: - name: Create GitHub Release uses: ncipollo/release-action@v1 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.RELEASE_ACTION }} tag: ${{ github.ref_name }} name: Release ${{ github.ref_name }} commit: ${{ github.sha }} draft: false prerelease: false - generateReleaseNotes: true + generateReleaseNotes: true \ No newline at end of file From 22f4fc88a3e0bbdb50e79c239a9c6b45f043c3f8 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 14:26:36 +0100 Subject: [PATCH 11/25] updated launcher and docker build release --- .github/workflows/docker-build.yml | 2 +- scripts/launcher | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 6e017f0bb..6d9608206 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -6,7 +6,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: karnot-arc-runner-set steps: - name: Checkout repository diff --git a/scripts/launcher b/scripts/launcher index a8d849117..7196ec3a8 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -480,7 +480,6 @@ if [ "$RPC_ACCESS" == "yes" ]; then continue fi - # If everything is okay, break the loop break done @@ -508,12 +507,23 @@ done tput rc tput ed + +# Check if the image is available locally +IMAGE_NAME="ghcr.io/madara-alliance/madara/madara:latest" +if docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "$IMAGE_NAME"; then + echo -e "\n📦 ${GREEN}Docker image '$IMAGE_NAME' is already available locally.${NC}" +else + echo -e "\n🚢 ${YELLOW}${BOLD}Docker image not found locally. Pulling from GitHub Packages...${NC}" + docker login ghcr.io -u GITHUB_USERNAME -p GITHUB_TOKEN + docker pull $IMAGE_NAME +fi + # Build the final Docker run command DOCKER_COMMAND="docker run -d --name madara-node \ -v ${BASE_PATH}:/data \ ${PORT_MAPPING} \ - madara \ - run --${MODE} --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" + $IMAGE_NAME \ + --${MODE} --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" echo -e "\n🔄 ${YELLOW}${BOLD}The following Docker command will be executed:${NC}\n" echo -e "${CYAN}$DOCKER_COMMAND${NC}" @@ -533,4 +543,4 @@ if [ "$CONFIRM" == "yes" ]; then echo -e "\n${GREEN}Madara node is now running in Docker container 'madara-node'.${NC}" else echo -e "${RED}Command execution aborted.${NC}" -fi +fi \ No newline at end of file From afde7527fc9f0f01722740897fe333bce145d331 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 15:21:36 +0100 Subject: [PATCH 12/25] updated launcher --- .github/workflows/release.yml | 2 +- scripts/launcher | 78 ++++++++++++++++------------------- 2 files changed, 36 insertions(+), 44 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5c07eee5..a550ce213 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,4 +23,4 @@ jobs: commit: ${{ github.sha }} draft: false prerelease: false - generateReleaseNotes: true \ No newline at end of file + generateReleaseNotes: true diff --git a/scripts/launcher b/scripts/launcher index 7196ec3a8..856531a42 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -266,42 +266,6 @@ else echo -e "\n${GREEN}All dependencies are successfully installed and verified.${NC}" fi -echo -e "\n${GREEN}We will now proceed with the download of Madara from GitHub:${NC}" -echo -e "${CYAN}${GITHUB_ICON}${UNDERLINE}https://github.com/madara-alliance/madara${NC}" - -# Ask for installation directory -echo -e "\n${YELLOW}${BOLD}Where would you like to install Madara? (default is current directory)${NC}" -read -p "> " INSTALL_DIR - -# Set default directory if not provided -INSTALL_DIR=${INSTALL_DIR:-$(pwd)} - -# Clone the Madara repository (this step should be removed when we have images available remotely) -echo -e "\n${GREEN}Cloning the Madara repository into ${INSTALL_DIR}...${NC}" -if [ -d "${INSTALL_DIR}/madara" ]; then - echo -e "${YELLOW}Madara directory already exists. Updating...${NC}" - cd "${INSTALL_DIR}/madara" && git pull -else - git clone https://github.com/madara-alliance/madara.git "${INSTALL_DIR}/madara" - git checkout fix/launcher-script - cd "${INSTALL_DIR}/madara" -fi - -tput rc -tput ed - -# Build the Docker image -echo -e "\n${GREEN}Building the Docker image... (this operation will take a few minutes)${NC}" -# if ! docker build -t madara .; then -# echo -e "${RED}Docker image build failed. Please check the Dockerfile and try again.${NC}" -# exit 1 -# fi - -tput rc -tput ed - -echo -e "\n${GREEN}Madara has been correctly installed here: ${BOLD}${INSTALL_DIR}${NC}${GREEN}.${NC}" - # Choose the mode echo -e "\n🕹️ ${YELLOW}${BOLD} On which mode would you like to run Madara? (Enter a number)${NC}\n" echo "${YELLOW}1. Full Node${NC}" @@ -519,7 +483,7 @@ else fi # Build the final Docker run command -DOCKER_COMMAND="docker run -d --name madara-node \ +DOCKER_COMMAND="docker run -d --name madara-client \ -v ${BASE_PATH}:/data \ ${PORT_MAPPING} \ $IMAGE_NAME \ @@ -534,13 +498,41 @@ read -p "> " CONFIRM if [ "$CONFIRM" == "yes" ]; then echo -e "\n${GREEN}Starting the Madara node via Docker...${NC}" # Stop and remove any existing container with the same name - if docker ps -a --format '{{.Names}}' | grep -Eq "^madara-node\$"; then - echo -e "\n${YELLOW}A container named 'madara-node' already exists. Stopping and removing it...${NC}" - docker stop madara-node - docker rm madara-node + if docker ps -a --format '{{.Names}}' | grep -Eq "^madara-client\$"; then + echo -e "\n${YELLOW}A container named 'madara-client' already exists. Stopping and removing it...${NC}" + docker stop madara-client + docker rm madara-client fi eval $DOCKER_COMMAND - echo -e "\n${GREEN}Madara node is now running in Docker container 'madara-node'.${NC}" + tput rc + tput ed + # Check if the Madara Docker container is running + if docker ps --format '{{.Names}}' | grep -q '^madara-client$'; then + echo -e "\n${GREEN}Madara client is running.${NC}" + echo -e "${YELLOW}Container details:${NC}" + docker inspect madara-client --format ' + Name: {{.Name}} + ID: {{.Id}} + Image: {{.Config.Image}} + Status: {{.State.Status}} + StartedAt: {{.State.StartedAt}} + Ports: {{range $p, $conf := .NetworkSettings.Ports}}{{$p}}: {{(index $conf 0).HostPort}}{{end}}' + + echo -e "\n${YELLOW}Client Logs (last 10 lines):${NC}" + docker logs --tail 10 madara-client + + # Ask the user whether to quit or display more logs + echo -e "\n${YELLOW}${BOLD}Would you like to display the full logs of the running instance or quit? (logs/quit)${NC}\n" + read -p "> " USER_CHOICE + if [ "$USER_CHOICE" == "logs" ]; then + echo -e "\n${YELLOW}Displaying full logs...${NC}" + docker logs -f madara-client + else + echo -e "\n${GREEN}Exiting...${NC}" + fi + else + echo -e "${RED}Madara client is not running.${NC}" + fi else echo -e "${RED}Command execution aborted.${NC}" -fi \ No newline at end of file +fi From 4c6e13e8f8c8ac20c108549ebb30d12ce00c45ba Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 17:18:10 +0100 Subject: [PATCH 13/25] added chain config configuration --- scripts/launcher | 276 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 200 insertions(+), 76 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index 856531a42..b70244030 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -82,6 +82,13 @@ echo -e "${RED} " } +# Preset Chain Config URLs +declare -A PRESET_URLS +PRESET_URLS["starknet_mainnet"]="https://raw.githubusercontent.com/madara-alliance/madara/main/configs/presets/mainnet.yaml" +PRESET_URLS["starknet_testnet"]="https://raw.githubusercontent.com/madara-alliance/madara/main/configs/presets/testnet.yaml" +PRESET_URLS["test"]="https://raw.githubusercontent.com/madara-alliance/madara/main/configs/presets/test.yaml" +PRESET_URLS["devnet"]="https://raw.githubusercontent.com/madara-alliance/madara/main/configs/presets/devnet.yaml" + # Welcome message clear ascii_art @@ -110,6 +117,7 @@ fi DEPENDENCIES=( "curl:command -v curl" "git:command -v git" + "yq:command -v yq" ) # Function to check for a dependency @@ -176,6 +184,12 @@ if [ ${#MISSING_DEPS[@]} -ne 0 ] || [ "$DOCKER_MISSING" = true ]; then if [ "$OS" == "Linux" ]; then sudo apt update for DEP in "${MISSING_DEPS[@]}"; do + if [ "$DEP" == "yq" ]; then + echo -e "${GREEN}Installing yq...${NC}" + sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq + sudo chmod +x /usr/local/bin/yq + continue + fi if ! sudo apt install -y "$DEP"; then echo -e "${RED}Failed to install $DEP.${NC}" fi @@ -191,6 +205,13 @@ if [ ${#MISSING_DEPS[@]} -ne 0 ] || [ "$DOCKER_MISSING" = true ]; then fi elif [ "$OS" == "Mac" ]; then for DEP in "${MISSING_DEPS[@]}"; do + if [ "$DEP" == "yq" ]; then + echo -e "${GREEN}Installing yq via Homebrew...${NC}" + if ! brew install yq; then + echo -e "${RED}Failed to install yq.${NC}" + fi + continue + fi if ! brew install "$DEP"; then echo -e "${RED}Failed to install $DEP.${NC}" fi @@ -200,7 +221,7 @@ if [ ${#MISSING_DEPS[@]} -ne 0 ] || [ "$DOCKER_MISSING" = true ]; then if ! brew install --cask docker; then echo -e "${RED}Failed to install Docker.${NC}" else - echo -e "${GREEN}Docker installed.\nTrying to open /Applications/Docker.app to start the Docker daemon (you may need to do this step yourself if not located under /Applications/Docker.app).${NC}" + echo -e "${GREEN}Docker installed.\nTrying to open /Applications/Docker.app to start the Docker daemon.${NC}" open /Applications/Docker.app # Wait for Docker daemon to start echo -e "${GREEN}Waiting for Docker daemon to start...${NC}" @@ -227,7 +248,7 @@ if [ "$DOCKER_NOT_RUNNING" = true ]; then echo -e "${GREEN}Docker daemon is running.${NC}" fi elif [ "$OS" == "Mac" ]; then - echo -e "${GREEN}Docker installed.\nTrying to open /Applications/Docker.app to start the Docker daemon (you may need to do this step yourself if not located under /Applications/Docker.app).${NC}" + echo -e "${GREEN}Trying to open /Applications/Docker.app to start the Docker daemon.${NC}" open /Applications/Docker.app # Wait for Docker daemon to start echo -e "${GREEN}Waiting for Docker daemon to start...${NC}" @@ -267,7 +288,7 @@ else fi # Choose the mode -echo -e "\n🕹️ ${YELLOW}${BOLD} On which mode would you like to run Madara? (Enter a number)${NC}\n" +echo -e "\n🕹️ ${YELLOW}${BOLD}On which mode would you like to run Madara? (Enter a number)${NC}\n" echo "${YELLOW}1. Full Node${NC}" echo "${YELLOW}2. Sequencer${NC}" echo "${YELLOW}3. Devnet${NC}" @@ -302,114 +323,219 @@ tput ed echo -e "\n${GREEN}Your node has been correctly named: ${BOLD}${NODE_NAME}${NC}${GREEN}.${NC}" +# Ask for the database path +echo -e "\n💾 ${YELLOW}${BOLD}Where would you like to store your database? (default: /tmp/madara)${NC}" +read -p "> " BASE_PATH +BASE_PATH=${BASE_PATH:-/tmp/madara} + +tput rc +tput ed + +# Create the base path directory if it doesn't exist +if [ ! -d "$BASE_PATH" ]; then + mkdir -p "$BASE_PATH" +fi + +# Modify Chain Config Function +modify_chain_config() { + local config_file="$1" + local OVERRIDES_FILE="$BASE_PATH/overrides.txt" + > "$OVERRIDES_FILE" # Empty the overrides file + + # Read all leaf nodes with their paths and values + config_entries=() + while IFS= read -r line; do + config_entries+=("$line") + done < <(yq eval '.. | select(tag != "!!map" and tag != "!!seq") | [path | join("."), .] | @tsv' "$config_file") + + tput rc + tput ed + + # Display all parameters with improved formatting + echo -e "\n${YELLOW}${BOLD}Here are all the parameters of your chosen configuration:${NC}\n" + + prev_prefix="" + for i in "${!config_entries[@]}"; do + entry="${config_entries[$i]}" + path=$(echo "$entry" | cut -f1) + value=$(echo "$entry" | cut -f2-) + + # Extract the top-level prefix for grouping + prefix=$(echo "$path" | cut -d'.' -f1) + + # Add a new line and header when a new group starts + if [[ "$prefix" != "$prev_prefix" ]]; then + echo -e "${BLUE}${BOLD}$prefix:${NC}" + prev_prefix="$prefix" + fi + + # Indent sub-parameters + sub_path=$(echo "$path" | cut -d'.' -f2-) + if [[ -n "$sub_path" ]]; then + display_path=" - ${sub_path}" + else + display_path=" - $prefix" + fi + + echo -e "${YELLOW}$((i+1)). ${display_path} = ${value}${NC}" + done + + # Ask user which parameters to modify + echo -e "\n${YELLOW}Enter the numbers of the parameters you wish to modify, separated by spaces (e.g., 1 3 5).${NC}" + echo -e "${YELLOW}Press Enter to continue without modifying any parameters.${NC}" + read -p "> " MODIFY_NUMBERS + + # Check if the user wants to skip modifications + if [[ -z "$MODIFY_NUMBERS" ]]; then + echo -e "${GREEN}No parameters selected for modification. Proceeding with the original configuration.${NC}" + else + selected_indices=($MODIFY_NUMBERS) + + for index in "${selected_indices[@]}"; do + # Subtract 1 to convert to zero-based index + idx=$((index - 1)) + if [ "$idx" -ge 0 ] && [ "$idx" -lt "${#config_entries[@]}" ]; then + entry="${config_entries[$idx]}" + path=$(echo "$entry" | cut -f1) + value=$(echo "$entry" | cut -f2-) + echo -e "\n${YELLOW}Parameter: ${path}${NC}" + echo -e "${GREEN}Current value: ${value}${NC}" + echo -e "${YELLOW}Enter new value for ${path}:${NC}" + read -p "> " NEW_VALUE + echo "${path}=${NEW_VALUE}" >> "$OVERRIDES_FILE" + else + echo -e "${RED}Invalid selection: $index${NC}" + fi + done + fi + + # Apply the overrides to the original config file and write to $BASE_PATH/chain_config.yaml + MODIFIED_CONFIG_PATH="$BASE_PATH/chain_config.yaml" + cp "$config_file" "$MODIFIED_CONFIG_PATH" + + if [[ -s "$OVERRIDES_FILE" ]]; then + while IFS= read -r line; do + key=$(echo "$line" | cut -d'=' -f1) + val=$(echo "$line" | cut -d'=' -f2-) + yq eval -i ".${key} = \"${val}\"" "$MODIFIED_CONFIG_PATH" + done < "$OVERRIDES_FILE" + fi + + # Set CHAIN_CONFIG_FILE to the path of the modified chain config + CHAIN_CONFIG_FILE="$MODIFIED_CONFIG_PATH" +} + # Choose the network based on the mode -if [ "$MODE" == "Sequencer" ] || [ "$MODE" == "Devnet" ]; then +if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then # For sequencer and devnet modes echo -e "\n🌐 ${YELLOW}${BOLD}Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" echo "${YELLOW}1. Starknet Mainnet${NC}" echo "${YELLOW}2. Starknet Testnet${NC}" - echo "${YELLOW}3. Test${NC}" + echo "${YELLOW}3. Devnet${NC}" echo "${YELLOW}4. Custom Chain config${NC}" while true; do read -p "> " NETWORK_CHOICE case $NETWORK_CHOICE in - 1) PRESET="starknet_mainnet"; break ;; - 2) PRESET="starknet_testnet"; break ;; - 3) PRESET="test"; break ;; + 1) + PRESET="starknet_mainnet" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; + 2) + PRESET="starknet_testnet" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; + 3) + PRESET="devnet" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; 4) echo -e "\n${YELLOW}Please provide the path to your custom chain config:${NC}" read -p "> " CUSTOM_CHAIN_CONFIG if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then - PRESET="$CUSTOM_CHAIN_CONFIG" - break + PRESET="custom" + PRESET_PATH="$CUSTOM_CHAIN_CONFIG" else echo -e "${RED}File not found. Please provide a valid path.${NC}" + continue fi ;; - *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}"; continue ;; esac + + # Now, if a preset was selected (options 1-3), download the chain config file + if [ "$PRESET" != "custom" ]; then + # Download the chain config file to a temporary location + PRESET_PATH=$(mktemp) + curl -s -o "$PRESET_PATH" "$PRESET_URL" + if [ $? -ne 0 ] || [ ! -s "$PRESET_PATH" ]; then + echo -e "${RED}Failed to download the chain config file from $PRESET_URL.${NC}" + exit 1 + fi + fi + + # Call modify_chain_config with the chain config file + modify_chain_config "$PRESET_PATH" + break done else # For full node mode echo -e "\n🌐 ${YELLOW}${BOLD}Please choose a Network or provide a custom Chain config path: (Enter a number)${NC}\n" echo "${YELLOW}1. Starknet Mainnet${NC}" echo "${YELLOW}2. Starknet Testnet${NC}" - echo "${YELLOW}3. Starknet Integration${NC}" + echo "${YELLOW}3. Test${NC}" echo "${YELLOW}4. Custom Chain config${NC}" while true; do read -p "> " NETWORK_CHOICE case $NETWORK_CHOICE in - 1) NETWORK="main"; break ;; - 2) NETWORK="test"; break ;; - 3) NETWORK="integration"; break ;; + 1) + NETWORK="main" + PRESET="starknet_mainnet" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; + 2) + NETWORK="test" + PRESET="starknet_testnet" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; + 3) + NETWORK="test" + PRESET="test" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; 4) - tput rc - tput ed - - echo -e "\n${GREEN}You have chosen to run your node under a custom Chain config.${NC}" - - echo -e "\n${YELLOW}${BOLD}🌐 Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" - echo "${YELLOW}1. Starknet Mainnet${NC}" - echo "${YELLOW}2. Starknet Testnet${NC}" - echo "${YELLOW}3. Test${NC}" - echo "${YELLOW}4. Custom Chain config${NC}" - while true; do - read -p "> " NETWORK_CHOICE - case $NETWORK_CHOICE in - 1) PRESET="starknet_mainnet"; break ;; - 2) PRESET="starknet_testnet"; break ;; - 3) PRESET="test"; break ;; - 4) - echo -e "\n${YELLOW}Please provide the path to your custom chain config:${NC}" - read -p "> " CUSTOM_CHAIN_CONFIG - if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then - PRESET="$CUSTOM_CHAIN_CONFIG" - break - else - echo -e "${RED}File not found. Please provide a valid path.${NC}" - fi - ;; - *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; - esac - done + echo -e "\n${YELLOW}Please provide the path to your custom chain config:${NC}" + read -p "> " CUSTOM_CHAIN_CONFIG + if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then + NETWORK="custom" + PRESET_PATH="$CUSTOM_CHAIN_CONFIG" + else + echo -e "${RED}File not found. Please provide a valid path.${NC}" + continue + fi ;; - *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}"; continue ;; esac - done -fi -tput rc -tput ed - -echo -e "\n${GREEN}You have chosen to run your node under: ${NETWORK}.${NC}" + # For options 1-3, download the chain config file and call modify_chain_config + if [ "$NETWORK" != "custom" ]; then + PRESET_PATH=$(mktemp) + curl -s -o "$PRESET_PATH" "$PRESET_URL" + if [ $? -ne 0 ] || [ ! -s "$PRESET_PATH" ]; then + echo -e "${RED}Failed to download the chain config file from $PRESET_URL.${NC}" + exit 1 + fi + fi -# Set the chain config or network option -if [ "$MODE" == "Sequencer" ] || [ "$MODE" == "Devnet" ]; then - # Use --chain-config with PRESET - CHAIN_CONFIG_OPT="--chain-config=\"${PRESET}\"" -else - # For full node mode - if [ "$NETWORK_CHOICE" -eq 4 ]; then - # Custom chain config - CHAIN_CONFIG_OPT="--chain-config=\"${NETWORK}\"" - else - # Use --network - CHAIN_CONFIG_OPT="--network=\"${NETWORK}\"" - fi + # Call modify_chain_config with the chain config file + modify_chain_config "$PRESET_PATH" + break + done fi -# Ask for the database path -echo -e "\n💾 ${YELLOW}${BOLD}Where would you like to store your database? (default: /tmp/madara)${NC}" -read -p "> " BASE_PATH -BASE_PATH=${BASE_PATH:-/tmp/madara} - tput rc tput ed -# Create the base path directory if it doesn't exist -if [ ! -d "$BASE_PATH" ]; then - mkdir -p "$BASE_PATH" -fi +echo -e "\n${GREEN}You have chosen to run your node under the preset or custom chain config.${NC}" # Ask for RPC access while true; do @@ -471,14 +597,12 @@ done tput rc tput ed - # Check if the image is available locally IMAGE_NAME="ghcr.io/madara-alliance/madara/madara:latest" if docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "$IMAGE_NAME"; then echo -e "\n📦 ${GREEN}Docker image '$IMAGE_NAME' is already available locally.${NC}" else echo -e "\n🚢 ${YELLOW}${BOLD}Docker image not found locally. Pulling from GitHub Packages...${NC}" - docker login ghcr.io -u GITHUB_USERNAME -p GITHUB_TOKEN docker pull $IMAGE_NAME fi @@ -487,7 +611,7 @@ DOCKER_COMMAND="docker run -d --name madara-client \ -v ${BASE_PATH}:/data \ ${PORT_MAPPING} \ $IMAGE_NAME \ - --${MODE} --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" + --${MODE} --name \"${NODE_NAME}\" --chain-config=\"/data/chain_config.yaml\" --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" echo -e "\n🔄 ${YELLOW}${BOLD}The following Docker command will be executed:${NC}\n" echo -e "${CYAN}$DOCKER_COMMAND${NC}" From 1b8b45f4d9fad0e90d0948ced3b700c7fb71c641 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 17:36:16 +0100 Subject: [PATCH 14/25] optimized docker build and launcher --- .github/workflows/docker-build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 6d9608206..9cc8da280 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -12,6 +12,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -35,6 +38,8 @@ jobs: labels: | org.opencontainers.image.source=${{ github.repository.html_url }} org.opencontainers.image.version=${{ github.event.release.tag_name }} + cache-from: type=gha + cache-to: type=gha,mode=max - name: Post successful message run: echo "Docker image built and pushed successfully" From f728bf9abd5ec1304c90ab9a82e4454761397698 Mon Sep 17 00:00:00 2001 From: antiyro Date: Wed, 2 Oct 2024 11:05:45 +0100 Subject: [PATCH 15/25] cleaned inputs --- scripts/launcher | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index a2cc388a1..624c86d9a 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -324,7 +324,7 @@ tput ed echo -e "\n${GREEN}Your node has been correctly named: ${BOLD}${NODE_NAME}${NC}${GREEN}.${NC}" # Ask for the database path -echo -e "\n💾 ${YELLOW}${BOLD}Where would you like to store your database? (default: /tmp/madara)${NC}" +echo -e "\n💾 ${YELLOW}${BOLD}Where would you like to store your database? (it will be located inside your docker container) (default: /tmp/madara)${NC}" read -p "> " BASE_PATH BASE_PATH=${BASE_PATH:-/tmp/madara} @@ -387,7 +387,7 @@ modify_chain_config() { # Check if the user wants to skip modifications if [[ -z "$MODIFY_NUMBERS" ]]; then - echo -e "${GREEN}No parameters selected for modification. Proceeding with the original configuration.${NC}" + echo -e "${GREEN}No parameters selected for modification. Proceeding with the original configuration.${NC}" else selected_indices=($MODIFY_NUMBERS) From 38205819009848ccc13f09917958fd170129ba04 Mon Sep 17 00:00:00 2001 From: antiyro Date: Wed, 2 Oct 2024 12:17:55 +0100 Subject: [PATCH 16/25] updated readme --- scripts/launcher | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index 624c86d9a..b64b933a1 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -47,6 +47,7 @@ RED=$(tput setaf 1) CYAN=$(tput setaf 6) NC=$(tput sgr0) # No Color BOLD=$(tput bold) +ITALIC=$(tput sitm) UNDERLINE=$(tput smul) BLINK=$(tput blink) @@ -289,9 +290,9 @@ fi # Choose the mode echo -e "\n🕹️ ${YELLOW}${BOLD}On which mode would you like to run Madara? (Enter a number)${NC}\n" -echo "${YELLOW}1. Full Node${NC}" -echo "${YELLOW}2. Sequencer${NC}" -echo "${YELLOW}3. Devnet${NC}" +echo "${YELLOW}1. Full Node ${ITALIC}(Syncronize state from a specific Network)${NC}" +echo "${YELLOW}2. Sequencer ${ITALIC}(Produce state for a specific Network)${NC}" +echo "${YELLOW}3. Devnet ${ITALIC}(Launch a test network with pre-funded accounts) ${NC}" while true; do read -p "> " MODE_CHOICE case $MODE_CHOICE in @@ -324,7 +325,7 @@ tput ed echo -e "\n${GREEN}Your node has been correctly named: ${BOLD}${NODE_NAME}${NC}${GREEN}.${NC}" # Ask for the database path -echo -e "\n💾 ${YELLOW}${BOLD}Where would you like to store your database? (it will be located inside your docker container) (default: /tmp/madara)${NC}" +echo -e "\n💾 ${YELLOW}${BOLD}Where would you like to store your database?${NC}${YELLOW} (it will be located inside your docker container) (default: /tmp/madara)${NC}" read -p "> " BASE_PATH BASE_PATH=${BASE_PATH:-/tmp/madara} @@ -482,8 +483,8 @@ else echo -e "\n🌐 ${YELLOW}${BOLD}Please choose a Network or provide a custom Chain config path: (Enter a number)${NC}\n" echo "${YELLOW}1. Starknet Mainnet${NC}" echo "${YELLOW}2. Starknet Testnet${NC}" - echo "${YELLOW}3. Test${NC}" - echo "${YELLOW}4. Custom Chain config${NC}" + echo "${YELLOW}3. Test Network${NC}" + echo "${YELLOW}4. Custom Network${NC}" while true; do read -p "> " NETWORK_CHOICE case $NETWORK_CHOICE in From 8e393844802f37042f52dd05918777fb36276cac Mon Sep 17 00:00:00 2001 From: antiyro Date: Wed, 2 Oct 2024 12:19:28 +0100 Subject: [PATCH 17/25] updated readme --- README.md | 519 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 396 insertions(+), 123 deletions(-) diff --git a/README.md b/README.md index cbbbbde65..8610d876d 100644 --- a/README.md +++ b/README.md @@ -9,214 +9,491 @@ [![Workflow - Push](https://github.com/madara-alliance/madara/actions/workflows/push.yml/badge.svg)](https://github.com/madara-alliance/madara/actions/workflows/push.yml) [![Project license](https://img.shields.io/github/license/madara-alliance/madara.svg?style=flat-square)](LICENSE) [![Pull Requests welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg?style=flat-square)](https://github.com/madara-alliance/madara/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) - - + + -# 🥷 Madara: Starknet client +# 🥷 Madara: Starknet Client -Madara is a powerfull Starknet hybrid client written in Rust. +Madara is a powerful Starknet hybrid client written in Rust. ## Table of Contents - ⬇️ Installation - [Run from Source](#run-from-source) - - [Run with Docker](#run-with-docker) + - [Run with Docker (Recommended)](#run-with-docker-recommended) - [Run with Docker Compose](#run-with-docker-compose) + - [Run with Installation Script](#run-with-installation-script) - ⚙️ Configuration - - [Basic Command-Line Options](#basic-command-line-options) - - [Advanced Command-Line Options](#advanced-command-line-options) + - [Priority of Configuration](#priority-of-configuration) + - [Command-Line Options](#command-line-options) + - [Basic Command-Line Options](#basic-command-line-options) + - [Advanced Command-Line Options by Namespace](#advanced-command-line-options-by-namespace) + - [Environment Variables](#environment-variables) + - [Configuration File](#configuration-file) - 📸 Snapshots - 🌐 Interactions - [Supported JSON-RPC Methods](#supported-json-rpc-methods) - [Example of Calling a JSON-RPC Method](#example-of-calling-a-json-rpc-method) -- Supported Features +- ✔ Supported Features - 👍 Contribute +- 🤝 Partnerships +- ⚠️ License ## ⬇️ Installation +In this section, we will guide you through the build and run process so that you can run your own Madara client and query the Starknet blockchain as smoothly as possible. + +We have divided this section into three difficulty levels: + +- [**Low-level**](#run-from-source) (from source by building the Rust binary locally) +- [**Mid-level**](#run-with-docker-recommended) (from Docker **recommended** via the available Docker images) +- [**High-level**](#run-with-installation-script) (from a high-level interactive menu) + ### Run from Source -1. **Install dependencies** +This installation process will help you build the binary directly from the source code locally on your machine. - Ensure you have the necessary dependencies: +1. **Install Dependencies** - ```sh - sudo apt-get update && sudo apt-get install -y \ - clang \ - protobuf-compiler \ - build-essential - ``` + Ensure you have everything needed to complete this tutorial. - Install Rust: + | Dependency | Version | Installation Command | + | ---------- | ---------- | --------------------------------------------------------------------------------- | + | Rust | rustc 1.78 | `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` | + | Clang | Latest | `sudo apt-get install clang` | + | Scarb | v2.8.2 | `curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh \| sh` | - ```sh - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s - ``` +2. **Get Code** - Clone the Madara repository: + Fetch the code from the official [Madara](https://github.com/madara-alliance/madara) repository in the folder of your choice. - ```sh + ```bash cd git clone https://github.com/madara-alliance/madara . ``` -2. **Run Madara** +3. **Build Program** + + Choose one of the following build modes: + + - **Debug** (fastest build mode, but lower performance, for testing purposes only) + + ```bash + cargo build + ``` + + - **Release** (the recommended build mode) + + ```bash + cargo build --release + ``` + + - **Production** (the recommended build mode for production performance) + + ```bash + cargo build --profile=production + ``` + +4. **Run Madara** + + Start the Madara client with a basic set of arguments, depending on your chosen mode: + + **Full Node** + + ```bash + cargo run --release -- \ + --name Madara \ + --full \ + --base-path /var/lib/madara \ + --network mainnet \ + --l1-endpoint ${ETHEREUM_API_URL} + ``` + + **Sequencer** + + ```bash + cargo run --release -- \ + --name Madara \ + --sequencer \ + --base-path /var/lib/madara \ + --preset test \ + --l1-endpoint ${ETHEREUM_API_URL} + ``` - Start the Madara client with synchronization to Starknet mainnet: + **Devnet** - ```sh + ```bash cargo run --release -- \ - --name madara \ - --base-path ../madara-db \ + --name Madara \ + --devnet \ + --base-path /var/lib/madara \ + --preset test + ``` + + > ℹ️ **Note:** We recommend visiting the [Configuration](#configuration) section to customize your node parameters. + + > ℹ️ **Note:** If you don't have an L1 endpoint URL, we recommend heading to the [Verification](#verification) section to get one. + +### Run with Docker (Recommended) + +This is the recommended way to easily install and run Madara as it only requires terminal access and Docker installed. + +1. **Install Docker** + + Ensure Docker is installed on your system. If not, you can install it by following the instructions for your operating system: + + - **MacOS**: + + Download and install Docker Desktop for Mac from [Docker Hub](https://hub.docker.com/editions/community/docker-ce-desktop-mac/). + + - **Linux**: + + Install Docker using the package manager for your distribution. For example, on Ubuntu: + + ```bash + sudo apt-get update + sudo apt-get install \ + ca-certificates \ + curl \ + gnupg \ + lsb-release + + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \ + https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + + sudo apt-get update + sudo apt-get install docker-ce docker-ce-cli containerd.io + ``` + + - **Windows**: + + Download and install Docker Desktop for Windows from [Docker Hub](https://hub.docker.com/editions/community/docker-ce-desktop-windows/). + +2. **Run Docker Image** + + Once you have successfully installed Docker, you can now run Madara using the available Docker images. + + ```bash + docker run -d \ + --name Madara \ + -p 9944:9944 \ + -v /var/lib/madara:/var/lib/madara \ + madara:latest \ + --base-path /var/lib/Madara \ --network main \ - --l1-endpoint ${ETHEREUM_API_URL} \ + --l1-endpoint ${ETHEREUM_API_URL} ``` -### Run with Docker + > ℹ️ **Note:** This is a default configuration. For more information on possible configurations, please visit the [Configuration](#configuration) section. -1 **Run docker image** + > ⚠️ **Warning:** Make sure to change the volume `-v` of your container if you change the `--base-path`. -To run Madara with Docker, use the following command: + If you don't have an L1 endpoint URL, we recommend heading to the [Verification](#verification) section to get one. -```sh -docker run -d \ - --name madara \ - -p 9944:9944 \ - -v /var/lib/madara:/var/lib/madara \ - madara:latest \ - --base-path ./madara-db \ - --network main \ - --rpc-external \ - --rpc-cors all \ - --preset mainnet \ - --l1-endpoint -``` +3. **Check Logs** -Check the logs of the running Madara service: + To check the logs of the running Madara service: -```sh -docker logs -f madara -``` + ```bash + docker logs -f Madara + ``` + + Now you can head up to the [Metrics](#metrics) section to easily deploy a Grafana and Prometheus dashboard. ### Run with Docker Compose -1. **Ensure environment variable** +1. **Prerequisites** + + Ensure you have Docker and Docker Compose installed on your machine. + +2. **Prepare the Environment** Set the necessary environment variable: - ```sh - export L1_ENDPOINT="your-ethereum-api-url" + ```bash + export ETHEREUM_API_URL="your-ethereum-api-url" ``` Or create a `.env` file in the same directory as your `docker-compose.yml` file: - ```sh - L1_ENDPOINT=your-ethereum-api-url + ``` + ETHEREUM_API_URL=your-ethereum-api-url ``` -2. **Build and Run the Container** + > ⚠️ **Note:** When running with `sudo`, environment variables set in the current session might not be carried over. You can pass the variable directly to sudo using the `-E` option to preserve the environment. - Navigate to the directory with your `docker-compose.yml` file and run one of the following commands: + If you don't have an L1 endpoint URL, we recommend heading to the [Verification](#verification) section to get one. - - Mainnet: +3. **Build and Run the Container** - ```sh - docker-compose --profile mainnet up -d - ``` + Navigate to the directory with your `docker-compose.yml` file and run the following command: + + ```bash + docker-compose up -d + ``` - - Testnet: + This command will build the Docker image and start the container in detached mode. - ```sh - docker-compose --profile testnet up -d - ``` +4. **Check Logs** - Check the logs of the running Madara service: + You can view the logs of the running Madara service using the following command: - ```sh - docker-compose logs -f madara + ```bash + docker-compose logs -f Madara ``` + Now you can head up to the [Metrics](#metrics) section to easily deploy a Grafana and Prometheus dashboard. + +### Run with Installation Script + +This is the highest-level way to install Madara with some custom features. For advanced configuration, we recommend using the source or Docker methods. + +1. **Download Script** + + You will need to download and run the installer script using the following command: + + ```bash + # Installation script command line (to be provided) + ``` + +2. **Follow Instructions** + + Follow the interactive instructions provided by the installation script to set up your Madara client. + + > **Note:** This method is under development. For more advanced configurations, please use the source or Docker methods. + +> ℹ️ **Note:** Now that you know how to launch a Madara client, you might want to set some parameters to customize it. Therefore, you can go to the following [Configuration](#configuration) section. + ## ⚙️ Configuration -Configuring your Madara node properly ensures it meets your specific needs +Configuring your Madara client properly ensures that it meets your specific needs. Configuration can be done through three main avenues: + +- **Command-line arguments** +- **Environment variables** +- **Configuration files** + +### Priority of Configuration + +> ℹ️ **Note:** Configuration priority is as follows: command-line arguments > environment variables > configuration files. When the same setting is configured in multiple places, the source with the highest priority takes effect. + +### Command-Line Options + +For a comprehensive list of command-line options: + +```bash +cargo run -- --help +``` -### Basic Command-Line Options +Below are some essential command-line options and a categorized list of advanced configurations: -Here are the recommended options for a quick and simple configuration of your Madara full node: +#### Basic Command-Line Options + +Here are the recommended options for a quick and simple configuration of your Madara client: - **`--name `**: The human-readable name for this node. It's used as the network node name. -- **`--base-path `**: Set the directory for Starknet data (default is `/tmp/madara`). -- **`--network `**: The network type to connect to (`main`, `test`, or `integration`). +- **`--base-path `**: Set the directory for Madara data (default is `/tmp/madara`). +- **`--network `**: The network type to connect to (`main`, `test`, `integration`, or `devnet`). - **`--l1-endpoint `**: Specify the Layer 1 endpoint the node will verify its state from. - **`--rpc-port `**: Specify the JSON-RPC server TCP port. -- **`--rpc-cors `**: Specify browser origins allowed to access the HTTP & WS RPC servers. +- **`--rpc-cors `**: Specify browser origins allowed to access the HTTP & WebSocket RPC servers. - **`--rpc-external`**: Listen to all RPC interfaces. Default is local. -- **`--snap `**: Start syncing from the closest snapshot available for the desired block (default is highest). -### Advanced Command-Line Options +> ℹ️ **Note:** For more information regarding synchronization configuration, please refer to the next section. + +#### Advanced Command-Line Options by Namespace -Here are more advanced command-line options, organized by namespace, for running and development purposes: +Toggle details for each namespace to view additional settings:
-Network +Network -- **`-n, --network `**: The network type to connect to (default: `integration`). -- **`--port `**: Set the network listening port. -- **`--l1-endpoint `**: Specify the Layer 1 endpoint the node will verify its state from. -- **`--gateway-key `**: Gateway API key to avoid rate limiting (optional). -- **`--sync-polling-interval `**: Polling interval in seconds (default: 2). -- **`--no-sync-polling`**: Stop sync polling. -- **`--n-blocks-to-sync `**: Number of blocks to sync. -- **`--starting-block `**: The block to start syncing from (make sure to set `--disable-root`). +- **`--network `**: The network type to connect to. + - [default: main] + + Possible values: + + - `main`: The main network (mainnet). Alias: mainnet + - `test`: The test network (testnet). Alias: sepolia + - `integration`: The integration network + - `devnet`: A devnet for local testing + +- **`--l1-endpoint `**: Specify the Layer 1 RPC endpoint for state verification. + +- **`--gateway-key `**: Gateway API key to avoid rate limiting (optional). + +- **`--sync-polling-interval `**: Polling interval in seconds. This affects the sync service after catching up with the blockchain tip. + - [default: 4] + +- **`--pending-block-poll-interval `**: Pending block polling interval in seconds. + - [default: 2] + +- **`--no-sync-polling`**: Disable sync polling. Sync service will not import new blocks after catching up with the blockchain tip. + +- **`--n-blocks-to-sync `**: Number of blocks to sync, useful for benchmarking. + +- **`--unsafe-starting-block `**: Start syncing from a specific block. May cause database inconsistency. + +- **`--sync-disabled`**: Disable the sync service. + +- **`--sync-l1-disabled`**: Disable L1 sync service. + +- **`--gas-price-sync-disabled`**: Disable the gas price sync service. + +- **`--gas-price-poll-ms `**: Interval in milliseconds for the gas price sync service to fetch the gas price. + - [default: 10000] + +
+ +
+RPC + +- **`--rpc-disabled`**: Disable the RPC server. + +- **`--rpc-external`**: Listen to all network interfaces. + +- **`--rpc-methods `**: RPC methods to expose. + - [default: auto] + + Possible values: + + - `auto`: Expose all methods if RPC is on localhost, otherwise serve only safe methods. + - `safe`: Allow only a safe subset of RPC methods. + - `unsafe`: Expose all RPC methods (even potentially unsafe ones). + +- **`--rpc-rate-limit `**: RPC rate limiting per connection. + +- **`--rpc-rate-limit-whitelisted-ips `**: Disable RPC rate limiting for specific IP addresses or ranges. + +- **`--rpc-rate-limit-trust-proxy-headers`**: Trust proxy headers for disabling rate limiting in reverse proxy setups. + +- **`--rpc-max-request-size `**: Maximum RPC request payload size. + - [default: 15] + +- **`--rpc-max-response-size `**: Maximum RPC response payload size. + - [default: 15] + +- **`--rpc-max-subscriptions-per-connection `**: Maximum concurrent subscriptions per connection. + - [default: 1024] + +- **`--rpc-port `**: The RPC port to listen on. + - [default: 9944] + +- **`--rpc-max-connections `**: Maximum number of RPC server connections at a given time. + - [default: 100] + +- **`--rpc-disable-batch-requests`**: Disable RPC batch requests. + +- **`--rpc-max-batch-request-len `**: Limit the max length for an RPC batch request. + +- **`--rpc-cors `**: Specify browser origins allowed to access the HTTP & WebSocket RPC servers. A comma-separated list of origins, or the special `all` value. + +- **`--rpc-message-buffer-capacity-per-connection `**: Maximum number of messages in memory per connection. + - [default: 64]
-RPC - -- **`--rpc-external`**: Listen to all RPC interfaces. Note: not all RPC methods are safe to be exposed publicly. - Use an RPC proxy server to filter out dangerous methods. -- **`--rpc-methods `**: RPC methods to expose (`auto`, `safe`, `unsafe`). -- **`--rpc-max-request-size `**: Set the maximum RPC request payload size in megabytes (default: 15). -- **`--rpc-max-response-size `**: Set the maximum RPC response payload size in megabytes (default: 15). -- **`--rpc-max-subscriptions-per-connection `**: Set the maximum concurrent subscriptions per connection (default: 1024). -- **`--rpc-port `**: Specify JSON-RPC server TCP port. -- **`--rpc-max-connections `**: Maximum number of RPC server connections (default: 100). -- **`--rpc-cors `**: Specify browser origins allowed to access the HTTP & WS RPC servers. +Database + +- **`--base-path `**: The path where Madara will store the database. + - [default: /tmp/madara] + +- **`--backup-dir `**: Directory for backups. + +- **`--backup-every-n-blocks `**: Periodically create a backup, useful for debugging. + +- **`--restore-from-latest-backup`**: Restore the database from the latest backup version.
-Database - -- **`--base-path `**: Specify custom base path (default: `/tmp/madara`). -- **`--snap `**: Start syncing from the closest snapshot available for the desired block. -- **`--tmp`**: Run a temporary node. A temporary directory will be created and deleted at the end of the process. -- **`--cache`**: Enable caching of blocks and transactions to improve response times. -- **`--db-cache `**: Limit the memory the database cache can use. -- **`--trie-cache-size `**: Specify the state cache size (default: 67108864). -- **`--backup-every-n-blocks `**: Specify the number of blocks after which a backup should be created. -- **`--backup-dir `**: Specify the directory where backups should be stored. -- **`--restore-from-latest-backup`**: Restore the database from the latest backup available. +Block Production + +- **`--block-production-disabled`**: Disable the block production service. + +- **`--devnet`**: Launch in block production mode, with devnet contracts. + +- **`--devnet-contracts `**: Create this number of contracts in the genesis block for the devnet configuration. + - [default: 10] + +- **`--override-devnet-chain-id`**: Launch a devnet with a production chain ID. This is unsafe because your devnet transactions can be replayed on the actual network. + +- **`--authority`**: Enable authority mode; the node will run as a sequencer and try to produce its own blocks.
-> ℹ️ **Info:** Note that not all parameters may be referenced here. -> Please refer to the `cargo run -- --help` command for the full list of parameters. +
+Metrics + +- **`--telemetry-disabled`**: Disable connection to the Madara telemetry server. + +- **`--telemetry-url `**: The URL of the telemetry server with verbosity level. + - [default: "wss://starknodes.com/submit 0"] + +- **`--prometheus-port `**: The port used by the Prometheus RPC service. + - [default: 9615] + +- **`--prometheus-external`**: Listen on all network interfaces for Prometheus. + +- **`--prometheus-disabled`**: Disable the Prometheus service. + +
+ +
+P2P + +**Coming soon** + +
+ +### Environment Variables + +Set up your node's environment variables using the `STARKNET_` prefix. For example: + +- `STARKNET_BASE_PATH=/path/to/data` +- `STARKNET_LOG=info` + +These variables allow you to adjust the node's configuration without using command-line arguments. + +### Configuration File + +You can use a JSON, TOML, or YAML file to structure your configuration settings. Specify your configuration file on startup with the `-c` option. Here's a basic example in JSON format: + +```json +{ + "name": "Deoxys", + "base_path": "../deoxys-db", + "network": "mainnet", + "l1_endpoint": "your-ethereum-api-url", + "rpc_port": 9944, + "rpc_cors": "*", + "rpc_external": true, + "prometheus_external": true +} +``` + +> 💡 **Tip:** Review settings carefully for optimal performance and refer to Starknet's official documentation for detailed configuration guidelines. + +Always test your configuration in a non-production environment before rolling it out to a live node to prevent downtime and other potential issues. + +> ℹ️ **Note:** For a custom chain configuration, you can head to the configuration section of chain operators deployments. ## 📸 Snapshots -Snapshots are under developpement and will be available through the `--snap ` parameter. +Snapshots are under development and will be available through the `--snap ` parameter. ## 🌐 Interactions -Madara fully supports all the JSON-RPC methods as specified in the Starknet mainnet official [JSON-RPC specs](https://github.com/starkware-libs/starknet-specs). -These methods can be categorized into three main types: Read-Only Access Methods, Trace Generation Methods, and Write Methods. +Madara fully supports all the JSON-RPC methods as specified in the Starknet mainnet official [JSON-RPC specs](https://github.com/starkware-libs/starknet-specs). These methods can be categorized into three main types: Read-Only Access Methods, Trace Generation Methods, and Write Methods. ### Supported JSON-RPC Methods @@ -275,7 +552,7 @@ Here is a list of all the supported methods with their current status: -> ℹ️ **Info:** Madara currently supports latest [JSON-RPC specs](https://github.com/starkware-libs/starknet-specs) specs up to version v0.7.1 +> ℹ️ **Info:** Madara currently supports the latest [JSON-RPC specs](https://github.com/starkware-libs/starknet-specs) up to version `v0.7.1`. ### Example of Calling a JSON-RPC Method @@ -292,12 +569,9 @@ Here is an example of how to call a JSON-RPC method using Madara: } ``` -You can use any JSON-RPC client to interact with the Madara node, such as `curl`, `httpie`, -or a custom client in your preferred programming language. -For more detailed information and examples on each method, please refer to the [Starknet JSON-RPC specs](https://github.com/starkware-libs/starknet-specs). +You can use any JSON-RPC client to interact with the Madara node, such as `curl`, `httpie`, or a custom client in your preferred programming language. For more detailed information and examples on each method, please refer to the [Starknet JSON-RPC specs](https://github.com/starkware-libs/starknet-specs). -> ⚠️ **Warning:** Write methods are forwarded to the Sequencer for execution. -> Ensure you handle errors appropriately as per the JSON-RPC schema. +> ⚠️ **Warning:** Write methods are forwarded to the Sequencer for execution. Ensure you handle errors appropriately as per the JSON-RPC schema. ## ✔ Supported Features @@ -314,15 +588,14 @@ Each feature is designed to ensure optimal performance and seamless integration ## 👍 Contribute +We welcome contributions from the community! Please read our [contributing guidelines](CONTRIBUTING.md) to get started. + ## 🤝 Partnerships -To establish a partnership with the Kasar team, or if you have any suggestion or -special request, feel free to reach us on [telegram](https://t.me/madara-alliance). +To establish a partnership with the Madara team, or if you have any suggestions or special requests, feel free to reach us on [Telegram](https://t.me/madara_alliance). ## ⚠️ License -Copyright (c) 2022-present, with the following -[contributors](https://github.com/madara-alliance/madara/graphs/contributors). +Copyright (c) 2022-present. -Madara is open-source software licensed under the -[Apache-2.0 License](https://github.com/madara-alliance/madara/blob/main/LICENSE). +Madara is open-source software licensed under the [Apache-2.0 License](https://github.com/madara-alliance/madara/blob/main/LICENSE). \ No newline at end of file From 2bfc8e618613f178169197e070171b4a8f997287 Mon Sep 17 00:00:00 2001 From: antiyro Date: Wed, 2 Oct 2024 13:40:15 +0100 Subject: [PATCH 18/25] reverted working docker --- Dockerfile | 64 +++---- README.md | 519 +++++++++++++---------------------------------------- 2 files changed, 150 insertions(+), 433 deletions(-) diff --git a/Dockerfile b/Dockerfile index d75185f7f..b68a62d29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,60 +1,50 @@ # Stage 1: Build the application -FROM rust:1.78 AS builder - +FROM rust:1.78 as builder # Install build dependencies -RUN apt-get -y update && \ +RUN apt-get -y update && \ apt-get install -y clang && \ - apt-get autoremove -y; \ - apt-get clean; \ + apt-get autoremove -y; \ + apt-get clean; \ rm -rf /var/lib/apt/lists/* - # Set the working directory WORKDIR /usr/src/madara/ - -# Copy the source code +# Copy the source code into the container COPY Cargo.toml Cargo.lock ./ COPY crates crates COPY cairo cairo COPY cairo_0 cairo_0 -# Installing Scarb -# Dynamically detect the architecture -ARG SCARB_VERSION="v2.8.2" -ARG SCARB_REPO="https://github.com/software-mansion/scarb/releases/download" -RUN ARCH=$(uname -m); \ - if [ "$ARCH" = "x86_64" ]; then \ - PLATFORM="x86_64-unknown-linux-gnu"; \ - elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then \ - PLATFORM="aarch64-unknown-linux-gnu"; \ - else \ - echo "Unsupported architecture: $ARCH"; exit 1; \ - fi && \ - curl -fLS -o /usr/src/scarb.tar.gz \ - $SCARB_REPO/$SCARB_VERSION/scarb-$SCARB_VERSION-$PLATFORM.tar.gz && \ - tar -xz -C /usr/local --strip-components=1 -f /usr/src/scarb.tar.gz + +# Installing scarb, new since devnet integration +# Installation steps are taken from the scarb build script +# https://github.com/software-mansion/scarb/blob/main/install.sh +ENV SCARB_VERSION="v2.8.2" +ENV SHELL /bin/bash +RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- ${SCARB_VERSION} +ENV PATH="/root/.local/bin:${PATH}" +RUN scarb --version + +# Install runtime dependencies +RUN apt-get -y update && \ + apt-get install -y openssl ca-certificates busybox && \ + apt-get autoremove -y; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/* # Build the application in release mode RUN cargo build --release - # Stage 2: Create the final runtime image -FROM debian:bookworm-slim - +FROM debian:bookworm # Install runtime dependencies -RUN apt-get -y update && \ - apt-get install -y openssl ca-certificates && \ - apt-get autoremove -y; \ - apt-get clean; \ +RUN apt-get -y update && \ + apt-get install -y openssl ca-certificates tini &&\ + apt-get autoremove -y; \ + apt-get clean; \ rm -rf /var/lib/apt/lists/* - # Set the working directory WORKDIR /usr/local/bin - # Copy the compiled binary from the builder stage COPY --from=builder /usr/src/madara/target/release/madara . -# Chain presets to be mounted at startup -VOLUME crates/primitives/chain_config/presets -VOLUME crates/primitives/chain_config/resources - # Set the entrypoint -ENTRYPOINT ["./madara"] +ENTRYPOINT ["./madara"] \ No newline at end of file diff --git a/README.md b/README.md index 8610d876d..cbbbbde65 100644 --- a/README.md +++ b/README.md @@ -9,491 +9,214 @@ [![Workflow - Push](https://github.com/madara-alliance/madara/actions/workflows/push.yml/badge.svg)](https://github.com/madara-alliance/madara/actions/workflows/push.yml) [![Project license](https://img.shields.io/github/license/madara-alliance/madara.svg?style=flat-square)](LICENSE) [![Pull Requests welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg?style=flat-square)](https://github.com/madara-alliance/madara/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) - - + + -# 🥷 Madara: Starknet Client +# 🥷 Madara: Starknet client -Madara is a powerful Starknet hybrid client written in Rust. +Madara is a powerfull Starknet hybrid client written in Rust. ## Table of Contents - ⬇️ Installation - [Run from Source](#run-from-source) - - [Run with Docker (Recommended)](#run-with-docker-recommended) + - [Run with Docker](#run-with-docker) - [Run with Docker Compose](#run-with-docker-compose) - - [Run with Installation Script](#run-with-installation-script) - ⚙️ Configuration - - [Priority of Configuration](#priority-of-configuration) - - [Command-Line Options](#command-line-options) - - [Basic Command-Line Options](#basic-command-line-options) - - [Advanced Command-Line Options by Namespace](#advanced-command-line-options-by-namespace) - - [Environment Variables](#environment-variables) - - [Configuration File](#configuration-file) + - [Basic Command-Line Options](#basic-command-line-options) + - [Advanced Command-Line Options](#advanced-command-line-options) - 📸 Snapshots - 🌐 Interactions - [Supported JSON-RPC Methods](#supported-json-rpc-methods) - [Example of Calling a JSON-RPC Method](#example-of-calling-a-json-rpc-method) -- ✔ Supported Features +- Supported Features - 👍 Contribute -- 🤝 Partnerships -- ⚠️ License ## ⬇️ Installation -In this section, we will guide you through the build and run process so that you can run your own Madara client and query the Starknet blockchain as smoothly as possible. - -We have divided this section into three difficulty levels: - -- [**Low-level**](#run-from-source) (from source by building the Rust binary locally) -- [**Mid-level**](#run-with-docker-recommended) (from Docker **recommended** via the available Docker images) -- [**High-level**](#run-with-installation-script) (from a high-level interactive menu) - ### Run from Source -This installation process will help you build the binary directly from the source code locally on your machine. +1. **Install dependencies** -1. **Install Dependencies** + Ensure you have the necessary dependencies: - Ensure you have everything needed to complete this tutorial. + ```sh + sudo apt-get update && sudo apt-get install -y \ + clang \ + protobuf-compiler \ + build-essential + ``` - | Dependency | Version | Installation Command | - | ---------- | ---------- | --------------------------------------------------------------------------------- | - | Rust | rustc 1.78 | `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` | - | Clang | Latest | `sudo apt-get install clang` | - | Scarb | v2.8.2 | `curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh \| sh` | + Install Rust: -2. **Get Code** + ```sh + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s + ``` - Fetch the code from the official [Madara](https://github.com/madara-alliance/madara) repository in the folder of your choice. + Clone the Madara repository: - ```bash + ```sh cd git clone https://github.com/madara-alliance/madara . ``` -3. **Build Program** - - Choose one of the following build modes: - - - **Debug** (fastest build mode, but lower performance, for testing purposes only) - - ```bash - cargo build - ``` - - - **Release** (the recommended build mode) - - ```bash - cargo build --release - ``` - - - **Production** (the recommended build mode for production performance) - - ```bash - cargo build --profile=production - ``` - -4. **Run Madara** - - Start the Madara client with a basic set of arguments, depending on your chosen mode: - - **Full Node** - - ```bash - cargo run --release -- \ - --name Madara \ - --full \ - --base-path /var/lib/madara \ - --network mainnet \ - --l1-endpoint ${ETHEREUM_API_URL} - ``` - - **Sequencer** - - ```bash - cargo run --release -- \ - --name Madara \ - --sequencer \ - --base-path /var/lib/madara \ - --preset test \ - --l1-endpoint ${ETHEREUM_API_URL} - ``` +2. **Run Madara** - **Devnet** + Start the Madara client with synchronization to Starknet mainnet: - ```bash + ```sh cargo run --release -- \ - --name Madara \ - --devnet \ - --base-path /var/lib/madara \ - --preset test - ``` - - > ℹ️ **Note:** We recommend visiting the [Configuration](#configuration) section to customize your node parameters. - - > ℹ️ **Note:** If you don't have an L1 endpoint URL, we recommend heading to the [Verification](#verification) section to get one. - -### Run with Docker (Recommended) - -This is the recommended way to easily install and run Madara as it only requires terminal access and Docker installed. - -1. **Install Docker** - - Ensure Docker is installed on your system. If not, you can install it by following the instructions for your operating system: - - - **MacOS**: - - Download and install Docker Desktop for Mac from [Docker Hub](https://hub.docker.com/editions/community/docker-ce-desktop-mac/). - - - **Linux**: - - Install Docker using the package manager for your distribution. For example, on Ubuntu: - - ```bash - sudo apt-get update - sudo apt-get install \ - ca-certificates \ - curl \ - gnupg \ - lsb-release - - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg - - echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \ - https://download.docker.com/linux/ubuntu \ - $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null - - sudo apt-get update - sudo apt-get install docker-ce docker-ce-cli containerd.io - ``` - - - **Windows**: - - Download and install Docker Desktop for Windows from [Docker Hub](https://hub.docker.com/editions/community/docker-ce-desktop-windows/). - -2. **Run Docker Image** - - Once you have successfully installed Docker, you can now run Madara using the available Docker images. - - ```bash - docker run -d \ - --name Madara \ - -p 9944:9944 \ - -v /var/lib/madara:/var/lib/madara \ - madara:latest \ - --base-path /var/lib/Madara \ + --name madara \ + --base-path ../madara-db \ --network main \ - --l1-endpoint ${ETHEREUM_API_URL} + --l1-endpoint ${ETHEREUM_API_URL} \ ``` - > ℹ️ **Note:** This is a default configuration. For more information on possible configurations, please visit the [Configuration](#configuration) section. +### Run with Docker - > ⚠️ **Warning:** Make sure to change the volume `-v` of your container if you change the `--base-path`. +1 **Run docker image** - If you don't have an L1 endpoint URL, we recommend heading to the [Verification](#verification) section to get one. +To run Madara with Docker, use the following command: -3. **Check Logs** +```sh +docker run -d \ + --name madara \ + -p 9944:9944 \ + -v /var/lib/madara:/var/lib/madara \ + madara:latest \ + --base-path ./madara-db \ + --network main \ + --rpc-external \ + --rpc-cors all \ + --preset mainnet \ + --l1-endpoint +``` - To check the logs of the running Madara service: +Check the logs of the running Madara service: - ```bash - docker logs -f Madara - ``` - - Now you can head up to the [Metrics](#metrics) section to easily deploy a Grafana and Prometheus dashboard. +```sh +docker logs -f madara +``` ### Run with Docker Compose -1. **Prerequisites** - - Ensure you have Docker and Docker Compose installed on your machine. - -2. **Prepare the Environment** +1. **Ensure environment variable** Set the necessary environment variable: - ```bash - export ETHEREUM_API_URL="your-ethereum-api-url" + ```sh + export L1_ENDPOINT="your-ethereum-api-url" ``` Or create a `.env` file in the same directory as your `docker-compose.yml` file: - ``` - ETHEREUM_API_URL=your-ethereum-api-url + ```sh + L1_ENDPOINT=your-ethereum-api-url ``` - > ⚠️ **Note:** When running with `sudo`, environment variables set in the current session might not be carried over. You can pass the variable directly to sudo using the `-E` option to preserve the environment. +2. **Build and Run the Container** - If you don't have an L1 endpoint URL, we recommend heading to the [Verification](#verification) section to get one. - -3. **Build and Run the Container** - - Navigate to the directory with your `docker-compose.yml` file and run the following command: - - ```bash - docker-compose up -d - ``` + Navigate to the directory with your `docker-compose.yml` file and run one of the following commands: - This command will build the Docker image and start the container in detached mode. + - Mainnet: -4. **Check Logs** - - You can view the logs of the running Madara service using the following command: - - ```bash - docker-compose logs -f Madara - ``` - - Now you can head up to the [Metrics](#metrics) section to easily deploy a Grafana and Prometheus dashboard. - -### Run with Installation Script + ```sh + docker-compose --profile mainnet up -d + ``` -This is the highest-level way to install Madara with some custom features. For advanced configuration, we recommend using the source or Docker methods. + - Testnet: -1. **Download Script** + ```sh + docker-compose --profile testnet up -d + ``` - You will need to download and run the installer script using the following command: + Check the logs of the running Madara service: - ```bash - # Installation script command line (to be provided) + ```sh + docker-compose logs -f madara ``` -2. **Follow Instructions** - - Follow the interactive instructions provided by the installation script to set up your Madara client. - - > **Note:** This method is under development. For more advanced configurations, please use the source or Docker methods. - -> ℹ️ **Note:** Now that you know how to launch a Madara client, you might want to set some parameters to customize it. Therefore, you can go to the following [Configuration](#configuration) section. - ## ⚙️ Configuration -Configuring your Madara client properly ensures that it meets your specific needs. Configuration can be done through three main avenues: - -- **Command-line arguments** -- **Environment variables** -- **Configuration files** - -### Priority of Configuration - -> ℹ️ **Note:** Configuration priority is as follows: command-line arguments > environment variables > configuration files. When the same setting is configured in multiple places, the source with the highest priority takes effect. - -### Command-Line Options - -For a comprehensive list of command-line options: - -```bash -cargo run -- --help -``` +Configuring your Madara node properly ensures it meets your specific needs -Below are some essential command-line options and a categorized list of advanced configurations: +### Basic Command-Line Options -#### Basic Command-Line Options - -Here are the recommended options for a quick and simple configuration of your Madara client: +Here are the recommended options for a quick and simple configuration of your Madara full node: - **`--name `**: The human-readable name for this node. It's used as the network node name. -- **`--base-path `**: Set the directory for Madara data (default is `/tmp/madara`). -- **`--network `**: The network type to connect to (`main`, `test`, `integration`, or `devnet`). +- **`--base-path `**: Set the directory for Starknet data (default is `/tmp/madara`). +- **`--network `**: The network type to connect to (`main`, `test`, or `integration`). - **`--l1-endpoint `**: Specify the Layer 1 endpoint the node will verify its state from. - **`--rpc-port `**: Specify the JSON-RPC server TCP port. -- **`--rpc-cors `**: Specify browser origins allowed to access the HTTP & WebSocket RPC servers. +- **`--rpc-cors `**: Specify browser origins allowed to access the HTTP & WS RPC servers. - **`--rpc-external`**: Listen to all RPC interfaces. Default is local. +- **`--snap `**: Start syncing from the closest snapshot available for the desired block (default is highest). -> ℹ️ **Note:** For more information regarding synchronization configuration, please refer to the next section. - -#### Advanced Command-Line Options by Namespace - -Toggle details for each namespace to view additional settings: - -
-Network - -- **`--network `**: The network type to connect to. - - [default: main] - - Possible values: - - - `main`: The main network (mainnet). Alias: mainnet - - `test`: The test network (testnet). Alias: sepolia - - `integration`: The integration network - - `devnet`: A devnet for local testing - -- **`--l1-endpoint `**: Specify the Layer 1 RPC endpoint for state verification. - -- **`--gateway-key `**: Gateway API key to avoid rate limiting (optional). - -- **`--sync-polling-interval `**: Polling interval in seconds. This affects the sync service after catching up with the blockchain tip. - - [default: 4] - -- **`--pending-block-poll-interval `**: Pending block polling interval in seconds. - - [default: 2] - -- **`--no-sync-polling`**: Disable sync polling. Sync service will not import new blocks after catching up with the blockchain tip. - -- **`--n-blocks-to-sync `**: Number of blocks to sync, useful for benchmarking. - -- **`--unsafe-starting-block `**: Start syncing from a specific block. May cause database inconsistency. - -- **`--sync-disabled`**: Disable the sync service. - -- **`--sync-l1-disabled`**: Disable L1 sync service. - -- **`--gas-price-sync-disabled`**: Disable the gas price sync service. - -- **`--gas-price-poll-ms `**: Interval in milliseconds for the gas price sync service to fetch the gas price. - - [default: 10000] - -
- -
-RPC - -- **`--rpc-disabled`**: Disable the RPC server. - -- **`--rpc-external`**: Listen to all network interfaces. - -- **`--rpc-methods `**: RPC methods to expose. - - [default: auto] - - Possible values: - - - `auto`: Expose all methods if RPC is on localhost, otherwise serve only safe methods. - - `safe`: Allow only a safe subset of RPC methods. - - `unsafe`: Expose all RPC methods (even potentially unsafe ones). - -- **`--rpc-rate-limit `**: RPC rate limiting per connection. - -- **`--rpc-rate-limit-whitelisted-ips `**: Disable RPC rate limiting for specific IP addresses or ranges. - -- **`--rpc-rate-limit-trust-proxy-headers`**: Trust proxy headers for disabling rate limiting in reverse proxy setups. - -- **`--rpc-max-request-size `**: Maximum RPC request payload size. - - [default: 15] - -- **`--rpc-max-response-size `**: Maximum RPC response payload size. - - [default: 15] - -- **`--rpc-max-subscriptions-per-connection `**: Maximum concurrent subscriptions per connection. - - [default: 1024] - -- **`--rpc-port `**: The RPC port to listen on. - - [default: 9944] - -- **`--rpc-max-connections `**: Maximum number of RPC server connections at a given time. - - [default: 100] - -- **`--rpc-disable-batch-requests`**: Disable RPC batch requests. +### Advanced Command-Line Options -- **`--rpc-max-batch-request-len `**: Limit the max length for an RPC batch request. - -- **`--rpc-cors `**: Specify browser origins allowed to access the HTTP & WebSocket RPC servers. A comma-separated list of origins, or the special `all` value. - -- **`--rpc-message-buffer-capacity-per-connection `**: Maximum number of messages in memory per connection. - - [default: 64] - -
+Here are more advanced command-line options, organized by namespace, for running and development purposes:
-Database - -- **`--base-path `**: The path where Madara will store the database. - - [default: /tmp/madara] +Network -- **`--backup-dir `**: Directory for backups. - -- **`--backup-every-n-blocks `**: Periodically create a backup, useful for debugging. - -- **`--restore-from-latest-backup`**: Restore the database from the latest backup version. +- **`-n, --network `**: The network type to connect to (default: `integration`). +- **`--port `**: Set the network listening port. +- **`--l1-endpoint `**: Specify the Layer 1 endpoint the node will verify its state from. +- **`--gateway-key `**: Gateway API key to avoid rate limiting (optional). +- **`--sync-polling-interval `**: Polling interval in seconds (default: 2). +- **`--no-sync-polling`**: Stop sync polling. +- **`--n-blocks-to-sync `**: Number of blocks to sync. +- **`--starting-block `**: The block to start syncing from (make sure to set `--disable-root`).
-Block Production - -- **`--block-production-disabled`**: Disable the block production service. - -- **`--devnet`**: Launch in block production mode, with devnet contracts. - -- **`--devnet-contracts `**: Create this number of contracts in the genesis block for the devnet configuration. - - [default: 10] - -- **`--override-devnet-chain-id`**: Launch a devnet with a production chain ID. This is unsafe because your devnet transactions can be replayed on the actual network. - -- **`--authority`**: Enable authority mode; the node will run as a sequencer and try to produce its own blocks. +RPC + +- **`--rpc-external`**: Listen to all RPC interfaces. Note: not all RPC methods are safe to be exposed publicly. + Use an RPC proxy server to filter out dangerous methods. +- **`--rpc-methods `**: RPC methods to expose (`auto`, `safe`, `unsafe`). +- **`--rpc-max-request-size `**: Set the maximum RPC request payload size in megabytes (default: 15). +- **`--rpc-max-response-size `**: Set the maximum RPC response payload size in megabytes (default: 15). +- **`--rpc-max-subscriptions-per-connection `**: Set the maximum concurrent subscriptions per connection (default: 1024). +- **`--rpc-port `**: Specify JSON-RPC server TCP port. +- **`--rpc-max-connections `**: Maximum number of RPC server connections (default: 100). +- **`--rpc-cors `**: Specify browser origins allowed to access the HTTP & WS RPC servers.
-Metrics - -- **`--telemetry-disabled`**: Disable connection to the Madara telemetry server. - -- **`--telemetry-url `**: The URL of the telemetry server with verbosity level. - - [default: "wss://starknodes.com/submit 0"] - -- **`--prometheus-port `**: The port used by the Prometheus RPC service. - - [default: 9615] - -- **`--prometheus-external`**: Listen on all network interfaces for Prometheus. - -- **`--prometheus-disabled`**: Disable the Prometheus service. +Database + +- **`--base-path `**: Specify custom base path (default: `/tmp/madara`). +- **`--snap `**: Start syncing from the closest snapshot available for the desired block. +- **`--tmp`**: Run a temporary node. A temporary directory will be created and deleted at the end of the process. +- **`--cache`**: Enable caching of blocks and transactions to improve response times. +- **`--db-cache `**: Limit the memory the database cache can use. +- **`--trie-cache-size `**: Specify the state cache size (default: 67108864). +- **`--backup-every-n-blocks `**: Specify the number of blocks after which a backup should be created. +- **`--backup-dir `**: Specify the directory where backups should be stored. +- **`--restore-from-latest-backup`**: Restore the database from the latest backup available.
-
-P2P - -**Coming soon** - -
- -### Environment Variables - -Set up your node's environment variables using the `STARKNET_` prefix. For example: - -- `STARKNET_BASE_PATH=/path/to/data` -- `STARKNET_LOG=info` - -These variables allow you to adjust the node's configuration without using command-line arguments. - -### Configuration File - -You can use a JSON, TOML, or YAML file to structure your configuration settings. Specify your configuration file on startup with the `-c` option. Here's a basic example in JSON format: - -```json -{ - "name": "Deoxys", - "base_path": "../deoxys-db", - "network": "mainnet", - "l1_endpoint": "your-ethereum-api-url", - "rpc_port": 9944, - "rpc_cors": "*", - "rpc_external": true, - "prometheus_external": true -} -``` - -> 💡 **Tip:** Review settings carefully for optimal performance and refer to Starknet's official documentation for detailed configuration guidelines. - -Always test your configuration in a non-production environment before rolling it out to a live node to prevent downtime and other potential issues. - -> ℹ️ **Note:** For a custom chain configuration, you can head to the configuration section of chain operators deployments. +> ℹ️ **Info:** Note that not all parameters may be referenced here. +> Please refer to the `cargo run -- --help` command for the full list of parameters. ## 📸 Snapshots -Snapshots are under development and will be available through the `--snap ` parameter. +Snapshots are under developpement and will be available through the `--snap ` parameter. ## 🌐 Interactions -Madara fully supports all the JSON-RPC methods as specified in the Starknet mainnet official [JSON-RPC specs](https://github.com/starkware-libs/starknet-specs). These methods can be categorized into three main types: Read-Only Access Methods, Trace Generation Methods, and Write Methods. +Madara fully supports all the JSON-RPC methods as specified in the Starknet mainnet official [JSON-RPC specs](https://github.com/starkware-libs/starknet-specs). +These methods can be categorized into three main types: Read-Only Access Methods, Trace Generation Methods, and Write Methods. ### Supported JSON-RPC Methods @@ -552,7 +275,7 @@ Here is a list of all the supported methods with their current status: -> ℹ️ **Info:** Madara currently supports the latest [JSON-RPC specs](https://github.com/starkware-libs/starknet-specs) up to version `v0.7.1`. +> ℹ️ **Info:** Madara currently supports latest [JSON-RPC specs](https://github.com/starkware-libs/starknet-specs) specs up to version v0.7.1 ### Example of Calling a JSON-RPC Method @@ -569,9 +292,12 @@ Here is an example of how to call a JSON-RPC method using Madara: } ``` -You can use any JSON-RPC client to interact with the Madara node, such as `curl`, `httpie`, or a custom client in your preferred programming language. For more detailed information and examples on each method, please refer to the [Starknet JSON-RPC specs](https://github.com/starkware-libs/starknet-specs). +You can use any JSON-RPC client to interact with the Madara node, such as `curl`, `httpie`, +or a custom client in your preferred programming language. +For more detailed information and examples on each method, please refer to the [Starknet JSON-RPC specs](https://github.com/starkware-libs/starknet-specs). -> ⚠️ **Warning:** Write methods are forwarded to the Sequencer for execution. Ensure you handle errors appropriately as per the JSON-RPC schema. +> ⚠️ **Warning:** Write methods are forwarded to the Sequencer for execution. +> Ensure you handle errors appropriately as per the JSON-RPC schema. ## ✔ Supported Features @@ -588,14 +314,15 @@ Each feature is designed to ensure optimal performance and seamless integration ## 👍 Contribute -We welcome contributions from the community! Please read our [contributing guidelines](CONTRIBUTING.md) to get started. - ## 🤝 Partnerships -To establish a partnership with the Madara team, or if you have any suggestions or special requests, feel free to reach us on [Telegram](https://t.me/madara_alliance). +To establish a partnership with the Kasar team, or if you have any suggestion or +special request, feel free to reach us on [telegram](https://t.me/madara-alliance). ## ⚠️ License -Copyright (c) 2022-present. +Copyright (c) 2022-present, with the following +[contributors](https://github.com/madara-alliance/madara/graphs/contributors). -Madara is open-source software licensed under the [Apache-2.0 License](https://github.com/madara-alliance/madara/blob/main/LICENSE). \ No newline at end of file +Madara is open-source software licensed under the +[Apache-2.0 License](https://github.com/madara-alliance/madara/blob/main/LICENSE). From 32aac9f86175bdddcb92e7dcedec3eaa6c69d32b Mon Sep 17 00:00:00 2001 From: antiyro <74653697+antiyro@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:45:25 +0100 Subject: [PATCH 19/25] Update Dockerfile Co-authored-by: Apoorv Sadana <95699312+apoorvsadana@users.noreply.github.com> --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b68a62d29..cd1e5ddaf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,8 +16,6 @@ COPY cairo_0 cairo_0 # Installing scarb, new since devnet integration -# Installation steps are taken from the scarb build script -# https://github.com/software-mansion/scarb/blob/main/install.sh ENV SCARB_VERSION="v2.8.2" ENV SHELL /bin/bash RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- ${SCARB_VERSION} From 4677439c37882466260c32a1f4c5f2ada21f1477 Mon Sep 17 00:00:00 2001 From: antiyro Date: Wed, 2 Oct 2024 13:49:32 +0100 Subject: [PATCH 20/25] updated docker build according to new dockerfile --- .github/workflows/docker-build.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 9cc8da280..199a37765 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -12,12 +12,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Log in to GitHub Container Registry uses: docker/login-action@v2 with: @@ -31,7 +25,6 @@ jobs: context: . file: ./Dockerfile push: true - platforms: linux/amd64,linux/arm64 tags: | ghcr.io/${{ github.repository_owner }}/madara:latest ghcr.io/${{ github.repository_owner }}/madara:${{ github.event.release.tag_name }} From d391badf709a416de62c702c910ae0daede1ab53 Mon Sep 17 00:00:00 2001 From: antiyro Date: Wed, 2 Oct 2024 13:52:29 +0100 Subject: [PATCH 21/25] removed unused dependency tini --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index cd1e5ddaf..d8a1a3b7a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,7 @@ RUN cargo build --release FROM debian:bookworm # Install runtime dependencies RUN apt-get -y update && \ - apt-get install -y openssl ca-certificates tini &&\ + apt-get install -y openssl ca-certificates &&\ apt-get autoremove -y; \ apt-get clean; \ rm -rf /var/lib/apt/lists/* From 1a00ff14ac33096816c38ea9d57c9baaed354fa4 Mon Sep 17 00:00:00 2001 From: antiyro Date: Wed, 2 Oct 2024 14:02:57 +0100 Subject: [PATCH 22/25] updated some documentation --- README.md | 379 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 261 insertions(+), 118 deletions(-) diff --git a/README.md b/README.md index cbbbbde65..eb07ecc82 100644 --- a/README.md +++ b/README.md @@ -17,20 +17,18 @@ -# 🥷 Madara: Starknet client +# 🥷 Madara: Starknet Client -Madara is a powerfull Starknet hybrid client written in Rust. +Madara is a powerful Starknet client written in Rust. ## Table of Contents - ⬇️ Installation - [Run from Source](#run-from-source) - [Run with Docker](#run-with-docker) - - [Run with Docker Compose](#run-with-docker-compose) - ⚙️ Configuration - [Basic Command-Line Options](#basic-command-line-options) - [Advanced Command-Line Options](#advanced-command-line-options) -- 📸 Snapshots - 🌐 Interactions - [Supported JSON-RPC Methods](#supported-json-rpc-methods) - [Example of Calling a JSON-RPC Method](#example-of-calling-a-json-rpc-method) @@ -45,173 +43,319 @@ Madara is a powerfull Starknet hybrid client written in Rust. Ensure you have the necessary dependencies: - ```sh - sudo apt-get update && sudo apt-get install -y \ - clang \ - protobuf-compiler \ - build-essential - ``` - - Install Rust: - - ```sh - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s - ``` + | Dependency | Version | Installation | + | ---------- | ---------- | ---------------------------------------------------------------------------------------- | + | Rust | rustc 1.78 | `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` | + | Clang | Latest | `sudo apt-get install clang` | + | Scarb | v2.8.2 | `curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh` | Clone the Madara repository: - ```sh + ```bash cd git clone https://github.com/madara-alliance/madara . ``` -2. **Run Madara** +2. **Build Program** - Start the Madara client with synchronization to Starknet mainnet: + Choose between different build modes: - ```sh - cargo run --release -- \ - --name madara \ - --base-path ../madara-db \ - --network main \ - --l1-endpoint ${ETHEREUM_API_URL} \ - ``` + - **Debug** (fastest build mode, but lower performance, for testing purposes only): -### Run with Docker + ```bash + cargo build + ``` -1 **Run docker image** - -To run Madara with Docker, use the following command: - -```sh -docker run -d \ - --name madara \ - -p 9944:9944 \ - -v /var/lib/madara:/var/lib/madara \ - madara:latest \ - --base-path ./madara-db \ - --network main \ - --rpc-external \ - --rpc-cors all \ - --preset mainnet \ - --l1-endpoint -``` + - **Release** (recommended build mode): -Check the logs of the running Madara service: + ```bash + cargo build --release + ``` -```sh -docker logs -f madara -``` + - **Production** (recommended for production performance): -### Run with Docker Compose + ```bash + cargo build --profile=production + ``` + +3. **Run Madara** -1. **Ensure environment variable** + Start the Madara client with a basic set of arguments depending on your chosen mode: - Set the necessary environment variable: + **Full Node** - ```sh - export L1_ENDPOINT="your-ethereum-api-url" + ```bash + cargo run --release -- \ + --name Madara \ + --full \ + --base-path /var/lib/madara \ + --network mainnet \ + --l1-endpoint ${ETHEREUM_API_URL} ``` - Or create a `.env` file in the same directory as your `docker-compose.yml` file: + **Sequencer** - ```sh - L1_ENDPOINT=your-ethereum-api-url + ```bash + cargo run --release -- \ + --name Madara \ + --sequencer \ + --base-path /var/lib/madara \ + --preset test \ + --l1-endpoint ${ETHEREUM_API_URL} ``` -2. **Build and Run the Container** + **Devnet** - Navigate to the directory with your `docker-compose.yml` file and run one of the following commands: + ```bash + cargo run --release -- \ + --name Madara \ + --devnet \ + --base-path /var/lib/madara \ + --preset test + ``` - - Mainnet: + > ℹ️ **Info:** We recommend you to head to the [Configuration](#configuration) section to customize your node parameters. - ```sh - docker-compose --profile mainnet up -d - ``` + > ℹ️ **Info:** If you don't have an L1 endpoint URL, we recommend you refer to the relevant section to obtain one. - - Testnet: +### Run with Docker - ```sh - docker-compose --profile testnet up -d - ``` +1. **Install Docker** - Check the logs of the running Madara service: + Ensure you have Docker installed on your machine. Once you have Docker installed, you can run Madara using the available Docker images. - ```sh - docker-compose logs -f madara + ```bash + docker run -d \ + --name Madara \ + --full + -p 9944:9944 \ + -v /var/lib/madara:/var/lib/madara \ + madara:latest \ + --base-path /var/lib/madara \ + --network mainnet \ + --l1-endpoint ${ETHEREUM_API_URL} ``` + > ℹ️ **Info:** This is a default configuration for a Full Node on Starknet mainnet. For more information on possible configurations, please visit the [Configuration](#configuration) section. + + > ⚠️ **Warning:** Make sure to change the volume `-v` of your container if you change the `--base-path`. + + > ℹ️ **Info:** If you don't have an L1 endpoint URL, we recommend you refer to the relevant section to obtain one. + +3. **Check Logs** + + ```bash + docker logs -f Madara + ``` + + > ℹ️ **Info:** Now you can head to the [Metrics](#metrics) section to deploy a Grafana and Prometheus dashboard. + ## ⚙️ Configuration -Configuring your Madara node properly ensures it meets your specific needs +### Command-Line Options -### Basic Command-Line Options +For a comprehensive list of command-line options: -Here are the recommended options for a quick and simple configuration of your Madara full node: +```bash +cargo run -- --help +``` + +Below are some essential command-line options and a categorized list of advanced configurations: + +#### Basic Command-Line Options + +Here are the recommended options for a quick and simple configuration of your Madara client: + +**Full Node** - **`--name `**: The human-readable name for this node. It's used as the network node name. + - **`--base-path `**: Set the directory for Starknet data (default is `/tmp/madara`). -- **`--network `**: The network type to connect to (`main`, `test`, or `integration`). + +- **`--full `**: The mode of your Madara client (either `--sequencer`, `--full`, or `devnet`). + - **`--l1-endpoint `**: Specify the Layer 1 endpoint the node will verify its state from. + - **`--rpc-port `**: Specify the JSON-RPC server TCP port. + - **`--rpc-cors `**: Specify browser origins allowed to access the HTTP & WS RPC servers. + - **`--rpc-external`**: Listen to all RPC interfaces. Default is local. -- **`--snap `**: Start syncing from the closest snapshot available for the desired block (default is highest). -### Advanced Command-Line Options +> ℹ️ **Info:** For more information regarding synchronization configuration, please refer to the [Configuration](#configuration) section. -Here are more advanced command-line options, organized by namespace, for running and development purposes: +### Advanced Command-Line Options by Namespace + +Toggle details for each namespace to view additional settings:
-Network +Network -- **`-n, --network `**: The network type to connect to (default: `integration`). -- **`--port `**: Set the network listening port. -- **`--l1-endpoint `**: Specify the Layer 1 endpoint the node will verify its state from. -- **`--gateway-key `**: Gateway API key to avoid rate limiting (optional). -- **`--sync-polling-interval `**: Polling interval in seconds (default: 2). -- **`--no-sync-polling`**: Stop sync polling. -- **`--n-blocks-to-sync `**: Number of blocks to sync. -- **`--starting-block `**: The block to start syncing from (make sure to set `--disable-root`). +- **`-n, --network `**: The network type to connect to. + - [default: mainnet] + + Possible values: + + - `mainnet`: The main network (mainnet). Alias: main + - `testnet`: The test network (testnet). Alias: sepolia + - `integration`: The integration network + - `devnet`: A devnet for local testing + +- **`--l1-endpoint `**: Specify the Layer 1 RPC endpoint for state verification. + +- **`--gateway-key `**: Gateway API key to avoid rate limiting (optional). + +- **`--sync-polling-interval `**: Polling interval in seconds. + - [default: 4] + +- **`--pending-block-poll-interval `**: Pending block polling interval in seconds. + - [default: 2] + +- **`--no-sync-polling`**: Disable sync polling. + +- **`--n-blocks-to-sync `**: Number of blocks to sync, useful for benchmarking. + +- **`--unsafe-starting-block `**: Start syncing from a specific block. May cause database inconsistency. + +- **`--sync-disabled`**: Disable the sync service. + +- **`--sync-l1-disabled`**: Disable L1 sync service. + +- **`--gas-price-sync-disabled`**: Disable the gas price sync service. + +- **`--gas-price-poll-ms `**: Interval in milliseconds for the gas price sync service to fetch the gas price. + - [default: 10000]
-RPC - -- **`--rpc-external`**: Listen to all RPC interfaces. Note: not all RPC methods are safe to be exposed publicly. - Use an RPC proxy server to filter out dangerous methods. -- **`--rpc-methods `**: RPC methods to expose (`auto`, `safe`, `unsafe`). -- **`--rpc-max-request-size `**: Set the maximum RPC request payload size in megabytes (default: 15). -- **`--rpc-max-response-size `**: Set the maximum RPC response payload size in megabytes (default: 15). -- **`--rpc-max-subscriptions-per-connection `**: Set the maximum concurrent subscriptions per connection (default: 1024). -- **`--rpc-port `**: Specify JSON-RPC server TCP port. -- **`--rpc-max-connections `**: Maximum number of RPC server connections (default: 100). -- **`--rpc-cors `**: Specify browser origins allowed to access the HTTP & WS RPC servers. +RPC + +- **`--rpc-disabled`**: Disable the RPC server. + +- **`--rpc-external`**: Listen to all network interfaces. + +- **`--rpc-methods `**: RPC methods to expose. + - [default: auto] + + Possible values: + + - `auto`: Expose all methods if RPC is on localhost, otherwise serve only safe methods. + - `safe`: Allow only a safe subset of RPC methods. + - `unsafe`: Expose all RPC methods (even potentially unsafe ones). + +- **`--rpc-rate-limit `**: RPC rate limiting per connection. + +- **`--rpc-rate-limit-whitelisted-ips `**: Disable RPC rate limiting for specific IP addresses or ranges. + +- **`--rpc-rate-limit-trust-proxy-headers`**: Trust proxy headers for disabling rate limiting in reverse proxy setups. + +- **`--rpc-max-request-size `**: Maximum RPC request payload size for both HTTP and WebSockets. + - [default: 15] + +- **`--rpc-max-response-size `**: Maximum RPC response payload size for both HTTP and WebSockets. + - [default: 15] + +- **`--rpc-max-subscriptions-per-connection `**: Maximum concurrent subscriptions per connection. + - [default: 1024] + +- **`--rpc-port `**: The RPC port to listen on. + - [default: 9944] + +- **`--rpc-max-connections `**: Maximum number of RPC server connections at a given time. + - [default: 100] + +- **`--rpc-disable-batch-requests`**: Disable RPC batch requests. + +- **`--rpc-max-batch-request-len `**: Limit the max length for an RPC batch request. + +- **`--rpc-cors `**: Specify browser origins allowed to access the HTTP & WebSocket RPC servers. + +- **`--rpc-message-buffer-capacity-per-connection `**: Maximum number of messages in memory per connection. + - [default: 64]
-Database - -- **`--base-path `**: Specify custom base path (default: `/tmp/madara`). -- **`--snap `**: Start syncing from the closest snapshot available for the desired block. -- **`--tmp`**: Run a temporary node. A temporary directory will be created and deleted at the end of the process. -- **`--cache`**: Enable caching of blocks and transactions to improve response times. -- **`--db-cache `**: Limit the memory the database cache can use. -- **`--trie-cache-size `**: Specify the state cache size (default: 67108864). -- **`--backup-every-n-blocks `**: Specify the number of blocks after which a backup should be created. -- **`--backup-dir `**: Specify the directory where backups should be stored. -- **`--restore-from-latest-backup`**: Restore the database from the latest backup available. +Database + +- **`--base-path `**: The path where Madara will store the database. + - [default: /tmp/madara] + +- **`--backup-dir `**: Directory for backups. + +- **`--backup-every-n-blocks `**: Periodically create a backup. + +- **`--restore-from-latest-backup`**: Restore the database from the latest backup version.
-> ℹ️ **Info:** Note that not all parameters may be referenced here. -> Please refer to the `cargo run -- --help` command for the full list of parameters. +
+Block Production + +- **`--block-production-disabled`**: Disable the block production service. + +- **`--devnet`**: Launch in block production mode, with devnet contracts. -## 📸 Snapshots +- **`--devnet-contracts `**: Create this number of contracts in the genesis block for the devnet configuration. + - [default: 10] -Snapshots are under developpement and will be available through the `--snap ` parameter. +- **`--override-devnet-chain-id`**: Launch a devnet with a production chain ID. + +- **`--authority`**: Enable authority mode; the node will run as a sequencer and try to produce its own blocks. + +
+ +
+Metrics + +- **`--telemetry-disabled`**: Disable connection to the Madara telemetry server. + +- **`--telemetry-url `**: The URL of the telemetry server with verbosity level. + - [default: "wss://starknodes.com/submit 0"] + +- **`--prometheus-port `**: The port used by the Prometheus RPC service. + - [default: 9615] + +- **`--prometheus-external`**: Listen on all network interfaces for Prometheus. + +- **`--prometheus-disabled`**: Disable the Prometheus service. + +
+ +> ℹ️ **Info:** Note that not all parameters may be referenced here. Please refer to the `cargo run -- --help` command for the full list of parameters. + +### Environment Variables + +Set up your node's environment variables using the `STARKNET_` prefix. For example: + +- `STARKNET_BASE_PATH=/path/to/data` +- `STARKNET_LOG=info` + +These variables allow you to adjust the node's configuration without using command-line arguments. + +### Configuration File + +You can use a JSON, TOML, or YAML file to structure your configuration settings. Specify your configuration file on startup with the `-c` option. Here's a basic example in JSON format: + +```json +{ + "name": "Deoxys", + "base_path": "../deoxys-db", + "network": "mainnet", + "l1_endpoint": "l1_key_url", + "rpc_port": 9944, + "rpc_cors": "*", + "rpc_external": true, + "prometheus_external": true +} +``` + +> 💡 **Tip:** Review settings carefully for optimal performance and refer to Starknet's official documentation for detailed configuration guidelines. + +Always test your configuration in a non-production environment before rolling it out to a live node to prevent downtime and other potential issues. + +> ℹ️ **Info:** For a custom chain configuration, you can refer to the configuration section of chain operator deployments. ## 🌐 Interactions @@ -275,7 +419,7 @@ Here is a list of all the supported methods with their current status: -> ℹ️ **Info:** Madara currently supports latest [JSON-RPC specs](https://github.com/starkware-libs/starknet-specs) specs up to version v0.7.1 +> ℹ️ **Info:** Madara currently supports the latest [JSON-RPC specs](https://github.com/starkware-libs/starknet-specs) up to version v0.7.1. ### Example of Calling a JSON-RPC Method @@ -314,15 +458,14 @@ Each feature is designed to ensure optimal performance and seamless integration ## 👍 Contribute +For guidelines on how to contribute to Madara, please see the [Contribution Guidelines](https://github.com/madara-alliance/madara/blob/main/CONTRIBUTING.md). + ## 🤝 Partnerships -To establish a partnership with the Kasar team, or if you have any suggestion or -special request, feel free to reach us on [telegram](https://t.me/madara-alliance). +To establish a partnership with the Madara team, or if you have any suggestions or +special requests, feel free to reach us on [Telegram](https://t.me/madara-alliance). ## ⚠️ License -Copyright (c) 2022-present, with the following -[contributors](https://github.com/madara-alliance/madara/graphs/contributors). - Madara is open-source software licensed under the -[Apache-2.0 License](https://github.com/madara-alliance/madara/blob/main/LICENSE). +[Apache-2.0 License](https://github.com/madara-alliance/madara/blob/main/LICENSE). \ No newline at end of file From d6832bd7cf58b0bda562b7b30b7320d388a6a362 Mon Sep 17 00:00:00 2001 From: antiyro Date: Wed, 2 Oct 2024 14:06:17 +0100 Subject: [PATCH 23/25] removed docker warnings --- Dockerfile | 6 +++--- README.md | 27 ++++++++++++++++++++------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index d8a1a3b7a..79ddb9ebf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Build the application -FROM rust:1.78 as builder +FROM rust:1.78 AS builder # Install build dependencies RUN apt-get -y update && \ apt-get install -y clang && \ @@ -17,7 +17,7 @@ COPY cairo_0 cairo_0 # Installing scarb, new since devnet integration ENV SCARB_VERSION="v2.8.2" -ENV SHELL /bin/bash +ENV SHELL="/bin/bash" RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- ${SCARB_VERSION} ENV PATH="/root/.local/bin:${PATH}" RUN scarb --version @@ -45,4 +45,4 @@ WORKDIR /usr/local/bin COPY --from=builder /usr/src/madara/target/release/madara . # Set the entrypoint -ENTRYPOINT ["./madara"] \ No newline at end of file +ENTRYPOINT ["./madara"] diff --git a/README.md b/README.md index eb07ecc82..6363a0861 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,11 @@ Madara is a powerful Starknet client written in Rust. Ensure you have the necessary dependencies: - | Dependency | Version | Installation | - | ---------- | ---------- | ---------------------------------------------------------------------------------------- | - | Rust | rustc 1.78 | `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` | - | Clang | Latest | `sudo apt-get install clang` | - | Scarb | v2.8.2 | `curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh` | + | Dependency | Version | Installation | + | ---------- | ---------- | --------------------------------------------------------------------------------- | --- | + | Rust | rustc 1.78 | `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` | + | Clang | Latest | `sudo apt-get install clang` | + | Scarb | v2.8.2 | `curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh` | Clone the Madara repository: @@ -142,7 +142,7 @@ Madara is a powerful Starknet client written in Rust. > ℹ️ **Info:** If you don't have an L1 endpoint URL, we recommend you refer to the relevant section to obtain one. -3. **Check Logs** +2. **Check Logs** ```bash docker logs -f Madara @@ -192,6 +192,7 @@ Toggle details for each namespace to view additional settings: Network - **`-n, --network `**: The network type to connect to. + - [default: mainnet] Possible values: @@ -206,9 +207,11 @@ Toggle details for each namespace to view additional settings: - **`--gateway-key `**: Gateway API key to avoid rate limiting (optional). - **`--sync-polling-interval `**: Polling interval in seconds. + - [default: 4] - **`--pending-block-poll-interval `**: Pending block polling interval in seconds. + - [default: 2] - **`--no-sync-polling`**: Disable sync polling. @@ -236,6 +239,7 @@ Toggle details for each namespace to view additional settings: - **`--rpc-external`**: Listen to all network interfaces. - **`--rpc-methods `**: RPC methods to expose. + - [default: auto] Possible values: @@ -251,18 +255,23 @@ Toggle details for each namespace to view additional settings: - **`--rpc-rate-limit-trust-proxy-headers`**: Trust proxy headers for disabling rate limiting in reverse proxy setups. - **`--rpc-max-request-size `**: Maximum RPC request payload size for both HTTP and WebSockets. + - [default: 15] - **`--rpc-max-response-size `**: Maximum RPC response payload size for both HTTP and WebSockets. + - [default: 15] - **`--rpc-max-subscriptions-per-connection `**: Maximum concurrent subscriptions per connection. + - [default: 1024] - **`--rpc-port `**: The RPC port to listen on. + - [default: 9944] - **`--rpc-max-connections `**: Maximum number of RPC server connections at a given time. + - [default: 100] - **`--rpc-disable-batch-requests`**: Disable RPC batch requests. @@ -280,6 +289,7 @@ Toggle details for each namespace to view additional settings: Database - **`--base-path `**: The path where Madara will store the database. + - [default: /tmp/madara] - **`--backup-dir `**: Directory for backups. @@ -298,6 +308,7 @@ Toggle details for each namespace to view additional settings: - **`--devnet`**: Launch in block production mode, with devnet contracts. - **`--devnet-contracts `**: Create this number of contracts in the genesis block for the devnet configuration. + - [default: 10] - **`--override-devnet-chain-id`**: Launch a devnet with a production chain ID. @@ -312,9 +323,11 @@ Toggle details for each namespace to view additional settings: - **`--telemetry-disabled`**: Disable connection to the Madara telemetry server. - **`--telemetry-url `**: The URL of the telemetry server with verbosity level. + - [default: "wss://starknodes.com/submit 0"] - **`--prometheus-port `**: The port used by the Prometheus RPC service. + - [default: 9615] - **`--prometheus-external`**: Listen on all network interfaces for Prometheus. @@ -468,4 +481,4 @@ special requests, feel free to reach us on [Telegram](https://t.me/madara-allian ## ⚠️ License Madara is open-source software licensed under the -[Apache-2.0 License](https://github.com/madara-alliance/madara/blob/main/LICENSE). \ No newline at end of file +[Apache-2.0 License](https://github.com/madara-alliance/madara/blob/main/LICENSE). From 7d9e608d3dfd13c2cd7fbd01908de3244c49c662 Mon Sep 17 00:00:00 2001 From: antiyro Date: Wed, 2 Oct 2024 14:29:46 +0100 Subject: [PATCH 24/25] prettified markdown --- README.md | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6363a0861..9876fddf3 100644 --- a/README.md +++ b/README.md @@ -114,9 +114,10 @@ Madara is a powerful Starknet client written in Rust. --preset test ``` - > ℹ️ **Info:** We recommend you to head to the [Configuration](#configuration) section to customize your node parameters. - - > ℹ️ **Info:** If you don't have an L1 endpoint URL, we recommend you refer to the relevant section to obtain one. + > ℹ️ **Info:** We recommend you to head to the [Configuration](https://docs.madara.build/fundamentals/configuration) + section to customize your node parameters. + > ℹ️ **Info:** If you don't have an L1 endpoint URL, we recommend you refer to the relevant + section to obtain one. ### Run with Docker @@ -136,10 +137,10 @@ Madara is a powerful Starknet client written in Rust. --l1-endpoint ${ETHEREUM_API_URL} ``` - > ℹ️ **Info:** This is a default configuration for a Full Node on Starknet mainnet. For more information on possible configurations, please visit the [Configuration](#configuration) section. - + > ℹ️ **Info:** This is a default configuration for a Full Node on Starknet mainnet. + For more information on possible configurations, please visit the + [Configuration](https://docs.madara.build/fundamentals/configuration) section. > ⚠️ **Warning:** Make sure to change the volume `-v` of your container if you change the `--base-path`. - > ℹ️ **Info:** If you don't have an L1 endpoint URL, we recommend you refer to the relevant section to obtain one. 2. **Check Logs** @@ -148,7 +149,8 @@ Madara is a powerful Starknet client written in Rust. docker logs -f Madara ``` - > ℹ️ **Info:** Now you can head to the [Metrics](#metrics) section to deploy a Grafana and Prometheus dashboard. + > ℹ️ **Info:** Now you can head to the [Metrics](https://docs.madara.build/monitoring/grafana) + section to deploy a Grafana and Prometheus dashboard. ## ⚙️ Configuration @@ -166,13 +168,11 @@ Below are some essential command-line options and a categorized list of advanced Here are the recommended options for a quick and simple configuration of your Madara client: -**Full Node** - - **`--name `**: The human-readable name for this node. It's used as the network node name. - **`--base-path `**: Set the directory for Starknet data (default is `/tmp/madara`). -- **`--full `**: The mode of your Madara client (either `--sequencer`, `--full`, or `devnet`). +- **`--full`**: The mode of your Madara client (either `--sequencer`, `--full`, or `devnet`). - **`--l1-endpoint `**: Specify the Layer 1 endpoint the node will verify its state from. @@ -182,9 +182,10 @@ Here are the recommended options for a quick and simple configuration of your Ma - **`--rpc-external`**: Listen to all RPC interfaces. Default is local. -> ℹ️ **Info:** For more information regarding synchronization configuration, please refer to the [Configuration](#configuration) section. +> ℹ️ **Info:** For more information regarding synchronization configuration, please refer to the +[Configuration](https://docs.madara.build/fundamentals/configuration) section. -### Advanced Command-Line Options by Namespace +### Advanced Command-Line Options Toggle details for each namespace to view additional settings: @@ -336,7 +337,8 @@ Toggle details for each namespace to view additional settings: -> ℹ️ **Info:** Note that not all parameters may be referenced here. Please refer to the `cargo run -- --help` command for the full list of parameters. +> ℹ️ **Info:** Note that not all parameters may be referenced here. +Please refer to the `cargo run -- --help` command for the full list of parameters. ### Environment Variables @@ -349,7 +351,8 @@ These variables allow you to adjust the node's configuration without using comma ### Configuration File -You can use a JSON, TOML, or YAML file to structure your configuration settings. Specify your configuration file on startup with the `-c` option. Here's a basic example in JSON format: +You can use a JSON, TOML, or YAML file to structure your configuration settings. +Specify your configuration file on startup with the `-c` option. Here's a basic example in JSON format: ```json { @@ -364,9 +367,11 @@ You can use a JSON, TOML, or YAML file to structure your configuration settings. } ``` -> 💡 **Tip:** Review settings carefully for optimal performance and refer to Starknet's official documentation for detailed configuration guidelines. +> 💡 **Tip:** Review settings carefully for optimal performance and refer to Starknet's +official documentation for detailed configuration guidelines. -Always test your configuration in a non-production environment before rolling it out to a live node to prevent downtime and other potential issues. +Always test your configuration in a non-production environment before rolling it out to a live node to prevent downtime +and other potential issues. > ℹ️ **Info:** For a custom chain configuration, you can refer to the configuration section of chain operator deployments. From fa645d45436cde35139e78ba2db900e3d3c2efba Mon Sep 17 00:00:00 2001 From: antiyro Date: Wed, 2 Oct 2024 14:31:36 +0100 Subject: [PATCH 25/25] runned prettier on md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9876fddf3..22ee5208d 100644 --- a/README.md +++ b/README.md @@ -115,9 +115,9 @@ Madara is a powerful Starknet client written in Rust. ``` > ℹ️ **Info:** We recommend you to head to the [Configuration](https://docs.madara.build/fundamentals/configuration) - section to customize your node parameters. + > section to customize your node parameters. > ℹ️ **Info:** If you don't have an L1 endpoint URL, we recommend you refer to the relevant - section to obtain one. + > section to obtain one. ### Run with Docker @@ -138,8 +138,8 @@ Madara is a powerful Starknet client written in Rust. ``` > ℹ️ **Info:** This is a default configuration for a Full Node on Starknet mainnet. - For more information on possible configurations, please visit the - [Configuration](https://docs.madara.build/fundamentals/configuration) section. + > For more information on possible configurations, please visit the + > [Configuration](https://docs.madara.build/fundamentals/configuration) section. > ⚠️ **Warning:** Make sure to change the volume `-v` of your container if you change the `--base-path`. > ℹ️ **Info:** If you don't have an L1 endpoint URL, we recommend you refer to the relevant section to obtain one. @@ -150,7 +150,7 @@ Madara is a powerful Starknet client written in Rust. ``` > ℹ️ **Info:** Now you can head to the [Metrics](https://docs.madara.build/monitoring/grafana) - section to deploy a Grafana and Prometheus dashboard. + > section to deploy a Grafana and Prometheus dashboard. ## ⚙️ Configuration @@ -183,7 +183,7 @@ Here are the recommended options for a quick and simple configuration of your Ma - **`--rpc-external`**: Listen to all RPC interfaces. Default is local. > ℹ️ **Info:** For more information regarding synchronization configuration, please refer to the -[Configuration](https://docs.madara.build/fundamentals/configuration) section. +> [Configuration](https://docs.madara.build/fundamentals/configuration) section. ### Advanced Command-Line Options @@ -338,7 +338,7 @@ Toggle details for each namespace to view additional settings: > ℹ️ **Info:** Note that not all parameters may be referenced here. -Please refer to the `cargo run -- --help` command for the full list of parameters. +> Please refer to the `cargo run -- --help` command for the full list of parameters. ### Environment Variables @@ -368,7 +368,7 @@ Specify your configuration file on startup with the `-c` option. Here's a basic ``` > 💡 **Tip:** Review settings carefully for optimal performance and refer to Starknet's -official documentation for detailed configuration guidelines. +> official documentation for detailed configuration guidelines. Always test your configuration in a non-production environment before rolling it out to a live node to prevent downtime and other potential issues.