chains

package
v0.0.0-...-6519026 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: BSD-3-Clause Imports: 64 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Commonly shared VM DB prefix
	VMDBPrefix = []byte("vm")

	// Bootstrapping prefixes for LinearizableVMs
	VertexDBPrefix              = []byte("vertex")
	VertexBootstrappingDBPrefix = []byte("vertex_bs")
	TxBootstrappingDBPrefix     = []byte("tx_bs")
	BlockBootstrappingDBPrefix  = []byte("interval_block_bs")

	// Bootstrapping prefixes for ChainVMs
	ChainBootstrappingDBPrefix = []byte("interval_bs")
)
View Source
var ErrNoPrimaryNetworkConfig = errors.New("no supernet config for primary network found")

Functions

func NewLinearizeOnInitializeVM

func NewLinearizeOnInitializeVM(vm vertex.LinearizableVMWithEngine) *linearizeOnInitializeVM

Types

type ChainConfig

type ChainConfig struct {
	Config  []byte
	Upgrade []byte
}

ChainConfig is configuration settings for the current execution. [Config] is the user-provided config blob for the chain. [Upgrade] is a chain-specific blob for coordinating upgrades.

type ChainParameters

type ChainParameters struct {
	// The ID of the chain being created.
	ID ids.ID
	// ID of the supernet that validates this chain.
	SupernetID ids.ID
	// The genesis data of this chain's ledger.
	GenesisData []byte
	// The ID of the vm this chain is running.
	VMID ids.ID
	// The IDs of the feature extensions this chain is running.
	FxIDs []ids.ID
	// The main asset used by this chain to pay the fees.
	ChainAssetID ids.ID
	// Invariant: Only used when [ID] is the P-chain ID.
	CustomBeacons validators.Manager
}

ChainParameters defines the chain being created

type Manager

type Manager interface {
	ids.Aliaser

	// Queues a chain to be created in the future after chain creator is unblocked.
	// This is only called from the P-chain thread to create other chains
	// Queued chains are created only after P-chain is bootstrapped.
	// This assumes only chains in tracked supernets are queued.
	QueueChainCreation(ChainParameters)

	// Add a registrant [r]. Every time a chain is
	// created, [r].RegisterChain([new chain]) is called.
	AddRegistrant(Registrant)

	// Given an alias, return the ID of the chain associated with that alias
	Lookup(string) (ids.ID, error)

	// Given an alias, return the ID of the VM associated with that alias
	LookupVM(string) (ids.ID, error)

	// Returns true iff the chain with the given ID exists and is finished bootstrapping
	IsBootstrapped(ids.ID) bool

	// Starts the chain creator with the initial platform chain parameters, must
	// be called once.
	StartChainCreator(platformChain ChainParameters) error

	Shutdown()
}

Manager manages the chains running on this node. It can:

  • Create a chain
  • Add a registrant. When a chain is created, each registrant calls RegisterChain with the new chain as the argument.
  • Manage the aliases of chains
var TestManager Manager = testManager{}

TestManager implements Manager but does nothing. Always returns nil error. To be used only in tests

func New

func New(config *ManagerConfig) Manager

New returns a new Manager

type ManagerConfig

type ManagerConfig struct {
	SybilProtectionEnabled bool
	StakingTLSSigner       crypto.Signer
	StakingTLSCert         *staking.Certificate
	StakingBLSKey          *bls.SecretKey
	TracingEnabled         bool
	// Must not be used unless [TracingEnabled] is true as this may be nil.
	Tracer                    trace.Tracer
	Log                       logging.Logger
	LogFactory                logging.Factory
	VMManager                 vms.Manager // Manage mappings from vm ID --> vm
	BlockAcceptorGroup        snow.AcceptorGroup
	TxAcceptorGroup           snow.AcceptorGroup
	VertexAcceptorGroup       snow.AcceptorGroup
	DB                        database.Database
	MsgCreator                message.OutboundMsgBuilder // message creator, shared with network
	Router                    router.Router              // Routes incoming messages to the appropriate chain
	Net                       network.Network            // Sends consensus messages to other validators
	Validators                validators.Manager         // Validators validating on this chain
	NodeID                    ids.NodeID                 // The ID of this node
	NetworkID                 uint32                     // ID of the network this node is connected to
	PartialSyncPrimaryNetwork bool
	Server                    server.Server // Handles HTTP API calls
	Keystore                  keystore.Keystore
	AtomicMemory              *atomic.Memory
	JUNEAssetID               ids.ID
	JVMChainID                ids.ID          // ID of the X-Chain,
	JUNEChainID               ids.ID          // ID of the C-Chain,
	CriticalChains            set.Set[ids.ID] // Chains that can't exit gracefully
	TimeoutManager            timeout.Manager // Manages request timeouts when sending messages to other validators
	Health                    health.Registerer
	SupernetConfigs           map[ids.ID]supernets.Config // ID -> SupernetConfig
	ChainConfigs              map[string]ChainConfig      // alias -> ChainConfig
	// ShutdownNodeFunc allows the chain manager to issue a request to shutdown the node
	ShutdownNodeFunc func(exitCode int)
	MeterVMEnabled   bool // Should each VM be wrapped with a MeterVM
	Metrics          metrics.MultiGatherer

	FrontierPollFrequency   time.Duration
	ConsensusAppConcurrency int

	// Max Time to spend fetching a container and its
	// ancestors when responding to a GetAncestors
	BootstrapMaxTimeGetAncestors time.Duration
	// Max number of containers in an ancestors message sent by this node.
	BootstrapAncestorsMaxContainersSent int
	// This node will only consider the first [AncestorsMaxContainersReceived]
	// containers in an ancestors message it receives.
	BootstrapAncestorsMaxContainersReceived int

	ApricotPhase4Time            time.Time
	ApricotPhase4MinPChainHeight uint64

	// Tracks CPU/disk usage caused by each peer.
	ResourceTracker timetracker.ResourceTracker

	StateSyncBeacons []ids.NodeID

	ChainDataDir string

	Supernets *Supernets
}

type Registrant

type Registrant interface {
	// Called when a chain is created
	// This function is called before the chain starts processing messages
	// [vm] should be a vertex.DAGVM or block.ChainVM
	RegisterChain(chainName string, ctx *snow.ConsensusContext, vm common.VM)
}

Registrant can register the existence of a chain

type Supernets

type Supernets struct {
	// contains filtered or unexported fields
}

Supernets holds the currently running supernets on this node

func NewSupernets

func NewSupernets(
	nodeID ids.NodeID,
	configs map[ids.ID]supernets.Config,
) (*Supernets, error)

NewSupernets returns an instance of Supernets

func (*Supernets) Bootstrapping

func (s *Supernets) Bootstrapping() []ids.ID

Bootstrapping returns the supernetIDs of any chains that are still bootstrapping.

func (*Supernets) GetOrCreate

func (s *Supernets) GetOrCreate(supernetID ids.ID) (supernets.Supernet, bool)

GetOrCreate returns a supernet running on this node, or creates one if it was not running before. Returns the supernet and if the supernet was created.

Directories

Path Synopsis
Package atomic is a generated GoMock package.
Package atomic is a generated GoMock package.

Jump to

Keyboard shortcuts

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