eth1

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContractABI added in v0.0.6

func ContractABI() string

ContractABI abi of the ssv-network contract

func LoadABI added in v0.0.6

func LoadABI(abiFilePath string) error

LoadABI enables to load a custom abi json

func SyncEth1Events added in v0.0.4

func SyncEth1Events(logger *zap.Logger, client Client, storage SyncOffsetStorage, syncOffset *SyncOffset, handler SyncEventHandler) error

SyncEth1Events sync past events

Types

type Client

type Client interface {
	EventsSubject() pubsub.Subscriber
	Start() error
	Sync(fromBlock *big.Int) error
}

Client represents the required interface for eth1 client

type ClientMock added in v0.0.16

type ClientMock struct {
	Sub pubsub.Subject

	SyncTimeout  time.Duration
	SyncResponse error
}

ClientMock implements eth1.Client interface

func (*ClientMock) EventsSubject added in v0.0.16

func (ec *ClientMock) EventsSubject() pubsub.Subscriber

EventsSubject mocking subject

func (*ClientMock) Start added in v0.0.16

func (ec *ClientMock) Start() error

Start mocking client init

func (*ClientMock) Sync added in v0.0.16

func (ec *ClientMock) Sync(fromBlock *big.Int) error

Sync mocking events sync

type Event

type Event struct {
	Log  types.Log
	Data interface{}
}

Event represents an eth1 event log in the system

type Oess

type Oess struct {
	Index             *big.Int
	OperatorPublicKey []byte
	SharedPublicKey   []byte
	EncryptedKey      []byte
}

Oess struct stands for operator encrypted secret share

type OperatorAddedEvent

type OperatorAddedEvent struct {
	Name           string
	PublicKey      []byte
	PaymentAddress common.Address
	OwnerAddress   common.Address
}

OperatorAddedEvent struct represents event received by the smart contract

func ParseOperatorAddedEvent added in v0.0.4

func ParseOperatorAddedEvent(logger *zap.Logger, operatorPrivateKey *rsa.PrivateKey, data []byte, contractAbi abi.ABI) (*OperatorAddedEvent, bool, error)

ParseOperatorAddedEvent parses an OperatorAddedEvent

type Options added in v0.0.6

type Options struct {
	ETH1Addr              string        `yaml:"ETH1Addr" env:"ETH_1_ADDR" env-required:"true" env-description:"ETH1 node WebSocket address"`
	ETH1SyncOffset        string        `yaml:"ETH1SyncOffset" env:"ETH_1_SYNC_OFFSET" env-description:"block number to start the sync from"`
	ETH1ConnectionTimeout time.Duration `yaml:"ETH1ConnectionTimeout" env:"ETH_1_CONNECTION_TIMEOUT" env-default:"10s" env-description:"eth1 node connection timeout"`
	RegistryContractAddr  string        `` /* 161-byte string literal not displayed */
	RegistryContractABI   string        `yaml:"RegistryContractABI" env:"REGISTRY_CONTRACT_ABI" env-description:"registry contract abi json file"`
	CleanRegistryData     bool          `` /* 156-byte string literal not displayed */
}

Options configurations related to eth1

type ShareEncryptionKeyProvider added in v0.0.6

type ShareEncryptionKeyProvider = func() (*rsa.PrivateKey, bool, error)

ShareEncryptionKeyProvider is a function that returns the operator private key

type SyncEndedEvent

type SyncEndedEvent struct {
	// Success returns true if the sync went well (all events were parsed)
	Success bool
	// Logs is the actual logs that we got from eth1
	Logs []types.Log
}

SyncEndedEvent meant to notify an observer that the sync is over

type SyncEventHandler added in v0.0.18

type SyncEventHandler func(Event) error

SyncEventHandler handles a given event

type SyncOffset added in v0.0.4

type SyncOffset = big.Int

SyncOffset is the type of variable used for passing around the offset

func DefaultSyncOffset added in v0.0.4

func DefaultSyncOffset() *SyncOffset

DefaultSyncOffset returns the default value (block number of the first event from the contract)

func HexStringToSyncOffset added in v0.0.4

func HexStringToSyncOffset(shex string) *SyncOffset

HexStringToSyncOffset converts an hex string to SyncOffset

type SyncOffsetStorage added in v0.0.4

type SyncOffsetStorage interface {
	// SaveSyncOffset saves the offset (block number)
	SaveSyncOffset(offset *SyncOffset) error
	// GetSyncOffset returns the sync offset
	GetSyncOffset() (*SyncOffset, bool, error)
}

SyncOffsetStorage represents the interface for compatible storage

type ValidatorAddedEvent

type ValidatorAddedEvent struct {
	PublicKey    []byte
	OwnerAddress common.Address
	OessList     []Oess
}

ValidatorAddedEvent struct represents event received by the smart contract

func ParseValidatorAddedEvent added in v0.0.4

func ParseValidatorAddedEvent(logger *zap.Logger, operatorPrivateKey *rsa.PrivateKey, data []byte, contractAbi abi.ABI) (*ValidatorAddedEvent, bool, error)

ParseValidatorAddedEvent parses ValidatorAddedEvent

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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