Files
dex/Makefile
T
zeekay 21301212f9 refactor(cmd): consolidate cmd/* into one binary — dexd
dexd is now the ONLY command in the repo. One binary, two run modes:

  dexd            run as a luxd rpcchainvm PLUGIN. luxd execs the plugin from
  dexd plugin     its PluginDir with NO positional args (engine address arrives
                  via the runtime.EngineAddressKey env var) and probes the
                  version with `dexd version`. No-subcommand == plugin is
                  REQUIRED to preserve that contract — byte-for-byte the old
                  cmd/dchain behavior (rpc.Serve over the plugin transport).
  dexd run        run the STANDALONE D-Chain venue: open the on-disk zapdb,
  dexd standalone serve the frozen dex_* surface over ZAP, and drive the
                  consensus sealer loop (WaitForEvent->BuildBlock->Verify->
                  Accept). -addr/-db flags preserved from the old cmd/dvenue.

Relocated logic (engine code NOT duplicated — pkg/dchain + pkg/lx untouched):
  cmd/dchain/{main,runner}   -> internal/plugin     (plugin.Run)
  cmd/dvenue/{main,engine_*} -> internal/standalone (standalone.Run + engineName)
  cmd/dexd/main.go            = thin run-mode dispatcher

Removed cmd dirs (12): dchain, dvenue, demo, dex-api-server, dex-server,
dexfillproof, dexseed, fix-gateway, gateway, monitor, persistent-server,
price-feed. Removed committed build artifacts: gateway, dex-server-linux.

Build/ship ONLY dexd:
  - Dockerfile: canonical CPU image (CGO=0, ghcr.io/luxfi/dex) running
    `dexd run`; no GPU/MLX required.
  - Dockerfile.dvenue: GPU operator bundle repointed cmd/dvenue -> cmd/dexd.
  - Deleted Dockerfile.{gateway,devnet,minimal,dvenue-cpu} and
    docker/{Dockerfile,Dockerfile.cuda,backend/Dockerfile,compose-simple.yml}.
  - Makefile rewritten to build/run/ship dexd only.
  - docker.yml: dropped the dex-gateway image; dex-venue-image.yml: dvenue->dexd.
  - Deleted legacy scripts that built removed/long-gone cmds; fixed deploy.sh +
    dev-setup.sh; .gitignore ignores root build binaries.

Also included (coupled, environment-applied, settled): the in-progress
clob -> dex/orderbook terminology refactor across pkg/* + sdk/* + tests/*
(identifier + file renames, e.g. RegisterCLOB->RegisterDEX,
source_clob.go->source_orderbook.go). The relocated standalone venue calls the
renamed API, so it lands in the same consistent snapshot.

Verified (GOWORK=off CGO_ENABLED=0): `go build ./cmd/dexd`, `go build ./...`,
`go vet ./...` all exit 0; `go test ./pkg/dchain` (renamed RegisterDEX socket
path) green. GPU/cgo path not compiled locally (no CUDA); its rename mirrors
the verified nocgo twins and preserves the C ABI symbol names.
2026-06-26 12:24:34 -07:00

112 lines
2.9 KiB
Makefile

# dexd Makefile — the ONE D-Chain DEX binary.
#
# dexd runs the DEX two ways (one binary, two modes):
# dexd run as a luxd rpcchainvm plugin (luxd execs it, no args)
# dexd run run the standalone D-Chain venue (ZAP + consensus sealer)
#
# Default build is CPU (CGO_ENABLED=0) — no GPU/MLX required. The GPU matcher
# (CGO_ENABLED=1, pkg/lx cuda kernels) is built only by Dockerfile.dvenue.
SHELL := /bin/bash
.PHONY: all build run test test-race bench vet fmt lint deps clean coverage \
docker proto sdk-typescript sdk-python sdk-go sdk-all ci help
# Version / build info
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
# Go
GO := go
CGO_ENABLED ?= 0
BINARY := dexd
BINARY_DIR := bin
IMAGE := ghcr.io/luxfi/dex
TEST_TIMEOUT := 60s
export CGO_ENABLED
all: fmt vet test build
help:
@echo "dexd Makefile:"
@echo " make build - Build dexd (CPU, CGO_ENABLED=0) -> $(BINARY_DIR)/$(BINARY)"
@echo " make run - Build and run the standalone venue (dexd run)"
@echo " make test - Run package tests"
@echo " make vet - go vet ./..."
@echo " make fmt - gofmt -s -w ."
@echo " make lint - golangci-lint run"
@echo " make docker - Build the canonical image ($(IMAGE)) from ./Dockerfile"
@echo " make clean - Remove build artifacts"
# Build the one binary (CPU).
build:
@echo "Building $(BINARY) (CGO_ENABLED=$(CGO_ENABLED))..."
@mkdir -p $(BINARY_DIR)
@$(GO) build -trimpath -ldflags "-s -w -X main.Version=$(VERSION) -X main.GitCommit=$(GIT_COMMIT)" \
-o $(BINARY_DIR)/$(BINARY) ./cmd/dexd
@echo "Built $(BINARY_DIR)/$(BINARY)"
# Run the standalone venue.
run: build
@$(BINARY_DIR)/$(BINARY) run
# Tests
test:
@$(GO) test -timeout $(TEST_TIMEOUT) ./pkg/...
test-race:
@$(GO) test -race -timeout 2m ./pkg/...
bench:
@$(GO) test -bench=. -benchmem -benchtime=10s -run=^$$ ./pkg/lx/...
# Quality
vet:
@$(GO) vet ./...
fmt:
@gofmt -s -w .
lint:
@golangci-lint run --timeout 5m 2>/dev/null || echo "Install golangci-lint for linting"
coverage:
@$(GO) test -coverprofile=coverage.out -covermode=atomic ./pkg/...
@$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
# Modules
deps:
@$(GO) mod download
@$(GO) mod tidy
clean:
@$(GO) clean
@rm -rf $(BINARY_DIR) coverage.out coverage.html
# Canonical image (CPU dexd).
docker:
@docker build -f Dockerfile -t $(IMAGE):$(VERSION) .
# Protobuf
proto:
@protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
proto/*.proto
# SDKs
sdk-typescript:
@cd sdk/typescript && npm install && npm run build
sdk-python:
@cd sdk/python && pip install -e .
sdk-go:
@cd sdk/go && go mod tidy && go build ./...
sdk-all: sdk-typescript sdk-python sdk-go
# CI pipeline
ci: fmt vet test build
@echo "CI complete"