mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
5.0 KiB
5.0 KiB
LLM.md - Lux EVM Module
Project Overview
Lux EVM (formerly Subnet-EVM) is the Ethereum Virtual Machine implementation for Lux subnets. This module provides EVM compatibility for the Lux network.
CRITICAL VERSION REQUIREMENTS
ALWAYS use these Lux-specific versions:
github.com/luxfi/node v1.16.15- Latest Lux node versiongithub.com/luxfi/geth v1.16.2-lux.4- Our fork of go-ethereum- Local packages from parent directory: consensus, crypto, warp (tagged v1.16.15-lux)
IMPORTANT: Package Usage
- Use
lp118package for p2p handlers - Import:
github.com/luxfi/node/network/p2p/lp118 - All handler IDs:
lp118.HandlerID - All functions:
lp118.NewCachedHandler,lp118.NewSignatureAggregator - NEVER import from ava-labs packages
- NEVER use go-ethereum directly, always use luxfi/geth
Module Structure
/home/z/work/lux/evm/
├── plugin/evm/ # Main VM implementation
├── core/ # Core blockchain logic
├── consensus/ # Consensus engine (dummy for Lux)
├── eth/ # Ethereum protocol implementation
├── miner/ # Block building and mining
├── precompile/ # Precompiled contracts and warp
├── network/ # P2P networking
├── params/ # Chain configuration
├── scripts/ # Build and test scripts
└── warp/ # Cross-subnet messaging
Current Build Status
🔄 IN PROGRESS - Updating to Latest Lux Versions
The module is being updated to use:
- node v1.16.15 - Latest Lux node version with lp118 support
- consensus v1.16.15-lux - Tagged to match node version
- crypto v1.16.15-lux - Tagged to match node version
- warp v1.16.15-lux - Tagged to match node version
Main Compatibility Issues
- ID Types: Node expects
node/ids.NodeIDbut consensus usesluxfi/ids.NodeID - Block Interface: Mismatch between
consensus/chain.Blockandnode/consensus/chain.Block - Logger Interface: luxfi/log.Logger vs node/utils/logging.Logger incompatibility
- AppError Types: consensus/core.AppError vs node/snow/engine/common.AppError
Fixes Applied
- Updated to latest Lux node v1.16.15
- Using lp118 package for p2p handlers
- Context changed from struct to context.Context
- Network module uses ID conversion functions
- All local modules tagged with v1.16.15-lux for consistency
Remaining Work
- Create adapter layer between node and consensus ID types
- Implement logger wrapper for luxfi/log to node/utils/logging
- Fix Block interface to satisfy both consensus and node requirements
- Update all ID conversions throughout the codebase
Key Implementation Details
Context Management
- VM uses
context.Contextinstead of consensus.Context struct - Access consensus data via helper functions:
consensus.GetChainID(ctx)consensus.GetNetworkID(ctx)consensus.GetNodeID(ctx)consensus.GetLogger(ctx)consensus.GetWarpSigner(ctx)
Interface Compatibility
- Block implements both
chain.Blockandconsensuschain.Block - BuildBlock returns
consensuschain.Blockfor compatibility - AppSender uses
set.Set[ids.NodeID]for node sets - Version uses
consensus/version.Applicationnot node's version
Package Dependencies
NEVER use these packages:
- ❌
github.com/ethereum/go-ethereum- Usegithub.com/luxfi/geth - ❌
github.com/ava-labs/*- Usegithub.com/luxfi/* - ❌
github.com/luxfi/node v1.16.x- Use v1.13.4 for compatibility
Always use:
- ✅
github.com/luxfi/consensus- Local consensus package - ✅
github.com/luxfi/crypto- Local crypto package - ✅
github.com/luxfi/warp- Local warp package - ✅
github.com/luxfi/geth- Our Ethereum fork
Build Commands
cd /home/z/work/lux/evm
go build ./... # Currently fails due to interface issues
go test ./... # Will work after build issues are resolved
Common Issues and Fixes
-
Version Requirements
- Always use node v1.16.15 or later Lux versions
- Never use ava-labs packages
- Check go.mod replace directives
-
Interface Compatibility
- Block needs SetStatus method (even if no-op)
- BuildBlock must return consensuschain.Block
- Context is context.Context, not a struct
-
Missing Metrics
- Metrics registration is currently disabled (TODO)
- Will be re-enabled when consensus context supports it
-
ID Type Conversions
// Convert between node's IDs and consensus IDs func nodeIDToConsensus(id nodeids.NodeID) ids.NodeID { var consensusID ids.NodeID copy(consensusID[:], id[:]) return consensusID }
Testing
- Run with
-shortflag for quick tests - 28 packages with tests, 14 without (expected)
- Tests will pass after build issues are resolved
Important Notes
- This module is actively being migrated from subnet-evm
- Maintains backwards compatibility with existing Lux subnets
- Uses single validator POA for development (k=1 consensus)
- Major refactoring needed to reconcile ID type differences between packages