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
12 changes: 6 additions & 6 deletions docs/limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ resolved.
16 GB Mac). Bump via Settings → Resources before running
multi-instance scenarios.

The preflight check enforces a per-version hard floor: 8 GB for the
0.6, 0.7, and 0.8 lines (and any uncurated tag on those majors, which
inherits the strictest catalogued floor for its major), 4 GB for
0.5.18 and only for tags whose major has no catalogued entry. The 12 GB figure is the coded recommendation
threshold (`recommended_memory_bytes`) — below it preflight WARNs
but does not refuse.
The preflight check uses code defaults of 4 GB minimum and 6 GB
recommended. Catalogue entries may override those per release line
(today 8 GB min / 12 GB recommended for the 0.6+ lines); tags with
no override of their own inherit the largest same-major override,
otherwise the code defaults. Below the recommended threshold
preflight WARNs but does not refuse.

On timeout, `WaitForHealthy` now dumps the last `docker compose ps`
snapshot in its error so the stuck service + state are visible
Expand Down
14 changes: 7 additions & 7 deletions docs/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ the canonical name in code and docs.
| `content_sha` | `scripts/compute-tree-sha.sh` | SHA-256 over the extracted `cluster/compose/localnet/` subtree (sorted by path). Stable across upstream gzip-envelope rewrites; this is the authoritative integrity check at fetch time. |
| `size` | byte count of the source-tarball | Informational; used to print a hint before download and to size the in-flight body cap. |
| `major` | first two segments of `tag` (or set manually for branch tags) | Routes to the per-major Splice adapter for that release line. |
| `min_memory_bytes` | empirically derived per release line (see `versions.go`) | Minimum Docker daemon memory the version needs to start cleanly; the pre-flight memory gate refuses to `up` below it. `0` / absent inherits the strictest catalogued floor for the same major line; the global 4 GB floor applies only when the major has no catalogued entry at all. |
| `recommended_memory_bytes` | empirically derived per release line (see `versions.go`) | The value at which the version runs without resource warnings; surfaced as the "raise Docker memory to ≥ N" remediation hint when the minimum passes but this threshold is not met. |
| `min_memory_bytes` | override only (see `versions.go`) | Optional. Minimum Docker daemon memory the version needs to start cleanly; the pre-flight memory gate refuses to `up` below it. Omit when the line matches the code default (4 GB). When set, later tags in the same major inherit the largest override; otherwise the code default applies. |
| `recommended_memory_bytes` | override only (see `versions.go`) | Optional. The value at which the version runs without resource warnings; surfaced as the "raise Docker memory to ≥ N" remediation hint when the minimum passes but this threshold is not met. Omit when the line matches the code default (6 GB). Same-major inheritance matches `min_memory_bytes`. |
| `channel` *(optional)* | catalogue maintainer | `""` / `"stable"` → production-ready; `"alpha"` → opt-in pre-release (Token Standard V2 snapshot etc.). `up` prints a one-line warning when an alpha entry is selected. |
| `image_repo` *(optional)* | catalogue maintainer | Overrides the default Docker image repository. Defaults to `ghcr.io/digital-asset/decentralized-canton-sync/docker`. Set to `ghcr.io/digital-asset/decentralized-canton-sync-dev/docker` for the V2 alpha track. The v06 adapter forwards this as the `IMAGE_REPO` compose env. |
| `image_tag` *(optional)* | catalogue maintainer | Overrides the Docker image tag. Empty falls back to `tag`, which is right for stable releases; the branch-backed `token-standard-v2` alpha entry sets it explicitly to a `0.6.5-snapshot` tag. The adapter forwards it as the `IMAGE_TAG` compose env. |
Expand Down Expand Up @@ -109,11 +109,11 @@ A maintainer then:
- Reviews the diff.
- Bumps `latest_alias` if the new tag should become the default
`--version latest`.
- Sets `min_memory_bytes` and `recommended_memory_bytes` on the first
entry of a new major line (from that release's
`cluster/compose/localnet/resource-constraints.yaml`). Later tags in
the line inherit them; `go test ./internal/splice/` fails until a
new major has them.
- Sets `min_memory_bytes` and `recommended_memory_bytes` only when
the release line needs floors different from the code defaults
(4 GB min / 6 GB recommended), using that release's
`cluster/compose/localnet/resource-constraints.yaml`. One override
on the major line is enough; later tags inherit it.
- Optionally runs the integration test against the new entry before
merging.
- Commits + pushes.
Expand Down
177 changes: 45 additions & 132 deletions internal/splice/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,76 +33,39 @@ import (
// the resolved image digests post-up and warns on drift — see
// internal/localnet/image_digests.go and docs/limitations.md ("Container
// image pinning").
//
// # Maintainer flow
//
// Add a new entry via:
//
// scripts/add-splice-version.sh <tag>
//
// The script resolves <tag> → commit SHA via the GitHub API, fetches +
// extracts the archive, computes ContentSHA, and appends a versions.json
// entry. A maintainer reviews the diff and commits.
type Version struct {
Tag string `json:"tag"`
Commit string `json:"commit"` // immutable git commit SHA the tag pointed to
ContentSHA string `json:"content_sha"` // sha-256 of the extracted localnet subtree (sorted, path+content)
Size int64 `json:"size"` // informational; used only to print a hint before download
Major string `json:"major"` // routes to internal/splice/v0X adapter
Size int64 `json:"size"`
Major string `json:"major"` // routes to internal/splice/v0X adapter

// MinMemoryBytes is the minimum Docker daemon memory the version
// needs to start cleanly. Empirically derived: Splice 0.6.x boots
// a single canton container hosting 2 sequencers + 2 mediators +
// 3 participants each at -Xmx 2.5 GiB, so the container OOM-loops
// on a stock Docker Desktop install (4 GB default). 0.5.x is
// lighter. 0 means "use docker.DefaultMinMemoryBytes" — the
// historical 4 GB floor.
//
// Values use decimal GB (1 GB = 10^9 bytes) to match Docker
// Desktop on macOS, which is the primary platform where users
// must manually set a memory limit. Using decimal GB ensures
// that "8 GB" in Docker Desktop satisfies a min_memory_bytes
// of 8_000_000_000.
// MinMemoryBytes overrides the code default min for this entry;
// 0 means no override. Values use decimal GB (1 GB = 10^9 bytes) so
// "8 GB" in Docker Desktop satisfies min_memory_bytes of 8_000_000_000.
MinMemoryBytes uint64 `json:"min_memory_bytes,omitempty"`
// RecommendedMemoryBytes is the value at which the version
// runs without resource warnings. UI surfaces this as the
// "raise Docker memory to ≥ N" remediation hint when Min*
// passes but the recommended threshold is not met.
// RecommendedMemoryBytes overrides the code default recommended
// memory for this entry; 0 means no override.
RecommendedMemoryBytes uint64 `json:"recommended_memory_bytes,omitempty"`

// Channel labels the maturity of a catalogue entry. Empty (the
// historical default) and "stable" both mean a production-ready
// release; "alpha" marks an opt-in pre-release that the user is
// expected to know they are pulling (e.g. the Token Standard V2
// snapshot, which runs on a separate -dev image repo and needs
// `--profile tokens-v2` for the alpha Canton protocol). The
// `versions` command surfaces this and `up` warns on selection.
// release; "alpha" marks an opt-in pre-release.
Channel string `json:"channel,omitempty"`

// ImageRepo overrides the default Docker image repository for
// this entry. Empty falls back to the stable repo that Splice's
// compose env files default to (currently
// `ghcr.io/digital-asset/decentralized-canton-sync/docker`). The
// Token Standard V2 pre-release stream publishes to a separate
// `-dev` repo, so its catalogue entry sets this explicitly. The
// adapter forwards it as the `IMAGE_REPO` compose env.
// compose env files default to. The adapter forwards it as the
// `IMAGE_REPO` compose env.
ImageRepo string `json:"image_repo,omitempty"`

// ImageTag overrides the Docker image tag used for this entry.
// Empty falls back to Tag, which is right for stable releases
// (where the catalogue Tag === the upstream ghcr tag). The
// Token Standard V2 alpha publishes its images under a snapshot
// tag distinct from the catalogue tag (e.g.
// `0.6.5-snapshot.20260526.2931.0.ve28a6722`), so its entry sets
// this explicitly. The adapter forwards it as the `IMAGE_TAG`
// compose env.
// Empty falls back to Tag. The adapter forwards it as the
// `IMAGE_TAG` compose env.
ImageTag string `json:"image_tag,omitempty"`
}

// IsAlpha reports whether the entry is in the alpha channel — an
// opt-in pre-release the user must consciously select. Equivalent to
// `v.Channel == "alpha"` but kept as a method so the comparison string
// only lives in one place.
// IsAlpha reports whether the entry is in the alpha channel.
func (v Version) IsAlpha() bool { return v.Channel == "alpha" }

// SupportsTokenStandardV2 reports whether a Splice release includes the
Expand All @@ -113,22 +76,16 @@ func SupportsTokenStandardV2(tag string) bool {
if tag == "token-standard-v2" {
return true
}
v, ok := parseSemver(tag)
v, ok := parseLeadingSemver(tag)
if !ok {
return false
}
return v[0] > 0 || (v[0] == 0 && (v[1] > 6 || (v[1] == 6 && v[2] >= 11)))
}

// catalogueFile is the embedded JSON catalogue. Kept as a separate file
// (rather than literal Go code) so the maintainer refresh script can
// append entries with a tiny JSON edit instead of regenerating Go
// source.
//
//go:embed versions.json
var catalogueFile []byte

// catalogue holds the in-memory shape of versions.json after init().
var catalogue struct {
LatestAlias string `json:"latest_alias"`
Versions []Version `json:"versions"`
Expand Down Expand Up @@ -170,10 +127,6 @@ func init() {
// the catalogue return ErrUncuratedTag — the caller is responsible for
// deciding whether to fall through to runtime resolution (see
// ResolveOrUpstream / ResolveUpstream).
//
// We keep Resolve catalogue-only so a "just give me whatever works"
// caller can't accidentally start running arbitrary upstream tags
// without an explicit opt-in elsewhere.
func Resolve(req string) (Version, error) {
if req == "" || req == "latest" {
req = LatestAlias
Expand All @@ -186,98 +139,63 @@ func Resolve(req string) (Version, error) {
return v, nil
}

// MinMemoryFor returns the version-specific Docker daemon memory
// floor for v. Called from both `dpm localnet up` (CLI gate) and the
// Web UI's GET /api/preflight handler so the two surfaces enforce
// identical numbers (see CONTRIBUTING.md "CLI ↔ Web UI parity"). The
// fallback constant is duplicated below to avoid an import cycle with
// internal/docker.
//
// MinMemoryFor returns the Docker daemon memory floor for v.
// Resolution order:
// 1. v.MinMemoryBytes when the entry sets it (curated entries).
// 2. The STRICTEST (largest) MinMemoryFor across every catalogued
// entry that shares v.Major — this is the uncurated path. An
// uncurated 0.6.x tag has no memory fields of its own, but its
// resource profile is governed by the Splice major, not by
// whether DevKit reviewed the tag; reusing the catalogued floor
// for the same major means the escape hatch TIGHTENS the gate to
// match curated 0.6.x (8 GiB) instead of silently loosening it to
// the global 4 GiB default, which is exactly backwards for the
// least-tested versions.
// 3. The global defaultMinMemoryBytesFallback when neither applies
// (e.g. a major with no catalogued entry at all).
//
// Invariant pinned by TestThresholdParity_VersionMinAtLeastDefault:
// every catalogued MinMemoryBytes is >= the global default, so the
// derived floor for a known major is also >= the default. A user on a
// 4 GiB host always sees a refusal regardless of which version they
// pick, curated or not.
// 1. v.MinMemoryBytes when the entry sets an override.
// 2. The largest MinMemoryBytes among catalogued entries that share
// v.Major — one override covers the whole major line.
// 3. defaultMinMemoryBytesFallback (4 GB).
func MinMemoryFor(v Version) uint64 {
if v.MinMemoryBytes > 0 {
return v.MinMemoryBytes
}
if m := strictestMinForMajor(v.Major); m > 0 {
if m := strictestForMajor(v.Major, func(v Version) uint64 { return v.MinMemoryBytes }); m > 0 {
return m
}
return defaultMinMemoryBytesFallback
}

// RecommendedMemoryFor returns the version's recommended memory
// (above which there are no resource warnings). For uncurated entries
// (no recommendation of their own) it falls back to the strictest
// catalogued recommendation for the same major, so the WARN tier is
// not silently disabled for the least-tested versions. Returns 0 only
// when neither the entry nor any same-major catalogue entry sets a
// recommendation; 0 disables the WARN tier in docker.checkDockerMemory
// — see internal/docker/checks.go.
// (above which there are no resource warnings). Resolution order:
// 1. v.RecommendedMemoryBytes when the entry sets an override.
// 2. The largest RecommendedMemoryBytes among catalogued entries
// that share v.Major.
// 3. defaultRecommendedMemoryBytesFallback (6 GB), raised to at
// least MinMemoryFor(v) so the WARN tier never undercuts the
// hard gate and never returns 0.
func RecommendedMemoryFor(v Version) uint64 {
if v.RecommendedMemoryBytes > 0 {
return v.RecommendedMemoryBytes
}
return strictestRecommendedForMajor(v.Major)
}

// strictestMinForMajor returns the largest MinMemoryBytes among
// catalogued entries whose Major matches, or 0 when major is empty or
// no catalogued entry shares it. "Strictest" (max) is deliberate: the
// gate must refuse a host that any same-major curated entry would
// refuse.
func strictestMinForMajor(major string) uint64 {
if major == "" {
return 0
if m := strictestForMajor(v.Major, func(v Version) uint64 { return v.RecommendedMemoryBytes }); m > 0 {
return m
}
var max uint64
for _, v := range SupportedVersions {
if v.Major == major && v.MinMemoryBytes > max {
max = v.MinMemoryBytes
}
rec := defaultRecommendedMemoryBytesFallback
if min := MinMemoryFor(v); rec < min {
return min
}
return max
return rec
}

// strictestRecommendedForMajor mirrors strictestMinForMajor for the
// recommended (WARN) threshold.
func strictestRecommendedForMajor(major string) uint64 {
func strictestForMajor(major string, field func(Version) uint64) uint64 {
if major == "" {
return 0
}
var max uint64
for _, v := range SupportedVersions {
if v.Major == major && v.RecommendedMemoryBytes > max {
max = v.RecommendedMemoryBytes
if v.Major == major {
if n := field(v); n > max {
max = n
}
}
}
return max
}

// defaultMinMemoryBytesFallback mirrors docker.DefaultMinMemoryBytes,
// duplicated so this package can compute the effective min without
// importing internal/docker (docker imports splice — importing back
// would create a cycle). TestThresholdParity_VersionMinAtLeastDefault
// asserts equality with docker.DefaultMinMemoryBytes so this never
// drifts.
const defaultMinMemoryBytesFallback uint64 = 4_000_000_000

const defaultRecommendedMemoryBytesFallback uint64 = 6_000_000_000

// Supported returns the supported tags in ascending version order.
// Ordering is numeric (0.6.9 before 0.6.10), not lexical, so the CLI's
// `--version` list matches the semver-sorted Web UI picker; non-semver
Expand All @@ -291,12 +209,9 @@ func Supported() []string {
return out
}

// compareTags orders two catalogue tags by numeric major.minor.patch.
// Semver tags sort before non-semver ones (token-standard-v2); ties and
// two non-semver tags fall back to a lexical compare.
func compareTags(a, b string) int {
va, oka := parseSemver(a)
vb, okb := parseSemver(b)
va, oka := parseLeadingSemver(a)
vb, okb := parseLeadingSemver(b)
if oka && okb {
for k := 0; k < 3; k++ {
if va[k] != vb[k] {
Expand All @@ -306,20 +221,18 @@ func compareTags(a, b string) int {
return 1
}
}
return strings.Compare(a, b) // same major.minor.patch: pre-release suffix, etc.
return strings.Compare(a, b)
}
if oka != okb {
if oka {
return -1 // semver before non-semver
return -1
}
return 1
}
return strings.Compare(a, b)
}

// parseSemver reads the leading major.minor.patch of a tag, ignoring any
// `-pre`/`+build` suffix. Returns false when the tag isn't N.N.N.
func parseSemver(tag string) ([3]int, bool) {
func parseLeadingSemver(tag string) ([3]int, bool) {
var v [3]int
base := tag
if i := strings.IndexAny(base, "-+"); i >= 0 {
Expand Down
20 changes: 17 additions & 3 deletions internal/splice/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@
"_comment": "Maintainer flow: scripts/add-splice-version.sh <tag> resolves the tag → commit, downloads the archive, computes ContentSHA, and appends an entry here. Reviewer checks the diff before merging.",
"latest_alias": "0.8.1",
"versions": [
{
"tag": "0.10.0",
"commit": "4dc85cc2eb9b3451f5c38d992fa30ada958e80e8",
"content_sha": "d1e8c0a709c8f5d9254d08c56ccd073ee3a163dc807529138ba1a4fac3ccfdbb",
"size": 228432553,
"major": "0.10",
"min_memory_bytes": 8000000000,
"recommended_memory_bytes": 12000000000
},
{
"tag": "0.10.1",
"commit": "69260d05fafe4adca45b87b3fd49878b94328f8f",
"content_sha": "d1e8c0a709c8f5d9254d08c56ccd073ee3a163dc807529138ba1a4fac3ccfdbb",
"size": 228487041,
"major": "0.10"
},
{
"tag": "0.5.18",
"commit": "b162650cd18df5b96dddeffd9bd48be5b2ff37d7",
"content_sha": "1a9d0b329cd7c9f76c04085674b9e8dc98169064b0404d007d7e2b22cb582150",
"size": 124198413,
"major": "0.5",
"min_memory_bytes": 4000000000,
"recommended_memory_bytes": 6000000000
"major": "0.5"
},
{
"tag": "0.6.10",
Expand Down
Loading
Loading