From e2924a53a211c021def557456e85e3d0e886d6b5 Mon Sep 17 00:00:00 2001 From: Nhu Viet Nguyen Date: Tue, 10 Dec 2024 18:39:30 +0100 Subject: [PATCH 1/2] chore/make: add celestia-node make file for arabica testnet --- Makefile | 3 ++ celestia-node.mk | 101 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 celestia-node.mk diff --git a/Makefile b/Makefile index def65cc137..8c1d06f0a8 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,9 @@ ifeq ($(SHORT),true) else INTEGRATION_RUN_LENGTH = endif + +include celestia-node.mk + ## help: Get more info on make commands. help: Makefile @echo " Choose a command run in "$(PROJECTNAME)":" diff --git a/celestia-node.mk b/celestia-node.mk new file mode 100644 index 0000000000..2729acc13b --- /dev/null +++ b/celestia-node.mk @@ -0,0 +1,101 @@ +# Celestia Node Management Rules +# These rules can be included in the main Makefile + +.PHONY: install get-address check-and-fund reset-node light-up node-help + +node-help: + @echo "Celestia Light Node Management Commands:" + @echo "" + @echo "Available targets:" + @echo " node-install - Install celestia node and cel-key binaries" + @echo " get-address - Display the wallet address from cel-key" + @echo " check-and-fund - Check wallet balance and request funds if needed" + @echo " reset-node - Reset node state and update config with latest block height" + @echo " light-arabica-up - Start the Celestia light node" + @echo "" + @echo "Special usage:" + @echo " light-arabica-up options:" + @echo " COMMAND=again - Reset the node before starting" + @echo " CORE_IP= - Use custom IP instead of default validator" + @echo "" + @echo "Examples:" + @echo " make light-arabica-up" + @echo " make light-arabica-up COMMAND=again" + @echo " make light-arabica-up CORE_IP=custom.ip.address" + @echo " make light-arabica-up COMMAND=again CORE_IP=custom.ip.address" + +# Install celestia node and cel-key binaries +node-install: + make install + make cel-key + +# Get wallet address from cel-key +get-address: + @address=$$(cel-key list --node.type light --p2p.network arabica | grep "address: " | cut -d' ' -f3); \ + echo $$address + +# Check balance and fund if needed +check-and-fund: + @address=$$(cel-key list --node.type light --p2p.network arabica | grep "address: " | cut -d' ' -f3); \ + echo "Checking balance for address: $$address"; \ + balance=$$(curl -s "https://api.celestia-arabica-11.com/cosmos/bank/v1beta1/balances/$$address" | jq -r '.balances[] | select(.denom == "utia") | .amount // "0"'); \ + if [[ $$balance =~ ^[0-9]+$$ ]]; then \ + balance_tia=$$(echo "scale=6; $$balance/1000000" | bc); \ + echo "Current balance: $$balance_tia TIA"; \ + else \ + balance_tia=0; \ + fi; \ + if (( $$(echo "$$balance_tia < 1" | bc -l) )); then \ + echo "Balance too low. Requesting funds from faucet..."; \ + curl -X POST 'https://faucet.celestia-arabica-11.com/api/v1/faucet/give_me' \ + -H 'Content-Type: application/json' \ + -d '{"address": "'$$address'", "chainId": "arabica-11" }'; \ + echo "Waiting 10 seconds for transaction to process..."; \ + sleep 10; \ + fi + +# Reset node state and update config +reset-node: + @echo "Resetting node state..." + @celestia light unsafe-reset-store --p2p.network arabica + @echo "Getting latest block height and hash..." + @block_response=$$(curl -s https://rpc.celestia-arabica-11.com/block); \ + latest_block=$$(echo $$block_response | jq -r '.result.block.header.height'); \ + latest_hash=$$(echo $$block_response | jq -r '.result.block_id.hash'); \ + echo "Latest block height: $$latest_block"; \ + echo "Latest block hash: $$latest_hash"; \ + config_file="$$HOME/.celestia-light-arabica-11/config.toml"; \ + echo "Updating config.toml..."; \ + sed -i.bak -e "s/\(TrustedHash[[:space:]]*=[[:space:]]*\).*/\1\"$$latest_hash\"/" \ + -e "s/\(SampleFrom[[:space:]]*=[[:space:]]*\).*/\1$$latest_block/" \ + "$$config_file"; \ + echo "Configuration updated successfully" + +# Start the Celestia light node +# Usage: make light-arabica-up [COMMAND=again] [CORE_IP=custom_ip] +light-arabica-up: + @config_file="$$HOME/.celestia-light-arabica-11/config.toml"; \ + if [ "$(COMMAND)" = "again" ]; then \ + $(MAKE) reset-node; \ + fi; \ + if [ -e "$$config_file" ]; then \ + echo "Using config file: $$config_file"; \ + else \ + celestia light init --p2p.network arabica; \ + $(MAKE) reset-node; \ + $(MAKE) check-and-fund; \ + fi; \ + $(MAKE) check-and-fund; \ + if [ -n "$(CORE_IP)" ]; then \ + celestia light start \ + --core.ip $(CORE_IP) \ + --rpc.skip-auth \ + --rpc.addr 0.0.0.0 \ + --p2p.network arabica; \ + else \ + celestia light start \ + --core.ip validator-1.celestia-arabica-11.com \ + --rpc.skip-auth \ + --rpc.addr 0.0.0.0 \ + --p2p.network arabica; \ + fi From c9443ed5a91379f10514482080544d7c9e9a9173 Mon Sep 17 00:00:00 2001 From: Nhu Viet Nguyen Date: Tue, 10 Dec 2024 21:30:15 +0100 Subject: [PATCH 2/2] doc: add fast tutorial for readme.md --- README.md | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d4667e6fb0..6db1959599 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Continue reading [here](https://blog.celestia.org/celestia-mvp-release-data-avai - [API docs](#api-docs) - [Node types](#node-types) - [Run a node](#run-a-node) + - [Quick Start with Light Node on arabica](#quick-start-with-light-node-on-arabica) - [Environment variables](#environment-variables) - [Package-specific documentation](#package-specific-documentation) - [Code of Conduct](#code-of-conduct) @@ -31,7 +32,7 @@ Continue reading [here](https://blog.celestia.org/celestia-mvp-release-data-avai ## Minimum requirements | Requirement | Notes | -| ----------- |----------------| +| ----------- | -------------- | | Go version | 1.23 or higher | ## System Requirements @@ -79,6 +80,40 @@ celestia start Please refer to [this guide](https://docs.celestia.org/nodes/celestia-node/) for more information on running a node. +### Quick Start with Light Node on arabica + +View available commands and their usage: + +```sh +make node-help +``` + +Install celestia node and cel-key binaries: + +```sh +make node-install +``` + +Start a light node with automated setup: + +```sh +make light-arabica-up +``` + +This command: + +- Automatically checks wallet balance +- Requests funds from faucet if needed +- Sets node height to latest-1 for quick startup +- Initializes the node if running for the first time + +Options: + +```sh +make light-arabica-up COMMAND=again # Reset node state to latest height +make light-arabica-up CORE_IP= # Use custom core IP +``` + ## Environment variables | Variable | Explanation | Default value | Required |