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 ¶
- type Definition
- func (d Definition) HashTreeRoot() ([32]byte, error)
- func (d Definition) HashTreeRootWith(hh *ssz.Hasher) 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) Sealed() (bool, error)
- func (d *Definition) UnmarshalJSON(data []byte) error
- type DistValidator
- type Lock
- type NodeIdx
- type Operator
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
// 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
// OperatorSignatures are EIP712 signatures of the definition hash by each operator Ethereum address.
// Fully populated operator signatures results in "sealed" definition ready for use in DKG.
OperatorSignatures [][]byte
}
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 version and UUID.
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 with a hasher.
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 operator signatures are populated and valid.
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"`
// 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
HashTreeRoot ssz hashes the Lock object.
func (Lock) HashTreeRootWith ¶ added in v0.4.0
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 {
// Address is the Ethereum address identifying the operator.
Address string `json:"address"`
// ENR identifies the charon node.
ENR string `json:"enr"`
// Nonce is incremented each time the ENR is signed.
Nonce int `json:"nonce"`
// 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
HashTreeRoot ssz hashes the Definition object.
func (Operator) HashTreeRootWith ¶ added in v0.4.0
HashTreeRootWith ssz hashes the Operator object with a hasher.
func (Operator) VerifySignature ¶ added in v0.4.0
VerifySignature returns an error if the ENR signature doesn't match the address and enr fields.