mirror of
https://github.com/luxfi/chains.git
synced 2026-09-24 00:26:00 +00:00
LP-134 was renumbered LP-1340 (lp-1340-lux-chain-topology); 21 citations across 16 files still named the old number, which resolves to nothing. Corona rests on Module-LWE, not Ring-LWE — LP-4805 says so in three places and b17e086 already corrected one file, leaving evm/main.go and schain/SECURITY_review.md claiming the wrong hardness assumption. The two-family argument in LP-4900 depends on which lattice problem this is. P3Q at 0x012205 is kind-byte signature dispatch; STARK/FRI is starkfri at 0x012220 (LP-7050). Naming P3Q for a scheme at another slot describes a precompile that is not the one being imported. Carries the substance of 2f22fa2, the one commit the parallel line held that this history did not.
137 lines
7.5 KiB
Go
137 lines
7.5 KiB
Go
// Command evm serves the C-Chain EVM to a Lux node, with every precompile
|
|
// linked in.
|
|
//
|
|
// Every precompile is explicitly imported. No umbrella packages. Genesis
|
|
// determines which are active at which block/timestamp.
|
|
//
|
|
// The binary's FILENAME must be the CB58 of constants.ContractVMID
|
|
// (mgj786NP7uDwBCcq6YwThhaN8FLyybkCa4zBWTQbNgmK6k9A6) — that is how the node's
|
|
// plugin registry resolves a vmID from a CreateChainTx to an implementation.
|
|
// A binary installed under any other name is invisible and the chain silently
|
|
// never starts, which is why `version` prints the id it must be installed as:
|
|
// the fact an operator needs is in the place an operator already looks.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
|
|
"github.com/luxfi/constants"
|
|
"github.com/luxfi/evm/plugin/evm"
|
|
"github.com/luxfi/log"
|
|
"github.com/luxfi/sys/ulimit"
|
|
"github.com/luxfi/version"
|
|
"github.com/luxfi/vm/rpc"
|
|
|
|
// ── Curves ───────────────────────────────────────────
|
|
_ "github.com/luxfi/precompile/bls12381" // 0x000B-0x0011 BLS12-381 (EIP-2537)
|
|
_ "github.com/luxfi/precompile/ed25519" // 0x3211 Ed25519 verify
|
|
_ "github.com/luxfi/precompile/secp256r1" // 0x0100 P-256 verify (EIP-7212)
|
|
_ "github.com/luxfi/precompile/sr25519" // 0x0A00 Substrate SR25519 verify
|
|
|
|
// ── VRF ──────────────────────────────────────────────
|
|
_ "github.com/luxfi/precompile/vrf" // 0x3213 ECVRF verify (RFC 9381)
|
|
|
|
// ── Post-Quantum (FIPS 203/204/205) — LP-4200 unified block ──────────
|
|
_ "github.com/luxfi/precompile/corona" // 0x012206 Corona (Module-LWE threshold)
|
|
_ "github.com/luxfi/precompile/mldsa" // 0x012202 ML-DSA (FIPS 204 — Module-LWE signature)
|
|
_ "github.com/luxfi/precompile/mlkem" // 0x012201 ML-KEM (FIPS 203 — Module-LWE KEM)
|
|
_ "github.com/luxfi/precompile/p3q" // 0x012205 P3Q (kind-byte PQ threshold-sig dispatch)
|
|
_ "github.com/luxfi/precompile/pulsar" // 0x012204 Pulsar (Module-LWE threshold FIPS 204)
|
|
_ "github.com/luxfi/precompile/slhdsa" // 0x012203 SLH-DSA (FIPS 205 — hash-based signature)
|
|
_ "github.com/luxfi/precompile/xwing" // 0x2221 X-Wing hybrid KEM (X25519+ML-KEM)
|
|
|
|
// ── Hashing / ZK Curves ─────────────────────────────
|
|
_ "github.com/luxfi/precompile/babyjubjub" // 0x0500..07 Baby Jubjub (BN254 twisted Edwards)
|
|
_ "github.com/luxfi/precompile/blake3" // 0x0500..04 Blake3 hash
|
|
_ "github.com/luxfi/precompile/pasta" // 0x0500..08 Pallas + Vesta (Halo2)
|
|
_ "github.com/luxfi/precompile/pedersen" // 0x0500..06 Pedersen commitment (BN254)
|
|
_ "github.com/luxfi/precompile/poseidon" // 0x0500..05 Poseidon2 ZK-friendly hash
|
|
|
|
// ── Threshold Signatures ─────────────────────────────
|
|
_ "github.com/luxfi/precompile/cggmp21" // 0x0800..03 CGGMP21 ECDSA threshold
|
|
_ "github.com/luxfi/precompile/frost" // 0x0800..02 FROST EdDSA threshold
|
|
|
|
// ── AI ────────────────────────────────────────────────
|
|
_ "github.com/luxfi/precompile/ai" // 0x0300 AI mining / inference
|
|
_ "github.com/luxfi/precompile/attestation" // 0x0300..01 TEE attestation (NVTrust/SGX/SEV-SNP/TDX)
|
|
_ "github.com/luxfi/precompile/compute" // 0x0300..10 AI compute marketplace
|
|
|
|
// Pre-LP-4200 quasar precompiles retired — they shipped a forgeable
|
|
// Verkle stub (any (commitment, proof) with first-17-byte match
|
|
// returned 1). The canonical PQ verifiers live in the LP-4200
|
|
// 0x012200 block: ML-KEM/ML-DSA/SLH-DSA/Pulsar/P3Q/Corona.
|
|
|
|
// ── Bridge ───────────────────────────────────────────
|
|
_ "github.com/luxfi/precompile/bridge" // 0x0440-0443 Gateway + Router + Verifier + Liquidity
|
|
|
|
// ── FHE ──────────────────────────────────────────────
|
|
_ "github.com/luxfi/precompile/fhe" // 0x0700 Fully homomorphic encryption
|
|
|
|
// ── ZK Proofs ────────────────────────────────────────
|
|
_ "github.com/luxfi/precompile/zk" // 0x0900 Groth16 + PLONK + fflonk + Halo2
|
|
|
|
// ── Encryption / Privacy ─────────────────────────────
|
|
_ "github.com/luxfi/precompile/curve25519" // 0x9204 Edwards25519 point ops
|
|
_ "github.com/luxfi/precompile/hpke" // 0x9200 HPKE seal (public-key encrypt only)
|
|
_ "github.com/luxfi/precompile/ring" // 0x9202 Ring signature verify only
|
|
_ "github.com/luxfi/precompile/x25519" // 0x9203 X25519 Diffie-Hellman
|
|
|
|
// ── DEX (LX Suite 0x9010-0x9080) ─────────────────────
|
|
_ "github.com/luxfi/precompile/dex" // Pool + Oracle + Router + Hooks + Flash + Book + Vault + Price + Lend + Repayer + Liquidator + Transmuter
|
|
_ "github.com/luxfi/precompile/stableswap" // 0x0400..60 Curve StableSwap AMM invariant
|
|
|
|
// ── Graph ────────────────────────────────────────────
|
|
_ "github.com/luxfi/precompile/graph" // 0x0500 On-chain GraphQL
|
|
|
|
// ── Blob ─────────────────────────────────────────────
|
|
_ "github.com/luxfi/precompile/kzg4844" // 0xB002 EIP-4844 KZG commitments
|
|
|
|
// ── Registry ─────────────────────────────────────────
|
|
_ "github.com/luxfi/precompile/registry" // Precompile registry + BLS12-381 curves
|
|
)
|
|
|
|
func main() {
|
|
os.Exit(run(context.Background(), os.Args[1:], os.Stdout, os.Stderr))
|
|
}
|
|
|
|
// run is main with the exit lifted out, so what the plugin does is reachable
|
|
// from a test and only the exit itself is not.
|
|
func run(ctx context.Context, args []string, out, errOut io.Writer) int {
|
|
if len(args) > 0 && args[0] == "version" {
|
|
// Every number here is read from the package that declares it. The EVM
|
|
// version is luxfi/evm's own — this line used to carry a literal
|
|
// "1.0.0" beside it, and two declarations of one version disagree the
|
|
// first time either is bumped, with the one an operator reads being
|
|
// this one. The rpcchainvm protocol comes from the same place the node
|
|
// reads it, because a plugin whose protocol differs from the node's is
|
|
// refused at the handshake and this line is where that is diagnosed.
|
|
fmt.Fprintf(out, "evm/%s %s [node=%s, rpcchainvm=%d]\n",
|
|
evm.Version, constants.ContractVMID, version.Current, version.RPCChainVMProtocol)
|
|
return 0
|
|
}
|
|
|
|
if err := ulimit.Set(ulimit.DefaultFDLimit, log.Root()); err != nil {
|
|
return fail(errOut, err)
|
|
}
|
|
|
|
// Resolve the execution backend before serving. With cgo this links
|
|
// luxcpp/cevm and selects AutoEVM (CppEVM when luxfi/evm is built
|
|
// with -tags cevm; GoEVM otherwise). Without cgo this stays on GoEVM.
|
|
selectExecutionBackend(log.Root())
|
|
|
|
if err := rpc.Serve(ctx, log.Root(), &evm.VM{}); err != nil {
|
|
return fail(errOut, err)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// fail reports why the plugin is not serving and gives the node a non-zero
|
|
// exit. A plugin that dies quietly presents as a chain that never starts.
|
|
func fail(w io.Writer, err error) int {
|
|
fmt.Fprintf(w, "evm plugin: %s\n", err)
|
|
return 1
|
|
}
|