app

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultOutputDirectory = "./validators_data"

Variables

View Source
var (
	ErrInvalidGenesisForkVersion    = fmt.Errorf("invalid genesis fork version length, must be 4 bytes")
	ErrInvalidGenesisValidatorsRoot = fmt.Errorf("invalid genesis validators root length, must be 32 bytes")

	ErrInvalidMnemonicLanguage = fmt.Errorf("invalid language (only %s allowed)", strings.Join(allowedLanguagesNames[:], ", "))
	ErrInvalidMnemonicBitlen   = fmt.Errorf("invalid bitlen (only 128, 160, 192, 244, 256 allowed)")
)

Config validation errors

View Source
var (
	ErrInvalidKDF = fmt.Errorf(
		"invalid key derivation function (only %s allowed)",
		strings.Join([]string{keystore.ScryptName, keystore.PBKDF2Name}, ", "),
	)

	ErrInvalidAmount = fmt.Errorf(
		"invalid amount (should be between %d and %d and divisible by %d)",
		config.MinDepositAmount,
		config.MaxDepositAmount,
		uint64(config.GweiPerEther),
	)
)

DepositConfig validation errors

View Source
var (
	ErrNoWithdrawalAddresses = errors.New("no withdrawal addresses provided for BLS to Execution transition")
	ErrNoValidatorIndices    = errors.New("no validator indices provided for BLS to Execution transition")
)

BLSToExecutionConfig validation errors

Functions

func EnsureBLSToExecutionConfigIsValid

func EnsureBLSToExecutionConfigIsValid(cfg *BLSToExecutionConfig) error

EnsureBLSToExecutionConfigIsValid validates all bls to execution generation related configurations

func EnsureDepositConfigIsValid

func EnsureDepositConfigIsValid(cfg *DepositConfig) error

EnsureDepositConfigIsValid validates all deposit generation related configurations

func GenerateBLSToExecutionMessages

func GenerateBLSToExecutionMessages(state *State[BLSToExecutionConfig]) ([]*types.SignedBLSToExecution, error)

GenerateDeposits generates all bls to execution messages according to the config

func GenerateDeposits

func GenerateDeposits(state *State[DepositConfig]) ([]*types.Deposit, []*keystore.Keystore, error)

GenerateDeposits generates all deposits and keystores according to the config

func GenerateMnemonic

func GenerateMnemonic(state *State[DepositConfig]) ([]string, words.List, error)

GenerateMnemonic generates new seed phrase

func IsValidAmount

func IsValidAmount(amount uint64) bool

IsValidAmount returns false if amount less than MinDepositAmount or greater than MaxDepositAmount

func IsValidIndex

func IsValidIndex(index, from, to uint32) bool

IsValidIndex returns false if index less than from or greater than to

func LanguageFromMnemonicConfig

func LanguageFromMnemonicConfig(cfg *MnemonicConfig) words.List

LanguageFromMnemonicConfig returns words list from config

Types

type Address

Address type

func (*Address) FromHex

func (a *Address) FromHex(hexstr string) error

FromHex parses hex string

func (*Address) MarshalJSON

func (a *Address) MarshalJSON() ([]byte, error)

func (Address) ToChecksumHex

func (a Address) ToChecksumHex() string

ToChecksumHex returns address in hex format with EIP-55 address checksum

func (Address) ToHex

func (a Address) ToHex() string

ToHex returns address in hex format

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(data []byte) error

type Amount

type Amount uint64

Amount wrapper

func (Amount) Ether

func (a Amount) Ether() uint64

Ether returns amount in Ether

func (*Amount) FromString

func (a *Amount) FromString(amount string) error

FromString parses value from string (optionally with prefix)

func (Amount) Gwei

func (a Amount) Gwei() uint64

Gwei returns amount in Gwei

func (*Amount) MarshalJSON

func (a *Amount) MarshalJSON() ([]byte, error)

func (Amount) ToString

func (a Amount) ToString(suffix string) string

ToString returns string representation of amount with suffix

func (*Amount) UnmarshalJSON

func (a *Amount) UnmarshalJSON(data []byte) error

type BLSToExecution added in v1.0.0

type BLSToExecution struct {
	// contains filtered or unexported fields
}

BLSToExecution...

func (*BLSToExecution) Unwrap added in v1.0.0

type BLSToExecutionConfig

type BLSToExecutionConfig struct {
	*Config

	ValidatorIndices    *IndexedConfig[uint64]             `json:"validator_indices,omitempty"`
	WithdrawalAddresses *IndexedConfigWithDefault[Address] `json:"withdrawal_addresses,omitempty"`
}

BLSToExecutionConfig stores all bls to execution generation related data

type BLSToExecutionConfigBuilder added in v1.0.0

type BLSToExecutionConfigBuilder struct {
	// contains filtered or unexported fields
}

func NewBLSToExecutionConfigBuilder added in v1.0.0

func NewBLSToExecutionConfigBuilder() *BLSToExecutionConfigBuilder

func (*BLSToExecutionConfigBuilder) Build added in v1.0.0

func (*BLSToExecutionConfigBuilder) Chain added in v1.0.0

func (*BLSToExecutionConfigBuilder) Directory added in v1.0.0

func (*BLSToExecutionConfigBuilder) EngineWorkers added in v1.0.0

func (b *BLSToExecutionConfigBuilder) EngineWorkers(workers int) *BLSToExecutionConfigBuilder

func (*BLSToExecutionConfigBuilder) GenesisForkVersion added in v1.0.0

func (b *BLSToExecutionConfigBuilder) GenesisForkVersion(forkVersion []byte) *BLSToExecutionConfigBuilder

func (*BLSToExecutionConfigBuilder) GenesisValidatorsRoot added in v1.0.0

func (b *BLSToExecutionConfigBuilder) GenesisValidatorsRoot(validatorsRoot []byte) *BLSToExecutionConfigBuilder

func (*BLSToExecutionConfigBuilder) MnemonicLanguage added in v1.0.0

func (b *BLSToExecutionConfigBuilder) MnemonicLanguage(language string) *BLSToExecutionConfigBuilder

func (*BLSToExecutionConfigBuilder) Number added in v1.0.0

func (*BLSToExecutionConfigBuilder) StartIndex added in v1.0.0

func (*BLSToExecutionConfigBuilder) ValidatorIndices added in v1.0.0

func (b *BLSToExecutionConfigBuilder) ValidatorIndices(indices ...string) *BLSToExecutionConfigBuilder

func (*BLSToExecutionConfigBuilder) WithdrawalAddresses added in v1.0.0

func (b *BLSToExecutionConfigBuilder) WithdrawalAddresses(addresses ...string) *BLSToExecutionConfigBuilder

type BLSToExecutionEngine added in v1.0.0

type BLSToExecutionEngine struct {
	*State[BLSToExecutionConfig]
	// contains filtered or unexported fields
}

BLSToExecutionEngine...

func NewBLSToExecutionEngine added in v1.0.0

func NewBLSToExecutionEngine(state *State[BLSToExecutionConfig]) *BLSToExecutionEngine

NewBLSToExecutionEngine...

func (*BLSToExecutionEngine) Generate added in v1.0.0

GenerateDeposits generates all bls to execution messages according to the config concurrently

func (*BLSToExecutionEngine) OnBLSToExecution added in v1.0.0

func (e *BLSToExecutionEngine) OnBLSToExecution(onBLSToExecution func(*BLSToExecution) error) *BLSToExecutionEngine

OnBLSToExecution sets the function which will be called once BLSToExecution message is generated

type Config

type Config struct {
	StartIndex uint32 `json:"start_index"`
	Number     uint32 `json:"number"`

	ChainConfig    *config.ChainConfig `json:"chain_config,omitempty"`
	MnemonicConfig *MnemonicConfig     `json:"mnemonic_config,omitempty"`

	Directory string `json:"directory"`

	EngineWorkers int `json:"-"`
}

Config is a base config

type ConfigConstraint added in v1.0.0

type ConfigConstraint interface {
	DepositConfig | BLSToExecutionConfig
}

type Deposit added in v1.0.0

type Deposit struct {
	// contains filtered or unexported fields
}

Deposit...

func (*Deposit) Unwrap added in v1.0.0

func (d *Deposit) Unwrap() (uint32, *types.Deposit, *keystore.Keystore)

type DepositConfig

type DepositConfig struct {
	*Config

	Amounts             *IndexedConfigWithDefault[Amount]  `json:"amounts,omitempty"`
	WithdrawalAddresses *IndexedConfigWithDefault[Address] `json:"withdrawal_addresses,omitempty"`

	ContractAddresses *IndexedConfig[Address] `json:"contract_addresses,omitempty"`

	KeystoreKeyDerivationFunction string `json:"kdf,omitempty"`
}

DepositConfig stores all deposit generation related data

type DepositConfigBuilder added in v1.0.0

type DepositConfigBuilder struct {
	// contains filtered or unexported fields
}

func NewDepositConfigBuilder added in v1.0.0

func NewDepositConfigBuilder() *DepositConfigBuilder

func (*DepositConfigBuilder) Amounts added in v1.0.0

func (b *DepositConfigBuilder) Amounts(amounts ...string) *DepositConfigBuilder

func (*DepositConfigBuilder) Build added in v1.0.0

func (b *DepositConfigBuilder) Build() (*DepositConfig, error)

func (*DepositConfigBuilder) Chain added in v1.0.0

func (*DepositConfigBuilder) ContractAddresses added in v1.0.0

func (b *DepositConfigBuilder) ContractAddresses(addresses ...string) *DepositConfigBuilder

func (*DepositConfigBuilder) Directory added in v1.0.0

func (b *DepositConfigBuilder) Directory(directory string) *DepositConfigBuilder

func (*DepositConfigBuilder) EngineWorkers added in v1.0.0

func (b *DepositConfigBuilder) EngineWorkers(workers int) *DepositConfigBuilder

func (*DepositConfigBuilder) GenesisForkVersion added in v1.0.0

func (b *DepositConfigBuilder) GenesisForkVersion(forkVersion []byte) *DepositConfigBuilder

func (*DepositConfigBuilder) GenesisValidatorsRoot added in v1.0.0

func (b *DepositConfigBuilder) GenesisValidatorsRoot(validatorsRoot []byte) *DepositConfigBuilder

func (*DepositConfigBuilder) KeystoreKDF added in v1.0.0

func (b *DepositConfigBuilder) KeystoreKDF(kdf string) *DepositConfigBuilder

func (*DepositConfigBuilder) MnemonicBitlen added in v1.0.0

func (b *DepositConfigBuilder) MnemonicBitlen(bitlen uint) *DepositConfigBuilder

func (*DepositConfigBuilder) MnemonicLanguage added in v1.0.0

func (b *DepositConfigBuilder) MnemonicLanguage(language string) *DepositConfigBuilder

func (*DepositConfigBuilder) Number added in v1.0.0

func (*DepositConfigBuilder) StartIndex added in v1.0.0

func (b *DepositConfigBuilder) StartIndex(index uint32) *DepositConfigBuilder

func (*DepositConfigBuilder) WithdrawalAddresses added in v1.0.0

func (b *DepositConfigBuilder) WithdrawalAddresses(addresses ...string) *DepositConfigBuilder

type DepositEngine added in v1.0.0

type DepositEngine struct {
	*State[DepositConfig]
	// contains filtered or unexported fields
}

DepositEngine...

func NewDepositEngine added in v1.0.0

func NewDepositEngine(state *State[DepositConfig]) *DepositEngine

NewDepositEngine...

func (*DepositEngine) Generate added in v1.0.0

func (e *DepositEngine) Generate(ctx context.Context) ([]*types.Deposit, []*keystore.Keystore, error)

Generate generates all deposits and keystores according to the config concurrently

func (*DepositEngine) OnDeposit added in v1.0.0

func (e *DepositEngine) OnDeposit(onDeposit func(*Deposit) error) *DepositEngine

OnDeposit sets the function which will be called once Deposit and Keystore is generated

type IndexedConfig

type IndexedConfig[T any] struct {
	Config map[uint32]T `json:"config"`
}

IndexedConfig stores values by key index

func (*IndexedConfig[T]) Get

func (cfg *IndexedConfig[T]) Get(index uint32) (T, bool)

Get value by key index if exist

type IndexedConfigWithDefault

type IndexedConfigWithDefault[T any] struct {
	Default T `json:"default"`
	IndexedConfig[T]
}

IndexedConfigWithDefault stroes values by key index and default value

func (*IndexedConfigWithDefault[T]) Get

func (cfg *IndexedConfigWithDefault[T]) Get(index uint32) T

Get value by key index or default

type MnemonicConfig

type MnemonicConfig struct {
	Language string `json:"language"`
	Bitlen   uint   `json:"bitlen"`
}

MnemonicConfig config

type State added in v1.0.0

type State[Config ConfigConstraint] struct {
	// contains filtered or unexported fields
}

func NewState added in v1.0.0

func NewState[Config ConfigConstraint](cfg *Config) *State[Config]

func (*State[Config]) Config added in v1.0.0

func (s *State[Config]) Config() *Config

func (*State[Config]) Mnemonic added in v1.0.0

func (s *State[Config]) Mnemonic() []string

func (*State[Config]) WithMnemonic added in v1.0.0

func (s *State[Config]) WithMnemonic(menmonic []string, list words.List) *State[Config]

func (*State[Config]) WithPassword added in v1.0.0

func (s *State[Config]) WithPassword(password string) *State[Config]

func (*State[Config]) Words added in v1.0.0

func (s *State[Config]) Words() words.List

Jump to

Keyboard shortcuts

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