Documentation ¶
Overview ¶
Package powchain defines the services that interact with the ETH1.0 of Ethereum.
Index ¶
- type Client
- type POWBlockFetcher
- type Reader
- type Web3Service
- func (w *Web3Service) ChainStartDeposits() []*pb.Deposit
- func (w *Web3Service) ChainStartFeed() *event.Feed
- func (w *Web3Service) Client() Client
- func (w *Web3Service) HasChainStartLogOccurred() (bool, uint64, error)
- func (w *Web3Service) LatestBlockHash() common.Hash
- func (w *Web3Service) LatestBlockNumber() *big.Int
- func (w *Web3Service) ProcessChainStartLog(VRClog gethTypes.Log)
- func (w *Web3Service) ProcessDepositLog(VRClog gethTypes.Log)
- func (w *Web3Service) ProcessLog(VRClog gethTypes.Log)
- func (w *Web3Service) Start()
- func (w *Web3Service) Status() error
- func (w *Web3Service) Stop() error
- type Web3ServiceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Reader POWBlockFetcher bind.ContractFilterer bind.ContractCaller }
Client defines a struct that combines all relevant ETH1.0 mainchain interactions required by the beacon chain node.
type POWBlockFetcher ¶
type POWBlockFetcher interface {
BlockByHash(ctx context.Context, hash common.Hash) (*gethTypes.Block, error)
}
POWBlockFetcher defines a struct that can retrieve mainchain blocks.
type Reader ¶
type Reader interface {
SubscribeNewHead(ctx context.Context, ch chan<- *gethTypes.Header) (ethereum.Subscription, error)
}
Reader defines a struct that can fetch latest header events from a web3 endpoint.
type Web3Service ¶
type Web3Service struct {
// contains filtered or unexported fields
}
Web3Service fetches important information about the canonical Ethereum ETH1.0 chain via a web3 endpoint using an ethclient. The Random Beacon Chain requires synchronization with the ETH1.0 chain's current blockhash, block number, and access to logs within the Validator Registration Contract on the ETH1.0 chain to kick off the beacon chain's validator registration process.
func NewWeb3Service ¶
func NewWeb3Service(ctx context.Context, config *Web3ServiceConfig) (*Web3Service, error)
NewWeb3Service sets up a new instance with an ethclient when given a web3 endpoint as a string in the config.
func (*Web3Service) ChainStartDeposits ¶
func (w *Web3Service) ChainStartDeposits() []*pb.Deposit
ChainStartDeposits returns a slice of validator deposits processed by the deposit contract and cached in the powchain service.
func (*Web3Service) ChainStartFeed ¶
func (w *Web3Service) ChainStartFeed() *event.Feed
ChainStartFeed returns a feed that is written to whenever the deposit contract fires a ChainStart log.
func (*Web3Service) Client ¶
func (w *Web3Service) Client() Client
Client for interacting with the ETH1.0 chain.
func (*Web3Service) HasChainStartLogOccurred ¶
func (w *Web3Service) HasChainStartLogOccurred() (bool, uint64, error)
HasChainStartLogOccurred queries all logs in the deposit contract to verify if ChainStart has occurred. If so, it returns true alongside the ChainStart timestamp.
func (*Web3Service) LatestBlockHash ¶
func (w *Web3Service) LatestBlockHash() common.Hash
LatestBlockHash in the ETH1.0 chain.
func (*Web3Service) LatestBlockNumber ¶
func (w *Web3Service) LatestBlockNumber() *big.Int
LatestBlockNumber in the ETH1.0 chain.
func (*Web3Service) ProcessChainStartLog ¶
func (w *Web3Service) ProcessChainStartLog(VRClog gethTypes.Log)
ProcessChainStartLog processes the log which had been received from the ETH1.0 chain by trying to determine when to start the beacon chain.
func (*Web3Service) ProcessDepositLog ¶
func (w *Web3Service) ProcessDepositLog(VRClog gethTypes.Log)
ProcessDepositLog processes the log which had been received from the ETH1.0 chain by trying to ascertain which participant deposited in the contract.
func (*Web3Service) ProcessLog ¶
func (w *Web3Service) ProcessLog(VRClog gethTypes.Log)
ProcessLog is the main method which handles the processing of all logs from the deposit contract on the ETH1.0 chain.
func (*Web3Service) Status ¶
func (w *Web3Service) Status() error
Status always returns nil. TODO(1204): Add service health checks.
func (*Web3Service) Stop ¶
func (w *Web3Service) Stop() error
Stop the web3 service's main event loop and associated goroutines.
type Web3ServiceConfig ¶
type Web3ServiceConfig struct { Endpoint string DepositContract common.Address Client Client Reader Reader Logger bind.ContractFilterer ContractBackend bind.ContractBackend BeaconDB *db.BeaconDB }
Web3ServiceConfig defines a config struct for web3 service to use through its life cycle.