mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
@@ -0,0 +1,18 @@
|
||||
[tool.commitizen]
|
||||
name = "cz_customize"
|
||||
tag_format = "snrd/v$version"
|
||||
ignored_tag_formats = ["*/v${version}", "v${version}"]
|
||||
version_scheme = "semver"
|
||||
version_provider = "scm"
|
||||
update_changelog_on_bump = true
|
||||
changelog_file = "CHANGELOG.md"
|
||||
major_version_zero = true
|
||||
annotated_tag = true
|
||||
pre_bump_hooks = ["bash scripts/hook-bump-pre.sh"]
|
||||
post_bump_hooks = ["goreleaser release --clean -f cmd/snrd/.goreleaser.yml"]
|
||||
|
||||
[tool.commitizen.customize]
|
||||
bump_pattern = "^(feat|fix|refactor|perf|BREAKING CHANGE)"
|
||||
bump_map = { "BREAKING CHANGE" = "MAJOR", "feat" = "MINOR", "fix" = "PATCH", "refactor" = "PATCH", "perf" = "PATCH" }
|
||||
default_bump = "PATCH"
|
||||
changelog_pattern = "^(feat|fix|refactor|docs|build)\\(core\\)(!)?:"
|
||||
@@ -0,0 +1,263 @@
|
||||
# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
|
||||
---
|
||||
version: 2
|
||||
dist: dist/snrd
|
||||
monorepo:
|
||||
tag_prefix: snrd/
|
||||
|
||||
project_name: snrd
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- go mod download
|
||||
|
||||
builds:
|
||||
# Darwin AMD64 Build
|
||||
- id: snrd-darwin-amd64
|
||||
main: ./cmd/snrd
|
||||
binary: snrd
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=o64-clang
|
||||
- CXX=o64-clang++
|
||||
- CGO_LDFLAGS=-lm
|
||||
goos:
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
flags:
|
||||
- -mod=readonly
|
||||
- -trimpath
|
||||
ldflags:
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Name=sonr
|
||||
- -X github.com/cosmos/cosmos-sdk/version.AppName=snrd
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}}
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
|
||||
- -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger"
|
||||
- -s -w
|
||||
tags:
|
||||
- netgo
|
||||
- ledger
|
||||
|
||||
# Darwin ARM64 Build
|
||||
- id: snrd-darwin-arm64
|
||||
main: ./cmd/snrd
|
||||
binary: snrd
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=oa64-clang
|
||||
- CXX=oa64-clang++
|
||||
- CGO_LDFLAGS=-lm
|
||||
goos:
|
||||
- darwin
|
||||
goarch:
|
||||
- arm64
|
||||
flags:
|
||||
- -mod=readonly
|
||||
- -trimpath
|
||||
ldflags:
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Name=sonr
|
||||
- -X github.com/cosmos/cosmos-sdk/version.AppName=snrd
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}}
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
|
||||
- -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger"
|
||||
- -s -w
|
||||
tags:
|
||||
- netgo
|
||||
- ledger
|
||||
|
||||
# Linux AMD64 Build
|
||||
- id: snrd-linux-amd64
|
||||
main: ./cmd/snrd
|
||||
binary: snrd
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=x86_64-linux-gnu-gcc
|
||||
- CXX=x86_64-linux-gnu-g++
|
||||
- CGO_LDFLAGS=-lm
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- amd64
|
||||
goamd64:
|
||||
- v1
|
||||
flags:
|
||||
- -mod=readonly
|
||||
- -trimpath
|
||||
ldflags:
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Name=sonr
|
||||
- -X github.com/cosmos/cosmos-sdk/version.AppName=snrd
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}}
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
|
||||
- -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger"
|
||||
- -s -w
|
||||
tags:
|
||||
- netgo
|
||||
- ledger
|
||||
|
||||
# Linux ARM64 Build
|
||||
- id: snrd-linux-arm64
|
||||
main: ./cmd/snrd
|
||||
binary: snrd
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=aarch64-linux-gnu-gcc
|
||||
- CXX=aarch64-linux-gnu-g++
|
||||
- CGO_LDFLAGS=-lm
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- arm64
|
||||
flags:
|
||||
- -mod=readonly
|
||||
- -trimpath
|
||||
ldflags:
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Name=sonr
|
||||
- -X github.com/cosmos/cosmos-sdk/version.AppName=snrd
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}}
|
||||
- -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
|
||||
- -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger"
|
||||
- -s -w
|
||||
tags:
|
||||
- netgo
|
||||
- ledger
|
||||
|
||||
aurs:
|
||||
- name: snrd-bin
|
||||
disable: true
|
||||
homepage: "https://sonr.io"
|
||||
description: "Sonr blockchain daemon - decentralized identity and data storage network"
|
||||
maintainers:
|
||||
- "Sonr <support@sonr.io>"
|
||||
license: "Apache-2.0"
|
||||
private_key: "{{ .Env.AUR_KEY }}"
|
||||
git_url: "ssh://[email protected]/snrd-bin.git"
|
||||
skip_upload: auto
|
||||
provides:
|
||||
- snrd
|
||||
conflicts:
|
||||
- snrd
|
||||
commit_msg_template: "Update to {{ .Tag }}"
|
||||
commit_author:
|
||||
name: goreleaserbot
|
||||
email: "prad@sonr.io"
|
||||
package: |-
|
||||
# bin
|
||||
install -Dm755 "./snrd" "${pkgdir}/usr/bin/snrd"
|
||||
|
||||
# license
|
||||
if [ -f "./LICENSE" ]; then
|
||||
install -Dm644 "./LICENSE" "${pkgdir}/usr/share/licenses/snrd-bin/LICENSE"
|
||||
fi
|
||||
|
||||
# readme
|
||||
if [ -f "./README.md" ]; then
|
||||
install -Dm644 "./README.md" "${pkgdir}/usr/share/doc/snrd-bin/README.md"
|
||||
fi
|
||||
|
||||
# systemd service (if exists)
|
||||
if [ -f "./snrd.service" ]; then
|
||||
install -Dm644 "./snrd.service" "${pkgdir}/usr/lib/systemd/system/snrd.service"
|
||||
fi
|
||||
|
||||
# config directory
|
||||
install -dm755 "${pkgdir}/etc/snrd"
|
||||
install -dm755 "${pkgdir}/var/lib/snrd"
|
||||
backup:
|
||||
- /etc/snrd/config.toml
|
||||
- /etc/snrd/app.toml
|
||||
|
||||
nix:
|
||||
- name: snrd
|
||||
ids:
|
||||
- snrd
|
||||
homepage: "https://sonr.io"
|
||||
description: "Sonr blockchain daemon - decentralized identity network"
|
||||
license: "gpl3Plus"
|
||||
path: pkgs/snrd/default.nix
|
||||
commit_msg_template: "snrd: {{ .Tag }}"
|
||||
dependencies:
|
||||
- glibc
|
||||
- stdenv.cc.cc.lib
|
||||
repository:
|
||||
owner: sonr-io
|
||||
name: nur
|
||||
branch: main
|
||||
token: "{{ .Env.GITHUB_TOKEN }}"
|
||||
|
||||
archives:
|
||||
- id: snrd
|
||||
ids:
|
||||
- snrd-linux-amd64
|
||||
- snrd-linux-arm64
|
||||
- snrd-darwin-amd64
|
||||
- snrd-darwin-arm64
|
||||
name_template: >-
|
||||
snrd_{{ .Os }}_{{- if eq .Arch "amd64" }}x86_64 {{- else if eq .Arch "386" }}i386 {{- else }}{{ .Arch }}{{ end }}
|
||||
formats: ["tar.gz"]
|
||||
files:
|
||||
- src: README*
|
||||
wrap_in_directory: false
|
||||
|
||||
nfpms:
|
||||
- id: snrd
|
||||
package_name: snrd
|
||||
ids:
|
||||
- snrd-linux-amd64
|
||||
- snrd-linux-arm64
|
||||
file_name_template: "snrd_{{ .Os }}_{{ .Arch }}{{ .ConventionalExtension }}"
|
||||
vendor: Sonr
|
||||
homepage: "https://sonr.io"
|
||||
maintainer: "Sonr <support@sonr.io>"
|
||||
description: "Sonr is a decentralized, permissionless, and censorship-resistant identity network."
|
||||
license: "Apache 2.0"
|
||||
formats:
|
||||
- rpm
|
||||
- deb
|
||||
- apk
|
||||
- archlinux
|
||||
contents:
|
||||
- src: README*
|
||||
dst: /usr/share/doc/snrd
|
||||
bindir: /usr/bin
|
||||
section: net
|
||||
priority: optional
|
||||
|
||||
blobs:
|
||||
- provider: s3
|
||||
endpoint: https://eb37925850388bca807b7fab964c12bb.r2.cloudflarestorage.com
|
||||
bucket: releases
|
||||
region: auto
|
||||
directory: "snrd/{{ .Tag }}"
|
||||
ids:
|
||||
- snrd
|
||||
|
||||
release:
|
||||
disable: false
|
||||
github:
|
||||
owner: sonr-io
|
||||
name: sonr
|
||||
name_template: "{{.ProjectName}}/{{ .Tag }}"
|
||||
draft: false
|
||||
replace_existing_draft: false # Don't replace drafts
|
||||
replace_existing_artifacts: false # Append, don't replace
|
||||
mode: append # Explicitly set to append mode
|
||||
|
||||
checksum:
|
||||
name_template: "snrd_checksums.txt"
|
||||
|
||||
snapshot:
|
||||
version_template: "{{ incpatch .Version }}-dev"
|
||||
|
||||
# Changelog configuration
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- "^docs:"
|
||||
- "^test:"
|
||||
- "^chore:"
|
||||
@@ -0,0 +1,89 @@
|
||||
# Use build argument for base image to allow using pre-cached base
|
||||
ARG BASE_IMAGE=golang:1.24.7-alpine3.22
|
||||
|
||||
FROM ${BASE_IMAGE} AS builder
|
||||
SHELL ["/bin/sh", "-ecuxo", "pipefail"]
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache \
|
||||
ca-certificates \
|
||||
build-base \
|
||||
git \
|
||||
linux-headers \
|
||||
bash \
|
||||
binutils-gold \
|
||||
wget
|
||||
|
||||
WORKDIR /code
|
||||
|
||||
# Copy entire source code (including crypto module)
|
||||
COPY . .
|
||||
|
||||
# Fix git ownership issue
|
||||
RUN git config --global --add safe.directory /code
|
||||
|
||||
# Download WasmVM library
|
||||
RUN --mount=type=cache,target=/tmp/wasmvm \
|
||||
set -eux; \
|
||||
export ARCH=$(uname -m); \
|
||||
WASM_VERSION=$(go list -m all | grep github.com/CosmWasm/wasmvm | head -1 || echo ""); \
|
||||
if [ ! -z "${WASM_VERSION}" ]; then \
|
||||
WASMVM_REPO=$(echo $WASM_VERSION | awk '{print $1}'); \
|
||||
WASMVM_VERS=$(echo $WASM_VERSION | awk '{print $2}'); \
|
||||
WASMVM_FILE="libwasmvm_muslc.${ARCH}.a"; \
|
||||
if [ ! -f "/tmp/wasmvm/${WASMVM_FILE}" ]; then \
|
||||
wget -O "/tmp/wasmvm/${WASMVM_FILE}" "https://${WASMVM_REPO}/releases/download/${WASMVM_VERS}/${WASMVM_FILE}"; \
|
||||
fi; \
|
||||
cp "/tmp/wasmvm/${WASMVM_FILE}" /lib/libwasmvm_muslc.a; \
|
||||
fi
|
||||
|
||||
# Download Go modules
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
go mod download
|
||||
|
||||
# Build binary with optimizations
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
set -eux; \
|
||||
VERSION=$(git describe --tags --always 2>/dev/null || echo "dev"); \
|
||||
COMMIT=$(git log -1 --format='%H' 2>/dev/null || echo "unknown"); \
|
||||
LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true \
|
||||
CGO_ENABLED=1 GOOS=linux \
|
||||
go build \
|
||||
-mod=readonly \
|
||||
-tags "netgo,ledger,muslc" \
|
||||
-ldflags "-X github.com/cosmos/cosmos-sdk/version.Name=sonr \
|
||||
-X github.com/cosmos/cosmos-sdk/version.AppName=snrd \
|
||||
-X github.com/cosmos/cosmos-sdk/version.Version=${VERSION} \
|
||||
-X github.com/cosmos/cosmos-sdk/version.Commit=${COMMIT} \
|
||||
-X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc \
|
||||
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \
|
||||
-buildvcs=false \
|
||||
-trimpath \
|
||||
-o /code/build/snrd \
|
||||
./cmd/snrd; \
|
||||
file /code/build/snrd; \
|
||||
echo "Ensuring binary is statically linked ..."; \
|
||||
(file /code/build/snrd | grep "statically linked")
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Final minimal runtime image
|
||||
FROM alpine:3.17
|
||||
|
||||
LABEL org.opencontainers.image.title="Sonr Daemon"
|
||||
LABEL org.opencontainers.image.source="https://github.com/sonr-io/sonr"
|
||||
|
||||
# Copy binary from build stage
|
||||
COPY --from=builder /code/build/snrd /usr/bin
|
||||
COPY --from=builder /lib/libwasmvm_muslc.a /lib/libwasmvm_muslc.a
|
||||
COPY --from=builder /code/scripts/test_node.sh /usr/bin/testnet
|
||||
RUN chmod +x /usr/bin/testnet
|
||||
|
||||
# Set up dependencies
|
||||
ENV PACKAGES="curl make bash jq sed"
|
||||
|
||||
# Install minimum necessary dependencies
|
||||
RUN apk add --no-cache $PACKAGES
|
||||
|
||||
WORKDIR /opt
|
||||
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
# Version and build information
|
||||
GIT_ROOT := $(shell git rev-parse --show-toplevel)
|
||||
VERSION := $(shell echo $(shell git describe --tags 2>/dev/null || echo "dev") | sed 's/^v//')
|
||||
COMMIT := $(shell git log -1 --format='%H')
|
||||
LEDGER_ENABLED ?= true
|
||||
|
||||
# Build tags configuration
|
||||
build_tags = netgo
|
||||
ifeq ($(LEDGER_ENABLED),true)
|
||||
ifeq ($(OS),Windows_NT)
|
||||
GCCEXE = $(shell where gcc.exe 2> NUL)
|
||||
ifeq ($(GCCEXE),)
|
||||
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
|
||||
else
|
||||
build_tags += ledger
|
||||
endif
|
||||
else
|
||||
UNAME_S = $(shell uname -s)
|
||||
ifeq ($(UNAME_S),OpenBSD)
|
||||
$(warning OpenBSD detected, disabling ledger support)
|
||||
else
|
||||
GCC = $(shell command -v gcc 2> /dev/null)
|
||||
ifeq ($(GCC),)
|
||||
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
|
||||
else
|
||||
build_tags += ledger
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(WITH_CLEVELDB),yes)
|
||||
build_tags += gcc
|
||||
endif
|
||||
build_tags += $(BUILD_TAGS)
|
||||
build_tags := $(strip $(build_tags))
|
||||
|
||||
whitespace :=
|
||||
empty = $(whitespace) $(whitespace)
|
||||
comma := ,
|
||||
build_tags_comma_sep := $(subst $(empty),$(comma),$(build_tags))
|
||||
|
||||
# Linker flags configuration
|
||||
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sonr \
|
||||
-X github.com/cosmos/cosmos-sdk/version.AppName=snrd \
|
||||
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
|
||||
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
|
||||
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
|
||||
-checklinkname=0 \
|
||||
-s -w
|
||||
|
||||
ifeq ($(WITH_CLEVELDB),yes)
|
||||
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
|
||||
endif
|
||||
ifeq ($(LINK_STATICALLY),true)
|
||||
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
|
||||
endif
|
||||
ldflags += $(LDFLAGS)
|
||||
ldflags := $(strip $(ldflags))
|
||||
|
||||
BUILD_FLAGS := -tags "$(build_tags_comma_sep)" -ldflags '$(ldflags)' -trimpath
|
||||
|
||||
# Build vault WASM module (required dependency)
|
||||
VAULT_ROOT := $(GIT_ROOT)/cmd/vault
|
||||
VAULT_OUT := $(GIT_ROOT)/x/dwn/client/plugin/vault.wasm
|
||||
SNRD_OUT := $(GIT_ROOT)/build/snrd
|
||||
SNRD_EXE_OUT := $(GIT_ROOT)/build/snrd.exe
|
||||
|
||||
.PHONY: all build install clean vault version help docker
|
||||
|
||||
all: build
|
||||
|
||||
build:
|
||||
ifeq ($(OS),Windows_NT)
|
||||
GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o $(SNRD_EXE_OUT) .
|
||||
else
|
||||
@echo "Building snrd binary..."
|
||||
@CGO_LDFLAGS="-lm" go build -mod=readonly $(BUILD_FLAGS) -o $(SNRD_OUT) .
|
||||
@echo "Binary built: ../../build/snrd"
|
||||
endif
|
||||
|
||||
install:
|
||||
@$(MAKE) -C $(VAULT_ROOT) build
|
||||
ifeq ($(OS),Windows_NT)
|
||||
@echo "Building snrd.exe for Windows..."
|
||||
GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o $(SNRD_EXE_OUT) .
|
||||
else
|
||||
@echo "Installing snrd binary..."
|
||||
@CGO_LDFLAGS="-lm" go install -mod=readonly $(BUILD_FLAGS) .
|
||||
@echo "Binary installed to $(GOPATH)/bin/snrd"
|
||||
endif
|
||||
|
||||
clean:
|
||||
@echo "Cleaning build artifacts..."
|
||||
@rm -f $(SNRD_OUT) $(SNRD_EXE_OUT)
|
||||
@$(MAKE) -C $(VAULT_ROOT) clean
|
||||
@echo "Clean complete"
|
||||
|
||||
version:
|
||||
@echo "Version: $(VERSION)"
|
||||
@echo "Commit: $(COMMIT)"
|
||||
@echo "Build tags: $(build_tags_comma_sep)"
|
||||
|
||||
test:
|
||||
@echo "Running snrd tests..."
|
||||
@go test -v ./...
|
||||
|
||||
release:
|
||||
@echo "Creating snrd release..."
|
||||
@cd $(GIT_ROOT) && cz --config cmd/snrd/.cz.toml --no-raise 6,21 bump --yes --increment PATCH
|
||||
|
||||
snapshot:
|
||||
@echo "Dry-Run Bumping snrd version..."
|
||||
@cd $(GIT_ROOT) && cz --config cmd/snrd/.cz.toml bump --yes --dry-run --no-verify --increment PATCH
|
||||
@echo "Creating snrd snapshots for all platforms..."
|
||||
@cd $(GIT_ROOT) && goreleaser release --snapshot --clean -f cmd/snrd/.goreleaser.yml
|
||||
|
||||
# Docker build targets
|
||||
docker:
|
||||
@echo "Building snrd Docker image..."
|
||||
@docker build -f Dockerfile -t onsonr/snrd:latest -t ghcr.io/sonr-io/snrd:latest ../..
|
||||
@echo "Docker image built and tagged:"
|
||||
@echo " - onsonr/snrd:latest"
|
||||
@echo " - ghcr.io/sonr-io/snrd:latest"
|
||||
|
||||
docker-local:
|
||||
@echo "Building snrd Docker image with local context..."
|
||||
@docker build -f Dockerfile -t onsonr/snrd:local -t ghcr.io/sonr-io/snrd:local ../..
|
||||
@echo "Docker image built and tagged:"
|
||||
@echo " - onsonr/snrd:local"
|
||||
@echo " - ghcr.io/sonr-io/snrd:local"
|
||||
|
||||
link-wasmvm:
|
||||
@echo "Downloading WasmVM libraries..."
|
||||
@mkdir -p build
|
||||
@WASMVM_VERSION=$$(go list -m all | grep github.com/CosmWasm/wasmvm | head -1 | cut -d' ' -f2); \
|
||||
echo "WasmVM version: $$WASMVM_VERSION"; \
|
||||
echo "Downloading Linux AMD64 static library..."; \
|
||||
curl -L -o build/libwasmvm_muslc_amd64.a https://github.com/CosmWasm/wasmvm/releases/download/$$WASMVM_VERSION/libwasmvm_muslc.x86_64.a; \
|
||||
echo "Downloading Linux ARM64 static library..."; \
|
||||
curl -L -o build/libwasmvm_muslc_arm64.a https://github.com/CosmWasm/wasmvm/releases/download/$$WASMVM_VERSION/libwasmvm_muslc.aarch64.a; \
|
||||
echo "Downloading macOS AMD64 dynamic library..."; \
|
||||
curl -L -o build/libwasmvm.dylib.amd64 https://github.com/CosmWasm/wasmvm/releases/download/$$WASMVM_VERSION/libwasmvm.dylib; \
|
||||
echo "Downloading macOS ARM64 dynamic library..."; \
|
||||
curl -L -o build/libwasmvm.dylib.arm64 https://github.com/CosmWasm/wasmvm/releases/download/$$WASMVM_VERSION/libwasmvm.dylib; \
|
||||
echo "WasmVM libraries downloaded successfully"
|
||||
|
||||
help:
|
||||
@echo "snrd Build Makefile"
|
||||
@echo "==================="
|
||||
@echo ""
|
||||
@echo "Available targets:"
|
||||
@echo " build - Build snrd binary (with vault WASM)"
|
||||
@echo " install - Install snrd to GOPATH/bin"
|
||||
@echo " vault - Build vault WASM module only"
|
||||
@echo " docker - Build Docker image (onsonr/snrd:latest)"
|
||||
@echo " clean - Remove build artifacts"
|
||||
@echo " version - Display version information"
|
||||
@echo " link-wasmvm - Download WasmVM libraries for goreleaser"
|
||||
@echo " help - Show this help message"
|
||||
@echo ""
|
||||
@echo "Build options:"
|
||||
@echo " LEDGER_ENABLED=true|false - Enable/disable ledger support (default: true)"
|
||||
@echo " WITH_CLEVELDB=yes - Build with CLevelDB support"
|
||||
@echo " LINK_STATICALLY=true - Build static binary"
|
||||
@echo " BUILD_TAGS='tag1 tag2' - Additional build tags"
|
||||
@echo ""
|
||||
@echo "Examples:"
|
||||
@echo " make build"
|
||||
@echo " make build LEDGER_ENABLED=false"
|
||||
@echo " make install LINK_STATICALLY=true"
|
||||
@@ -0,0 +1,412 @@
|
||||
# snrd - Sonr Blockchain Daemon
|
||||
|
||||
`snrd` is the command-line interface and daemon for the Sonr blockchain network. It provides a comprehensive set of tools for running nodes, interacting with the network, managing identities, and performing blockchain operations.
|
||||
|
||||
## Overview
|
||||
|
||||
Sonr is a Cosmos SDK-based blockchain that combines decentralized identity (DID), WebAuthn authentication, and IPFS storage capabilities. The `snrd` daemon serves as the primary interface for:
|
||||
|
||||
- Running blockchain nodes (validators, full nodes)
|
||||
- Managing decentralized identities and credentials
|
||||
- Performing wallet operations and transaction signing
|
||||
- Interacting with IPFS for decentralized storage
|
||||
- Querying blockchain state and submitting transactions
|
||||
|
||||
## Installation
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Go 1.24+
|
||||
- Docker (for IPFS operations)
|
||||
- Git
|
||||
|
||||
### Build from Source
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/sonr-io/sonr.git
|
||||
cd sonr
|
||||
|
||||
# Install the binary
|
||||
make install
|
||||
|
||||
# Verify installation
|
||||
snrd version
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
The `snrd` binary is built on the Cosmos SDK v0.50.13 and includes:
|
||||
|
||||
- **Cosmos SDK modules**: Standard blockchain functionality (auth, bank, staking, etc.)
|
||||
- **Custom modules**:
|
||||
- `x/did`: W3C DID specification with WebAuthn support
|
||||
- `x/dwn`: Decentralized Web Node for data storage
|
||||
- `x/svc`: Service management and domain verification
|
||||
- `x/ucan`: User-Controlled Authorization Networks
|
||||
- **EVM compatibility**: Ethereum Virtual Machine support via Evmos
|
||||
- **IPFS integration**: Decentralized storage for large data objects
|
||||
|
||||
### Network Configuration
|
||||
|
||||
- **Address prefix**: `idx` (Bech32 encoded addresses)
|
||||
- **Coin type**: 60 (BIP44 - Ethereum compatible)
|
||||
- **Default node home**: `~/.snrd`
|
||||
- **Minimum gas prices**: `0stake`
|
||||
|
||||
## Usage
|
||||
|
||||
### Node Operations
|
||||
|
||||
#### Initialize a New Node
|
||||
|
||||
```bash
|
||||
# Initialize node configuration
|
||||
snrd init <moniker> --chain-id <chain-id>
|
||||
|
||||
# Example for testnet
|
||||
snrd init my-node --chain-id sonr-testnet-1
|
||||
```
|
||||
|
||||
#### Start the Node
|
||||
|
||||
```bash
|
||||
# Start the blockchain node
|
||||
snrd start
|
||||
|
||||
# Start with custom configuration
|
||||
snrd start --home ~/.sonr --p2p.laddr tcp://0.0.0.0:26656
|
||||
```
|
||||
|
||||
#### Node Management
|
||||
|
||||
```bash
|
||||
# Check node status
|
||||
snrd status
|
||||
|
||||
# View node information
|
||||
snrd query block
|
||||
|
||||
# Export application state
|
||||
snrd export
|
||||
|
||||
# Reset node data
|
||||
snrd reset
|
||||
```
|
||||
|
||||
### Identity Management
|
||||
|
||||
#### Authentication Commands
|
||||
|
||||
```bash
|
||||
# Register a new WebAuthn credential
|
||||
snrd auth register --username <username>
|
||||
|
||||
# Login with existing credentials
|
||||
snrd auth login
|
||||
```
|
||||
|
||||
The authentication system uses WebAuthn for passwordless, cryptographically secure user authentication. The registration process opens a browser window for biometric or security key authentication.
|
||||
|
||||
### Wallet Operations
|
||||
|
||||
#### Transaction Management
|
||||
|
||||
```bash
|
||||
# Sign a transaction
|
||||
snrd wallet sign <tx-file>
|
||||
|
||||
# Verify a signature
|
||||
snrd wallet verify <signature> <message>
|
||||
|
||||
# Simulate transaction execution
|
||||
snrd wallet simulate <tx-file>
|
||||
|
||||
# Broadcast a signed transaction
|
||||
snrd wallet broadcast <signed-tx-file>
|
||||
```
|
||||
|
||||
### IPFS Integration
|
||||
|
||||
#### IPFS Node Management
|
||||
|
||||
```bash
|
||||
# Start IPFS containers
|
||||
snrd ipfs start
|
||||
|
||||
# View IPFS logs with interactive interface
|
||||
snrd ipfs logs
|
||||
|
||||
# Stop IPFS containers
|
||||
snrd ipfs stop
|
||||
```
|
||||
|
||||
The IPFS integration provides decentralized storage capabilities for large data objects referenced by blockchain transactions.
|
||||
|
||||
### Querying the Network
|
||||
|
||||
#### Basic Queries
|
||||
|
||||
```bash
|
||||
# Query account information
|
||||
snrd query auth account <address>
|
||||
|
||||
# Query account balance
|
||||
snrd query bank balances <address>
|
||||
|
||||
# Query validator information
|
||||
snrd query staking validator <validator-address>
|
||||
|
||||
# Query transaction by hash
|
||||
snrd query tx <hash>
|
||||
```
|
||||
|
||||
#### Module-Specific Queries
|
||||
|
||||
```bash
|
||||
# Query DID documents
|
||||
snrd query did did-document <did>
|
||||
|
||||
# Query WebAuthn credentials
|
||||
snrd query did webauthn-credentials <address>
|
||||
|
||||
# Query service records
|
||||
snrd query svc service <service-id>
|
||||
|
||||
# Query UCAN capabilities
|
||||
snrd query ucan capability <capability-id>
|
||||
```
|
||||
|
||||
### Transaction Commands
|
||||
|
||||
#### Standard Transactions
|
||||
|
||||
```bash
|
||||
# Send tokens
|
||||
snrd tx bank send <from-address> <to-address> <amount>
|
||||
|
||||
# Delegate to validator
|
||||
snrd tx staking delegate <validator-address> <amount>
|
||||
|
||||
# Submit governance proposal
|
||||
snrd tx gov submit-proposal <proposal-file>
|
||||
```
|
||||
|
||||
#### Custom Module Transactions
|
||||
|
||||
```bash
|
||||
# Register a DID document
|
||||
snrd tx did register-did <did-document-file>
|
||||
|
||||
# Register WebAuthn credential
|
||||
snrd tx did register-webauthn-credential <credential-file>
|
||||
|
||||
# Create service record
|
||||
snrd tx svc create-service <service-config>
|
||||
|
||||
# Issue UCAN capability
|
||||
snrd tx ucan issue-capability <capability-config>
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Node Configuration
|
||||
|
||||
Node configuration is stored in `~/.snrd/config/`:
|
||||
|
||||
- `config.toml`: Node and P2P configuration
|
||||
- `app.toml`: Application-specific settings
|
||||
- `client.toml`: Client configuration
|
||||
- `genesis.json`: Genesis state
|
||||
|
||||
#### Key Configuration Options
|
||||
|
||||
```toml
|
||||
# config.toml
|
||||
[p2p]
|
||||
laddr = "tcp://0.0.0.0:26656"
|
||||
persistent_peers = ""
|
||||
max_num_inbound_peers = 40
|
||||
max_num_outbound_peers = 10
|
||||
|
||||
[consensus]
|
||||
timeout_commit = "5s"
|
||||
timeout_propose = "3s"
|
||||
|
||||
# app.toml
|
||||
[api]
|
||||
enable = true
|
||||
swagger = true
|
||||
address = "tcp://0.0.0.0:1317"
|
||||
|
||||
[grpc]
|
||||
enable = true
|
||||
address = "0.0.0.0:9090"
|
||||
|
||||
[json-rpc]
|
||||
enable = true
|
||||
address = "0.0.0.0:8545"
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
```bash
|
||||
# Override default home directory
|
||||
export SNRD_HOME=/path/to/custom/home
|
||||
|
||||
# Set custom chain ID
|
||||
export SNRD_CHAIN_ID=custom-chain-1
|
||||
|
||||
# Configure logging level
|
||||
export SNRD_LOG_LEVEL=info
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Building
|
||||
|
||||
```bash
|
||||
# Build binary
|
||||
make build
|
||||
|
||||
# Build with race detection
|
||||
make build-race
|
||||
|
||||
# Cross-compile for different platforms
|
||||
GOOS=linux GOARCH=amd64 make build
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
# Run unit tests
|
||||
make test
|
||||
|
||||
# Run tests with coverage
|
||||
make test-cover
|
||||
|
||||
# Run integration tests
|
||||
make test-integration
|
||||
```
|
||||
|
||||
### Code Generation
|
||||
|
||||
```bash
|
||||
# Generate protobuf code
|
||||
make proto-gen
|
||||
|
||||
# Generate swagger documentation
|
||||
make swagger-gen
|
||||
|
||||
# Format code
|
||||
make format
|
||||
|
||||
# Run linter
|
||||
make lint
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### Node Won't Start
|
||||
|
||||
```bash
|
||||
# Check configuration
|
||||
snrd validate-genesis
|
||||
|
||||
# Reset corrupted data
|
||||
snrd unsafe-reset-all
|
||||
|
||||
# Check logs
|
||||
snrd start --log_level debug
|
||||
```
|
||||
|
||||
#### Connection Issues
|
||||
|
||||
```bash
|
||||
# Test network connectivity
|
||||
snrd status
|
||||
|
||||
# Check peer connections
|
||||
snrd query tendermint-validator-set
|
||||
```
|
||||
|
||||
#### IPFS Issues
|
||||
|
||||
```bash
|
||||
# Check Docker status
|
||||
docker ps
|
||||
|
||||
# Reset IPFS containers
|
||||
snrd ipfs stop
|
||||
docker system prune
|
||||
snrd ipfs start
|
||||
```
|
||||
|
||||
### Debugging Commands
|
||||
|
||||
```bash
|
||||
# Enable debug logging
|
||||
snrd start --log_level debug --log_format json
|
||||
|
||||
# Profile performance
|
||||
snrd start --cpu-profile cpu.prof
|
||||
|
||||
# Memory profiling
|
||||
snrd start --mem-profile mem.prof
|
||||
```
|
||||
|
||||
## Network Endpoints
|
||||
|
||||
### Testnet
|
||||
|
||||
- **RPC**: `https://testnet-rpc.sonr.network`
|
||||
- **REST**: `https://testnet-api.sonr.network`
|
||||
- **gRPC**: `testnet-grpc.sonr.network:443`
|
||||
- **Chain ID**: `sonr-testnet-1`
|
||||
|
||||
### Mainnet
|
||||
|
||||
- **RPC**: `https://rpc.sonr.network`
|
||||
- **REST**: `https://api.sonr.network`
|
||||
- **gRPC**: `grpc.sonr.network:443`
|
||||
- **Chain ID**: `sonr-mainnet-1`
|
||||
|
||||
## API Documentation
|
||||
|
||||
- **REST API**: Available at `/swagger/` endpoint when API server is running
|
||||
- **gRPC**: Protocol buffer definitions in `/proto` directory
|
||||
- **GraphQL**: Available at `/graphql` endpoint (if enabled)
|
||||
|
||||
## Security Considerations
|
||||
|
||||
### Key Management
|
||||
|
||||
- Private keys are stored in the OS keyring by default
|
||||
- Hardware wallet support available via Ledger integration
|
||||
- WebAuthn provides passwordless authentication with biometric security
|
||||
|
||||
### Network Security
|
||||
|
||||
- TLS encryption for all API endpoints
|
||||
- P2P encryption via Tendermint
|
||||
- Signature verification for all transactions
|
||||
|
||||
### Best Practices
|
||||
|
||||
- Regular backups of validator keys and node data
|
||||
- Use hardware security modules (HSMs) for validator keys
|
||||
- Enable firewall rules for production deployments
|
||||
- Monitor node health and connectivity
|
||||
|
||||
## Support
|
||||
|
||||
- **Documentation**: [https://docs.sonr.network](https://docs.sonr.network)
|
||||
- **GitHub Issues**: [https://github.com/sonr-io/sonr/issues](https://github.com/sonr-io/sonr/issues)
|
||||
- **Discord**: [https://discord.gg/sonr](https://discord.gg/sonr)
|
||||
- **Telegram**: [https://t.me/sonrnetwork](https://t.me/sonrnetwork)
|
||||
|
||||
## License
|
||||
|
||||
Licensed under the Apache License 2.0. See [LICENSE](../../LICENSE) for details.
|
||||
Executable
+305
@@ -0,0 +1,305 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
cmtcfg "github.com/cometbft/cometbft/config"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/sonr-io/sonr/app"
|
||||
util "github.com/sonr-io/sonr/app/commands"
|
||||
didcli "github.com/sonr-io/sonr/x/did/client/cli"
|
||||
dwncli "github.com/sonr-io/sonr/x/dwn/client/cli"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
confixcmd "cosmossdk.io/tools/confix/cmd"
|
||||
|
||||
cmtcli "github.com/cometbft/cometbft/libs/cli"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/debug"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/pruning"
|
||||
"github.com/cosmos/cosmos-sdk/client/rpc"
|
||||
"github.com/cosmos/cosmos-sdk/client/snapshot"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis"
|
||||
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||
evmosserverconfig "github.com/cosmos/evm/server/config"
|
||||
|
||||
evmoscmd "github.com/cosmos/evm/client"
|
||||
evmosserver "github.com/cosmos/evm/server"
|
||||
srvflags "github.com/cosmos/evm/server/flags"
|
||||
)
|
||||
|
||||
// AddCustomCommands adds custom commands to the root command
|
||||
func AddCustomCommands(rootCmd *cobra.Command) {
|
||||
didcli.AddAuthCmds(rootCmd)
|
||||
dwncli.AddWalletCmds(rootCmd)
|
||||
rootCmd.AddCommand(util.GovCmd())
|
||||
|
||||
// Add VRF keys management to keys command
|
||||
keysCmd := findKeysCommand(rootCmd)
|
||||
if keysCmd != nil {
|
||||
keysCmd.AddCommand(util.VRFKeysCmd())
|
||||
}
|
||||
}
|
||||
|
||||
// findKeysCommand finds the keys command in the root command
|
||||
func findKeysCommand(rootCmd *cobra.Command) *cobra.Command {
|
||||
for _, cmd := range rootCmd.Commands() {
|
||||
if cmd.Name() == "keys" {
|
||||
return cmd
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// initCometBFTConfig helps to override default CometBFT Config values.
|
||||
// return cmtcfg.DefaultConfig if no custom configuration is required for the application.
|
||||
func initCometBFTConfig() *cmtcfg.Config {
|
||||
cfg := cmtcfg.DefaultConfig()
|
||||
|
||||
// these values put a higher strain on node memory
|
||||
// cfg.P2P.MaxNumInboundPeers = 100
|
||||
// cfg.P2P.MaxNumOutboundPeers = 40
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
||||
type CustomAppConfig struct {
|
||||
serverconfig.Config
|
||||
|
||||
EVM evmosserverconfig.EVMConfig
|
||||
JSONRPC evmosserverconfig.JSONRPCConfig
|
||||
TLS evmosserverconfig.TLSConfig
|
||||
}
|
||||
|
||||
// initAppConfig helps to override default appConfig template and configs.
|
||||
// return "", nil if no custom configuration is required for the application.
|
||||
func initAppConfig() (string, any) {
|
||||
// The following code snippet is just for reference.
|
||||
|
||||
// Optionally allow the chain developer to overwrite the SDK's default
|
||||
// server config.
|
||||
srvCfg := serverconfig.DefaultConfig()
|
||||
// The SDK's default minimum gas price is set to "" (empty value) inside
|
||||
// app.toml. If left empty by validators, the node will halt on startup.
|
||||
// However, the chain developer can set a default app.toml value for their
|
||||
// validators here.
|
||||
//
|
||||
// In summary:
|
||||
// - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their
|
||||
// own app.toml config,
|
||||
// - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their
|
||||
// own app.toml to override, or use this default value.
|
||||
//
|
||||
// In simapp, we set the min gas prices to 0.
|
||||
srvCfg.MinGasPrices = "0stake"
|
||||
// srvCfg.BaseConfig.IAVLDisableFastNode = true // disable fastnode by default
|
||||
|
||||
customAppConfig := CustomAppConfig{
|
||||
Config: *srvCfg,
|
||||
EVM: *evmosserverconfig.DefaultEVMConfig(),
|
||||
JSONRPC: *evmosserverconfig.DefaultJSONRPCConfig(),
|
||||
TLS: *evmosserverconfig.DefaultTLSConfig(),
|
||||
}
|
||||
|
||||
customAppTemplate := serverconfig.DefaultConfigTemplate
|
||||
|
||||
customAppTemplate += evmosserverconfig.DefaultEVMConfigTemplate
|
||||
|
||||
return customAppTemplate, customAppConfig
|
||||
}
|
||||
|
||||
func initRootCmd(
|
||||
rootCmd *cobra.Command,
|
||||
chainApp *app.ChainApp,
|
||||
) {
|
||||
cfg := sdk.GetConfig()
|
||||
cfg.Seal()
|
||||
|
||||
rootCmd.AddCommand(
|
||||
util.EnhancedInit(chainApp),
|
||||
genutilcli.Commands(chainApp.TxConfig(), chainApp.BasicModuleManager, app.DefaultNodeHome),
|
||||
cmtcli.NewCompletionCmd(rootCmd, true),
|
||||
debug.Cmd(),
|
||||
confixcmd.ConfigCommand(),
|
||||
pruning.Cmd(newApp, app.DefaultNodeHome),
|
||||
snapshot.Cmd(newApp),
|
||||
)
|
||||
|
||||
// add EVM' flavored TM commands to start server, etc.
|
||||
evmosserver.AddCommands(
|
||||
rootCmd,
|
||||
evmosserver.NewDefaultStartOptions(newApp, app.DefaultNodeHome),
|
||||
appExport,
|
||||
addModuleInitFlags,
|
||||
)
|
||||
|
||||
// add EVM key commands
|
||||
rootCmd.AddCommand(
|
||||
evmoscmd.KeyCommands(app.DefaultNodeHome, true),
|
||||
)
|
||||
|
||||
// add keybase, auxiliary RPC, query, genesis, and tx child commands
|
||||
rootCmd.AddCommand(
|
||||
server.StatusCommand(),
|
||||
|
||||
queryCommand(),
|
||||
txCommand(),
|
||||
)
|
||||
|
||||
// add general tx flags to the root command
|
||||
_, err := srvflags.AddTxFlags(rootCmd)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Add custom commands
|
||||
AddCustomCommands(rootCmd)
|
||||
}
|
||||
|
||||
func addModuleInitFlags(startCmd *cobra.Command) {
|
||||
crisis.AddModuleInitFlags(startCmd)
|
||||
}
|
||||
|
||||
func queryCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "query",
|
||||
Aliases: []string{"q"},
|
||||
Short: "Querying subcommands",
|
||||
DisableFlagParsing: false,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
rpc.QueryEventForTxCmd(),
|
||||
rpc.ValidatorCommand(),
|
||||
authcmd.QueryTxsByEventsCmd(),
|
||||
authcmd.QueryTxCmd(),
|
||||
server.QueryBlocksCmd(),
|
||||
server.QueryBlockResultsCmd(),
|
||||
)
|
||||
|
||||
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func txCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "tx",
|
||||
Short: "Transactions subcommands",
|
||||
DisableFlagParsing: false,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
authcmd.GetSignCommand(),
|
||||
authcmd.GetSignBatchCommand(),
|
||||
authcmd.GetMultiSignCommand(),
|
||||
authcmd.GetMultiSignBatchCmd(),
|
||||
authcmd.GetValidateSignaturesCommand(),
|
||||
authcmd.GetBroadcastCommand(),
|
||||
authcmd.GetEncodeCommand(),
|
||||
authcmd.GetDecodeCommand(),
|
||||
authcmd.GetSimulateCmd(),
|
||||
)
|
||||
|
||||
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// newApp creates the application
|
||||
func newApp(
|
||||
logger log.Logger,
|
||||
db dbm.DB,
|
||||
traceStore io.Writer,
|
||||
appOpts servertypes.AppOptions,
|
||||
) servertypes.Application {
|
||||
baseappOptions := server.DefaultBaseappOptions(appOpts)
|
||||
|
||||
if cast.ToBool(appOpts.Get("telemetry.enabled")) {
|
||||
// TODO: Implement telemetry configuration
|
||||
// This should set up telemetry options such as:
|
||||
// - Metrics collection endpoints
|
||||
// - Sampling rates
|
||||
// - Export intervals
|
||||
// - Custom labels and tags
|
||||
// Consider using baseappOptions.SetTelemetry() or similar
|
||||
}
|
||||
|
||||
return app.NewChainApp(
|
||||
logger, db, traceStore, true,
|
||||
appOpts,
|
||||
app.EVMAppOptions,
|
||||
baseappOptions...,
|
||||
)
|
||||
}
|
||||
|
||||
func appExport(
|
||||
logger log.Logger,
|
||||
db dbm.DB,
|
||||
traceStore io.Writer,
|
||||
height int64,
|
||||
forZeroHeight bool,
|
||||
jailAllowedAddrs []string,
|
||||
appOpts servertypes.AppOptions,
|
||||
modulesToExport []string,
|
||||
) (servertypes.ExportedApp, error) {
|
||||
var chainApp *app.ChainApp
|
||||
// this check is necessary as we use the flag in x/upgrade.
|
||||
// we can exit more gracefully by checking the flag here.
|
||||
homePath, ok := appOpts.Get(flags.FlagHome).(string)
|
||||
if !ok || homePath == "" {
|
||||
return servertypes.ExportedApp{}, errors.New("application home is not set")
|
||||
}
|
||||
|
||||
viperAppOpts, ok := appOpts.(*viper.Viper)
|
||||
if !ok {
|
||||
return servertypes.ExportedApp{}, errors.New("appOpts is not viper.Viper")
|
||||
}
|
||||
|
||||
// overwrite the FlagInvCheckPeriod
|
||||
viperAppOpts.Set(server.FlagInvCheckPeriod, 1)
|
||||
appOpts = viperAppOpts
|
||||
|
||||
chainApp = app.NewChainApp(
|
||||
logger,
|
||||
db,
|
||||
traceStore,
|
||||
height == -1,
|
||||
appOpts,
|
||||
app.EVMAppOptions,
|
||||
)
|
||||
|
||||
if height != -1 {
|
||||
if err := chainApp.LoadHeight(height); err != nil {
|
||||
return servertypes.ExportedApp{}, err
|
||||
}
|
||||
}
|
||||
|
||||
return chainApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport)
|
||||
}
|
||||
|
||||
var tempDir = func() string {
|
||||
dir, err := os.MkdirTemp("", "simd")
|
||||
if err != nil {
|
||||
panic("failed to create temp dir: " + err.Error())
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
return dir
|
||||
}
|
||||
Executable
+336
@@ -0,0 +1,336 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# ================================
|
||||
# SONR TESTNET BOOTSTRAP SCRIPT
|
||||
# ================================
|
||||
|
||||
# Color output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
log_header() { echo -e "${BLUE}==== $1 ====${NC}"; }
|
||||
|
||||
# Script directory and repository root
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
# Load environment variables if .env exists
|
||||
if [ -f "$REPO_ROOT/.env" ]; then
|
||||
export $(grep -v '^#' "$REPO_ROOT/.env" | xargs)
|
||||
fi
|
||||
|
||||
# Default values
|
||||
export CHAIN_ID=${CHAIN_ID:-"sonrtest_1-1"}
|
||||
export DENOM=${DENOM:-"usnr"}
|
||||
export DOCKER_IMAGE=${DOCKER_IMAGE:-"onsonr/snrd:latest"}
|
||||
|
||||
# Function to check prerequisites
|
||||
check_prerequisites() {
|
||||
log_header "Checking prerequisites"
|
||||
|
||||
local has_error=false
|
||||
|
||||
# Check Docker
|
||||
if ! command -v docker &> /dev/null; then
|
||||
log_error "Docker is not installed"
|
||||
has_error=true
|
||||
else
|
||||
log_info "Docker: $(docker --version)"
|
||||
fi
|
||||
|
||||
# Check Docker Compose
|
||||
if ! docker compose version &> /dev/null; then
|
||||
log_error "Docker Compose is not installed"
|
||||
has_error=true
|
||||
else
|
||||
log_info "Docker Compose: $(docker compose version)"
|
||||
fi
|
||||
|
||||
# Check jq
|
||||
if ! command -v jq &> /dev/null; then
|
||||
log_warn "jq is not installed - some commands may not work"
|
||||
log_warn "Install with: apt-get install jq (Ubuntu) or brew install jq (macOS)"
|
||||
else
|
||||
log_info "jq: $(jq --version)"
|
||||
fi
|
||||
|
||||
if [ "$has_error" = true ]; then
|
||||
log_error "Prerequisites check failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "All prerequisites met"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Function to initialize validators
|
||||
init_validators() {
|
||||
log_header "Initializing validators and sentries"
|
||||
|
||||
# Check for local snrd binary
|
||||
if ! command -v snrd &> /dev/null; then
|
||||
log_error "snrd binary not found in PATH"
|
||||
log_error "Please install snrd locally or add it to your PATH"
|
||||
log_error "The initialization requires a local snrd binary to avoid permission issues"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "$SCRIPT_DIR/init-testnet.sh" ]; then
|
||||
log_info "Using init-testnet.sh (local snrd binary initialization)"
|
||||
log_info "snrd location: $(which snrd)"
|
||||
"$SCRIPT_DIR/init-testnet.sh"
|
||||
else
|
||||
log_error "init-testnet.sh not found in $SCRIPT_DIR!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to start testnet
|
||||
start_testnet() {
|
||||
log_header "Starting testnet"
|
||||
|
||||
# Check if validators are initialized
|
||||
if [ ! -d "val-alice" ] || [ ! -d "sentry-alice" ]; then
|
||||
log_warn "Validators not initialized, running init first..."
|
||||
init_validators
|
||||
fi
|
||||
|
||||
# Pull latest image
|
||||
log_info "Pulling Docker image: $DOCKER_IMAGE"
|
||||
docker pull "$DOCKER_IMAGE"
|
||||
|
||||
# Start services
|
||||
log_info "Starting services with docker compose..."
|
||||
docker compose up -d
|
||||
|
||||
# Wait for services to be healthy
|
||||
log_info "Waiting for services to start..."
|
||||
sleep 5
|
||||
|
||||
# Check status
|
||||
show_status
|
||||
|
||||
log_info "Testnet started successfully!"
|
||||
echo ""
|
||||
log_info "View logs: docker compose logs -f"
|
||||
log_info "Stop testnet: ./bootstrap.sh stop"
|
||||
}
|
||||
|
||||
# Function to stop testnet
|
||||
stop_testnet() {
|
||||
log_header "Stopping testnet"
|
||||
|
||||
docker compose down
|
||||
log_info "Testnet stopped"
|
||||
}
|
||||
|
||||
# Function to restart testnet
|
||||
restart_testnet() {
|
||||
log_header "Restarting testnet"
|
||||
|
||||
stop_testnet
|
||||
sleep 2
|
||||
start_testnet
|
||||
}
|
||||
|
||||
# Function to clean all data
|
||||
clean_all() {
|
||||
log_header "Cleaning testnet data"
|
||||
|
||||
# Stop containers and remove volumes
|
||||
log_info "Stopping containers and removing volumes..."
|
||||
docker compose down -v 2>/dev/null || true
|
||||
|
||||
# Remove data directories using Docker to handle permission issues
|
||||
log_info "Removing validator and sentry directories..."
|
||||
if [ -d "val-alice" ] || [ -d "val-bob" ] || [ -d "val-carol" ] || [ -d "sentry-alice" ] || [ -d "sentry-bob" ] || [ -d "sentry-carol" ]; then
|
||||
docker run --rm -v "$(pwd):/workspace" alpine:latest sh -c \
|
||||
"rm -rf /workspace/val-alice /workspace/val-bob /workspace/val-carol /workspace/sentry-alice /workspace/sentry-bob /workspace/sentry-carol" \
|
||||
2>/dev/null || true
|
||||
fi
|
||||
|
||||
log_info "Clean complete"
|
||||
}
|
||||
|
||||
# Function to show status
|
||||
show_status() {
|
||||
log_header "Testnet Status"
|
||||
|
||||
echo ""
|
||||
echo "Container Status:"
|
||||
docker ps --filter "name=val-" --filter "name=sentry-" --filter "name=ipfs" --format "table {{.Names}}\t{{.Status}}\t{{.State}}"
|
||||
|
||||
echo ""
|
||||
echo "Network Endpoints (via Cloudflare Tunnel):"
|
||||
echo " Alice RPC: https://alice-rpc.sonr.land"
|
||||
echo " Alice REST: https://alice-rest.sonr.land"
|
||||
echo " Alice gRPC: https://alice-grpc.sonr.land"
|
||||
echo " Alice EVM: https://alice-evm.sonr.land"
|
||||
echo " Bob RPC: https://bob-rpc.sonr.land"
|
||||
echo " Carol RPC: https://carol-rpc.sonr.land"
|
||||
echo " IPFS API: https://ipfs-api.sonr.land"
|
||||
echo " IPFS Gateway: https://ipfs-gateway.sonr.land"
|
||||
|
||||
# Check sync status if services are running
|
||||
if docker ps | grep -q "sentry-alice"; then
|
||||
echo ""
|
||||
echo "Sync Status:"
|
||||
local block_height=$(docker exec sentry-alice sh -c 'curl -s http://localhost:26657/status 2>/dev/null | jq -r ".result.sync_info.latest_block_height" 2>/dev/null' || echo "0")
|
||||
echo " Block Height: $block_height"
|
||||
for container in sentry-alice sentry-bob sentry-carol; do
|
||||
status=$(docker exec $container sh -c 'curl -s http://localhost:26657/status 2>/dev/null | jq -r ".result.sync_info.catching_up" 2>/dev/null' || echo "unavailable")
|
||||
echo " $container: catching_up=$status"
|
||||
done
|
||||
fi
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Function to view logs
|
||||
view_logs() {
|
||||
local service=$1
|
||||
|
||||
if [ -z "$service" ]; then
|
||||
docker compose logs -f --tail=100
|
||||
else
|
||||
docker compose logs -f --tail=100 "$service"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to execute command in container
|
||||
exec_in_container() {
|
||||
local container=$1
|
||||
shift
|
||||
|
||||
if [ -z "$container" ]; then
|
||||
log_error "Container name required"
|
||||
echo "Usage: ./bootstrap.sh exec <container> <command>"
|
||||
echo "Example: ./bootstrap.sh exec val-alice status"
|
||||
return 1
|
||||
fi
|
||||
|
||||
docker exec -it "$container" snrd --home /root/.sonr "$@"
|
||||
}
|
||||
|
||||
# Function to run tests
|
||||
run_tests() {
|
||||
log_header "Running testnet tests"
|
||||
|
||||
# Check if all services are running
|
||||
log_info "Checking service health..."
|
||||
local all_healthy=true
|
||||
|
||||
for service in val-alice val-bob val-carol sentry-alice sentry-bob sentry-carol; do
|
||||
if ! docker ps | grep -q "$service"; then
|
||||
log_error "$service is not running"
|
||||
all_healthy=false
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$all_healthy" = false ]; then
|
||||
log_error "Not all services are running"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Test RPC endpoints
|
||||
log_info "Testing RPC endpoints..."
|
||||
for container in sentry-alice sentry-bob sentry-carol; do
|
||||
if docker exec $container sh -c 'curl -s http://localhost:26657/status' > /dev/null 2>&1; then
|
||||
log_info "$container: OK"
|
||||
else
|
||||
log_error "$container: FAILED"
|
||||
fi
|
||||
done
|
||||
|
||||
# Test validator connectivity
|
||||
log_info "Testing validator connectivity..."
|
||||
local block_height=$(docker exec sentry-alice sh -c 'curl -s http://localhost:26657/status 2>/dev/null | jq -r ".result.sync_info.latest_block_height" 2>/dev/null' || echo "unavailable")
|
||||
if [ "$block_height" != "unavailable" ] && [ "$block_height" != "null" ]; then
|
||||
log_info "Current block height: $block_height"
|
||||
else
|
||||
log_error "Failed to get validator status"
|
||||
fi
|
||||
|
||||
log_info "Tests complete"
|
||||
}
|
||||
|
||||
# Function to show usage
|
||||
show_usage() {
|
||||
echo "Sonr Testnet Bootstrap Script"
|
||||
echo ""
|
||||
echo "Usage: ./bootstrap.sh [command]"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " init Initialize validators and sentries"
|
||||
echo " start Start the testnet"
|
||||
echo " stop Stop the testnet"
|
||||
echo " restart Restart the testnet"
|
||||
echo " status Show testnet status"
|
||||
echo " logs View logs (optional: service name)"
|
||||
echo " clean Clean all data and volumes"
|
||||
echo " exec Execute command in container"
|
||||
echo " test Run basic tests"
|
||||
echo " help Show this help message"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " ./bootstrap.sh init"
|
||||
echo " ./bootstrap.sh start"
|
||||
echo " ./bootstrap.sh logs sentry-alice"
|
||||
echo " ./bootstrap.sh exec val-alice status"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Main command handler
|
||||
main() {
|
||||
case "${1:-help}" in
|
||||
init)
|
||||
check_prerequisites
|
||||
init_validators
|
||||
;;
|
||||
start)
|
||||
check_prerequisites
|
||||
start_testnet
|
||||
;;
|
||||
stop)
|
||||
stop_testnet
|
||||
;;
|
||||
restart)
|
||||
restart_testnet
|
||||
;;
|
||||
status)
|
||||
show_status
|
||||
;;
|
||||
logs)
|
||||
view_logs "${2:-}"
|
||||
;;
|
||||
clean)
|
||||
clean_all
|
||||
;;
|
||||
exec)
|
||||
shift
|
||||
exec_in_container "$@"
|
||||
;;
|
||||
test)
|
||||
run_tests
|
||||
;;
|
||||
help|--help|-h)
|
||||
show_usage
|
||||
;;
|
||||
*)
|
||||
log_error "Unknown command: $1"
|
||||
show_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Run main function with all arguments
|
||||
main "$@"
|
||||
Executable
+418
@@ -0,0 +1,418 @@
|
||||
#!/bin/bash
|
||||
# Run this script to quickly install, setup, and run the current version of the network without docker.
|
||||
#
|
||||
# Examples:
|
||||
# CHAIN_ID="localchain_9000-1" HOME_DIR="~/.sonr" BLOCK_TIME="1000ms" CLEAN=true sh scripts/test_node.sh
|
||||
# CHAIN_ID="localchain_9000-2" HOME_DIR="~/.sonr" CLEAN=true RPC=36657 REST=2317 PROFF=6061 P2P=36656 GRPC=8090 GRPC_WEB=8091 ROSETTA=8081 BLOCK_TIME="500ms" sh scripts/test_node.sh
|
||||
|
||||
set -eu
|
||||
|
||||
export KEY="acc0"
|
||||
export KEY2="acc1"
|
||||
|
||||
export CHAIN_ID=${CHAIN_ID:-"sonrtest_1-1"}
|
||||
export MONIKER="localvalidator"
|
||||
export KEYALGO="eth_secp256k1"
|
||||
export KEYRING=${KEYRING:-"test"}
|
||||
export HOME_DIR=$(eval echo "${HOME_DIR:-"~/.sonr"}")
|
||||
export BINARY=${BINARY:-snrd}
|
||||
export DENOM=${DENOM:-usnr}
|
||||
|
||||
export CLEAN=${CLEAN:-"false"}
|
||||
export RPC=${RPC:-"26657"}
|
||||
export REST=${REST:-"1317"}
|
||||
export PROFF=${PROFF:-"6060"}
|
||||
export P2P=${P2P:-"26656"}
|
||||
export GRPC=${GRPC:-"9090"}
|
||||
export GRPC_WEB=${GRPC_WEB:-"9091"}
|
||||
export ROSETTA=${ROSETTA:-"8080"}
|
||||
export JSON_RPC=${JSON_RPC:-"8545"}
|
||||
export JSON_RPC_WS=${JSON_RPC_WS:-"8546"}
|
||||
export BLOCK_TIME=${BLOCK_TIME:-"5s"}
|
||||
|
||||
# Configurable Mnemomics
|
||||
export SONR_MNEMONIC_1=${SONR_MNEMONIC_1:-"decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry"}
|
||||
export SONR_MNEMONIC_2=${SONR_MNEMONIC_2:-"wealth flavor believe regret funny network recall kiss grape useless pepper cram hint member few certain unveil rather brick bargain curious require crowd raise"}
|
||||
|
||||
# Check if binary exists, if not use Docker (or force Docker if requested)
|
||||
export FORCE_DOCKER=${FORCE_DOCKER:-"false"}
|
||||
export SKIP_INSTALL=${SKIP_INSTALL:-"false"}
|
||||
USE_DOCKER=false
|
||||
if [[ "${FORCE_DOCKER}" == "true" ]] || [[ -z $(which "${BINARY}") ]]; then
|
||||
# Check if Docker is available and use it
|
||||
if command -v docker >/dev/null 2>&1; then
|
||||
if [[ "${FORCE_DOCKER}" == "true" ]]; then
|
||||
echo "Force Docker mode enabled, using Docker image onsonr/snrd:latest..."
|
||||
else
|
||||
echo "Binary ${BINARY} not found locally, checking for Docker image onsonr/snrd:latest..."
|
||||
fi
|
||||
if docker image inspect onsonr/snrd:latest >/dev/null 2>&1; then
|
||||
echo "Using Docker image onsonr/snrd:latest"
|
||||
USE_DOCKER=true
|
||||
else
|
||||
echo "Docker image onsonr/snrd:latest not found. Pulling image..."
|
||||
docker pull onsonr/snrd:latest || {
|
||||
echo "Failed to pull onsonr/snrd:latest. Please ensure Docker is running and you have internet access."
|
||||
exit 1
|
||||
}
|
||||
USE_DOCKER=true
|
||||
fi
|
||||
else
|
||||
echo "Binary ${BINARY} not found. Please either:"
|
||||
echo " 1. Install ${BINARY} with 'make install'"
|
||||
echo " 2. Install Docker to use the containerized version"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Final check if not using Docker
|
||||
if [[ "${USE_DOCKER}" == "false" ]]; then
|
||||
command -v "${BINARY}" >/dev/null 2>&1 || {
|
||||
echo >&2 "${BINARY} command not found. Ensure this is setup / properly installed in your GOPATH (make install)."
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
command -v jq >/dev/null 2>&1 || {
|
||||
echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# generate_vrf_key generates a VRF keypair and stores it securely
|
||||
# Mirrors the Go implementation in app/commands/enhance_init.go
|
||||
generate_vrf_key() {
|
||||
local home_dir="$1"
|
||||
local use_docker="${2:-false}"
|
||||
|
||||
# Validate parameters
|
||||
if [[ -z "${home_dir}" ]]; then
|
||||
echo "Error: HOME_DIR parameter is required" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Path to genesis file
|
||||
local genesis_file="${home_dir}/config/genesis.json"
|
||||
|
||||
# Check if genesis file exists
|
||||
if [[ ! -f "${genesis_file}" ]]; then
|
||||
echo "Error: Genesis file not found at ${genesis_file}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Extract chain-id from genesis file
|
||||
local chain_id
|
||||
chain_id=$(jq -r '.chain_id' "${genesis_file}" 2>/dev/null)
|
||||
|
||||
if [[ -z "${chain_id}" || "${chain_id}" == "null" ]]; then
|
||||
echo "Error: Failed to extract chain-id from genesis file" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Generating VRF keypair for network: ${chain_id}"
|
||||
|
||||
# Create deterministic entropy from chain-id using SHA256
|
||||
local entropy_seed
|
||||
entropy_seed=$(echo -n "${chain_id}" | sha256sum | cut -d' ' -f1)
|
||||
|
||||
# Generate 64 bytes of deterministic randomness
|
||||
local seed_part1="${entropy_seed}"
|
||||
local seed_part2
|
||||
seed_part2=$(echo -n "${entropy_seed}" | sha256sum | cut -d' ' -f1)
|
||||
|
||||
# Combine to create 64 bytes of hex data
|
||||
local vrf_key_hex="${seed_part1}${seed_part2}"
|
||||
|
||||
# Ensure we have exactly 128 hex characters (64 bytes)
|
||||
if [[ ${#vrf_key_hex} -ne 128 ]]; then
|
||||
echo "Error: Generated VRF key has incorrect size: ${#vrf_key_hex}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Path to store VRF secret key
|
||||
local vrf_key_path="${home_dir}/vrf_secret.key"
|
||||
|
||||
# Ensure directory exists
|
||||
mkdir -p "${home_dir}"
|
||||
|
||||
# Convert hex to binary and write to file
|
||||
echo -n "${vrf_key_hex}" | xxd -r -p > "${vrf_key_path}"
|
||||
|
||||
# Set restrictive permissions (owner read/write only)
|
||||
chmod 0600 "${vrf_key_path}"
|
||||
|
||||
# Validate file was created with correct size (64 bytes)
|
||||
local file_size
|
||||
file_size=$(wc -c < "${vrf_key_path}")
|
||||
|
||||
if [[ ${file_size} -ne 64 ]]; then
|
||||
echo "Error: VRF key file has incorrect size: ${file_size} bytes" >&2
|
||||
rm -f "${vrf_key_path}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "✓ VRF keypair generated for network: ${chain_id}"
|
||||
echo "✓ VRF secret key stored securely: ${vrf_key_path}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Create wrapper function for binary execution
|
||||
run_binary() {
|
||||
if [[ "${USE_DOCKER}" == "true" ]]; then
|
||||
# Ensure the directory exists on the host
|
||||
mkdir -p "${HOME_DIR}"
|
||||
# Determine if we're in a TTY
|
||||
DOCKER_TTY_FLAG=""
|
||||
if [ -t 0 ]; then
|
||||
DOCKER_TTY_FLAG="-it"
|
||||
fi
|
||||
# Mount home directory to container's /root/.sonr
|
||||
docker run --rm ${DOCKER_TTY_FLAG} \
|
||||
-v "${HOME_DIR}:/root/.sonr" \
|
||||
--network host \
|
||||
onsonr/snrd:latest \
|
||||
snrd --home /root/.sonr "$@"
|
||||
else
|
||||
${BINARY} "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
set_config() {
|
||||
run_binary config set client chain-id "${CHAIN_ID}"
|
||||
run_binary config set client keyring-backend "${KEYRING}"
|
||||
}
|
||||
set_config
|
||||
|
||||
from_scratch() {
|
||||
# Fresh install on current branch (skip if using Docker or SKIP_INSTALL is true)
|
||||
if [[ "${USE_DOCKER}" == "false" ]] && [[ "${SKIP_INSTALL}" == "false" ]]; then
|
||||
make install
|
||||
fi
|
||||
|
||||
# remove existing daemon files.
|
||||
if [[ ${#HOME_DIR} -le 2 ]]; then
|
||||
echo "HOME_DIR must be more than 2 characters long"
|
||||
return
|
||||
fi
|
||||
rm -rf "${HOME_DIR}" && echo "Removed ${HOME_DIR}"
|
||||
|
||||
# reset values if not set already after whipe
|
||||
set_config
|
||||
|
||||
add_key() {
|
||||
key=$1
|
||||
mnemonic=$2
|
||||
if [[ "${USE_DOCKER}" == "true" ]]; then
|
||||
# For Docker, we need to pass the mnemonic differently
|
||||
mkdir -p "${HOME_DIR}"
|
||||
echo "${mnemonic}" | docker run --rm -i \
|
||||
-v "${HOME_DIR}:/root/.sonr" \
|
||||
--network host \
|
||||
onsonr/snrd:latest \
|
||||
snrd --home /root/.sonr keys add "${key}" --keyring-backend "${KEYRING}" --algo "${KEYALGO}" --recover
|
||||
else
|
||||
echo "${mnemonic}" | ${BINARY} keys add "${key}" --keyring-backend "${KEYRING}" --algo "${KEYALGO}" --home "${HOME_DIR}" --recover
|
||||
fi
|
||||
}
|
||||
|
||||
# idx140fehngcrxvhdt84x729p3f0qmkmea8n570lrg
|
||||
add_key "${KEY}" "${SONR_MNEMONIC_1}"
|
||||
|
||||
# idx1r6yue0vuyj9m7xw78npspt9drq2tmtvgcrf7sr
|
||||
add_key "${KEY2}" "${SONR_MNEMONIC_2}"
|
||||
|
||||
if [[ "${USE_DOCKER}" == "true" ]]; then
|
||||
# For Docker init, we need to handle it specially
|
||||
docker run --rm \
|
||||
-v "${HOME_DIR}:/root/.sonr" \
|
||||
--network host \
|
||||
onsonr/snrd:latest \
|
||||
snrd --home /root/.sonr init "${MONIKER}" --chain-id "${CHAIN_ID}" --default-denom "${DENOM}"
|
||||
else
|
||||
${BINARY} init "${MONIKER}" --chain-id "${CHAIN_ID}" --default-denom "${DENOM}" --home "${HOME_DIR}"
|
||||
fi
|
||||
|
||||
update_test_genesis() {
|
||||
cat "${HOME_DIR}"/config/genesis.json | jq "$1" >"${HOME_DIR}"/config/tmp_genesis.json && mv "${HOME_DIR}"/config/tmp_genesis.json "${HOME_DIR}"/config/genesis.json
|
||||
}
|
||||
|
||||
# === CORE MODULES ===
|
||||
|
||||
# Block
|
||||
update_test_genesis '.consensus_params["block"]["max_gas"]="100000000"'
|
||||
|
||||
# Gov
|
||||
update_test_genesis $(printf '.app_state["gov"]["params"]["min_deposit"]=[{"denom":"%s","amount":"1000000"}]' "${DENOM}")
|
||||
update_test_genesis '.app_state["gov"]["params"]["voting_period"]="30s"'
|
||||
update_test_genesis '.app_state["gov"]["params"]["expedited_voting_period"]="15s"'
|
||||
|
||||
# Add CONSTITUTION.md to governance if it exists
|
||||
if [ -f "CONSTITUTION.md" ]; then
|
||||
CONSTITUTION_CONTENT=$(cat CONSTITUTION.md | jq -Rs .)
|
||||
update_test_genesis ".app_state[\"gov\"][\"constitution\"]=$CONSTITUTION_CONTENT"
|
||||
fi
|
||||
|
||||
update_test_genesis $(printf '.app_state["evm"]["params"]["evm_denom"]="%s"' "${DENOM}")
|
||||
update_test_genesis '.app_state["evm"]["params"]["active_static_precompiles"]=["0x0000000000000000000000000000000000000100","0x0000000000000000000000000000000000000400","0x0000000000000000000000000000000000000800","0x0000000000000000000000000000000000000801","0x0000000000000000000000000000000000000802","0x0000000000000000000000000000000000000803","0x0000000000000000000000000000000000000804","0x0000000000000000000000000000000000000805"]'
|
||||
update_test_genesis '.app_state["erc20"]["params"]["native_precompiles"]=["0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"]' # https://eips.ethereum.org/EIPS/eip-7528
|
||||
update_test_genesis $(printf '.app_state["erc20"]["token_pairs"]=[{contract_owner:1,erc20_address:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",denom:"%s",enabled:true}]' "${DENOM}")
|
||||
update_test_genesis '.app_state["feemarket"]["params"]["no_base_fee"]=true'
|
||||
update_test_genesis '.app_state["feemarket"]["params"]["base_fee"]="0.000000000000000000"'
|
||||
|
||||
# staking
|
||||
update_test_genesis $(printf '.app_state["staking"]["params"]["bond_denom"]="%s"' "${DENOM}")
|
||||
update_test_genesis '.app_state["staking"]["params"]["min_commission_rate"]="0.050000000000000000"'
|
||||
|
||||
# mint
|
||||
update_test_genesis $(printf '.app_state["mint"]["params"]["mint_denom"]="%s"' "${DENOM}")
|
||||
|
||||
# crisis
|
||||
update_test_genesis $(printf '.app_state["crisis"]["constant_fee"]={"denom":"%s","amount":"1000"}' "${DENOM}")
|
||||
|
||||
## abci
|
||||
update_test_genesis '.consensus["params"]["abci"]["vote_extensions_enable_height"]="1"'
|
||||
|
||||
# === CUSTOM MODULES ===
|
||||
# tokenfactory
|
||||
update_test_genesis '.app_state["tokenfactory"]["params"]["denom_creation_fee"]=[]'
|
||||
update_test_genesis '.app_state["tokenfactory"]["params"]["denom_creation_gas_consume"]=100000'
|
||||
|
||||
BASE_GENESIS_ALLOCATIONS="100000000000000000000000000${DENOM},100000000test"
|
||||
|
||||
# Allocate genesis accounts
|
||||
if [[ "${USE_DOCKER}" == "true" ]]; then
|
||||
docker run --rm \
|
||||
-v "${HOME_DIR}:/root/.sonr" \
|
||||
--network host \
|
||||
onsonr/snrd:latest \
|
||||
snrd --home /root/.sonr genesis add-genesis-account "${KEY}" "${BASE_GENESIS_ALLOCATIONS}" --keyring-backend "${KEYRING}" --append
|
||||
docker run --rm \
|
||||
-v "${HOME_DIR}:/root/.sonr" \
|
||||
--network host \
|
||||
onsonr/snrd:latest \
|
||||
snrd --home /root/.sonr genesis add-genesis-account "${KEY2}" "${BASE_GENESIS_ALLOCATIONS}" --keyring-backend "${KEYRING}" --append
|
||||
# Sign genesis transaction
|
||||
docker run --rm \
|
||||
-v "${HOME_DIR}:/root/.sonr" \
|
||||
--network host \
|
||||
onsonr/snrd:latest \
|
||||
snrd --home /root/.sonr genesis gentx "${KEY}" 1000000000000000000000"${DENOM}" --gas-prices 0"${DENOM}" --keyring-backend "${KEYRING}" --chain-id "${CHAIN_ID}"
|
||||
docker run --rm \
|
||||
-v "${HOME_DIR}:/root/.sonr" \
|
||||
--network host \
|
||||
onsonr/snrd:latest \
|
||||
snrd --home /root/.sonr genesis collect-gentxs
|
||||
docker run --rm \
|
||||
-v "${HOME_DIR}:/root/.sonr" \
|
||||
--network host \
|
||||
onsonr/snrd:latest \
|
||||
snrd --home /root/.sonr genesis validate-genesis
|
||||
else
|
||||
${BINARY} genesis add-genesis-account "${KEY}" "${BASE_GENESIS_ALLOCATIONS}" --keyring-backend "${KEYRING}" --home "${HOME_DIR}" --append
|
||||
${BINARY} genesis add-genesis-account "${KEY2}" "${BASE_GENESIS_ALLOCATIONS}" --keyring-backend "${KEYRING}" --home "${HOME_DIR}" --append
|
||||
# Sign genesis transaction
|
||||
${BINARY} genesis gentx "${KEY}" 1000000000000000000000"${DENOM}" --gas-prices 0"${DENOM}" --keyring-backend "${KEYRING}" --chain-id "${CHAIN_ID}" --home "${HOME_DIR}"
|
||||
${BINARY} genesis collect-gentxs --home "${HOME_DIR}"
|
||||
${BINARY} genesis validate-genesis --home "${HOME_DIR}"
|
||||
fi
|
||||
err=$?
|
||||
if [[ ${err} -ne 0 ]]; then
|
||||
echo "Failed to validate genesis"
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
# check if CLEAN is not set to false
|
||||
if [[ ${CLEAN} != "false" ]]; then
|
||||
echo "Starting from a clean state"
|
||||
from_scratch
|
||||
|
||||
# Generate VRF keypair (must be done after genesis file is created)
|
||||
echo ""
|
||||
echo "Generating VRF keypair..."
|
||||
if ! generate_vrf_key "${HOME_DIR}" "${USE_DOCKER}"; then
|
||||
echo "Warning: VRF key generation failed, but continuing..."
|
||||
echo "Note: Multi-validator encryption features may not work without VRF keys"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Starting node..."
|
||||
|
||||
# Opens the RPC endpoint to outside connections
|
||||
sed -i -e 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:'"${RPC}"'"/g' "${HOME_DIR}"/config/config.toml
|
||||
sed -i -e 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["*"\]/g' "${HOME_DIR}"/config/config.toml
|
||||
|
||||
# REST endpoint
|
||||
sed -i -e 's/address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:'"${REST}"'"/g' "${HOME_DIR}"/config/app.toml
|
||||
sed -i -e 's/enable = false/enable = true/g' "${HOME_DIR}"/config/app.toml
|
||||
sed -i -e 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' "${HOME_DIR}"/config/app.toml
|
||||
|
||||
# peer exchange
|
||||
sed -i -e 's/pprof_laddr = "localhost:6060"/pprof_laddr = "localhost:'"${PROFF}"'"/g' "${HOME_DIR}"/config/config.toml
|
||||
sed -i -e 's/laddr = "tcp:\/\/0.0.0.0:26656"/laddr = "tcp:\/\/0.0.0.0:'"${P2P}"'"/g' "${HOME_DIR}"/config/config.toml
|
||||
|
||||
# GRPC
|
||||
sed -i -e 's/address = "localhost:9090"/address = "0.0.0.0:'"${GRPC}"'"/g' "${HOME_DIR}"/config/app.toml
|
||||
sed -i -e 's/address = "localhost:9091"/address = "0.0.0.0:'"${GRPC_WEB}"'"/g' "${HOME_DIR}"/config/app.toml
|
||||
|
||||
# Rosetta Api
|
||||
sed -i -e 's/address = ":8080"/address = "0.0.0.0:'"${ROSETTA}"'"/g' "${HOME_DIR}"/config/app.toml
|
||||
|
||||
# JSON-RPC
|
||||
sed -i -e '/\[json-rpc\]/,/^\[/ s/enable = false/enable = true/' "${HOME_DIR}"/config/app.toml
|
||||
sed -i -e '/\[json-rpc\]/,/^\[/ s/address = "127.0.0.1:8545"/address = "0.0.0.0:'"${JSON_RPC}"'"/' "${HOME_DIR}"/config/app.toml
|
||||
sed -i -e '/\[json-rpc\]/,/^\[/ s/ws-address = "127.0.0.1:8546"/ws-address = "0.0.0.0:'"${JSON_RPC_WS}"'"/' "${HOME_DIR}"/config/app.toml
|
||||
|
||||
# Faster blocks
|
||||
sed -i -e 's/timeout_commit = "5s"/timeout_commit = "'"${BLOCK_TIME}"'"/g' "${HOME_DIR}"/config/config.toml
|
||||
|
||||
# Start the node (with or without Docker)
|
||||
if [[ "${USE_DOCKER}" == "true" ]]; then
|
||||
echo "Starting node using Docker..."
|
||||
|
||||
# Check for detached mode via environment variable or prompt
|
||||
DETACHED_MODE=""
|
||||
if [[ "${DOCKER_DETACHED}" == "true" ]]; then
|
||||
DETACHED_MODE="-d"
|
||||
echo "Running in detached mode. Use 'docker logs -f sonr-testnode' to view logs."
|
||||
echo "Stop with: docker stop sonr-testnode"
|
||||
elif [ -t 0 ]; then
|
||||
echo ""
|
||||
echo "Would you like to run the node in detached mode (background)? [y/N]"
|
||||
read -r -n 1 DETACH_RESPONSE
|
||||
echo ""
|
||||
if [[ "$DETACH_RESPONSE" =~ ^[Yy]$ ]]; then
|
||||
DETACHED_MODE="-d"
|
||||
echo "Running in detached mode. Use 'docker logs -f sonr-testnode' to view logs."
|
||||
echo "Stop with: docker stop sonr-testnode"
|
||||
else
|
||||
echo "Running in foreground mode. Use Ctrl+C to stop."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Determine if we're in a TTY (only for non-detached mode)
|
||||
DOCKER_TTY_FLAG=""
|
||||
if [ -t 0 ] && [ -z "$DETACHED_MODE" ]; then
|
||||
DOCKER_TTY_FLAG="-it"
|
||||
fi
|
||||
|
||||
docker run --rm ${DETACHED_MODE} ${DOCKER_TTY_FLAG} \
|
||||
-v "${HOME_DIR}:/root/.sonr" \
|
||||
--network host \
|
||||
--name sonr-testnode \
|
||||
onsonr/snrd:latest \
|
||||
snrd start --pruning=nothing --minimum-gas-prices=0"${DENOM}" --rpc.laddr="tcp://0.0.0.0:${RPC}" --home /root/.sonr --json-rpc.api=eth,txpool,personal,net,debug,web3 --json-rpc.address="0.0.0.0:${JSON_RPC}" --json-rpc.ws-address="0.0.0.0:${JSON_RPC_WS}" --chain-id="${CHAIN_ID}"
|
||||
|
||||
# If running detached, show status
|
||||
if [ -n "$DETACHED_MODE" ]; then
|
||||
echo ""
|
||||
echo "✅ Node started in background"
|
||||
echo ""
|
||||
echo "Useful commands:"
|
||||
echo " View logs: docker logs -f sonr-testnode"
|
||||
echo " Stop node: docker stop sonr-testnode"
|
||||
echo " Node status: curl http://localhost:${RPC}/status | jq '.result.sync_info'"
|
||||
echo ""
|
||||
fi
|
||||
else
|
||||
${BINARY} start --pruning=nothing --minimum-gas-prices=0"${DENOM}" --rpc.laddr="tcp://0.0.0.0:${RPC}" --home "${HOME_DIR}" --json-rpc.api=eth,txpool,personal,net,debug,web3 --json-rpc.address="0.0.0.0:${JSON_RPC}" --json-rpc.ws-address="0.0.0.0:${JSON_RPC_WS}" --chain-id="${CHAIN_ID}"
|
||||
fi
|
||||
@@ -0,0 +1,33 @@
|
||||
version: "0.5"
|
||||
processes:
|
||||
postgres-sonr:
|
||||
command: |
|
||||
# Generate pgsodium key if not set
|
||||
if [ -z "${PGSODIUM_ROOT_KEY}" ]; then
|
||||
echo "Generating pgsodium root key..."
|
||||
export PGSODIUM_ROOT_KEY=$(openssl rand -hex 32)
|
||||
echo "Generated key: ${PGSODIUM_ROOT_KEY:0:10}..."
|
||||
fi
|
||||
|
||||
# Run the container using the pre-built image
|
||||
docker run --rm \
|
||||
--name ${POSTGRES_CONTAINER_NAME} \
|
||||
-e POSTGRES_USER="${POSTGRES_USER:-postgres}" \
|
||||
-e POSTGRES_DB="${POSTGRES_DB:-sonr}" \
|
||||
-e PGSODIUM_ROOT_KEY="${PGSODIUM_ROOT_KEY}" \
|
||||
-v ${POSTGRES_DATA_DIR}:/var/lib/postgresql/data \
|
||||
-p ${POSTGRES_PORT:-5432}:5432 \
|
||||
${POSTGRES_DOCKER_IMAGE}
|
||||
availability:
|
||||
restart: "on_failure"
|
||||
backoff_seconds: 5
|
||||
max_restarts: 5
|
||||
readiness_probe:
|
||||
exec:
|
||||
command: "docker exec ${POSTGRES_CONTAINER_NAME} pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-hway}"
|
||||
initial_delay_seconds: 15
|
||||
period_seconds: 10
|
||||
shutdown:
|
||||
command: "docker stop ${POSTGRES_CONTAINER_NAME} || true"
|
||||
timeout_seconds: 30
|
||||
log_location: "{{ .Virtenv }}/logs/postgres-sonr.log"
|
||||
Executable
+293
@@ -0,0 +1,293 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
# Load .env file if it exists
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
if [ -f "${REPO_ROOT}/.env" ]; then
|
||||
set -a
|
||||
source "${REPO_ROOT}/.env"
|
||||
set +a
|
||||
fi
|
||||
|
||||
export CHAIN_ID=${CHAIN_ID:-"sonrtest_1-1"}
|
||||
export DENOM=${DENOM:-"usnr"}
|
||||
export KEYRING=${KEYRING:-"test"}
|
||||
export KEYALGO="eth_secp256k1"
|
||||
|
||||
VALIDATORS=("alice" "bob" "carol")
|
||||
VAL_HOMES=("./val-alice" "./val-bob" "./val-carol")
|
||||
SENTRY_HOMES=("./sentry-alice" "./sentry-bob" "./sentry-carol")
|
||||
|
||||
# Get mnemonics from environment
|
||||
declare -A MNEMONICS
|
||||
MNEMONICS["alice"]="$ALICE_MNEMONIC"
|
||||
MNEMONICS["bob"]="$BOB_MNEMONIC"
|
||||
MNEMONICS["carol"]="$CAROL_MNEMONIC"
|
||||
MNEMONICS["faucet"]="$FAUCET_MNEMONIC"
|
||||
|
||||
echo "🚀 Initializing Sonr Testnet with 3 validators..."
|
||||
echo "Chain ID: $CHAIN_ID"
|
||||
echo "Denom: $DENOM"
|
||||
echo ""
|
||||
|
||||
# Check if snrd is available locally
|
||||
if ! command -v snrd &> /dev/null; then
|
||||
echo "❌ snrd binary not found in PATH"
|
||||
echo "Please install snrd locally or add it to your PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Using local snrd: $(which snrd)"
|
||||
echo ""
|
||||
|
||||
# Function to initialize a validator node
|
||||
init_validator() {
|
||||
local name=$1
|
||||
local home_dir=$2
|
||||
local mnemonic=$3
|
||||
|
||||
echo "📋 Initializing validator: $name"
|
||||
|
||||
local abs_home="${REPO_ROOT}/${home_dir#./}"
|
||||
rm -rf "$abs_home" 2>/dev/null || true
|
||||
mkdir -p "$abs_home"
|
||||
|
||||
echo | snrd --home "$abs_home" init "val-$name" --chain-id "$CHAIN_ID" --default-denom "$DENOM" --overwrite >/dev/null 2>&1
|
||||
|
||||
snrd --home "$abs_home" keys delete "$name" --keyring-backend "$KEYRING" -y 2>/dev/null || true
|
||||
|
||||
echo "$mnemonic" | snrd --home "$abs_home" keys add "$name" \
|
||||
--keyring-backend "$KEYRING" \
|
||||
--algo "$KEYALGO" \
|
||||
--recover
|
||||
|
||||
update_config "$abs_home"
|
||||
}
|
||||
|
||||
# Function to initialize a sentry node
|
||||
init_sentry() {
|
||||
local name=$1
|
||||
local home_dir=$2
|
||||
|
||||
echo "🛡️ Initializing sentry: $name"
|
||||
|
||||
local abs_home="${REPO_ROOT}/${home_dir#./}"
|
||||
rm -rf "$abs_home" 2>/dev/null || true
|
||||
mkdir -p "$abs_home"
|
||||
|
||||
echo | snrd --home "$abs_home" init "sentry-$name" --chain-id "$CHAIN_ID" --default-denom "$DENOM" --overwrite >/dev/null 2>&1
|
||||
|
||||
update_config "$abs_home"
|
||||
}
|
||||
|
||||
# Function to update node config
|
||||
update_config() {
|
||||
local abs_home=$1
|
||||
|
||||
sed -i 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/g' "${abs_home}/config/config.toml"
|
||||
sed -i 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["*"\]/g' "${abs_home}/config/config.toml"
|
||||
sed -i 's/address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:1317"/g' "${abs_home}/config/app.toml"
|
||||
sed -i '/\[api\]/,/\[grpc\]/ s/enable = false/enable = true/' "${abs_home}/config/app.toml"
|
||||
sed -i 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' "${abs_home}/config/app.toml"
|
||||
sed -i 's/address = "localhost:9090"/address = "0.0.0.0:9090"/g' "${abs_home}/config/app.toml"
|
||||
sed -i 's/address = "localhost:9091"/address = "0.0.0.0:9091"/g' "${abs_home}/config/app.toml"
|
||||
}
|
||||
|
||||
# Function to update genesis
|
||||
update_genesis() {
|
||||
local genesis_file="$1"
|
||||
|
||||
cat "$genesis_file" | \
|
||||
jq '.consensus_params.block.max_gas="100000000"' | \
|
||||
jq ".app_state.gov.params.min_deposit=[{\"denom\":\"$DENOM\",\"amount\":\"1000000\"}]" | \
|
||||
jq '.app_state.gov.params.voting_period="30s"' | \
|
||||
jq '.app_state.gov.params.expedited_voting_period="15s"' | \
|
||||
jq ".app_state.evm.params.evm_denom=\"$DENOM\"" | \
|
||||
jq '.app_state.evm.params.active_static_precompiles=["0x0000000000000000000000000000000000000100","0x0000000000000000000000000000000000000400","0x0000000000000000000000000000000000000800","0x0000000000000000000000000000000000000801","0x0000000000000000000000000000000000000802","0x0000000000000000000000000000000000000803","0x0000000000000000000000000000000000000804","0x0000000000000000000000000000000000000805"]' | \
|
||||
jq '.app_state.erc20.params.native_precompiles=["0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"]' | \
|
||||
jq ".app_state.erc20.token_pairs=[{contract_owner:1,erc20_address:\"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE\",denom:\"$DENOM\",enabled:true}]" | \
|
||||
jq '.app_state.feemarket.params.no_base_fee=true' | \
|
||||
jq '.app_state.feemarket.params.base_fee="0.000000000000000000"' | \
|
||||
jq ".app_state.staking.params.bond_denom=\"$DENOM\"" | \
|
||||
jq '.app_state.staking.params.min_commission_rate="0.050000000000000000"' | \
|
||||
jq ".app_state.mint.params.mint_denom=\"$DENOM\"" | \
|
||||
jq ".app_state.crisis.constant_fee={\"denom\":\"$DENOM\",\"amount\":\"1000\"}" | \
|
||||
jq '.consensus.params.abci.vote_extensions_enable_height="1"' | \
|
||||
jq '.app_state.tokenfactory.params.denom_creation_fee=[]' | \
|
||||
jq '.app_state.tokenfactory.params.denom_creation_gas_consume=100000' \
|
||||
> "$genesis_file.tmp" && mv "$genesis_file.tmp" "$genesis_file"
|
||||
}
|
||||
|
||||
# Initialize all validators
|
||||
for i in "${!VALIDATORS[@]}"; do
|
||||
name="${VALIDATORS[$i]}"
|
||||
init_validator "$name" "${VAL_HOMES[$i]}" "${MNEMONICS[$name]}"
|
||||
done
|
||||
|
||||
# Initialize all sentries
|
||||
for i in "${!VALIDATORS[@]}"; do
|
||||
init_sentry "${VALIDATORS[$i]}" "${SENTRY_HOMES[$i]}"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "💰 Adding genesis accounts and creating genesis transactions..."
|
||||
|
||||
BASE_ALLOCATION="100000000000000000000000000${DENOM}"
|
||||
STAKE_AMOUNT="30000000000000000000000${DENOM}"
|
||||
|
||||
# Use alice's validator for genesis creation
|
||||
GENESIS_HOME="./val-alice"
|
||||
|
||||
# Add genesis accounts for all validators
|
||||
GENESIS_ABS_HOME="${REPO_ROOT}/${GENESIS_HOME#./}"
|
||||
for i in "${!VALIDATORS[@]}"; do
|
||||
name="${VALIDATORS[$i]}"
|
||||
abs_home="${REPO_ROOT}/${VAL_HOMES[$i]#./}"
|
||||
# Get address from each validator's keyring
|
||||
addr=$(snrd --home "$abs_home" keys show "$name" --keyring-backend "$KEYRING" -a)
|
||||
# Add to genesis using address
|
||||
snrd --home "$GENESIS_ABS_HOME" genesis add-genesis-account "$addr" "$BASE_ALLOCATION" --append
|
||||
done
|
||||
|
||||
# Add faucet account to genesis
|
||||
echo "💰 Creating faucet account..."
|
||||
snrd --home "$GENESIS_ABS_HOME" keys delete faucet --keyring-backend "$KEYRING" -y 2>/dev/null || true
|
||||
echo "${MNEMONICS["faucet"]}" | snrd --home "$GENESIS_ABS_HOME" keys add faucet \
|
||||
--keyring-backend "$KEYRING" \
|
||||
--algo "$KEYALGO" \
|
||||
--recover
|
||||
FAUCET_ADDR=$(snrd --home "$GENESIS_ABS_HOME" keys show faucet --keyring-backend "$KEYRING" -a)
|
||||
FAUCET_ALLOCATION="${FAUCET_ALLOCATION:-500000000000000000000000000${DENOM}}"
|
||||
snrd --home "$GENESIS_ABS_HOME" genesis add-genesis-account "$FAUCET_ADDR" "$FAUCET_ALLOCATION" --append
|
||||
echo " Faucet address: $FAUCET_ADDR"
|
||||
echo " Faucet balance: $FAUCET_ALLOCATION"
|
||||
|
||||
# Distribute genesis with all accounts to all validators before creating gentx
|
||||
for i in "${!VALIDATORS[@]}"; do
|
||||
abs_home="${REPO_ROOT}/${VAL_HOMES[$i]#./}"
|
||||
if [ "$abs_home" != "$GENESIS_ABS_HOME" ]; then
|
||||
cp "$GENESIS_ABS_HOME/config/genesis.json" "$abs_home/config/genesis.json"
|
||||
fi
|
||||
done
|
||||
|
||||
# Create gentx for each validator
|
||||
for i in "${!VALIDATORS[@]}"; do
|
||||
echo "Creating gentx for ${VALIDATORS[$i]}..."
|
||||
abs_home="${REPO_ROOT}/${VAL_HOMES[$i]#./}"
|
||||
snrd --home "$abs_home" genesis gentx "${VALIDATORS[$i]}" "$STAKE_AMOUNT" \
|
||||
--keyring-backend "$KEYRING" \
|
||||
--chain-id "$CHAIN_ID" \
|
||||
--gas-prices "0${DENOM}"
|
||||
|
||||
# Copy gentx to genesis home (skip if same directory)
|
||||
if [ "$abs_home" != "$GENESIS_ABS_HOME" ]; then
|
||||
cp "${abs_home}/config/gentx"/* "$GENESIS_ABS_HOME/config/gentx/"
|
||||
fi
|
||||
done
|
||||
|
||||
# Collect gentxs
|
||||
echo "Collecting genesis transactions..."
|
||||
snrd --home "$GENESIS_ABS_HOME" genesis collect-gentxs
|
||||
|
||||
# Update genesis parameters
|
||||
echo "Updating genesis parameters..."
|
||||
update_genesis "$GENESIS_ABS_HOME/config/genesis.json"
|
||||
|
||||
# Validate genesis
|
||||
echo "Validating genesis..."
|
||||
snrd --home "$GENESIS_ABS_HOME" genesis validate-genesis
|
||||
|
||||
# Distribute genesis to all nodes
|
||||
echo ""
|
||||
echo "📤 Distributing genesis to all nodes..."
|
||||
for home in "${VAL_HOMES[@]}" "${SENTRY_HOMES[@]}"; do
|
||||
if [ "$home" != "$GENESIS_HOME" ]; then
|
||||
abs_home="${REPO_ROOT}/${home#./}"
|
||||
cp "$GENESIS_ABS_HOME/config/genesis.json" "$abs_home/config/genesis.json"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "🔗 Setting up peer connections..."
|
||||
|
||||
# Get validator node IDs
|
||||
declare -A VAL_IDS
|
||||
for i in "${!VALIDATORS[@]}"; do
|
||||
abs_home="${REPO_ROOT}/${VAL_HOMES[$i]#./}"
|
||||
VAL_IDS[${VALIDATORS[$i]}]=$(snrd --home "$abs_home" tendermint show-node-id | tr -d '\r\n')
|
||||
echo " val-${VALIDATORS[$i]}: ${VAL_IDS[${VALIDATORS[$i]}]}"
|
||||
done
|
||||
|
||||
# Get sentry node IDs
|
||||
declare -A SENTRY_IDS
|
||||
for i in "${!VALIDATORS[@]}"; do
|
||||
abs_home="${REPO_ROOT}/${SENTRY_HOMES[$i]#./}"
|
||||
SENTRY_IDS[${VALIDATORS[$i]}]=$(snrd --home "$abs_home" tendermint show-node-id | tr -d '\r\n')
|
||||
echo " sentry-${VALIDATORS[$i]}: ${SENTRY_IDS[${VALIDATORS[$i]}]}"
|
||||
done
|
||||
|
||||
# Configure validators to connect to their sentries only
|
||||
for i in "${!VALIDATORS[@]}"; do
|
||||
name="${VALIDATORS[$i]}"
|
||||
abs_home="${REPO_ROOT}/${VAL_HOMES[$i]#./}"
|
||||
sed -i "s/persistent_peers = \"\"/persistent_peers = \"${SENTRY_IDS[$name]}@sentry-$name:26656\"/g" "${abs_home}/config/config.toml"
|
||||
done
|
||||
|
||||
# Configure sentries to connect to their validators and other sentries
|
||||
for i in "${!VALIDATORS[@]}"; do
|
||||
name="${VALIDATORS[$i]}"
|
||||
abs_home="${REPO_ROOT}/${SENTRY_HOMES[$i]#./}"
|
||||
|
||||
# Build seeds list (all other sentries)
|
||||
seeds=""
|
||||
for j in "${!VALIDATORS[@]}"; do
|
||||
other_name="${VALIDATORS[$j]}"
|
||||
if [ "$name" != "$other_name" ]; then
|
||||
if [ -n "$seeds" ]; then
|
||||
seeds="${seeds},"
|
||||
fi
|
||||
seeds="${seeds}${SENTRY_IDS[$other_name]}@sentry-$other_name:26656"
|
||||
fi
|
||||
done
|
||||
|
||||
# Set persistent peer to own validator and seeds to other sentries
|
||||
sed -i "s/persistent_peers = \"\"/persistent_peers = \"${VAL_IDS[$name]}@val-$name:26656\"/g" "${abs_home}/config/config.toml"
|
||||
sed -i "s/seeds = \"\"/seeds = \"$seeds\"/g" "${abs_home}/config/config.toml"
|
||||
sed -i "s/private_peer_ids = \"\"/private_peer_ids = \"${VAL_IDS[$name]}\"/g" "${abs_home}/config/config.toml"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "✅ Testnet initialization complete!"
|
||||
echo ""
|
||||
echo "🎯 Validator Addresses:"
|
||||
for i in "${!VALIDATORS[@]}"; do
|
||||
abs_home="${REPO_ROOT}/${VAL_HOMES[$i]#./}"
|
||||
addr=$(snrd --home "$abs_home" keys show "${VALIDATORS[$i]}" --keyring-backend "$KEYRING" -a | tr -d '\r\n')
|
||||
echo " ${VALIDATORS[$i]}: $addr"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "💰 Faucet Address:"
|
||||
echo " faucet: $FAUCET_ADDR"
|
||||
|
||||
echo ""
|
||||
echo "📡 Service Endpoints (via Cloudflare Tunnel):"
|
||||
echo " Alice RPC: https://alice-rpc.sonr.land"
|
||||
echo " Alice REST: https://alice-rest.sonr.land"
|
||||
echo " Alice gRPC: https://alice-grpc.sonr.land"
|
||||
echo " Alice EVM: https://alice-evm.sonr.land"
|
||||
echo " Bob RPC: https://bob-rpc.sonr.land"
|
||||
echo " Bob REST: https://bob-rest.sonr.land"
|
||||
echo " Bob gRPC: https://bob-grpc.sonr.land"
|
||||
echo " Bob EVM: https://bob-evm.sonr.land"
|
||||
echo " Carol RPC: https://carol-rpc.sonr.land"
|
||||
echo " Carol REST: https://carol-rest.sonr.land"
|
||||
echo " Carol gRPC: https://carol-grpc.sonr.land"
|
||||
echo " Carol EVM: https://carol-evm.sonr.land"
|
||||
echo " IPFS API: https://ipfs-api.sonr.land"
|
||||
echo " IPFS Gateway: https://ipfs-gateway.sonr.land"
|
||||
echo ""
|
||||
echo "🚀 Start testnet with: docker compose up -d"
|
||||
echo "📊 View logs with: docker compose logs -f"
|
||||
echo "🛑 Stop testnet with: docker compose down"
|
||||
+441
@@ -0,0 +1,441 @@
|
||||
module snrd
|
||||
|
||||
go 1.24.7
|
||||
|
||||
// overrides
|
||||
replace (
|
||||
cosmossdk.io/core => cosmossdk.io/core v0.11.0
|
||||
cosmossdk.io/store => github.com/evmos/cosmos-sdk/store v0.0.0-20240718141609-414cbd051fbe
|
||||
github.com/CosmWasm/wasmd => github.com/rollchains/wasmd v0.50.0-evm
|
||||
|
||||
github.com/cosmos/cosmos-sdk => github.com/strangelove-ventures/cosmos-sdk v0.0.0-20250317212103-0767f8c5b1e5
|
||||
github.com/cosmos/evm => github.com/strangelove-ventures/cosmos-evm v0.2.0
|
||||
github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2
|
||||
github.com/sonr-io/sonr => ../../
|
||||
github.com/sonr-io/sonr/crypto => ../../crypto
|
||||
github.com/spf13/viper => github.com/spf13/viper v1.17.0 // v1.18+ breaks app overrides
|
||||
nhooyr.io/websocket => nhooyr.io/websocket v1.8.17
|
||||
)
|
||||
|
||||
replace (
|
||||
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
|
||||
// Fix btcec version for evmos compatibility
|
||||
github.com/btcsuite/btcd/btcec/v2 => github.com/btcsuite/btcd/btcec/v2 v2.3.2
|
||||
// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
|
||||
// See: https://github.com/cosmos/cosmos-sdk/issues/13134
|
||||
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
|
||||
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
|
||||
// See: https://github.com/cosmos/cosmos-sdk/issues/10409
|
||||
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1
|
||||
|
||||
// pin version! 126854af5e6d has issues with the store so that queries fail
|
||||
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
|
||||
github.com/tyler-smith/go-bip39 => github.com/go-sonr/go-bip39 v1.1.1
|
||||
)
|
||||
|
||||
require (
|
||||
cosmossdk.io/log v1.5.0
|
||||
cosmossdk.io/tools/confix v0.1.2
|
||||
github.com/cometbft/cometbft v0.38.17
|
||||
github.com/cosmos/cosmos-db v1.1.1
|
||||
github.com/cosmos/cosmos-sdk v0.53.4
|
||||
github.com/cosmos/evm v0.1.0
|
||||
github.com/sonr-io/sonr v0.0.0-00010101000000-000000000000
|
||||
github.com/spf13/cast v1.9.2
|
||||
github.com/spf13/cobra v1.8.1
|
||||
github.com/spf13/viper v1.19.0
|
||||
)
|
||||
|
||||
require (
|
||||
cosmossdk.io/api v0.7.6 // indirect
|
||||
cosmossdk.io/client/v2 v2.0.0-beta.7 // indirect
|
||||
cosmossdk.io/collections v0.4.0 // indirect
|
||||
cosmossdk.io/core v0.12.0 // indirect
|
||||
cosmossdk.io/depinject v1.1.0 // indirect
|
||||
cosmossdk.io/errors v1.0.1 // indirect
|
||||
cosmossdk.io/math v1.5.0 // indirect
|
||||
cosmossdk.io/orm v1.0.0-beta.3 // indirect
|
||||
cosmossdk.io/store v1.1.1 // indirect
|
||||
cosmossdk.io/x/circuit v0.1.1 // indirect
|
||||
cosmossdk.io/x/evidence v0.1.1 // indirect
|
||||
cosmossdk.io/x/feegrant v0.1.1 // indirect
|
||||
cosmossdk.io/x/nft v0.1.0 // indirect
|
||||
cosmossdk.io/x/tx v0.13.7 // indirect
|
||||
cosmossdk.io/x/upgrade v0.1.4 // indirect
|
||||
github.com/CosmWasm/wasmvm v1.5.8 // indirect
|
||||
github.com/Oudwins/zog v0.21.6 // indirect
|
||||
github.com/asynkron/protoactor-go v0.0.0-20240822202345-3c0e61ca19c9 // indirect
|
||||
github.com/biter777/countries v1.7.5 // indirect
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
|
||||
github.com/cosmos/go-bip39 v1.0.0 // indirect
|
||||
github.com/cosmos/gogoproto v1.7.0 // indirect
|
||||
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.1.1 // indirect
|
||||
github.com/cosmos/ibc-apps/modules/rate-limiting/v8 v8.0.0 // indirect
|
||||
github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect
|
||||
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092650-57fcdb9a9a9d // indirect
|
||||
github.com/cosmos/ibc-go/v8 v8.7.0 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
|
||||
github.com/ethereum/go-ethereum v1.16.3 // indirect
|
||||
github.com/extism/go-sdk v1.7.1 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/go-tpm v0.9.5 // indirect
|
||||
github.com/gorilla/mux v1.8.1 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
|
||||
github.com/ipfs/boxo v0.32.0 // indirect
|
||||
github.com/ipfs/kubo v0.35.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/labstack/echo/v4 v4.13.4 // indirect
|
||||
github.com/labstack/gommon v0.4.2 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/sonr-io/sonr/crypto v0.0.0-00010101000000-000000000000 // indirect
|
||||
github.com/strangelove-ventures/tokenfactory v0.50.3 // indirect
|
||||
github.com/stretchr/testify v1.10.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.11 // indirect
|
||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 // indirect
|
||||
google.golang.org/grpc v1.71.0 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gorm.io/driver/sqlite v1.6.0 // indirect
|
||||
gorm.io/gorm v1.30.1 // indirect
|
||||
nhooyr.io/websocket v1.8.10 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.115.0 // indirect
|
||||
cloud.google.com/go/auth v0.6.0 // indirect
|
||||
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.6.0 // indirect
|
||||
cloud.google.com/go/iam v1.1.9 // indirect
|
||||
cloud.google.com/go/storage v1.41.0 // indirect
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
||||
github.com/99designs/keyring v1.2.1 // indirect
|
||||
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
|
||||
github.com/DataDog/zstd v1.5.6-0.20230824185856-869dae002e5e // indirect
|
||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
|
||||
github.com/Workiva/go-datastructures v1.1.3 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
|
||||
github.com/alexvec/go-bip39 v1.1.0 // indirect
|
||||
github.com/aws/aws-sdk-go v1.55.6 // indirect
|
||||
github.com/benbjohnson/clock v1.3.5 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
|
||||
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.24.0 // indirect
|
||||
github.com/blang/semver/v4 v4.0.0 // indirect
|
||||
github.com/btcsuite/btcd v0.24.2 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
|
||||
github.com/btcsuite/btcd/btcutil v1.1.6 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
|
||||
github.com/bwesterb/go-ristretto v1.2.3 // indirect
|
||||
github.com/bytedance/sonic v1.14.0 // indirect
|
||||
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
||||
github.com/caddyserver/certmagic v0.21.6 // indirect
|
||||
github.com/caddyserver/zerossl v0.1.3 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/chzyer/readline v1.5.1 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
|
||||
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
|
||||
github.com/cockroachdb/crlib v0.0.0-20241015224233-894974b3ad94 // indirect
|
||||
github.com/cockroachdb/errors v1.11.3 // indirect
|
||||
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
|
||||
github.com/cockroachdb/pebble v1.1.2 // indirect
|
||||
github.com/cockroachdb/pebble/v2 v2.0.3 // indirect
|
||||
github.com/cockroachdb/redact v1.1.5 // indirect
|
||||
github.com/cockroachdb/swiss v0.0.0-20250624142022-d6e517c1d961 // indirect
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
|
||||
github.com/cometbft/cometbft-db v0.14.1 // indirect
|
||||
github.com/consensys/gnark-crypto v0.19.0 // indirect
|
||||
github.com/cosmos/btcutil v1.0.5 // indirect
|
||||
github.com/cosmos/gogogateway v1.2.0 // indirect
|
||||
github.com/cosmos/iavl v1.2.2 // indirect
|
||||
github.com/cosmos/ics23/go v0.11.0 // indirect
|
||||
github.com/cosmos/ledger-cosmos-go v0.14.0 // indirect
|
||||
github.com/crackcomm/go-gitignore v0.0.0-20241020182519-7843d2ba8fdf // indirect
|
||||
github.com/creachadair/atomicfile v0.3.1 // indirect
|
||||
github.com/creachadair/tomledit v0.0.24 // indirect
|
||||
github.com/danieljoos/wincred v1.1.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
|
||||
github.com/deckarep/golang-set v1.8.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
|
||||
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
|
||||
github.com/dgraph-io/ristretto v0.1.1 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.0 // indirect
|
||||
github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
|
||||
github.com/dylibso/observe-sdk/go v0.0.0-20240819160327-2d926c5d788a // indirect
|
||||
github.com/edsrzf/mmap-go v1.1.0 // indirect
|
||||
github.com/emicklei/dot v1.6.2 // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/flynn/noise v1.1.0 // indirect
|
||||
github.com/francoispqt/gojay v1.2.13 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/gammazero/deque v1.0.0 // indirect
|
||||
github.com/getsentry/sentry-go v0.27.0 // indirect
|
||||
github.com/go-kit/kit v0.13.0 // indirect
|
||||
github.com/go-kit/log v0.2.1 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
|
||||
github.com/go-stack/stack v1.8.1 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
|
||||
github.com/gogo/googleapis v1.4.1 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/gogo/status v1.1.0 // indirect
|
||||
github.com/golang/glog v1.2.4 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/snappy v0.0.5-0.20231225225746-43d5d4cd4e0e // indirect
|
||||
github.com/google/btree v1.1.3 // indirect
|
||||
github.com/google/flatbuffers v23.5.26+incompatible // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
github.com/google/gopacket v1.1.19 // indirect
|
||||
github.com/google/orderedcode v0.0.1 // indirect
|
||||
github.com/google/s2a-go v0.1.7 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.12.5 // indirect
|
||||
github.com/gopherjs/gopherjs v1.17.2 // indirect
|
||||
github.com/gorilla/handlers v1.5.2 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
|
||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
|
||||
github.com/gtank/merlin v0.1.1 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-getter v1.7.9 // indirect
|
||||
github.com/hashicorp/go-hclog v1.5.0 // indirect
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
github.com/hashicorp/go-metrics v0.5.3 // indirect
|
||||
github.com/hashicorp/go-plugin v1.5.2 // indirect
|
||||
github.com/hashicorp/go-safetemp v1.0.0 // indirect
|
||||
github.com/hashicorp/go-version v1.7.0 // indirect
|
||||
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
|
||||
github.com/holiman/uint256 v1.3.2 // indirect
|
||||
github.com/huandu/skiplist v1.2.0 // indirect
|
||||
github.com/huin/goupnp v1.3.0 // indirect
|
||||
github.com/iancoleman/orderedmap v0.3.0 // indirect
|
||||
github.com/iancoleman/strcase v0.3.0 // indirect
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca // indirect
|
||||
github.com/improbable-eng/grpc-web v0.15.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/ipfs/bbloom v0.0.4 // indirect
|
||||
github.com/ipfs/go-bitfield v1.1.0 // indirect
|
||||
github.com/ipfs/go-block-format v0.2.1 // indirect
|
||||
github.com/ipfs/go-cid v0.5.0 // indirect
|
||||
github.com/ipfs/go-datastore v0.8.2 // indirect
|
||||
github.com/ipfs/go-ds-measure v0.2.2 // indirect
|
||||
github.com/ipfs/go-fs-lock v0.1.1 // indirect
|
||||
github.com/ipfs/go-ipfs-cmds v0.14.1 // indirect
|
||||
github.com/ipfs/go-ipld-cbor v0.2.0 // indirect
|
||||
github.com/ipfs/go-ipld-format v0.6.1 // indirect
|
||||
github.com/ipfs/go-ipld-legacy v0.2.1 // indirect
|
||||
github.com/ipfs/go-log v1.0.5 // indirect
|
||||
github.com/ipfs/go-log/v2 v2.6.0 // indirect
|
||||
github.com/ipfs/go-metrics-interface v0.3.0 // indirect
|
||||
github.com/ipfs/go-unixfsnode v1.10.1 // indirect
|
||||
github.com/ipld/go-car/v2 v2.14.3 // indirect
|
||||
github.com/ipld/go-codec-dagpb v1.7.0 // indirect
|
||||
github.com/ipld/go-ipld-prime v0.21.0 // indirect
|
||||
github.com/ipshipyard/p2p-forge v0.5.1 // indirect
|
||||
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
|
||||
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/jmhodges/levigo v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||
github.com/koron/go-ssdp v0.0.6 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/lib/pq v1.10.9 // indirect
|
||||
github.com/libdns/libdns v0.2.2 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
||||
github.com/libp2p/go-cidranger v1.1.0 // indirect
|
||||
github.com/libp2p/go-flow-metrics v0.2.0 // indirect
|
||||
github.com/libp2p/go-libp2p v0.43.0 // indirect
|
||||
github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect
|
||||
github.com/libp2p/go-libp2p-kad-dht v0.33.1 // indirect
|
||||
github.com/libp2p/go-libp2p-kbucket v0.7.0 // indirect
|
||||
github.com/libp2p/go-libp2p-record v0.3.1 // indirect
|
||||
github.com/libp2p/go-libp2p-routing-helpers v0.7.5 // indirect
|
||||
github.com/libp2p/go-msgio v0.3.0 // indirect
|
||||
github.com/libp2p/go-netroute v0.2.2 // indirect
|
||||
github.com/libp2p/go-reuseport v0.4.0 // indirect
|
||||
github.com/linxGnu/grocksdb v1.9.8 // indirect
|
||||
github.com/lithammer/shortuuid/v4 v4.0.0 // indirect
|
||||
github.com/lmittmann/tint v1.0.3 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/manifoldco/promptui v0.9.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/mholt/acmez/v3 v3.0.0 // indirect
|
||||
github.com/miekg/dns v1.1.66 // indirect
|
||||
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
|
||||
github.com/minio/highwayhash v1.0.3 // indirect
|
||||
github.com/minio/sha256-simd v1.0.1 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||
github.com/mtibben/percent v0.2.1 // indirect
|
||||
github.com/multiformats/go-base32 v0.1.0 // indirect
|
||||
github.com/multiformats/go-base36 v0.2.0 // indirect
|
||||
github.com/multiformats/go-multiaddr v0.16.0 // indirect
|
||||
github.com/multiformats/go-multiaddr-dns v0.4.1 // indirect
|
||||
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
|
||||
github.com/multiformats/go-multibase v0.2.0 // indirect
|
||||
github.com/multiformats/go-multicodec v0.9.1 // indirect
|
||||
github.com/multiformats/go-multihash v0.2.3 // indirect
|
||||
github.com/multiformats/go-multistream v0.6.1 // indirect
|
||||
github.com/multiformats/go-varint v0.1.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
|
||||
github.com/oklog/run v1.1.0 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/orcaman/concurrent-map v1.0.0 // indirect
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 // indirect
|
||||
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
|
||||
github.com/pion/datachannel v1.5.10 // indirect
|
||||
github.com/pion/dtls/v2 v2.2.12 // indirect
|
||||
github.com/pion/dtls/v3 v3.0.6 // indirect
|
||||
github.com/pion/ice/v4 v4.0.10 // indirect
|
||||
github.com/pion/interceptor v0.1.40 // indirect
|
||||
github.com/pion/logging v0.2.3 // indirect
|
||||
github.com/pion/mdns/v2 v2.0.7 // indirect
|
||||
github.com/pion/randutil v0.1.0 // indirect
|
||||
github.com/pion/rtcp v1.2.15 // indirect
|
||||
github.com/pion/rtp v1.8.19 // indirect
|
||||
github.com/pion/sctp v1.8.39 // indirect
|
||||
github.com/pion/sdp/v3 v3.0.13 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.6 // indirect
|
||||
github.com/pion/stun v0.6.1 // indirect
|
||||
github.com/pion/stun/v3 v3.0.0 // indirect
|
||||
github.com/pion/transport/v2 v2.2.10 // indirect
|
||||
github.com/pion/transport/v3 v3.0.7 // indirect
|
||||
github.com/pion/turn/v4 v4.0.2 // indirect
|
||||
github.com/pion/webrtc/v4 v4.1.2 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/polydawn/refmt v0.89.0 // indirect
|
||||
github.com/prometheus/client_golang v1.22.0 // indirect
|
||||
github.com/prometheus/client_model v0.6.2 // indirect
|
||||
github.com/prometheus/common v0.64.0 // indirect
|
||||
github.com/prometheus/procfs v0.16.1 // indirect
|
||||
github.com/prometheus/tsdb v0.10.0 // indirect
|
||||
github.com/quic-go/qpack v0.5.1 // indirect
|
||||
github.com/quic-go/quic-go v0.54.0 // indirect
|
||||
github.com/quic-go/webtransport-go v0.9.0 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/rjeczalik/notify v0.9.3 // indirect
|
||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||
github.com/rs/cors v1.11.1 // indirect
|
||||
github.com/rs/zerolog v1.33.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/samber/lo v1.47.0 // indirect
|
||||
github.com/sasha-s/go-deadlock v0.3.5 // indirect
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
|
||||
github.com/smarty/assertions v1.15.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/pflag v1.0.6 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
|
||||
github.com/tendermint/go-amino v0.16.0 // indirect
|
||||
github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834 // indirect
|
||||
github.com/tetratelabs/wazero v1.9.0 // indirect
|
||||
github.com/tidwall/btree v1.7.0 // indirect
|
||||
github.com/tidwall/gjson v1.18.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
github.com/tidwall/sjson v1.2.5 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/twmb/murmur3 v1.1.8 // indirect
|
||||
github.com/ulikunitz/xz v0.5.11 // indirect
|
||||
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect
|
||||
github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect
|
||||
github.com/whyrusleeping/cbor-gen v0.1.2 // indirect
|
||||
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
|
||||
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
|
||||
github.com/wlynxg/anet v0.0.5 // indirect
|
||||
github.com/zeebo/blake3 v0.2.4 // indirect
|
||||
github.com/zondax/hid v0.9.2 // indirect
|
||||
github.com/zondax/ledger-go v0.14.3 // indirect
|
||||
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect
|
||||
go.opentelemetry.io/otel v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.44.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk/metric v1.34.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.35.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
||||
go.uber.org/dig v1.19.0 // indirect
|
||||
go.uber.org/fx v1.24.0 // indirect
|
||||
go.uber.org/mock v0.5.2 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.uber.org/zap/exp v0.3.0 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.2 // indirect
|
||||
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
|
||||
golang.org/x/arch v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.42.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 // indirect
|
||||
golang.org/x/mod v0.27.0 // indirect
|
||||
golang.org/x/net v0.43.0 // indirect
|
||||
golang.org/x/oauth2 v0.30.0 // indirect
|
||||
golang.org/x/sync v0.17.0 // indirect
|
||||
golang.org/x/sys v0.36.0 // indirect
|
||||
golang.org/x/term v0.35.0 // indirect
|
||||
golang.org/x/text v0.29.0 // indirect
|
||||
golang.org/x/time v0.12.0 // indirect
|
||||
golang.org/x/tools v0.36.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
|
||||
gonum.org/v1/gonum v0.16.0 // indirect
|
||||
google.golang.org/api v0.186.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gotest.tools/v3 v3.5.1 // indirect
|
||||
lukechampine.com/blake3 v1.4.1 // indirect
|
||||
pgregory.net/rapid v1.1.0 // indirect
|
||||
sigs.k8s.io/yaml v1.5.0 // indirect
|
||||
)
|
||||
+3106
File diff suppressed because it is too large
Load Diff
Executable
+37
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/sonr-io/sonr/app"
|
||||
)
|
||||
|
||||
func main() {
|
||||
setupSDKConfig()
|
||||
|
||||
// Standard snrd execution
|
||||
rootCmd := NewRootCmd()
|
||||
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
|
||||
fmt.Fprintln(rootCmd.OutOrStderr(), err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func setupSDKConfig() {
|
||||
config := sdk.GetConfig()
|
||||
SetBech32Prefixes(config)
|
||||
config.SetCoinType(app.CoinType)
|
||||
config.SetPurpose(44)
|
||||
config.Seal()
|
||||
}
|
||||
|
||||
// SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings.
|
||||
func SetBech32Prefixes(config *sdk.Config) {
|
||||
config.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub)
|
||||
config.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub)
|
||||
config.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub)
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "snrd",
|
||||
"version": "0.1.0",
|
||||
"description": "Plugin for Sonr PostgreSQL Docker image with pgsodium support and auto-start service",
|
||||
"packages": ["docker@latest"],
|
||||
"env": {
|
||||
"POSTGRES_HOST": "localhost",
|
||||
"POSTGRES_PORT": "${POSTGRES_PORT:-5432}",
|
||||
"POSTGRES_USER": "${POSTGRES_USER:-postgres}",
|
||||
"POSTGRES_PASSWORD": "${POSTGRES_PASSWORD:-password}",
|
||||
"POSTGRES_DB": "${POSTGRES_DB:-sonr}",
|
||||
"PGSODIUM_ROOT_KEY": "${PGSODIUM_ROOT_KEY:-}",
|
||||
"POSTGRES_DATA_DIR": "{{ .Virtenv }}/data",
|
||||
"POSTGRES_DOCKER_IMAGE": "ghcr.io/sonr-io/postgres:latest",
|
||||
"POSTGRES_HOST_AUTH_METHOD": "trust",
|
||||
"POSTGRES_CONTAINER_NAME": "devbox-postgres-sonr"
|
||||
},
|
||||
"create_files": {
|
||||
"{{ .Virtenv }}/data": "",
|
||||
"{{ .Virtenv }}/logs": "",
|
||||
"{{ .Virtenv }}/process-compose.yaml": "etc/process-compose.yaml",
|
||||
"{{ .DevboxDir }}/init.sh": "etc/init.sh"
|
||||
},
|
||||
"shell": {
|
||||
"init_hook": ["chmod +x {{ .DevboxDir }}/init.sh", "{{ .DevboxDir }}/init.sh"],
|
||||
"scripts": {
|
||||
"start": "devbox services start postgres-sonr",
|
||||
"stop": "devbox services stop postgres-sonr",
|
||||
"restart": "devbox services restart postgres-sonr",
|
||||
"logs": "docker logs -f ${POSTGRES_CONTAINER_NAME}",
|
||||
"shell": "docker exec -it ${POSTGRES_CONTAINER_NAME} psql -U ${POSTGRES_USER} -d ${POSTGRES_DB}",
|
||||
"exec": "docker exec -it ${POSTGRES_CONTAINER_NAME} bash",
|
||||
"status": "docker exec ${POSTGRES_CONTAINER_NAME} pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB} && echo 'PostgreSQL is ready' || echo 'PostgreSQL is not ready'",
|
||||
"backup": "docker exec ${POSTGRES_CONTAINER_NAME} pg_dumpall -U ${POSTGRES_USER} > {{ .DevboxProjectDir }}/backup-$(date +%Y%m%d-%H%M%S).sql",
|
||||
"reset": [
|
||||
"devbox services stop postgres-sonr",
|
||||
"rm -rf {{ .Virtenv }}/data/*",
|
||||
"devbox services start postgres-sonr"
|
||||
],
|
||||
"generate-key": "openssl rand -hex 32"
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+131
@@ -0,0 +1,131 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/config"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
|
||||
evmoskeyring "github.com/cosmos/evm/crypto/keyring"
|
||||
|
||||
"github.com/sonr-io/sonr/app"
|
||||
"github.com/sonr-io/sonr/app/params"
|
||||
)
|
||||
|
||||
// NewRootCmd creates a new root command for chain app. It is called once in the
|
||||
// main function.
|
||||
func NewRootCmd() *cobra.Command {
|
||||
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
|
||||
// note, this is not necessary when using app wiring, as depinject can be directly used (see root_v2.go)
|
||||
tempApp := app.NewChainApp(
|
||||
log.NewNopLogger(),
|
||||
dbm.NewMemDB(),
|
||||
nil,
|
||||
false,
|
||||
simtestutil.NewAppOptionsWithFlagHome(tempDir()),
|
||||
app.EVMAppOptions,
|
||||
)
|
||||
encodingConfig := params.EncodingConfig{
|
||||
InterfaceRegistry: tempApp.InterfaceRegistry(),
|
||||
Codec: tempApp.AppCodec(),
|
||||
TxConfig: tempApp.TxConfig(),
|
||||
Amino: tempApp.LegacyAmino(),
|
||||
}
|
||||
|
||||
initClientCtx := client.Context{}.
|
||||
WithCodec(encodingConfig.Codec).
|
||||
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
|
||||
WithTxConfig(encodingConfig.TxConfig).
|
||||
WithLegacyAmino(encodingConfig.Amino).
|
||||
WithInput(os.Stdin).
|
||||
WithAccountRetriever(authtypes.AccountRetriever{}).
|
||||
WithHomeDir(app.DefaultNodeHome).
|
||||
WithBroadcastMode(flags.FlagBroadcastMode).
|
||||
WithKeyringOptions(evmoskeyring.Option()).
|
||||
WithLedgerHasProtobuf(true).
|
||||
WithViper("")
|
||||
|
||||
rootCmd := &cobra.Command{
|
||||
Use: version.AppName,
|
||||
Short: version.AppName + " Daemon (server)",
|
||||
SilenceErrors: true,
|
||||
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
|
||||
// set the default command outputs
|
||||
var err error
|
||||
cmd.SetOut(cmd.OutOrStdout())
|
||||
cmd.SetErr(cmd.ErrOrStderr())
|
||||
|
||||
initClientCtx = initClientCtx.WithCmdContext(cmd.Context())
|
||||
initClientCtx, err = client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
initClientCtx, err = config.ReadFromClientConfig(initClientCtx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// This needs to go after ReadFromClientConfig, as that function
|
||||
// sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode
|
||||
// is only available if the client is online.
|
||||
if !initClientCtx.Offline {
|
||||
enabledSignModes := append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
|
||||
txConfigOpts := tx.ConfigOptions{
|
||||
EnabledSignModes: enabledSignModes,
|
||||
TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx),
|
||||
}
|
||||
txConfig, err := tx.NewTxConfigWithOptions(
|
||||
initClientCtx.Codec,
|
||||
txConfigOpts,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
initClientCtx = initClientCtx.WithTxConfig(txConfig)
|
||||
}
|
||||
|
||||
if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
customAppTemplate, customAppConfig := initAppConfig()
|
||||
customCMTConfig := initCometBFTConfig()
|
||||
|
||||
return server.InterceptConfigsPreRunHandler(
|
||||
cmd,
|
||||
customAppTemplate,
|
||||
customAppConfig,
|
||||
customCMTConfig,
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
initRootCmd(rootCmd, tempApp)
|
||||
|
||||
// add keyring to autocli opts
|
||||
autoCliOpts := tempApp.AutoCliOpts()
|
||||
initClientCtx, _ = config.ReadFromClientConfig(initClientCtx)
|
||||
autoCliOpts.ClientCtx = initClientCtx
|
||||
|
||||
if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Return the root command
|
||||
return rootCmd
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package main
|
||||
|
||||
// Version is set by commitizen during release process
|
||||
var Version = "dev"
|
||||
Reference in New Issue
Block a user