mirror of
https://github.com/luxfi/chains.git
synced 2026-09-24 00:26:00 +00:00
luxfi/evm dropped in-process backend switching (2f9a3158): choosing an EVM is choosing which plugin binary the host runs, and the switch it replaced never ran a block — its executor returned nil, nil and its tagged build did not compile. The callers stayed here, so this package no longer built against evm at all: parallel.SetBackend, AutoEVM, GoEVM, ActiveBackend and AvailableBackends are gone. What is left is worth saying out loud, so one file reports it: the C++ library's ABI, the backends it offers, and the health battery each answered. The cevm package carries its own build tags, so the cgo/nocgo split in the caller went with them. Two tests went too. They asserted that selection left a runnable lane active and that it was idempotent, and there is no selection to be idempotent about; that a build reports what it cannot execute is still covered. The package went from listing no tests at all — it did not compile — to running ten. Co-authored-by: Hanzo Dev <[email protected]>
136 lines
7.4 KiB
Go
136 lines
7.4 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)
|
|
}
|
|
|
|
// Say what this binary linked before it serves, so an operator reading
|
|
// the log knows which library answered.
|
|
reportCevm(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
|
|
}
|