Documentation
¶
Overview ¶
Package node assembles a consensus node: configuration parsing and start-up checks, profiles, the start-up handshake with the application, the node life cycle, the implementation of the Consensus service and of the RPC backend.
Index ¶
- Variables
- type Config
- type Deps
- type JournalConfig
- type MempoolConfig
- type Node
- func (n *Node) APIs() []rpc.API
- func (n *Node) Address() types.Address
- func (n *Node) AdminAPIs() []rpc.API
- func (n *Node) AppEvents() event.AppEmitter
- func (n *Node) Consensus() app.Consensus
- func (n *Node) LogLevels() logcat.Applied
- func (n *Node) Logger(m logcat.Module) *slog.Logger
- func (n *Node) Mempool() mempool.Pool
- func (n *Node) Metrics() *metrics.Registry
- func (n *Node) Runner() *runner.Runner
- func (n *Node) SetLogLevels(s logcat.Settings, source string) (logcat.Applied, error)
- func (n *Node) SignFloor() (types.Height, bool)
- func (n *Node) Start(ctx context.Context) error
- func (n *Node) Stop() error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConfig reports an unusable node configuration. ErrConfig = errors.New("node: invalid configuration") // ErrStartRefused reports a start-up check that refuses to start. ErrStartRefused = errors.New("node: start refused") )
Errors of the node.
var LogDefaults = logcat.Settings{Base: logcat.LevelInfo}
LogDefaults are the log settings of a node whose Config.Log is nil: every module at info.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// DataDir holds the durable state of the node: the write-ahead log in
// wal/, the sign state in privval/state and the message journal in
// journal/.
DataDir string
// KeyFile is the node key in the go-stablenet nodekey format (64 hex
// characters). Empty runs a node that never signs: it verifies headers
// but runs no consensus core.
KeyFile string
// TakeoverGuard sets the sign floor at head + 1 when the sign state is
// empty and the head is above genesis, so that a node that takes over
// a key without its sign record signs nothing at that height
// (privval.takeover_guard).
TakeoverGuard bool
// RunID names this run in the event records; empty derives one from the
// start time.
RunID string
// Mempool configures the transaction pool; used when Deps.Admission is
// set.
Mempool MempoolConfig
// Standalone runs the node in standalone mode, where the authority may
// come from a native module of the application. In the default
// (embedded) mode the node refuses an authority source marked as native
// (source.Native): an embedded chain takes its authority from the state
// it shares with the reference implementation.
Standalone bool
// Journal configures the message journal of a validator.
Journal JournalConfig
// Log is the base log level and the levels of single modules
// (observe.md 7.1); nil uses LogDefaults. An unknown module name
// refuses the start.
Log *logcat.Settings
// LogUnmapped lists log settings of the application that name no
// module (wbft-stablenet's --log.vmodule patterns of single files);
// they are recorded with the settings in force (LOG_CONFIG unmapped).
LogUnmapped []string
}
Config configures a Node.
type Deps ¶
type Deps struct {
// App is the application. Required.
App app.Application
// Authority gives the authority snapshot of the head at start-up and
// the epoch candidates during block execution. Required.
Authority source.AuthoritySource
// Transport carries consensus messages; nil runs a node without peers.
Transport transport.Transport
// Admission validates transactions for the pool; nil runs no pool.
Admission mempool.AdmissionHook
// TxTransport gossips transactions; nil keeps them local.
TxTransport mempool.TxTransport
// Orderings are ordering policies besides the built-in "fifo".
Orderings []mempool.OrderingPolicy
// Events receives the event records as JSON Lines; nil drops them.
Events io.Writer
// Logger is where the node's log lines go; nil discards. Each module
// logs through it with a module attribute, at the level the log
// settings give the module, so its handler should accept every level.
Logger *slog.Logger
// contains filtered or unexported fields
}
Deps are the collaborators of a Node.
type JournalConfig ¶
type JournalConfig struct {
Disabled bool
// KeepHeights and MaxBytes bound the journal; zero takes the defaults
// of journal.DefaultOptions (100000 heights, 8 GiB).
KeepHeights uint64
MaxBytes int64
}
JournalConfig configures the message journal (package observe/journal): the steps of the consensus core and the outcomes of received messages, in DataDir/journal, for analysis and replay. A validator keeps it unless Disabled is set (journal.DefaultEnabled); a node without a key runs no core and keeps none.
type MempoolConfig ¶
type MempoolConfig struct {
// Ordering names the ordering policy: "fifo" (the default) or one of
// Deps.Orderings. An unknown name refuses the start.
Ordering string
// Limits bound the pool.
Limits mempool.Config
}
MempoolConfig configures the transaction pool of a node.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a consensus node: it runs the consensus core for the application and offers the application the Consensus service.
func (*Node) Address ¶
Address returns the address of the node key, or the zero address for a node without a key. It is known after Start.
func (*Node) AdminAPIs ¶
AdminAPIs returns the administrative methods of the node (admin_wbftSetLogLevels); the application registers them only on IPC or an authenticated endpoint.
func (*Node) AppEvents ¶
func (n *Node) AppEvents() event.AppEmitter
AppEvents returns the channel through which application modules put their records into the node's event stream (event.AppEmitter). Records emitted before Start, or when the node writes no events, are dropped.
func (*Node) Logger ¶
Logger returns a logger of module m (logcat.Register for application modules, before the node is made) that writes where the node's lines go, at the level the node's log settings give m.
func (*Node) Mempool ¶
Mempool returns the transaction pool, or nil for a node without an admission hook or before Start.
func (*Node) Metrics ¶
Metrics returns the node's metric registry (observe.md 5). The application serves it (metrics.Registry.Handler) or reads it (Gather) and may register its own metrics in it.
func (*Node) Runner ¶
Runner returns the consensus runner, or nil for a node without a key or before Start.
func (*Node) SetLogLevels ¶
SetLogLevels applies new log settings while the node runs (source: rpc, or config for a reload) and records them; an unknown module changes nothing and returns an error.
func (*Node) SignFloor ¶
SignFloor returns the sign floor of the node key and true if one is set. It is known after Start.
func (*Node) Start ¶
Start runs the start-up handshake and starts the consensus core:
- read the application's Info and check its interface version;
- parse and check the chain configuration;
- open the write-ahead log and the sign state, and set the sign floor of a taken-over key;
- compare the application head with the log and the sign state, and finalize again a decided block the application did not store;
- load the authority snapshot of the head;
- connect the transport and start the core at head + 1.