mirror of
https://github.com/luxfi/dex.git
synced 2026-09-24 00:26:31 +00:00
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.
50 lines
1.7 KiB
Go
50 lines
1.7 KiB
Go
// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
// Package plugin boots the native D-Chain DEX VM as a luxd rpcchainvm plugin,
|
|
// mirroring github.com/luxfi/evm/plugin/runner. rpc.Serve takes the engine
|
|
// address from the runtime.EngineAddressKey env var, opens this chain's own
|
|
// badgerdb/zapdb, hands it to VM.Initialize, and serves block requests so
|
|
// BuildBlock/Verify/Accept run inside luxd's multi-validator consensus — the
|
|
// exact harness lux/evm boots through. The VM (pkg/dchain) is pure-Go (CGO=0);
|
|
// this entrypoint links no native code.
|
|
package plugin
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/luxfi/dex/pkg/dchain"
|
|
log "github.com/luxfi/log"
|
|
"github.com/luxfi/version"
|
|
"github.com/luxfi/vm/rpc"
|
|
)
|
|
|
|
// Run boots the d-chain VM over the rpcchainvm plugin transport. It blocks
|
|
// until the node runtime shuts the VM down. When luxd probes the plugin version
|
|
// (a single "version" arg), it prints the version line and exits 0.
|
|
func Run() {
|
|
versionStr := fmt.Sprintf("Lux-DChain/%s [node=%s, rpcchainvm=%d]",
|
|
dchain.Version, version.Current, version.RPCChainVMProtocol)
|
|
if printVersion() {
|
|
fmt.Println(versionStr)
|
|
os.Exit(0)
|
|
}
|
|
if err := rpc.Serve(context.Background(), log.Root(), &dchain.VM{}); err != nil {
|
|
fmt.Printf("dchain rpc.Serve error: %s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
// printVersion reports whether the process was asked to just print its version
|
|
// and exit. The node passes a single "version" arg when probing a plugin.
|
|
func printVersion() bool {
|
|
for _, a := range os.Args[1:] {
|
|
if a == "version" || a == "--version" || a == "-version" {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|