signing_automation_ethereum

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EphemeralDepositContractAddr = "0x4242424242424242424242424242424242424242"
	MainnetDepositContractAddr   = "0x00000000219ab540356cBB839Cbe05303d7705Fa"
	GoerliDepositContractAddr    = "0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b"
	EphemeralBeacon              = "https://eth.ephemeral.zeus.fyi"
	BeaconGenesisPath            = "/eth/v1/beacon/genesis"
	BeaconForkPath               = "/eth/v1/beacon/states/head/fork"
	BeaconVoluntaryExitPath      = "/eth/v1/beacon/pool/voluntary_exits"
)

Variables

View Source
var (
	Gwei   = big.NewInt(1e9)
	Szabo  = big.NewInt(1e12)
	Finney = big.NewInt(1e15)
	Ether  = big.NewInt(1e18)

	OneHundred                       = big.NewInt(100)
	ThirtyTwo                        = big.NewInt(32)
	ValidatorDeposit32Eth            = big.NewInt(1).Mul(Ether, ThirtyTwo)
	ValidatorDeposit32EthInGweiUnits = big.NewInt(1).Mul(Gwei, ThirtyTwo)
)

Functions

func ABIOpenFile

func ABIOpenFile(ctx context.Context, abiFile string) (*abi.ABI, error)

func DecryptKeystoreCipher

func DecryptKeystoreCipher(ctx context.Context, keystoreJSON map[string]interface{}, password string) ([]byte, error)

func DecryptKeystoreCipherIntoEthSignerBLS

func DecryptKeystoreCipherIntoEthSignerBLS(ctx context.Context, keystoreJSON map[string]interface{}, password string) (bls_signer.EthBLSAccount, error)

func ForceDirToEthSigningDirLocation

func ForceDirToEthSigningDirLocation() string

func GetCurrentForkVersion

func GetCurrentForkVersion(ctx context.Context, beacon string) (*spec.Version, error)

func GetEphemeralForkVersion

func GetEphemeralForkVersion(ctx context.Context) (*spec.Version, error)

func GetForkVersion

func GetForkVersion(ctx context.Context, beacon string) (*spec.Version, error)

func GetValidatorDepositPayload

func GetValidatorDepositPayload(ctx context.Context, depositParams *DepositDataParams) (web3_actions.SendContractTxPayload, error)

func GetValidatorDepositPayloadV2

func GetValidatorDepositPayloadV2(ctx context.Context, depositParams ExtendedDepositParams) (web3_actions.SendContractTxPayload, error)

func GetValidatorIndexFromPubkey

func GetValidatorIndexFromPubkey(ctx context.Context, beacon, pubkey string) (string, error)

func MultiplyEtherUnit

func MultiplyEtherUnit(mul int64, unit *big.Int) *big.Int

func MustReadAbiString

func MustReadAbiString(ctx context.Context, abiContents string) *abi.ABI

func PrintJSONSlice

func PrintJSONSlice(p filepaths.Path, dpParamSlice []*DepositDataParams, network string)

func ReadAbi

func ReadAbi(ctx context.Context, reader io.Reader) (*abi.ABI, error)

func ReadAbiString

func ReadAbiString(ctx context.Context, abiContents string) (*abi.ABI, error)

func SubmitVoluntaryExit

func SubmitVoluntaryExit(ctx context.Context, beacon string, ve *spec.SignedVoluntaryExit) error

func ValidateAndReturnBLSPubkeyBytes

func ValidateAndReturnBLSPubkeyBytes(blsPubKey string) ([]byte, error)

ValidateAndReturnBLSPubkeyBytes is borrowed from https://github.com/wealdtech/ethdo

func ValidateAndReturnEcdsaPubkeyBytes

func ValidateAndReturnEcdsaPubkeyBytes(ecdsaWithdrawalKey string) ([]byte, error)

ValidateAndReturnEcdsaPubkeyBytes is borrowed from https://github.com/wealdtech/ethdo

Types

type DepositDataJSON

type DepositDataJSON struct {
	Pubkey                string `json:"pubkey"`
	WithdrawalCredentials string `json:"withdrawal_credentials"`
	Signature             string `json:"signature"`
	Amount                int    `json:"amount"`
	DepositDataRoot       string `json:"deposit_data_root"`
	DepositMessageRoot    string `json:"deposit_message_root"`
	ForkVersion           string `json:"fork_version"`
}

func DepositDataParamsJSON

func DepositDataParamsJSON(dpParamSlice []*DepositDataParams) []DepositDataJSON

type DepositDataParams

type DepositDataParams struct {
	*spec.DepositData  `json:"deposit_data"`
	DepositDataRoot    [32]byte      `json:"deposit_data_root"`
	DepositMessageRoot [32]byte      `json:"deposit_message_root"`
	ForkVersion        *spec.Version `json:"fork_version"`
}

func (*DepositDataParams) FormatJSON

func (dd *DepositDataParams) FormatJSON() DepositDataJSON

func (*DepositDataParams) GetValidatorDepositParamsStringValues

func (dd *DepositDataParams) GetValidatorDepositParamsStringValues() ValidatorDepositParams

type ExtendedDepositParams

type ExtendedDepositParams struct {
	ValidatorDepositParams
	Amount             int    `json:"amount"`
	DepositMessageRoot string `json:"deposit_message_root"`
	ForkVersion        string `json:"fork_version"`
	NetworkName        string `json:"network_name,omitempty"`
	DepositCliVersion  string `json:"deposit_cli_version,omitempty"`
}

type ForkData

type ForkData struct {
	ExecutionOptimistic bool `json:"execution_optimistic"`
	Finalized           bool `json:"finalized"`
	Data                struct {
		PreviousVersion string `json:"previous_version"`
		CurrentVersion  string `json:"current_version"`
		Epoch           string `json:"epoch"`
	} `json:"data"`
}

type GenesisData

type GenesisData struct {
	Data struct {
		GenesisTime           string `json:"genesis_time"`
		GenesisValidatorsRoot string `json:"genesis_validators_root"`
		GenesisForkVersion    string `json:"genesis_fork_version"`
	} `json:"data"`
}

type ValidatorDepositGenerationParams

type ValidatorDepositGenerationParams struct {
	Fp                   filepaths.Path
	Mnemonic             string `json:"mnemonic"`
	Pw                   string `json:"hdWalletPassword"`
	ValidatorIndexOffset int    `json:"hdOffset"`
	NumValidators        int    `json:"validatorCount"`

	// used for looping derivations
	WithdrawalKeyIndexOffset int `json:"WdHdOffset"`
	NumWithdrawalKeys        int `json:"numWdKeys"`

	// used for network selection variables
	Network string `json:"network"`
}

func (*ValidatorDepositGenerationParams) DerivedKey

func (*ValidatorDepositGenerationParams) EthDepositEncryptionAndAddMetadata

func (vd *ValidatorDepositGenerationParams) EthDepositEncryptionAndAddMetadata(ctx context.Context, path string) (map[string]interface{}, error)

func (*ValidatorDepositGenerationParams) GenerateAgeEncryptedValidatorKeysInMemZipFile

func (vd *ValidatorDepositGenerationParams) GenerateAgeEncryptedValidatorKeysInMemZipFile(ctx context.Context, inMemFs memfs.MemFS, age age_encryption.Age) (*bytes.Buffer, error)

GenerateAgeEncryptedValidatorKeysInMemZipFile generates a zip file of validator keys encrypted with age, the unzipped contents are keystores/keystores.tar.gz.age

func (*ValidatorDepositGenerationParams) GenerateAndEncryptValidatorKeysFromSeedAndPath

func (vd *ValidatorDepositGenerationParams) GenerateAndEncryptValidatorKeysFromSeedAndPath(ctx context.Context) error

func (*ValidatorDepositGenerationParams) GenerateDerivedKeySigner

func (vd *ValidatorDepositGenerationParams) GenerateDerivedKeySigner(ctx context.Context, offset int) (bls_signer.EthBLSAccount, error)

func (*ValidatorDepositGenerationParams) GenerateDerivedWithdrawalKeys

func (vd *ValidatorDepositGenerationParams) GenerateDerivedWithdrawalKeys(ctx context.Context) ([]string, error)

func (*ValidatorDepositGenerationParams) GeneratePaddedBytesDefaultDerivedBLSWithdrawalKey

func (vd *ValidatorDepositGenerationParams) GeneratePaddedBytesDefaultDerivedBLSWithdrawalKey(ctx context.Context) ([]byte, error)

type ValidatorDepositParams

type ValidatorDepositParams struct {
	Pubkey                string `json:"pubkey"`
	WithdrawalCredentials string `json:"withdrawal_credentials"`
	Signature             string `json:"signature"`
	DepositDataRoot       string `json:"deposit_data_root"`
}

type ValidatorDepositSlice

type ValidatorDepositSlice []ExtendedDepositParams

func ParseValidatorDepositSliceJSON

func ParseValidatorDepositSliceJSON(ctx context.Context, p filepaths.Path) (ValidatorDepositSlice, error)

type ValidatorInfo

type ValidatorInfo struct {
	ExecutionOptimistic bool `json:"execution_optimistic"`
	Finalized           bool `json:"finalized"`
	Data                struct {
		Index     string `json:"index"`
		Balance   string `json:"balance"`
		Status    string `json:"status"`
		Validator struct {
			Pubkey                     string `json:"pubkey"`
			WithdrawalCredentials      string `json:"withdrawal_credentials"`
			EffectiveBalance           string `json:"effective_balance"`
			Slashed                    bool   `json:"slashed"`
			ActivationEligibilityEpoch string `json:"activation_eligibility_epoch"`
			ActivationEpoch            string `json:"activation_epoch"`
			ExitEpoch                  string `json:"exit_epoch"`
			WithdrawableEpoch          string `json:"withdrawable_epoch"`
		} `json:"validator"`
	} `json:"data"`
}

type VoluntaryExitMessage

type VoluntaryExitMessage struct {
	Message struct {
		Epoch          string `json:"epoch"`
		ValidatorIndex string `json:"validator_index"`
	} `json:"message"`
	Signature string `json:"signature"`
}

type Web3SignerClient

type Web3SignerClient struct {
	web3_actions.Web3Actions
}

func NewWeb3Client

func NewWeb3Client(nodeUrl string, acc *accounts.Account) Web3SignerClient

func (*Web3SignerClient) GenerateDepositData

func (w *Web3SignerClient) GenerateDepositData(ctx context.Context, blsSigner bls_signer.EthBLSAccount, withdrawalAddress []byte, forkVersion *spec.Version) (*DepositDataParams, error)

func (*Web3SignerClient) GenerateDepositDataWithDefaultWd

func (w *Web3SignerClient) GenerateDepositDataWithDefaultWd(ctx context.Context, vdg ValidatorDepositGenerationParams, fv *spec.Version) ([]*DepositDataParams, error)

func (*Web3SignerClient) GenerateDepositDataWithForWdAddr

func (w *Web3SignerClient) GenerateDepositDataWithForWdAddr(ctx context.Context, vdg ValidatorDepositGenerationParams, wd []byte, fv *spec.Version) ([]*DepositDataParams, error)

func (*Web3SignerClient) GenerateEphemeryDepositDataWithDefaultWd

func (w *Web3SignerClient) GenerateEphemeryDepositDataWithDefaultWd(ctx context.Context, vdg ValidatorDepositGenerationParams) ([]*DepositDataParams, error)

func (*Web3SignerClient) GenerateVoluntaryExit

func (w *Web3SignerClient) GenerateVoluntaryExit(ctx context.Context, blsSigner bls_signer.EthBLSAccount, forkVersion *spec.Version, genesisForkVersion [32]byte, validatorIndex string) (*spec.SignedVoluntaryExit, error)

GenerateVoluntaryExit TODO generateVoluntaryExit needs current fork version

func (*Web3SignerClient) SignValidatorDepositTxToBroadcast

func (w *Web3SignerClient) SignValidatorDepositTxToBroadcast(ctx context.Context, depositParams *DepositDataParams) (*types.Transaction, error)

func (*Web3SignerClient) SignValidatorDepositTxToBroadcastFromJSON

func (w *Web3SignerClient) SignValidatorDepositTxToBroadcastFromJSON(ctx context.Context, depositParams ExtendedDepositParams) (*types.Transaction, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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