diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..bf4af9e Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index b291a07..4f646af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ -graph-node-alternate/ +# graph-node-alternate/ networks/testing-alt -.idea/ \ No newline at end of file +.idea/ +kachra/* \ No newline at end of file diff --git a/base/persistencecore/genesis.yaml b/base/persistencecore/genesis.yaml index dfe724f..a5d0a5b 100644 --- a/base/persistencecore/genesis.yaml +++ b/base/persistencecore/genesis.yaml @@ -58,11 +58,11 @@ spec: spec: initContainers: - name: init-genesis - image: docker.io/persistenceone/persistencecore:v7.0.0-fh + image: persistenceone/persistencecore:v12-alliance-rc0 imagePullPolicy: Always env: - name: COINS - value: "100000000000000000uxprt" + value: "100000000000000000uxprt,100000000000000000stk/uxprt,100000000000000000stk/uatom,100000000000000000stk/udydx,100000000000000000stk/uosmo" - name: CHAIN_ID valueFrom: configMapKeyRef: @@ -86,53 +86,66 @@ spec: jq -r ".genesis[0].mnemonic" /configs/validators.json | persistenceCore keys add $(jq -r ".genesis[0].name" /configs/validators.json) --recover --keyring-backend='test' --home $HOME_DIR # Provide genesis validator self deligations - persistenceCore add-genesis-account $(jq -r .genesis[$i].address /configs/validators.json) $COINS --keyring-backend='test' --home $HOME_DIR + persistenceCore genesis add-genesis-account $(jq -r .genesis[$i].address /configs/validators.json) $COINS --keyring-backend='test' --home $HOME_DIR # Give Validator addresses initial coins for ((i=0; i<$(jq -r '.validators | length' /configs/validators.json); i++)) do jq -r ".validators[$i].mnemonic" /configs/validators.json | persistenceCore keys add $(jq -r ".validators[$i].name" /configs/validators.json) --recover --keyring-backend='test' --home $HOME_DIR - persistenceCore add-genesis-account $(jq -r .validators[$i].address /configs/validators.json) $COINS --keyring-backend='test' --home $HOME_DIR + persistenceCore genesis add-genesis-account $(jq -r .validators[$i].address /configs/validators.json) $COINS --keyring-backend='test' --home $HOME_DIR done - persistenceCore gentx $(jq -r ".genesis[0].name" /configs/validators.json) 5000000000uxprt --keyring-backend="test" --chain-id $CHAIN_ID --home $HOME_DIR + persistenceCore genesis gentx $(jq -r ".genesis[0].name" /configs/validators.json) 5000000000uxprt --keyring-backend="test" --chain-id $CHAIN_ID --home $HOME_DIR echo "Output of gentx" cat $HOME_DIR/config/gentx/*.json | jq echo "Running collect-gentxs" - persistenceCore collect-gentxs --home $HOME_DIR + persistenceCore genesis collect-gentxs --home $HOME_DIR sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' $HOME_DIR/config/config.toml sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $HOME_DIR/config/config.toml sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $HOME_DIR/config/config.toml sed -i 's/index_all_keys = false/index_all_keys = true/g' $HOME_DIR/config/config.toml sed -i 's/unsafe = false/unsafe = true/g' $HOME_DIR/config/config.toml - sed -i 's/minimum-gas-prices = ""/minimum-gas-prices = "0.00uxprt"/g' $HOME_DIR/config/config.toml + sed -i 's/minimum-gas-prices = ""/minimum-gas-prices = "0.01uxprt"/g' $HOME_DIR/config/config.toml sed -i 's/cors_allowed_origins = []/cors_allowed_origins = ["*"]/g' $HOME_DIR/config/config.toml sed -i 's/enable = false/enable = true/g' $HOME_DIR/config/app.toml sed -i 's/swagger = false/swagger = true/g' $HOME_DIR/config/app.toml sed -i 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' $HOME_DIR/config/app.toml + sed -i 's/min-gas-prices = ""/min-gas-prices = "0.01uxprt"/g' $HOME_DIR/config/app.toml jq '.consensus_params.block.max_bytes |= "42020096"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json jq '.app_state.gov.voting_params.voting_period |= "30s"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json + jq '.app_state.gov.params.voting_period |= "30s"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json + mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json jq '.app_state.gov.tally_params.quorum |= "0.0"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json + jq '.app_state.gov.params.quorum |= "0.0"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json + mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json jq '.app_state.gov.deposit_params.min_deposit[0].amount |= "10"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json + jq '.app_state.gov.params.min_deposit[0].amount |= "10"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json + mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json jq '.app_state.crisis.constant_fee.denom |= "uxprt"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json jq '.app_state.gov.deposit_params.min_deposit[0].denom |= "uxprt"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json - jq '.app_state.liquidity.params.pool_creation_fee[0].denom |= "uxprt"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json + jq '.app_state.gov.params.min_deposit[0].denom |= "uxprt"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json + # jq '.app_state.liquidity.params.pool_creation_fee[0].denom |= "uxprt"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json + # mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json jq '.app_state.mint.params.mint_denom |= "uxprt"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json jq '.app_state.staking.params.bond_denom |= "uxprt"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json + + # update slash_window parameter (app_state.oracle.slash_window) from 1 day and 4 hours to an year in seconds + jq '.app_state.oracle.params.slash_window |= "31536000"' $HOME_DIR/config/genesis.json | tee $HOME_DIR/config/genesis.new.json + mv $HOME_DIR/config/genesis.new.json $HOME_DIR/config/genesis.json echo "TRYING TO PRINT GENESIS JSON" cat $HOME_DIR/config/genesis.json | jq @@ -152,7 +165,7 @@ spec: name: addresses containers: - name: validator - image: docker.io/persistenceone/persistencecore:v7.0.0-fh + image: persistenceone/persistencecore:v9.2.1-fh imagePullPolicy: Always env: - name: CHAIN_ID @@ -166,6 +179,7 @@ spec: - bash - "-c" - | + # sleep infinity persistenceCore start --home $HOME_DIR resources: limits: diff --git a/base/persistencecore/kustomization.yaml b/base/persistencecore/kustomization.yaml index 46d140c..63368d9 100644 --- a/base/persistencecore/kustomization.yaml +++ b/base/persistencecore/kustomization.yaml @@ -1,5 +1,6 @@ resources: - genesis.yaml + # - configmap.yaml - validator.yaml generatorOptions: diff --git a/base/persistencecore/validator.yaml b/base/persistencecore/validator.yaml index 7948701..5008b0e 100644 --- a/base/persistencecore/validator.yaml +++ b/base/persistencecore/validator.yaml @@ -50,7 +50,7 @@ spec: spec: initContainers: - name: wait-for-genesis - image: docker.io/persistenceone/persistencecore:v7.0.0-fh + image:persistenceone/persistencecore:v12-alliance-rc0 imagePullPolicy: Always env: - name: GENESIS_HOST @@ -68,7 +68,7 @@ spec: echo "Ready to start" exit 0 - name: init-validator - image: docker.io/persistenceone/persistencecore:v7.0.0-fh + image:persistenceone/persistencecore:v12-alliance-rc0 imagePullPolicy: Always env: - name: CHAIN_ID diff --git a/docker/firecosmos.dockerfile b/docker/firecosmos.dockerfile new file mode 100644 index 0000000..1c17689 --- /dev/null +++ b/docker/firecosmos.dockerfile @@ -0,0 +1,14 @@ +FROM alpine AS release + +RUN apk add wget +RUN apk add bash +RUN wget https://github.com/graphprotocol/firehose-cosmos/releases/download/v0.6.0/firecosmos_linux_amd64 -O firecosmos + +# make executable +RUN chmod +x firecosmos + +# move firecosmos to bin +RUN mv firecosmos /usr/local/bin + +# set as cmd +# CMD ["firecosmos"] \ No newline at end of file diff --git a/docker/firepersistence-core.dockerfile b/docker/firepersistence-core.dockerfile new file mode 100644 index 0000000..4e64df0 --- /dev/null +++ b/docker/firepersistence-core.dockerfile @@ -0,0 +1,87 @@ +# syntax=docker/dockerfile:1 + +# Multi-stage build producing: +# - firecore (from streamingfast/firehose-core) +# - chain poller binary (default: firepersistence) from persistenceOne/firehose-cosmos + +ARG FIRECORE_REPO=https://github.com/streamingfast/firehose-core.git +ARG FIRECORE_REF=v1.11.1 +ARG FIRECHAIN_REPO=https://github.com/persistenceOne/firehose-cosmos.git +ARG FIRECHAIN_REF=betterclever/persistence-support +ARG CHAIN_BINARY_NAME=firepersistence + +FROM golang:1.24 AS firecore_builder + +ARG FIRECORE_REPO +ARG FIRECORE_REF + +WORKDIR /src/firecore +RUN git clone --depth=1 -b ${FIRECORE_REF} ${FIRECORE_REPO} . \ + && if [ -f go.mod ]; then go mod download; fi + +# Build firecore binary +ENV GOTOOLCHAIN=auto +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + ca-certificates build-essential clang pkg-config \ + && rm -rf /var/lib/apt/lists/* +RUN CGO_ENABLED=1 go build -o /out/firecore ./cmd/firecore + + +FROM golang:1.24 AS firechain_builder + +ARG FIRECHAIN_REPO +ARG FIRECHAIN_REF +ARG CHAIN_BINARY_NAME + +WORKDIR /src/firechain +RUN git clone --depth=1 -b ${FIRECHAIN_REF} ${FIRECHAIN_REPO} . \ + && if [ -f go.mod ]; then go mod download; fi + +ENV GOTOOLCHAIN=auto +RUN set -e; \ + mkdir -p /out; \ + found=""; \ + for name in "${CHAIN_BINARY_NAME}" firepersistence firecosmos fireinjective firemantra; do \ + for path in "./${name}" "./cmd/${name}"; do \ + if [ -d "$path" ]; then \ + echo "Building $name from $path"; \ + (cd "$path" && CGO_ENABLED=0 go build -o "/out/${name}"); \ + found="$name"; \ + break; \ + fi; \ + done; \ + if [ -n "$found" ]; then break; fi; \ + done; \ + if [ -z "$found" ]; then \ + echo "Could not locate chain binary source dir (tried ${CHAIN_BINARY_NAME}, firepersistence, firecosmos, fireinjective, firemantra)"; \ + find . -maxdepth 3 -type d -print; \ + exit 1; \ + fi; \ + # Ensure default name is firepersistence inside image + if [ "$found" != "firepersistence" ]; then \ + cp "/out/$found" "/out/firepersistence"; \ + fi + + +FROM ubuntu:24.04 AS runtime + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + ca-certificates bash curl jq \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +COPY --from=firecore_builder /out/firecore /usr/local/bin/firecore +COPY --from=firechain_builder /out/ /usr/local/bin/ + +ENV PATH="/usr/local/bin:${PATH}" + +# Data directory used by firecore --data-dir +RUN mkdir -p /app/data + +EXPOSE 9000 9102 + +# Default to show help; override in k8s CMD/args +CMD ["firecore", "--help"] + + diff --git a/graph-node-alternate/base/config-graph/config-graph-node-v1.toml b/graph-node-alternate/base/config-graph/config-graph-node-v1.toml new file mode 100644 index 0000000..1a5857a --- /dev/null +++ b/graph-node-alternate/base/config-graph/config-graph-node-v1.toml @@ -0,0 +1,19 @@ +[deployment] +[[deployment.rule]] +shard = "primary" +indexers = [ "index_node_cosmos_1" ] + +[store] +[store.primary] +connection = "postgresql://POSTGRES_USER:POSTGRES_PASSWORD@POSTGRES_HOST:POSTGRES_PORT/POSTGRES_DB" +pool_size = 10 + +[chains] +ingestor = "block_ingestor_node" + +[chains.persistence] +shard = "primary" +protocol = "cosmos" +provider = [ + { label = "persistence", details = { type = "firehose", url = "http://FIREHOSE_HOST:FIREHOSE_PORT" }}, +] \ No newline at end of file diff --git a/graph-node-alternate/base/config-graph/config-graph-node-v2.toml b/graph-node-alternate/base/config-graph/config-graph-node-v2.toml new file mode 100644 index 0000000..94ffda3 --- /dev/null +++ b/graph-node-alternate/base/config-graph/config-graph-node-v2.toml @@ -0,0 +1,27 @@ +[deployment] +[[deployment.rule]] +shard = "primary" +indexers = [ "index_node_cosmos_2" ] + +[store] +[store.primary] +connection = "postgresql://POSTGRES_USER:POSTGRES_PASSWORD@POSTGRES_HOST:POSTGRES_PORT/POSTGRES_DB_SUBSTREAMS" +pool_size = 10 + +[chains] +ingestor = "block_ingestor_node" + +[chains.babylon] +shard = "primary" +protocol = "substreams" +provider = [ + { label = "substreams", details = { type = "substreams", url = "http://159.89.170.65:10016" }}, +] + +[chains.persistence] +shard = "primary" +protocol = "substreams" +provider = [ + { label = "substreams", details = { type = "substreams", url = "https://substreams.core.persistence.one:443" }}, +] + diff --git a/graph-node-alternate/base/config-graph/config-graph-node.toml b/graph-node-alternate/base/config-graph/config-graph-node.toml new file mode 100644 index 0000000..11ae6c7 --- /dev/null +++ b/graph-node-alternate/base/config-graph/config-graph-node.toml @@ -0,0 +1,26 @@ +[deployment] +[[deployment.rule]] +shard = "primary" +indexers = [ "index_node_cosmos_1", "index_node_cosmos_2" ] + +[store] +[store.primary] +connection = "postgresql://POSTGRES_USER:POSTGRES_PASSWORD@POSTGRES_HOST:POSTGRES_PORT/POSTGRES_DB" +pool_size = 10 + +[chains] +ingestor = "block_ingestor_node" + +[chains.persistence] +shard = "primary" +protocol = "cosmos" +provider = [ + { label = "persistence", details = { type = "firehose", url = "http://FIREHOSE_HOST:FIREHOSE_PORT" }}, +] + +[chains.babylon] +shard = "primary" +protocol = "substreams" +provider = [ + { label = "babylon", details = { type = "substreams", url = "http://159.89.170.65:10016" }}, +] diff --git a/graph-node-alternate/base/config-graph/config.toml b/graph-node-alternate/base/config-graph/config.toml new file mode 100644 index 0000000..5c0582a --- /dev/null +++ b/graph-node-alternate/base/config-graph/config.toml @@ -0,0 +1,6 @@ +####################################################### +### Extractor Configuration Options ### +####################################################### +[extractor] +enabled = true +output_file = "stdout" \ No newline at end of file diff --git a/graph-node-alternate/base/config-graph/firehose-node.json b/graph-node-alternate/base/config-graph/firehose-node.json new file mode 100644 index 0000000..f5a7431 --- /dev/null +++ b/graph-node-alternate/base/config-graph/firehose-node.json @@ -0,0 +1,14 @@ +{ + "firehose_nodes": [ + { + "name": "firehose-node-1", + "type": "local", + "address": "persistence1y3x3uaqnnlhulway8g5dvm4erpd5r4f0d29hn5", + "pubkey": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Agn5q1U2vLjdAhg4dcKuUKm3ZwdmrrFmVnlnqsqkXoIA" + }, + "mnemonic": "tag apart multiply food bleak isolate describe stand guide field session design cable combine excess shrug abuse pause course ketchup umbrella program labor ripple" + } + ] +} diff --git a/graph-node-alternate/base/config-graph/firehose-reader.yml b/graph-node-alternate/base/config-graph/firehose-reader.yml new file mode 100644 index 0000000..dbf450a --- /dev/null +++ b/graph-node-alternate/base/config-graph/firehose-reader.yml @@ -0,0 +1,15 @@ +start: + args: + - reader + flags: + # Common flags + common-first-streamable-block: 0 + + # reader specific flags + reader-mode: node + reader-node-path: /usr/bin/persistenceCore + reader-node-args: start --x-crisis-skip-assert-invariants --home /persistencecore + reader-node-logs-filter: "module=(p2p|pex|consensus|x/bank|x/wasm)" + + common-one-block-store-url: 's3://sgp1.digitaloceanspaces.com/dexter-zone/one-blocks?region=us-east-1' + common-merged-blocks-store-url: 's3://sgp1.digitaloceanspaces.com/dexter-zone/merged-blocks?region=us-east-1' \ No newline at end of file diff --git a/graph-node-alternate/base/config-graph/firehose.yml b/graph-node-alternate/base/config-graph/firehose.yml new file mode 100644 index 0000000..336896a --- /dev/null +++ b/graph-node-alternate/base/config-graph/firehose.yml @@ -0,0 +1,15 @@ +start: + args: + - reader + - merger + - relayer + - firehose + flags: + # Common flags + common-first-streamable-block: 0 + + # reader specific flags + reader-mode: node + reader-node-path: /usr/bin/persistenceCore + reader-node-args: start --x-crisis-skip-assert-invariants --home /persistencecore + reader-node-logs-filter: "module=(p2p|pex|consensus|x/bank|x/wasm)" \ No newline at end of file diff --git a/graph-node-alternate/base/graph-node.yaml b/graph-node-alternate/base/graph-node.yaml new file mode 100644 index 0000000..48fe2a1 --- /dev/null +++ b/graph-node-alternate/base/graph-node.yaml @@ -0,0 +1,323 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: persistencecore-graph-node + labels: + app.kubernetes.io/name: persistencecore-graph-node +spec: + clusterIP: None + ports: + - name: http + port: 8000 + protocol: TCP + targetPort: 8000 + - name: websocket + port: 8001 + protocol: TCP + targetPort: 8001 + - name: admin + port: 8020 + protocol: TCP + targetPort: 8020 + - name: health + port: 8030 + protocol: TCP + targetPort: 8030 + - name: prometheus + port: 8040 + protocol: TCP + targetPort: 8040 + selector: + app.kubernetes.io/name: persistencecore-graph-node +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: persistencecore-graph-node +spec: + replicas: 1 + revisionHistoryLimit: 3 + selector: + matchLabels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/name: persistencecore-graph-node + template: + metadata: + annotations: + quality: release + role: api-gateway + sla: high + tier: gateway + labels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/type: persistencecore-graph-node + app.kubernetes.io/name: persistencecore-graph-node + app.kubernetes.io/version: "0.1" + spec: + initContainers: + - name: wait-for-firehose-node + image: networld/grpcurl + imagePullPolicy: Always + env: + - name: FIREHOSE_HOST + valueFrom: + configMapKeyRef: + name: graph-node-config + key: firehose_node.host + - name: FIREHOSE_PORT + valueFrom: + configMapKeyRef: + name: graph-node-config + key: firehose_node.port + command: + - sh + - "-c" + - | + apk update + apk add jq + + x=1; while [ $x -le 10 ]; do + echo "Attempt number: $x" + FIREHOSE_STATUS=$(./grpcurl -plaintext $FIREHOSE_HOST:$FIREHOSE_PORT grpc.health.v1.Health.Check | jq .status) + if [ $FIREHOSE_STATUS == '"SERVING"' ] + then + echo "Ready to start" + exit 0 + fi + echo "Firehose node does not seem to be ready. Status: $FIREHOSE_STATUS Waiting for it to start. Sleeping for 15 seconds." + sleep 15 + x=$(( $x + 1 )) + done + + echo "Retry limit exceeded. Current status: $(./grpcurl -plaintext $FIREHOSE_HOST:$FIREHOSE_PORT grpc.health.v1.Health.Check | jq .status)" + exit 1 + + containers: + - name: graph-node + image: graphprotocol/graph-node:v0.35.1 + imagePullPolicy: Always + env: + - name: FIREHOSE_HOST + valueFrom: + configMapKeyRef: + name: graph-node-config + key: firehose_node.host + - name: FIREHOSE_PORT + valueFrom: + configMapKeyRef: + name: graph-node-config + key: firehose_node.port + - name: IPFS_HOST + valueFrom: + configMapKeyRef: + name: graph-node-config + key: ipfs.host + - name: IPFS_PORT + valueFrom: + configMapKeyRef: + name: graph-node-config + key: ipfs.port + - name: POSTGRES_HOST + valueFrom: + secretKeyRef: + name: postgres-secret + key: POSTGRES_HOST + - name: POSTGRES_PORT + valueFrom: + secretKeyRef: + name: postgres-secret + key: POSTGRES_PORT + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: postgres-secret + key: POSTGRES_USER + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: postgres-secret + key: POSTGRES_PASSWORD + - name: POSTGRES_DB + valueFrom: + secretKeyRef: + name: postgres-secret + key: POSTGRES_DB + command: + - bash + - "-c" + - | + + cp config-graph/config-graph-node-v1.toml config.toml + sed -i "s/POSTGRES_USER/$POSTGRES_USER/g" config.toml + sed -i "s/POSTGRES_PASSWORD/$POSTGRES_PASSWORD/g" config.toml + sed -i "s/POSTGRES_HOST/$POSTGRES_HOST/g" config.toml + sed -i "s/POSTGRES_PORT/$POSTGRES_PORT/g" config.toml + sed -i "s/POSTGRES_DB/$POSTGRES_DB/g" config.toml + sed -i "s/FIREHOSE_HOST/$FIREHOSE_HOST/g" config.toml + sed -i "s/FIREHOSE_PORT/$FIREHOSE_PORT/g" config.toml + + # Print config before starting node + cat config.toml + + graph-node --config config.toml \ + --ipfs "$IPFS_HOST:$IPFS_PORT" \ + --node-id index_node_cosmos_1 + resources: + limits: + cpu: "1" + memory: "1G" + requests: + cpu: "0.5" + memory: "512Mi" + volumeMounts: + - mountPath: config-graph + name: config-graph + volumes: + - name: config-graph + configMap: + name: config-graph +--- +apiVersion: v1 +kind: Service +metadata: + name: persistencecore-graph-node-v037 + labels: + app.kubernetes.io/name: persistencecore-graph-node-v037 +spec: + clusterIP: None + ports: + - name: http + port: 8000 + protocol: TCP + targetPort: 8000 + - name: websocket + port: 8001 + protocol: TCP + targetPort: 8001 + - name: admin + port: 8020 + protocol: TCP + targetPort: 8020 + - name: health + port: 8030 + protocol: TCP + targetPort: 8030 + - name: prometheus + port: 8040 + protocol: TCP + targetPort: 8040 + selector: + app.kubernetes.io/name: persistencecore-graph-node-v037 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: persistencecore-graph-node-v037 +spec: + replicas: 1 + revisionHistoryLimit: 3 + selector: + matchLabels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/name: persistencecore-graph-node-v037 + template: + metadata: + annotations: + quality: release + role: api-gateway + sla: high + tier: gateway + labels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/type: persistencecore-graph-node-v037 + app.kubernetes.io/name: persistencecore-graph-node-v037 + app.kubernetes.io/version: "0.37" + spec: + containers: + - name: graph-node + image: graphprotocol/graph-node:v0.38.0 + imagePullPolicy: Always + env: + - name: BABYLON_SUBSTREAMS_HOST + valueFrom: + configMapKeyRef: + name: graph-node-config + key: babylon_substreams.host + - name: BABYLON_SUBSTREAMS_PORT + valueFrom: + configMapKeyRef: + name: graph-node-config + key: babylon_substreams.port + - name: IPFS_HOST + valueFrom: + configMapKeyRef: + name: graph-node-config + key: ipfs.host + - name: IPFS_PORT + valueFrom: + configMapKeyRef: + name: graph-node-config + key: ipfs.port + - name: POSTGRES_HOST + valueFrom: + secretKeyRef: + name: postgres-secret + key: POSTGRES_HOST + - name: POSTGRES_PORT + valueFrom: + secretKeyRef: + name: postgres-secret + key: POSTGRES_PORT + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: postgres-secret + key: POSTGRES_USER + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: postgres-secret + key: POSTGRES_PASSWORD + - name: POSTGRES_DB_SUBSTREAMS + valueFrom: + secretKeyRef: + name: postgres-secret + key: POSTGRES_DB_SUBSTREAMS + - name: GRAPH_NODE_FIREHOSE_DISABLE_EXTENDED_BLOCKS_FOR_CHAINS + value: "babylon,persistence" + command: + - bash + - "-c" + - | + + cp config-graph/config-graph-node-v2.toml config.toml + sed -i "s/POSTGRES_USER/$POSTGRES_USER/g" config.toml + sed -i "s/POSTGRES_PASSWORD/$POSTGRES_PASSWORD/g" config.toml + sed -i "s/POSTGRES_HOST/$POSTGRES_HOST/g" config.toml + sed -i "s/POSTGRES_PORT/$POSTGRES_PORT/g" config.toml + sed -i "s/POSTGRES_DB_SUBSTREAMS/$POSTGRES_DB_SUBSTREAMS/g" config.toml + sed -i "s/BABYLON_SUBSTREAMS_HOST/$BABYLON_SUBSTREAMS_HOST/g" config.toml + sed -i "s/BABYLON_SUBSTREAMS_PORT/$BABYLON_SUBSTREAMS_PORT/g" config.toml + + # Print config before starting node + cat config.toml + + graph-node --config config.toml \ + --ipfs "$IPFS_HOST:$IPFS_PORT" \ + --node-id index_node_cosmos_2 + resources: + limits: + cpu: "1" + memory: "1G" + requests: + cpu: "0.5" + memory: "512Mi" + volumeMounts: + - mountPath: config-graph + name: config-graph + volumes: + - name: config-graph + configMap: + name: config-graph + diff --git a/graph-node-alternate/base/hasura.yaml b/graph-node-alternate/base/hasura.yaml new file mode 100644 index 0000000..b7f12d3 --- /dev/null +++ b/graph-node-alternate/base/hasura.yaml @@ -0,0 +1,60 @@ +apiVersion: v1 +kind: Service +metadata: + name: persistencecore-hasura + labels: + app.kubernetes.io/name: persistencecore-hasura +spec: + ports: + - name: http + protocol: TCP + port: 8080 + targetPort: 8080 + selector: + app.kubernetes.io/name: persistencecore-hasura + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: persistencecore-hasura +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: persistencecore-hasura + template: + metadata: + labels: + app.kubernetes.io/name: persistencecore-hasura + spec: + containers: + - name: hasura + image: hasura/graphql-engine:v2.19.0 + ports: + - containerPort: 8080 + protocol: TCP + resources: + limits: + cpu: "2" + memory: "2G" + requests: + cpu: "1" + memory: "2G" + env: + - name: HASURA_GRAPHQL_DATABASE_URL + valueFrom: + secretKeyRef: + name: postgres-secret + key: POSTGRES_HASURA_URL + - name: HASURA_GRAPHQL_ENABLE_CONSOLE + value: 'true' + - name: HASURA_GRAPHQL_DEV_MODE + value: 'true' + - name: HASURA_GRAPHQL_ADMIN_SECRET + valueFrom: + secretKeyRef: + name: postgres-secret + key: HASURA_GRAPHQL_ADMIN_SECRET + - name: HASURA_GRAPHQL_UNAUTHORIZED_ROLE + value: api-user \ No newline at end of file diff --git a/graph-node-alternate/base/hasura2.yaml b/graph-node-alternate/base/hasura2.yaml new file mode 100644 index 0000000..6100d25 --- /dev/null +++ b/graph-node-alternate/base/hasura2.yaml @@ -0,0 +1,65 @@ +apiVersion: v1 +kind: Service +metadata: + name: dexter-hasura + labels: + app.kubernetes.io/name: dexter-hasura +spec: + ports: + - name: http + protocol: TCP + port: 8080 + targetPort: 8080 + selector: + app.kubernetes.io/name: dexter-hasura + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: dexter-hasura +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: dexter-hasura + template: + metadata: + labels: + app.kubernetes.io/name: dexter-hasura + spec: + containers: + - name: hasura + image: hasura/graphql-engine:v2.37.0 + ports: + - containerPort: 8080 + protocol: TCP + resources: + limits: + cpu: "2" + memory: "2G" + requests: + cpu: "1" + memory: "2G" + env: + - name: HASURA_GRAPHQL_DATABASE_URL + valueFrom: + secretKeyRef: + name: postgres-secret + key: DEXTER_POSTGRES_HASURA_URL2 + - name: DEXTER_POSTGRES_HASURA_GRAPHCORE_DB + valueFrom: + secretKeyRef: + name: postgres-secret + key: DEXTER_POSTGRES_HASURA_GRAPHCORE_DB + - name: HASURA_GRAPHQL_ENABLE_CONSOLE + value: 'true' + - name: HASURA_GRAPHQL_DEV_MODE + value: 'true' + - name: HASURA_GRAPHQL_ADMIN_SECRET + valueFrom: + secretKeyRef: + name: postgres-secret + key: HASURA_GRAPHQL_ADMIN_SECRET + - name: HASURA_GRAPHQL_UNAUTHORIZED_ROLE + value: api-user \ No newline at end of file diff --git a/graph-node-alternate/base/ipfs-node.yaml b/graph-node-alternate/base/ipfs-node.yaml new file mode 100644 index 0000000..13d171a --- /dev/null +++ b/graph-node-alternate/base/ipfs-node.yaml @@ -0,0 +1,60 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: ipfs-node + labels: + app.kubernetes.io/name: ipfs-node +spec: + clusterIP: None + ports: + - name: http + port: 5001 + protocol: TCP + targetPort: 5001 + selector: + app.kubernetes.io/name: ipfs-node +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ipfs-node +spec: + replicas: 1 + revisionHistoryLimit: 3 + selector: + matchLabels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/name: ipfs-node + template: + metadata: + annotations: + quality: release + role: api-gateway + sla: high + tier: gateway + labels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/type: ipfs-node + app.kubernetes.io/name: ipfs-node + app.kubernetes.io/version: '0.1' + spec: + volumes: + - name: ipfs-pv-storage + persistentVolumeClaim: + claimName: ipfs-pv-claim + containers: + - name: ipfs-node + image: ipfs/go-ipfs:v0.10.0 + imagePullPolicy: Always + resources: + limits: + cpu: "0.5" + memory: "500M" + requests: + cpu: "0.25" + memory: "250M" + volumeMounts: + - mountPath: /data/ipfs + name: ipfs-pv-storage +--- diff --git a/graph-node-alternate/base/ipfs-persistent-volume.yaml b/graph-node-alternate/base/ipfs-persistent-volume.yaml new file mode 100644 index 0000000..9c15438 --- /dev/null +++ b/graph-node-alternate/base/ipfs-persistent-volume.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: ipfs-pv-claim +spec: + storageClassName: do-block-storage + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi \ No newline at end of file diff --git a/graph-node-alternate/base/kustomization.yaml b/graph-node-alternate/base/kustomization.yaml new file mode 100644 index 0000000..abeb933 --- /dev/null +++ b/graph-node-alternate/base/kustomization.yaml @@ -0,0 +1,22 @@ +resources: + - graph-node.yaml + - ipfs-node.yaml + # - hasura.yaml + - hasura2.yaml + - ipfs-persistent-volume.yaml + +generatorOptions: + disableNameSuffixHash: true + +configMapGenerator: + - name: config-graph + files: + - config-graph/firehose-node.json + - config-graph/firehose-reader.yml + - config-graph/config.toml + - config-graph/config-graph-node.toml + - config-graph/config-graph-node-v1.toml + - config-graph/config-graph-node-v2.toml + - name: scripts-graph + files: + - scripts/init-firehose-node.sh \ No newline at end of file diff --git a/graph-node-alternate/base/scripts/init-firehose-node.sh b/graph-node-alternate/base/scripts/init-firehose-node.sh new file mode 100644 index 0000000..90e0746 --- /dev/null +++ b/graph-node-alternate/base/scripts/init-firehose-node.sh @@ -0,0 +1,132 @@ +NODE_INDEX=${HOSTNAME##*-} +echo "firehose-node Index: $NODE_INDEX" + + +# print all environment variables +printenv + +# If genesis json exists and force_init is not set, then skip the node initialization +if [ "$FORCE_INIT" = "true" ]; then + echo "Force init is set to true. Initializing node." + rm -rf $HOME_DIR/* +else + echo "Force init is set to false. Skipping node initialization." +fi + + +if test -f $HOME_DIR/config/genesis.json; then + echo "Genesis.json exists. Skipping node initialization." +else + echo "Genesis.json does not exist. Initializing node." + + NODE_NAME=$(jq -r ".firehose_nodes[$NODE_INDEX].name" /config-graph/firehose-node.json) + echo "firehose-node Index: $NODE_INDEX, Key name: $NODE_NAME" + + # Print mnemonic + MNEMONIC=$(jq -r ".firehose_nodes[$NODE_INDEX].mnemonic" /config-graph/firehose-node.json) + echo "Mnemonic: $MNEMONIC" + + jq -r ".firehose_nodes[$NODE_INDEX].mnemonic" /config-graph/firehose-node.json | persistenceCore init $NODE_NAME --chain-id $CHAIN_ID --home $HOME_DIR --recover + echo $MNEMONIC | persistenceCore keys add $NODE_NAME --recover --keyring-backend="test" --home $HOME_DIR + + # if we have GENESIS_NODE_DATA_RESOLUTION_METHOD is dynamic fetch the genesis from the GENESIS_EXPOSER_PORT on the GENESIS_HOST + # else fetch it directly from GENESIS_JSON_FETCH_URL + GENESIS_NODE_ID="" + if [ $GENESIS_NODE_DATA_RESOLUTION_METHOD = "DYNAMIC" ]; then + echo "Config: DYNAMIC. Fetching genesis file from $GENESIS_HOST:$GENESIS_EXPOSER_PORT" + GENESIS_NODE_ID=$(curl -s http://$GENESIS_HOST:$GENESIS_EXPOSER_PORT/node_id) + curl http://$GENESIS_HOST:$GENESIS_EXPOSER_PORT/genesis -o $HOME_DIR/config/genesis.json + else + echo "Config: STATIC. Fetching genesis file from $GENESIS_JSON_FETCH_URL" + curl $GENESIS_JSON_FETCH_URL -o $HOME_DIR/config/genesis.json + fi + + GENESIS_NODE_P2P="$GENESIS_NODE_ID@$GENESIS_HOST:$GENESIS_PORT_P2P" + echo "Node P2P: $GENESIS_NODE_P2P" + + # skip persistent_peers if GENESIS_NODE_DATA_RESOLUTION_METHOD is static + if [ $GENESIS_NODE_DATA_RESOLUTION_METHOD = "DYNAMIC" ]; then + sed -i "s/persistent_peers = \"\"/persistent_peers = \"$GENESIS_NODE_P2P\"/g" $HOME_DIR/config/config.toml + fi + sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' $HOME_DIR/config/config.toml + sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $HOME_DIR/config/config.toml + sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $HOME_DIR/config/config.toml + sed -i 's/index_all_keys = false/index_all_keys = true/g' $HOME_DIR/config/config.toml + sed -i 's/prometheus = false/prometheus = true/g' $HOME_DIR/config/config.toml + + # replace seeds if the variable is not empty + if [ ! -z "$SEEDS" ]; then + sed -i "s/seeds = \"\"/seeds = \"$SEEDS\"/g" $HOME_DIR/config/config.toml + fi + + # replace persistent_peers if the variable is not empty + if [ ! -z "$PERSISTENT_PEERS" ]; then + sed -i "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" $HOME_DIR/config/config.toml + fi + + echo "Printing the whole config.toml file" + + cat << END >> $HOME_DIR/config/config.toml + ####################################################### + ### Extractor Configuration Options ### + ####################################################### + [extractor] + enabled = true + output_file = "stdout" +END + + cat $HOME_DIR/config/config.toml + + + # update the app.toml pruning config to Nothing + # sed -i 's/pruning = "default"/pruning = "nothing"/g' $HOME_DIR/config/app.toml + # update the minimum-gas-prices in app.toml to 100uxprt + sed -i 's/minimum-gas-prices = ""/minimum-gas-prices = "100uxprt"/g' $HOME_DIR/config/app.toml + + echo "Setting up pruning configuration in app.toml" + sed -i 's/pruning = "default"/pruning = "custom"/g' $HOME_DIR/config/app.toml + sed -i 's/pruning-interval = "0"/pruning-interval = "100"/g' $HOME_DIR/config/app.toml + sed -i 's/pruning-keep-recent = "0"/pruning-keep-recent = "10000"/g' $HOME_DIR/config/app.toml + + + # if STATE_RESTORE_SNAPSHOT_URL is not empty url and wasm folder doesn't exist, then download and extract the snapshot + if [ ! -z "$STATE_RESTORE_SNAPSHOT_URL" ]; then + echo "=> Downloading snapshot from $STATE_RESTORE_SNAPSHOT_URL" + FILENAME=$(basename $STATE_RESTORE_SNAPSHOT_URL) + curl $STATE_RESTORE_SNAPSHOT_URL -o $HOME_DIR/$FILENAME + + echo "=> Extracting snapshot" + cp $HOME_DIR/data/priv_validator_state.json $HOME/priv_validator_state_backup.json + + case "$FILENAME" in + *.tar.lz4) + if ! command -v lz4 &> /dev/null; then + apk add --no-cache lz4 + fi + + lz4 -c -d $HOME_DIR/$FILENAME | tar -x -C $HOME_DIR + # delete the $HOME_DIR/wasm/wasm/cache folder + rm -rf $HOME_DIR/wasm/wasm/cache + rm -rf $HOME_DIR/$FILENAME + ;; + + *.tar.gz) + tar -xvf $HOME_DIR/$FILENAME -C $HOME_DIR + rm -rf $HOME_DIR/wasm/wasm/cache + rm -rf $HOME_DIR/$FILENAME + ;; + esac + + mv $HOME_DIR/priv_validator_state_backup.json $HOME/data/priv_validator_state.json + rm $HOME_DIR/priv_validator_state_backup.json + fi + +fi +# copy the firehose.yml file to the HOME_DIR because config-graph is a read-only volume +cp /config-graph/firehose-reader.yml $HOME_DIR/config/firehose.yml + +# if FIRST_STREAMABLE_BLOCK is not empty, then set the first_streamable_block in firehose.yml +if [ ! -z "$FIRST_STREAMABLE_BLOCK" ]; then + echo "Setting common-first-streamable-block to $FIRST_STREAMABLE_BLOCK" + sed -i "s/common-first-streamable-block: 0/common-first-streamable-block: $FIRST_STREAMABLE_BLOCK/g" $HOME_DIR/config/firehose.yml +fi \ No newline at end of file diff --git a/graph-node-alternate/dummy-configmap.yaml b/graph-node-alternate/dummy-configmap.yaml new file mode 100644 index 0000000..2adb0a9 --- /dev/null +++ b/graph-node-alternate/dummy-configmap.yaml @@ -0,0 +1,33 @@ +# Dummy values. The actual values are set in the respective environment's configmap. + +apiVersion: v1 +kind: ConfigMap +metadata: + name: persistencecore +data: + chain.id: persistencecore + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: firehose-node-config +data: + sync_node.resolution_method: DYNAMIC + sync_node.host: '' + sync_node.exposer_port: '' + sync_node.port_p2p: '' + sync_node.genesis_json_fetch_url: '' + snapshot_restore_url: '' + seeds: '' +--- + +apiVersion: v1 +kind: ConfigMap +metadata: + name: graph-node-config +data: + firehose_node.host: 'firehose-node.testnet.svc.cluster.local' + firehose_node.port: '9030' + ipfs.host: 'ipfs.testnet.svc.cluster.local' + ipfs.port: '5001' \ No newline at end of file diff --git a/graph-node-alternate/overlays/multi-pod/firehose-firehose.yaml b/graph-node-alternate/overlays/multi-pod/firehose-firehose.yaml new file mode 100644 index 0000000..a37ecfd --- /dev/null +++ b/graph-node-alternate/overlays/multi-pod/firehose-firehose.yaml @@ -0,0 +1,121 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: persistencecore-firehose + labels: + app.kubernetes.io/name: persistencecore-firehose +spec: + clusterIP: None + ports: + - name: firehose + port: 10015 + protocol: TCP + targetPort: 10015 + - name: substreams-tier1 + port: 10016 + protocol: TCP + targetPort: 10016 + - name: substreams-tier2 + port: 10017 + protocol: TCP + targetPort: 10017 + - name: prometheus-firehose + port: 9102 + protocol: TCP + targetPort: 9102 + selector: + app.kubernetes.io/name: persistencecore-firehose + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: persistencecore-firehose +spec: + replicas: 1 + revisionHistoryLimit: 3 + selector: + matchLabels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/name: persistencecore-firehose + template: + metadata: + annotations: + quality: release + role: api-gateway + sla: high + tier: gateway + labels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/type: persistencecore-firehose + app.kubernetes.io/name: persistencecore-firehose + app.kubernetes.io/version: '0.1' + spec: + terminationGracePeriodSeconds: 10 + containers: + - name: firehose-node + image: ghcr.io/persistenceone/firecore-firepersistence:0.1 + imagePullPolicy: Always + env: + - name: FIRST_STREAMABLE_BLOCK + valueFrom: + configMapKeyRef: + key: first_streamable_block + name: firehose-node-config + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + key: aws_access_key_id + name: firehose-node-aws-credentials + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + key: aws_secret_access_key + name: firehose-node-aws-credentials + - name: ONE_BLOCK_STORE_URL + valueFrom: + configMapKeyRef: + key: one_block_store_url + name: firehose-node-config + - name: MERGED_BLOCKS_STORE_URL + valueFrom: + configMapKeyRef: + key: merged_blocks_store_url + name: firehose-node-config + - name: CHAIN_ID + valueFrom: + configMapKeyRef: + key: chain.id + name: persistencecore + command: + - bash + - "-c" + - | + export NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace) + exec firecore start relayer firehose substreams-tier1 substreams-tier2 \ + --config-file= \ + --log-format=stackdriver \ + --log-to-file=false \ + --data-dir=/fh-data \ + --common-auto-max-procs \ + --common-auto-mem-limit-percent=90 \ + --common-one-block-store-url "$ONE_BLOCK_STORE_URL" \ + --common-merged-blocks-store-url "$MERGED_BLOCKS_STORE_URL" \ + --common-first-streamable-block $FIRST_STREAMABLE_BLOCK \ + --common-live-blocks-addr persistencecore-firehose-reader.$NAMESPACE.svc.cluster.local:10010 \ + --advertise-chain-name "$CHAIN_ID" + resources: + limits: + cpu: "2" + memory: "2G" + requests: + cpu: "1" + memory: "2G" + volumes: + - name: config-graph + configMap: + name: config-graph + - name: scripts-graph + configMap: + name: scripts-graph \ No newline at end of file diff --git a/graph-node-alternate/overlays/multi-pod/firehose-merger.yaml b/graph-node-alternate/overlays/multi-pod/firehose-merger.yaml new file mode 100644 index 0000000..206a667 --- /dev/null +++ b/graph-node-alternate/overlays/multi-pod/firehose-merger.yaml @@ -0,0 +1,106 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: persistencecore-firehose-merger + labels: + app.kubernetes.io/name: persistencecore-firehose-merger +spec: + clusterIP: None + ports: + - name: merger-grpc + port: 10012 + protocol: TCP + targetPort: 10012 + - name: prometheus-firehose + port: 9102 + protocol: TCP + targetPort: 9102 + selector: + app.kubernetes.io/name: persistencecore-firehose-merger +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: persistencecore-firehose-merger +spec: + replicas: 1 + revisionHistoryLimit: 3 + selector: + matchLabels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/name: persistencecore-firehose-merger + template: + metadata: + annotations: + quality: release + role: api-gateway + sla: high + tier: gateway + labels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/type: persistencecore-firehose-merger + app.kubernetes.io/name: persistencecore-firehose-merger + app.kubernetes.io/version: '0.1' + spec: + terminationGracePeriodSeconds: 10 + containers: + - name: firehose-merger-node + image: ghcr.io/persistenceone/firecore-firepersistence:0.1 + imagePullPolicy: Always + env: + - name: FIRST_STREAMABLE_BLOCK + valueFrom: + configMapKeyRef: + key: first_streamable_block + name: firehose-node-config + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + key: aws_access_key_id + name: firehose-node-aws-credentials + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + key: aws_secret_access_key + name: firehose-node-aws-credentials + - name: ONE_BLOCK_STORE_URL + valueFrom: + configMapKeyRef: + key: one_block_store_url + name: firehose-node-config + - name: MERGED_BLOCKS_STORE_URL + valueFrom: + configMapKeyRef: + key: merged_blocks_store_url + name: firehose-node-config + command: + - bash + - "-c" + - | + export NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace) + exec firecore start merger \ + --config-file= \ + --log-format=stackdriver \ + --log-to-file=false \ + --data-dir=/fh-data \ + --common-auto-max-procs \ + --common-auto-mem-limit-percent=90 \ + --common-live-blocks-addr persistencecore-firehose-reader.$NAMESPACE.svc.cluster.local:10010 \ + --common-first-streamable-block $FIRST_STREAMABLE_BLOCK \ + --common-one-block-store-url $ONE_BLOCK_STORE_URL \ + --common-merged-blocks-store-url $MERGED_BLOCKS_STORE_URL + resources: + limits: + cpu: "0.5" + memory: "1G" + requests: + cpu: "0.5" + memory: "1G" + volumes: + - name: config-graph + configMap: + name: config-graph + - name: scripts-graph + configMap: + name: scripts-graph \ No newline at end of file diff --git a/graph-node-alternate/overlays/multi-pod/firehose-reader.yaml b/graph-node-alternate/overlays/multi-pod/firehose-reader.yaml new file mode 100644 index 0000000..26d72c5 --- /dev/null +++ b/graph-node-alternate/overlays/multi-pod/firehose-reader.yaml @@ -0,0 +1,128 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: persistencecore-firehose-reader + labels: + app.kubernetes.io/name: persistencecore-firehose-reader +spec: + clusterIP: None + ports: + - name: reader-grpc + port: 10010 + protocol: TCP + targetPort: 10010 + - name: prometheus-node + port: 26660 + protocol: TCP + targetPort: 26660 + - name: prometheus-firehose + port: 9102 + protocol: TCP + targetPort: 9102 + selector: + app.kubernetes.io/name: persistencecore-firehose-reader +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: persistencecore-firehose-reader +spec: + serviceName: persistencecore-firehose-reader + replicas: 1 + revisionHistoryLimit: 3 + selector: + matchLabels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/name: persistencecore-firehose-reader + template: + metadata: + annotations: + quality: release + role: api-gateway + sla: high + tier: gateway + labels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/type: persistencecore-firehose-reader + app.kubernetes.io/name: persistencecore-firehose-reader + app.kubernetes.io/version: '0.1' + spec: + terminationGracePeriodSeconds: 10 + containers: + - name: firehose-node + image: ghcr.io/persistenceone/firecore-firepersistence:0.1 + imagePullPolicy: Always + env: + - name: CHAIN_ID + valueFrom: + configMapKeyRef: + key: chain.id + name: persistencecore + - name: HOME_DIR + value: /persistencecore + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + key: aws_access_key_id + name: firehose-node-aws-credentials + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + key: aws_secret_access_key + name: firehose-node-aws-credentials + - name: ONE_BLOCK_STORE_URL + valueFrom: + configMapKeyRef: + key: one_block_store_url + name: firehose-node-config + - name: MERGED_BLOCKS_STORE_URL + valueFrom: + configMapKeyRef: + key: merged_blocks_store_url + name: firehose-node-config + - name: FIRST_STREAMABLE_BLOCK + valueFrom: + configMapKeyRef: + key: first_streamable_block + name: firehose-node-config + command: + - bash + - "-c" + - | + exec firecore start reader-node \ + --config-file= \ + --log-format=stackdriver \ + --log-to-file=false \ + --data-dir=/fh-data \ + --common-auto-max-procs \ + --common-auto-mem-limit-percent=90 \ + --common-one-block-store-url "$ONE_BLOCK_STORE_URL" \ + --common-merged-blocks-store-url "$MERGED_BLOCKS_STORE_URL" \ + --common-first-streamable-block $FIRST_STREAMABLE_BLOCK \ + --reader-node-data-dir=/fh-data/oneblock \ + --reader-node-working-dir=/fh-data/work \ + --reader-node-readiness-max-latency=600s \ + --reader-node-debug-firehose-logs=false \ + --reader-node-blocks-chan-capacity=1000 \ + --reader-node-path=firepersistence \ + --reader-node-arguments="fetch rpc $FIRST_STREAMABLE_BLOCK --state-dir /fh-data --block-fetch-batch-size=1 --endpoints https://rpc.core.persistence.one:443 --max-block-fetch-duration 10s" \ + --advertise-chain-name "$CHAIN_ID" + resources: + limits: + cpu: "1" + memory: "2G" + requests: + cpu: "0.5" + memory: "1G" + # No volume mounts needed when not restoring snapshots + # No additional volumes required + volumeClaimTemplates: + - metadata: + name: node-pv-storage + spec: + storageClassName: do-block-storage + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 20Gi diff --git a/graph-node-alternate/overlays/multi-pod/firehose-relayer.yaml b/graph-node-alternate/overlays/multi-pod/firehose-relayer.yaml new file mode 100644 index 0000000..92b9aad --- /dev/null +++ b/graph-node-alternate/overlays/multi-pod/firehose-relayer.yaml @@ -0,0 +1,95 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: persistencecore-firehose-relayer + labels: + app.kubernetes.io/name: persistencecore-firehose-relayer +spec: + clusterIP: None + ports: + - name: relayer-grpc + port: 10014 + protocol: TCP + targetPort: 10014 + - name: prometheus-firehose + port: 9102 + protocol: TCP + targetPort: 9102 + selector: + app.kubernetes.io/name: persistencecore-firehose-relayer + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: persistencecore-firehose-relayer +spec: + replicas: 1 + revisionHistoryLimit: 3 + selector: + matchLabels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/name: persistencecore-firehose-relayer + template: + metadata: + annotations: + quality: release + role: api-gateway + sla: high + tier: gateway + labels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/type: persistencecore-firehose-relayer + app.kubernetes.io/name: persistencecore-firehose-relayer + app.kubernetes.io/version: '0.1' + spec: + terminationGracePeriodSeconds: 10 + containers: + - name: firehose-relayer-node + image: ghcr.io/persistenceone/firecore-firepersistence:0.1 + imagePullPolicy: Always + env: + - name: FIRST_STREAMABLE_BLOCK + valueFrom: + configMapKeyRef: + key: first_streamable_block + name: firehose-node-config + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + key: aws_access_key_id + name: firehose-node-aws-credentials + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + key: aws_secret_access_key + name: firehose-node-aws-credentials + command: + - bash + - "-c" + - | + export NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace) + exec firecore start relayer \ + --config-file= \ + --log-format=stackdriver \ + --log-to-file=false \ + --data-dir=/fh-data \ + --common-auto-max-procs \ + --common-auto-mem-limit-percent=90 \ + --relayer-source persistencecore-firehose-reader.$NAMESPACE.svc.cluster.local:10010 \ + --common-first-streamable-block $FIRST_STREAMABLE_BLOCK + resources: + limits: + cpu: "0.25" + memory: "0.5G" + requests: + cpu: "0.25" + memory: "0.5G" + volumes: + - name: config-graph + configMap: + name: config-graph + - name: scripts-graph + configMap: + name: scripts-graph \ No newline at end of file diff --git a/graph-node-alternate/overlays/multi-pod/firehose-resync.yaml b/graph-node-alternate/overlays/multi-pod/firehose-resync.yaml new file mode 100644 index 0000000..0d9538b --- /dev/null +++ b/graph-node-alternate/overlays/multi-pod/firehose-resync.yaml @@ -0,0 +1,243 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: persistencecore-firehose-resync + labels: + app.kubernetes.io/name: persistencecore-firehose-resync +spec: + clusterIP: None + selector: + app.kubernetes.io/name: persistencecore-firehose-resync +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: persistencecore-firehose-resync +spec: + serviceName: persistencecore-firehose-resync + replicas: 1 + revisionHistoryLimit: 3 + selector: + matchLabels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/name: persistencecore-firehose-resync + template: + metadata: + annotations: + quality: release + role: api-gateway + sla: high + tier: gateway + labels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/type: persistencecore-firehose-resync + app.kubernetes.io/name: persistencecore-firehose-resync + app.kubernetes.io/version: '0.1' + spec: + terminationGracePeriodSeconds: 10 + initContainers: + - name: wait-for-genesis + image: persistenceone/persistencecore:v10.4.0-fh + imagePullPolicy: Always + env: + - name: GENESIS_NODE_DATA_RESOLUTION_METHOD + valueFrom: + configMapKeyRef: + key: sync_node.resolution_method + name: firehose-node-config + - name: GENESIS_HOST + valueFrom: + configMapKeyRef: + key: sync_node.host + name: firehose-node-config + - name: GENESIS_PORT + valueFrom: + configMapKeyRef: + key: sync_node.exposer_port + name: firehose-node-config + command: + - bash + - "-c" + - | + # Do the following if the resolution method is dynamic else skip (we assume that in static configuration peer node is already up) + if [ "$GENESIS_NODE_DATA_RESOLUTION_METHOD" = "DYNAMIC" ]; then + while [ $(curl -sw '%{http_code}' http://$GENESIS_HOST:$GENESIS_PORT/node_id -o /dev/null) -ne 200 ]; do + echo "Genesis validator does not seem to be ready. Waiting for it to start..." + sleep 10; + done + fi + echo "Ready to start" + exit 0 + - name: init-firehose-node + image: persistenceone/persistencecore:v10.4.0-fh + imagePullPolicy: Always + env: + - name: CHAIN_ID + valueFrom: + configMapKeyRef: + key: chain.id + name: persistencecore + - name: HOME_DIR + value: /persistencecore + - name: GENESIS_HOST + valueFrom: + configMapKeyRef: + key: sync_node.host + name: firehose-node-config + # We support 2 types of resolution methods: (dynamic, static), if the resolution method is dynamic then we fetch the node id + # on the fly from the exposer app exposed service on the specified port, otherwise it is required that the node id is + # specified exactly as an environment variable + - name: GENESIS_NODE_DATA_RESOLUTION_METHOD + valueFrom: + configMapKeyRef: + key: sync_node.resolution_method + name: firehose-node-config + - name: GENESIS_EXPOSER_PORT + valueFrom: + configMapKeyRef: + key: sync_node.exposer_port + name: firehose-node-config + # This URL is used to fetch the genesis json if the NODE_DATA_RESOLUTION_METHOD is static + - name: GENESIS_JSON_FETCH_URL + valueFrom: + configMapKeyRef: + key: sync_node.genesis_json_fetch_url + name: firehose-node-config + - name: GENESIS_PORT_P2P + valueFrom: + configMapKeyRef: + key: sync_node.port_p2p + name: firehose-node-config + - name: STATE_RESTORE_SNAPSHOT_URL + value: 'https://persistence-snapshot.s3.us-west-1.amazonaws.com/core-1/2024-02-09/core-1_15293560.tar.lz4' + - name: SEEDS + valueFrom: + configMapKeyRef: + key: seeds + name: firehose-node-config + - name: PERSISTENT_PEERS + valueFrom: + configMapKeyRef: + key: persistent_peers + name: firehose-node-config + - name: FIRST_STREAMABLE_BLOCK + valueFrom: + configMapKeyRef: + key: first_streamable_block + name: firehose-node-config + - name: FORCE_INIT + value: 'true' + command: + - bash + - "-c" + - | + # Execute the initialization script for the firehose node + bash /scripts/init-firehose-node.sh + + echo "Installing firecosmos if not already installed" + + # Check if firecosmos is already installed + if [ ! -f /persistencecore/bin/firecosmos ]; then + # Download the firecosmos binary from the specified URL + wget https://github.com/figment-networks/firehose-cosmos/releases/download/v0.6.0/firecosmos_linux_amd64 -O firecosmos + # Make the downloaded binary executable + chmod +x firecosmos + # Create the directory for firecosmos if it doesn't exist + mkdir -p /persistencecore/bin + # Move the firecosmos binary to the appropriate directory + mv firecosmos /persistencecore/bin/firecosmos + fi + resources: + limits: + cpu: "0.5" + memory: "0.5G" + requests: + cpu: "0.5" + memory: "0.5G" + volumeMounts: + - mountPath: /persistencecore + name: node-pv-storage + - mountPath: /config-graph + name: config-graph + - mountPath: /scripts + name: scripts-graph + containers: + - name: firehose-node + image: persistenceone/persistencecore:v10.4.0-fh + imagePullPolicy: Always + env: + - name: CHAIN_ID + valueFrom: + configMapKeyRef: + key: chain.id + name: persistencecore + - name: HOME_DIR + value: /persistencecore + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + key: aws_access_key_id + name: firehose-node-aws-credentials + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + key: aws_secret_access_key + name: firehose-node-aws-credentials + - name: ONE_BLOCK_STORE_URL + valueFrom: + configMapKeyRef: + key: one_block_store_url + name: firehose-node-config + - name: MERGED_BLOCKS_STORE_URL + valueFrom: + configMapKeyRef: + key: merged_blocks_store_url + name: firehose-node-config + - name: FIRST_STREAMABLE_BLOCK + valueFrom: + configMapKeyRef: + key: first_streamable_block + name: firehose-node-config + command: + - bash + - "-c" + - | + sleep infinity + exec /persistencecore/bin/firecosmos start reader \ + --reader-mode node \ + --reader-node-path /usr/bin/persistenceCore \ + --reader-node-args "start --x-crisis-skip-assert-invariants --home /persistencecore" \ + --reader-node-logs-filter "module=(p2p|pex|consensus|x/bank|x/wasm)" \ + --common-first-streamable-block $FIRST_STREAMABLE_BLOCK \ + --common-one-block-store-url "$ONE_BLOCK_STORE_URL" \ + --common-merged-blocks-store-url "$MERGED_BLOCKS_STORE_URL" \ + --data-dir /fh-data + resources: + limits: + cpu: "1" + memory: "2G" + requests: + cpu: "1" + memory: "2G" + volumeMounts: + - mountPath: /persistencecore + name: node-pv-storage + - mountPath: /config-graph + name: config-graph + volumes: + - name: config-graph + configMap: + name: config-graph + - name: scripts-graph + configMap: + name: scripts-graph + volumeClaimTemplates: + - metadata: + name: node-pv-storage + spec: + storageClassName: do-block-storage + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 20Gi diff --git a/graph-node-alternate/overlays/multi-pod/kustomization.yaml b/graph-node-alternate/overlays/multi-pod/kustomization.yaml new file mode 100644 index 0000000..608156c --- /dev/null +++ b/graph-node-alternate/overlays/multi-pod/kustomization.yaml @@ -0,0 +1,7 @@ +resources: + - ../../base/ + - firehose-reader.yaml + - firehose-merger.yaml + - firehose-firehose.yaml + # - persistencecore-graph-node-2.yaml + # - firehose-resync.yaml \ No newline at end of file diff --git a/graph-node-alternate/overlays/one-pod/firehose.yaml b/graph-node-alternate/overlays/one-pod/firehose.yaml new file mode 100644 index 0000000..2fac908 --- /dev/null +++ b/graph-node-alternate/overlays/one-pod/firehose.yaml @@ -0,0 +1,260 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: persistencecore-firehose + labels: + app.kubernetes.io/name: persistencecore-firehose +spec: + clusterIP: None + ports: + - name: firehose + port: 9030 + protocol: TCP + targetPort: 9030 + - name: prometheus-node + port: 26660 + protocol: TCP + targetPort: 26660 + - name: prometheus-firehose + port: 9102 + protocol: TCP + targetPort: 9102 + selector: + app.kubernetes.io/name: persistencecore-firehose +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: persistencecore-firehose +spec: + serviceName: persistencecore-firehose + replicas: 1 + revisionHistoryLimit: 3 + selector: + matchLabels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/name: persistencecore-firehose + template: + metadata: + annotations: + quality: release + role: api-gateway + sla: high + tier: gateway + labels: + app.kubernetes.io/instance: persistencecore + app.kubernetes.io/type: persistencecore-firehose + app.kubernetes.io/name: persistencecore-firehose + app.kubernetes.io/version: '0.1' + spec: + terminationGracePeriodSeconds: 30 + initContainers: + - name: wait-for-genesis + image: betterpersist/persistencecore:v11.15.0-rc0-fh + imagePullPolicy: Always + env: + - name: GENESIS_NODE_DATA_RESOLUTION_METHOD + valueFrom: + configMapKeyRef: + key: sync_node.resolution_method + name: firehose-node-config + - name: GENESIS_HOST + valueFrom: + configMapKeyRef: + key: sync_node.host + name: firehose-node-config + - name: GENESIS_PORT + valueFrom: + configMapKeyRef: + key: sync_node.exposer_port + name: firehose-node-config + command: + - bash + - "-c" + - | + # Do the following if the resolution method is dynamic else skip (we assume that in static configuration peer node is already up) + if [ "$GENESIS_NODE_DATA_RESOLUTION_METHOD" = "DYNAMIC" ]; then + while [ $(curl -sw '%{http_code}' http://$GENESIS_HOST:$GENESIS_PORT/node_id -o /dev/null) -ne 200 ]; do + echo "Genesis validator does not seem to be ready. Waiting for it to start..." + sleep 10; + done + fi + echo "Ready to start" + exit 0 + - name: init-firehose-node + image: betterpersist/persistencecore:v11.1.0-rc0-fh + imagePullPolicy: Always + env: + - name: CHAIN_ID + valueFrom: + configMapKeyRef: + key: chain.id + name: persistencecore + - name: HOME_DIR + value: /persistencecore + - name: GENESIS_HOST + valueFrom: + configMapKeyRef: + key: sync_node.host + name: firehose-node-config + # We support 2 types of resolution methods: (dynamic, static), if the resolution method is dynamic then we fetch the node id + # on the fly from the exposer app exposed service on the specified port, otherwise it is required that the node id is + # specified exactly as an environment variable + - name: GENESIS_NODE_DATA_RESOLUTION_METHOD + valueFrom: + configMapKeyRef: + key: sync_node.resolution_method + name: firehose-node-config + - name: GENESIS_EXPOSER_PORT + valueFrom: + configMapKeyRef: + key: sync_node.exposer_port + name: firehose-node-config + # This URL is used to fetch the genesis json if the NODE_DATA_RESOLUTION_METHOD is static + - name: GENESIS_JSON_FETCH_URL + valueFrom: + configMapKeyRef: + key: sync_node.genesis_json_fetch_url + name: firehose-node-config + - name: GENESIS_PORT_P2P + valueFrom: + configMapKeyRef: + key: sync_node.port_p2p + name: firehose-node-config + - name: STATE_RESTORE_SNAPSHOT_URL + valueFrom: + configMapKeyRef: + key: snapshot_restore_url + name: firehose-node-config + - name: SEEDS + valueFrom: + configMapKeyRef: + key: seeds + name: firehose-node-config + - name: PERSISTENT_PEERS + valueFrom: + configMapKeyRef: + key: persistent_peers + name: firehose-node-config + - name: FIRST_STREAMABLE_BLOCK + valueFrom: + configMapKeyRef: + key: first_streamable_block + name: firehose-node-config + - name: FORCE_INIT + valueFrom: + configMapKeyRef: + key: force_init + name: firehose-node-config + command: + - bash + - "-c" + - | + bash /scripts/init-firehose-node.sh + + echo "Installing firecosmos if not already installed" + + # Install firecosmos if not already installed + if [ ! -f /persistencecore/bin/firecosmos ]; then + wget https://github.com/figment-networks/firehose-cosmos/releases/download/v0.6.0/firecosmos_linux_amd64 -O firecosmos + chmod +x firecosmos + mkdir -p /persistencecore/bin + mv firecosmos /persistencecore/bin/firecosmos + fi + resources: + limits: + cpu: "1" + memory: "1G" + requests: + cpu: "1" + memory: "1G" + volumeMounts: + - mountPath: /persistencecore + name: node-pv-storage + - mountPath: /config-graph + name: config-graph + - mountPath: /scripts + name: scripts-graph + containers: + - name: firehose-node + image: betterpersist/persistencecore:v11.15.0-rc0-fh + imagePullPolicy: Always + env: + - name: CHAIN_ID + valueFrom: + configMapKeyRef: + key: chain.id + name: persistencecore + - name: HOME_DIR + value: /persistencecore + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + key: aws_access_key_id + name: firehose-node-aws-credentials + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + key: aws_secret_access_key + name: firehose-node-aws-credentials + - name: ONE_BLOCK_STORE_URL + valueFrom: + configMapKeyRef: + key: one_block_store_url + name: firehose-node-config + - name: MERGED_BLOCKS_STORE_URL + valueFrom: + configMapKeyRef: + key: merged_blocks_store_url + name: firehose-node-config + - name: FIRST_STREAMABLE_BLOCK + valueFrom: + configMapKeyRef: + key: first_streamable_block + name: firehose-node-config + command: + - bash + - "-c" + - | + # sleep infinity + # exec /persistencecore/bin/firecosmos start reader \ + # exec /persistencecore/bin/firecosmos start merger \ + exec /persistencecore/bin/firecosmos start reader merger relayer firehose \ + --reader-mode node \ + --reader-node-path /usr/bin/persistenceCore \ + --reader-node-args "start --x-crisis-skip-assert-invariants --home /persistencecore" \ + --reader-node-logs-filter "module=(p2p|pex|consensus|x/bank|x/wasm)" \ + --common-first-streamable-block $FIRST_STREAMABLE_BLOCK \ + --common-one-block-store-url "$ONE_BLOCK_STORE_URL" \ + --common-merged-blocks-store-url "$MERGED_BLOCKS_STORE_URL" \ + --data-dir /fh-data + + resources: + limits: + cpu: "3" + memory: "7G" + requests: + cpu: "3" + memory: "7G" + volumeMounts: + - mountPath: /persistencecore + name: node-pv-storage + - mountPath: /config-graph + name: config-graph + volumes: + - name: config-graph + configMap: + name: config-graph + - name: scripts-graph + configMap: + name: scripts-graph + volumeClaimTemplates: + - metadata: + name: node-pv-storage + spec: + storageClassName: do-block-storage + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 100Gi diff --git a/graph-node-alternate/overlays/one-pod/kustomization.yaml b/graph-node-alternate/overlays/one-pod/kustomization.yaml new file mode 100644 index 0000000..ec103f6 --- /dev/null +++ b/graph-node-alternate/overlays/one-pod/kustomization.yaml @@ -0,0 +1,3 @@ +resources: + - ../../base/ + - firehose.yaml \ No newline at end of file diff --git a/graph-node/firehose-node.yaml b/graph-node/firehose-node.yaml index b45f0a8..e9dd7ff 100644 --- a/graph-node/firehose-node.yaml +++ b/graph-node/firehose-node.yaml @@ -55,7 +55,7 @@ spec: terminationGracePeriodSeconds: 10 initContainers: - name: wait-for-genesis - image: docker.io/persistenceone/persistencecore:v7.0.0-fh + image: persistenceone/persistencecore:v9.2.1-fh imagePullPolicy: Always env: - name: GENESIS_NODE_DATA_RESOLUTION_METHOD @@ -87,7 +87,7 @@ spec: echo "Ready to start" exit 0 - name: init-firehose-node - image: docker.io/persistenceone/persistencecore:v7.0.0-fh + image: persistenceone/persistencecore:v9.2.1-fh imagePullPolicy: Always env: - name: CHAIN_ID @@ -178,7 +178,7 @@ spec: name: scripts-graph containers: - name: firehose-node - image: docker.io/persistenceone/persistencecore:v7.0.0-fh + image: persistenceone/persistencecore:v9.2.1-fh imagePullPolicy: Always env: - name: CHAIN_ID @@ -188,6 +188,20 @@ spec: name: persistencecore - name: HOME_DIR value: /persistencecore + # command: + # - /persistencecore/bin/firecosmos + # args: + # - start + # - --config + # - /persistencecore/config/firehose.yml + # - --data-dir + # - /fh-data + # command: + # - persistenceCore + # args: + # - start + # - --home + # - /persistencecore command: - bash - "-c" @@ -220,3 +234,12 @@ spec: - name: scripts-graph configMap: name: scripts-graph + volumeClaimTemplates: + - metadata: + name: node-pv-storage + spec: + storageClassName: do-block-storage + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 90Gi diff --git a/graph-node/scripts/init-firehose-node.sh b/graph-node/scripts/init-firehose-node.sh index b829f3b..a4e8d1c 100644 --- a/graph-node/scripts/init-firehose-node.sh +++ b/graph-node/scripts/init-firehose-node.sh @@ -59,7 +59,7 @@ else fi echo "Adding extractor options in config.toml" - cat << END >> $HOME_DIR/config/config.toml +cat << END >> $HOME_DIR/config/config.toml ####################################################### ### Extractor Configuration Options ### ####################################################### diff --git a/networks/devnet/configmap.yaml b/networks/devnet/configmap.yaml index 0f46bcd..da2dc75 100644 --- a/networks/devnet/configmap.yaml +++ b/networks/devnet/configmap.yaml @@ -18,16 +18,18 @@ data: sync_node.genesis_json_fetch_url: '' snapshot_restore_url: '' seeds: '' - # For buffer time to sync the node - first_streamable_block: '300' + persistent_peers: '' + first_streamable_block: '50' force_init: 'false' + one_block_store_url: 's3://sgp1.digitaloceanspaces.com/dexter-zone/persistence-new/devnet/one-blocks?region=us-east-1' + merged_blocks_store_url: 's3://sgp1.digitaloceanspaces.com/dexter-zone/persistence-new/devnet/merged-blocks?region=us-east-1' --- apiVersion: v1 kind: ConfigMap metadata: name: graph-node-config data: - firehose_node.host: 'persistencecore-firehose-node.devnet.svc.cluster.local' + firehose_node.host: 'persistencecore-firehose.devnet.svc.cluster.local' firehose_node.port: '9030' ipfs.host: 'ipfs-node.devnet.svc.cluster.local' ipfs.port: '5001' \ No newline at end of file diff --git a/networks/devnet/ingress.yaml b/networks/devnet/ingress.yaml index 08fe968..1ae4a7a 100644 --- a/networks/devnet/ingress.yaml +++ b/networks/devnet/ingress.yaml @@ -108,4 +108,29 @@ spec: name: persistencecore-graph-node port: number: 8001 + ingressClassName: nginx +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-core-devnet-hasura + annotations: + nginx.ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/enable-cors: "true" +spec: + tls: + - secretName: cloudflare-tls + hosts: + - api.devnet.core.dexter.zone + rules: + - host: api.devnet.core.dexter.zone + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: persistencecore-hasura + port: + number: 8080 ingressClassName: nginx \ No newline at end of file diff --git a/networks/devnet/kustomization.yaml b/networks/devnet/kustomization.yaml index d3df580..b98ae34 100644 --- a/networks/devnet/kustomization.yaml +++ b/networks/devnet/kustomization.yaml @@ -4,4 +4,4 @@ resources: - ../../base/persistencecore - ingress.yaml - configmap.yaml - - ../../graph-node \ No newline at end of file + # - ../../graph-node-alternate/overlays/one-pod \ No newline at end of file diff --git a/networks/mainnet/configmap.yaml b/networks/mainnet/configmap.yaml index 2581764..83421e6 100644 --- a/networks/mainnet/configmap.yaml +++ b/networks/mainnet/configmap.yaml @@ -16,12 +16,13 @@ data: sync_node.exposer_port: '' sync_node.port_p2p: '26656' sync_node.genesis_json_fetch_url: 'https://raw.githubusercontent.com/persistenceOne/networks/master/core-1/final_genesis.json' - snapshot_restore_url: 'https://files.audit.one/persistence/snapshot/data_height_10522614.tar.lz4' - # seeds: 'fbf0aa94b512902a249b246ed5763b50df9c0543@seed.core.persistence.one:26656,ade4d8bc8cbe014af6ebdf3cb7b1e9ad36f412c0@seeds.polkachu.com:15456,ebc272824924ea1a27ea3183dd0b9ba713494f83@persistence-mainnet-seed.autostake.com:26896' - seeds: 'fbf0aa94b512902a249b246ed5763b50df9c0543@seed.core.persistence.one:26656' - # For buffer time to sync the node - first_streamable_block: '10522616' + snapshot_restore_url: 'https://persistence-chain-snapshots.s3.ap-south-1.amazonaws.com/core-1/2025-08-13/core-1_23301398.tar.lz4' + seeds: 'ade4d8bc8cbe014af6ebdf3cb7b1e9ad36f412c0@seeds.polkachu.com:15456' + persistent_peers: '' + first_streamable_block: '23794500' force_init: 'false' + one_block_store_url: 's3://sgp1.digitaloceanspaces.com/dexter-zone/persistence-new/one-blocks?region=us-east-1' + merged_blocks_store_url: 's3://sgp1.digitaloceanspaces.com/dexter-zone/persistence-new/merged-blocks?region=us-east-1' --- apiVersion: v1 @@ -29,7 +30,9 @@ kind: ConfigMap metadata: name: graph-node-config data: - firehose_node.host: 'persistencecore-firehose-node.graph-core-1.svc.cluster.local' + firehose_node.host: 'persistencecore-firehose.mainnet.svc.cluster.local' firehose_node.port: '9030' - ipfs.host: 'ipfs-node.graph-core-1.svc.cluster.local' - ipfs.port: '5001' \ No newline at end of file + ipfs.host: 'ipfs-node.mainnet.svc.cluster.local' + ipfs.port: '5001' + babylon_substreams.host: '159.89.170.65' + babylon_substreams.port: '10016' \ No newline at end of file diff --git a/networks/mainnet/ingress.yaml b/networks/mainnet/ingress.yaml index c52070a..64e9118 100644 --- a/networks/mainnet/ingress.yaml +++ b/networks/mainnet/ingress.yaml @@ -1,23 +1,205 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: ingress-graph-mainnet-persistence + name: ingress-core-mainnet-graph annotations: nginx.ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/enable-cors: "true" + nginx.org/websocket-services: "persistencecore-graph-node" + nginx.ingress.kubernetes.io/rewrite-target: /$2 spec: tls: - - secretName: cloudflare-tls + - secretName: cloudflare-tls-persistence hosts: - - graph.mainnet.persistence.one + - graph.dex.persistence.one rules: - - host: graph.mainnet.persistence.one + - host: graph.dex.persistence.one http: paths: - - path: / + - path: /()(.*) + pathType: Prefix + backend: + service: + name: persistencecore-graph-node + port: + number: 8000 + - path: /ws(/|$)(.*) pathType: Prefix backend: service: name: persistencecore-graph-node + port: + number: 8001 + ingressClassName: nginx +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-core-mainnet-firehose-substreams + annotations: + nginx.ingress.kubernetes.io/backend-protocol: "GRPC" + nginx.ingress.kubernetes.io/ssl-redirect: "true" +spec: + tls: + - secretName: cloudflare-tls-persistence + hosts: + - substreams.core.persistence.one + - firehose.core.persistence.one + rules: + - host: substreams.core.persistence.one + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: persistencecore-firehose + port: + number: 10016 + - host: firehose.core.persistence.one + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: persistencecore-firehose + port: + number: 10015 + ingressClassName: nginx +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-core-mainnet-graph-new + annotations: + nginx.ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/enable-cors: "true" + nginx.org/websocket-services: "persistencecore-graph-new" + nginx.ingress.kubernetes.io/rewrite-target: /$2 +spec: + tls: + - secretName: cloudflare-tls-persistence + hosts: + - graph-new.dex.persistence.one + rules: + - host: graph-new.dex.persistence.one + http: + paths: + - path: /()(.*) + pathType: Prefix + backend: + service: + name: persistencecore-graph-node-v037 port: number: 8000 - ingressClassName: nginx \ No newline at end of file + - path: /ws(/|$)(.*) + pathType: Prefix + backend: + service: + name: persistencecore-graph-node-v037 + port: + number: 8001 + ingressClassName: nginx +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-core-mainnet-hasura + annotations: + nginx.ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/enable-cors: "true" +spec: + tls: + - secretName: cloudflare-tls-persistence + hosts: + - api.dex.persistence.one + rules: + - host: api.dex.persistence.one + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: dexter-hasura + port: + number: 8080 + ingressClassName: nginx + +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-core-mainnet-hasura-dexter-base-old + annotations: + nginx.ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/enable-cors: "true" +spec: + tls: + - secretName: cloudflare-tls + hosts: + - api.core-1.dexter.zone + rules: + - host: api.core-1.dexter.zone + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: dexter-hasura + port: + number: 8080 + ingressClassName: nginx +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-core-mainnet-hasura-dexter-base-old-next + annotations: + nginx.ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/enable-cors: "true" +spec: + tls: + - secretName: cloudflare-tls + hosts: + - api-next.core-1.dexter.zone + rules: + - host: api-next.core-1.dexter.zone + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: dexter-hasura + port: + number: 8080 + ingressClassName: nginx +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-core-mainnet-hasura-dexter-base-old-api2 + annotations: + nginx.ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/enable-cors: "true" +spec: + tls: + - secretName: cloudflare-tls + hosts: + - api2.core-1.dexter.zone + rules: + - host: api2.core-1.dexter.zone + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: dexter-hasura + port: + number: 8080 + ingressClassName: nginx + diff --git a/networks/mainnet/kustomization.yaml b/networks/mainnet/kustomization.yaml index e939d80..2983d49 100644 --- a/networks/mainnet/kustomization.yaml +++ b/networks/mainnet/kustomization.yaml @@ -1,6 +1,6 @@ -namespace: graph-core-1 +namespace: mainnet resources: - ingress.yaml - - ../../graph-node + - ../../graph-node-alternate/overlays/multi-pod - configmap.yaml \ No newline at end of file diff --git a/networks/testnet/configmap.yaml b/networks/testnet/configmap.yaml index 84086c4..1b78085 100644 --- a/networks/testnet/configmap.yaml +++ b/networks/testnet/configmap.yaml @@ -3,7 +3,7 @@ kind: ConfigMap metadata: name: persistencecore data: - chain.id: test-core-1 + chain.id: test-core-2 --- apiVersion: v1 @@ -15,20 +15,22 @@ data: sync_node.host: '' sync_node.exposer_port: '' sync_node.port_p2p: '26656' - sync_node.genesis_json_fetch_url: 'https://raw.githubusercontent.com/persistenceOne/networks/master/test-core-1/final_genesis.json' - snapshot_restore_url: 'https://nevermore.sgp1.digitaloceanspaces.com/persistence%2Fsnapshot%2Ftestnet%2Ftestnet_10750519.tar.lz4' - seeds: 'b4237f8a7ca357d380ad119b76cbceec7e7e8a75@seed.testnet.persistence.one:26656' + sync_node.genesis_json_fetch_url: https://raw.githubusercontent.com/persistenceOne/networks/master/test-core-2/genesis.json + snapshot_restore_url: https://persistence-snapshot.s3.us-west-1.amazonaws.com/test-core-2/2024-09-27/test-core-2_7527939.tar.lz4 + seeds: '3ce04530d850e727d092e9a81d9f580c7ff8db56@141.94.97.77:26656' + persistent_peers: '3ce04530d850e727d092e9a81d9f580c7ff8db56@141.94.97.77:26656,3f0918801adf0ea1d17bef501e2583a5539f5cd9@65.21.126.182:26656,8eb88b7edf912ac9d63b183b42823f220a3fc226@65.108.192.123:48656,98f6fc6560ebec5a1d2099ecf91213b53575ec81@65.21.77.175:11006,ee239d2498bd073968e774887f813ac1fd4e50b3@95.216.242.183:26656,0134c0a888ab07d67c4a41afcb103b76266fb0e7@65.21.202.61:11006,f6ef633ef1caa621f3f4bea7a7ef31463fc9a43e@95.216.184.59:26656,591ceb144a142275ac3e51ed310aa1b6eb04e20c@217.76.48.63:38556,9b341b2b1d6d453a79c911ad7b2d032e117184cf@136.243.105.228:26656,b2f036bfa207249363ea2ac935e6bed3d4c10dbd@37.252.184.239:26656,2dd629fc08c97061c64f15f934c1c368565870d6@217.76.53.18:36656,7fd0511997417324ab46ac85a935d89998d1e4e2@94.130.76.179:26656,c3e785f853677ad3677542f9e2679a20957ca104@217.76.61.200:26756,47d24380223603552fa3b981239617df8bf58902@185.225.233.30:26656,cee6b94965f301e8b5ad905a65fa39c03cd193ce@51.68.152.17:26656,990269572d9075777f98460e35fa57d6665fac9d@94.130.132.227:2130,428b57bad52f71845fc6f359c49bdbc39eb22d99@195.14.6.2:26656,21ca0b996db604681fb73721ecb01d2c6410c628@162.19.94.46:26656,30859d0fb31dd08894ba15ac90bf020b26ba5890@23.88.53.28:56666,ac80febd6313b39e70d3e5ed50afddc491d79258@195.189.96.111:31656,82e69659bef9c385b4934727f43d69a673f6f033@5.161.191.128:26656,762c339b3f7626b9ebcfe7286f1e133eec587164@65.108.98.235:58556,49d98497f4922217829d0aff65bfb68cce715677@192.248.177.214:26656,fc86e4edef908edc6699bbecdf568cc7743d8d07@125.143.190.194:13002,7f971fc5fc2ffedbaf32f3b4021645571461a712@198.244.177.67:26656,9551e08e22f13ee6dc769731cd131d59f9731332@65.108.79.246:26706,5c2a752c9b1952dbed075c56c600c3a79b58c395@195.3.220.54:26896,8de0a3e97190d24b75736a2db6ebc107aeaafce8@93.115.25.18:31656,20b4f9207cdc9d0310399f848f057621f7251846@222.106.187.13:20800,2585af35660dcfb0a02dd8bc2e766d11f5603f99@73.117.148.143:26656,40f63c75b6afe61e74af428cc669eb481089a587@65.108.225.158:15456,23ae7c78081becdfe16af99329337920beafa2b2@167.235.115.119:26656' # For buffer time to sync the node - first_streamable_block: '10750521' + first_streamable_block: '60000' force_init: 'false' - + one_block_store_url: 's3://sgp1.digitaloceanspaces.com/dexter-zone/persistence-new/testnet/one-blocks?region=us-east-1' + merged_blocks_store_url: 's3://sgp1.digitaloceanspaces.com/dexter-zone/persistence-new/testnet/merged-blocks?region=us-east-1' --- apiVersion: v1 kind: ConfigMap metadata: name: graph-node-config data: - firehose_node.host: 'persistencecore-firehose-node.graph-test-core-1.svc.cluster.local' + firehose_node.host: 'persistencecore-firehose.testnet.svc.cluster.local' firehose_node.port: '9030' - ipfs.host: 'ipfs-node.graph-test-core-1.svc.cluster.local' + ipfs.host: 'ipfs-node.testnet.svc.cluster.local' ipfs.port: '5001' \ No newline at end of file diff --git a/networks/testnet/ingress.yaml b/networks/testnet/ingress.yaml index 688b2e7..c144aaa 100644 --- a/networks/testnet/ingress.yaml +++ b/networks/testnet/ingress.yaml @@ -1,23 +1,33 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: ingress-graph-testnet-persistence + name: ingress-core-testnet-graph annotations: nginx.ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/enable-cors: "true" + nginx.org/websocket-services: "persistencecore-graph-node" + nginx.ingress.kubernetes.io/rewrite-target: /$2 spec: tls: - - secretName: cloudflare-tls-graph-testnet + - secretName: cloudflare-tls hosts: - - graph.testnet.persistence.one + - graph.testnet.dexter.zone rules: - - host: graph.testnet.persistence.one + - host: graph.testnet.dexter.zone http: paths: - - path: / + - path: /()(.*) pathType: Prefix backend: service: name: persistencecore-graph-node port: number: 8000 + - path: /ws(/|$)(.*) + pathType: Prefix + backend: + service: + name: persistencecore-graph-node + port: + number: 8001 ingressClassName: nginx \ No newline at end of file diff --git a/networks/testnet/kustomization.yaml b/networks/testnet/kustomization.yaml index fe8ddc4..3732531 100644 --- a/networks/testnet/kustomization.yaml +++ b/networks/testnet/kustomization.yaml @@ -1,6 +1,6 @@ -namespace: graph-test-core-1 +namespace: testnet resources: - ingress.yaml - - ../../graph-node - - configmap.yaml \ No newline at end of file + - configmap.yaml + - ../../graph-node-alternate/overlays/one-pod \ No newline at end of file diff --git a/run-babylon-local.sh b/run-babylon-local.sh new file mode 100644 index 0000000..b5236ef --- /dev/null +++ b/run-babylon-local.sh @@ -0,0 +1,103 @@ +#!/bin/bash +set -e + +# Colors for better output +GREEN='\033[0;32m' +BLUE='\033[0;34m' +RED='\033[0;31m' +NC='\033[0m' # No Color + +echo -e "${BLUE}Setting up local Graph Node for Babylon chain debugging${NC}" + +# PostgreSQL configuration +DB_NAME="graph_node_babylon" +DB_USER="postgres" +DB_PASSWORD="postgres" +DB_HOST="localhost" +DB_PORT="5432" + +# Check if PostgreSQL is running +if ! pg_isready -h $DB_HOST -p $DB_PORT > /dev/null 2>&1; then + echo -e "${RED}Error: PostgreSQL is not running on $DB_HOST:$DB_PORT${NC}" + echo "Please make sure PostgreSQL is installed and running." + echo "You can install it with:" + echo " brew install postgresql@14" + echo " brew services start postgresql@14" + exit 1 +fi + +# Create database if it doesn't exist +if ! psql -h $DB_HOST -p $DB_PORT -U $DB_USER -lqt | cut -d \| -f 1 | grep -qw $DB_NAME; then + echo -e "${BLUE}Creating database '$DB_NAME'...${NC}" + createdb -h $DB_HOST -p $DB_PORT -U $DB_USER $DB_NAME + echo -e "${GREEN}Database created successfully!${NC}" +else + echo -e "${GREEN}Database '$DB_NAME' already exists${NC}" +fi + +# Create config directory +CONFIG_DIR="./babylon-graph-node-config" +mkdir -p $CONFIG_DIR + +# Create config file for Graph Node +CONFIG_FILE="$CONFIG_DIR/config.toml" +echo -e "${BLUE}Creating Graph Node configuration file...${NC}" +cat > $CONFIG_FILE << EOF +[deployment] +[[deployment.rule]] +shard = "primary" +indexers = [ "index_node_cosmos_1" ] + +[store] +[store.primary] +connection = "postgresql://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME" +pool_size = 10 + +[chains] +ingestor = "block_ingestor_node" + +[chains.babylon] +shard = "primary" +protocol = "substreams" +provider = [ + { label = "babylon", details = { type = "substreams", url = "http://159.89.170.65:10016" }}, +] +EOF + +echo -e "${GREEN}Configuration file created at $CONFIG_FILE${NC}" +echo "Contents of the configuration file:" +cat $CONFIG_FILE + +# Check if graph-node is installed +if ! command -v graph-node &> /dev/null; then + echo -e "${BLUE}Graph Node binary not found${NC}" + echo "Please install Graph Node from source:" + echo " git clone https://github.com/graphprotocol/graph-node.git" + echo " cd graph-node" + echo " cargo build --release" + echo " Add the binary to your PATH or provide the full path below" + + read -p "Enter the path to the graph-node binary or press Enter to exit: " GRAPH_NODE_PATH + + if [ -z "$GRAPH_NODE_PATH" ]; then + echo -e "${RED}No path provided. Exiting.${NC}" + exit 1 + fi + + if [ ! -f "$GRAPH_NODE_PATH" ]; then + echo -e "${RED}Invalid path. File does not exist. Exiting.${NC}" + exit 1 + fi +else + GRAPH_NODE_PATH="graph-node" +fi + +# Run Graph Node +echo -e "${BLUE}Starting Graph Node for Babylon chain...${NC}" +echo "Press Ctrl+C to stop" + +$GRAPH_NODE_PATH \ + --config $CONFIG_FILE \ + --node-id index_node_cosmos_1 + +echo -e "${GREEN}Graph Node stopped${NC}" \ No newline at end of file