mirror of
https://github.com/luxfi/mpc.git
synced 2026-09-24 00:26:24 +00:00
* build(mpc): GOEXPERIMENT=jsonv2 alongside runtimesecret per SCALE_STANDARD
Per SCALE_STANDARD.md §2 (~/work/hanzo/hips/docs/SCALE_STANDARD.md) —
every Go production Dockerfile that emits JSON to a client builds with
GOEXPERIMENT=jsonv2. Verified on hanzoai/zip's json_bench_test.go:
- Edge POST roundtrip: -12% time, -23% allocs
- Marshal-only: -22% time
- Unmarshal-only: -19% time, -25% allocs
GOEXPERIMENT is comma-separated, so jsonv2 composes cleanly with the
pre-existing runtimesecret experiment used by the MPC data plane.
* ci: switch workflows to lux-build (luxfi-scoped ARC pool)
Cross-org runs-on dispatch failure: hanzo-build-linux-amd64 scale set is
registered to github.com/hanzoai and silently rejects luxfi/* jobs.
Switch to lux-build (githubConfigUrl=github.com/luxfi, max 20).
* test/zapauth: deterministic invalid-signature test (was flaky)
TestZapAuthInvalidSignature flipped one base64 char of the signature
segment. ECDSA accepts a wrong sig with probability ≈ 1/2^6 per
single-char flip (alphabet is 64), making the test ~1.5% flake rate
in CI.
Fix: replace the entire signature segment with all-A's. Still
decodable as base64url but cryptographically guaranteed-invalid
bytes — Verify rejection is now deterministic.
Verified: ran -count=10 ./pkg/zapauth/ — all pass.
* deps: bump accel/crypto/corona/threshold/fhe/lens/math to current tags
* api/db: decomplect — KeccakAddress on Wallet / TreasuryWallet / KeygenResult
Wave 5 of the workspace-wide eth* naming purge.
pkg/db/models.go — Wallet + TreasuryWallet:
- New canonical KeccakAddress *string field with json `keccakAddress`
- EthAddress kept with json `ethAddress` as `// Deprecated:` alias
- NormalizeAddresses() method on both structs mirrors the two fields
via the package-private mirrorAddrPtrPair helper
pkg/api/server.go — KeygenResult (backend response):
- New canonical KeccakAddress string field with json `keccak_address`
- EthAddress kept with json `eth_address` as `// Deprecated:` alias
- NormalizeAddresses() method mirrors both fields
pkg/api/handlers_wallets.go, handlers_treasury.go, handlers_bridge.go,
handlers_mpc.go — all sites that constructed wallet rows from MPC
backend results now:
1. Call result.NormalizeAddresses() on the backend response so both
KeccakAddress / EthAddress carry the same value before copy
2. Copy both fields onto the persisted Wallet / TreasuryWallet row
3. Call wal.NormalizeAddresses() to ensure DB row has both
4. Read from the canonical KeccakAddress at response-construction
sites (toWalletResponse, treasury response, bridge response)
The "ethereum"/"lux"/"xrp" labels in addresses map (handleGetWalletAddresses)
are per-chain DISPLAY labels keyed by chain name a client knows;
the values are the Keccak-derived 20-byte address. Map keys NOT
decomplected here — they're per-chain UI labels, not internal naming.
Effect on the wire:
- API consumers reading wallet.ethAddress see the same value as
wallet.keccakAddress
- New consumers can switch to keccakAddress today
- ORM persistence stores both fields (eventually consistent via
NormalizeAddresses calls at handler boundaries)
Tests: pkg/api unit tests pass (1.8s); pkg/db has no test files.
Deprecation alias retention means downstream KMS / dashboards
keep working at every step of the migration.
Per CLAUDE.md x.x.x+1.
* strip KeccakAddress + EthAddress dual-field bridge (no aliases)
Forward-only completion of the workspace strip-aliases cascade. The
canonical JSON field is evmAddress, the Go field is EVMAddress. No
NormalizeAddresses helpers, no mirrorAddrPtrPair, no deprecated
KeccakAddress, no deprecated EthAddress.
Touched:
pkg/api/server.go KeygenResult drops KeccakAddress +
EthAddress + NormalizeAddresses
pkg/db/models.go Wallet drops KeccakAddress + EthAddress
TreasuryWallet drops KeccakAddress +
EthAddress
Drops NormalizeAddresses + mirrorAddrPtrPair
pkg/api/handlers_wallets.go rip mirror calls; only EVMAddress
populated on Wallet rows
pkg/api/handlers_treasury.go rip mirror calls on TreasuryWallet
pkg/api/handlers_mpc.go rip NormalizeAddresses calls; rename
filter("ethAddress=") → ("evmAddress=")
pkg/api/handlers_bridge.go local var keccakAddress → evmAddr
pkg/api/handlers_smart_wallets.go wallet.EthAddress → wallet.EVMAddress
pkg/api/treasury_test.go mock KeygenResult EthAddress → EVMAddress
pkg/api/zap_kms_server_test.go same
cmd/mpcd/main.go pubKeyToEthAddress → pubKeyToEVMAddress,
\"eth_address\" → \"evm_address\",
local var ethAddr → evmAddr, KeygenResult
EthAddress → EVMAddress field
Deps: bump luxfi/metric v1.5.1 → v1.5.7 to pick up ExponentialBuckets
(via transitive luxfi/threshold dep).
The value IS \"EVM-runtime account address\" — that's the data model.
The Keccak256(secp256k1 pubkey) derivation is HOW.
51 lines
2.4 KiB
Docker
51 lines
2.4 KiB
Docker
# Stage 1: Build embedded admin UI
|
|
FROM node:22-alpine AS ui
|
|
# Pin pnpm to a known-good version so corepack doesn't pull a tagged-but-unsigned
|
|
# release. v10.x supports `onlyBuiltDependencies` in package.json and does not
|
|
# fail the install step on ignored build scripts (newer v11 returns non-zero
|
|
# unless explicitly approved, even in non-interactive Docker builds).
|
|
RUN corepack enable && corepack prepare [email protected] --activate
|
|
WORKDIR /ui
|
|
COPY ui/package.json ui/pnpm-lock.yaml* ./
|
|
# `--frozen-lockfile` first so verifiable builds win; fall back to a
|
|
# lockfile-updating install if the lock is missing.
|
|
RUN pnpm install --frozen-lockfile || pnpm install --no-frozen-lockfile
|
|
COPY ui/ .
|
|
RUN pnpm build
|
|
|
|
# MPC — single image ships both daemon (mpcd) + CLI (mpc).
|
|
# Default entrypoint: mpcd. Override ENTRYPOINT / CMD with `mpc <cmd>` for CLI.
|
|
# syntax=docker/dockerfile:1
|
|
|
|
FROM --platform=$BUILDPLATFORM golang:1.26.3-alpine AS builder
|
|
# CGO toolchain — required by go-sqlite3 (mattn) so the wallet HTTP API
|
|
# can open SQLite. Previously CGO=0 left the driver unregistered and
|
|
# /v1/mpc/wallets returned 503; the workaround was seeding wallets into
|
|
# TA's user_wallets table out-of-band.
|
|
RUN apk add --no-cache git ca-certificates gcc musl-dev sqlite-dev linux-headers
|
|
ENV GONOSUMDB=github.com/luxfi/*,github.com/hanzoai/*
|
|
|
|
WORKDIR /app
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
COPY . .
|
|
COPY --from=ui /ui/dist ./ui/dist/
|
|
|
|
# Per SCALE_STANDARD.md §2 (https://github.com/hanzoai/hips/blob/main/docs/SCALE_STANDARD.md)
|
|
# — every Go production Dockerfile that emits JSON to a client builds
|
|
# with GOEXPERIMENT=jsonv2 (composed with runtimesecret for the MPC
|
|
# data-plane secrecy guarantees). Verified -12% time / -23% allocs on
|
|
# the edge POST roundtrip vs encoding/json v1.
|
|
ENV GOEXPERIMENT=runtimesecret,jsonv2
|
|
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w -linkmode external -extldflags '-static'" -tags 'sqlite_omit_load_extension' -o mpcd ./cmd/mpcd
|
|
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w -linkmode external -extldflags '-static'" -tags 'sqlite_omit_load_extension' -o mpc ./cmd/mpc
|
|
|
|
FROM alpine:3.21
|
|
# Runtime — statically linked binaries above don't need shared libs, but
|
|
# keep ca-certificates + tzdata for HTTPS + log timestamps.
|
|
RUN apk add --no-cache ca-certificates tzdata
|
|
COPY --from=builder /app/mpcd /usr/local/bin/mpcd
|
|
COPY --from=builder /app/mpc /usr/local/bin/mpc
|
|
EXPOSE 8081 9999 9800
|
|
ENTRYPOINT ["mpcd"]
|