From ab8faf8250bbc12838d95a2f693cafc0a6b23907 Mon Sep 17 00:00:00 2001 From: Slava <20563034+veaceslavdoina@users.noreply.github.com> Date: Thu, 3 Jul 2025 21:50:44 +0300 Subject: [PATCH] feat: add devnet scripts (#34) * feat: add a way to get marketplace address from url * feat: add devnet scripts --- README.md | 25 ++++++++++++++++++++++ devnet/generate.sh | 16 ++++++++++++++ devnet/index.html | 52 ++++++++++++++++++++++++++++++++++++++++++++++ devnet/install.sh | 17 +++++++++++++++ devnet/run.sh | 20 ++++++++++++++++++ run.sh | 29 +++++++++++++++++++++++--- 6 files changed, 156 insertions(+), 3 deletions(-) create mode 100755 devnet/generate.sh create mode 100644 devnet/index.html create mode 100755 devnet/install.sh create mode 100755 devnet/run.sh diff --git a/README.md b/README.md index 9007e92..6782c82 100644 --- a/README.md +++ b/README.md @@ -78,3 +78,28 @@ curl -s https://get.codex.storage/testnet/generate.sh | bash # Run Codex curl -s https://get.codex.storage/testnet/run.sh | bash ``` + + +## Join Codex Devnet + +### Linux, macOS and Windows (msys2) + +```shell +# Create a directory +mkdir codex-devnet && cd codex-devnet +``` + +```shell +# Install Codex +curl -s https://get.codex.storage/devnet/install.sh | bash +``` + +```shell +# Generate key +curl -s https://get.codex.storage/devnet/generate.sh | bash +``` + +```shell +# Run Codex +curl -s https://get.codex.storage/devnet/run.sh | bash +``` diff --git a/devnet/generate.sh b/devnet/generate.sh new file mode 100755 index 0000000..0e8f9ae --- /dev/null +++ b/devnet/generate.sh @@ -0,0 +1,16 @@ +# Codex Devnet - Generate + +# Variables +set -a +BASE_SCRIPT="https://get.codex.storage/generate.sh" +SCRIPT_URL="https://get.codex.storage/devnet/generate.sh" +set +a + +# Help +if [[ $1 == *"help"* ]] ; then + curl -s "${BASE_SCRIPT}" | bash -s -- help + exit 0 +fi + +# Generate +curl -s "${BASE_SCRIPT}" | bash diff --git a/devnet/index.html b/devnet/index.html new file mode 100644 index 0000000..aaff3ba --- /dev/null +++ b/devnet/index.html @@ -0,0 +1,52 @@ + + + + Join Codex Devnet + + + + +

+ Join Codex Devnet - Linux, macOS and Windows (msys2) +

+ +

+ + # Create a directory + +
+ mkdir codex-devnet && cd codex-devnet +

+ +

+ + # Install Codex + +
+ curl -s https://get.codex.storage/devnet/install.sh | bash +

+ +

+ + # Generate key + +
+ curl -s https://get.codex.storage/devnet/generate.sh | bash +

+ +

+ + # Run Codex + +
+ curl -s https://get.codex.storage/devnet/run.sh | bash +

+ + diff --git a/devnet/install.sh b/devnet/install.sh new file mode 100755 index 0000000..b423892 --- /dev/null +++ b/devnet/install.sh @@ -0,0 +1,17 @@ +# Codex Devnet - Install + +# Variables +set -a +BASE_SCRIPT="https://get.codex.storage/install.sh" +SCRIPT_URL="https://get.codex.storage/devnet/install.sh" +INSTALL_DIR="${INSTALL_DIR:-.}" +set +a + +# Help +if [[ $1 == *"help"* ]] ; then + curl -s "${BASE_SCRIPT}" | bash -s -- help + exit 0 +fi + +# Install +curl -s "${BASE_SCRIPT}" | bash diff --git a/devnet/run.sh b/devnet/run.sh new file mode 100755 index 0000000..37321d3 --- /dev/null +++ b/devnet/run.sh @@ -0,0 +1,20 @@ +# Codex Devnet - Run + +# Variables +set -a +BASE_SCRIPT="https://get.codex.storage/run.sh" +SCRIPT_URL="https://get.codex.storage/devnet/run.sh" +CODEX_BINARY="${CODEX_BINARY:-./codex}" +BOOTSTRAP_NODE_FROM_URL="https://spr.codex.storage/devnet" +MARKETPLACE_ADDRESS_FROM_URL="https://marketplace.codex.storage/codex-devnet/latest" +CODEX_ETH_PROVIDER="${CODEX_ETH_PROVIDER:-wss://public.sepolia.rpc.status.network/ws}" +set +a + +# Help +if [[ $1 == *"help"* ]] ; then + curl -s "${BASE_SCRIPT}" | bash -s -- help + exit 0 +fi + +# Run +curl -s "${BASE_SCRIPT}" | bash -s -- $@ diff --git a/run.sh b/run.sh index c347866..03fd60f 100755 --- a/run.sh +++ b/run.sh @@ -28,7 +28,7 @@ export CODEX_ETH_PRIVATE_KEY="${CODEX_ETH_PRIVATE_KEY:-eth.key}" export CODEX_ETH_PROVIDER="${CODEX_ETH_PROVIDER:-https://rpc.testnet.codex.storage}" [[ -n "${CODEX_MARKETPLACE_ADDRESS}" ]] && export CODEX_MARKETPLACE_ADDRESS="${CODEX_MARKETPLACE_ADDRESS}" -# Default bootstrap nodes +# Bootstrap node from URL BOOTSTRAP_NODE_FROM_URL="${BOOTSTRAP_NODE_FROM_URL:-https://spr.codex.storage/testnet}" WAIT=60 SECONDS=0 @@ -49,6 +49,29 @@ while (( SECONDS < WAIT )); do fi done +# Marketplace address from URL +if [[ ( -z "${CODEX_MARKETPLACE_ADDRESS}" || "$@" != *"--marketplace-address"* ) && -n "${MARKETPLACE_ADDRESS_FROM_URL}" ]]; then + + echo "args - $@" + echo "CODEX_MARKETPLACE_ADDRESS - $CODEX_MARKETPLACE_ADDRESS" + echo "MARKETPLACE_ADDRESS_FROM_URL - $MARKETPLACE_ADDRESS_FROM_URL" + WAIT=60 + SECONDS=0 + SLEEP=1 + while (( SECONDS < WAIT )); do + set +e + MARKETPLACE_ADDRESS=($(curl -s -f -m 5 "${MARKETPLACE_ADDRESS_FROM_URL}")) + set -e + if [[ $? -eq 0 && -n "${MARKETPLACE_ADDRESS}" ]]; then + export CODEX_MARKETPLACE_ADDRESS="${MARKETPLACE_ADDRESS}" + break + else + echo "Can't get Marketplace address from ${MARKETPLACE_ADDRESS_FROM_URL} - Retry in $SLEEP seconds / $((WAIT - SECONDS))" + sleep $SLEEP + fi + done +fi + # Help if [[ $1 == *"help"* ]] ; then COMMAND="curl -s ${SCRIPT_URL}" @@ -168,5 +191,5 @@ message="Running Codex" show_progress "${message}" && show_pass "${message}\n" ${CODEX_BINARY} \ - $@ \ - persistence + persistence \ + $@