Files
zeekay 7cf87b230b node-unified is the node
The module already called itself github.com/luxfi/node while containing no node
in Go: cmd/luxd was twenty-one lines that printed the size of a few types, and
the Go column of the matrix measured a VM plugin. A repo that fetches the thing
it claims to be has not replaced it, so the Go sources move in — 1515 files,
the daemon and everything under it — and the build reaches outside this module
for nothing.

Rust and C++ sit beside it unchanged and are still measured against it by the
differential. That is the point of one repo: the reference implementation and
the two ports are the same checkout, so parity is a thing you can run rather
than a thing you assert.

Verified: builds, and the closure carries no lux-private — checked at build time
rather than believed. The daemon starts twelve chains on a local network
(P X C Q Z A B G K M F, plus D through its plugin) and reports healthy.
2026-09-07 16:15:25 -07:00

69 lines
2.3 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package proposervm
import (
"context"
"github.com/luxfi/node/vms/proposervm/summary"
chain "github.com/luxfi/vm/chain"
)
var _ chain.StateSummary = (*stateSummary)(nil)
// stateSummary implements chain.StateSummary by layering three objects:
//
// 1. [statelessSummary] carries all summary marshallable content along with
// data immediately retrievable from it.
// 2. [innerSummary] reports the height of the summary as well as notifying the
// inner vm of the summary's acceptance.
// 3. [block] is used to update the proposervm's last accepted block upon
// Accept.
//
// Note: summary.StatelessSummary contains the data to build both [innerSummary]
// and [block].
type stateSummary struct {
summary.StateSummary
// inner summary, retrieved via Parse
innerSummary chain.StateSummary
// block associated with the summary
block PostForkBlock
vm *VM
}
func (s *stateSummary) Height() uint64 {
return s.innerSummary.Height()
}
func (s *stateSummary) Accept(ctx context.Context) (chain.StateSyncMode, error) {
// set fork height first, before accepting proposerVM full block
// which updates height index (among other indices)
if err := s.vm.State.SetForkHeight(s.StateSummary.ForkHeight()); err != nil {
return chain.StateSyncSkipped, err
}
// Mark the summary as accepted on the outerVM iff it rolls forward.
// We refuse to roll the proposerVM backward because it violates the invariant
// that the proposerVM index is always >= the innerVM index.
if s.vm.lastAcceptedHeight < s.Height() {
// We store the full proposerVM block associated with the summary
// and update height index with it, so that state sync could resume
// after a shutdown.
if err := s.block.acceptOuterBlk(); err != nil {
return chain.StateSyncSkipped, err
}
}
// innerSummary.Accept may fail with the proposerVM block and index already
// updated. The error would be treated as fatal and the chain would then be
// repaired upon the VM restart.
// After the inner summary is accepted, the engine transitions to bootstrapping
// and SetState is responsible for re-aligning the ProposerVM to the height reported
// by the inner VM after handling state sync.
return s.innerSummary.Accept(ctx)
}