records

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// ZeroSubnets is the representation of no subnets
	ZeroSubnets = "00000000000000000000000000000000"
	// AllSubnets is the representation of all subnets
	AllSubnets = "ffffffffffffffffffffffffffffffff"
)

Variables

View Source
var ErrEntryNotFound = errors.New("not found")

Functions

func CreateLocalNode

func CreateLocalNode(privKey *ecdsa.PrivateKey, storagePath string, ipAddr net.IP, udpPort, tcpPort int) (*enode.LocalNode, error)

CreateLocalNode create a new enode.LocalNode instance

func DiffSubnets added in v0.3.0

func DiffSubnets(a, b []byte) map[int]byte

DiffSubnets returns a diff of the two given subnets. returns a map with all the different entries and their post change value

func GetDomainTypeEntry added in v1.1.0

func GetDomainTypeEntry(record *enr.Record) (spectypes.DomainType, error)

GetDomainTypeEntry extracts the value of domain type entry

func GetSubnetsEntry

func GetSubnetsEntry(record *enr.Record) ([]byte, error)

GetSubnetsEntry extracts the value of subnets entry from some record

func SetDomainTypeEntry added in v1.1.0

func SetDomainTypeEntry(node *enode.LocalNode, domainType spectypes.DomainType) error

SetDomainTypeEntry adds domain type entry to the node

func SetSubnetsEntry

func SetSubnetsEntry(node *enode.LocalNode, subnets []byte) error

SetSubnetsEntry adds subnets entry to our enode.LocalNode

func SharedSubnets added in v0.3.0

func SharedSubnets(a, b []byte, maxLen int) []int

SharedSubnets returns the shared subnets

func UpdateSubnets

func UpdateSubnets(node *enode.LocalNode, count int, added []int, removed []int) ([]byte, error)

UpdateSubnets updates subnets entry according to the given changes. count is the amount of subnets, in case that the entry doesn't exist as we want to initialize it

Types

type AnyNodeInfo added in v1.1.0

type AnyNodeInfo interface {
	Codec() []byte
	Domain() string
	MarshalRecord() ([]byte, error)
	UnmarshalRecord(data []byte) error
	Seal(netPrivateKey crypto.PrivKey) ([]byte, error)
	Consume(data []byte) error
	GetNodeInfo() *NodeInfo
}

type DomainTypeEntry added in v1.1.0

type DomainTypeEntry spectypes.DomainType

DomainTypeEntry holds the domain type of the node

func (*DomainTypeEntry) DecodeRLP added in v1.1.0

func (dt *DomainTypeEntry) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, decodes domain type from bytes

func (DomainTypeEntry) ENRKey added in v1.1.0

func (dt DomainTypeEntry) ENRKey() string

ENRKey implements enr.Entry, returns the entry key

func (DomainTypeEntry) EncodeRLP added in v1.1.0

func (dt DomainTypeEntry) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder, encodes domain type as bytes

type HandshakeData added in v1.1.0

type HandshakeData struct {
	SenderPeerID    peer.ID
	RecipientPeerID peer.ID
	Timestamp       time.Time
	SenderPublicKey []byte
}

func (*HandshakeData) Encode added in v1.3.3

func (h *HandshakeData) Encode() []byte

type NodeInfo

type NodeInfo struct {
	// NetworkID is the id of the node's network
	NetworkID string
	// Metadata holds node's general information
	Metadata *NodeMetadata
}

NodeInfo holds node's information such as network information. it implements record.Record so we can safely sign, exchange and verify the data. for more information see record.Envelope

func NewNodeInfo

func NewNodeInfo(networkID string) *NodeInfo

NewNodeInfo creates a new node info

func (*NodeInfo) Codec

func (ni *NodeInfo) Codec() []byte

Codec is a binary identifier for this type of record.record

func (*NodeInfo) Consume

func (ni *NodeInfo) Consume(data []byte) error

Consume takes a raw envelope and extracts the parsed record

func (*NodeInfo) Domain

func (ni *NodeInfo) Domain() string

Domain is the "signature domain" used when signing and verifying an record.Record

func (*NodeInfo) GetNodeInfo added in v1.1.0

func (ni *NodeInfo) GetNodeInfo() *NodeInfo

GetNodeInfo returns a value representation of the info

func (*NodeInfo) MarshalRecord

func (ni *NodeInfo) MarshalRecord() ([]byte, error)

MarshalRecord converts a Record instance to a []byte, so that it can be used as an Envelope payload

func (*NodeInfo) Seal

func (ni *NodeInfo) Seal(privateKey crypto.PrivKey) ([]byte, error)

Seal seals and encodes the record to be sent to other peers

func (*NodeInfo) UnmarshalRecord

func (ni *NodeInfo) UnmarshalRecord(data []byte) error

UnmarshalRecord unmarshals a []byte payload into an instance of a particular Record type

type NodeMetadata

type NodeMetadata struct {
	// NodeVersion is the ssv-node version, it is a required field
	NodeVersion string
	// ExecutionNode is the "name/version" of the eth1 node
	ExecutionNode string
	// ConsensusNode is the "name/version" of the beacon node
	ConsensusNode string
	// Subnets represents the subnets that our node is subscribed to
	Subnets string
}

NodeMetadata holds node's general information

func (*NodeMetadata) Decode

func (nm *NodeMetadata) Decode(data []byte) error

Decode decodes a raw payload into metadata TODO: switch to SSZ

func (*NodeMetadata) Encode

func (nm *NodeMetadata) Encode() ([]byte, error)

Encode encodes the metadata into bytes TODO: switch to SSZ

type SignedNodeInfo added in v1.1.0

type SignedNodeInfo struct {
	NodeInfo      *NodeInfo
	HandshakeData HandshakeData
	Signature     []byte
}

func (*SignedNodeInfo) Codec added in v1.1.0

func (sni *SignedNodeInfo) Codec() []byte

func (*SignedNodeInfo) Consume added in v1.1.0

func (sni *SignedNodeInfo) Consume(data []byte) error

Consume takes a raw envelope and extracts the parsed record

func (*SignedNodeInfo) Domain added in v1.1.0

func (sni *SignedNodeInfo) Domain() string

func (*SignedNodeInfo) GetNodeInfo added in v1.1.0

func (sni *SignedNodeInfo) GetNodeInfo() *NodeInfo

GetNodeInfo returns inner representation of the info

func (*SignedNodeInfo) MarshalRecord added in v1.1.0

func (sni *SignedNodeInfo) MarshalRecord() ([]byte, error)

MarshalRecord serializes SignedNodeInfo IMPORTANT: MarshalRecord rounds SignedNodeInfo.HandshakeData.Timestamp to seconds

func (*SignedNodeInfo) Seal added in v1.1.0

func (sni *SignedNodeInfo) Seal(netPrivateKey crypto.PrivKey) ([]byte, error)

Seal seals and encodes the record to be sent to other peers IMPORTANT: Seal rounds sni.HandshakeData.Timestamp to seconds

func (*SignedNodeInfo) UnmarshalRecord added in v1.1.0

func (sni *SignedNodeInfo) UnmarshalRecord(data []byte) error

type Subnets added in v0.3.0

type Subnets []byte

Subnets holds all the subscribed subnets of a specific node

func (Subnets) Active added in v0.5.3

func (s Subnets) Active() int

func (Subnets) Clone added in v0.3.0

func (s Subnets) Clone() Subnets

Clone clones the independent byte slice

func (Subnets) FromString added in v0.3.0

func (s Subnets) FromString(subnetsStr string) (Subnets, error)

FromString parses a given subnet string

func (Subnets) String added in v0.3.0

func (s Subnets) String() string

Jump to

Keyboard shortcuts

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