cluster

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: GPL-3.0 Imports: 27 Imported by: 3

Documentation

Overview

Package cluster provides the cluster configuration API. It defines the `Definition` type that is the output of the Launchpad and `charon create dkg` commands. `Definition` is also the input to `charon dkg`. If defines the `Lock` type that is the output of the `charon dkg` and `charon create cluster` commands. `Lock` is also the input to `charon run` command.

launchpad.obol.net ─┐
                    ├─► cluster-definition.json ──► charon dkg ─┐
 charon create dkg ─┘                                           ├─► cluster-lock.json ──► charon run
                                         charon create cluster ─┘

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Definition added in v0.4.0

type Definition struct {
	// Name is an optional cosmetic identifier
	Name string

	// UUID is a random unique identifier
	UUID string

	// Version is the schema version of this definition.
	Version string

	// Timestamp is the human readable timestamp of this definition.
	// Note this was added in v1.0.1, so may be empty for older versions.
	Timestamp string

	// NumValidators is the number of DVs (n*32ETH) to be created in the cluster lock file.
	NumValidators int

	// Threshold required for signature reconstruction. Defaults to safe value for number of nodes/peers.
	Threshold int

	// FeeRecipientAddress Ethereum address.
	FeeRecipientAddress string

	// WithdrawalAddress Ethereum address.
	WithdrawalAddress string

	// DKGAlgorithm to use for key generation.
	DKGAlgorithm string

	// ForkVersion defines the cluster's beacon chain hex fork definitionVersion (network/chain identifier).
	ForkVersion string

	// Operators define the charon nodes in the cluster and their operators.
	Operators []Operator
}

Definition defines an intended charon cluster configuration.

func NewDefinition added in v0.4.0

func NewDefinition(
	name string,
	numVals int,
	threshold int,
	feeRecipient string,
	withdrawalAddress string,
	forkVersionHex string,
	operators []Operator,
	random io.Reader,
) Definition

NewDefinition returns a new definition with populated with latest version, timestamp and UUID.

func (Definition) ConfigHash added in v0.7.0

func (d Definition) ConfigHash() ([32]byte, error)

ConfigHash returns the config hash of the definition object.

func (Definition) HashTreeRoot added in v0.4.0

func (d Definition) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Definition object.

func (Definition) HashTreeRootWith added in v0.4.0

func (d Definition) HashTreeRootWith(hh *ssz.Hasher) error

HashTreeRootWith ssz hashes the Definition object by including all the fields inside Operator. This is done in order to calculate definition_hash of the final Definition object.

func (Definition) MarshalJSON added in v0.4.0

func (d Definition) MarshalJSON() ([]byte, error)

func (Definition) NodeIdx added in v0.4.0

func (d Definition) NodeIdx(pID peer.ID) (NodeIdx, error)

NodeIdx returns the node index for the peer.

func (Definition) PeerIDs added in v0.5.0

func (d Definition) PeerIDs() ([]peer.ID, error)

PeerIDs is a convenience function that returns the operators p2p peer IDs.

func (Definition) Peers added in v0.4.0

func (d Definition) Peers() ([]p2p.Peer, error)

Peers returns the operators as a slice of p2p peers.

func (Definition) Sealed added in v0.4.0

func (d Definition) Sealed() (bool, error)

Sealed returns true if all config signatures are fully populated and valid. A "sealed" definition is ready for use in DKG.

func (*Definition) UnmarshalJSON added in v0.4.0

func (d *Definition) UnmarshalJSON(data []byte) error

type DistValidator added in v0.4.0

type DistValidator struct {
	// PubKey is the distributed validator group public key.
	PubKey string `json:"distributed_public_key"`

	// PubShares are the public keys corresponding to each node's secret key share.
	// It can be used to verify a partial signature created by any node in the cluster.
	PubShares [][]byte `json:"public_shares,omitempty"`

	// FeeRecipientAddress Ethereum address override for this validator, defaults to definition withdrawal address.
	FeeRecipientAddress string `json:"fee_recipient_address,omitempty"`
}

DistValidator is a distributed validator (1x32ETH) managed by the cluster.

func (DistValidator) HashTreeRoot added in v0.4.0

func (v DistValidator) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Lock object.

func (DistValidator) HashTreeRootWith added in v0.4.0

func (v DistValidator) HashTreeRootWith(hh *ssz.Hasher) error

HashTreeRootWith ssz hashes the Lock object with a hasher.

func (DistValidator) PublicKey added in v0.5.0

func (v DistValidator) PublicKey() (*bls_sig.PublicKey, error)

PublicKey returns the validator group public key.

func (DistValidator) PublicShare added in v0.5.0

func (v DistValidator) PublicShare(peerIdx int) (*bls_sig.PublicKey, error)

PublicShare returns a peer's threshold BLS public share.

type Lock added in v0.4.0

type Lock struct {
	// Definition is embedded and extended by Lock.
	Definition

	// Validators are the distributed validators (n*32ETH) managed by the cluster.
	Validators []DistValidator

	// SignatureAggregate is the bls aggregate signature of the lock hash signed by each DV pubkey.
	// It acts as an attestation by all the distributed validators of the charon cluster they are part of.
	SignatureAggregate []byte
}

Lock extends the cluster config Definition with bls threshold public keys and checksums.

func NewForT added in v0.1.1

func NewForT(t *testing.T, dv, k, n, seed int) (Lock, []*ecdsa.PrivateKey, [][]*bls_sig.SecretKeyShare)

NewForT returns a new cluster lock with dv number of distributed validators, k threshold and n peers. It also returns the peer p2p keys and BLS secret shares. If the seed is zero a random cluster on available loopback ports is generated, else a deterministic cluster is generated. Note this is not defined in testutil since it is tightly coupled with the cluster package.

func (Lock) HashTreeRoot added in v0.4.0

func (l Lock) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Lock object.

func (Lock) HashTreeRootWith added in v0.4.0

func (l Lock) HashTreeRootWith(hh *ssz.Hasher) error

HashTreeRootWith ssz hashes the Lock object with a hasher.

func (Lock) MarshalJSON added in v0.4.0

func (l Lock) MarshalJSON() ([]byte, error)

func (*Lock) UnmarshalJSON added in v0.4.0

func (l *Lock) UnmarshalJSON(data []byte) error

type NodeIdx added in v0.4.0

type NodeIdx struct {
	// PeerIdx is the index of a peer in the peer list (it 0-indexed).
	PeerIdx int
	// ShareIdx is the tbls share identifier (it is 1-indexed).
	ShareIdx int
}

NodeIdx represents the index of a node/peer/share in the cluster as operator order in cluster definition.

type Operator added in v0.4.0

type Operator struct {
	// The Ethereum address of the operator
	Address string `json:"address"`

	// ENR identifies the charon node.
	ENR string `json:"enr"`

	//  Nonce is incremented each time the ENR is added or signed.
	Nonce int `json:"nonce"`

	// ConfigSignature is an EIP712 signature of the config_hash using privkey corresponding to operator Ethereum Address.
	ConfigSignature []byte `json:"config_signature"`

	// ENRSignature is a EIP712 signature of the ENR by the Address, authorising the charon node to act on behalf of the operator in the cluster.
	ENRSignature []byte `json:"enr_signature"`
}

Operator identifies a charon node and its operator.

func (Operator) HashTreeRoot added in v0.4.0

func (o Operator) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Definition object.

func (Operator) HashTreeRootWith added in v0.4.0

func (o Operator) HashTreeRootWith(hh *ssz.Hasher) error

HashTreeRootWith ssz hashes the Operator object with a hasher.

func (Operator) VerifySignature added in v0.4.0

func (o Operator) VerifySignature() error

VerifySignature returns an error if the ENR signature doesn't match the address and enr fields.

Jump to

Keyboard shortcuts

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