api

package
v0.0.0-...-49ff922 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: LGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConstructRequestErrorMessage = "construct header request"
	DoHTTPRequestErrorMessage    = "do http request"
	HTTPStatusNotOKErrorMessage  = "http status not ok"
	ReadResponseBodyErrorMessage = "read response body"
	UnmarshalBodyErrorMessage    = "unmarshal body"
)

Variables

View Source
var (
	ErrNotFound                        = errors.New("not found")
	ErrSyncCommitteeUpdateNotAvailable = errors.New("no sync committee update available")
)

Functions

func SyncAggregateToScale

func SyncAggregateToScale(s state.SyncAggregate) scale.SyncAggregate

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

func (AttestationDataResponse) ToScale

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)

func (AttestationResponse) ToScale

func (a AttestationResponse) ToScale() (scale.Attestation, error)

type AttesterSlashingResponse

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

func (AttesterSlashingResponse) ToFastSSZ

func (AttesterSlashingResponse) ToScale

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 {
	GetHeader(blockRoot common.Hash) (BeaconHeader, error)
	GetHeaderBySlot(slot uint64) (BeaconHeader, error)
	GetSyncCommitteePeriodUpdate(from uint64) (SyncCommitteePeriodUpdateResponse, error)
	GetBeaconBlock(slot uint64) (BeaconBlockResponse, error)
	GetInitialSync(blockRoot string) (BootstrapResponse, error)
	GetFinalizedCheckpoint() (FinalizedCheckpoint, error)
	GetGenesis() (Genesis, error)
	GetLatestFinalizedUpdate() (LatestFinalisedUpdateResponse, error)
	GetBootstrap(blockRoot common.Hash) (Bootstrap, 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 struct {
		Message struct {
			Slot          string `json:"slot"`
			ProposerIndex string `json:"proposer_index"`
			ParentRoot    string `json:"parent_root"`
			StateRoot     string `json:"state_root"`
			Body          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"`
				} `json:"execution_payload"`
				BlsToExecutionChanges []SignedBLSToExecutionChangeResponse `json:"bls_to_execution_changes"`
			} `json:"body"`
		} `json:"message"`
	} `json:"data"`
}

func (BeaconBlockResponse) ToFastSSZ

func (b BeaconBlockResponse) ToFastSSZ(activeSpec config.ActiveSpec, epoch uint64) (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.

func (BeaconBlockResponse) ToScale

func (b BeaconBlockResponse) ToScale() (scale.BeaconBlock, error)

type BeaconClient

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

func NewBeaconClient

func NewBeaconClient(endpoint string, activeSpec config.ActiveSpec, slotsInEpoch uint64) *BeaconClient

func (*BeaconClient) DownloadBeaconState

func (b *BeaconClient) DownloadBeaconState(stateIdOrSlot string) (string, error)

func (*BeaconClient) GetBeaconBlock

func (b *BeaconClient) GetBeaconBlock(blockID common.Hash) (state.BeaconBlock, 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) 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(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)

func (DepositResponse) ToScale

func (d DepositResponse) ToScale() (scale.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

func (IndexedAttestationResponse) ToScale

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

func (ProposerSlashingResponse) ToScale

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 []byte         `json:"signature"`
}

func (SignedHeaderResponse) ToFastSSZ

func (SignedHeaderResponse) ToScale

type SignedVoluntaryExitResponse

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

func (SignedVoluntaryExitResponse) ToFastSSZ

func (SignedVoluntaryExitResponse) ToScale

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