upgrades

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package upgrades is the ledger of every binary a gno.land network has run.

misc/deployments/<chain>/upgrades.json is the source of truth; UPGRADES.md next to it carries a table rendered from the JSON between two markers. This package owns the format: parsing, the invariants a replaying supervisor relies on, the rendering, and the check that the two files agree. The rules live in Go, tested, rather than in a shell script forked per chain.

The contract: a version runs the blocks from the previous entry's halt_height + 1 (1 for genesis) up to and including its own successor's halt_height. Entries are in chain order: strictly increasing versions and strictly increasing halt heights. A rolling release — a PATCH that changes no consensus code, switched to whenever an operator likes — has no halt and bounds no range: it can serve the same blocks as the entry before it.

Index

Constants

View Source
const (
	// LedgerFile and DocFile are the two files a deployment directory holds.
	LedgerFile = "upgrades.json"
	DocFile    = "UPGRADES.md"

	// BeginMarker and EndMarker delimit the generated table inside DocFile.
	BeginMarker = "<!-- BEGIN GENERATED (gno.land/pkg/upgrades) -->"
	EndMarker   = "<!-- END GENERATED -->"

	// SchemaVersion is the only format this package reads and writes.
	SchemaVersion = 1
)

Variables

This section is empty.

Functions

func Check

func Check(dir string) error

Check fails if dir/upgrades.json is invalid or dir/UPGRADES.md is stale.

func ParseVersion

func ParseVersion(v string) (string, bool)

ParseVersion normalises a release tag the way the node does (gno.land/pkg/gnoland.parseReleaseVersion): vMAJOR.MINOR.PATCH with an optional pre-release, build metadata dropped. The ledger only ever holds tags the node can order, because halt_min_version is compared with them.

func Render

func Render(dir string) error

Render rewrites dir/UPGRADES.md from dir/upgrades.json.

func Splice

func Splice(doc []byte, table string) ([]byte, error)

Splice replaces the generated block of doc, markers included, with table.

Types

type Entry

type Entry struct {
	Kind           Kind              `json:"kind"`
	Version        string            `json:"version"`
	Commit         string            `json:"commit"`
	HaltHeight     *int64            `json:"halt_height"`
	HaltTime       *time.Time        `json:"halt_time"`
	HaltMinVersion *string           `json:"halt_min_version"`
	Proposal       *int64            `json:"proposal"`
	Image          Image             `json:"image"`
	Binaries       map[string]string `json:"binaries"`
	RanAs          *string           `json:"ran_as"`
	Release        string            `json:"release"`
}

Entry is one binary the network ran. Pointer fields are null in the JSON until the fact they record has happened: the digest until CI built the image, the halt time until the halt, the proposal until it was created. HaltMinVersion is null when the proposal set no floor; an empty string is refused, so "the gate was off" and "someone forgot" cannot be confused.

type Image

type Image struct {
	Ref    string  `json:"ref"`
	Digest *string `json:"digest"`
}

Image is the gnoland container image for an entry: the tag operators pin, and the digest that tag resolved to when the ledger was written.

type Kind

type Kind string

Kind says what an entry is: the genesis the chain started on, a coordinated upgrade that changed the binary at a halt height, or a rolling release that operators switch to at their convenience.

const (
	KindGenesis Kind = "genesis"
	KindUpgrade Kind = "upgrade"
	KindRolling Kind = "rolling"
)

type Ledger

type Ledger struct {
	Schema        string    `json:"$schema,omitempty"`
	SchemaVersion int       `json:"schema_version"`
	ChainID       string    `json:"chain_id"`
	GenesisSHA256 string    `json:"genesis_sha256"`
	GenesisTime   time.Time `json:"genesis_time"`
	Upgrades      []Entry   `json:"upgrades"`
}

Ledger is one chain's upgrades.json.

func Load

func Load(dir string) (*Ledger, error)

Load reads and parses dir/upgrades.json.

func Parse

func Parse(data []byte) (*Ledger, error)

Parse decodes a ledger. Unknown fields are an error: a misspelled field would otherwise vanish silently, which for a null-able field looks exactly like "pending".

func (*Ledger) BlockRanges

func (l *Ledger) BlockRanges() []Range

BlockRanges is the contract made explicit: which version produced which blocks. Only the genesis and the coordinated upgrades open a range; a rolling release is attached to the range it was released into. The last range's To is 0 because the current version is still running.

func (*Ledger) Has

func (l *Ledger) Has(v string) bool

Has reports whether the ledger has an entry for v, ignoring a pre-release suffix on either side: a release candidate rehearses the final version's entry rather than getting one of its own.

func (*Ledger) RenderTable

func (l *Ledger) RenderTable() string

RenderTable renders the Markdown table, markers included, with a readable word in every cell whose fact has not happened yet.

func (*Ledger) Validate

func (l *Ledger) Validate() error

Validate checks every invariant and reports all violations at once.

type Range

type Range struct {
	Version  string
	From, To int64
	Rolling  []string
}

Range is the blocks one entry's version produced or replays. To is 0 for the current version, which has no successor yet. Rolling lists the patches released on top of Version before the next halt: consensus- compatible with it, so any of them can serve the same blocks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL