client

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestUrlFormat   = "%s%s"
	RequestContentType = "application/json"

	RequestSyncStatusPath                  = "/eth/v1/node/syncing"
	RequestEth2ConfigPath                  = "/eth/v1/config/spec"
	RequestEth2DepositContractMethod       = "/eth/v1/config/deposit_contract"
	RequestCommitteePath                   = "/eth/v1/beacon/states/%s/committees"
	RequestGenesisPath                     = "/eth/v1/beacon/genesis"
	RequestFinalityCheckpointsPath         = "/eth/v1/beacon/states/%s/finality_checkpoints"
	RequestForkPath                        = "/eth/v1/beacon/states/%s/fork"
	RequestValidatorsPath                  = "/eth/v1/beacon/states/%s/validators"
	RequestVoluntaryExitPath               = "/eth/v1/beacon/pool/voluntary_exits"
	RequestAttestationsPath                = "/eth/v1/beacon/blocks/%s/attestations"
	RequestBeaconBlockPath                 = "/eth/v2/beacon/blocks/%s"
	RequestBeaconBlockHeaderPath           = "/eth/v1/beacon/headers/%s"
	RequestValidatorSyncDuties             = "/eth/v1/validator/duties/sync/%s"
	RequestValidatorProposerDuties         = "/eth/v1/validator/duties/proposer/%s"
	RequestWithdrawalCredentialsChangePath = "/eth/v1/beacon/pool/bls_to_execution_changes"

	MaxRequestValidatorsCount = 600
)

Config

Variables

This section is empty.

Functions

This section is empty.

Types

type Attestation

type Attestation struct {
	AggregationBits string `json:"aggregation_bits"`
	Data            struct {
		Slot  uinteger `json:"slot"`
		Index uinteger `json:"index"`
	} `json:"data"`
}

type AttestationsResponse

type AttestationsResponse struct {
	Data []Attestation `json:"data"`
}

type BLSToExecutionChangeMessage

type BLSToExecutionChangeMessage struct {
	ValidatorIndex     string    `json:"validator_index"`
	FromBLSPubkey      byteArray `json:"from_bls_pubkey"`
	ToExecutionAddress byteArray `json:"to_execution_address"`
}

type BLSToExecutionChangeRequest

type BLSToExecutionChangeRequest struct {
	Message   BLSToExecutionChangeMessage `json:"message"`
	Signature byteArray                   `json:"signature"`
}

type BeaconBlockHeaderResponse added in v0.2.0

type BeaconBlockHeaderResponse struct {
	Finalized bool `json:"finalized"`
	Data      struct {
		Root      string `json:"root"`
		Canonical bool   `json:"canonical"`
		Header    struct {
			Message struct {
				Slot          uinteger `json:"slot"`
				ProposerIndex string   `json:"proposer_index"`
			} `json:"message"`
		} `json:"header"`
	} `json:"data"`
}

type BeaconBlockResponse

type BeaconBlockResponse struct {
	Data struct {
		Message struct {
			Slot          uinteger `json:"slot"`
			ProposerIndex string   `json:"proposer_index"`
			Body          struct {
				Eth1Data struct {
					DepositRoot  byteArray `json:"deposit_root"`
					DepositCount uinteger  `json:"deposit_count"`
					BlockHash    byteArray `json:"block_hash"`
				} `json:"eth1_data"`
				Attestations     []Attestation `json:"attestations"`
				ExecutionPayload *struct {
					FeeRecipient byteArray `json:"fee_recipient"`
					BlockNumber  uinteger  `json:"block_number"`
				} `json:"execution_payload"`
			} `json:"body"`
		} `json:"message"`
	} `json:"data"`
}

type Committee added in v0.2.0

type Committee struct {
	Index      uinteger `json:"index"`
	Slot       uinteger `json:"slot"`
	Validators []string `json:"validators"`
}

func (*Committee) UnmarshalJSON added in v0.2.0

func (c *Committee) UnmarshalJSON(body []byte) error

type CommitteesResponse added in v0.2.0

type CommitteesResponse struct {
	Data []Committee `json:"data"`
}

func (*CommitteesResponse) Count added in v0.2.0

func (c *CommitteesResponse) Count() int

func (*CommitteesResponse) Index added in v0.2.0

func (c *CommitteesResponse) Index(idx int) uint64

func (*CommitteesResponse) Release added in v0.2.0

func (c *CommitteesResponse) Release()

func (*CommitteesResponse) Slot added in v0.2.0

func (c *CommitteesResponse) Slot(idx int) uint64

func (*CommitteesResponse) Validators added in v0.2.0

func (c *CommitteesResponse) Validators(idx int) []string

type Eth2ConfigResponse

type Eth2ConfigResponse struct {
	Data struct {
		SecondsPerSlot               uinteger  `json:"SECONDS_PER_SLOT"`
		SlotsPerEpoch                uinteger  `json:"SLOTS_PER_EPOCH"`
		EpochsPerSyncCommitteePeriod uinteger  `json:"EPOCHS_PER_SYNC_COMMITTEE_PERIOD"`
		CapellaForkVersion           byteArray `json:"CAPELLA_FORK_VERSION"`
	} `json:"data"`
}

type Eth2DepositContractResponse

type Eth2DepositContractResponse struct {
	Data struct {
		ChainID uinteger       `json:"chain_id"`
		Address common.Address `json:"address"`
	} `json:"data"`
}

type FinalityCheckpointsResponse

type FinalityCheckpointsResponse struct {
	Data struct {
		PreviousJustified struct {
			Epoch uinteger `json:"epoch"`
		} `json:"previous_justified"`
		CurrentJustified struct {
			Epoch uinteger `json:"epoch"`
		} `json:"current_justified"`
		Finalized struct {
			Epoch uinteger `json:"epoch"`
		} `json:"finalized"`
	} `json:"data"`
}

type ForkResponse

type ForkResponse struct {
	Data struct {
		PreviousVersion byteArray `json:"previous_version"`
		CurrentVersion  byteArray `json:"current_version"`
		Epoch           uinteger  `json:"epoch"`
	} `json:"data"`
}

type GenesisResponse

type GenesisResponse struct {
	Data struct {
		GenesisTime           uinteger  `json:"genesis_time"`
		GenesisForkVersion    byteArray `json:"genesis_fork_version"`
		GenesisValidatorsRoot byteArray `json:"genesis_validators_root"`
	} `json:"data"`
}

type ProposerDutiesResponse

type ProposerDutiesResponse struct {
	Data []ProposerDuty `json:"data"`
}

type ProposerDuty

type ProposerDuty struct {
	ValidatorIndex string `json:"validator_index"`
}

type StandardHttpClient

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

Beacon client using the standard Beacon HTTP REST API (https://ethereum.github.io/beacon-APIs/)

func NewStandardHttpClient

func NewStandardHttpClient(providerAddress string, timeout time.Duration) *StandardHttpClient

Create a new client instance

func (*StandardHttpClient) ChangeWithdrawalCredentials

func (c *StandardHttpClient) ChangeWithdrawalCredentials(ctx context.Context, validatorIndex string, fromBlsPubkey beacon.ValidatorPubkey, toExecutionAddress common.Address, signature beacon.ValidatorSignature) error

Perform a withdrawal credentials change on a validator

func (*StandardHttpClient) Close

func (c *StandardHttpClient) Close(ctx context.Context) error

Close the client connection

func (*StandardHttpClient) ExitValidator

func (c *StandardHttpClient) ExitValidator(ctx context.Context, validatorIndex string, epoch uint64, signature beacon.ValidatorSignature) error

Perform a voluntary exit on a validator

func (*StandardHttpClient) GetAttestations

func (c *StandardHttpClient) GetAttestations(ctx context.Context, blockId string) ([]beacon.AttestationInfo, bool, error)

func (*StandardHttpClient) GetBeaconBlock

func (c *StandardHttpClient) GetBeaconBlock(ctx context.Context, blockId string) (beacon.BeaconBlock, bool, error)

func (*StandardHttpClient) GetBeaconBlockHeader added in v0.2.0

func (c *StandardHttpClient) GetBeaconBlockHeader(ctx context.Context, blockId string) (beacon.BeaconBlockHeader, bool, error)

func (*StandardHttpClient) GetBeaconHead

func (c *StandardHttpClient) GetBeaconHead(ctx context.Context) (beacon.BeaconHead, error)

Get the beacon head

func (*StandardHttpClient) GetCommitteesForEpoch added in v0.2.0

func (c *StandardHttpClient) GetCommitteesForEpoch(ctx context.Context, epoch *uint64) (beacon.Committees, error)

Get the attestation committees for the given epoch, or the current epoch if nil

func (*StandardHttpClient) GetDomainData

func (c *StandardHttpClient) GetDomainData(ctx context.Context, domainType []byte, epoch uint64, useGenesisFork bool) ([]byte, error)

Get domain data for a domain type at a given epoch

func (*StandardHttpClient) GetEth1DataForEth2Block

func (c *StandardHttpClient) GetEth1DataForEth2Block(ctx context.Context, blockId string) (beacon.Eth1Data, bool, error)

Get the ETH1 data for the target beacon block

func (*StandardHttpClient) GetEth2Config

func (c *StandardHttpClient) GetEth2Config(ctx context.Context) (beacon.Eth2Config, error)

Get the eth2 config

func (*StandardHttpClient) GetEth2DepositContract

func (c *StandardHttpClient) GetEth2DepositContract(ctx context.Context) (beacon.Eth2DepositContract, error)

Get the eth2 deposit contract info

func (*StandardHttpClient) GetSyncStatus

func (c *StandardHttpClient) GetSyncStatus(ctx context.Context) (beacon.SyncStatus, error)

Get the node's sync status

func (*StandardHttpClient) GetValidatorIndex

func (c *StandardHttpClient) GetValidatorIndex(ctx context.Context, pubkey beacon.ValidatorPubkey) (string, error)

Get a validator's index

func (*StandardHttpClient) GetValidatorProposerDuties

func (c *StandardHttpClient) GetValidatorProposerDuties(ctx context.Context, indices []string, epoch uint64) (map[string]uint64, error)

Sums proposer duties per validators for a given epoch

func (*StandardHttpClient) GetValidatorStatus

Get a validator's status

func (*StandardHttpClient) GetValidatorStatusByIndex

func (c *StandardHttpClient) GetValidatorStatusByIndex(ctx context.Context, index string, opts *beacon.ValidatorStatusOptions) (beacon.ValidatorStatus, error)

func (*StandardHttpClient) GetValidatorStatuses

Get multiple validators' statuses

func (*StandardHttpClient) GetValidatorSyncDuties

func (c *StandardHttpClient) GetValidatorSyncDuties(ctx context.Context, indices []string, epoch uint64) (map[string]bool, error)

Get whether validators have sync duties to perform at given epoch

type SyncDutiesResponse

type SyncDutiesResponse struct {
	Data []SyncDuty `json:"data"`
}

type SyncDuty

type SyncDuty struct {
	Pubkey               byteArray  `json:"pubkey"`
	ValidatorIndex       string     `json:"validator_index"`
	SyncCommitteeIndices []uinteger `json:"validator_sync_committee_indices"`
}

type SyncStatusResponse

type SyncStatusResponse struct {
	Data struct {
		IsSyncing    bool     `json:"is_syncing"`
		HeadSlot     uinteger `json:"head_slot"`
		SyncDistance uinteger `json:"sync_distance"`
	} `json:"data"`
}

Response types

type Validator

type Validator struct {
	Index     string   `json:"index"`
	Balance   uinteger `json:"balance"`
	Status    string   `json:"status"`
	Validator struct {
		Pubkey                     byteArray `json:"pubkey"`
		WithdrawalCredentials      byteArray `json:"withdrawal_credentials"`
		EffectiveBalance           uinteger  `json:"effective_balance"`
		Slashed                    bool      `json:"slashed"`
		ActivationEligibilityEpoch uinteger  `json:"activation_eligibility_epoch"`
		ActivationEpoch            uinteger  `json:"activation_epoch"`
		ExitEpoch                  uinteger  `json:"exit_epoch"`
		WithdrawableEpoch          uinteger  `json:"withdrawable_epoch"`
	} `json:"validator"`
}

type ValidatorsResponse

type ValidatorsResponse struct {
	Data []Validator `json:"data"`
}

type VoluntaryExitMessage

type VoluntaryExitMessage struct {
	Epoch          uinteger `json:"epoch"`
	ValidatorIndex string   `json:"validator_index"`
}

Request types

type VoluntaryExitRequest

type VoluntaryExitRequest struct {
	Message   VoluntaryExitMessage `json:"message"`
	Signature byteArray            `json:"signature"`
}

Jump to

Keyboard shortcuts

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