Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
GO ?= go
IGNITE ?= ignite
BUF ?= buf
GOLANGCI_LINT ?= golangci-lint
BUILD_DIR ?= build
RELEASE_DIR ?= release

Expand Down Expand Up @@ -114,10 +115,14 @@ release:
###################################################
### Tests and Simulation ###
###################################################
.PHONY: unit-tests integration-tests system-tests simulation-tests all-tests
.PHONY: unit-tests integration-tests system-tests simulation-tests all-tests lint

all-tests: unit-tests integration-tests system-tests simulation-tests

lint:
@echo "Running linters..."
@${GOLANGCI_LINT} run ./... --timeout=5m

unit-tests:
@echo "Running unit tests in x/..."
${GO} test ./x/... -v -coverprofile=coverage.out
Expand All @@ -138,4 +143,3 @@ simulation-tests:
systemex-tests:
@echo "Running system tests..."
cd ./tests/systemtests/ && go test -tags=system_test -v .

7 changes: 5 additions & 2 deletions Makefile.devnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: devnet-build devnet-up devnet-reset devnet-up-detach devnet-down devnet-stop devnet-clean devnet-deploy-tar devnet-upgrade devnet-new devnet-start
.PHONY: devnet-build-default _check-devnet-default-cfg devnet-upgrade-binaries devnet-update-scripts
.PHONY: devnet-build-default _check-devnet-default-cfg devnet-upgrade-binaries devnet-upgrade-binaries-default devnet-update-scripts

##### Devnet Makefile ########################################
#
Expand Down Expand Up @@ -233,13 +233,16 @@ devnet-upgrade-binaries:
fi; \
./devnet/scripts/upgrade-binaries.sh "${BUILD_DIR}"

devnet-upgrade-binaries-default:
./devnet/scripts/upgrade-binaries.sh "${DEVNET_BIN_DIR}"

devnet-update-scripts:
@if [ ! -f "$(COMPOSE_FILE)" ]; then \
echo "Missing $(COMPOSE_FILE); run 'make devnet-build' first."; \
exit 1; \
fi
@services="$$(docker compose -f $(COMPOSE_FILE) ps --services)"; \
common_scripts="start.sh validator-setup.sh supernode-setup.sh network-maker-setup.sh"; \
common_scripts="start.sh stop.sh restart.sh validator-setup.sh supernode-setup.sh network-maker-setup.sh"; \
updated=0; \
for svc in $$services; do \
container="$$(docker compose -f $(COMPOSE_FILE) ps -q $$svc)"; \
Expand Down
9 changes: 9 additions & 0 deletions devnet/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type ChainConfig struct {
NetworkMaker struct {
MaxAccounts int `json:"max_accounts"`
AccountBalance string `json:"account_balance"`
Enabled bool `json:"enabled"`
GRPCPort int `json:"grpc_port"`
HTTPPort int `json:"http_port"`
} `json:"network-maker"`
Hermes struct {
Enabled bool `json:"enabled"`
Expand All @@ -59,6 +62,12 @@ type Validator struct {
AccountBalance string `json:"account_balance"`
ValidatorStake string `json:"validator_stake"`
} `json:"initial_distribution"`

NetworkMaker struct {
Enabled bool `json:"enabled,omitempty"`
GRPCPort int `json:"grpc_port,omitempty"`
HTTPPort int `json:"http_port,omitempty"`
} `json:"network-maker,omitempty"`
}

func LoadConfigs(configPath, validatorsPath string) (*ChainConfig, []Validator, error) {
Expand Down
5 changes: 4 additions & 1 deletion devnet/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"keyring_backend": "test"
},
"network-maker": {
"max_accounts": 5,
"enabled": true,
"grpc_port": 50051,
"http_port": 8080,
"max_accounts": 3,
"account_balance": "10000000ulume"
},
"hermes": {
Expand Down
8 changes: 6 additions & 2 deletions devnet/config/validators.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
"supernode_port": 7445,
"supernode_p2p_port": 7446,
"supernode_gateway_port": 18003,
"network-maker": true,
"network-maker": {
"enabled": true,
"grpc_port": 50051,
"http_port": 8080
},
"initial_distribution": {
"account_balance": "2000000000000ulume",
"validator_stake": "1000000000000ulume"
Expand Down Expand Up @@ -80,4 +84,4 @@
"validator_stake": "1000000000000ulume"
}
}
]
]
12 changes: 10 additions & 2 deletions devnet/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,31 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
iputils-ping \
lnav \
mc \
nginx-light \
&& rm -rf /var/lib/apt/lists/*

# Install Node.js (for network-maker UI tooling) using NodeSource 25.x
RUN curl -fsSL https://deb.nodesource.com/setup_25.x | bash - && \
apt-get update && apt-get install -y --no-install-recommends nodejs && \
rm -rf /var/lib/apt/lists/*

# Update libraries cache & create directories
RUN ldconfig && mkdir -p ${SCRIPTS_DEST_DIR} /root/.lumerad

# Copy scripts with correct paths
COPY --chmod=0755 \
${SCRIPTS_SRC_DIR}/start.sh \
${SCRIPTS_SRC_DIR}/stop.sh \
${SCRIPTS_SRC_DIR}/restart.sh \
${SCRIPTS_SRC_DIR}/validator-setup.sh \
${SCRIPTS_SRC_DIR}/supernode-setup.sh \
${SCRIPTS_SRC_DIR}/network-maker-setup.sh \
${SCRIPTS_DEST_DIR}/

# Expose necessary ports
EXPOSE 26656 26657 1317 9090 4444 8002
EXPOSE 26656 26657 1317 9090 4444 8002 50051 8080 8088

# Set working directory
WORKDIR /root

ENTRYPOINT ["/bin/bash", "/root/scripts/start.sh"]
ENTRYPOINT ["/bin/bash", "/root/scripts/start.sh"]
6 changes: 6 additions & 0 deletions devnet/generators/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ const (
DefaultSupernodePort = 4444
DefaultSupernodeP2PPort = 4445
DefaultSupernodeGatewayPort = 8002
DefaultNetworkMakerGRPCPort = 50051
DefaultNetworkMakerHTTPPort = 8080
DefaultNetworkMakerUIPort = 8088
DefaultGRPCWebPort = 9091
DefaultHermesSimdHostP2PPort = 36656
DefaultHermesSimdHostRPCPort = 36657
DefaultHermesSimdHostAPIPort = 31317
DefaultHermesSimdHostGRPCPort = 39090
DefaultHermesSimdHostGRPCWebPort = 39091

EnvNMAPIBase = "VITE_API_BASE"
EnvNMAPIToken = "VITE_API_KEY"

FolderScripts = "/root/scripts"
SubFolderShared = "shared"
SubFolderConfig = "config"
Expand Down
90 changes: 77 additions & 13 deletions devnet/generators/docker-compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import (
"gopkg.in/yaml.v2"
)

const (
defaultNetworkDriver = "bridge"
defaultNetworkSubnet = "172.28.0.0/24"
defaultNetworkPrefix = "172.28.0."
defaultServiceIPStart = 10
)

type DockerComposeLogging struct {
Driver string `yaml:"driver"`
Options map[string]string `yaml:"options,omitempty"`
Expand All @@ -20,21 +27,36 @@ type DockerComposeConfig struct {
}

type DockerComposeService struct {
Build string `yaml:"build"`
Image string `yaml:"image,omitempty"`
ContainerName string `yaml:"container_name"`
Ports []string `yaml:"ports"`
Volumes []string `yaml:"volumes"`
Environment map[string]string `yaml:"environment,omitempty"`
Command string `yaml:"command,omitempty"`
DependsOn []string `yaml:"depends_on,omitempty"`
CapAdd []string `yaml:"cap_add,omitempty"`
SecurityOpt []string `yaml:"security_opt,omitempty"`
Logging *DockerComposeLogging `yaml:"logging,omitempty"`
Build string `yaml:"build"`
Image string `yaml:"image,omitempty"`
ContainerName string `yaml:"container_name"`
Ports []string `yaml:"ports"`
Volumes []string `yaml:"volumes"`
Environment map[string]string `yaml:"environment,omitempty"`
Command string `yaml:"command,omitempty"`
DependsOn []string `yaml:"depends_on,omitempty"`
Networks map[string]DockerComposeServiceNetwork `yaml:"networks,omitempty"`
CapAdd []string `yaml:"cap_add,omitempty"`
SecurityOpt []string `yaml:"security_opt,omitempty"`
Logging *DockerComposeLogging `yaml:"logging,omitempty"`
}

type DockerComposeNetwork struct {
Name string `yaml:"name"`
Name string `yaml:"name"`
Driver string `yaml:"driver,omitempty"`
IPAM *DockerComposeIPAM `yaml:"ipam,omitempty"`
}

type DockerComposeIPAM struct {
Config []DockerComposeIPAMConfig `yaml:"config,omitempty"`
}

type DockerComposeIPAMConfig struct {
Subnet string `yaml:"subnet,omitempty"`
}

type DockerComposeServiceNetwork struct {
IPv4Address string `yaml:"ipv4_address,omitempty"`
}

func supernodeBinaryHostPath() (string, bool) {
Expand All @@ -55,14 +77,23 @@ func GenerateDockerCompose(config *confg.ChainConfig, validators []confg.Validat
Services: make(map[string]DockerComposeService),
Networks: map[string]DockerComposeNetwork{
"default": {
Name: config.Docker.NetworkName,
Name: config.Docker.NetworkName,
Driver: defaultNetworkDriver,
IPAM: &DockerComposeIPAM{
Config: []DockerComposeIPAMConfig{
{
Subnet: defaultNetworkSubnet,
},
},
},
},
},
}

_, snPresent := supernodeBinaryHostPath()

folderMount := fmt.Sprintf("/tmp/%s", config.Chain.ID)
validatorBaseIP := defaultServiceIPStart + 1

for index, validator := range validators {
serviceName := fmt.Sprintf("%s-%s", config.Docker.ContainerPrefix, validator.Name)
Expand Down Expand Up @@ -95,6 +126,11 @@ func GenerateDockerCompose(config *confg.ChainConfig, validators []confg.Validat
CapAdd: []string{
"SYS_PTRACE",
},
Networks: map[string]DockerComposeServiceNetwork{
"default": {
IPv4Address: fmt.Sprintf("%s%d", defaultNetworkPrefix, validatorBaseIP+index),
},
},
SecurityOpt: []string{
"seccomp=unconfined",
},
Expand Down Expand Up @@ -125,6 +161,29 @@ func GenerateDockerCompose(config *confg.ChainConfig, validators []confg.Validat
service.DependsOn = []string{validators[0].Name}
}

if validator.NetworkMaker.Enabled {
nmGrpc := validator.NetworkMaker.GRPCPort
if nmGrpc == 0 {
nmGrpc = DefaultNetworkMakerGRPCPort
}
nmHTTP := validator.NetworkMaker.HTTPPort
if nmHTTP == 0 {
nmHTTP = DefaultNetworkMakerHTTPPort
}
service.Ports = append(service.Ports,
fmt.Sprintf("%d:%d", nmGrpc, DefaultNetworkMakerGRPCPort),
fmt.Sprintf("%d:%d", nmHTTP, DefaultNetworkMakerHTTPPort),
fmt.Sprintf("%d:%d", DefaultNetworkMakerUIPort, DefaultNetworkMakerUIPort),
)

if config.NetworkMaker.GRPCPort > 0 {
env[EnvNMAPIBase] = fmt.Sprintf("http://localhost:%d", nmHTTP)
}
if config.NetworkMaker.AccountBalance != "" {
// reserve env slot for key if provided in config (optional)
}
}

compose.Services[validator.Name] = service
}

Expand All @@ -144,6 +203,11 @@ func GenerateDockerCompose(config *confg.ChainConfig, validators []confg.Validat
fmt.Sprintf("%s/hermes-router:%s", folderMount, HermesStateHome),
fmt.Sprintf("%s/shared:/shared", folderMount),
},
Networks: map[string]DockerComposeServiceNetwork{
"default": {
IPv4Address: fmt.Sprintf("%s%d", defaultNetworkPrefix, defaultServiceIPStart),
},
},
Environment: map[string]string{
"HERMES_CONFIG": "/root/.hermes/config.toml",
},
Expand Down
12 changes: 11 additions & 1 deletion devnet/scripts/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ NM="network-maker"
NM_CFG="${BIN_DIR}/nm-config.toml"
SNCLI="sncli"
SNCLI_CFG="${BIN_DIR}/sncli-config.toml"
NM_UI_SRC="${BIN_DIR}/nm-ui"
NM_UI_DST="${RELEASE_DIR}/nm-ui"

install_supernode() {
if [ -n "${BIN_DIR}" ] && [ -f "${BIN_DIR}/${SN}" ]; then
Expand All @@ -113,6 +115,14 @@ install_nm() {
echo "[CONFIGURE] Copying network-maker file from ${BIN_DIR} to ${RELEASE_DIR}"
cp -f "${BIN_DIR}/${NM}" "${NM_CFG}" "${RELEASE_DIR}/"
chmod 755 "${RELEASE_DIR}/${NM}"

if [ -d "${NM_UI_SRC}" ]; then
echo "[CONFIGURE] Copying network-maker UI from ${NM_UI_SRC} to ${NM_UI_DST}"
rm -rf "${NM_UI_DST}"
cp -r "${NM_UI_SRC}" "${NM_UI_DST}"
else
echo "[CONFIGURE] network-maker UI not found at ${NM_UI_SRC}; skipping UI copy"
fi
fi
}

Expand All @@ -137,4 +147,4 @@ echo "[CONFIGURE] Configuration files copied to ${CFG_DIR}"
install_supernode
install_sncli
install_nm
echo "[CONFIGURE] Lumera configuration completed successfully."
echo "[CONFIGURE] Lumera configuration completed successfully."
16 changes: 15 additions & 1 deletion devnet/scripts/network-maker-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ NM_FILES_DIR_SHARED="/shared/nm-files"
NM_LOG="${NM_LOG:-/root/logs/network-maker.log}"
NM_TEMPLATE="${RELEASE_DIR}/nm-config.toml" # Your template in /shared/release (you said it's attached as config.toml)
NM_CONFIG="${NM_HOME}/config.toml"
NM_GRPC_PORT="${NM_GRPC_PORT:-50051}"
NM_HTTP_PORT="${NM_HTTP_PORT:-8080}"

NM_KEY_PREFIX="nm-account"
NM_MNEMONIC_FILE_BASE="${NODE_STATUS_DIR}/nm_mnemonic"
Expand Down Expand Up @@ -73,6 +75,10 @@ wait_for_file() { while [ ! -s "$1" ]; do sleep 1; done; }

fail_soft() { echo "[NM] $*"; exit 0; } # exit 0 so container keeps running

version_ge() {
printf '%s\n' "$2" "$1" | sort -V | head -n1 | grep -q "^$2$"
}

# Fetch the latest block height from lumerad.
latest_block_height() {
local status
Expand Down Expand Up @@ -156,7 +162,11 @@ fi
VAL_REC_JSON="$(jq -c --arg m "$MONIKER" '[.[] | select(.moniker==$m)][0]' "${CFG_VALS}")"
[ -n "${VAL_REC_JSON}" ] && [ "${VAL_REC_JSON}" != "null" ] || { echo "[NM] Validator moniker ${MONIKER} not found in validators.json"; exit 1; }

NM_ENABLED="$(echo "${VAL_REC_JSON}" | jq -r 'try .["network-maker"] // "false"')"
NM_ENABLED="$(echo "${VAL_REC_JSON}" | jq -r 'try .["network-maker"].enabled // .["network-maker"] // "false"')"
NM_GRPC_PORT="$(echo "${VAL_REC_JSON}" | jq -r 'try .["network-maker"].grpc_port // empty')"
NM_HTTP_PORT="$(echo "${VAL_REC_JSON}" | jq -r 'try .["network-maker"].http_port // empty')"
if [ -z "${NM_GRPC_PORT}" ] || [ "${NM_GRPC_PORT}" = "null" ]; then NM_GRPC_PORT="${NM_GRPC_PORT:-50051}"; fi
if [ -z "${NM_HTTP_PORT}" ] || [ "${NM_HTTP_PORT}" = "null" ]; then NM_HTTP_PORT="${NM_HTTP_PORT:-8080}"; fi

# ----- short-circuits -----
if [ "${START_MODE}" = "wait" ]; then
Expand Down Expand Up @@ -274,6 +284,10 @@ configure_nm() {
crudini --set "$cfg" lumera chain_id "\"$CHAIN_ID\""
crudini --set "$cfg" lumera denom "\"$DENOM\""

# monitor (grpc/http) listeners
crudini --set "$cfg" network-maker grpc_listen "\"0.0.0.0:${NM_GRPC_PORT}\""
crudini --set "$cfg" network-maker http_gateway_listen "\"0.0.0.0:${NM_HTTP_PORT}\""

# keyring section
crudini --set "$cfg" keyring backend "\"$KEYRING_BACKEND\""
crudini --set "$cfg" keyring dir "\"${DAEMON_HOME}\""
Expand Down
Loading
Loading