eth2

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: LGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoResult = errors.New("no result in JSON-RPC response")

Functions

func AssembleProof

func AssembleProof(header BlockHeader, log types.Log, receipts []*types.Receipt, method string, fId msg.ChainId, proofType int64) ([]byte, error)

func Generate

func Generate(slot, endpoint string) ([][32]byte, string, string, error)

func GenerateByApi

func GenerateByApi(slot []string) [][32]byte

Types

type AttestationData

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

type Attestations

type Attestations struct {
	AggregationBits string          `json:"aggregation_bits"`
	Data            AttestationData `json:"data"`
	Signature       string          `json:"signature"`
}

type AttestedHeader

type AttestedHeader struct {
	Beacon          Beacon    `json:"beacon"`
	Execution       Execution `json:"execution"`
	ExecutionBranch []string  `json:"execution_branch"`
}

type Beacon

type Beacon 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"`
}

type BeaconBlockHeader

type BeaconBlockHeader struct {
	Slot          uint64   `json:"slot"`
	ProposerIndex uint64   `json:"proposer_index"`
	ParentRoot    [32]byte `json:"parent_root"` // bytes32
	StateRoot     [32]byte `json:"state_root"`  // bytes32
	BodyRoot      [32]byte `json:"body_root"`
}

type BeaconHeadersData

type BeaconHeadersData struct {
	Root      string `json:"root"`
	Canonical bool   `json:"canonical"`
	Header    Header `json:"header"`
}

type BeaconHeadersResp

type BeaconHeadersResp struct {
	Data                BeaconHeadersData `json:"data"`
	ExecutionOptimistic bool              `json:"execution_optimistic"`
}

type BlockData

type BlockData struct {
	Message   BlocksMessage `json:"message"`
	Signature string        `json:"signature"`
}

type BlockHeader

type BlockHeader struct {
	ParentHash       [32]byte       `json:"parent_hash"`
	Sha3Uncles       [32]byte       `json:"sha_3_uncles"`
	Miner            common.Address `json:"miner"`
	StateRoot        [32]byte       `json:"stateRoot"`
	TransactionsRoot [32]byte       `json:"transactionsRoot"`
	ReceiptsRoot     [32]byte       `json:"receiptsRoot"`
	LogsBloom        []byte         `json:"logsBloom"`
	Difficulty       *big.Int       `json:"difficulty"`
	Number           *big.Int       `json:"number"`
	GasLimit         *big.Int       `json:"gasLimit"`
	GasUsed          *big.Int       `json:"gasUsed"`
	Timestamp        *big.Int       `json:"timestamp"`
	ExtraData        []byte         `json:"extraData"`
	MixHash          [32]byte       `json:"mixHash"`
	Nonce            []byte         `json:"nonce"`
	BaseFeePerGas    *big.Int       `json:"baseFeePerGas"`
	WithdrawalsRoot  [32]byte       `json:"withdrawalsRoot"`
}

func ConvertHeader

func ConvertHeader(header *ethclient.Header) *BlockHeader

type BlocksMessage

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

type BlocksResp

type BlocksResp struct {
	Data                BlockData `json:"data"`
	ExecutionOptimistic bool      `json:"execution_optimistic"`
}

type Body

type Body struct {
	RandaoReveal      string         `json:"randao_reveal"`
	Eth1Data          Eth1Data       `json:"eth1_data"`
	Graffiti          string         `json:"graffiti"`
	ProposerSlashings []interface{}  `json:"proposer_slashings"`
	AttesterSlashings []interface{}  `json:"attester_slashings"`
	Attestations      []Attestations `json:"attestations"`
	Deposits          []interface{}  `json:"deposits"`
	VoluntaryExits    []interface{}  `json:"voluntary_exits"`
	SyncAggregate     SyncAggregate  `json:"sync_aggregate"`
	ExecutionPayload  Execution      `json:"execution_payload"`
}

type Client

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

func DialHttp

func DialHttp(endpoint string) (*Client, error)

func (*Client) BeaconHeaders

func (c *Client) BeaconHeaders(ctx context.Context, blockId constant.BlockIdOfEth2) (*BeaconHeadersResp, error)

func (*Client) CallContext

func (c *Client) CallContext(ctx context.Context, url string, result interface{}) error

func (*Client) FinallyUpdate

func (c *Client) FinallyUpdate(ctx context.Context) (*FinalityUpdateResp, error)

func (*Client) GetBlocks

func (c *Client) GetBlocks(ctx context.Context, blockId string) (*BlocksResp, error)

func (*Client) LightClientUpdate

func (c *Client) LightClientUpdate(ctx context.Context, startPeriod uint64) (*LightClientUpdatesResp, error)

type CommonData

type CommonData struct {
	StatusCode          int         `json:"statusCode"`
	Error               string      `json:"error"`
	Message             string      `json:"message"`
	Data                interface{} `json:"data"`
	ExecutionOptimistic bool        `json:"execution_optimistic"`
	Version             string      `json:"version"`
}

type CommonDataArray

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

type ContractExecution

type ContractExecution struct {
	ParentHash       [32]byte       `json:"parent_hash"`
	FeeRecipient     common.Address `json:"fee_recipient"`
	StateRoot        [32]byte       `json:"state_root"`
	ReceiptsRoot     [32]byte       `json:"receipts_root"`
	LogsBloom        []byte         `json:"logs_bloom"`
	PrevRandao       [32]byte       `json:"prev_randao"`
	BlockNumber      *big.Int       `json:"block_number"`
	GasLimit         *big.Int       `json:"gas_limit"`
	GasUsed          *big.Int       `json:"gas_used"`
	Timestamp        *big.Int       `json:"timestamp"`
	ExtraData        []byte         `json:"extra_data"`
	BaseFeePerGas    *big.Int       `json:"base_fee_per_gas"`
	BlockHash        [32]byte       `json:"block_hash"`
	TransactionsRoot [32]byte       `json:"transactions_root"`
	WithdrawalsRoot  [32]byte       `json:"withdrawals_root"`
}

func ConvertExecution

func ConvertExecution(execution *Execution) (*ContractExecution, error)

type ContractSyncAggregate

type ContractSyncAggregate struct {
	SyncCommitteeBits      []byte `json:"sync_committee_bits"`
	SyncCommitteeSignature []byte `json:"sync_committee_signature"`
}

type ContractSyncCommittee

type ContractSyncCommittee struct {
	Pubkeys         []byte // 48 * 512
	AggregatePubkey []byte // 48
}

type Eth1Data

type Eth1Data struct {
	DepositRoot  string `json:"deposit_root"`
	DepositCount string `json:"deposit_count"`
	BlockHash    string `json:"block_hash"`
}

type Execution

type Execution 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"`
	TransactionsRoot string `json:"transactions_root"`
	WithdrawalsRoot  string `json:"withdrawals_root"`
}

type FinalityUpdateData

type FinalityUpdateData struct {
	AttestedHeader  NewAttestedHeader  `json:"attested_header"`
	FinalizedHeader NewFinalizedHeader `json:"finalized_header"`
	FinalityBranch  []string           `json:"finality_branch"`
	SyncAggregate   SyncAggregate      `json:"sync_aggregate"`
	SignatureSlot   string             `json:"signature_slot"`
}

type FinalityUpdateResp

type FinalityUpdateResp struct {
	Data    FinalityUpdateData `json:"data"`
	Version string             `json:"version"`
}

type FinalizedHeader

type FinalizedHeader struct {
	Beacon          Beacon    `json:"beacon"`
	Execution       Execution `json:"execution"`
	ExecutionBranch []string  `json:"execution_branch"`
}
type Header struct {
	Message   Message `json:"message"`
	Signature string  `json:"signature"`
}

type LightClientUpdate

type LightClientUpdate struct {
	AttestedHeader          BeaconBlockHeader     `json:"attested_header"`
	SignatureSlot           uint64                `json:"signature_slot"`
	SyncAggregate           ContractSyncAggregate `json:"sync_aggregate"`
	NextSyncCommittee       ContractSyncCommittee `json:"nextSyncCommittee"`
	NextSyncCommitteeBranch [][32]byte            `json:"nextSyncCommitteeBranch"`
	FinalizedHeader         BeaconBlockHeader
	FinalityBranch          [][32]byte
	ExecutionBranch         [][32]byte
	FinalizedExecution      *ContractExecution
}

type LightClientUpdatesData

type LightClientUpdatesData struct {
	AttestedHeader          NewAttestedHeader  `json:"attested_header"`
	NextSyncCommittee       NextSyncCommittee  `json:"next_sync_committee"`
	NextSyncCommitteeBranch []string           `json:"next_sync_committee_branch"`
	FinalizedHeader         NewFinalizedHeader `json:"finalized_header"`
	FinalityBranch          []string           `json:"finality_branch"`
	SyncAggregate           SyncAggregate      `json:"sync_aggregate"`
	SignatureSlot           string             `json:"signature_slot"`
}

type LightClientUpdatesResp

type LightClientUpdatesResp struct {
	Data    LightClientUpdatesData `json:"data"`
	Version string                 `json:"version"`
}

type Message

type Message 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"`
}

type NewAttestedHeader

type NewAttestedHeader struct {
	Beacon          Beacon    `json:"beacon"`
	Execution       Execution `json:"execution"`
	ExecutionBranch []string  `json:"execution_branch"`
}

type NewFinalizedHeader

type NewFinalizedHeader struct {
	Beacon          Beacon    `json:"beacon"`
	Execution       Execution `json:"execution"`
	ExecutionBranch []string  `json:"execution_branch"`
}

type NextSyncCommittee

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

type Receipt added in v1.2.0

type Receipt struct {
	*types.Receipt
}

type ReceiptProof

type ReceiptProof struct {
	Header    BlockHeader
	TxReceipt mapprotocol.TxReceipt
	KeyIndex  []byte
	Proof     [][]byte
}

type Receipts added in v1.2.0

type Receipts []*Receipt

func (Receipts) EncodeIndex added in v1.2.0

func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer)

func (Receipts) Len added in v1.2.0

func (rs Receipts) Len() int

type Source

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

type SyncAggregate

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

type Target

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

Jump to

Keyboard shortcuts

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