core

package
v1.5.11 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0, MIT Imports: 47 Imported by: 3

Documentation

Index

Constants

View Source
const DefaultBeaconPeriod = 1 * time.Minute

DefaultBeaconPeriod is the period in which the beacon logic creates new random beacon.

View Source
const DefaultConfigFolderName = ".drand"

DefaultConfigFolderName is the name of the folder containing all key materials (and the beacons db file by default). It is relative to the user's home directory.

View Source
const DefaultControlPort = "8888"

DefaultControlPort is the default port the functionality control port communicate on.

View Source
const DefaultDBFolder = "db"

DefaultDBFolder is the name of the folder in which the db file is saved. It is relative to the DefaultConfigFolder path.

View Source
const DefaultDKGTimeout = 10 * time.Second

DefaultDKGTimeout is the default time of each DKG period by default. Note that by default, DKG uses the "fast sync" mode that shorten the first phase and the second phase, "as fast as possible" when the protocol runs smoothly (there is no malicious party).

View Source
const DefaultGenesisOffset = 1 * time.Second

DefaultGenesisOffset is the time the leader adds after the maximum DKG time (the full three phases) to compute the genesis time of the randomness chain.

View Source
const InProgressDesc = "In progress"
View Source
const NotStartedDesc = "Not started"
View Source
const UnknownDesc = "Unknown"

Variables

View Source
var DefaultResharingOffset = 30 * time.Second

DefaultResharingOffset is the time the leader adds to the current time to set the TransitionTime field in the group file when setting up a resharing. This time will be rounded up to the next round time of the beacon, since a beacon has to keep the same period.

View Source
var MaxWaitPrepareDKG = 24 * 7 * 2 * time.Hour

MaxWaitPrepareDKG is the maximum time the "automatic" setting up of the group can take. If the setup is still not finished after this time, it is canceled.

Functions

func DefaultConfigFolder

func DefaultConfigFolder() string

DefaultConfigFolder returns the default path of the configuration folder.

func GetBeaconDescription added in v1.4.6

func GetBeaconDescription(value BeaconStatus) string

func GetDkgStatusDescription added in v1.4.6

func GetDkgStatusDescription(value DkgStatus) string

func GetReshareStatusDescription added in v1.4.6

func GetReshareStatusDescription(value ReshareStatus) string

func Proxy added in v1.0.0

Proxy wraps a server interface into a client interface so it can be queried

func StatusResponseToString added in v1.4.6

func StatusResponseToString(status *drand.StatusResponse) string

Types

type BeaconProcess added in v1.4.6

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

BeaconProcess is the main logic of the program. It reads the keys / group file, it can start the DKG, read/write shares to files and can initiate/respond to tBLS signature requests.

func NewBeaconProcess added in v1.4.6

func NewBeaconProcess(log dlog.Logger, store key.Store, beaconID string, opts *Config, privGateway *net.PrivateGateway,
	pubGateway *net.PublicGateway) (*BeaconProcess, error)

func (*BeaconProcess) BackupDatabase added in v1.4.6

func (bp *BeaconProcess) BackupDatabase(ctx context.Context, req *drand.BackupDBRequest) (*drand.BackupDBResponse, error)

BackupDatabase triggers a backup of the primary database.

func (*BeaconProcess) BroadcastDKG added in v1.4.6

func (bp *BeaconProcess) BroadcastDKG(c context.Context, in *drand.DKGPacket) (*drand.Empty, error)

BroadcastDKG is the public method to call during a DKG protocol.

func (*BeaconProcess) ChainInfo added in v1.4.6

ChainInfo replies with the chain information this node participates to

func (*BeaconProcess) GetIdentity added in v1.4.6

GetIdentity returns the identity of this drand node

func (*BeaconProcess) GroupFile added in v1.4.6

GroupFile replies with the distributed key in the response

func (*BeaconProcess) Home added in v1.4.6

Home provides the address the local node is listening

func (*BeaconProcess) InitDKG added in v1.4.6

InitDKG take a InitDKGPacket, extracts the information needed and wait for the DKG protocol to finish. If the request specifies this node is a leader, it starts the DKG protocol.

func (*BeaconProcess) InitReshare added in v1.4.6

InitReshare receives information about the old and new group from which to operate the resharing protocol.

func (*BeaconProcess) ListBeaconIDs added in v1.4.6

func (*BeaconProcess) ListSchemes added in v1.4.6

func (*BeaconProcess) Load added in v1.4.6

func (bp *BeaconProcess) Load() (bool, error)

Load restores a drand instance that is ready to serve randomness, with a pre-existing distributed share. Returns 'true' if this BeaconProcess is a fresh run, returns 'false' otherwise

func (*BeaconProcess) MetricsHandlerForPeer added in v1.4.6

func (bp *BeaconProcess) MetricsHandlerForPeer(addr string) (http.Handler, error)

MetricsHandlerForPeer returns a handler for retrieving metric information from a peer in this group

func (*BeaconProcess) PartialBeacon added in v1.4.6

func (bp *BeaconProcess) PartialBeacon(c context.Context, in *drand.PartialBeaconPacket) (*drand.Empty, error)

PartialBeacon receives a beacon generation request and answers with the partial signature from this drand node.

func (*BeaconProcess) PingPong added in v1.4.6

func (bp *BeaconProcess) PingPong(context.Context, *drand.Ping) (*drand.Pong, error)

PingPong simply responds with an empty packet, proving that this drand node is up and alive.

func (*BeaconProcess) PublicKey added in v1.4.6

PublicKey is a functionality of Control Service defined in protobuf/control that requests the long term public key of the drand node running locally

func (*BeaconProcess) PublicRand added in v1.4.6

PublicRand returns a public random beacon according to the request. If the Round field is 0, then it returns the last one generated.

func (*BeaconProcess) PublicRandStream added in v1.4.6

PublicRandStream exports a stream of new beacons as they are generated over gRPC

func (*BeaconProcess) PushDKGInfo added in v1.4.6

func (bp *BeaconProcess) PushDKGInfo(_ context.Context, in *drand.DKGInfoPacket) (*drand.Empty, error)

PushDKGInfo triggers sending DKG info to other members

func (*BeaconProcess) RemoteStatus added in v1.4.6

func (*BeaconProcess) SignalDKGParticipant added in v1.4.6

func (bp *BeaconProcess) SignalDKGParticipant(ctx context.Context, p *drand.SignalDKGPacket) (*drand.Empty, error)

SignalDKGParticipant receives a dkg signal packet from another member

func (*BeaconProcess) StartBeacon added in v1.4.6

func (bp *BeaconProcess) StartBeacon(catchup bool) error

StartBeacon initializes the beacon if needed and launch a go routine that runs the generation loop.

func (*BeaconProcess) StartCheckChain added in v1.4.6

StartCheckChain checks a chain for validity and pulls invalid beacons from other nodes

func (*BeaconProcess) StartFollowChain added in v1.4.6

StartFollowChain syncs up with a chain from other nodes

func (*BeaconProcess) Status added in v1.4.6

Status responds with the actual status of drand process

func (*BeaconProcess) Stop added in v1.4.6

func (bp *BeaconProcess) Stop(ctx context.Context)

Stop simply stops all drand operations.

func (*BeaconProcess) StopBeacon added in v1.4.6

func (bp *BeaconProcess) StopBeacon()

StopBeacon stops the beacon generation process and resets it.

func (*BeaconProcess) SyncChain added in v1.4.6

func (bp *BeaconProcess) SyncChain(req *drand.SyncRequest, stream drand.Protocol_SyncChainServer) error

SyncChain is an inter-node protocol that replies to a syncing request from a given round

func (*BeaconProcess) WaitDKG added in v1.4.6

func (bp *BeaconProcess) WaitDKG() (*key.Group, error)

WaitDKG waits on the running dkg protocol. In case of an error, it returns it. In case of a finished DKG protocol, it saves the dist. public key and private share. These should be loadable by the store.

func (*BeaconProcess) WaitExit added in v1.4.6

func (bp *BeaconProcess) WaitExit() chan bool

WaitExit returns a channel that signals when drand stops its operations

type BeaconStatus added in v1.4.6

type BeaconStatus uint32
const (
	BeaconNotInited BeaconStatus = iota
	BeaconInited
)

type Broadcast added in v1.2.6

type Broadcast interface {
	dkg.Board
	BroadcastDKG(c context.Context, p *drand.DKGPacket) error
	Stop()
}

Broadcast is an interface that represents the minimum functionality required by drand to both (1) be the interface between drand and the dkg logic and (2) implement the broadcasting mechanism.

type Client

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

Client is the endpoint logic, communicating with drand servers XXX: This API should go away. Do not extend any further.

func NewGrpcClient added in v0.3.7

func NewGrpcClient(chainHash []byte, opts ...grpc.DialOption) *Client

NewGrpcClient returns a Client able to talk to drand instances using gRPC communication method

func NewGrpcClientFromCert added in v0.3.7

func NewGrpcClientFromCert(chainHash []byte, c *net.CertManager, opts ...grpc.DialOption) *Client

NewGrpcClientFromCert returns a client that contact its peer over TLS

func (*Client) ChainInfo added in v1.0.0

func (c *Client) ChainInfo(p net.Peer) (*chain.Info, error)

ChainInfo returns the chain info as reported by the given peer.

type Config

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

Config holds all relevant information for a drand node to run.

func NewConfig

func NewConfig(opts ...ConfigOption) *Config

NewConfig returns the config to pass to drand with the default options set and the updated values given by the options.

func (*Config) BoltOptions added in v0.9.0

func (d *Config) BoltOptions() *bolt.Options

BoltOptions returns the options given to the bolt db

func (*Config) Certs added in v0.3.7

func (d *Config) Certs() *net.CertManager

Certs returns all custom certs currently being trusted by drand.

func (*Config) ConfigFolder

func (d *Config) ConfigFolder() string

ConfigFolder returns the folder under which drand stores all its configuration.

func (*Config) ConfigFolderMB added in v1.4.6

func (d *Config) ConfigFolderMB() string

ConfigFolderMB returns the folder under which multi-beacon drand stores all its configuration.

func (*Config) ControlPort added in v0.4.0

func (d *Config) ControlPort() string

ControlPort returns the port used for control port communications which can be the default one or the port setup thanks to WithControlPort

func (*Config) DBFolder

func (d *Config) DBFolder(beaconID string) string

DBFolder returns the folder under which drand stores db file specifically. If beacon id is empty, it will use the default value

func (*Config) Logger added in v0.5.2

func (d *Config) Logger() log.Logger

Logger returns the logger associated with this config.

func (*Config) PgDSN added in v1.5.3

func (d *Config) PgDSN() string

PgDSN returns the PostgreSQL specific DSN configuration.

func (*Config) PrivateListenAddress added in v0.9.0

func (d *Config) PrivateListenAddress(defaultAddr string) string

PrivateListenAddress returns the given default address or the listen address stored in the config thanks to WithPrivateListenAddress

func (*Config) PublicListenAddress added in v0.9.0

func (d *Config) PublicListenAddress(defaultAddr string) string

PublicListenAddress returns the given default address or the listen address stored in the config thanks to WithPublicListenAddress

func (*Config) Version added in v1.0.0

func (d *Config) Version() string

Version returns the configured version of the binary

type ConfigOption

type ConfigOption func(*Config)

ConfigOption is a function that applies a specific setting to a Config.

func WithBoltOptions

func WithBoltOptions(opts *bolt.Options) ConfigOption

WithBoltOptions applies boltdb specific options when storing random beacons.

func WithCallOption added in v0.3.7

func WithCallOption(opts ...grpc.CallOption) ConfigOption

WithCallOption applies grpc options when drand calls a gRPC method.

func WithConfigFolder

func WithConfigFolder(folder string) ConfigOption

WithConfigFolder sets the base configuration folder to the given string.

func WithControlPort added in v0.4.0

func WithControlPort(port string) ConfigOption

WithControlPort specifies which port on localhost the ListenerControl should bind to.

func WithDBStorageEngine added in v1.5.3

func WithDBStorageEngine(engine chain.StorageType) ConfigOption

WithDBStorageEngine allows setting the specific storage type

func WithDkgTimeout

func WithDkgTimeout(t time.Duration) ConfigOption

WithDkgTimeout sets the timeout under which the DKG must finish.

func WithGrpcOptions

func WithGrpcOptions(opts ...grpc.DialOption) ConfigOption

WithGrpcOptions applies grpc dialing option used when a drand node actively contacts another.

func WithInsecure added in v0.3.7

func WithInsecure() ConfigOption

WithInsecure allows drand to listen on standard non-encrypted port and to contact other nodes over non-encrypted TCP connections.

func WithLogLevel added in v0.5.2

func WithLogLevel(level int, jsonFormat bool) ConfigOption

WithLogLevel sets the logging verbosity to the given level.

func WithMemDBSize added in v1.5.3

func WithMemDBSize(bufferSize int) ConfigOption

func WithPgDSN added in v1.5.3

func WithPgDSN(dsn string) ConfigOption

WithPgDSN applies PosgresSQL specific options to the PG store. It will also create a new database connection.

func WithPrivateListenAddress added in v0.9.0

func WithPrivateListenAddress(addr string) ConfigOption

WithPrivateListenAddress specifies the address the drand instance should bind to. It is useful if you want to advertise a public proxy address and the drand instance runs behind your network.

func WithPublicListenAddress added in v0.9.0

func WithPublicListenAddress(addr string) ConfigOption

WithPublicListenAddress specifies the address the drand instance should bind to. It is useful if you want to advertise a public proxy address and the drand instance runs behind your network.

func WithTLS added in v0.3.7

func WithTLS(certPath, keyPath string) ConfigOption

WithTLS registers the certificates and private key path so drand can accept and issue connections using TLS.

func WithTrustedCerts added in v0.3.7

func WithTrustedCerts(certPaths ...string) ConfigOption

WithTrustedCerts saves the certificates at the given paths and forces drand to trust them. Mostly useful for testing.

func WithVersion added in v1.0.0

func WithVersion(version string) ConfigOption

WithVersion sets a version for drand, a visible string to other peers.

type DkgStatus added in v1.4.6

type DkgStatus uint32
const (
	DkgReady DkgStatus = iota
	DkgInProgress
	DkgNotStarted
)

type DrandDaemon added in v1.4.6

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

func NewDrandDaemon added in v1.4.6

func NewDrandDaemon(c *Config) (*DrandDaemon, error)

NewDrandDaemon creates a new instance of DrandDaemon

func (*DrandDaemon) AddBeaconHandler added in v1.4.6

func (dd *DrandDaemon) AddBeaconHandler(beaconID string, bp *BeaconProcess)

AddBeaconHandler adds a handler linked to beacon with chain hash from http server used to expose public services

func (*DrandDaemon) BackupDatabase added in v1.4.6

func (dd *DrandDaemon) BackupDatabase(ctx context.Context, in *drand.BackupDBRequest) (*drand.BackupDBResponse, error)

BackupDatabase triggers a backup of the primary database.

func (*DrandDaemon) BroadcastDKG added in v1.4.6

func (dd *DrandDaemon) BroadcastDKG(c context.Context, in *drand.DKGPacket) (*drand.Empty, error)

BroadcastDKG is the public method to call during a DKG protocol.

func (*DrandDaemon) ChainInfo added in v1.4.6

ChainInfo replies with the chain information this node participates to

func (*DrandDaemon) GetIdentity added in v1.4.6

GetIdentity returns the identity of this drand node

func (*DrandDaemon) GroupFile added in v1.4.6

func (dd *DrandDaemon) GroupFile(ctx context.Context, in *drand.GroupRequest) (*drand.GroupPacket, error)

GroupFile replies with the distributed key in the response

func (*DrandDaemon) Home added in v1.4.6

Home provides the address the local node is listening

func (*DrandDaemon) InitDKG added in v1.4.6

InitDKG take a InitDKGPacket, extracts the information needed and wait for the DKG protocol to finish. If the request specifies this node is a leader, it starts the DKG protocol.

func (*DrandDaemon) InitReshare added in v1.4.6

func (dd *DrandDaemon) InitReshare(ctx context.Context, in *drand.InitResharePacket) (*drand.GroupPacket, error)

InitReshare receives information about the old and new group from which to operate the resharing protocol.

func (*DrandDaemon) InstantiateBeaconProcess added in v1.4.6

func (dd *DrandDaemon) InstantiateBeaconProcess(beaconID string, store key.Store) (*BeaconProcess, error)

InstantiateBeaconProcess creates a new BeaconProcess linked to beacon with id 'beaconID'

func (*DrandDaemon) ListBeaconIDs added in v1.4.6

func (*DrandDaemon) ListSchemes added in v1.4.6

func (*DrandDaemon) LoadBeacon added in v1.4.6

LoadBeacon tells the DrandDaemon to load a new beacon into the memory

func (*DrandDaemon) LoadBeaconFromDisk added in v1.4.6

func (dd *DrandDaemon) LoadBeaconFromDisk(beaconID string) (*BeaconProcess, error)

func (*DrandDaemon) LoadBeaconFromStore added in v1.4.6

func (dd *DrandDaemon) LoadBeaconFromStore(beaconID string, store key.Store) (*BeaconProcess, error)

func (*DrandDaemon) LoadBeaconsFromDisk added in v1.4.6

func (dd *DrandDaemon) LoadBeaconsFromDisk(metricsFlag string, singleBeacon bool, singleBeaconName string) error

LoadBeaconsFromDisk checks for existing stores and creates the corresponding BeaconProcess accordingly to each stored BeaconID. When singleBeacon is set, and the singleBeaconName matches one of the stored beacons, then only that beacon will be loaded. If the singleBeaconName is an empty string, no beacon will be loaded.

func (*DrandDaemon) NodeVersionStreamValidator added in v1.4.6

func (dd *DrandDaemon) NodeVersionStreamValidator(srv interface{}, ss grpc.ServerStream,
	info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func (*DrandDaemon) NodeVersionValidator added in v1.4.6

func (dd *DrandDaemon) NodeVersionValidator(ctx context.Context, req interface{},
	info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (response interface{}, err error)

func (*DrandDaemon) PartialBeacon added in v1.4.6

func (dd *DrandDaemon) PartialBeacon(c context.Context, in *drand.PartialBeaconPacket) (*drand.Empty, error)

PartialBeacon receives a beacon generation request and answers with the partial signature from this drand node.

func (*DrandDaemon) PingPong added in v1.4.6

func (dd *DrandDaemon) PingPong(ctx context.Context, in *drand.Ping) (*drand.Pong, error)

PingPong simply responds with an empty packet, proving that this drand node is up and alive.

func (*DrandDaemon) PrivateKey added in v1.4.6

PrivateKey is a functionality of Control Service defined in protobuf/control that requests the long term private key of the drand node running locally Deprecated: no need to export secret key to a remote client.

func (*DrandDaemon) PublicKey added in v1.4.6

PublicKey is a functionality of Control Service defined in protobuf/control that requests the long term public key of the drand node running locally

func (*DrandDaemon) PublicRand added in v1.4.6

PublicRand returns a public random beacon according to the request. If the Round field is 0, then it returns the last one generated.

func (*DrandDaemon) PublicRandStream added in v1.4.6

func (dd *DrandDaemon) PublicRandStream(in *drand.PublicRandRequest, stream drand.Public_PublicRandStreamServer) error

PublicRandStream exports a stream of new beacons as they are generated over gRPC

func (*DrandDaemon) PushDKGInfo added in v1.4.6

func (dd *DrandDaemon) PushDKGInfo(ctx context.Context, in *drand.DKGInfoPacket) (*drand.Empty, error)

PushDKGInfo triggers sending DKG info to other members

func (*DrandDaemon) RemoteStatus added in v1.4.6

func (*DrandDaemon) RemoveBeaconHandler added in v1.4.6

func (dd *DrandDaemon) RemoveBeaconHandler(beaconID string, bp *BeaconProcess)

RemoveBeaconHandler removes a handler linked to beacon with chain hash from http server used to expose public services

func (*DrandDaemon) RemoveBeaconProcess added in v1.4.6

func (dd *DrandDaemon) RemoveBeaconProcess(beaconID string, bp *BeaconProcess)

RemoveBeaconProcess remove a BeaconProcess linked to beacon with id 'beaconID'

func (*DrandDaemon) Share added in v1.4.6

Share is a functionality of Control Service defined in protobuf/control that requests the private share of the drand node running locally Deprecated: no need to export the secret share to a remote client.

func (*DrandDaemon) Shutdown added in v1.4.6

Shutdown stops the node

func (*DrandDaemon) SignalDKGParticipant added in v1.4.6

func (dd *DrandDaemon) SignalDKGParticipant(ctx context.Context, in *drand.SignalDKGPacket) (*drand.Empty, error)

SignalDKGParticipant receives a dkg signal packet from another member

func (*DrandDaemon) StartCheckChain added in v1.4.6

func (*DrandDaemon) StartFollowChain added in v1.4.6

func (dd *DrandDaemon) StartFollowChain(in *drand.StartSyncRequest, stream drand.Control_StartFollowChainServer) error

func (*DrandDaemon) Status added in v1.4.6

Status responds with the actual status of drand process

func (*DrandDaemon) Stop added in v1.4.6

func (dd *DrandDaemon) Stop(ctx context.Context)

Stop simply stops all drand operations.

func (*DrandDaemon) SyncChain added in v1.4.6

func (dd *DrandDaemon) SyncChain(in *drand.SyncRequest, stream drand.Protocol_SyncChainServer) error

SyncChain is a inter-node protocol that replies to a syncing request from a given round

func (*DrandDaemon) WaitExit added in v1.4.6

func (dd *DrandDaemon) WaitExit() chan bool

WaitExit returns a channel that signals when drand stops its operations

type MetadataGetter added in v1.4.6

type MetadataGetter interface {
	GetMetadata() *common.Metadata
}

type ReshareStatus added in v1.4.6

type ReshareStatus uint32
const (
	ReshareNotInProgress ReshareStatus = iota
	ReshareInProgress
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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