Files
node/upgrade/upgrade.go
T
Hanzo AI ab3d1e6b8f decomplect: delete IsXxxActivated predicates (Apricot/Banff/Cortina/Durango/Etna/Fortuna/Granite); inline all callsites to always-on; activate-all-implicitly from genesis
Phase 1b of the upstream-upgrade purge per ~/work/lux/proofs/UPGRADE_RIP.md.

Production code:
- upgrade.Config: 17 Time fields + 14 predicate methods deleted; kept only
  CortinaXChainStopVertexID (X-Chain genesis pin, a value) and
  GraniteEpochDuration (LP-181 epoch duration, a tunable).
- upgrade.AlwaysOn: tiny adapter that satisfies runtime.NetworkUpgrades
  (every predicate returns true). Used by chains/manager.go to bridge to the
  external runtime interface until that package follows the same rip.
- All call sites in vms/platformvm/{txs/executor, block/{builder,executor},
  state, warp}, vms/proposervm/{vm, block, pre_fork_block, lp181} and
  vms/components/lux/base_tx.go inlined to the always-active branch.
- ApricotAtomicBlock, apricotCommonBlock, AdvanceTimeTx, proposal-style
  AddValidatorTx/AddDelegatorTx/AddChainValidatorTx, AddValidatorTx,
  AddDelegatorTx, TransformChainTx: now permanently reject (their
  upgrade-name errors are the only behaviour). No legacy logic remains.
- node.go: NewNetwork's minCompatibleTime is upgrade.InitiallyActiveTime
  instead of the deleted FortunaTime.
- xvm/config.Config.EtnaTime field deleted; xvm.Linearize uses
  upgrade.InitiallyActiveTime for genesis chain-state initialization.

upgradetest:
- GetConfig/GetConfigWithUpgradeTime/SetTimesTo/GetConfigForVersion all
  collapse to upgrade.Default; the Fork enum stays (deleted in Phase 4
  alongside the upgrade.UnscheduledActivationTime constant the tests use).

No backwards compatibility for old chaindata: deleted upgrade.Time fields
break wire compatibility for codec-version-0 P-Chain state. Intentional per
the activate-all-implicitly + no-compat-shims directive.

Build: `GOCACHE=/tmp/gocache-decomplect-r2 GOWORK=off go build ./...` green.
Test files still reference deleted upgrade.Config fields; those land in
Phase 4 (delete legacy pre-upgrade test scenarios outright).
2026-05-18 22:16:55 -07:00

87 lines
3.6 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
// Package upgrade publishes the canonical Lux genesis-activation timestamp and
// the small set of runtime tunables that survived the upstream upgrade rip.
//
// All historical "fork timestamp + IsXxxActivated()" gates were deleted under
// the activate-all-implicitly directive: every Lux chain runs the post-Granite
// rule-set from genesis, so the legacy predicates are unreachable. The fields
// retained here encode real runtime values, not gates.
package upgrade
import (
"time"
"github.com/luxfi/constants"
"github.com/luxfi/ids"
)
// InitiallyActiveTime is the canonical Lux genesis-activation timestamp. It is
// referenced by code paths that historically demanded "post-fork timestamp" as
// an input and now want a single deterministic value.
var InitiallyActiveTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC)
// Config carries the runtime tunables that survived the upstream upgrade rip.
//
// - CortinaXChainStopVertexID encodes the per-network stop-vertex ID that
// pins X-Chain genesis state at boot. It is a value, not a gate.
// - GraniteEpochDuration is the LP-181 epoch duration; per-network value
// (5m on mainnet, 30s on test/dev) tunes consensus pacing.
type Config struct {
CortinaXChainStopVertexID ids.ID `json:"cortinaXChainStopVertexID"`
GraniteEpochDuration time.Duration `json:"graniteEpochDuration"`
}
// Validate is retained for callers that still invoke it; under activate-all-
// implicitly there is no upgrade ordering to enforce, so the function is a
// no-op.
func (*Config) Validate() error { return nil }
var (
Mainnet = Config{
CortinaXChainStopVertexID: ids.FromStringOrPanic("jrGWDh5Po9FMj54depyunNixpia5PN4aAYxfmNzU8n752Rjga"),
GraniteEpochDuration: 5 * time.Minute,
}
Testnet = Config{
CortinaXChainStopVertexID: ids.FromStringOrPanic("2D1cmbiG36BqQMRyHt4kFhWarmatA1ighSpND3FeFgz3vFVtCZ"),
GraniteEpochDuration: 30 * time.Second,
}
Default = Config{
CortinaXChainStopVertexID: ids.Empty,
GraniteEpochDuration: 30 * time.Second,
}
)
// GetConfig resolves the per-network runtime config.
func GetConfig(networkID uint32) Config {
switch networkID {
case constants.MainnetID:
return Mainnet
case constants.TestnetID:
return Testnet
default:
return Default
}
}
// AlwaysOn is the activate-all-implicitly bridge that satisfies
// runtime.NetworkUpgrades for callers that haven't yet been migrated off the
// legacy predicate interface. Every method returns true.
type AlwaysOn struct{}
func (AlwaysOn) IsApricotPhase1Activated(time.Time) bool { return true }
func (AlwaysOn) IsApricotPhase2Activated(time.Time) bool { return true }
func (AlwaysOn) IsApricotPhase3Activated(time.Time) bool { return true }
func (AlwaysOn) IsApricotPhase4Activated(time.Time) bool { return true }
func (AlwaysOn) IsApricotPhase5Activated(time.Time) bool { return true }
func (AlwaysOn) IsApricotPhasePre6Activated(time.Time) bool { return true }
func (AlwaysOn) IsApricotPhase6Activated(time.Time) bool { return true }
func (AlwaysOn) IsApricotPhasePost6Activated(time.Time) bool { return true }
func (AlwaysOn) IsBanffActivated(time.Time) bool { return true }
func (AlwaysOn) IsCortinaActivated(time.Time) bool { return true }
func (AlwaysOn) IsDurangoActivated(time.Time) bool { return true }
func (AlwaysOn) IsEtnaActivated(time.Time) bool { return true }
func (AlwaysOn) IsFortunaActivated(time.Time) bool { return true }
func (AlwaysOn) IsGraniteActivated(time.Time) bool { return true }