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 ¶
- func SupportedVersionsForT(*testing.T) []string
- func Threshold(nodes int) int
- type Definition
- func (d Definition) ConfigHash() ([32]byte, error)
- func (d Definition) GetTree() (*ssz.Node, error)
- func (d Definition) HashTreeRoot() ([32]byte, error)
- func (d Definition) HashTreeRootWith(hh ssz.HashWalker) error
- func (d Definition) MarshalJSON() ([]byte, error)
- func (d Definition) NodeIdx(pID peer.ID) (NodeIdx, error)
- func (d Definition) PeerIDs() ([]peer.ID, error)
- func (d Definition) Peers() ([]p2p.Peer, error)
- func (d *Definition) UnmarshalJSON(data []byte) error
- func (d Definition) Verify() error
- type DistValidator
- func (v DistValidator) GetTree() (*ssz.Node, error)
- func (v DistValidator) HashTreeRoot() ([32]byte, error)
- func (v DistValidator) HashTreeRootWith(hh ssz.HashWalker) error
- func (v DistValidator) PublicKey() (*bls_sig.PublicKey, error)
- func (v DistValidator) PublicShare(peerIdx int) (*bls_sig.PublicKey, error)
- type Lock
- type NodeIdx
- type Operator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SupportedVersionsForT ¶ added in v0.10.0
SupportedVersionsForT returns the supported definition versions for testing purposes only.
func Threshold ¶ added in v0.10.0
Threshold returns minimum threshold required for a cluster with given nodes. This formula has been taken from: https://github.com/ObolNetwork/charon/blob/a8fc3185bdda154412fe034dcd07c95baf5c1aaf/core/qbft/qbft.go#L63
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 that this was added in v1.1.0, 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 populated with the 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) GetTree ¶ added in v0.10.0
func (d Definition) GetTree() (*ssz.Node, error)
GetTree ssz hashes 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.HashWalker) 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) UnmarshalJSON ¶ added in v0.4.0
func (d *Definition) UnmarshalJSON(data []byte) error
func (Definition) Verify ¶ added in v0.10.0
func (d Definition) Verify() error
Verify returns true if all config signatures are fully populated and valid. A verified definition is ready for use in DKG.
type DistValidator ¶ added in v0.4.0
type DistValidator struct {
// PubKey is the distributed validator group public key.
PubKey string `json:"distributed_public_key"`
// 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) GetTree ¶ added in v0.10.0
func (v DistValidator) GetTree() (*ssz.Node, error)
GetTree ssz hashes the DistValidator object.
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.HashWalker) 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
// all the private key shares of all the distributed validators.
// 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, opts ...func(*Definition)) (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
HashTreeRoot ssz hashes the Lock object.
func (Lock) HashTreeRootWith ¶ added in v0.4.0
func (l Lock) HashTreeRootWith(hh ssz.HashWalker) error
HashTreeRootWith ssz hashes the Lock object with a hasher.
func (Lock) MarshalJSON ¶ added in v0.4.0
func (*Lock) UnmarshalJSON ¶ added in v0.4.0
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 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
// ENR identifies the charon node.
ENR string
// ConfigSignature is an EIP712 signature of the config_hash using privkey corresponding to operator Ethereum Address.
ConfigSignature []byte
// 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
}
Operator identifies a charon node and its operator.
func (Operator) HashTreeRoot ¶ added in v0.4.0
HashTreeRoot ssz hashes the Definition object.
func (Operator) HashTreeRootWith ¶ added in v0.4.0
func (o Operator) HashTreeRootWith(hh ssz.HashWalker) error
HashTreeRootWith ssz hashes the Operator object with a hasher.
func (Operator) HashTreeRootWithV1x1 ¶ added in v0.10.0
func (o Operator) HashTreeRootWithV1x1(hh ssz.HashWalker) error
HashTreeRootWithV1x1 ssz hashes the Operator object with a hasher for versions v1.0.0 and v1.1.0.