common

package
v1.0.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: AGPL-3.0 Imports: 26 Imported by: 6

Documentation

Overview

Package common provides things used by various other components

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServerAlreadyRunning = errors.New("server already running")

	SlotsPerEpoch    = 32
	DurationPerSlot  = time.Second * 12
	DurationPerEpoch = DurationPerSlot * time.Duration(SlotsPerEpoch)
)
View Source
var (
	ErrInvalidSlot      = errors.New("invalid slot")
	ErrInvalidHash      = errors.New("invalid hash")
	ErrInvalidPubkey    = errors.New("invalid pubkey")
	ErrInvalidSignature = errors.New("invalid signature")
)
View Source
var (
	ErrUnknownNetwork = errors.New("unknown network")
	ErrEmptyPayload   = errors.New("empty payload")
)
View Source
var (
	EthNetworkRopsten  = "ropsten"
	EthNetworkSepolia  = "sepolia"
	EthNetworkGoerli   = "goerli"
	EthNetworkMainnet  = "mainnet"
	EthNetworkZhejiang = "zhejiang"

	CapellaForkVersionRopsten = "0x03001020"
	CapellaForkVersionSepolia = "0x90000072"
	CapellaForkVersionGoerli  = "0x03001020"
	CapellaForkVersionMainnet = "0x03000000"

	// Zhejiang details
	GenesisForkVersionZhejiang    = "0x00000069"
	GenesisValidatorsRootZhejiang = "0x53a92d8f2bb1d85f62d16a156e6ebcd1bcaba652d0900b2c2f387826f3481f6f"
	BellatrixForkVersionZhejiang  = "0x00000071"
	CapellaForkVersionZhejiang    = "0x00000072"
)
View Source
var (
	ErrInvalidForkVersion = errors.New("invalid fork version")
	ErrHTTPErrorResponse  = errors.New("got an HTTP error response")
)
View Source
var TestLog = logrus.WithField("testing", true)

TestLog is used to log information in the test methods

View Source
var ValidPayloadRegisterValidator = types.SignedValidatorRegistration{
	Message: &types.RegisterValidatorRequestMessage{
		FeeRecipient: _HexToAddress("0xdb65fEd33dc262Fe09D9a2Ba8F80b329BA25f941"),
		Timestamp:    1234356,
		GasLimit:     278234191203,
		Pubkey: _HexToPubkey(
			"0x8a1d7b8dd64e0aafe7ea7b6c95065c9364cf99d38470c12ee807d55f7de1529ad29ce2c422e0b65e3d5a05c02caca249"),
	},

	Signature: _HexToSignature(
		"0x8209b5391cd69f392b1f02dbc03bab61f574bb6bb54bf87b59e2a85bdc0756f7db6a71ce1b41b727a1f46ccc77b213bf0df1426177b5b29926b39956114421eaa36ec4602969f6f6370a44de44a6bce6dae2136e5fb594cce2a476354264d1ea"),
}

Functions

func BoostBidToBidTrace added in v0.20.0

func BoostBidToBidTrace(bidTrace *boostTypes.BidTrace) *apiv1.BidTrace

func ComputeDomain

func ComputeDomain(domainType types.DomainType, forkVersionHex, genesisValidatorsRootHex string) (domain types.Domain, err error)

ComputeDomain computes the signing domain

func GetEnv

func GetEnv(key, defaultValue string) string

func GetIPXForwardedFor

func GetIPXForwardedFor(r *http.Request) string

func GetMevBoostVersionFromUserAgent added in v0.8.1

func GetMevBoostVersionFromUserAgent(ua string) string

GetMevBoostVersionFromUserAgent returns the mev-boost version from an user agent string Example ua: "mev-boost/1.0.1 go-http-client" -> returns "1.0.1". If no version is found, returns "-"

func GetSliceEnv

func GetSliceEnv(key string, defaultValue []string) []string

func LogSetup

func LogSetup(json bool, logLevel string) *logrus.Entry

func U256StrToUint256 added in v0.20.0

func U256StrToUint256(s types.U256Str) *uint256.Int

Types

type BidTraceV2 added in v0.10.0

type BidTraceV2 struct {
	apiv1.BidTrace
	BlockNumber uint64 `json:"block_number,string" db:"block_number"`
	NumTx       uint64 `json:"num_tx,string" db:"num_tx"`
}

func (BidTraceV2) MarshalJSON added in v0.20.0

func (b BidTraceV2) MarshalJSON() ([]byte, error)

func (*BidTraceV2) UnmarshalJSON added in v0.20.0

func (b *BidTraceV2) UnmarshalJSON(data []byte) error

type BidTraceV2JSON added in v0.10.0

type BidTraceV2JSON struct {
	Slot                 uint64 `json:"slot,string"`
	ParentHash           string `json:"parent_hash"`
	BlockHash            string `json:"block_hash"`
	BuilderPubkey        string `json:"builder_pubkey"`
	ProposerPubkey       string `json:"proposer_pubkey"`
	ProposerFeeRecipient string `json:"proposer_fee_recipient"`
	GasLimit             uint64 `json:"gas_limit,string"`
	GasUsed              uint64 `json:"gas_used,string"`
	Value                string `json:"value"`
	NumTx                uint64 `json:"num_tx,string"`
	BlockNumber          uint64 `json:"block_number,string"`
}

func (*BidTraceV2JSON) CSVHeader added in v0.10.0

func (b *BidTraceV2JSON) CSVHeader() []string

func (*BidTraceV2JSON) ToCSVRecord added in v0.10.0

func (b *BidTraceV2JSON) ToCSVRecord() []string

type BidTraceV2WithTimestampJSON added in v0.10.0

type BidTraceV2WithTimestampJSON struct {
	BidTraceV2JSON
	Timestamp   int64 `json:"timestamp,string,omitempty"`
	TimestampMs int64 `json:"timestamp_ms,string,omitempty"`
}

func (*BidTraceV2WithTimestampJSON) CSVHeader added in v0.14.0

func (b *BidTraceV2WithTimestampJSON) CSVHeader() []string

func (*BidTraceV2WithTimestampJSON) ToCSVRecord added in v0.14.0

func (b *BidTraceV2WithTimestampJSON) ToCSVRecord() []string

type BuilderEntry

type BuilderEntry struct {
	Address string
	Pubkey  hexutil.Bytes
	URL     *url.URL
}

BuilderEntry represents a builder that is allowed to send blocks Address will be schema://hostname:port

func NewBuilderEntry

func NewBuilderEntry(builderURL string) (entry *BuilderEntry, err error)

NewBuilderEntry creates a new instance based on an input string builderURL can be IP@PORT, PUBKEY@IP:PORT, https://IP, etc.

type BuilderSubmitBlockRequest added in v0.20.0

type BuilderSubmitBlockRequest struct {
	Bellatrix *boostTypes.BuilderSubmitBlockRequest
	Capella   *capella.SubmitBlockRequest
}

func (*BuilderSubmitBlockRequest) BlockHash added in v0.20.0

func (b *BuilderSubmitBlockRequest) BlockHash() string

func (*BuilderSubmitBlockRequest) BlockNumber added in v0.20.0

func (b *BuilderSubmitBlockRequest) BlockNumber() uint64

func (*BuilderSubmitBlockRequest) BuilderPubkey added in v0.20.0

func (b *BuilderSubmitBlockRequest) BuilderPubkey() phase0.BLSPubKey

func (*BuilderSubmitBlockRequest) ExecutionPayloadBlockHash added in v0.20.0

func (b *BuilderSubmitBlockRequest) ExecutionPayloadBlockHash() string

func (*BuilderSubmitBlockRequest) ExecutionPayloadParentHash added in v0.20.0

func (b *BuilderSubmitBlockRequest) ExecutionPayloadParentHash() string

func (*BuilderSubmitBlockRequest) ExecutionPayloadResponse added in v0.20.0

func (b *BuilderSubmitBlockRequest) ExecutionPayloadResponse() (*GetPayloadResponse, error)

func (*BuilderSubmitBlockRequest) GasLimit added in v0.20.0

func (b *BuilderSubmitBlockRequest) GasLimit() uint64

func (*BuilderSubmitBlockRequest) GasUsed added in v0.20.0

func (b *BuilderSubmitBlockRequest) GasUsed() uint64

func (*BuilderSubmitBlockRequest) HasExecutionPayload added in v0.20.0

func (b *BuilderSubmitBlockRequest) HasExecutionPayload() bool

func (*BuilderSubmitBlockRequest) MarshalJSON added in v0.20.0

func (b *BuilderSubmitBlockRequest) MarshalJSON() ([]byte, error)

func (*BuilderSubmitBlockRequest) Message added in v0.20.0

func (*BuilderSubmitBlockRequest) NumTx added in v0.20.0

func (b *BuilderSubmitBlockRequest) NumTx() int

func (*BuilderSubmitBlockRequest) ParentHash added in v0.20.0

func (b *BuilderSubmitBlockRequest) ParentHash() string

func (*BuilderSubmitBlockRequest) ProposerFeeRecipient added in v0.20.0

func (b *BuilderSubmitBlockRequest) ProposerFeeRecipient() string

func (*BuilderSubmitBlockRequest) ProposerPubkey added in v0.20.0

func (b *BuilderSubmitBlockRequest) ProposerPubkey() string

func (*BuilderSubmitBlockRequest) Random added in v0.20.0

func (b *BuilderSubmitBlockRequest) Random() string

func (*BuilderSubmitBlockRequest) Signature added in v0.20.0

func (*BuilderSubmitBlockRequest) Slot added in v0.20.0

func (*BuilderSubmitBlockRequest) Timestamp added in v0.20.0

func (b *BuilderSubmitBlockRequest) Timestamp() uint64

func (*BuilderSubmitBlockRequest) UnmarshalJSON added in v0.20.0

func (b *BuilderSubmitBlockRequest) UnmarshalJSON(data []byte) error

func (*BuilderSubmitBlockRequest) Value added in v0.20.0

func (b *BuilderSubmitBlockRequest) Value() *big.Int

func (*BuilderSubmitBlockRequest) Withdrawals added in v0.20.0

type EthNetworkDetails

type EthNetworkDetails struct {
	Name                     string
	GenesisForkVersionHex    string
	GenesisValidatorsRootHex string
	BellatrixForkVersionHex  string
	CapellaForkVersionHex    string

	DomainBuilder                 boostTypes.Domain
	DomainBeaconProposerBellatrix boostTypes.Domain
	DomainBeaconProposerCapella   boostTypes.Domain
}

func NewEthNetworkDetails

func NewEthNetworkDetails(networkName string) (ret *EthNetworkDetails, err error)

type ExecutionPayload

type ExecutionPayload struct {
	Bellatrix *boostTypes.ExecutionPayload
	Capella   *consensuscapella.ExecutionPayload
}

func (*ExecutionPayload) BlockHash

func (e *ExecutionPayload) BlockHash() string

func (*ExecutionPayload) BlockNumber

func (e *ExecutionPayload) BlockNumber() uint64

func (*ExecutionPayload) MarshalJSON

func (e *ExecutionPayload) MarshalJSON() ([]byte, error)

func (*ExecutionPayload) NumTx

func (e *ExecutionPayload) NumTx() int

func (*ExecutionPayload) ParentHash

func (e *ExecutionPayload) ParentHash() string

func (*ExecutionPayload) Timestamp

func (e *ExecutionPayload) Timestamp() uint64

func (*ExecutionPayload) UnmarshalJSON

func (e *ExecutionPayload) UnmarshalJSON(data []byte) error

type ExecutionPayloadHeader

type ExecutionPayloadHeader struct {
	Bellatrix *boostTypes.ExecutionPayloadHeader
	Capella   *consensuscapella.ExecutionPayloadHeader
}

type GetHeaderResponse added in v0.20.0

type GetHeaderResponse struct {
	Bellatrix *boostTypes.GetHeaderResponse
	Capella   *spec.VersionedSignedBuilderBid
}

func (*GetHeaderResponse) BlockHash added in v0.20.0

func (p *GetHeaderResponse) BlockHash() phase0.Hash32

func (*GetHeaderResponse) Empty added in v0.20.0

func (p *GetHeaderResponse) Empty() bool

func (*GetHeaderResponse) MarshalJSON added in v0.20.0

func (p *GetHeaderResponse) MarshalJSON() ([]byte, error)

func (*GetHeaderResponse) UnmarshalJSON added in v0.20.0

func (p *GetHeaderResponse) UnmarshalJSON(data []byte) error

func (*GetHeaderResponse) Value added in v0.20.0

func (p *GetHeaderResponse) Value() *big.Int

type GetPayloadResponse added in v0.20.0

type GetPayloadResponse struct {
	Bellatrix *boostTypes.GetPayloadResponse
	Capella   *api.VersionedExecutionPayload
}

func (*GetPayloadResponse) MarshalJSON added in v0.20.0

func (p *GetPayloadResponse) MarshalJSON() ([]byte, error)

func (*GetPayloadResponse) UnmarshalJSON added in v0.20.0

func (p *GetPayloadResponse) UnmarshalJSON(data []byte) error

type HTTPServerTimeouts

type HTTPServerTimeouts struct {
	Read       time.Duration // Timeout for body reads. None if 0.
	ReadHeader time.Duration // Timeout for header reads. None if 0.
	Write      time.Duration // Timeout for writes. None if 0.
	Idle       time.Duration // Timeout to disconnect idle client connections. None if 0.
}

HTTPServerTimeouts are various timeouts for requests to the mev-boost HTTP server

type SignedBeaconBlock added in v0.20.0

type SignedBeaconBlock struct {
	Bellatrix *boostTypes.SignedBeaconBlock
	Capella   *consensuscapella.SignedBeaconBlock
}

func (*SignedBeaconBlock) BlockHash added in v0.20.0

func (s *SignedBeaconBlock) BlockHash() string

func (*SignedBeaconBlock) MarshalJSON added in v0.20.0

func (s *SignedBeaconBlock) MarshalJSON() ([]byte, error)

func (*SignedBeaconBlock) Slot added in v0.20.0

func (s *SignedBeaconBlock) Slot() uint64

type SignedBlindedBeaconBlock added in v0.20.0

type SignedBlindedBeaconBlock struct {
	Bellatrix *boostTypes.SignedBlindedBeaconBlock
	Capella   *apiv1capella.SignedBlindedBeaconBlock
}

func (*SignedBlindedBeaconBlock) BlockHash added in v0.20.0

func (s *SignedBlindedBeaconBlock) BlockHash() string

func (*SignedBlindedBeaconBlock) BlockNumber added in v0.20.0

func (s *SignedBlindedBeaconBlock) BlockNumber() uint64

func (*SignedBlindedBeaconBlock) MarshalJSON added in v0.20.0

func (s *SignedBlindedBeaconBlock) MarshalJSON() ([]byte, error)

func (*SignedBlindedBeaconBlock) Message added in v0.20.0

func (*SignedBlindedBeaconBlock) ProposerIndex added in v0.20.0

func (s *SignedBlindedBeaconBlock) ProposerIndex() uint64

func (*SignedBlindedBeaconBlock) Signature added in v0.20.0

func (s *SignedBlindedBeaconBlock) Signature() []byte

func (*SignedBlindedBeaconBlock) Slot added in v0.20.0

func (s *SignedBlindedBeaconBlock) Slot() uint64

type VersionedExecutionPayload added in v0.20.0

type VersionedExecutionPayload struct {
	Bellatrix *boostTypes.GetPayloadResponse
	Capella   *api.VersionedExecutionPayload
}

func (*VersionedExecutionPayload) MarshalJSON added in v0.20.0

func (e *VersionedExecutionPayload) MarshalJSON() ([]byte, error)

func (*VersionedExecutionPayload) NumTx added in v0.20.0

func (e *VersionedExecutionPayload) NumTx() int

func (*VersionedExecutionPayload) UnmarshalJSON added in v0.20.0

func (e *VersionedExecutionPayload) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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