core

package
v0.0.0-...-7d5141f Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidatorStatusInactive  = 0
	ValidatorStatusActive    = 1
	ValidatorStatusWithdrawn = 2
)
View Source
const FAR_FUTURE_EPOCH = math.MaxUint64

(https://github.com/Layr-Labs/eigenlayer-contracts/blob/d148952a2942a97a218a2ab70f9b9f1792796081/src/contracts/libraries/BeaconChainProofs.sol#L64)

Variables

View Source
var (
	ErrNoEigenPod               = errors.New("no eigenpod associated with owner")
	ErrBeaconClientNotSupported = errors.New("could not instantiate beacon chain client")
	ErrValidatorNotFound        = errors.New("validator not found")
)

Functions

func AllZero

func AllZero(s []byte) bool

func CastValidatorFields

func CastValidatorFields(proof [][]eigenpodproofs.Bytes32) [][][32]byte

golang was a mistake. these types are literally identical :'(

func ContextWithTracing

func ContextWithTracing(ctx context.Context, callbacks *TracerCallbacks) context.Context

func FetchMultipleOnchainValidatorInfoMulticalls

func FetchMultipleOnchainValidatorInfoMulticalls(eigenpodAddress string, allValidators []*phase0.Validator) ([]*multicall.MultiCallMetaData[*onchain.IEigenPodValidatorInfo], error)

func FindStaleEigenpods

func FindStaleEigenpods(ctx context.Context, eth *ethclient.Client, nodeUrl string, beacon BeaconClient, chainId *big.Int, verbose bool, tolerance float64) (map[string][]ValidatorWithIndex, error)

func ForkVersions

func ForkVersions() map[uint64]string

this is a mapping from <chainId, genesis_fork_version>.

func FracMul

func FracMul(a *big.Int, x *big.Int, y *big.Int) *big.Int

multiply by a fraction

func GenerateCheckpointProof

func GenerateCheckpointProof(ctx context.Context, eigenpodAddress string, eth *ethclient.Client, chainId *big.Int, beaconClient BeaconClient, verbose bool) (*eigenpodproofs.VerifyCheckpointProofsCallParams, error)

func GenerateCheckpointProofForState

func GenerateCheckpointProofForState(ctx context.Context, eigenpodAddress string, beaconState *spec.VersionedBeaconState, header *v1.BeaconBlockHeader, eth *ethclient.Client, currentCheckpointTimestamp uint64, proofs *eigenpodproofs.EigenPodProofs, verbose bool) (*eigenpodproofs.VerifyCheckpointProofsCallParams, error)

func GenerateValidatorProof

func GenerateValidatorProof(ctx context.Context, eigenpodAddress string, eth *ethclient.Client, chainId *big.Int, beaconClient BeaconClient, validatorIndex *big.Int, verbose bool) (*eigenpodproofs.VerifyValidatorFieldsCallParams, uint64, error)

*

  • Generates a .ProveValidatorContainers() proof for all eligible validators on the pod. If `validatorIndex` is set, it will only generate a proof
  • against that validator, regardless of the validator's state.

func GenerateValidatorProofAtState

func GenerateValidatorProofAtState(ctx context.Context, proofs *eigenpodproofs.EigenPodProofs, eigenpodAddress string, beaconState *spec.VersionedBeaconState, eth *ethclient.Client, chainId *big.Int, header *v1.BeaconBlockHeader, blockTimestamp uint64, forSpecificValidatorIndex *big.Int, verbose bool) (*eigenpodproofs.VerifyValidatorFieldsCallParams, error)

func GetCheckpointTimestampAndBeaconState

func GetCheckpointTimestampAndBeaconState(
	ctx context.Context,
	eigenpodAddress string,
	eth *ethclient.Client,
	beaconClient BeaconClient,
) (uint64, *spec.VersionedBeaconState, error)

Fetch and return the current checkpoint timestamp for the pod If the checkpoint exists (timestamp != 0), also return the beacon state for the checkpoint If the checkpoint does not exist (timestamp == 0), return the head beacon state (i.e. the state we would use "if we start a checkpoint now")

func GetCurrentCheckpoint

func GetCurrentCheckpoint(eigenpodAddress string, client *ethclient.Client) (uint64, error)

func GetCurrentCheckpointBlockRoot

func GetCurrentCheckpointBlockRoot(eigenpodAddress string, eth *ethclient.Client) (*[32]byte, error)

func GweiToEther

func GweiToEther(val *big.Float) *big.Float

func GweiToWei

func GweiToWei(val *big.Float) *big.Float

func IGweiToWei

func IGweiToWei(val *big.Int) *big.Int

func IsAwaitingWithdrawalCredentialProof

func IsAwaitingWithdrawalCredentialProof(validatorInfo onchain.IEigenPodValidatorInfo, validator *phase0.Validator) bool

func IweiToEther

func IweiToEther(val *big.Int) *big.Float

func LoadCheckpointProofFromFile

func LoadCheckpointProofFromFile(path string) (*eigenpodproofs.VerifyCheckpointProofsCallParams, error)

, out, owner *string, forceCheckpoint bool

func Panic

func Panic(message string)

func PanicIfNoConsent

func PanicIfNoConsent(prompt string)

func PanicOnError

func PanicOnError(message string, err error)

func PodManagerContracts

func PodManagerContracts() map[uint64]string

func SortByStatus

func SortByStatus(validators map[string]Validator) ([]Validator, []Validator, []Validator, []Validator)

func StartCheckpoint

func StartCheckpoint(ctx context.Context, eigenpodAddress string, ownerPrivateKey string, chainId *big.Int, eth *ethclient.Client, forceCheckpoint bool, noSend bool) (*types.Transaction, error)

func StartCheckpointProofConsent

func StartCheckpointProofConsent() string

func SubmitCheckpointProof

func SubmitCheckpointProof(ctx context.Context, owner, eigenpodAddress string, chainId *big.Int, proof *eigenpodproofs.VerifyCheckpointProofsCallParams, eth *ethclient.Client, batchSize uint64, noPrompt bool, noSend bool, verbose bool) ([]*types.Transaction, error)

func SubmitCheckpointProofBatch

func SubmitCheckpointProofBatch(ctx context.Context, owner, eigenpodAddress string, chainId *big.Int, proof *eigenpodproofs.ValidatorBalancesRootProof, balanceProofs []*eigenpodproofs.BalanceProof, eth *ethclient.Client, noSend bool, verbose bool) (*types.Transaction, error)

func SubmitCredentialsProofConsent

func SubmitCredentialsProofConsent(numTransactions int) string

func SubmitValidatorProof

func SubmitValidatorProof(ctx context.Context, owner, eigenpodAddress string, chainId *big.Int, eth *ethclient.Client, batchSize uint64, proofs *eigenpodproofs.VerifyValidatorFieldsCallParams, oracleBeaconTimesetamp uint64, noPrompt bool, noSend bool, verbose bool) ([]*types.Transaction, [][]*big.Int, error)

func SubmitValidatorProofChunk

func SubmitValidatorProofChunk(ctx context.Context, ownerAccount *Owner, eigenPod *onchain.EigenPod, chainId *big.Int, eth *ethclient.Client, indices []*big.Int, validatorFields [][][32]byte, stateRootProofs *eigenpodproofs.StateRootProof, validatorFieldsProofs [][]byte, oracleBeaconTimesetamp uint64, verbose bool) (*types.Transaction, error)

func Uint64ArrayToBigIntArray

func Uint64ArrayToBigIntArray(nums []uint64) []*big.Int

func WeiToGwei

func WeiToGwei(val *big.Int) *big.Float

func WriteOutputToFileOrStdout

func WriteOutputToFileOrStdout(output []byte, out *string) error

Types

type BeaconClient

type BeaconClient interface {
	GetBeaconHeader(ctx context.Context, blockId string) (*v1.BeaconBlockHeader, error)
	GetBeaconState(ctx context.Context, stateId string) (*spec.VersionedBeaconState, error)
	GetValidator(ctx context.Context, index uint64) (*v1.Validator, error)
	GetGenesisForkVersion(ctx context.Context) (*phase0.Version, error)
}

func GetBeaconClient

func GetBeaconClient(beaconUri string, verbose bool) (BeaconClient, error)

func GetClients

func GetClients(ctx context.Context, node, beaconNodeUri string, enableLogs bool) (*ethclient.Client, BeaconClient, *big.Int, error)

func NewBeaconClient

func NewBeaconClient(endpoint string, verbose bool) (BeaconClient, context.CancelFunc, error)

type Cache

type Cache struct {
	PodOwnerShares map[string]PodOwnerShare
}

type Checkpoint

type Checkpoint struct {
	ProofsRemaining uint64
	StartedAt       uint64
}

type EigenpodStatus

type EigenpodStatus struct {
	Validators map[string]Validator

	ActiveCheckpoint *Checkpoint

	NumberValidatorsToCheckpoint int

	CurrentTotalSharesETH *big.Float
	Status                int

	// if you completed a new checkpoint right now, how many shares would you get?
	//
	//  this is computed as:
	// 		- If checkpoint is already started:
	// 			sum(beacon chain balances) + currentCheckpoint.podBalanceGwei + pod.withdrawableRestakedExecutionLayerGwei()
	// 		- If no checkpoint is started:
	// 			total_shares_after_checkpoint = sum(validator[i].regular_balance) + (balanceOf(pod) rounded down to gwei) - withdrawableRestakedExecutionLayerGwei
	TotalSharesAfterCheckpointGwei *big.Float
	TotalSharesAfterCheckpointETH  *big.Float

	PodOwner       gethCommon.Address
	ProofSubmitter gethCommon.Address

	// Whether the checkpoint would need to be started with the `--force` flag.
	// This would be due to the pod not having any uncheckpointed native ETH
	MustForceCheckpoint bool
}

func GetStatus

func GetStatus(ctx context.Context, eigenpodAddress string, eth *ethclient.Client, beaconClient BeaconClient) EigenpodStatus

type Owner

type Owner = struct {
	FromAddress        common.Address
	PublicKey          *ecdsa.PublicKey
	TransactionOptions *bind.TransactOpts
	IsDryRun           bool
}

func PrepareAccount

func PrepareAccount(owner *string, chainID *big.Int, noSend bool) (*Owner, error)

type PodOwnerShare

type PodOwnerShare struct {
	SharesWei                *big.Int
	ExecutionLayerBalanceWei *big.Int
	IsEigenpod               bool
}

type SerializableCredentialProof

type SerializableCredentialProof struct {
	ValidatorProofs       *eigenpodproofs.VerifyValidatorFieldsCallParams
	OracleBeaconTimestamp uint64
}

func LoadValidatorProofFromFile

func LoadValidatorProofFromFile(path string) (*SerializableCredentialProof, error)

type TEigenKey

type TEigenKey string
const EIGEN_KEY TEigenKey = "com.eigen.tracer"

type TracerCallbacks

type TracerCallbacks struct {
	OnStartSection func(name string, metadata map[string]string)
	OnEndSection   func()
}

func GetContextTracingCallbacks

func GetContextTracingCallbacks(ctx context.Context) *TracerCallbacks

type Validator

type Validator struct {
	Slashed                             bool
	Index                               uint64
	Status                              int
	PublicKey                           string
	IsAwaitingActivationQueue           bool
	IsAwaitingWithdrawalCredentialProof bool
	EffectiveBalance                    uint64
	CurrentBalance                      uint64
}

type ValidatorWithIndex

type ValidatorWithIndex = struct {
	Validator *phase0.Validator
	Index     uint64
}

func FindAllValidatorsForEigenpod

func FindAllValidatorsForEigenpod(eigenpodAddress string, beaconState *spec.VersionedBeaconState) ([]ValidatorWithIndex, error)

search through beacon state for validators whose withdrawal address is set to eigenpod.

type ValidatorWithOnchainInfo

type ValidatorWithOnchainInfo = struct {
	Info      onchain.IEigenPodValidatorInfo
	Validator *phase0.Validator
	Index     uint64
}

func FetchMultipleOnchainValidatorInfo

func FetchMultipleOnchainValidatorInfo(ctx context.Context, client *ethclient.Client, eigenpodAddress string, allValidators []ValidatorWithIndex) ([]ValidatorWithOnchainInfo, error)

func SelectActiveValidators

func SelectActiveValidators(
	client *ethclient.Client,
	eigenpodAddress string,
	validators []ValidatorWithOnchainInfo,
) ([]ValidatorWithOnchainInfo, error)

func SelectAwaitingActivationValidators

func SelectAwaitingActivationValidators(
	client *ethclient.Client,
	eigenpodAddress string,
	validators []ValidatorWithOnchainInfo,
) ([]ValidatorWithOnchainInfo, error)

Validators whose deposits have been processed but are awaiting activation on the beacon chain If the validator has 32 ETH effective balance, they should

func SelectAwaitingCredentialValidators

func SelectAwaitingCredentialValidators(
	client *ethclient.Client,
	eigenpodAddress string,
	validators []ValidatorWithOnchainInfo,
) ([]ValidatorWithOnchainInfo, error)

func SelectCheckpointableValidators

func SelectCheckpointableValidators(
	client *ethclient.Client,
	eigenpodAddress string,
	validators []ValidatorWithOnchainInfo,
	lastCheckpoint uint64,
) ([]ValidatorWithOnchainInfo, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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