mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
Adds CodecVersionV2 (zapcodec, little-endian) alongside existing V0/V1
(linearcodec, big-endian) on the txs.Codec / txs.GenesisCodec managers.
The codec.Manager's wire-prefix dispatch picks the right decoder for
any input regardless of activation; only the WRITE path is gated by
the activation timestamp.
ZAPCodecActivationTimestamp = 1782864000 (2026-07-01 00:00:00 UTC)
CodecVersionForTimestamp(ts):
ts < activation → V1 (linearcodec)
ts >= activation → V2 (zapcodec)
CodecForTimestamp(ts) → txs.Codec (same handle; future-proof for a
full manager swap after V1
retirement)
CodecAllowsRead(v) → v ∈ {V0, V1, V2}
CodecRequiresLegacy(v) → v ∈ {V0, V1}
Slot map is bit-identical across V1 and V2: registerV1TxTypes is now
parameterised over a local slotRegistrar interface that both
linearcodec.Codec and zapcodec.Codec satisfy. Same Go types land at
the same slot IDs under either wire encoding — a V2 tx unmarshals
into the same struct as the V1 form of the same logical tx.
Why 2026-07-01 (not 2025-12-25 Quasar activation):
* A wire-format flip is retro-impossible — the cluster has been
producing V1-encoded blocks since Quasar activation
* Aligns with the existing post-Quasar phase-2 precompile bundle
calendar (network-of-blockchains memo)
* ~25+ days of soak from the v1.28.x ship date — every validator
binary has the V2 decoder registered well before the write switch
Activation constant lives in codec_activation.go for clear separation.
Tests (12 new, all passing — existing 2 unchanged):
TestCodecVersionForTimestamp_StrictBoundary — bit-exact ts == act flip
TestCodecForTimestamp_ManagerIsStable — manager handle is stable
TestPreActivationRoundTripV1 — ts < act → V1 round-trip
TestPostActivationRoundTripV2 — ts >= act → V2 round-trip
TestCrossVersionWireIsDistinct — V1 ≠ V2 wire bytes
TestCodecAllowsRead — read-acceptance gate
TestCodecRequiresLegacy — legacy classifier
TestV2WireIsZapNative — byte-position LE assertions
TestV1WireIsBigEndian — byte-position BE assertions
TestActivationConstantUnchanged — constant value watchdog
All existing platformvm txs / block / executor / fee / mempool /
txheap / zap_native tests still pass.
40 lines
1.8 KiB
Go
40 lines
1.8 KiB
Go
// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package txs
|
|
|
|
// ZAPCodecActivationTimestamp is the unix timestamp at which the
|
|
// canonical write codec for the P-chain transitions from
|
|
// linearcodec (V1, big-endian) to zapcodec (V2, little-endian).
|
|
//
|
|
// Value: 1782864000 = 2026-07-01 00:00:00 UTC.
|
|
//
|
|
// Why 2026-07-01:
|
|
//
|
|
// - The historical Quasar activation milestone (Dec 25 2025 16:20
|
|
// PST) is retro-impossible for a wire-format flip; the cluster
|
|
// has been running and producing V1-encoded blocks since then.
|
|
// - 2026-07-01 aligns with the existing post-Quasar phase-2
|
|
// precompile activation calendar (see the network of blockchains
|
|
// architecture memo in MEMORY.md). Bundling wire-codec flips
|
|
// with precompile bundles reduces the number of forward-dated
|
|
// activations operators must track.
|
|
// - Far enough out that every validator binary in the field before
|
|
// activation will recognise V2 as a registered codec (this
|
|
// constant ships in v1.28.x+ and the activation gives operators
|
|
// a multi-week soak window).
|
|
//
|
|
// Read path is timestamp-blind: any binary with this constant baked
|
|
// in unmarshals both V1 and V2 bytes via codec.Manager's wire-prefix
|
|
// dispatch. The timestamp gates only the WRITE path — which version
|
|
// the mempool/block-builder/signer emits.
|
|
//
|
|
// Coordination protocol: changing this constant requires every
|
|
// validator to ship the new binary BEFORE the new timestamp ticks.
|
|
// Otherwise validators on the old binary will reject V2-prefixed
|
|
// blocks produced by the new binary (codec.Manager returns
|
|
// ErrUnknownVersion) and the chain halts. A long forward-dated
|
|
// activation gives operators time to upgrade without coordination
|
|
// drama.
|
|
const ZAPCodecActivationTimestamp uint64 = 1782864000
|