Documentation
¶
Index ¶
- Constants
- Variables
- func EnsureBLSToExecutionConfigIsValid(cfg *BLSToExecutionConfig) error
- func EnsureDepositConfigIsValid(cfg *DepositConfig) error
- func GenerateBLSToExecutionMessages(state *State[BLSToExecutionConfig]) ([]*types.SignedBLSToExecution, error)
- func GenerateDeposits(state *State[DepositConfig]) ([]*types.Deposit, []*keystore.Keystore, error)
- func GenerateMnemonic(state *State[DepositConfig]) ([]string, words.List, error)
- func IsValidAmount(amount uint64) bool
- func IsValidIndex(index, from, to uint32) bool
- func LanguageFromMnemonicConfig(cfg *MnemonicConfig) words.List
- type Address
- type Amount
- type BLSToExecution
- type BLSToExecutionConfig
- type BLSToExecutionConfigBuilder
- func (b *BLSToExecutionConfigBuilder) Build() (*BLSToExecutionConfig, error)
- func (b *BLSToExecutionConfigBuilder) Chain(name string) *BLSToExecutionConfigBuilder
- func (b *BLSToExecutionConfigBuilder) Directory(directory string) *BLSToExecutionConfigBuilder
- func (b *BLSToExecutionConfigBuilder) EngineWorkers(workers int) *BLSToExecutionConfigBuilder
- func (b *BLSToExecutionConfigBuilder) GenesisForkVersion(forkVersion []byte) *BLSToExecutionConfigBuilder
- func (b *BLSToExecutionConfigBuilder) GenesisValidatorsRoot(validatorsRoot []byte) *BLSToExecutionConfigBuilder
- func (b *BLSToExecutionConfigBuilder) MnemonicLanguage(language string) *BLSToExecutionConfigBuilder
- func (b *BLSToExecutionConfigBuilder) Number(number uint32) *BLSToExecutionConfigBuilder
- func (b *BLSToExecutionConfigBuilder) StartIndex(index uint32) *BLSToExecutionConfigBuilder
- func (b *BLSToExecutionConfigBuilder) ValidatorIndices(indices ...string) *BLSToExecutionConfigBuilder
- func (b *BLSToExecutionConfigBuilder) WithdrawalAddresses(addresses ...string) *BLSToExecutionConfigBuilder
- type BLSToExecutionEngine
- type Config
- type ConfigConstraint
- type Deposit
- type DepositConfig
- type DepositConfigBuilder
- func (b *DepositConfigBuilder) Amounts(amounts ...string) *DepositConfigBuilder
- func (b *DepositConfigBuilder) Build() (*DepositConfig, error)
- func (b *DepositConfigBuilder) Chain(name string) *DepositConfigBuilder
- func (b *DepositConfigBuilder) ContractAddresses(addresses ...string) *DepositConfigBuilder
- func (b *DepositConfigBuilder) Directory(directory string) *DepositConfigBuilder
- func (b *DepositConfigBuilder) EngineWorkers(workers int) *DepositConfigBuilder
- func (b *DepositConfigBuilder) GenesisForkVersion(forkVersion []byte) *DepositConfigBuilder
- func (b *DepositConfigBuilder) GenesisValidatorsRoot(validatorsRoot []byte) *DepositConfigBuilder
- func (b *DepositConfigBuilder) KeystoreKDF(kdf string) *DepositConfigBuilder
- func (b *DepositConfigBuilder) MnemonicBitlen(bitlen uint) *DepositConfigBuilder
- func (b *DepositConfigBuilder) MnemonicLanguage(language string) *DepositConfigBuilder
- func (b *DepositConfigBuilder) Number(number uint32) *DepositConfigBuilder
- func (b *DepositConfigBuilder) StartIndex(index uint32) *DepositConfigBuilder
- func (b *DepositConfigBuilder) WithdrawalAddresses(addresses ...string) *DepositConfigBuilder
- type DepositEngine
- type IndexedConfig
- type IndexedConfigWithDefault
- type MnemonicConfig
- type State
Constants ¶
const DefaultOutputDirectory = "./validators_data"
Variables ¶
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
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
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 ¶
GenerateDeposits generates all deposits and keystores according to the config
func GenerateMnemonic ¶
GenerateMnemonic generates new seed phrase
func IsValidAmount ¶
IsValidAmount returns false if amount less than MinDepositAmount or greater than MaxDepositAmount
func IsValidIndex ¶
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 ¶
type Address [config.ExecutionAddressLength]byte
Address type
func (*Address) MarshalJSON ¶
func (Address) ToChecksumHex ¶
ToChecksumHex returns address in hex format with EIP-55 address checksum
func (*Address) UnmarshalJSON ¶
type Amount ¶
type Amount uint64
Amount wrapper
func (*Amount) FromString ¶
FromString parses value from string (optionally with prefix)
func (*Amount) MarshalJSON ¶
func (*Amount) UnmarshalJSON ¶
type BLSToExecution ¶ added in v1.0.0
type BLSToExecution struct {
// contains filtered or unexported fields
}
BLSToExecution...
func (*BLSToExecution) Unwrap ¶ added in v1.0.0
func (m *BLSToExecution) Unwrap() (uint32, *types.SignedBLSToExecution)
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 (b *BLSToExecutionConfigBuilder) Build() (*BLSToExecutionConfig, error)
func (*BLSToExecutionConfigBuilder) Chain ¶ added in v1.0.0
func (b *BLSToExecutionConfigBuilder) Chain(name string) *BLSToExecutionConfigBuilder
func (*BLSToExecutionConfigBuilder) Directory ¶ added in v1.0.0
func (b *BLSToExecutionConfigBuilder) Directory(directory string) *BLSToExecutionConfigBuilder
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 (b *BLSToExecutionConfigBuilder) Number(number uint32) *BLSToExecutionConfigBuilder
func (*BLSToExecutionConfigBuilder) StartIndex ¶ added in v1.0.0
func (b *BLSToExecutionConfigBuilder) StartIndex(index uint32) *BLSToExecutionConfigBuilder
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
func (e *BLSToExecutionEngine) Generate(ctx context.Context) ([]*types.SignedBLSToExecution, error)
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...
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 (b *DepositConfigBuilder) Chain(name string) *DepositConfigBuilder
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 (b *DepositConfigBuilder) Number(number uint32) *DepositConfigBuilder
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 ¶
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 ¶
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]