mirror of
https://github.com/luxfi/chains.git
synced 2026-09-24 00:26:00 +00:00
VM consolidation (one module, one place only):
- Removed per-VM go.mod/go.sum/VERSION from {aivm,bridgevm,dexvm,evm,
graphvm,identityvm,keyvm,oraclevm,quantumvm,relayvm,thresholdvm,zkvm}
- All VMs now compile under github.com/luxfi/chains root module
- aivm/, dexvm/, identityvm/, keyvm/, oraclevm/ factory.go + vm.go updated
for AccelHost wiring
cevm Go-side (evm/cevm/):
- cevm.go, cevm_cgo.go, cevm_nocgo.go: ExecuteBlockV4(backend, threads,
txs, ctx, state) with StateAccount snapshot
- cevm_secp256k1.go: BatchRecoverSenders Metal LDFLAGS
- cevm_secp256k1_metal_anchor_darwin.{c,go}: anchor to keep linker from
dropping libsecp256k1_metal.a
- cevm_secp256k1_nocgo.go: stub for non-cgo builds
- plugin.go, fetch-luxcpp.sh, luxcpp-SHA256SUMS, LUXCPP_VERSION:
pinned luxcpp consumption
- evm/cevm/parallel/parallel.go: BlockExecutor adapter calls
cevm.ExecuteBlockV4 with state snapshot built from txs+statedb
Quantum/ZK witness:
- quantumvm/quasar_witness.go, zkvm/zwitness.go
go.mod: removed dead `replace github.com/ethereum/go-ethereum => luxfi/geth`
directive (caused dual-path conflict after math semver bump; no remaining
ethereum/go-ethereum imports in source). go mod tidy clean.
Tests: TestBatchRecoverSenders PASS through Metal anchor (cevm package).
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package keyvm
|
|
|
|
import (
|
|
"github.com/luxfi/accel"
|
|
"github.com/luxfi/chains/keyvm/config"
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/log"
|
|
"github.com/luxfi/node/vms"
|
|
)
|
|
|
|
var _ vms.Factory = (*Factory)(nil)
|
|
|
|
// VMID is the unique identifier for KeyVM (K-Chain)
|
|
var VMID = ids.ID{'k', 'e', 'y', 'v', 'm'}
|
|
|
|
// Factory implements vms.Factory interface for creating K-Chain VM instances.
|
|
type Factory struct {
|
|
config.Config
|
|
}
|
|
|
|
// New creates a new K-Chain VM instance.
|
|
// Allocates a per-VM GPU session at PriorityHigh because key management
|
|
// is on the hot path for cross-chain operations.
|
|
func (f *Factory) New(logger log.Logger) (interface{}, error) {
|
|
// Set default configuration if not provided
|
|
if f.Config.ListenPort == 0 {
|
|
f.Config = config.DefaultConfig()
|
|
}
|
|
|
|
// Validate configuration
|
|
if err := f.Config.Validate(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
sess, err := accel.NewVMSession("keyvm", accel.WithPriority(accel.PriorityHigh))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// Create and return new K-Chain VM instance
|
|
vm := &VM{
|
|
Config: f.Config,
|
|
log: logger,
|
|
accel: sess,
|
|
}
|
|
|
|
return vm, nil
|
|
}
|
|
|
|
// NewFactory creates a new K-Chain VM factory with the given configuration.
|
|
func NewFactory(cfg config.Config) *Factory {
|
|
return &Factory{Config: cfg}
|
|
}
|
|
|
|
// NewDefaultFactory creates a new K-Chain VM factory with default configuration.
|
|
func NewDefaultFactory() *Factory {
|
|
return &Factory{Config: config.DefaultConfig()}
|
|
}
|