mirror of
https://github.com/luxfi/chains.git
synced 2026-09-24 00:26:00 +00:00
Nine chains each write their own Accept, and five of them write it with individual Puts that return early. A later write failing leaves the earlier ones on disk and the chain already believing the block was accepted: state is half-applied and there is no path back. The discipline two chains already have becomes the only one there is. A block declares what it Writes and what it Publishes; the store stages the writes through a versiondb, commits them in ONE batch with the block, its height entry and the tip pointer, and on any failure rolls the view back and rebuilds the caches from committed state. Nothing the block claimed survives and the tip does not move. Publish runs after the commit, so there is no window in which the chain has advanced past state that is not on disk. Beside it: the blocks in flight, under the store's one lock, pruned at or below the accepted height because the engine may abandon a block without ever deciding it; the pool, whose claim set is derived from its queue so a claim cannot outlive the entry that made it; the fee a chain declares, which admits nothing until it is declared; and the factory, whose VM holds nothing until Initialize. Seven mutations of the store and three of the pool each fail at least one test.
21 lines
698 B
Go
21 lines
698 B
Go
// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package chain
|
|
|
|
import (
|
|
"github.com/luxfi/log"
|
|
"github.com/luxfi/node/vms"
|
|
)
|
|
|
|
// Factory builds one chain's VM. The zero VM is the whole of it: a VM gets its
|
|
// database, its configuration and its caches in Initialize, and nothing else
|
|
// may hand it state — a factory that half-populates a VM leaves two places
|
|
// that decide what a fresh VM holds, and they drift.
|
|
type Factory[T any] struct{}
|
|
|
|
var _ vms.Factory = Factory[struct{}]{}
|
|
|
|
// New returns a VM with nothing set. Initialize does the rest.
|
|
func (Factory[T]) New(log.Logger) (interface{}, error) { return new(T), nil }
|