mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
Wire the EVM side of the always-on DEX settlement money path 0x9999. It is ACTIVE
on every chain from genesis with NO config entry — neither a genesis-inlined
precompile nor a precompileUpgrades timestamp. Zero per-net config, one way.
Activation is DISPATCH-only (genesis state is consensus-critical and immutable):
- params.GetExtrasRules injects every modules.AlwaysOnModules() entry into the
enabled precompile set unconditionally (every chain, every timestamp). This is
what PrecompileOverride.IsPrecompileEnabled consults, so 0x9999 runs for a
tx-to-0x9999, a low-level CALL/STATICCALL, and the 0x9010 V4 forward.
- ApplyPrecompileActivations writes NO genesis state for always-on modules. An
EXTCODESIZE marker at genesis would change the genesis hash and FORK existing
networks (a fresh-syncing node would disagree with the committed genesis). The
real lux-mainnet genesis hash is preserved (TestSkipPostMergeFieldsGenesisHash).
- The always-on module's Configurator is never invoked (no activating config).
DChainID runtime resolution (THE crux): contract.AtomicState gains DChainID(); the
EVM adapter (accessibleStateAdapter) resolves it from the consensus context via
runtime.GetBCLookup().Lookup("D") — the dexvm "D"/"dex"/"dexvm" alias the node
registers in initChainAliases before any chain bootstraps. Identical on every
validator and re-execution; ids.Empty on a network with no dexvm (seam stays closed,
fail-secure). The registry bridge forwards DChainID across the internal/external
AtomicState surfaces. modules.Module gains AlwaysOn (+ AlwaysOnModules()), bridged
from github.com/luxfi/precompile.
deps: precompile v0.5.51 -> v0.5.52 (DChainID + AlwaysOn + always-on settle module).
Tests: core suite green incl. the real-mainnet genesis-hash guards. New
core/precompile_alwayson_test.go: 0x9999 registers AlwaysOn, is dispatch-enabled with
NO config at genesis + far-future ts, and writes NO genesis state (genesis-hash
immutability). (Two pre-existing unrelated failures: params/config_test.go references
a removed DurangoTimestamp field; mainnet upgrade.json aiMining/warp timestamp guards
— both fail identically on pristine main.)
47 lines
1.6 KiB
Go
47 lines
1.6 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package modules
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/luxfi/evm/precompile/contract"
|
|
"github.com/luxfi/geth/common"
|
|
)
|
|
|
|
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 from the runtime (consensus
|
|
// context / atomic state). The DEX settlement precompile (0x9999) is the canonical
|
|
// case. An always-on module's Configurator is never invoked (no activating config);
|
|
// the host gives it the EXTCODESIZE marker at genesis and dispatches Run on every
|
|
// block. Bridged from github.com/luxfi/precompile/modules.Module.AlwaysOn.
|
|
AlwaysOn bool
|
|
}
|
|
|
|
type moduleArray []Module
|
|
|
|
func (u moduleArray) Len() int {
|
|
return len(u)
|
|
}
|
|
|
|
func (u moduleArray) Swap(i, j int) {
|
|
u[i], u[j] = u[j], u[i]
|
|
}
|
|
|
|
func (m moduleArray) Less(i, j int) bool {
|
|
return bytes.Compare(m[i].Address.Bytes(), m[j].Address.Bytes()) < 0
|
|
}
|