api

package
v0.0.0-...-b4f0473 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound                        = errors.New("not found")
	ErrSyncCommitteeUpdateNotAvailable = errors.New("no sync committee update available")
	ConstructRequestErrorMessage       = "construct header request"
	DoHTTPRequestErrorMessage          = "do http request"
	HTTPStatusNotOKErrorMessage        = "http status not ok"
	ReadResponseBodyErrorMessage       = "read response body"
	UnmarshalBodyErrorMessage          = "unmarshal body"
)

Functions

Types

type AttestationDataResponse

type AttestationDataResponse struct {
	Slot            string             `json:"slot"`
	Index           string             `json:"index"`
	BeaconBlockRoot string             `json:"beacon_block_root"`
	Source          CheckpointResponse `json:"source"`
	Target          CheckpointResponse `json:"target"`
}

func (AttestationDataResponse) ToFastSSZ

type AttestationResponse

type AttestationResponse struct {
	AggregationBits string                  `json:"aggregation_bits"`
	Data            AttestationDataResponse `json:"data"`
	Signature       string                  `json:"signature"`
}

func (AttestationResponse) ToFastSSZ

func (a AttestationResponse) ToFastSSZ() (*state.Attestation, error)

type AttesterSlashingResponse

type AttesterSlashingResponse struct {
	Attestation1 IndexedAttestationResponse `json:"attestation_1"`
	Attestation2 IndexedAttestationResponse `json:"attestation_2"`
}

func (AttesterSlashingResponse) ToFastSSZ

type BLSToExecutionChangeResponse

type BLSToExecutionChangeResponse struct {
	ValidatorIndex     string `json:"validator_index"`
	FromBlsPubkey      string `json:"from_bls_pubkey"`
	ToExecutionAddress string `json:"to_execution_address"`
}

type BeaconAPI

type BeaconAPI interface {
	GetBootstrap(blockRoot common.Hash) (BootstrapResponse, error)
	GetGenesis() (Genesis, error)
	GetFinalizedCheckpoint() (FinalizedCheckpoint, error)
	GetHeaderBySlot(slot uint64) (BeaconHeader, error)
	GetHeaderAtHead() (BeaconHeader, error)
	GetHeaderByBlockRoot(blockRoot common.Hash) (BeaconHeader, error)
	GetBeaconBlockBySlot(slot uint64) (BeaconBlockResponse, error)
	GetBeaconBlockRoot(slot uint64) (common.Hash, error)
	GetBeaconBlock(blockID common.Hash) (BeaconBlockResponse, error)
	GetSyncCommitteePeriodUpdate(from uint64) (SyncCommitteePeriodUpdateResponse, error)
	GetLatestFinalizedUpdate() (LatestFinalisedUpdateResponse, error)
	GetBeaconState(stateIdOrSlot string) ([]byte, error)
}

type BeaconBlock

type BeaconBlock struct {
	Slot          uint64
	ProposerIndex uint64
	ParentRoot    common.Hash
	StateRoot     common.Hash
	BodyRoot      common.Hash
}

type BeaconBlockResponse

type BeaconBlockResponse struct {
	Data BeaconBlockResponseData `json:"data"`
}

func (BeaconBlockResponse) ToFastSSZ

func (b BeaconBlockResponse) ToFastSSZ(isDeneb bool) (state.BeaconBlock, error)

ToFastSSZ can be removed once Lodestar supports returning block data as SSZ instead of JSON only. Because it only returns JSON, we need this interim step where we convert the block JSON to the data types that the FastSSZ lib expects. When Lodestar supports SSZ block response, we can remove all these and directly unmarshal SSZ bytes to state.BeaconBlock.

type BeaconBlockResponseBody

type BeaconBlockResponseBody struct {
	RandaoReveal string `json:"randao_reveal"`
	Eth1Data     struct {
		DepositRoot  string `json:"deposit_root"`
		DepositCount string `json:"deposit_count"`
		BlockHash    string `json:"block_hash"`
	} `json:"eth1_data"`
	Graffiti          string                        `json:"graffiti"`
	ProposerSlashings []ProposerSlashingResponse    `json:"proposer_slashings"`
	AttesterSlashings []AttesterSlashingResponse    `json:"attester_slashings"`
	Attestations      []AttestationResponse         `json:"attestations"`
	Deposits          []DepositResponse             `json:"deposits"`
	VoluntaryExits    []SignedVoluntaryExitResponse `json:"voluntary_exits"`
	SyncAggregate     SyncAggregateResponse         `json:"sync_aggregate"`
	ExecutionPayload  struct {
		ParentHash    string               `json:"parent_hash"`
		FeeRecipient  string               `json:"fee_recipient"`
		StateRoot     string               `json:"state_root"`
		ReceiptsRoot  string               `json:"receipts_root"`
		LogsBloom     string               `json:"logs_bloom"`
		PrevRandao    string               `json:"prev_randao"`
		BlockNumber   string               `json:"block_number"`
		GasLimit      string               `json:"gas_limit"`
		GasUsed       string               `json:"gas_used"`
		Timestamp     string               `json:"timestamp"`
		ExtraData     string               `json:"extra_data"`
		BaseFeePerGas string               `json:"base_fee_per_gas"`
		BlockHash     string               `json:"block_hash"`
		Transactions  []string             `json:"transactions"`
		Withdrawals   []WithdrawalResponse `json:"withdrawals"`
		BlobGasUsed   string               `json:"blob_gas_used,omitempty"`
		ExcessBlobGas string               `json:"excess_blob_gas,omitempty"`
	} `json:"execution_payload"`
	BlsToExecutionChanges []SignedBLSToExecutionChangeResponse `json:"bls_to_execution_changes"`
	BlobKzgCommitments    []string                             `json:"blob_kzg_commitments"`
}

type BeaconBlockResponseData

type BeaconBlockResponseData struct {
	Message BeaconBlockResponseMessage `json:"message"`
}

type BeaconBlockResponseMessage

type BeaconBlockResponseMessage struct {
	Slot          string                  `json:"slot"`
	ProposerIndex string                  `json:"proposer_index"`
	ParentRoot    string                  `json:"parent_root"`
	StateRoot     string                  `json:"state_root"`
	Body          BeaconBlockResponseBody `json:"body"`
}

type BeaconClient

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

func NewBeaconClient

func NewBeaconClient(endpoint, stateEndpoint string) *BeaconClient

func (*BeaconClient) GetBeaconBlock

func (b *BeaconClient) GetBeaconBlock(blockID common.Hash) (BeaconBlockResponse, error)

func (*BeaconClient) GetBeaconBlockBySlot

func (b *BeaconClient) GetBeaconBlockBySlot(slot uint64) (BeaconBlockResponse, error)

func (*BeaconClient) GetBeaconBlockRoot

func (b *BeaconClient) GetBeaconBlockRoot(slot uint64) (common.Hash, error)

func (*BeaconClient) GetBeaconState

func (b *BeaconClient) GetBeaconState(stateIdOrSlot string) ([]byte, error)

func (*BeaconClient) GetBootstrap

func (b *BeaconClient) GetBootstrap(blockRoot common.Hash) (BootstrapResponse, error)

func (*BeaconClient) GetFinalizedCheckpoint

func (b *BeaconClient) GetFinalizedCheckpoint() (FinalizedCheckpoint, error)

func (*BeaconClient) GetGenesis

func (b *BeaconClient) GetGenesis() (Genesis, error)

func (*BeaconClient) GetHeader

func (b *BeaconClient) GetHeader(qualifier string) (BeaconHeader, error)

func (*BeaconClient) GetHeaderAtHead

func (b *BeaconClient) GetHeaderAtHead() (BeaconHeader, error)

func (*BeaconClient) GetHeaderByBlockRoot

func (b *BeaconClient) GetHeaderByBlockRoot(blockRoot common.Hash) (BeaconHeader, error)

func (*BeaconClient) GetHeaderBySlot

func (b *BeaconClient) GetHeaderBySlot(slot uint64) (BeaconHeader, error)

func (*BeaconClient) GetLatestFinalizedUpdate

func (b *BeaconClient) GetLatestFinalizedUpdate() (LatestFinalisedUpdateResponse, error)

func (*BeaconClient) GetSyncCommitteePeriodUpdate

func (b *BeaconClient) GetSyncCommitteePeriodUpdate(from uint64) (SyncCommitteePeriodUpdateResponse, error)

type BeaconHeader

type BeaconHeader struct {
	Slot          uint64      `json:"slot"`
	ProposerIndex uint64      `json:"proposer_index"`
	ParentRoot    common.Hash `json:"parent_root"`
	StateRoot     common.Hash `json:"state_root"`
	BodyRoot      common.Hash `json:"body_root"`
}

func (BeaconHeader) ToScale

func (h BeaconHeader) ToScale() (scale.BeaconHeader, error)

type BeaconHeaderResponse

type BeaconHeaderResponse struct {
	Data struct {
		Root      string `json:"root"`
		Canonical bool   `json:"canonical"`
		Header    struct {
			Message   HeaderResponse `json:"message"`
			Signature string         `json:"signature"`
		} `json:"header"`
	} `json:"data"`
}

type Bootstrap

type Bootstrap struct {
	Header                     HeaderResponse
	CurrentSyncCommittee       beaconjson.SyncCommittee
	CurrentSyncCommitteeBranch []string
}

type BootstrapResponse

type BootstrapResponse struct {
	Data struct {
		Header struct {
			Beacon HeaderResponse `json:"beacon"`
		} `json:"header"`
		CurrentSyncCommittee       SyncCommitteeResponse `json:"current_sync_committee"`
		CurrentSyncCommitteeBranch []string              `json:"current_sync_committee_branch"`
	} `json:"data"`
}

type BranchResponse

type BranchResponse []string

type CheckpointResponse

type CheckpointResponse struct {
	Epoch string `json:"epoch"`
	Root  string `json:"root"`
}

func (CheckpointResponse) ToFastSSZ

func (c CheckpointResponse) ToFastSSZ() (*state.Checkpoint, error)

func (CheckpointResponse) ToScale

func (c CheckpointResponse) ToScale() (scale.Checkpoint, error)

type DepositDataResponse

type DepositDataResponse struct {
	Pubkey                string `json:"pubkey"`
	WithdrawalCredentials string `json:"withdrawal_credentials"`
	Amount                string `json:"amount"`
	Signature             string `json:"signature"`
}

type DepositResponse

type DepositResponse struct {
	Proof []string            `json:"proof"`
	Data  DepositDataResponse `json:"data"`
}

func (DepositResponse) ToFastSSZ

func (d DepositResponse) ToFastSSZ() (*state.Deposit, error)

type ErrorMessage

type ErrorMessage struct {
	StatusCode int    `json:"statusCode"`
	Error      string `json:"error"`
	Message    string `json:"message"`
}

type FinalizedCheckpoint

type FinalizedCheckpoint struct {
	FinalizedBlockRoot common.Hash
}

type FinalizedCheckpointResponse

type FinalizedCheckpointResponse struct {
	Data struct {
		Finalized struct {
			Root string `json:"root"`
		} `json:"finalized"`
	} `json:"data"`
}

type ForkResponse

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

type Genesis

type Genesis struct {
	ValidatorsRoot common.Hash
	Time           uint64
}

type GenesisResponse

type GenesisResponse struct {
	Data struct {
		GenesisValidatorsRoot string `json:"genesis_validators_root"`
		Time                  string `json:"genesis_time"`
	} `json:"data"`
}

type HeaderResponse

type HeaderResponse struct {
	Slot          string `json:"slot"`
	ProposerIndex string `json:"proposer_index"`
	ParentRoot    string `json:"parent_root"`
	StateRoot     string `json:"state_root"`
	BodyRoot      string `json:"body_root"`
}

func (*HeaderResponse) ToBeaconHeader

func (h *HeaderResponse) ToBeaconHeader() (BeaconHeader, error)

func (*HeaderResponse) ToFastSSZ

func (h *HeaderResponse) ToFastSSZ() (*state.BeaconBlockHeader, error)

func (*HeaderResponse) ToScale

func (h *HeaderResponse) ToScale() (scale.BeaconHeader, error)

type IndexedAttestationResponse

type IndexedAttestationResponse struct {
	AttestingIndices []string                `json:"attesting_indices"`
	Data             AttestationDataResponse `json:"data"`
	Signature        string                  `json:"signature"`
}

func (IndexedAttestationResponse) ToFastSSZ

type LatestFinalisedUpdateResponse

type LatestFinalisedUpdateResponse struct {
	Data struct {
		AttestedHeader struct {
			Beacon HeaderResponse `json:"beacon"`
		} `json:"attested_header"`
		FinalizedHeader struct {
			Beacon HeaderResponse `json:"beacon"`
		} `json:"finalized_header"`
		FinalityBranch []string              `json:"finality_branch"`
		SyncAggregate  SyncAggregateResponse `json:"sync_aggregate"`
		SignatureSlot  string                `json:"signature_slot"`
	} `json:"data"`
}

type LatestHeaderUpdateResponse

type LatestHeaderUpdateResponse struct {
	Data struct {
		AttestedHeader HeaderResponse        `json:"attested_header"`
		SyncAggregate  SyncAggregateResponse `json:"sync_aggregate"`
	} `json:"data"`
}

type ProposerSlashingResponse

type ProposerSlashingResponse struct {
	SignedHeader1 SignedHeaderResponse `json:"signed_header_1"`
	SignedHeader2 SignedHeaderResponse `json:"signed_header_2"`
}

func (ProposerSlashingResponse) ToFastSSZ

type SignedBLSToExecutionChangeResponse

type SignedBLSToExecutionChangeResponse struct {
	Message   *BLSToExecutionChangeResponse `json:"message,omitempty"`
	Signature string                        `json:"signature,omitempty"`
}

func (*SignedBLSToExecutionChangeResponse) ToFastSSZ

type SignedHeaderResponse

type SignedHeaderResponse struct {
	Message   HeaderResponse `json:"message"`
	Signature string         `json:"signature"`
}

func (SignedHeaderResponse) ToFastSSZ

type SignedVoluntaryExitResponse

type SignedVoluntaryExitResponse struct {
	Message   VoluntaryExitResponse `json:"message"`
	Signature string                `json:"signature"`
}

func (SignedVoluntaryExitResponse) ToFastSSZ

type SyncAggregateResponse

type SyncAggregateResponse struct {
	SyncCommitteeBits      string `json:"sync_committee_bits"`
	SyncCommitteeSignature string `json:"sync_committee_signature"`
}

func (SyncAggregateResponse) ToScale

type SyncCommitteePeriodUpdateResponse

type SyncCommitteePeriodUpdateResponse struct {
	Data struct {
		AttestedHeader struct {
			Beacon HeaderResponse `json:"beacon"`
		} `json:"attested_header"`
		NextSyncCommittee       SyncCommitteeResponse `json:"next_sync_committee"`
		NextSyncCommitteeBranch []string              `json:"next_sync_committee_branch"`
		FinalizedHeader         struct {
			Beacon HeaderResponse `json:"beacon"`
		} `json:"finalized_header"`
		FinalityBranch []string              `json:"finality_branch"`
		SyncAggregate  SyncAggregateResponse `json:"sync_aggregate"`
		SignatureSlot  string                `json:"signature_slot"`
	} `json:"data"`
}

type SyncCommitteeResponse

type SyncCommitteeResponse struct {
	Pubkeys         []string `json:"pubkeys"`
	AggregatePubkey string   `json:"aggregate_pubkey"`
}

func (SyncCommitteeResponse) ToScale

type VoluntaryExitResponse

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

type WithdrawalResponse

type WithdrawalResponse struct {
	Index          string `json:"index"`
	ValidatorIndex string `json:"validator_index"`
	Address        string `json:"address"`
	Amount         string `json:"amount"`
}

func (*WithdrawalResponse) ToFastSSZ

func (w *WithdrawalResponse) ToFastSSZ() (*state.Withdrawal, error)

Jump to

Keyboard shortcuts

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