build

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package build holds network-wide constants and configuration: the genesis CID, DRAND chain configuration, and the F3 network manifest references.

Values here are copied from github.com/filecoin-project/lotus/build at commit a0ecb8687f1c60d5e66040b6de364dbc9cc4d253 and adapted where the Lantern light-client scope diverges. See LICENSE.

Index

Constants

View Source
const BlockDelaySecs = uint64(30)

BlockDelaySecs is the target seconds between epochs. Upstream: build/buildconstants/params_shared_vals.go

View Source
const BlockGasLimit = int64(10_000_000_000)

BlockGasLimit is the per-block gas budget. Used by types.Message.ValidForBlockInclusion. Upstream: build/buildconstants/params_shared_vals.go

View Source
const BlocksPerEpoch = uint64(5)

BlocksPerEpoch is the expected number of block producers per epoch. Upstream: build/buildconstants/params_shared_vals.go

var BlocksPerEpoch = uint64(builtin2.ExpectedLeadersPerEpoch) // == 5
View Source
const CalibnetGenesisCID = "bafy2bzacecyaggy24wol5ruvs6qm73gjibs2l2iyhcqmvi7r7a4ph7zx3yqd4"

CalibnetGenesisCID is the CID of block 0 of Filecoin calibration, returned by Filecoin.ChainGetGenesis on any healthy calibration node. Used by the /fil/hello/1.0.0 protocol to identify our network to peers: nodes on different chains close the Hello stream on genesis mismatch.

Source: queried Filecoin.ChainGetGenesis against api.calibration.node.glif.io on 2026-05-23.

View Source
const CalibnetGenesisUnix = 1667326380

CalibnetGenesisUnix is the unix timestamp of the current calibration network's epoch 0 (2022-11-01 18:13:00 UTC, the post-reset genesis).

View Source
const CalibnetGossipTopicBlocks = "/fil/blocks/calibrationnet"

CalibnetGossipTopicBlocks is the calibration block topic.

View Source
const CalibnetGossipTopicMessages = "/fil/msgs/calibrationnet"

CalibnetGossipTopicMessages is the calibration message-pool gossipsub topic. Unlike mainnet's literal "testnetnet" wire-name, calibration uses its own network name in the topic path.

View Source
const CalibnetNetworkName = "calibrationnet"

CalibnetNetworkName is the wire-name string Filecoin libp2p protocols expect on calibration. Confirmed via Filecoin.StateNetworkName against api.calibration.node.glif.io on 2026-05-23.

View Source
const DefaultNetwork = Mainnet

DefaultNetwork is what Lantern targets when no --network flag is passed. Mainnet, preserving V1.2.1 behavior.

View Source
const FilBase = uint64(2_000_000_000)

FilBase is the total FIL supply in whole-FIL units. Upstream: build/buildconstants/params_shared_vals.go

View Source
const FilecoinPrecision = uint64(1_000_000_000_000_000_000)

FilecoinPrecision is the number of attoFIL per whole FIL. Upstream: build/buildconstants/params_shared_vals.go

View Source
const MainnetGenesisCID = "bafy2bzacecnamqgqmifpluoeldx7zzglxcljo6oja4vrmtj7432rphldpdmm2"

MainnetGenesisCID is the CID of block 0 of Filecoin mainnet, returned by Filecoin.ChainGetGenesis on any healthy node. Used by the /fil/hello/1.0.0 protocol (issue #16) to identify our network to peers: nodes on different chains close the Hello stream on genesis mismatch.

Source: queried Filecoin.ChainGetGenesis against api.node.glif.io, 2026-05-22; matches the Lotus mainnet GenesisFile.

View Source
const MainnetGenesisUnix = 1598306400

MainnetGenesisUnix is the unix timestamp of mainnet epoch 0 (2020-08-24 22:00:00 UTC).

View Source
const MainnetGossipTopicBlocks = "/fil/blocks/testnetnet"

MainnetGossipTopicBlocks is the canonical block topic.

View Source
const MainnetGossipTopicMessages = "/fil/msgs/testnetnet"

MainnetGossipTopicMessages is the mainnet message-pool gossipsub topic. Yes, the topic name is literally "testnetnet" for historical reasons: Filecoin's network name was "testnetnet" before the mainnet rebrand and the topic name was never changed, to preserve backward compatibility. Source: lotus/build/buildconstants/params_mainnet.go (NetworkBundle).

View Source
const MainnetNetworkName = "testnetnet"

MainnetNetworkName is the wire-name string Filecoin libp2p protocols expect.

View Source
const MaxBlockGas = BlockGasLimit

MaxBlockGas is the per-block gas budget (alias for BlockGasLimit), kept separate so callers reading `vm/gas.go` semantics don't have to know the Lotus build constant.

View Source
const MaxDynamicBeaconPeers = 16

MaxDynamicBeaconPeers caps how many DHT-discovered (untrusted-origin) beacon peers are kept in the cert-exchange rotation (security #59 anti-eclipse). Bounding the dynamic pool means a rendezvous flood can crowd the rotation only up to this ceiling; the trusted floor + operator pins always sit ahead of them and are never evicted.

View Source
const MinimumBaseFee = int64(100)

MinimumBaseFee is the floor base fee in attoFIL. Upstream: build/buildconstants/params_shared_vals.go (== 100 attoFIL).

Variables

View Source
var CalibnetBootstrapPeers = []string{
	"/dns/bootstrap.calibration.filecoin.chain.love/tcp/1237/p2p/12D3KooWQPYouEAsUQKzvFUA9sQ8tz4rfpqtTzh2eL6USd9bwg7x",
	"/dns/bootstrap-calibnet-0.chainsafe-fil.io/tcp/34000/p2p/12D3KooWABQ5gTDHPWyvhJM7jPhtNwNJruzTEo32Lo4gcS5ABAMm",
	"/dns/bootstrap-calibnet-1.chainsafe-fil.io/tcp/34000/p2p/12D3KooWS3ZRhMYL67b4bD5XQ6fcpTyVQXnDe8H89LvwrDqaSbiT",
	"/dns/bootstrap-calibnet-2.chainsafe-fil.io/tcp/34000/p2p/12D3KooWEiBN8jBX8EBoM3M47pVRLRWV812gDRUJhMxgyVkUoR48",
}

CalibnetBootstrapPeers is the canonical calibration bootstrap multiaddr list.

View Source
var DefaultBeaconPeers = map[Network][]string{

	Mainnet:     {},
	Calibration: {},
}

DefaultBeaconPeers is the built-in, trusted Lantern cert-exchange beacon floor (security #59). A fresh node seeds its cert-exchange peer set from this list BEFORE DHT rendezvous discovery warms, so it always has an honest source of F3 finality certs and cannot be fully eclipsed by an attacker who floods the rendezvous point with hostile peers.

F3 certs from any peer are still BLS-aggregate-verified downstream, so a hostile peer cannot forge a cert; the threat this floor mitigates is *eclipse / availability* — being crowded out of honest cert sources and thereby stalled in finality observation. Operators can extend the floor with --certexch-peers.

Entries are full multiaddrs including /p2p/<peerid>. Keep this list small and operator-trustworthy; it is a trust anchor.

View Source
var DrandConfigs = map[DrandNetwork]DrandChainInfo{
	DrandQuicknet: {
		IsChained:     false,
		ChainInfoJSON: `{"public_key":"83cf0f2896adee7eb8b5f01fcad3912212c437e0073e911fb90022d3e760183c8c4b450b6a0a6c3ac6a5776a2d1064510d1fec758c921cc22b0e17e63aaf4bcb5ed66304de9cf809bd274ca73bab4af5a6e9c76a4bc09e76eae8991ef5ece45a","period":3,"genesis_time":1692803367,"hash":"52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971","groupHash":"f477d5c89f21a17c863a7f937c6a6d15859414d2be09cd448d4279af331c5d3e","schemeID":"bls-unchained-g1-rfc9380","metadata":{"beaconID":"quicknet"}}`,
	},
	DrandTestnet: {
		IsChained:     true,
		ChainInfoJSON: `{"public_key":"922a2e93828ff83345bae533f5172669a26c02dc76d6bf59c80892e12ab1455c229211886f35bb56af6d5bea981024df","period":25,"genesis_time":1590445175,"hash":"84b2234fb34e835dccd048255d7ad3194b81af7d978c3bf157e3469592ae4e02","groupHash":"4dd408e5fdff9323c76a9b6f087ba8fdc5a6da907bd9217d9d10f2287d081957"}`,
	},
	DrandIncentinet: {
		IsChained:     true,
		ChainInfoJSON: `{"public_key":"8cad0c72c606ab27d36ee06de1d5b2db1faf92e447025ca37575ab3a8aac2eaae83192f846fc9e158bc738423753d000","period":30,"genesis_time":1595873820,"hash":"80c8b872c714f4c00fdd3daa465d5514049f457f01f85a4caf68cdcd394ba039","groupHash":"d9406aaed487f7af71851b4399448e311f2328923d454e971536c05398ce2d9b"}`,
	},
	DrandMainnet: {
		IsChained:     true,
		ChainInfoJSON: `{"public_key":"868f005eb8e6e4ca0a47c8a77ceaa5309a47978a7c71bc5cce96366b5d7a569937c529eeda66c7293784a9402801af31","period":30,"genesis_time":1595431050,"hash":"8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce","groupHash":"176f93498eac9ca337150b46d21dd58673ea4e3581185f869672e59fa4cb390a"}`,
	},
}

DrandConfigs holds the chain-info blobs for every drand network Filecoin has trusted. Verbatim from buildconstants.DrandConfigs.

View Source
var F3ManifestCalibnetJSON []byte
View Source
var F3ManifestMainnetJSON []byte
View Source
var MainnetBootstrapPeers = []string{
	"/dns/bootstrap.filecoin.chain.love/tcp/1235/p2p/12D3KooWBF8cpp65hp2u9LK5mh19x67ftAam84z9LsfaquTDSBpt",
	"/dns/bootstrap-venus.mainnet.filincubator.com/tcp/8888/p2p/QmQu8C6deXwKvJP2D8B6QGyhngc3ZiDnFzEHBDx8yeBXST",
	"/dns/bootstrap-mainnet-0.chainsafe-fil.io/tcp/34000/p2p/12D3KooWKKkCZbcigsWTEu1cgNetNbZJqeNtysRtFpq7DTqw3eqH",
	"/dns/bootstrap-mainnet-1.chainsafe-fil.io/tcp/34000/p2p/12D3KooWGnkd9GQKo3apkShQDaq1d6cKJJmsVe6KiQkacUk1T8oZ",
	"/dns/bootstrap-mainnet-2.chainsafe-fil.io/tcp/34000/p2p/12D3KooWHQRSDFv4FvAjtU32shQ7znz7oRbLBryXzZ9NMK2feyyH",
	"/dns/n1.mainnet.fil.devtty.eu/udp/443/quic-v1/p2p/12D3KooWAke3M2ji7tGNKx3BQkTHCyxVhtV1CN68z6Fkrpmfr37F",
	"/dns/n1.mainnet.fil.devtty.eu/tcp/443/p2p/12D3KooWAke3M2ji7tGNKx3BQkTHCyxVhtV1CN68z6Fkrpmfr37F",
}

MainnetBootstrapPeers is the canonical bootstrap multiaddr list.

View Source
var ZeroAddress = mustParseAddress("f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a")

ZeroAddress is the Filecoin BLS zero address. Upstream: build/buildconstants/params_shared_vals.go

Functions

func ConfigureDevnet

func ConfigureDevnet(cfg *DevnetConfig)

ConfigureDevnet installs a devnet runtime config. Called from cmd/lantern before any daemon subsystem asks Network methods for devnet values. Subsequent calls overwrite the previous config (useful in tests). Nil config clears it.

func IsDevnetConfigured

func IsDevnetConfigured() bool

IsDevnetConfigured reports whether ConfigureDevnet has been called with a non-nil config in this process.

func SaveDevnetConfig

func SaveDevnetConfig(path string, cfg *DevnetConfig) error

SaveDevnetConfig writes cfg to path atomically (tmp file + rename). Creates the parent directory if it doesn't exist.

Types

type DevnetConfig

type DevnetConfig struct {
	// NetworkName is the wire-name string libp2p protocols expect
	// (gossipsub topics, DHT prefix). Comes from
	// Filecoin.StateNetworkName on the devnet lotus.
	NetworkName string `json:"networkName"`

	// GenesisCID is the CID of block 0. Comes from
	// Filecoin.ChainGetGenesis on the devnet lotus. Used by the
	// /fil/hello/1.0.0 handshake so peers on the same devnet
	// authenticate.
	GenesisCID string `json:"genesisCID"`

	// LotusRPC is the JSON-RPC URL of the devnet lotus (used by
	// `lantern devnet-init` to fetch this config, and later by the
	// daemon as a fallback head source when there is no gossipsub
	// mesh — a single-node devnet stays reachable this way).
	LotusRPC string `json:"lotusRPC"`

	// BootstrapPeers is the list of libp2p multiaddrs the daemon
	// dials on startup. For the curio-fork docker devnet, this is
	// typically empty (single-cluster; lotus discovers itself) or
	// contains the docker-network lotus multiaddr.
	BootstrapPeers []string `json:"bootstrapPeers,omitempty"`

	// GenesisTime is the wall-clock time of block 0 (unix seconds).
	// Optional; if set, it lets the daemon compute anchor age
	// without a chain read. Comes from ChainGetGenesis's Blocks[0].Timestamp.
	GenesisTime uint64 `json:"genesisTime,omitempty"`

	// BlockDelaySecs is the block time (default 4s for the
	// //go:build 2k curio devnet; mainnet is 30s). Optional; the
	// daemon uses build.BlockDelaySecs as fallback.
	BlockDelaySecs uint64 `json:"blockDelaySecs,omitempty"`

	// EthChainID is the EIP-155 chain identifier the devnet lotus
	// reports via eth_chainId. Comes from eth_chainId on the devnet
	// lotus at devnet-init time. Devnet lotus uses this to scope
	// signatures + reject cross-chain replays. The curio-fork docker
	// devnet defaults to 31415926 (0x1df5e76); custom setups may pick
	// different values. Optional (older configs may lack the field);
	// when missing, callers should re-run `lantern devnet-init --force`.
	EthChainID uint64 `json:"ethChainID,omitempty"`

	// NetworkVersion is the Filecoin network version the devnet reports
	// (Filecoin.StateNetworkVersion). Used with ActorCodeCIDs to register
	// the devnet's custom actor bundle into Lantern's decoder registry at
	// the correct actors version. Optional (older configs lack it).
	NetworkVersion uint64 `json:"networkVersion,omitempty"`

	// ActorCodeCIDs is the devnet's actor-name -> code-CID map
	// (Filecoin.StateActorCodeCIDs). A debug-compiled devnet ships code
	// CIDs that are in no released builtin-actors bundle, so Lantern's
	// registry can't decode devnet actor state without them. Recording
	// them here lets the daemon register the bundle at startup and decode
	// devnet state (StateMinerPower, StateMinerInfo, ...). CIDs are stored
	// as strings for JSON stability. Optional (older configs lack it);
	// re-run `lantern devnet-init --force` to populate.
	ActorCodeCIDs map[string]string `json:"actorCodeCIDs,omitempty"`
}

DevnetConfig is the runtime identity of a Lantern-visible devnet. All fields are required except LotusRPC (which is used as an anchor + head source but not baked into the daemon's steady-state operation).

func GetDevnetConfig

func GetDevnetConfig() *DevnetConfig

GetDevnetConfig returns the current devnet config or nil when unconfigured. Callers on the devnet hot path should use the convenience getters below (they panic-with-help when unconfigured).

func LoadDevnetConfig

func LoadDevnetConfig(path string) (*DevnetConfig, error)

LoadDevnetConfig reads a JSON-encoded DevnetConfig from disk. Returns (nil, nil) when the file doesn't exist so cold-boot code can detect "operator hasn't run devnet-init yet" cleanly.

type DrandChainInfo

type DrandChainInfo struct {
	ChainInfoJSON string
	IsChained     bool
}

DrandChainInfo is the static configuration for one drand network: the chain-info JSON blob (carries the group public key, scheme ID and chain hash) and whether the chain operates in chained mode.

type DrandNetwork

type DrandNetwork int

DrandNetwork identifies one of the drand networks Filecoin has trusted over its lifetime.

const (
	DrandMainnet DrandNetwork = iota + 1 // legacy league-of-entropy chained chain
	DrandTestnet

	DrandIncentinet // legacy incentinet chain
	DrandQuicknet   // post-FIP-0063 unchained chain
)

type Network

type Network string

Network selects which Filecoin network Lantern targets.

const (
	// Mainnet is the default — Filecoin mainnet. Wire-name "testnetnet"
	// (historical from pre-rebrand). DRAND chain switches: started on
	// chained DrandMainnet, post-FIP-0063 uses unchained DrandQuicknet.
	Mainnet Network = "mainnet"

	// Calibration is Filecoin's public test network. Wire-name
	// "calibrationnet". DRAND chain: Quicknet only (Calibration was
	// launched post-FIP-0063).
	Calibration Network = "calibration"

	// Devnet targets a locally-hosted Curio devnet (curio-fork/docker,
	// `make devnet/up`). The wire-name, genesis CID, gossip topics, and
	// bootstrap peers are supplied at runtime via ConfigureDevnet (see
	// build/devnet.go), populated by `lantern devnet-init --lotus-rpc
	// <URL>`. Trust posture: single-source (the operator's own lotus);
	// F3 is not required.
	Devnet Network = "devnet"
)

func (Network) BeaconPeers

func (n Network) BeaconPeers() []string

BeaconPeers returns the default trusted beacon floor for the network.

func (Network) BitswapProtocolPrefix

func (n Network) BitswapProtocolPrefix() string

BitswapProtocolPrefix returns the libp2p protocol-ID prefix Filecoin nodes serve bitswap under. Lotus and Forest both namespace bitswap as "/chain/ipfs/bitswap/...", NOT the boxo/IPFS default "/ipfs/bitswap/...". This is the bitswap analogue of the "/fil/kad/<net>" DHT prefix: a client using the IPFS default connects but can never exchange blocks with the Filecoin swarm. The prefix is the same across networks (mainnet + calibration). lantern#50.

func (Network) BootstrapPeers

func (n Network) BootstrapPeers() []string

BootstrapPeers returns the libp2p multiaddr list Lantern dials on startup to enter the DHT + gossipsub mesh for the selected network.

func (Network) ExpectedHeadEpoch

func (n Network) ExpectedHeadEpoch(nowUnix int64) int64

ExpectedHeadEpoch returns the epoch the network head should be at for the given unix time, or -1 when the genesis time is unknown. The answer is exact for a healthy chain (Filecoin epochs are wall-clock scheduled); real heads trail it by at most a few epochs.

func (Network) F3Manifest

func (n Network) F3Manifest() []byte

F3Manifest returns the embedded F3 network-manifest JSON for the selected network. The manifest carries the F3 NetworkName, BootstrapEpoch, InitialPowerTable, and gpbft parameters that the F3 cert-chain verifier uses as its trust anchor.

func (Network) GenesisCID

func (n Network) GenesisCID() string

GenesisCID returns the CID of block 0 for the selected network. Used by the /fil/hello/1.0.0 handshake to identify which chain a peer is on.

func (Network) GenesisUnix

func (n Network) GenesisUnix() int64

GenesisUnix returns the wall-clock unix timestamp of epoch 0 for the selected network, or 0 when unknown (unconfigured devnet). Used for wall-clock sanity checks on bootstrap anchors: expected head epoch ≈ (now - genesis) / BlockDelaySecs.

func (Network) GossipTopicBlocks

func (n Network) GossipTopicBlocks() string

GossipTopicBlocks returns the block gossipsub topic name for the selected network.

func (Network) GossipTopicMessages

func (n Network) GossipTopicMessages() string

GossipTopicMessages returns the message-pool gossipsub topic name for the selected network.

func (Network) NetworkName

func (n Network) NetworkName() string

NetworkName returns the wire-name string Filecoin libp2p protocols (DHT prefix, gossipsub topics) expect for the selected network. Mainnet returns "testnetnet" for historical reasons; calibration returns "calibrationnet".

func (Network) String

func (n Network) String() string

String returns the canonical network identifier.

func (Network) Valid

func (n Network) Valid() bool

Valid reports whether n is a recognized network identifier.

Jump to

Keyboard shortcuts

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