swcommon

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Stakewise validators deposit a full 32 ETH
	StakewiseDepositAmount uint64 = 32e9
)

Variables

This section is empty.

Functions

func GetNodesetStatus added in v1.0.0

func GetNodesetStatus(pubKey beacon.ValidatorPubkey, registeredPubkeysStatusMapping map[beacon.ValidatorPubkey]stakewise.StakeWiseStatus) swtypes.NodesetStatus

func IsUploadedToNodeset added in v0.1.2

func IsUploadedToNodeset(pubKey beacon.ValidatorPubkey, registeredPubkeys []beacon.ValidatorPubkey) bool

Types

type DepositDataManager

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

DepositDataManager manages the aggregated deposit data file that Stakewise uses

func NewDepositDataManager

func NewDepositDataManager(sp IStakeWiseServiceProvider) (*DepositDataManager, error)

Creates a new manager

func (*DepositDataManager) ComputeMerkleRoot

func (m *DepositDataManager) ComputeMerkleRoot(data []beacon.ExtendedDepositData) (common.Hash, error)

Compute the Merkle root of the aggregated deposit data using the Stakewise rules NOTE: reverse engineered from https://github.com/stakewise/v3-operator/blob/fa4ac2673a64a486ced51098005376e56e2ddd19/src/validators/utils.py#L207

func (*DepositDataManager) GenerateDepositData

func (m *DepositDataManager) GenerateDepositData(logger *slog.Logger, keys []*eth2types.BLSPrivateKey) ([]beacon.ExtendedDepositData, error)

Generates deposit data for the provided keys

func (*DepositDataManager) GetDepositData

func (m *DepositDataManager) GetDepositData() ([]byte, error)

Read the deposit data file

func (*DepositDataManager) UpdateDepositData

func (m *DepositDataManager) UpdateDepositData(data []beacon.ExtendedDepositData) error

Save the deposit data file

type IDepositDataManagerProvider added in v1.1.0

type IDepositDataManagerProvider interface {
	// Gets the deposit data manager
	GetDepositDataManager() *DepositDataManager
}

Provides the deposit data manager

type IStakeWiseConfigProvider added in v1.1.0

type IStakeWiseConfigProvider interface {
	// Gets the StakeWise config
	GetConfig() *swconfig.StakeWiseConfig

	// Gets the StakeWise resources
	GetResources() *swconfig.MergedResources
}

Provides the StakeWise module config and resources

type IStakeWiseRequirementsProvider added in v1.1.0

type IStakeWiseRequirementsProvider interface {
	RequireStakewiseWalletReady(ctx context.Context, status wallet.WalletStatus) error
	WaitForStakewiseWallet(ctx context.Context) error
}

Provides requirements for the StakeWise daemon

type IStakeWiseServiceProvider added in v1.1.0

func NewStakeWiseServiceProvider added in v1.0.0

func NewStakeWiseServiceProvider(sp services.IModuleServiceProvider, settingsList []*swconfig.StakeWiseSettings) (IStakeWiseServiceProvider, error)

Create a new service provider with Stakewise daemon-specific features

func NewStakeWiseServiceProviderFromCustomServices added in v1.0.0

func NewStakeWiseServiceProviderFromCustomServices(sp services.IModuleServiceProvider, cfg *swconfig.StakeWiseConfig, resources *swconfig.MergedResources) (IStakeWiseServiceProvider, error)

Create a new service provider with Stakewise daemon-specific features, using custom services instead of loading them from the module service provider.

type IStakeWiseWalletProvider added in v1.1.0

type IStakeWiseWalletProvider interface {
	// Gets the wallet
	GetWallet() *Wallet
}

Provides the StakeWise wallet

type Wallet

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

Wallet manager for the Stakewise daemon

func NewWallet

func NewWallet(sp services.IModuleServiceProvider) (*Wallet, error)

Create a new wallet

func (*Wallet) CheckIfStakewiseWalletExists

func (w *Wallet) CheckIfStakewiseWalletExists() (bool, error)

Check if the Stakewise wallet and password files exist

func (*Wallet) DerivePubKeys

func (w *Wallet) DerivePubKeys(privateKeys []*eth2types.BLSPrivateKey) ([]beacon.ValidatorPubkey, error)

Get the private validator key with the corresponding pubkey

func (*Wallet) GenerateNewValidatorKey

func (w *Wallet) GenerateNewValidatorKey() (*eth2types.BLSPrivateKey, error)

Generate a new validator key and save it

func (*Wallet) GetAllPrivateKeys

func (w *Wallet) GetAllPrivateKeys() ([]*eth2types.BLSPrivateKey, error)

Gets all of the validator private keys that are stored in the Stakewise keystore folder

func (*Wallet) GetLatestDepositDataVersion

func (w *Wallet) GetLatestDepositDataVersion() int

Get the version of the aggregated deposit data from the NodeSet server that's stored on disk

func (*Wallet) GetPrivateKeyForPubkey

func (w *Wallet) GetPrivateKeyForPubkey(pubkey beacon.ValidatorPubkey) (*eth2types.BLSPrivateKey, error)

Get the private validator key with the corresponding pubkey

func (*Wallet) Reload added in v1.0.0

func (w *Wallet) Reload() error

Reload the wallet data from disk

func (*Wallet) SaveStakewiseWallet

func (w *Wallet) SaveStakewiseWallet(ethKey []byte, password string) error

Saves the Stakewise wallet and password files

func (*Wallet) SetLatestDepositDataVersion

func (w *Wallet) SetLatestDepositDataVersion(version int) error

Set the latest deposit data version and save the wallet data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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