chains

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: BSD-3-Clause Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allychain added in v0.1.5

type Allychain interface {
	common.Allychain
	// contains filtered or unexported methods
}

Allychain keeps track of the currently bootstrapping chains in a allychain. If no chains in the allychain are currently bootstrapping, the allychain is considered bootstrapped.

type AllychainConfig added in v0.1.5

type AllychainConfig struct {
	sender.GossipConfig

	// ValidatorOnly indicates that this Allychain's Chains are available to only allychain validators.
	ValidatorOnly       bool            `json:"validatorOnly"`
	ConsensusParameters axia.Parameters `json:"consensusParameters"`
}

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 allychain that validates this chain.
	AllychainID ids.ID
	// The genesis data of this chain's ledger.
	GenesisData []byte
	// The ID of the vm this chain is running.
	VMAlias string
	// The IDs of the feature extensions this chain is running.
	FxAliases []string
	// Should only be set if the default beacons can't be used.
	CustomBeacons validators.Set
}

ChainParameters defines the chain being created

type Manager

type Manager interface {
	ids.Aliaser

	// Return the router this Manager is using to route consensus messages to chains
	Router() router.Router

	// Create a chain in the future
	CreateChain(ChainParameters)

	// Create a chain now
	ForceCreateChain(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 the ID of the allychain that is validating the provided chain
	AllychainID(chainID ids.ID) (ids.ID, error)

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

	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

func New

func New(config *ManagerConfig) Manager

New returns a new Manager

type ManagerConfig

type ManagerConfig struct {
	StakingEnabled              bool            // True iff the network has staking enabled
	StakingCert                 tls.Certificate // needed to sign snowman++ blocks
	Log                         logging.Logger
	LogFactory                  logging.Factory
	VMManager                   vms.Manager // Manage mappings from vm ID --> vm
	DecisionAcceptorGroup       snow.AcceptorGroup
	ConsensusAcceptorGroup      snow.AcceptorGroup
	DBManager                   dbManager.Manager
	MsgCreator                  message.Creator    // message creator, shared with network
	Router                      router.Router      // Routes incoming messages to the appropriate chain
	Net                         network.Network    // Sends consensus messages to other validators
	ConsensusParams             avcon.Parameters   // The consensus parameters (alpha, beta, etc.) for new chains
	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
	Server                      server.Server      // Handles HTTP API calls
	Keystore                    keystore.Keystore
	AtomicMemory                *atomic.Memory
	AXCAssetID                  ids.ID
	SwapChainID                 ids.ID
	CriticalChains              ids.Set         // Chains that can't exit gracefully
	WhitelistedAllychains       ids.Set         // Allychains to validate
	TimeoutManager              timeout.Manager // Manages request timeouts when sending messages to other validators
	Health                      health.Registerer
	RetryBootstrap              bool                       // Should Bootstrap be retried
	RetryBootstrapWarnFrequency int                        // Max number of times to retry bootstrap before warning the node operator
	AllychainConfigs            map[ids.ID]AllychainConfig // ID -> AllychainConfig
	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

	ConsensusGossipFrequency time.Duration

	GossipConfig sender.GossipConfig

	// 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
	ApricotPhase4MinCoreChainHeight uint64

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

	StateSyncBeacons         []ids.NodeID
	StateSyncDisableRequests bool
}

type MockManager

type MockManager struct{}

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

func (MockManager) AddRegistrant

func (mm MockManager) AddRegistrant(Registrant)

func (MockManager) Alias

func (mm MockManager) Alias(ids.ID, string) error

func (MockManager) Aliases

func (mm MockManager) Aliases(ids.ID) ([]string, error)

func (MockManager) AllychainID added in v0.1.5

func (mm MockManager) AllychainID(ids.ID) (ids.ID, error)

func (MockManager) CreateChain

func (mm MockManager) CreateChain(ChainParameters)

func (MockManager) ForceCreateChain

func (mm MockManager) ForceCreateChain(ChainParameters)

func (MockManager) IsBootstrapped

func (mm MockManager) IsBootstrapped(ids.ID) bool

func (MockManager) Lookup

func (mm MockManager) Lookup(s string) (ids.ID, error)

func (MockManager) LookupVM

func (mm MockManager) LookupVM(s string) (ids.ID, error)

func (MockManager) PrimaryAlias

func (mm MockManager) PrimaryAlias(ids.ID) (string, error)

func (MockManager) PrimaryAliasOrDefault

func (mm MockManager) PrimaryAliasOrDefault(ids.ID) string

func (MockManager) RemoveAliases

func (mm MockManager) RemoveAliases(ids.ID)

func (MockManager) Router

func (mm MockManager) Router() router.Router

func (MockManager) Shutdown

func (mm MockManager) Shutdown()

type Registrant

type Registrant interface {
	// Called when the chain described by [engine] is created
	// This function is called before the chain starts processing messages
	// [engine] should be an axia.Engine or snowman.Engine
	RegisterChain(name string, engine common.Engine)
}

Registrant can register the existence of a chain

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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