Help us shape the future of Go! Take the 2026 Go Developer Survey

network

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MainnetHardforks = []Hardfork{
	{
		Name:                "merge",
		DisplayName:         "the merge",
		Block:               15537394,
		Date:                "2022-09-15",
		ApproxArchiveSizeTB: 1.5,
	},
	{
		Name:                "shanghai",
		DisplayName:         "shanghai",
		Block:               17034870,
		Date:                "2023-04-12",
		ApproxArchiveSizeTB: 1.2,
	},
	{
		Name:                "cancun",
		DisplayName:         "cancun",
		Block:               19426587,
		Date:                "2024-03-13",
		ApproxArchiveSizeTB: 0.8,
	},
	{
		Name:                "prague",
		DisplayName:         "prague",
		Block:               22431084,
		Date:                "2025-05-07",
		ApproxArchiveSizeTB: 0.4,
	},
	{
		Name:                "osaka",
		DisplayName:         "osaka",
		Block:               23935694,
		Date:                "2025-12-03",
		ApproxArchiveSizeTB: 0.2,
	},
}

MainnetHardforks is the ordered list of mainnet hardforks supported by --since presets, oldest first.

Functions

func AddCustomRPC added in v0.5.0

func AddCustomRPC(cfg *config.Config, chainID int, chainName, endpoint string, readOnly bool) error

AddCustomRPC adds a single custom RPC endpoint for a chain to the eRPC ConfigMap. Uses the "custom-" prefix to distinguish from ChainList-sourced upstreams. When readOnly is true, eth_sendRawTransaction and eth_sendTransaction are blocked.

func AddPublicRPCs added in v0.5.0

func AddPublicRPCs(cfg *config.Config, chainID int, chainName string, endpoints []RPCEndpoint, readOnly bool) error

AddPublicRPCs adds ChainList RPCs for a chain to the eRPC ConfigMap. When readOnly is true, eth_sendRawTransaction and eth_sendTransaction are blocked.

func CheckNetworkDiskSpace added in v0.10.0

func CheckNetworkDiskSpace(u *ui.UI, dataDir, network, mode, executionClient string, scope ArchiveScope) error

CheckNetworkDiskSpace warns when the data directory has less free disk than the install is expected to need. The default answer is to continue: in non-interactive contexts (no TTY, JSON mode) the prompt auto-accepts so scripted installs don't deadlock. The user only blocks the install by explicitly declining at an interactive prompt.

func DefaultChainListFetcher added in v0.5.0

func DefaultChainListFetcher() ([]byte, error)

DefaultChainListFetcher fetches from the real ChainList API.

func Delete

func Delete(cfg *config.Config, u *ui.UI, deploymentIdentifier string) error

Delete removes the network deployment configuration and cluster resources

func DeregisterERPCUpstream added in v0.3.2

func DeregisterERPCUpstream(cfg *config.Config, networkType, id string) error

DeregisterERPCUpstream removes a previously registered local upstream from the eRPC ConfigMap.

func GetERPCStatus added in v0.5.0

func GetERPCStatus(cfg *config.Config) (podStatus string, upstreamCounts map[int]int, err error)

GetERPCStatus returns eRPC pod status and upstream counts.

func Install

func Install(cfg *config.Config, u *ui.UI, network string, overrides map[string]string, force bool) error

Install creates a network configuration by executing Go templates and saving to config directory

func List

func List(cfg *config.Config, u *ui.UI) error

List displays all available networks from the embedded filesystem

func ListInstanceIDs added in v0.5.0

func ListInstanceIDs(cfg *config.Config) ([]string, error)

ListInstanceIDs returns all installed network deployment identifiers (as "network/id" strings) by walking the networks directory on disk.

func ReconcileRecordedRPCs added in v0.10.0

func ReconcileRecordedRPCs(cfg *config.Config, u *ui.UI)

ReconcileRecordedRPCs replays recorded remote upstreams into a (possibly fresh) cluster. Called after `obol stack up`. Best-effort per chain.

func RegisterERPCUpstream added in v0.3.2

func RegisterERPCUpstream(cfg *config.Config, networkType, id string) error

RegisterERPCUpstream reads the deployed network's RPC endpoint and adds it as an upstream in the eRPC ConfigMap. The local node becomes the primary upstream (group: "primary") with automatic fallback to existing remote upstreams.

func RemovePublicRPCs added in v0.5.0

func RemovePublicRPCs(cfg *config.Config, chainID int) error

RemovePublicRPCs removes all ChainList RPCs for a chain from the eRPC ConfigMap.

func ResolveChainID added in v0.5.0

func ResolveChainID(nameOrID string) (int, string, error)

ResolveChainID converts a chain name or numeric string to a chain ID. Returns the chain ID and the resolved name (for display).

func ResolveInstance added in v0.5.0

func ResolveInstance(cfg *config.Config, args []string) (identifier string, remaining []string, err error)

ResolveInstance determines which network deployment to target based on how many deployments are installed:

  • 0 deployments: returns an error prompting the user to install one
  • 1 deployment: auto-selects it, returns args unchanged
  • 2+ deployments: expects args[0] to be a known "network/id" identifier; consumes it from args and returns the rest. Errors if no match.

func SortByQuality added in v0.5.0

func SortByQuality(endpoints []RPCEndpoint)

SortByQuality sorts RPC endpoints by tracking quality. Preference: tracking=none > tracking=limited > tracking=unknown > anything else.

func Sync

func Sync(cfg *config.Config, u *ui.UI, deploymentIdentifier string) error

Sync deploys or updates a network configuration to the cluster using helmfile

func SyncAll added in v0.3.2

func SyncAll(cfg *config.Config, u *ui.UI) error

SyncAll syncs all installed network deployments found in the config directory.

Types

type ArchiveScope added in v0.10.0

type ArchiveScope struct {
	// Kind is one of: "all" (full archive from genesis), "before" (prune
	// before a specific block), "distance" (keep last N blocks of history).
	Kind string
	// Block is set when Kind == "before".
	Block uint64
	// Distance is set when Kind == "distance".
	Distance uint64
	// Label is a human-readable description for logs/picker confirmation.
	Label string
}

ArchiveScope is the resolved meaning of --since after parsing.

func ParseSince added in v0.10.0

func ParseSince(raw string) (ArchiveScope, error)

ParseSince resolves a --since value into an ArchiveScope. Accepted forms:

  • "genesis", "all": full archive from genesis
  • "merge", "shanghai", "cancun", "prague", "osaka": EL hardfork name
  • "<N>d", "<N>mo", "<N>y": duration back from chain head (12s slots)
  • "<block>": raw block number (any unsigned integer)

Mode is reth-anchored: "before" presets get translated to reth's --prune.<segment>.before flags; "distance" presets to --prune.<segment>.distance.

type ChainEntry added in v0.5.0

type ChainEntry struct {
	Name    string `json:"name"`
	Chain   string `json:"chain"`
	ChainID int    `json:"chainId"`
	RPC     []any  `json:"rpc"` // mix of strings and objects
}

ChainEntry represents a single chain entry from the ChainList API.

type ChainListFetcher added in v0.5.0

type ChainListFetcher func() ([]byte, error)

ChainListFetcher abstracts the HTTP fetch so tests can inject fixtures.

type Hardfork added in v0.10.0

type Hardfork struct {
	// Name is the canonical EL fork name used by --since=<name>.
	Name string
	// DisplayName is shown in the interactive picker.
	DisplayName string
	// Block is the first execution block at or after the fork activation.
	Block uint64
	// Date is the activation date, used only for picker labels.
	Date string
	// ApproxArchiveSizeTB is a rough estimate of mainnet archive disk usage
	// when pruning state history before this block (reth). Used in picker
	// labels so users have a realistic expectation. Values rounded.
	ApproxArchiveSizeTB float64
}

Hardfork describes a mainnet hardfork activation point used by the partial-archive picker. All block numbers are verified for Ethereum mainnet — paris from the reth chainspec source, post-merge forks from the beacon API by computing slot = (fork_ts - beacon_genesis) / 12 and reading execution_payload.block_number from the canonical block at (or shortly after) that slot.

Verified 2026-05-27 against:

  • reth v2.2.0 crates/chainspec/src/spec.rs (paris)
  • go-ethereum params/config.go (post-merge fork timestamps)
  • ethereum-beacon-api.publicnode.com (slot → execution block lookups)

func HardforkByName added in v0.10.0

func HardforkByName(name string) *Hardfork

HardforkByName returns the hardfork with the given name, or nil.

type RPCEndpoint added in v0.5.0

type RPCEndpoint struct {
	URL      string `json:"url"`
	Tracking string `json:"tracking"` // "none", "limited", or "yes"
}

RPCEndpoint represents a single RPC endpoint from ChainList.

func FetchChainListRPCs added in v0.5.0

func FetchChainListRPCs(chainID int, fetcher ChainListFetcher) ([]RPCEndpoint, string, error)

FetchChainListRPCs fetches RPCs for a given chain ID from ChainList, filters for free/public HTTPS endpoints, and returns up to maxRPCs sorted by quality (tracking=none preferred over tracking=limited).

func FilterFreeRPCs added in v0.5.0

func FilterFreeRPCs(endpoints []RPCEndpoint) []RPCEndpoint

FilterFreeRPCs filters RPC endpoints to only include free, HTTPS, non-tracking endpoints.

func ParseAndFilterRPCs added in v0.5.0

func ParseAndFilterRPCs(data []byte, chainID, maxRPCs int) ([]RPCEndpoint, string, error)

ParseAndFilterRPCs parses ChainList JSON, finds the chain, filters and sorts RPCs. Exported for testing.

type RPCNetworkInfo added in v0.5.0

type RPCNetworkInfo struct {
	ChainID   int
	Alias     string
	Upstreams []RPCUpstreamInfo
}

RPCNetworkInfo represents a network (chain) configured in eRPC.

func ListRPCNetworks added in v0.5.0

func ListRPCNetworks(cfg *config.Config) ([]RPCNetworkInfo, error)

ListRPCNetworks reads the eRPC ConfigMap and returns configured networks with their upstreams.

type RPCUpstreamInfo added in v0.5.0

type RPCUpstreamInfo struct {
	ID       string
	Endpoint string
	ChainID  int
}

RPCUpstreamInfo represents an upstream in the eRPC config for display.

type RecordedChain added in v0.10.0

type RecordedChain struct {
	Name      string             `yaml:"name"`
	Chainlist *RecordedChainlist `yaml:"chainlist,omitempty"`
	Custom    *RecordedCustom    `yaml:"custom,omitempty"`
}

RecordedChain holds the recorded upstream intent for one chain.

type RecordedChainlist added in v0.10.0

type RecordedChainlist struct {
	ReadOnly  bool          `yaml:"readOnly"`
	Endpoints []RPCEndpoint `yaml:"endpoints"`
}

RecordedChainlist snapshots the ChainList endpoints selected at add time, so replay is deterministic and offline (no re-fetch of chainlist.org).

type RecordedCustom added in v0.10.0

type RecordedCustom struct {
	Endpoint string `yaml:"endpoint"`
	ReadOnly bool   `yaml:"readOnly"`
}

RecordedCustom is a `network add --endpoint` upstream.

type RecordedRPCs added in v0.10.0

type RecordedRPCs struct {
	Version int                       `yaml:"version"`
	Chains  map[string]*RecordedChain `yaml:"chains"` // key: decimal chain ID
}

RecordedRPCs is the host-side record of operator-added remote upstreams.

type TemplateField

type TemplateField struct {
	Name         string
	DefaultValue string
	FlagName     string   // CLI flag name derived from field name
	Description  string   // Human-readable description from @description
	EnumValues   []string // Valid enum values from @enum
	Required     bool     // Whether this field is required (no default value)
}

TemplateField represents a template field with its configuration

func ParseTemplateFields

func ParseTemplateFields(networkName string) ([]TemplateField, error)

ParseTemplateFields extracts template fields from an embedded network values file Uses Go template parsing to identify field references and their annotations

Jump to

Keyboard shortcuts

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