eth1

package
v0.0.0-...-a2b18cf Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MaxEffectiveBalance of an active eth2 validator.
	MaxEffectiveBalance = uint64(32 * 1e9)
)

Functions

func BlockHeader

func BlockHeader(blockNum uint64) *types.Header

BlockHeader returns a block header with time.Now and a blockNum.

func ConstructBlocksByNumber

func ConstructBlocksByNumber(currentBlockNum uint64, blockTime time.Duration) map[uint64]*types.Header

ConstructBlocksByNumber builds a list of historical blocks down to block 0 from some current block number, used to simulate a real eth1 chain which can be queried for all of its blocks by their respective number.

func DepositCount

func DepositCount(deposits []*DepositData) [8]byte

DepositCount returns an encoded number of deposits.

func DepositEventLogs

func DepositEventLogs(deposits []*DepositData) ([]types.Log, error)

DepositEventLogs returns a list of eth1 logs that have occurred at a deposit contract address. This uses an internal list of deposit data to return instead of relying on a real network and parsing a real deposit contract for this information.

func DepositLogsID

func DepositLogsID() string

DepositLogsID returns the event hash from the ABI corresponding to fetching the deposit logs event.

func DepositMethodID

func DepositMethodID() string

DepositMethodID returns the ABI encoded method value as a hex string.

func DepositRoot

func DepositRoot(deposits []*DepositData) ([32]byte, error)

DepositRoot produces a hash tree root of a list of deposits to match the output of the deposit contract on the eth1 chain.

func PackDepositCount

func PackDepositCount(count []byte) ([]byte, error)

Types

type DepositData

type DepositData struct {
	Pubkey                []byte `json:"pubkey,omitempty" ssz-size:"48"`
	WithdrawalCredentials []byte `json:"withdrawal_credentials,omitempty" ssz-size:"32"`
	Amount                uint64 `json:"amount,omitempty"`
	Signature             []byte `json:"signature,omitempty" ssz-size:"96"`
}

DepositData defines an Ethereum 2.0 data structure used as part of the core protocol state transition - onboarding new active validators into the chain accordingly.

func CreateDepositData

func CreateDepositData(validatorKey []byte, withdrawalKey []byte, amountInGwei uint64) (*DepositData, error)

CreateDepositData takes in raw private key bytes and a deposit amount and generates the proper DepositData Eth2 struct type. This involves BLS signing the deposit, generating hashed withdrawal credentials, and including the public key from the validator's private key into the deposit struct.

type ForkData

type ForkData struct {
	CurrentVersion        [4]byte
	GenesisValidatorsRoot [32]byte
}

type SigningRoot

type SigningRoot struct {
	ObjectRoot [32]byte
	Domain     [32]byte
}

Jump to

Keyboard shortcuts

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