3.9 KiB
Final codec rip — luxfi/utxo
Activation 2025-12-25T16:20:00-08:00. No backwards compat, no shim, no env var. The wire is ZAP. Delete the legacy.
Surface to delete
Per-fx vm.go (8 files)
Drop CodecRegistry() codec.Registry from the VM interface. Drop the
Codec field from TestVM and its CodecRegistry() accessor. Drop the
luxfi/codec import. Files:
secp256k1fx/vm.gomldsafx/vm.goslhdsafx/vm.goed25519fx/vm.gosecp256r1fx/vm.goschnorrfx/vm.gobls12381fx/fx.go(VM interface lives in fx.go for this package)
Per-fx fx.go Initialize (9 files)
Drop the c := fx.VM.CodecRegistry() block + the RegisterType chain.
The wire schema is static at compile time; nothing to register. Each
Initialize keeps the VM cast + logger init and otherwise becomes a
no-op. Files:
secp256k1fx/fx.gomldsafx/fx.goslhdsafx/fx.goed25519fx/fx.gosecp256r1fx/fx.goschnorrfx/fx.gobls12381fx/fx.gonftfx/fx.go— embedssecp256k1fx.Fx, has its own RegisterType chainpropertyfx/fx.go— embedssecp256k1fx.Fx, has its own RegisterType chain
Root package
api.go— replacecodec.Uint32/codec.Uint64withjsonutil.Uint32/jsonutil.Uint64(new package) or unqualifieduint32/uint64with hand-rolled JSON. Cleanest: replicate the JSON-string-quoted types locally inutxo/jsonutil/.atomic_utxos.go— dropcodec codec.Managerfield + ctor param; parse cross-chain bytes throughwire.WrapUTXO(b).flow_checker.go— replacewrappers.Errswith an inline 5-lineerrsstruct or move toutxo/internal/errs/. Drop theluxfi/codec/wrappersimport.transferables.go— dropc codec.ManagerfromSortTransferableOutputs,IsSortedTransferableOutputs,VerifyTx. Sort key is nowout.Bytes()(the ZAP wire envelope returned by thewireSerializableinterface).Verifyis unchanged.utxo_state.go— dropcodec codec.Managerfield + ctor params; encode/decode throughutxo.WireBytes()/utxo.WrapUTXOBytes().
wire/discriminator.go
Doc-comment-only reference. Comment text is correct historical context; no import statement. Leave it.
Activation invariant
The new network's genesis is at unix 1766708400. Every block produced after that point uses ZAP-native UTXO encoding. No legacy codec UTXOs exist on disk or on the wire.
Cascade
After this lands, every luxd caller of:
lux.SortTransferableOutputs(outs, Codec)→lux.SortTransferableOutputs(outs)lux.IsSortedTransferableOutputs(outs, Codec)→lux.IsSortedTransferableOutputs(outs)lux.VerifyTx(fee, feeAsset, ins, outs, Codec)→lux.VerifyTx(fee, feeAsset, ins, outs)lux.GetAtomicUTXOs(sm, codec, ...)→lux.GetAtomicUTXOs(sm, ...)lux.NewAtomicUTXOManager(sm, codec)→lux.NewAtomicUTXOManager(sm)lux.NewUTXOState(db, codec, track)→lux.NewUTXOState(db, track)lux.NewMeteredUTXOState(db, codec, metrics, track)→lux.NewMeteredUTXOState(db, metrics, track)
needs the codec arg dropped. Plus every fx.Initialize callsite no
longer needs vm.CodecRegistry() to do anything.
Order of operations
- Define
utxo/jsonutil/uint.gowithUint32/Uint64JSON-string types. - Patch
api.goto usejsonutil. - Patch
flow_checker.goto inline a tiny errs collector. - Patch
transferables.goto usewireSerializable.Bytes()as sort key. - Patch
atomic_utxos.goto usewire.WrapUTXO(b). - Patch
utxo_state.goto useutxo.WireBytes()/WrapUTXOBytes. - Patch every fx's
vm.goto dropCodecRegistry()+Codecfield. - Patch every fx's
fx.goInitializeto drop the registration chain. - Patch every fx's tests to drop
Codec: linearcodec.NewDefault()+ thelinearcodecimport. - Build + test in tree.
go mod edit -droprequire=github.com/luxfi/codec+ tidy.- Cascade through
luxdconsumer files.