Files
zeekay 9cfae862cf dex(0x9999): always-on settlement precompile, runtime params, zero per-net config
0x9999 — the native C<->D atomic DEX settlement money path — is now ALWAYS-ON:
present + active on every chain that loads the EVM plugin, from genesis, with NO
dexSettleConfig genesis/upgrade entry. This is the production-launch design; the
per-net config-gate is killed. Forward-perfect, one activation way.

Activation: modules.Module gains an AlwaysOn flag (+ modules.AlwaysOnModules()).
SettleModule sets AlwaysOn=true. The Configurator is retained only to satisfy the
interface; for an always-on module the host never invokes Configure (no activating
config). SettleConfig collapses to a parameter-free {Upgrade} marker that always
Verifies — 0x9999 takes no per-net parameters.

Params resolved at RUNTIME, not config (Configure has no consensus context, so it
cannot resolve them):
  - protocolFeeController: built-in DefaultDAOTreasury (set in init). One canonical
    DAO governance authority across every network; not a compromised dev key.
  - networkID / cChainID: already sourced at runtime via contract.AtomicState.
  - dChainID (THE crux): contract.AtomicState gains DChainID(). The 4 native-client
    sites that read loadDChainTarget(stateDB) now read atomicState.DChainID(), which
    the host resolves from the chain topology (consensus-context "D"/dexvm alias).
    ids.Empty (no dexvm on this network) closes the seam — fail-secure, no mint.

Money-path logic is byte-for-byte unchanged: DeriveIntentID/DerivePositionCommitID,
lock/stage/credit, conservation, exactly-once, rail discriminator, FIX-2 one-batch
flush, nonReentrant/custody guards all untouched. The ONLY change is HOW the
precompile activates and obtains its params (runtime, not config). The Empty-dChain
revert is preserved (strengthened: SubmitSwapIntent/SubmitPositionCommit now revert
on Empty instead of falling back to the C-Chain's own id).

Dead config machinery removed (one way, no dead code): SetSettle{ChainIdentity,
DChainTarget}, loadDChainTarget, loadSettleChainIdentity, cfg{Net,CChain,DChain}IDKey
slots, the STM read-set entries for them, and the now-unused kvAdapter Configure bridge.

Tests: full dex suite 335/335 PASS, 0 fail, 0 skip (CGO_ENABLED=0; the test binary's
only CGO dep is luxfi/accel, unrelated to the pure-Go money path). Harness feeds the
D peer via the runtime AtomicState capability, mirroring production exactly — proof
that the money path is intact with zero config.

go.sum: reconcile e2e threshold v1.9.4 to the origin-canonical hash (upstream re-tag).
2026-06-21 09:03:37 -07:00

32 lines
1.5 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package modules
import (
"github.com/luxfi/geth/common"
"github.com/luxfi/precompile/contract"
)
type Module struct {
// ConfigKey is the key used in json config files to specify this precompile config.
ConfigKey string
// Address returns the address where the stateful precompile is accessible.
Address common.Address
// Contract returns a thread-safe singleton that can be used as the StatefulPrecompiledContract when
// this config is enabled.
Contract contract.StatefulPrecompiledContract
// Configurator is used to configure the stateful precompile when the config is enabled.
contract.Configurator
// AlwaysOn marks a precompile that is ACTIVE on every chain from genesis with NO
// config entry (neither a genesis-inlined precompile nor a precompileUpgrades
// timestamp). It is the one-way activation for system precompiles that take no
// per-network parameters and resolve everything they need from the runtime
// (consensus context / atomic state). The DEX settlement precompile (0x9999) is
// the canonical case: it is the money path and must be present + callable the
// instant the EVM plugin loads, with zero per-net configuration. An always-on
// module's Configurator is never invoked (there is no activating config); the host
// gives it the EXTCODESIZE marker at genesis and dispatches its Run unconditionally.
AlwaysOn bool
}