lib

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouter

func NewRouter(relayURLs []string, store Store, log *logrus.Entry) (*mux.Router, error)

NewRouter creates a json rpc router that handles all methods

Types

type BlindedBeaconBlock

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

BlindedBeaconBlock forked from https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#beaconblock

type BlindedBeaconBlockBodyPartial

type BlindedBeaconBlockBodyPartial struct {
	ExecutionPayload      ExecutionPayloadHeaderOnlyBlockHash `json:"execution_payload_header"`
	ExecutionPayloadCamel ExecutionPayloadHeaderOnlyBlockHash `json:"executionPayloadHeader"`
}

BlindedBeaconBlockBodyPartial a partial block body only containing a payload, in both snake_case and camelCase

type ExecutionPayloadHeaderOnlyBlockHash

type ExecutionPayloadHeaderOnlyBlockHash struct {
	BlockHash      string `json:"block_hash"`
	BlockHashCamel string `json:"blockHash"`
}

ExecutionPayloadHeaderOnlyBlockHash an execution payload with only a block hash, used for BlindedBeaconBlockBodyPartial

type ExecutionPayloadWithTxRootV1

type ExecutionPayloadWithTxRootV1 struct {
	ParentHash       common.Hash    `json:"parentHash" gencodec:"required"`
	FeeRecipient     common.Address `json:"feeRecipient" gencodec:"required"`
	StateRoot        common.Hash    `json:"stateRoot" gencodec:"required"`
	ReceiptsRoot     common.Hash    `json:"receiptsRoot" gencodec:"required"`
	LogsBloom        []byte         `json:"logsBloom" gencodec:"required"`
	PrevRandao       common.Hash    `json:"prevRandao" gencodec:"required"`
	Number           uint64         `json:"blockNumber" gencodec:"required"`
	GasLimit         uint64         `json:"gasLimit" gencodec:"required"`
	GasUsed          uint64         `json:"gasUsed" gencodec:"required"`
	Timestamp        uint64         `json:"timestamp" gencodec:"required"`
	ExtraData        []byte         `json:"extraData" gencodec:"required"`
	BaseFeePerGas    *big.Int       `json:"baseFeePerGas" gencodec:"required"`
	BlockHash        common.Hash    `json:"blockHash" gencodec:"required"`
	Transactions     *[]string      `json:"transactions,omitempty"`
	TransactionsRoot common.Hash    `json:"transactionsRoot"`
	FeeRecipientDiff *big.Int       `json:"feeRecipientDiff" gencodec:"required"`
}

ExecutionPayloadWithTxRootV1 is the same as ExecutionPayloadV1 with a transactionsRoot in addition to transactions

func (ExecutionPayloadWithTxRootV1) MarshalJSON

func (e ExecutionPayloadWithTxRootV1) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*ExecutionPayloadWithTxRootV1) UnmarshalJSON

func (e *ExecutionPayloadWithTxRootV1) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type ForkChoiceResponse

type ForkChoiceResponse struct {
	PayloadStatus PayloadStatus  `json:"payloadStatus,omitempty"`
	PayloadID     *hexutil.Bytes `json:"payloadId,omitempty"`
}

ForkChoiceResponse is a workaround for mergemock allowing these fields to be null

type ForkchoiceStatus

type ForkchoiceStatus string

ForkchoiceStatus as defined in the engine spec: https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md#engine_forkchoiceupdatedv1

var (
	// ForkchoiceStatusValid indicates the fork choice is valid
	ForkchoiceStatusValid ForkchoiceStatus = "VALID"

	// ForkchoiceStatusInvalid indicates the fork choice is invalid
	ForkchoiceStatusInvalid ForkchoiceStatus = "INVALID"

	// ForkchoiceStatusAccepted indicates the fork choice is accepted
	ForkchoiceStatusAccepted ForkchoiceStatus = "ACCEPTED"

	// ForkchoiceStatusSyncing indicates the node is still syncing
	ForkchoiceStatusSyncing ForkchoiceStatus = "SYNCING"

	// ForkchoiceStatusInvalidBlockHash indicates supplied blockhash is unknown
	ForkchoiceStatusInvalidBlockHash ForkchoiceStatus = "INVALID_BLOCK_HASH"

	// ForkchoiceStatusInvalidTerminalBlock indicates the latest valid ancestor is not a descendant of configured TTD block
	ForkchoiceStatusInvalidTerminalBlock ForkchoiceStatus = "INVALID_TERMINAL_BLOCK"
)

type PayloadStatus

type PayloadStatus struct {
	Status          ForkchoiceStatus `json:"status,omitempty"`
	LatestValidHash string           `json:"latestValidHash,omitempty"`
	ValidationError string           `json:"validationError,omitempty"`
}

PayloadStatus is used in ForkChoiceResponse

type RelayService

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

RelayService TODO

func (*RelayService) ForkchoiceUpdatedV1

func (m *RelayService) ForkchoiceUpdatedV1(_ *http.Request, args *[]interface{}, result *ForkChoiceResponse) error

ForkchoiceUpdatedV1 TODO

func (*RelayService) GetPayloadHeaderV1

func (m *RelayService) GetPayloadHeaderV1(_ *http.Request, args *string, result *ExecutionPayloadWithTxRootV1) error

GetPayloadHeaderV1 TODO

func (*RelayService) ProposeBlindedBlockV1

func (m *RelayService) ProposeBlindedBlockV1(_ *http.Request, args *SignedBlindedBeaconBlock, result *ExecutionPayloadWithTxRootV1) error

ProposeBlindedBlockV1 TODO

type SignedBlindedBeaconBlock

type SignedBlindedBeaconBlock struct {
	Message   *BlindedBeaconBlock `json:"message"`
	Signature string              `json:"signature"`
}

SignedBlindedBeaconBlock forked from https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#signedbeaconblockheader

type Store

type Store interface {
	GetExecutionPayload(blockHash common.Hash) *ExecutionPayloadWithTxRootV1
	SetExecutionPayload(blockHash common.Hash, payload *ExecutionPayloadWithTxRootV1)

	SetForkchoiceResponse(boostPayloadID, relayURL, relayPayloadID string)
	GetForkchoiceResponse(boostPayloadID string) (map[string]string, bool)

	Cleanup()
}

Store stores payloads and retrieves them based on blockHash hashes

func NewStore

func NewStore() Store

NewStore creates an in-mem store. Does not call Store.Cleanup() by default, so memory will build up. Use NewStoreWithCleanup if you want to start a cleanup loop as well.

func NewStoreWithCleanup

func NewStoreWithCleanup() Store

NewStoreWithCleanup creates an in-mem store, and starts goroutine that periodically removes old entries.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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