eth2api

package module
v0.0.0-...-5f8afbd Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 19 Imported by: 18

README

Eth2 API bindings

Fully typed API bindings, for both client and server, to implement the standard Eth2.0 API specification.

Work in progress, testing in progress

TODO:

  • Client
    • Types for full API spec
    • Bindings for full API spec
      • Beacon API
      • Debug API
      • Config API
      • Node API
      • Validator API
    • Abstraction of requests/responses
    • HTTP client implementation
    • Testing: API Integration test-suite against test vectors (generated from Lighthouse API, verified with spec)
      • Beacon API
      • Debug API
      • Config API
      • Node API
      • Validator API
    • Tests for the util methods
  • Server
    • (WIP) Interfaces for serverside API
    • (WIP) Abstract server that consumes above interfaces, runs API server

The API design is not definite yet, current bindings are based on Eth2.0-apis commit ceb555f9b40ff9c2094d038e9f70a19419e5b652.

Example

package main

import (
	"context"
	"fmt"
	"github.com/protolambda/eth2api"
	"github.com/protolambda/eth2api/client/beaconapi"
	"github.com/protolambda/zrnt/eth2/beacon/common"
	"github.com/protolambda/zrnt/eth2/configs"
	"net/http"
	"os"
	"time"
)

func main() {
	// Make an HTTP client (reuse connections!)
	client := &eth2api.Eth2HttpClient{
		Addr: "http://localhost:5052",
		Cli: &http.Client{
			Transport: &http.Transport{
				MaxIdleConnsPerHost: 123,
			},
			Timeout: 10 * time.Second,
		},
	  Codec: eth2api.JSONCodec{},
	}


	//// e.g. cancel requests with a context.WithTimeout/WithCancel/WithDeadline
	ctx := context.Background()

	var genesis eth2api.GenesisResponse
	if exists, err := beaconapi.Genesis(ctx, client, &genesis); !exists {
		fmt.Println("chain did not start yet")
		os.Exit(1)
	} else if err != nil {
		fmt.Println("failed to get genesis", err)
		os.Exit(1)
	}
	spec := configs.Mainnet
	// or load testnet config info from a YAML file
	// yaml.Unmarshal(data, &spec.Config)

	// every fork has a digest. Blocks are versioned by name in the API,
	// but wrapped with digest info in ZRNT to do enable different kinds of processing
	altairForkDigest := common.ComputeForkDigest(spec.ALTAIR_FORK_VERSION, genesis.GenesisValidatorsRoot)


	id := eth2api.BlockHead
	// or try other block ID types:
	// eth2api.BlockIdSlot(common.Slot(12345))
	// eth2api.BlockIdRoot(common.Root{0x.....})
	// eth2api.BlockGenesis

	// standard errors are part of the API.
	var versionedBlock eth2api.VersionedSignedBeaconBlock
	if exists, err := beaconapi.BlockV2(ctx, client, id, &versionedBlock); !exists {
		fmt.Println("block not found")
		os.Exit(1)
	} else if err != nil {
		fmt.Println("failed to get block", err)
		os.Exit(1)
	} else {
		fmt.Println("block version:", versionedBlock.Version)
		// get the block (any fork)
		fmt.Printf("data: %v\n", versionedBlock.Data)

		// add digest:
		envelope := versionedBlock.Data.Envelope(spec, altairForkDigest)
		fmt.Println("got block:", envelope.BlockRoot)
	}
}

Testing

Testing is not fully automated yet, awaiting first test vector release.

For now, you can:

  • Use protolambda/eth2-api-testgen to generate test vectors.
  • Copy the output dir to the tests dir in this repo. (cp -r ../eth2-api-testgen/output tests)
  • Run the Go tests in this repo (go test ./...)

Architecture

  • Strictly typed client bindings that send a PreparedRequest via a Client and decode the Response
  • Strictly typed server routes, backed by chain/db interfaces, with handlers which take a Request and produce a PreparedResponse
  • A Server is a mux of routes, calling the handlers, and encoding the PreparedResponse to serve to the requesting client

The Client and Server essentially do the encoding and transport, and are fully replaceable, without rewriting any API.

                                    __________________ Client __________________
                                   |                                            |
call binding ---PreparedRequest---> Eth2HttpClient ---http.Request--> HttpClient

                          _______________________ Server _________________________
                         |                                                        |
create route ---Route---> Eth2HttpMux ---http.Handler---> julienschmidt/httprouter


  ________________ Server ________________                                                     _________________ Server _______________ 
 |                                        |                                                   |                                        |
 ---http.Request---> Eth2HttpMux & Decoder ---Request---> route handler ---PreparedResponse---> Http server Encoder ---http.Response--->

How is this different from prysmaticlabs/ethereumapis?

  • Stricter typing, bazed on ZRNT
  • Full transport abstraction, no protobufs, implement it how you like
  • Focus on full JSON compatibility with Lighthouse and Teku
  • Avoids allocations, optimized requests
  • Minimal dependencies
  • Designed for customization. Swap the transport, change the encoding, add Eth2 Phase1, whatever.

License

MIT, see LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MinimalRequest

func MinimalRequest(ctx context.Context, cli Client, req PreparedRequest, dest interface{}) (err error)

func SimpleRequest

func SimpleRequest(ctx context.Context, cli Client, req PreparedRequest, dest interface{}) (exists bool, err error)

Types

type ApiError

type ApiError interface {
	error
	Code() uint
}

type ApiPeerId

type ApiPeerId string

Cryptographic hash of a peer’s public key. [Read more](https://docs.libp2p.io/concepts/peer-id/) Further (optional) processing in Go with: https://github.com/libp2p/go-libp2p-core/blob/a39b84ea2e340466d57fdb342c7d62f12957d972/peer/peer.go#L42

type AttesterDuty

type AttesterDuty struct {
	Pubkey common.BLSPubkey `json:"pubkey"`
	// Index of validator in validator registry
	ValidatorIndex common.ValidatorIndex `json:"validator_index"`
	// The committee index
	CommitteeIndex common.CommitteeIndex `json:"committee_index"`
	// Number of validators in committee
	CommitteeLength view.Uint64View `json:"committee_length"`
	// Number of committees at the provided slot
	CommitteesAtSlot view.Uint64View `json:"committees_at_slot"`
	// Index of validator in committee
	ValidatorCommitteeIndex view.Uint64View `json:"validator_committee_index"`
	// The slot at which the validator must attest.
	Slot common.Slot `json:"slot"`
}

type BasicResponse

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

func (*BasicResponse) Body

func (b *BasicResponse) Body() interface{}

func (*BasicResponse) Code

func (b *BasicResponse) Code() uint

func (*BasicResponse) Headers

func (b *BasicResponse) Headers() Headers

type BeaconBlockHeaderAndInfo

type BeaconBlockHeaderAndInfo struct {
	Root      common.Root                    `json:"root"`
	Canonical bool                           `json:"canonical"`
	Header    common.SignedBeaconBlockHeader `json:"header"`
}

type BeaconCommitteeSubscribeSignal

type BeaconCommitteeSubscribeSignal struct {
	ValidatorIndex common.ValidatorIndex `json:"validator_index"`
	CommitteeIndex common.CommitteeIndex `json:"committee_index"`
	// Number of committees at the returned slot
	CommitteesAtSlot view.Uint64View `json:"committees_at_slot"`
	// Should be slot at which validator is assigned to attest
	Slot common.Slot `json:"slot"`
	// Signals to BN that a validator on the VC has been chosen for aggregator role.
	IsAggregator view.BoolView `json:"is_aggregator"`
}

type BlockId

type BlockId interface {
	BlockId() string
}

Block identifier Can have different shapes. E.g. BlockHead, BlockIdSlot(123), BlockIdRoot(Root{0x...})

func ParseBlockId

func ParseBlockId(v string) (BlockId, error)

type BlockIdRoot

type BlockIdRoot common.Root

func (BlockIdRoot) BlockId

func (r BlockIdRoot) BlockId() string

type BlockIdSlot

type BlockIdSlot common.Slot

func (BlockIdSlot) BlockId

func (s BlockIdSlot) BlockId() string

type BlockIdStrMode

type BlockIdStrMode string
const (
	BlockHead      BlockIdStrMode = "head"
	BlockGenesis   BlockIdStrMode = "genesis"
	BlockFinalized BlockIdStrMode = "finalized"
)

func (BlockIdStrMode) BlockId

func (m BlockIdStrMode) BlockId() string

type ChainHead

type ChainHead struct {
	Root common.Root `json:"root"`
	Slot common.Slot `json:"slot"`
}

type Client

type Client interface {
	Request(ctx context.Context, req PreparedRequest) Response
}

type ClientApiErr

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

func (ClientApiErr) Code

func (ce ClientApiErr) Code() uint

type ClientErr

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

func (ClientErr) Decode

func (ce ClientErr) Decode(dest interface{}) (uint, error)

type ClientFunc

type ClientFunc func(ctx context.Context, req PreparedRequest) Response

func (ClientFunc) Request

func (fn ClientFunc) Request(ctx context.Context, req PreparedRequest) Response

type Codec

type Codec interface {
	EncodeResponseBody(w io.Writer, data interface{}) error
	DecodeResponseBody(code uint, r io.ReadCloser, dest interface{}) error
	EncodeRequestBody(w io.Writer, body interface{}) error
	DecodeRequestBody(r io.ReadCloser, dst interface{}) error
	ContentType() []string
}

type Committee

type Committee struct {
	// Committee index at a slot
	Index common.CommitteeIndex `json:"index"`

	// Slot the committee performs duties on
	Slot common.Slot `json:"slot"`

	// List of validator indices assigned to this committee
	Validators []common.ValidatorIndex `json:"validators"`
}

type ConnectionDirection

type ConnectionDirection string
const (
	ConnectionDirectionInbound  ConnectionDirection = "inbound"
	ConnectionDirectionOutbound ConnectionDirection = "outbound"
)

type ConnectionState

type ConnectionState string
const (
	ConnectionStateDisconnected  ConnectionState = "disconnected"
	ConnectionStateConnecting    ConnectionState = "connecting"
	ConnectionStateConnected     ConnectionState = "connected"
	ConnectionStateDisconnecting ConnectionState = "disconnecting"
)

type DataWrap

type DataWrap struct {
	Data interface{} `json:"data"`
}

DataWrap is a util to accommodate responses which are wrapped with a single field container with key "data".

func Wrap

func Wrap(data interface{}) *DataWrap

type DependentAttesterDuties

type DependentAttesterDuties struct {
	// Duties are valid only on the chain with this given block root
	DependentRoot common.Root    `json:"dependent_root"`
	Data          []AttesterDuty `json:"data"`
}

Wrapper around the original AttesterDuty response

type DependentProposerDuty

type DependentProposerDuty struct {
	// Duties are valid only on the chain with this given block root
	DependentRoot common.Root    `json:"dependent_root"`
	Data          []ProposerDuty `json:"data"`
}

Wrapper around the original ProposerDuty response

type DepositContractResponse

type DepositContractResponse struct {
	// Id of Eth1 chain on which contract is deployed.
	ChainID view.Uint64View `json:"chain_id"`
	// Hex encoded deposit contract address with 0x prefix
	Address common.Eth1Address `json:"address"`
}

type ErrorMessage

type ErrorMessage struct {
	// Either specific error code in case of invalid request or http status code
	CodeValue uint `json:"code"`
	// Message describing error
	Message string `json:"message"`
	// Optional stacktraces, sent when node is in debug mode
	Stacktraces []string `json:"stacktraces,omitempty"`
	// Optional list of individual items that have failed
	Failures []IndexedErrorMessageItem `json:"failures,omitempty"`
}

func (*ErrorMessage) Code

func (err *ErrorMessage) Code() uint

func (*ErrorMessage) Error

func (err *ErrorMessage) Error() string

func (*ErrorMessage) IndexedErrors

func (m *ErrorMessage) IndexedErrors() []IndexedErrorMessageItem

type Eth2HttpClient

type Eth2HttpClient struct {
	Addr  string
	Cli   HTTPClient
	Codec Codec
}

func (*Eth2HttpClient) Request

func (cli *Eth2HttpClient) Request(ctx context.Context, req PreparedRequest) Response

type FinalityCheckpoints

type FinalityCheckpoints struct {
	PreviousJustified common.Checkpoint `json:"previous_justified"`
	CurrentJustified  common.Checkpoint `json:"current_justified"`
	Finalized         common.Checkpoint `json:"finalized"`
}

type GenesisResponse

type GenesisResponse struct {
	GenesisTime           common.Timestamp `json:"genesis_time"`
	GenesisValidatorsRoot common.Root      `json:"genesis_validators_root"`
	GenesisForkVersion    common.Version   `json:"genesis_fork_version"`
}

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type HandlerFn

type HandlerFn func(ctx context.Context, req Request) PreparedResponse

type Headers

type Headers map[string]string

type HttpResponse

type HttpResponse struct {
	*http.Response
	Codec Codec
}

func (*HttpResponse) Decode

func (resp *HttpResponse) Decode(dest interface{}) (code uint, err error)

type HttpRouter

type HttpRouter struct {
	httprouter.Router
	Codec         Codec
	OnEncodingErr func(error)
}

func NewHttpRouter

func NewHttpRouter() *HttpRouter

func (*HttpRouter) AddRoute

func (r *HttpRouter) AddRoute(route Route)

func (*HttpRouter) ServeHTTP

func (r *HttpRouter) ServeHTTP(w http.ResponseWriter, req *http.Request)

type IndexedError

type IndexedError interface {
	IndexedErrors() []IndexedErrorMessageItem
}

Optional error enhancement, applicable for API methods that can have a partial success.

type IndexedErrorMessageItem

type IndexedErrorMessageItem struct {
	// Index of item in the request list that caused the error
	Index uint `json:"index"`
	// Message describing error
	Message string `json:"message"`
}

type JSONCodec

type JSONCodec struct{}

func (JSONCodec) ContentType

func (JSONCodec) ContentType() []string

func (JSONCodec) DecodeRequestBody

func (JSONCodec) DecodeRequestBody(r io.ReadCloser, dst interface{}) error

func (JSONCodec) DecodeResponseBody

func (JSONCodec) DecodeResponseBody(code uint, r io.ReadCloser, dest interface{}) error

func (JSONCodec) EncodeRequestBody

func (JSONCodec) EncodeRequestBody(w io.Writer, body interface{}) error

func (JSONCodec) EncodeResponseBody

func (JSONCodec) EncodeResponseBody(w io.Writer, data interface{}) error

type NetworkIdentity

type NetworkIdentity struct {
	PeerID ApiPeerId `json:"peer_id"`

	// Ethereum node record. [Read more](https://eips.ethereum.org/EIPS/eip-778)
	ENR string `json:"enr"`

	// Node's addresses on which eth2 rpc requests are served. [Read more](https://docs.libp2p.io/reference/glossary/#multiaddr)
	P2PAddresses []string `json:"p2p_addresses"`

	// Node's addresses on which is listening for discv5 requests. [Read more](https://docs.libp2p.io/reference/glossary/#multiaddr)
	DiscoveryAddresses []string `json:"discovery_addresses"`

	// Based on eth2 Metadata object
	Metadata common.MetaData `json:"metadata"`
}

Network identity data, not typed in detail, using libp2p and discv5 dependencies for further processing is optional.

type NodeVersionResponse

type NodeVersionResponse struct {
	Version string `json:"version"`
}

type Peer

type Peer struct {
	PeerID             ApiPeerId           `json:"peer_id"`
	ENR                string              `json:"enr"`
	LastSeenP2PAddress string              `json:"last_seen_p2p_address"`
	State              ConnectionState     `json:"state"`
	Direction          ConnectionDirection `json:"direction"`
}

type PeerCountResponse

type PeerCountResponse struct {
	Disconnected  view.Uint64View `json:"disconnected"`
	Connecting    view.Uint64View `json:"connecting"`
	Connected     view.Uint64View `json:"connected"`
	Disconnecting view.Uint64View `json:"disconnecting"`
}

Retrieves number of known peers.

type PlainGET

type PlainGET string

func (PlainGET) Body

func (p PlainGET) Body() interface{}

func (PlainGET) Method

func (p PlainGET) Method() ReqMethod

func (PlainGET) Path

func (p PlainGET) Path() string

func (PlainGET) Query

func (p PlainGET) Query() Query

type PreparedRequest

type PreparedRequest interface {
	// The type of request
	Method() ReqMethod

	// Body, optional. Returns nil if no body. Only used for PUT/POST methods.
	Body() interface{}

	// Path to request, including any path variable contents
	Path() string

	// Query params to add to the request, may be nil
	Query() Query
}

func BodyPOST

func BodyPOST(path string, body interface{}) PreparedRequest

func FmtGET

func FmtGET(format string, data ...interface{}) PreparedRequest

func FmtQueryGET

func FmtQueryGET(query Query, format string, data ...interface{}) PreparedRequest

func QueryGET

func QueryGET(query Query, path string) PreparedRequest

type PreparedResponse

type PreparedResponse interface {
	//
	Code() uint
	// body to encode as response, may be nil
	Body() interface{}
	// headers to put into the response, may be nil
	Headers() Headers
}

func RespondAccepted

func RespondAccepted(err error) PreparedResponse

func RespondBadInput

func RespondBadInput(err error) PreparedResponse

func RespondBadInputs

func RespondBadInputs(msg string, failures []IndexedErrorMessageItem) PreparedResponse

func RespondInternalError

func RespondInternalError(err error) PreparedResponse

func RespondNotFound

func RespondNotFound(msg string) PreparedResponse

func RespondOK

func RespondOK(body interface{}) PreparedResponse

func RespondOKMsg

func RespondOKMsg(msg string) PreparedResponse

func RespondSyncing

func RespondSyncing(msg string) PreparedResponse

type ProposerDuty

type ProposerDuty struct {
	Pubkey common.BLSPubkey `json:"pubkey"`
	// Index of validator in validator registry
	ValidatorIndex common.ValidatorIndex `json:"validator_index"`
	// The slot at which the validator must propose block.
	Slot common.Slot
}

type Query

type Query map[string]interface{}

simplified Query interface. No duplicate key entries

type ReqMethod

type ReqMethod string
const (
	GET  ReqMethod = "GET"
	POST ReqMethod = "POST"
)

type Request

type Request interface {
	DecodeBody(dst interface{}) error
	Param(name string) string
	Query(name string) (values []string, ok bool)
}

type Response

type Response interface {
	// Decode into destination type. May throw a decoding error.
	// Or throws DecodeNoContentErr if it was an error without returned value.
	// Call with nil to just close the response contents.
	// May only be called once.
	Decode(dest interface{}) (code uint, err error)
}

type RootResponse

type RootResponse struct {
	Root common.Root `json:"root"`
}

type Route

type Route interface {
	Method() ReqMethod
	Route() string
	Handle(ctx context.Context, req Request) PreparedResponse
}

func MakeRoute

func MakeRoute(method ReqMethod, path string, handle HandlerFn) Route

type Server

type Server interface {
	AddRoute(handler Route)
}

type SignedBeaconBlock

type SignedBeaconBlock interface {
	beacon.OpaqueBlock
}

type StateId

type StateId interface {
	StateId() string
}

func ParseStateId

func ParseStateId(v string) (StateId, error)

type StateIdRoot

type StateIdRoot common.Root

func (StateIdRoot) StateId

func (r StateIdRoot) StateId() string

type StateIdSlot

type StateIdSlot common.Slot

func (StateIdSlot) StateId

func (s StateIdSlot) StateId() string

type StateIdStrMode

type StateIdStrMode string
const (
	StateHead      StateIdStrMode = "head"
	StateGenesis   StateIdStrMode = "genesis"
	StateFinalized StateIdStrMode = "finalized"
	StateJustified StateIdStrMode = "justified"
)

func (StateIdStrMode) StateId

func (m StateIdStrMode) StateId() string

type StatusFilter

type StatusFilter []ValidatorStatus

func (StatusFilter) String

func (sf StatusFilter) String() string

type SyncCommitteeDuty

type SyncCommitteeDuty struct {
	Pubkey                        common.BLSPubkey      `json:"pubkey"`
	ValidatorIndex                common.ValidatorIndex `json:"validator_index"`
	ValidatorSyncCommitteeIndices []view.Uint64View     `json:"validator_sync_committee_indices"`
}

type SyncCommitteeSubscribeSignal

type SyncCommitteeSubscribeSignal struct {
	ValidatorIndex common.ValidatorIndex `json:"validator_index"`
	// positions of the validator-index relative to the complete sync committee (a validator can have multiple)
	SyncCommitteeIndices []view.Uint64View `json:"sync_committee_indices"`
	UntilEpoch           common.Epoch      `json:"until_epoch"`
}

type SyncCommittees

type SyncCommittees struct {
	// All of the validator indices in the current sync committee
	Validators []common.ValidatorIndex `json:"validators"`
	// Subcommittee slices of the current sync committee
	ValidatorAggregates [][]common.ValidatorIndex `json:"validator_aggregates"`
}

type SyncingStatus

type SyncingStatus struct {
	// Head slot node is trying to reach
	HeadSlot common.Slot `json:"head_slot"`
	// How many slots node needs to process to reach head. 0 if synced.
	SyncDistance common.Slot `json:"sync_distance"`
}

type ValidatorBalanceResponse

type ValidatorBalanceResponse struct {
	// Index of validator in validator registry.
	Index common.ValidatorIndex `json:"index"`

	// Current validator balance in gwei
	Balance common.Gwei `json:"balance"`
}

type ValidatorId

type ValidatorId interface {
	ValidatorId() string
}

func ParseValidatorId

func ParseValidatorId(v string) (ValidatorId, error)

type ValidatorIdFilter

type ValidatorIdFilter []ValidatorId

func (ValidatorIdFilter) String

func (vidf ValidatorIdFilter) String() string

type ValidatorIdIndex

type ValidatorIdIndex common.ValidatorIndex

func (ValidatorIdIndex) ValidatorId

func (v ValidatorIdIndex) ValidatorId() string

type ValidatorIdPubkey

type ValidatorIdPubkey common.BLSPubkey

func (ValidatorIdPubkey) ValidatorId

func (v ValidatorIdPubkey) ValidatorId() string

type ValidatorResponse

type ValidatorResponse struct {
	// Index of validator in validator registry.
	Index common.ValidatorIndex `json:"index"`
	// Current validator balance in gwei
	Balance common.Gwei `json:"balance"`
	// TODO
	Status ValidatorStatus `json:"status"`
	// The validator as defined in the registry in the BeaconState
	Validator phase0.Validator `json:"validator"`
}

type ValidatorStatus

type ValidatorStatus string

TODO enum with or without additional values?

const (
	ValidatorStatusUnknown                     ValidatorStatus = "unknown"
	ValidatorStatusWaitingForEligibility       ValidatorStatus = "waiting_for_eligibility"
	ValidatorStatusWaitingForFinality          ValidatorStatus = "waiting_for_finality"
	ValidatorStatusWaitingInQueue              ValidatorStatus = "waiting_in_queue"
	ValidatorStatusStandbyForActive            ValidatorStatus = "standby_for_active"
	ValidatorStatusActive                      ValidatorStatus = "active"
	ValidatorStatusActiveAwaitingVoluntaryExit ValidatorStatus = "active_awaiting_voluntary_exit"
	ValidatorStatusActiveAwaitingSlashedExit   ValidatorStatus = "active_awaiting_slashed_exit"
	ValidatorStatusExitedVoluntarily           ValidatorStatus = "exited_voluntarily"
	ValidatorStatusExitedSlashed               ValidatorStatus = "exited_slashed"
	ValidatorStatusWithdrawable                ValidatorStatus = "withdrawable"
	ValidatorStatusWithdrawn                   ValidatorStatus = "withdrawn"
)

status names known from lighthouse, differ from spec, TODO

func (ValidatorStatus) String

func (vs ValidatorStatus) String() string

type VersionedBeaconBlock

type VersionedBeaconBlock struct {
	Version string `json:"version"`
	// Data is *phase0.BeaconBlock, *altair.BeaconBlock,
	// *bellatrix.BeaconBlock or *sharding.BeaconBlock.
	Data common.SpecObj `json:"data"`
}

func (*VersionedBeaconBlock) UnmarshalJSON

func (v *VersionedBeaconBlock) UnmarshalJSON(b []byte) error

type VersionedBeaconState

type VersionedBeaconState struct {
	Version string `json:"version"`
	// Data is *phase0.BeaconState, *altair.BeaconState, *bellatrix.BeaconState or *sharding.BeaconState.
	// See the Tree(spec) method to transform into a binary-tree backed state for advanced processing.
	Data common.SpecObj `json:"data"`
}

func (*VersionedBeaconState) Tree

func (*VersionedBeaconState) UnmarshalJSON

func (v *VersionedBeaconState) UnmarshalJSON(b []byte) error

type VersionedSignedBeaconBlock

type VersionedSignedBeaconBlock struct {
	Version string `json:"version"`
	// Data is *phase0.SignedBeaconBlock, *altair.SignedBeaconBlock,
	// *bellatrix.SignedBeaconBlock or *sharding.SignedBeaconBlock.
	Data SignedBeaconBlock `json:"data"`
}

func (*VersionedSignedBeaconBlock) UnmarshalJSON

func (v *VersionedSignedBeaconBlock) UnmarshalJSON(b []byte) error

Directories

Path Synopsis
client
server

Jump to

Keyboard shortcuts

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