relay

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderKeySlotUID = "X-MEVPLUS-SlotID"
	HeaderKeyVersion = "X-MEVPLUS-Version"
)
View Source
const (
	PublicKeyLength = bls12381.SizeOfG1AffineCompressed
	SecretKeyLength = fr.Bytes
	SignatureLength = bls12381.SizeOfG2AffineCompressed
)

Variables

View Source
var (
	ErrMissingRelayPubkey        = fmt.Errorf("missing relay public key")
	ErrHTTPErrorResponse         = errors.New("HTTP error response")
	ErrNoBidReceived             = errors.New("No bid received")
	ErrInvalidInput              = errors.New("Invalid input")
	ErrIncompletePayload         = errors.New("Missing parts of the request payload from the beacon-node")
	ErrNoPayloadReceived         = errors.New("No payload received from relay")
	ErrMaxRetriesExceeded        = errors.New("max retries exceeded")
	ErrInvalidTransaction        = errors.New("invalid transaction")
	ErrPointAtInfinityPubkey     = fmt.Errorf("relay public key cannot be the point-at-infinity")
	ErrLength                    = errors.New("invalid length")
	ErrNoRelays                  = errors.New("no relays")
	ErrInvalidSlot               = errors.New("invalid slot")
	ErrInvalidHash               = errors.New("invalid hash")
	ErrInvalidPubkey             = errors.New("invalid pubkey")
	ErrNoSuccessfulRelayResponse = errors.New("no successful relay response")
	ErrUseLastResponse           = errors.New("net/http: use last response")
)
View Source
var (
	ErrInvalidPubkeyLength    = errors.New("invalid public key length")
	ErrInvalidSecretKeyLength = errors.New("invalid secret key length")
	ErrInvalidSignatureLength = errors.New("invalid signature length")
	ErrSecretKeyIsZero        = errors.New("invalid secret key is zero")
)

Functions

func DecodeJSON

func DecodeJSON(r io.Reader, dst any) error

DecodeJSON reads JSON from io.Reader and decodes it into a struct

func GetURI

func GetURI(url *url.URL, path string) string

GetURI returns the full request URI with scheme, host, path and args.

func HexToPubkey

func HexToPubkey(s string) (ret phase0.BLSPubKey, err error)

HexToPubkey takes a hex string and returns a PublicKey

func ParseConfigFLags

func ParseConfigFLags(r *RelayService, moduleFlags commonType.ModuleFlags) error

func RelayEntriesToStrings

func RelayEntriesToStrings(relays []RelayEntry) []string

RelayEntriesToStrings returns the string representation of a list of relay entries

func SendHTTPRequest

func SendHTTPRequest(ctx context.Context, client http.Client, method, url string, payload, dst any) (code int, err error)

SendHTTPRequest - prepare and send HTTP request, marshaling the payload if any, and decoding the response if dst is set

func SendHTTPRequestWithRetries

func SendHTTPRequestWithRetries(ctx context.Context, client http.Client, method, url string, payload, dst any, maxRetries int, log *logrus.Entry) (code int, err error)

SendHTTPRequestWithRetries - prepare and send HTTP request, retrying the request if within the client timeout

func VerifySignature

func VerifySignature(sig *Signature, pk *PublicKey, msg []byte) (bool, error)

func VerifySignatureBytes

func VerifySignatureBytes(msg, sigBytes, pkBytes []byte) (bool, error)

Types

type PublicKey

type PublicKey = bls12381.G1Affine

func PublicKeyFromBytes

func PublicKeyFromBytes(pkBytes []byte) (*PublicKey, error)

type RelayEntry

type RelayEntry struct {
	PublicKey     phase0.BLSPubKey
	SigningDomain phase0.Domain
	URL           *url.URL
}

RelayEntry represents a relay that mev-plus connects to.

func NewRelayEntry

func NewRelayEntry(relayURL string) (entry RelayEntry, err error)

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

func (*RelayEntry) GetURI

func (r *RelayEntry) GetURI(path string) string

GetURI returns the full request URI with scheme, host, path and args for the relay.

func (*RelayEntry) String

func (r *RelayEntry) String() string

type RelayService

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

func NewRelayService

func NewRelayService() *RelayService

func (*RelayService) CliCommand added in v1.0.0

func (r *RelayService) CliCommand() *cli.Command

func (*RelayService) Configure

func (r *RelayService) Configure(moduleFlags commonType.ModuleFlags) error

func (*RelayService) ConnectCore

func (r *RelayService) ConnectCore(coreClient *coreCommon.Client, pingId string) error

func (*RelayService) GetHeader

func (r *RelayService) GetHeader(slot uint64, parentHash, pubkey string) (res []spec.VersionedSignedBuilderBid, err error)

func (*RelayService) GetPayload

func (r *RelayService) GetPayload(VersionedSignedBlindedBeaconBlock *commonTypes.VersionedSignedBlindedBeaconBlock) (versionedExecutionPayload []commonTypes.VersionedExecutionPayloadV2WithVersionName, err error)

func (*RelayService) Name

func (r *RelayService) Name() string

func (*RelayService) RegisterValidator

func (r *RelayService) RegisterValidator(payload []apiv1.SignedValidatorRegistration) error

func (*RelayService) Start

func (r *RelayService) Start() error

func (*RelayService) Status

func (r *RelayService) Status() error

func (*RelayService) Stop

func (r *RelayService) Stop() error

type SecretKey

type SecretKey = fr.Element

type Signature

type Signature = bls12381.G2Affine

func SignatureFromBytes

func SignatureFromBytes(sigBytes []byte) (*Signature, error)

Directories

Path Synopsis
Code generated by fastssz.
Code generated by fastssz.

Jump to

Keyboard shortcuts

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