fork

package
v0.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package fork provides the `gnogenesis fork` subcommands for building and smoke-testing hardfork genesis files.

A hardfork genesis is built from:

  1. SOURCE CHAIN — provides historical state (genesis + tx history)
  2. NEW BINARY — the updated gnoland built from this repo

Source modes (auto-detected from --source):

http(s)://...    RPC of a running or recently-halted node
/path/to/dir     local node data directory (must contain config/genesis.json)
/path/to/file    exported file: genesis.json (no txs) or .jsonl (txs) or .tar.gz

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewForkCmd

func NewForkCmd(io commands.IO) *commands.Command

NewForkCmd returns the `gnogenesis fork` parent command with its subcommands (`generate`, `test`) attached.

Types

type AnnotatedTx

type AnnotatedTx struct {
	Tx       std.Tx                 `json:"tx"`
	Metadata *gnoland.GnoTxMetadata `json:"metadata,omitempty"`
	Reason   string                 `json:"reason,omitempty"`
}

AnnotatedTx is the schema for --patch-txs and --migration-tx jsonl inputs. It mirrors gnoland.TxWithMetadata with one extra field — Reason — that the user writes to document why this tx exists. The reason flows into the produced genesis as GnoTxMetadata.Note when the tx is materialized.

Files written in the plain gnoland.TxWithMetadata shape (no "reason" key) still parse here; Reason defaults to "" in that case.

type GenesisSource

type GenesisSource interface {
	// Description returns a human-readable source type label.
	Description() string

	// FetchGenesis returns the source chain's genesis document.
	FetchGenesis(ctx context.Context) (*bft.GenesisDoc, error)

	// Close releases any resources held by the source.
	Close() error
}

GenesisSource provides the source chain's genesis document. Two implementations live alongside this file, picked via mutually-exclusive --source-genesis-* flags:

  • rpcGenesisSource (--source-genesis-rpc <url>): source_genesis_rpc.go
  • fileGenesisSource (--source-genesis-file <path>): source_genesis_file.go

Historical transactions are fetched separately via a TxsSource (see source_txs.go).

type TxsSource

type TxsSource interface {
	// Description returns a human-readable source type label.
	Description() string

	// LatestHeight returns the latest committed block height known to
	// this source. Used to auto-detect halt height when --halt-height
	// is not specified.
	LatestHeight(ctx context.Context) (int64, error)

	// FetchTxs fetches all transactions in [fromHeight, toHeight] with
	// metadata (BlockHeight, Timestamp, ChainID populated). chainID is
	// supplied by the caller (sourced from the GenesisSource) so that
	// TxsSource implementations do not need to read genesis themselves.
	// Progress is reported via io.
	FetchTxs(ctx context.Context, chainID string, fromHeight, toHeight int64, io commands.IO) ([]gnoland.TxWithMetadata, error)

	// Close releases any resources held by the source.
	Close() error
}

TxsSource provides historical transactions and the latest committed height of a source chain. Three implementations live alongside this file, picked via mutually-exclusive --source-txs-* flags:

  • rpcTxsSource (--source-txs-rpc <url>): source_txs_rpc.go
  • jsonlFileTxsSource (--source-txs-jsonl-file PATH): source_txs_jsonl_file.go
  • dataDirTxsSource (--source-txs-data-dir DIR): source_txs_data_dir.go

Genesis is fetched separately via a GenesisSource (see source_genesis.go).

Jump to

Keyboard shortcuts

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