Skip to content

config: blank *-content flag falls through to *-file (strict-PQ staking key fix)#138

Closed
woobin-satschel wants to merge 1 commit into
luxfi:mainfrom
woobin-satschel:fix/pq-staking-content-flag-fallthrough
Closed

config: blank *-content flag falls through to *-file (strict-PQ staking key fix)#138
woobin-satschel wants to merge 1 commit into
luxfi:mainfrom
woobin-satschel:fix/pq-staking-content-flag-fallthrough

Conversation

@woobin-satschel

Copy link
Copy Markdown
Contributor

Problem

config.pemBytesOrFile (config/config.go) short-circuits when a *-content flag is set but empty: v.IsSet(contentKey) is true, the value is "", and it returns empty bytes instead of falling through to the corresponding *-file path.

For strict-PQ staking keys (--staking-mldsa-key-file-content / --staking-mldsa-key-file), a deploy whose env var or template rendered the -content flag to "" alongside a valid -file path silently degraded the validator to a classical ECDSA NodeID — StakingMLDSAPub stayed empty, IsStrictPQ() was false, and the node booted with no error. The genesis validator set then never matched the live NodeIDs, so the P-chain produced 0 blocks: the strict-PQ activation outage (the #48 failure class).

This is a config concern, deliberately out of scope for #137 (schemeGate + pre-dedup handshake + classical-compat), which covered the consensus/chain-creation layers.

Fix

Treat a set-but-empty *-content flag identically to an absent one and fall through to the *-file path, so a blank content flag and a missing one behave the same. The same helper backs the ML-KEM handshake keys, so both key paths are covered.

Test

Restores config/staking_mldsa_test.go, including the regression guard TestLoadStakingMLDSA_EmptyContentFallsThroughToPath plus the surrounding loadStakingMLDSA cases (path form, content form, classical-compat, and priv-only-is-fatal). The guard fails on main (priv is nil — the silent degradation) and passes with this change.

Verification

CGO_ENABLED=0 go test ./config/   # ok

(cgo is broken in this tree — build/test with CGO_ENABLED=0.)

pemBytesOrFile short-circuited when a *-content flag was set but empty
(v.IsSet true, value ""), returning empty bytes instead of consulting
the corresponding *-file path.

For strict-PQ staking keys (--staking-mldsa-key-file-content /
--staking-mldsa-key-file) this silently degraded a validator to a
classical ECDSA NodeID: StakingMLDSAPub stayed empty, IsStrictPQ() was
false, and the node booted with no error. The genesis validator set then
never matched the live NodeIDs and the P-chain produced 0 blocks -- the
strict-PQ activation outage (the #48 failure class).

Treat a set-but-empty content flag identically to an absent one and fall
through to the *-file path. The same helper backs the ML-KEM handshake
keys, so both paths are fixed.

Restore the regression guard
TestLoadStakingMLDSA_EmptyContentFallsThroughToPath (fails on main,
passes here) alongside the other loadStakingMLDSA cases.

Verified: CGO_ENABLED=0 go test ./config/
@Darkhorse7stars

Copy link
Copy Markdown
Member

Superseded by #139, opened directly on luxfi/node (same fix + restored regression test). Closing this fork-based PR and removing the fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants