chaincmd

package
v0.8.12 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: GPL-3.0, LGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InitCommand = &cli.Command{
		Action:    initGenesis,
		Name:      "init",
		Usage:     "Bootstrap and initialize a new genesis block",
		ArgsUsage: "<genesisPath>",
		Flags:     utils.DatabaseFlags,
		Description: `
The init command initializes a new genesis block and definition for the network.
Supports SubnetEVM genesis format with proper field handling.`,
	}

	ExportCommand = &cli.Command{
		Action:    exportChain,
		Name:      "export",
		Usage:     "Export blockchain from SubnetEVM pebbledb to RLP file",
		ArgsUsage: "<filename> [<blockNumFirst> <blockNumLast>]",
		Flags: []cli.Flag{
			utils.DataDirFlag,
			namespaceFlag,
		},
		Description: `
Export blocks from a SubnetEVM pebbledb database to an RLP-encoded file.
The database must be a pebbledb with SubnetEVM namespace prefix format.`,
	}

	ImportCommand = &cli.Command{
		Action:    importChain,
		Name:      "import",
		Usage:     "Import a blockchain file with full transaction replay",
		ArgsUsage: "<filename>",
		Flags:     utils.DatabaseFlags,
		Description: `
Import blocks from an RLP-encoded file and replay all transactions.
This performs TRUE migration with state verification.`,
	}

	CopyGenesisCommand = &cli.Command{
		Action:    copyGenesis,
		Name:      "copy-genesis",
		Usage:     "Copy genesis state from SubnetEVM pebbledb to new database",
		ArgsUsage: "",
		Flags: []cli.Flag{
			utils.DataDirFlag,
			namespaceFlag,
			&cli.StringFlag{
				Name:     "source",
				Usage:    "Source SubnetEVM pebbledb path",
				Required: true,
			},
		},
		Description: `
Copy the genesis block and state directly from a SubnetEVM database.
This preserves the exact genesis hash for TRUE migration.`,
	}

	// JSONLToRLPCommand converts JSONL block export to RLP format
	JSONLToRLPCommand = &cli.Command{
		Action:    jsonlToRLP,
		Name:      "jsonl-to-rlp",
		Usage:     "Convert JSONL block export to RLP format",
		ArgsUsage: "<input.jsonl> <output.rlp>",
		Flags:     []cli.Flag{},
		Description: `
Convert a JSONL block export file to RLP format for import.
This is a one-time conversion - delete JSONL after conversion.`,
	}

	// RegenesisCommand performs disaster recovery via transaction replay
	RegenesisCommand = &cli.Command{
		Action:    regenesis,
		Name:      "regenesis",
		Usage:     "Disaster recovery: initialize genesis and replay transactions",
		ArgsUsage: "<genesis.json> <blocks.rlp>",
		Flags:     utils.DatabaseFlags,
		Description: `
Performs disaster recovery by:
1. Initializing with computed genesis (produces NEW genesis hash)
2. Extracting transactions from old blocks
3. Replaying transactions to rebuild state

NOTE: Block hashes will differ from original chain.
Transaction history and final state are preserved.`,
	}
)

Functions

This section is empty.

Types

type JSONLBlock

type JSONLBlock struct {
	Number      uint64 `json:"number"`
	Hash        string `json:"hash"`
	HeaderRLP   string `json:"header_rlp"`
	BodyRLP     string `json:"body_rlp"`
	ReceiptsRLP string `json:"receipts_rlp"`
}

JSONLBlock represents a block in JSONL export format

Jump to

Keyboard shortcuts

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