Documentation ¶
Overview ¶
Package common provides things used by various other components
Index ¶
- Variables
- func BuildGetHeaderResponse(payload *VersionedSubmitBlockRequest, sk *bls.SecretKey, ...) (*builderSpec.VersionedSignedBuilderBid, error)
- func BuildGetPayloadResponse(payload *VersionedSubmitBlockRequest) (*builderApi.VersionedSubmitBlindedBlockResponse, error)
- func BuilderBlockRequestToSignedBuilderBid(payload *VersionedSubmitBlockRequest, ...) (*builderSpec.VersionedSignedBuilderBid, error)
- func CapellaUnblindSignedBlock(blindedBlock *eth2ApiV1Capella.SignedBlindedBeaconBlock, ...) *capella.SignedBeaconBlock
- func ComputeDomain(domainType phase0.DomainType, forkVersionHex, genesisValidatorsRootHex string) (domain phase0.Domain, err error)
- func DenebUnblindSignedBlock(blindedBlock *eth2ApiV1Deneb.SignedBlindedBeaconBlock, ...) *eth2ApiV1Deneb.SignedBlockContents
- func GetBlockSubmissionExecutionPayload(submission *VersionedSubmitBlockRequest) (*builderApi.VersionedSubmitBlindedBlockResponse, error)
- func GetEnv(key, defaultValue string) string
- func GetEnvDurationSec(key string, defaultValueSec int) time.Duration
- func GetEnvStrSlice(key string, defaultValue []string) []string
- func GetIPXForwardedFor(r *http.Request) string
- func GetMevBoostVersionFromUserAgent(ua string) string
- func GetSliceEnv(key string, defaultValue []string) []string
- func LoadGzippedBytes(t *testing.T, filename string) []byte
- func LoadGzippedJSON(t *testing.T, filename string, dst any)
- func LogSetup(json bool, logLevel string) *logrus.Entry
- func MustB64Gunzip(s string) []byte
- func SlotPos(slot uint64) uint64
- func SlotToEpoch(slot uint64) uint64
- func StrToPhase0Hash(s string) (ret phase0.Hash32, err error)
- func StrToPhase0Pubkey(s string) (ret phase0.BLSPubKey, err error)
- func U256StrToUint256(s types.U256Str) *uint256.Int
- type BidTraceV2
- type BidTraceV2JSON
- type BidTraceV2WithBlobFields
- type BidTraceV2WithBlobFieldsJSON
- type BidTraceV2WithTimestampJSON
- type BlockSubmissionInfo
- type BuilderBlockValidationRequest
- type BuilderGetValidatorsResponseEntry
- type BuilderStatus
- type CreateTestBlockSubmissionOpts
- type EthNetworkDetails
- type HTTPErrorResp
- type HTTPServerTimeouts
- type Profile
- type PubkeyHex
- type SubmitBlockRequestV2Optimistic
- func (s *SubmitBlockRequestV2Optimistic) MarshalSSZ() ([]byte, error)
- func (s *SubmitBlockRequestV2Optimistic) MarshalSSZTo(buf []byte) (dst []byte, err error)
- func (s *SubmitBlockRequestV2Optimistic) SizeSSZ() (size int)
- func (s *SubmitBlockRequestV2Optimistic) UnmarshalSSZ(buf []byte) error
- func (s *SubmitBlockRequestV2Optimistic) UnmarshalSSZHeaderOnly(buf []byte) error
- type VersionedSignedBlindedBeaconBlock
- type VersionedSignedProposal
- type VersionedSubmitBlockRequest
- func (r *VersionedSubmitBlockRequest) HashTreeRoot() (phase0.Root, error)
- func (r *VersionedSubmitBlockRequest) MarshalJSON() ([]byte, error)
- func (r *VersionedSubmitBlockRequest) MarshalSSZ() ([]byte, error)
- func (r *VersionedSubmitBlockRequest) UnmarshalJSON(input []byte) error
- func (r *VersionedSubmitBlockRequest) UnmarshalSSZ(input []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrServerAlreadyRunning = errors.New("server already running") SecondsPerSlot = uint64(cli.GetEnvInt("SEC_PER_SLOT", 12)) DurationPerSlot = time.Duration(SecondsPerSlot) * time.Second SlotsPerEpoch = uint64(cli.GetEnvInt("SLOTS_PER_EPOCH", 32)) DurationPerEpoch = DurationPerSlot * time.Duration(SlotsPerEpoch) )
var ( ErrInvalidSlot = errors.New("invalid slot") ErrInvalidHash = errors.New("invalid hash") ErrInvalidPubkey = errors.New("invalid pubkey") ErrInvalidSignature = errors.New("invalid signature") )
var ( ErrUnknownNetwork = errors.New("unknown network") ErrEmptyPayload = errors.New("empty payload") EthNetworkHolesky = "holesky" EthNetworkSepolia = "sepolia" EthNetworkGoerli = "goerli" EthNetworkMainnet = "mainnet" EthNetworkCustom = "custom" GenesisForkVersionHolesky = "0x01017000" GenesisForkVersionSepolia = "0x90000069" GenesisForkVersionGoerli = "0x00001020" GenesisForkVersionMainnet = "0x00000000" GenesisValidatorsRootHolesky = "0x9143aa7c615a7f7115e2b6aac319c03529df8242ae705fba9df39b79c59fa8b1" GenesisValidatorsRootSepolia = "0xd8ea171f3c94aea21ebc42a1ed61052acf3f9209c00e4efbaaddac09ed9b8078" GenesisValidatorsRootGoerli = "0x043db0d9a83813551ee2f33450d23797757d430911a9320530ad8a0eabc43efb" GenesisValidatorsRootMainnet = "0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95" BellatrixForkVersionHolesky = "0x03017000" BellatrixForkVersionSepolia = "0x90000071" BellatrixForkVersionGoerli = "0x02001020" BellatrixForkVersionMainnet = "0x02000000" CapellaForkVersionHolesky = "0x04017000" CapellaForkVersionSepolia = "0x90000072" CapellaForkVersionGoerli = "0x03001020" CapellaForkVersionMainnet = "0x03000000" DenebForkVersionHolesky = "0x05017000" DenebForkVersionSepolia = "0x90000073" DenebForkVersionGoerli = "0x04001020" DenebForkVersionMainnet = "0x04000000" ForkVersionStringBellatrix = "bellatrix" ForkVersionStringCapella = "capella" ForkVersionStringDeneb = "deneb" )
var ( ErrMissingRequest = errors.New("req is nil") ErrMissingSecretKey = errors.New("secret key is nil") ErrInvalidVersion = errors.New("invalid version") )
var ( ErrInvalidForkVersion = errors.New("invalid fork version") ErrHTTPErrorResponse = errors.New("got an HTTP error response") ErrIncorrectLength = errors.New("incorrect length") )
var NilResponse = struct{}{}
var TestLog = logrus.WithField("testing", true)
TestLog is used to log information in the test methods
var ValidPayloadRegisterValidator = builderApiV1.SignedValidatorRegistration{ Message: &builderApiV1.ValidatorRegistration{ FeeRecipient: _HexToAddress("0xdb65fEd33dc262Fe09D9a2Ba8F80b329BA25f941"), Timestamp: time.Unix(1606824043, 0), GasLimit: 30000000, Pubkey: _HexToPubkey( "0x84e975405f8691ad7118527ee9ee4ed2e4e8bae973f6e29aa9ca9ee4aea83605ae3536d22acc9aa1af0545064eacf82e"), }, Signature: _HexToSignature( "0xaf12df007a0c78abb5575067e5f8b089cfcc6227e4a91db7dd8cf517fe86fb944ead859f0781277d9b78c672e4a18c5d06368b603374673cf2007966cece9540f3a1b3f6f9e1bf421d779c4e8010368e6aac134649c7a009210780d401a778a5"), }
Functions ¶
func BuildGetHeaderResponse ¶ added in v0.20.0
func BuildGetHeaderResponse(payload *VersionedSubmitBlockRequest, sk *bls.SecretKey, pubkey *phase0.BLSPubKey, domain phase0.Domain) (*builderSpec.VersionedSignedBuilderBid, error)
func BuildGetPayloadResponse ¶ added in v0.20.0
func BuildGetPayloadResponse(payload *VersionedSubmitBlockRequest) (*builderApi.VersionedSubmitBlindedBlockResponse, error)
func BuilderBlockRequestToSignedBuilderBid ¶ added in v0.29.0
func BuilderBlockRequestToSignedBuilderBid(payload *VersionedSubmitBlockRequest, header *builderApi.VersionedExecutionPayloadHeader, sk *bls.SecretKey, pubkey *phase0.BLSPubKey, domain phase0.Domain) (*builderSpec.VersionedSignedBuilderBid, error)
func CapellaUnblindSignedBlock ¶ added in v0.29.0
func CapellaUnblindSignedBlock(blindedBlock *eth2ApiV1Capella.SignedBlindedBeaconBlock, executionPayload *capella.ExecutionPayload) *capella.SignedBeaconBlock
func ComputeDomain ¶
func ComputeDomain(domainType phase0.DomainType, forkVersionHex, genesisValidatorsRootHex string) (domain phase0.Domain, err error)
ComputeDomain computes the signing domain
func DenebUnblindSignedBlock ¶ added in v0.29.0
func DenebUnblindSignedBlock(blindedBlock *eth2ApiV1Deneb.SignedBlindedBeaconBlock, blockPayload *builderApiDeneb.ExecutionPayloadAndBlobsBundle) *eth2ApiV1Deneb.SignedBlockContents
func GetBlockSubmissionExecutionPayload ¶ added in v0.29.0
func GetBlockSubmissionExecutionPayload(submission *VersionedSubmitBlockRequest) (*builderApi.VersionedSubmitBlindedBlockResponse, error)
func GetEnvDurationSec ¶ added in v0.27.1
GetEnvDurationSec returns the value of the environment variable as duration in seconds, or defaultValue if the environment variable doesn't exist or is not a valid integer
func GetEnvStrSlice ¶ added in v0.20.0
GetEnvStrSlice returns a slice of strings from a comma-separated env var
func GetIPXForwardedFor ¶
func GetMevBoostVersionFromUserAgent ¶ added in v0.8.1
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 LoadGzippedBytes ¶ added in v0.26.0
func LoadGzippedJSON ¶ added in v0.26.0
func MustB64Gunzip ¶ added in v0.27.1
func SlotPos ¶ added in v0.20.0
SlotPos returns the slot's position in the epoch (1-based, i.e. 1..32)
func SlotToEpoch ¶ added in v0.27.1
func StrToPhase0Hash ¶ added in v0.20.0
func StrToPhase0Pubkey ¶ added in v0.20.0
Types ¶
type BidTraceV2 ¶ added in v0.10.0
type BidTraceV2 struct { builderApiV1.BidTrace BlockNumber uint64 `db:"block_number" json:"block_number,string"` NumTx uint64 `db:"num_tx" json:"num_tx,string"` }
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 BidTraceV2WithBlobFields ¶ added in v0.29.1
type BidTraceV2WithBlobFields struct { builderApiV1.BidTrace BlockNumber uint64 `db:"block_number" json:"block_number,string"` NumTx uint64 `db:"num_tx" json:"num_tx,string"` NumBlobs uint64 `db:"num_blobs" json:"num_blobs,string"` BlobGasUsed uint64 `db:"blob_gas_used" json:"blob_gas_used,string"` ExcessBlobGas uint64 `db:"excess_blob_gas" json:"excess_blob_gas,string"` }
func (BidTraceV2WithBlobFields) MarshalJSON ¶ added in v0.29.1
func (b BidTraceV2WithBlobFields) MarshalJSON() ([]byte, error)
func (*BidTraceV2WithBlobFields) UnmarshalJSON ¶ added in v0.29.1
func (b *BidTraceV2WithBlobFields) UnmarshalJSON(data []byte) error
type BidTraceV2WithBlobFieldsJSON ¶ added in v0.29.1
type BidTraceV2WithBlobFieldsJSON 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"` NumBlobs uint64 `json:"num_blobs,string"` BlobGasUsed uint64 `json:"blob_gas_used,string"` ExcessBlobGas uint64 `json:"excess_blob_gas,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"` OptimisticSubmission bool `json:"optimistic_submission"` }
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 BlockSubmissionInfo ¶ added in v0.29.0
type BlockSubmissionInfo struct { BidTrace *builderApiV1.BidTrace ExecutionPayloadBlockHash phase0.Hash32 ExecutionPayloadParentHash phase0.Hash32 GasUsed uint64 GasLimit uint64 Timestamp uint64 BlockNumber uint64 PrevRandao phase0.Hash32 Signature phase0.BLSSignature Transactions []bellatrix.Transaction Withdrawals []*capella.Withdrawal Blobs []deneb.Blob BlobGasUsed uint64 ExcessBlobGas uint64 }
func GetBlockSubmissionInfo ¶ added in v0.29.0
func GetBlockSubmissionInfo(submission *VersionedSubmitBlockRequest) (*BlockSubmissionInfo, error)
type BuilderBlockValidationRequest ¶ added in v0.20.0
type BuilderBlockValidationRequest struct { *VersionedSubmitBlockRequest RegisteredGasLimit uint64 ParentBeaconBlockRoot *phase0.Root }
func (*BuilderBlockValidationRequest) MarshalJSON ¶ added in v0.20.0
func (r *BuilderBlockValidationRequest) MarshalJSON() ([]byte, error)
type BuilderGetValidatorsResponseEntry ¶ added in v0.20.0
type BuilderGetValidatorsResponseEntry struct { Slot uint64 `json:"slot,string"` ValidatorIndex uint64 `json:"validator_index,string"` Entry *builderApiV1.SignedValidatorRegistration `json:"entry"` }
type BuilderStatus ¶ added in v0.24.0
BuilderStatus configures how builder blocks are processed.
type CreateTestBlockSubmissionOpts ¶ added in v0.20.0
type CreateTestBlockSubmissionOpts struct { Version spec.DataVersion Slot uint64 ParentHash string ProposerPubkey string // contains filtered or unexported fields }
type EthNetworkDetails ¶
type EthNetworkDetails struct { Name string GenesisForkVersionHex string GenesisValidatorsRootHex string BellatrixForkVersionHex string CapellaForkVersionHex string DenebForkVersionHex string DomainBuilder phase0.Domain DomainBeaconProposerBellatrix phase0.Domain DomainBeaconProposerCapella phase0.Domain DomainBeaconProposerDeneb phase0.Domain }
func NewEthNetworkDetails ¶
func NewEthNetworkDetails(networkName string) (ret *EthNetworkDetails, err error)
func (*EthNetworkDetails) String ¶ added in v0.20.0
func (e *EthNetworkDetails) String() string
type HTTPErrorResp ¶ added in v0.20.0
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 Profile ¶ added in v0.24.0
type Profile struct { Decode uint64 Prechecks uint64 Simulation uint64 RedisUpdate uint64 Total uint64 }
Profile captures performance metrics for the block submission handler. Each field corresponds to the number of microseconds in each stage. The `Total` field is the number of microseconds taken for entire flow.
type SubmitBlockRequestV2Optimistic ¶ added in v0.27.1
type SubmitBlockRequestV2Optimistic struct { Message *builderApiV1.BidTrace ExecutionPayloadHeader *capella.ExecutionPayloadHeader Signature phase0.BLSSignature `ssz-size:"96"` Transactions []bellatrix.Transaction `ssz-max:"1048576,1073741824" ssz-size:"?,?"` Withdrawals []*capella.Withdrawal `ssz-max:"16"` }
SubmitBlockRequestV2Optimistic is the v2 request from the builder to submit a block. The message must be SSZ encoded. The first three fields are at most 944 bytes, which fit into a single 1500 MTU ethernet packet. The `UnmarshalSSZHeaderOnly` function just parses the first three fields, which is sufficient data to set the bid of the builder. The `Transactions` and `Withdrawals` fields are required to construct the full SignedBeaconBlock and are parsed asynchronously.
Header only layout: [000-236) = Message (236 bytes) [236-240) = offset1 ( 4 bytes) [240-336) = Signature ( 96 bytes) [336-340) = offset2 ( 4 bytes) [340-344) = offset3 ( 4 bytes) [344-944) = EPH (600 bytes)
func (*SubmitBlockRequestV2Optimistic) MarshalSSZ ¶ added in v0.27.1
func (s *SubmitBlockRequestV2Optimistic) MarshalSSZ() ([]byte, error)
MarshalSSZ ssz marshals the SubmitBlockRequestV2Optimistic object
func (*SubmitBlockRequestV2Optimistic) MarshalSSZTo ¶ added in v0.27.1
func (s *SubmitBlockRequestV2Optimistic) MarshalSSZTo(buf []byte) (dst []byte, err error)
MarshalSSZTo ssz marshals the SubmitBlockRequestV2Optimistic object to a target array
func (*SubmitBlockRequestV2Optimistic) SizeSSZ ¶ added in v0.27.1
func (s *SubmitBlockRequestV2Optimistic) SizeSSZ() (size int)
SizeSSZ returns the ssz encoded size in bytes for the SubmitBlockRequestV2Optimistic object
func (*SubmitBlockRequestV2Optimistic) UnmarshalSSZ ¶ added in v0.27.1
func (s *SubmitBlockRequestV2Optimistic) UnmarshalSSZ(buf []byte) error
UnmarshalSSZ ssz unmarshals the SubmitBlockRequestV2Optimistic object
func (*SubmitBlockRequestV2Optimistic) UnmarshalSSZHeaderOnly ¶ added in v0.27.1
func (s *SubmitBlockRequestV2Optimistic) UnmarshalSSZHeaderOnly(buf []byte) error
UnmarshalSSZHeaderOnly ssz unmarshals the first 3 fields of the SubmitBlockRequestV2Optimistic object
type VersionedSignedBlindedBeaconBlock ¶ added in v0.29.0
type VersionedSignedBlindedBeaconBlock struct {
eth2Api.VersionedSignedBlindedBeaconBlock
}
func (*VersionedSignedBlindedBeaconBlock) MarshalJSON ¶ added in v0.29.0
func (r *VersionedSignedBlindedBeaconBlock) MarshalJSON() ([]byte, error)
func (*VersionedSignedBlindedBeaconBlock) UnmarshalJSON ¶ added in v0.29.0
func (r *VersionedSignedBlindedBeaconBlock) UnmarshalJSON(input []byte) error
type VersionedSignedProposal ¶ added in v0.29.0
type VersionedSignedProposal struct {
eth2Api.VersionedSignedProposal
}
func SignedBlindedBeaconBlockToBeaconBlock ¶ added in v0.20.0
func SignedBlindedBeaconBlockToBeaconBlock(signedBlindedBeaconBlock *VersionedSignedBlindedBeaconBlock, blockPayload *builderApi.VersionedSubmitBlindedBlockResponse) (*VersionedSignedProposal, error)
func (*VersionedSignedProposal) MarshalJSON ¶ added in v0.29.0
func (r *VersionedSignedProposal) MarshalJSON() ([]byte, error)
func (*VersionedSignedProposal) MarshalSSZ ¶ added in v0.29.0
func (r *VersionedSignedProposal) MarshalSSZ() ([]byte, error)
func (*VersionedSignedProposal) UnmarshalJSON ¶ added in v0.29.0
func (r *VersionedSignedProposal) UnmarshalJSON(input []byte) error
func (*VersionedSignedProposal) UnmarshalSSZ ¶ added in v0.29.0
func (r *VersionedSignedProposal) UnmarshalSSZ(input []byte) error
type VersionedSubmitBlockRequest ¶ added in v0.29.0
type VersionedSubmitBlockRequest struct {
builderSpec.VersionedSubmitBlockRequest
}
func CreateTestBlockSubmission ¶ added in v0.20.0
func CreateTestBlockSubmission(t *testing.T, builderPubkey string, value *uint256.Int, opts *CreateTestBlockSubmissionOpts) (payload *VersionedSubmitBlockRequest, getPayloadResponse *builderApi.VersionedSubmitBlindedBlockResponse, getHeaderResponse *builderSpec.VersionedSignedBuilderBid)
func TestBuilderSubmitBlockRequest ¶ added in v0.24.0
func TestBuilderSubmitBlockRequest(sk *bls.SecretKey, bid *BidTraceV2WithBlobFields, version spec.DataVersion) *VersionedSubmitBlockRequest
func (*VersionedSubmitBlockRequest) HashTreeRoot ¶ added in v0.29.0
func (r *VersionedSubmitBlockRequest) HashTreeRoot() (phase0.Root, error)
func (*VersionedSubmitBlockRequest) MarshalJSON ¶ added in v0.29.0
func (r *VersionedSubmitBlockRequest) MarshalJSON() ([]byte, error)
func (*VersionedSubmitBlockRequest) MarshalSSZ ¶ added in v0.29.0
func (r *VersionedSubmitBlockRequest) MarshalSSZ() ([]byte, error)
func (*VersionedSubmitBlockRequest) UnmarshalJSON ¶ added in v0.29.0
func (r *VersionedSubmitBlockRequest) UnmarshalJSON(input []byte) error
func (*VersionedSubmitBlockRequest) UnmarshalSSZ ¶ added in v0.29.0
func (r *VersionedSubmitBlockRequest) UnmarshalSSZ(input []byte) error