feat(precompiles): enable FHE and rename precompileHook

- Enable FHE precompile from standalone precompiles package
- Rename luxRulesHook to precompileHook for clarity
- DEX precompiles to be imported from standalone precompiles package
- Clean up debug logging from vm.go

The FHE precompile uses pure Go TFHE implementation from
github.com/luxfi/fhe for on-chain homomorphic encryption.
This commit is contained in:
2025-12-29 23:05:42 -08:00
parent 24daa57cd3
commit 4692930eff
5 changed files with 20 additions and 7 deletions
+3 -3
View File
@@ -22,11 +22,11 @@ import (
func init() {
// Register the rules hook to populate Rules.Payload with our PrecompileOverrider
gethparams.SetRulesHook(luxRulesHook)
gethparams.SetRulesHook(precompileHook)
}
// luxRulesHook populates Rules.Payload with the LuxPrecompileOverrider
func luxRulesHook(c *gethparams.ChainConfig, rules *gethparams.Rules, num *big.Int, isMerge bool, timestamp uint64) {
// precompileHook populates Rules.Payload with the LuxPrecompileOverrider
func precompileHook(c *gethparams.ChainConfig, rules *gethparams.Rules, num *big.Int, isMerge bool, timestamp uint64) {
// Store context for GetRulesExtra to use
params.SetRulesContext(rules, c, timestamp)
+4
View File
@@ -33,6 +33,7 @@ require (
github.com/luxfi/node v1.22.75
github.com/luxfi/p2p v1.18.2
github.com/luxfi/precompiles v0.1.10
github.com/luxfi/precompiles/dex v0.0.0-20251229190240-aa4133362cd3
github.com/luxfi/timer v1.0.1
github.com/luxfi/trace v0.1.4
github.com/luxfi/units v1.0.0
@@ -147,6 +148,7 @@ require (
github.com/wlynxg/anet v0.0.5 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
github.com/zeebo/blake3 v0.2.4 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.37.0 // indirect
@@ -169,3 +171,5 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
replace github.com/luxfi/node => /Users/z/work/lux/node
+8 -2
View File
@@ -252,12 +252,12 @@ github.com/luxfi/metric v1.4.8 h1:mMbcJW+E1z6qQxn34+BE109HlvT6ciiDXuc10qEBJRs=
github.com/luxfi/metric v1.4.8/go.mod h1:AUQ7NSNz9WndAcr/SKnOkP7XSFFnBXOa+ihtJYfDaQY=
github.com/luxfi/mock v0.1.0 h1:IwElfNu+T9sXvzFX6tudPDx1vqPuACRSRdxpD5lxW+o=
github.com/luxfi/mock v0.1.0/go.mod h1:izF+9K0gGzFC9zERn6Po37v46eLdPB+EIsDjL3GLk+U=
github.com/luxfi/node v1.22.75 h1:kOs6bbwP23scRTDN1YTjglcVQgncpaZqmeZIV/Cheqc=
github.com/luxfi/node v1.22.75/go.mod h1:97xyVTMBFq/LmbrQ0VMA6DNNWBYSu+3jQG1ztBBEuHc=
github.com/luxfi/p2p v1.18.2 h1:elpyXr58wht1KP64D4BcKXft1AEjJ3IRACj/W8vdLI8=
github.com/luxfi/p2p v1.18.2/go.mod h1:eM6XpmBFbDjaI7fFuGYBPab77TS1esxHxAOluBLAC0Y=
github.com/luxfi/precompiles v0.1.10 h1:M90JTzW+je/uaCBSE2BvoONamBTbuUDskh4fxua6oUE=
github.com/luxfi/precompiles v0.1.10/go.mod h1:s4054PbUgIZ/CezXT3BSNGbUqimgzK7LABP0wMhNG/Y=
github.com/luxfi/precompiles/dex v0.0.0-20251229190240-aa4133362cd3 h1:v7UmxcrSKN52n2hVF2vBGDvNiHFWP4xy/ehyQ+qn8Ag=
github.com/luxfi/precompiles/dex v0.0.0-20251229190240-aa4133362cd3/go.mod h1:KL6OoRe3+HJmssPRXkQA4qkjM6K/yUcusH+80NGEKxk=
github.com/luxfi/sampler v1.0.0 h1:k8Sf6otW83w4pQp0jXLA+g3J/joB7w7SqXQsWmNTOV0=
github.com/luxfi/sampler v1.0.0/go.mod h1:f96/ozlj9vFfZj+akLtrHn4VpulQahwB+MQQhpeIekk=
github.com/luxfi/timer v1.0.1 h1:3lRf3j0L/fA3Ud0j67cm/BW2In1kz+jxd1HqgKyglYY=
@@ -402,6 +402,12 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI=
github.com/zeebo/blake3 v0.2.4/go.mod h1:7eeQ6d2iXWRGF6npfaxl2CU+xy2Fjo2gxeyZGCRUjcE=
github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
+1 -1
View File
@@ -926,7 +926,7 @@ func (vm *VM) initializeMetrics() error {
func (vm *VM) initializeChain(lastAcceptedHash common.Hash, ethConfig ethconfig.Config) error {
nodecfg := &node.Config{
EVMVersion: Version,
EVMVersion: Version,
KeyStoreDir: vm.config.KeystoreDirectory,
ExternalSigner: vm.config.KeystoreExternalSigner,
InsecureUnlockAllowed: vm.config.KeystoreInsecureUnlockAllowed,
+4 -1
View File
@@ -16,9 +16,12 @@ import (
_ "github.com/luxfi/evm/precompile/contracts/warp"
// Crypto precompiles from standalone precompiles package
// _ "github.com/luxfi/precompiles/fhe" // FHE operations via Z-Chain coprocessor (disabled - tfhe not ready)
_ "github.com/luxfi/precompiles/fhe" // FHE operations at 0x0200...0080 (pure Go TFHE)
_ "github.com/luxfi/precompiles/mldsa" // ML-DSA signature verification (FIPS 204)
_ "github.com/luxfi/precompiles/pqcrypto" // Unified PQ crypto operations
// DEX precompiles (from standalone precompiles package)
// _ "github.com/luxfi/precompiles/dex" // DEX PoolManager at 0x0300...0020 (TODO: enable when ready)
)
// This list is kept just for reference. The actual addresses defined in respective packages of precompiles.