Documentation
¶
Index ¶
- Constants
- Variables
- func NewLinearizeOnInitializeVM(vm consensusvertex.LinearizableVMWithEngine, toEngine chan<- block.Message) *linearizeOnInitializeVM
- type ChainConfig
- type ChainDBManager
- func (m *ChainDBManager) Close() error
- func (m *ChainDBManager) GetAllChainIDs() []ids.ID
- func (m *ChainDBManager) GetDatabase(chainID ids.ID, chainAlias string) (database.Database, error)
- func (m *ChainDBManager) GetDatabasePrefix(chainID ids.ID) []byte
- func (m *ChainDBManager) GetGlobalDB() database.Database
- func (m *ChainDBManager) GetVMDatabase(chainID ids.ID, chainAlias string) (database.Database, error)
- type ChainDBManagerConfig
- type ChainParameters
- type ChainRouter
- type Engine
- type Manager
- type ManagerConfig
- type Nets
- type Registrant
Constants ¶
const (
ChainLabel = "chain"
)
Variables ¶
var ( // corely 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") )
var ErrNoPrimaryNetworkConfig = errors.New("no net config for primary network found")
var ( // ErrSkipped is returned when a linearizable VM is asked to perform // chain VM operations ErrSkipped = errors.New("skipped") )
Functions ¶
func NewLinearizeOnInitializeVM ¶ added in v0.1.1
func NewLinearizeOnInitializeVM(vm consensusvertex.LinearizableVMWithEngine, toEngine chan<- block.Message) *linearizeOnInitializeVM
Types ¶
type ChainConfig ¶ added in v0.1.1
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 ChainDBManager ¶ added in v1.16.56
type ChainDBManager struct {
// contains filtered or unexported fields
}
ChainDBManager manages chain database access using a single global BadgerDB. All chains share one BadgerDB instance with prefix-based isolation: 1. Single database - easier to manage, backup, and query across chains 2. Prefix isolation - each chain's data is prefixed by its chainID 3. G-Chain compatible - dgraph can index the entire database for GraphQL queries
func NewChainDBManager ¶ added in v1.16.56
func NewChainDBManager(config ChainDBManagerConfig) *ChainDBManager
NewChainDBManager creates a new chain database manager using a single global BadgerDB
func (*ChainDBManager) Close ¶ added in v1.16.56
func (m *ChainDBManager) Close() error
Close is a no-op since the global database lifecycle is managed elsewhere. Chain-specific prefixed databases don't need to be closed separately.
func (*ChainDBManager) GetAllChainIDs ¶ added in v1.16.56
func (m *ChainDBManager) GetAllChainIDs() []ids.ID
GetAllChainIDs returns all chain IDs that have databases allocated. Useful for G-Chain to enumerate chains for indexing.
func (*ChainDBManager) GetDatabase ¶ added in v1.16.56
GetDatabase returns a prefixed database for the given chain. Uses prefix-based isolation on the single global BadgerDB.
func (*ChainDBManager) GetDatabasePrefix ¶ added in v1.16.56
func (m *ChainDBManager) GetDatabasePrefix(chainID ids.ID) []byte
GetDatabasePrefix returns the prefix used for a chain's data. This is the chainID bytes, which can be used by G-Chain to iterate chain data.
func (*ChainDBManager) GetGlobalDB ¶ added in v1.16.56
func (m *ChainDBManager) GetGlobalDB() database.Database
GetGlobalDB returns the underlying global database. This is useful for G-Chain (dgraph-powered GraphQL VM) to query across all chains.
func (*ChainDBManager) GetVMDatabase ¶ added in v1.16.56
func (m *ChainDBManager) GetVMDatabase(chainID ids.ID, chainAlias string) (database.Database, error)
GetVMDatabase returns a VM-prefixed database for the given chain. Adds a "vm" prefix within the chain's prefix for VM-specific data.
type ChainDBManagerConfig ¶ added in v1.16.56
type ChainDBManagerConfig struct {
// DB is the global shared database (BadgerDB)
DB database.Database
Log log.Logger
}
ChainDBManagerConfig holds configuration for the chain database manager
type ChainParameters ¶
type ChainParameters struct {
// The ID of the blockchain being created.
ID ids.ID
// ID of the chain that validates this blockchain.
ChainID ids.ID
// The genesis data of this blockchain's ledger.
GenesisData []byte
// The ID of the vm this blockchain is running.
VMID ids.ID
// The IDs of the feature extensions this blockchain is running.
FxIDs []ids.ID
// Invariant: Only used when [ID] is the P-chain ID.
CustomBeacons validators.Manager
// Name of the chain (used for HTTP routing alias, e.g., /ext/bc/zoo/rpc)
Name string
}
ChainParameters defines the chain being created
type ChainRouter ¶ added in v1.16.56
type ChainRouter interface {
AddChain(ctx context.Context, chainID ids.ID, handler handler.Handler)
}
ChainRouter is the interface for routing messages to chains. This is defined here to avoid circular imports with the node package.
type Engine ¶ added in v1.11.14
type Engine interface {
Start(context.Context, bool) error
StopWithError(context.Context, error) error
Context() context.Context
}
Engine represents a consensus engine
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 subnets 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
type ManagerConfig ¶ added in v0.1.1
type ManagerConfig struct {
SybilProtectionEnabled bool
StakingTLSSigner crypto.Signer
StakingTLSCert *staking.Certificate
StakingBLSKey bls.Signer
TracingEnabled bool
// Must not be used unless [TracingEnabled] is true as this may be nil.
Tracer trace.Tracer
Log log.Logger
LogFactory log.Factory
VMManager vms.Manager // Manage mappings from vm ID --> vm
BlockAcceptorGroup nodeconsensus.AcceptorGroup
TxAcceptorGroup nodeconsensus.AcceptorGroup
VertexAcceptorGroup nodeconsensus.AcceptorGroup
DB database.Database
MsgCreator message.OutboundMsgBuilder // message creator, shared with network
Router ChainRouter // 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
AtomicMemory *atomic.Memory
XAssetID ids.ID
SkipBootstrap bool // Skip bootstrapping and start processing immediately
EnableAutomining bool // Enable automining in POA mode
XChainID ids.ID // ID of the X-Chain,
CChainID 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
NetConfigs map[ids.ID]nets.Config // ID -> NetConfig
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 metric.MultiGatherer
MeterDBMetrics metric.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
Upgrades upgrade.Config
// Tracks CPU/disk usage caused by each peer.
ResourceTracker timetracker.ResourceTracker
StateSyncBeacons []ids.NodeID
ChainDataDir string
Nets *Nets
}
type Nets ¶ added in v1.16.56
type Nets struct {
// contains filtered or unexported fields
}
Nets holds the currently running subnets on this node
func (*Nets) Bootstrapping ¶ added in v1.16.56
Bootstrapping returns the netIDs of any chains that are still bootstrapping.
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 *consensus.Context, vm interfaces.VM)
}
Registrant can register the existence of a chain
func NewRegistrantAdapter ¶ added in v1.11.14
func NewRegistrantAdapter(s server.Server) Registrant
NewRegistrantAdapter creates an adapter that allows Server to be used as chains.Registrant
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package atomic is a generated GoMock package.
|
Package atomic is a generated GoMock package. |
|
atomicmock
Package atomicmock is a generated GoMock package.
|
Package atomicmock is a generated GoMock package. |
|
Package rpc provides robust RPC handler registration with retries, health checks, and clear debugging.
|
Package rpc provides robust RPC handler registration with retries, health checks, and clear debugging. |