proxy

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package proxy provides the main proxy server.

Index

Constants

View Source
const (
	FlashbotsPeerName = "flashbots"

	EthSendBundleMethod         = "eth_sendBundle"
	MevSendBundleMethod         = "mev_sendBundle"
	EthCancelBundleMethod       = "eth_cancelBundle"
	EthSendRawTransactionMethod = "eth_sendRawTransaction"
	BidSubsidiseBlockMethod     = "bid_subsidiseBlock"
)
View Source
const DefaultMaxRequestBodySizeBytes = int64(30 * 1024 * 1024) // 30 MB
View Source
const NewOrderEventsMethod = "flashbots_newOrderEvents"

Variables

View Source
var (
	// ArchiveBatchSize is a maximum size of the batch to send to the archive
	ArchiveBatchSize = 100
	// ArchiveBatchSizeFlushTimeout is a timeout to force flush the batch to the archive
	ArchiveBatchSizeFlushTimeout = time.Second * 6

	ArchiveRequestTimeout = time.Second * 15
	ArchiveRetryMaxTime   = time.Second * 120

	ArchiveWorkerQueueSize = 10000
)
View Source
var (
	HTTPDefaultReadTimeout  = 60 * time.Second
	HTTPDefaultWriteTimeout = 30 * time.Second
)
View Source
var DefaultOrderflowProxyPublicPort = "5544"
View Source
var (
	ReceiverProxyWorkerQueueSize = 10000
)
View Source
var (
	ShareWorkerQueueSize = 10000
)

Functions

func GenerateCert

func GenerateCert(validFor time.Duration, hosts []string) (cert, key []byte, err error)

GenerateCert generated a TLS certificate and key. - `hosts`: a list of ip / dns names to include in the certificate

func HTTPClientWithMaxConnections added in v0.2.2

func HTTPClientWithMaxConnections(maxOpenConnections int) *http.Client

func OrderflowProxyURLFromIP

func OrderflowProxyURLFromIP(ip string) string

func RPCClientWithCertAndSigner

func RPCClientWithCertAndSigner(endpoint string, certPEM []byte, signer *signature.Signer, maxOpenConnections int) (rpcclient.RPCClient, error)

func ValidateEthCancelBundle

func ValidateEthCancelBundle(args *rpctypes.EthCancelBundleArgs, publicEndpoint bool) error

func ValidateEthSendBundle

func ValidateEthSendBundle(args *rpctypes.EthSendBundleArgs, publicEndpoint bool) error

func ValidateMevSendBundle

func ValidateMevSendBundle(args *rpctypes.MevSendBundleArgs, publicEndpoint bool) error

Types

type ArchiveEvent

type ArchiveEvent struct {
	EthSendBundle   *ArchiveEventEthSendBundle   `json:"eth_sendBundle,omitempty"`
	MevSendBundle   *ArchiveEventMevSendBundle   `json:"mev_sendBundle,omitempty"`
	EthCancelBundle *ArchiveEventEthCancelBundle `json:"eth_cancelBundle,omitempty"`
}

type ArchiveEventEthCancelBundle

type ArchiveEventEthCancelBundle struct {
	Params   *rpctypes.EthCancelBundleArgs `json:"params"`
	Metadata *ArchiveEventMetadata         `json:"metadata"`
}

type ArchiveEventEthSendBundle

type ArchiveEventEthSendBundle struct {
	Params   *rpctypes.EthSendBundleArgs `json:"params"`
	Metadata *ArchiveEventMetadata       `json:"metadata"`
}

type ArchiveEventMetadata

type ArchiveEventMetadata struct {
	// ReceivedAt is a unix millisecond timestamp
	ReceivedAt int64 `json:"receivedAt"`
}

type ArchiveEventMevSendBundle

type ArchiveEventMevSendBundle struct {
	Params   *rpctypes.MevSendBundleArgs `json:"params"`
	Metadata *ArchiveEventMetadata       `json:"metadata"`
}

type ArchiveQueue

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

func (*ArchiveQueue) Run

func (aq *ArchiveQueue) Run()

type BlockNumberSource

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

func NewBlockNumberSource

func NewBlockNumberSource(endpoint string) *BlockNumberSource

func (*BlockNumberSource) BlockNumber

func (bs *BlockNumberSource) BlockNumber() (uint64, error)

func (*BlockNumberSource) UpdateCachedBlockNumber

func (bs *BlockNumberSource) UpdateCachedBlockNumber() error

type BuilderConfigHub

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

func NewBuilderConfigHub

func NewBuilderConfigHub(log *slog.Logger, endpoint string) *BuilderConfigHub

func (*BuilderConfigHub) Builders

func (b *BuilderConfigHub) Builders(internal bool) (result []ConfighubBuilder, err error)

func (*BuilderConfigHub) RegisterCredentials

func (b *BuilderConfigHub) RegisterCredentials(ctx context.Context, info ConfighubOrderflowProxyCredentials) error

type ConfighubBuilder

type ConfighubBuilder struct {
	Name           string                             `json:"name"`
	IP             string                             `json:"ip"`
	OrderflowProxy ConfighubOrderflowProxyCredentials `json:"orderflow_proxy"`
}

type ConfighubOrderflowProxyCredentials

type ConfighubOrderflowProxyCredentials struct {
	TLSCert            string         `json:"tls_cert"`
	EcdsaPubkeyAddress common.Address `json:"ecdsa_pubkey_address"`
}

type FlashbotsNewOrderEventsArgs

type FlashbotsNewOrderEventsArgs struct {
	OrderEvents []ArchiveEvent `json:"orderEvents"`
}

type ParsedRequest

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

type ReceiverProxy

type ReceiverProxy struct {
	ReceiverProxyConstantConfig

	ConfigHub *BuilderConfigHub

	OrderflowSigner *signature.Signer
	PublicCertPEM   []byte
	Certificate     tls.Certificate

	PublicHandler http.Handler
	LocalHandler  http.Handler
	CertHandler   http.Handler // this endpoint just returns generated certificate
	// contains filtered or unexported fields
}

func NewReceiverProxy

func NewReceiverProxy(config ReceiverProxyConfig) (*ReceiverProxy, error)

func (*ReceiverProxy) BidSubsidiseBlock

func (prx *ReceiverProxy) BidSubsidiseBlock(ctx context.Context, bidSubsidiseBlock rpctypes.BidSubsisideBlockArgs, publicEndpoint bool) error

func (*ReceiverProxy) BidSubsidiseBlockLocal

func (prx *ReceiverProxy) BidSubsidiseBlockLocal(ctx context.Context, bidSubsidiseBlock rpctypes.BidSubsisideBlockArgs) error

func (*ReceiverProxy) BidSubsidiseBlockPublic

func (prx *ReceiverProxy) BidSubsidiseBlockPublic(ctx context.Context, bidSubsidiseBlock rpctypes.BidSubsisideBlockArgs) error

func (*ReceiverProxy) EthCancelBundle

func (prx *ReceiverProxy) EthCancelBundle(ctx context.Context, ethCancelBundle rpctypes.EthCancelBundleArgs, publicEndpoint bool) error

func (*ReceiverProxy) EthCancelBundleLocal

func (prx *ReceiverProxy) EthCancelBundleLocal(ctx context.Context, ethCancelBundle rpctypes.EthCancelBundleArgs) error

func (*ReceiverProxy) EthCancelBundlePublic

func (prx *ReceiverProxy) EthCancelBundlePublic(ctx context.Context, ethCancelBundle rpctypes.EthCancelBundleArgs) error

func (*ReceiverProxy) EthSendBundle

func (prx *ReceiverProxy) EthSendBundle(ctx context.Context, ethSendBundle rpctypes.EthSendBundleArgs, publicEndpoint bool) error

func (*ReceiverProxy) EthSendBundleLocal

func (prx *ReceiverProxy) EthSendBundleLocal(ctx context.Context, ethSendBundle rpctypes.EthSendBundleArgs) error

func (*ReceiverProxy) EthSendBundlePublic

func (prx *ReceiverProxy) EthSendBundlePublic(ctx context.Context, ethSendBundle rpctypes.EthSendBundleArgs) error

func (*ReceiverProxy) EthSendRawTransaction

func (prx *ReceiverProxy) EthSendRawTransaction(ctx context.Context, ethSendRawTransaction rpctypes.EthSendRawTransactionArgs, publicEndpoint bool) error

func (*ReceiverProxy) EthSendRawTransactionLocal

func (prx *ReceiverProxy) EthSendRawTransactionLocal(ctx context.Context, ethSendRawTransaction rpctypes.EthSendRawTransactionArgs) error

func (*ReceiverProxy) EthSendRawTransactionPublic

func (prx *ReceiverProxy) EthSendRawTransactionPublic(ctx context.Context, ethSendRawTransaction rpctypes.EthSendRawTransactionArgs) error

func (*ReceiverProxy) FlushArchiveQueue

func (prx *ReceiverProxy) FlushArchiveQueue()

FlushArchiveQueue forces the archive queue to flush

func (*ReceiverProxy) HandleParsedRequest

func (prx *ReceiverProxy) HandleParsedRequest(ctx context.Context, parsedRequest ParsedRequest) error

func (*ReceiverProxy) LocalJSONRPCHandler

func (prx *ReceiverProxy) LocalJSONRPCHandler(maxRequestBodySizeBytes int64) (*rpcserver.JSONRPCHandler, error)

func (*ReceiverProxy) MevSendBundle

func (prx *ReceiverProxy) MevSendBundle(ctx context.Context, mevSendBundle rpctypes.MevSendBundleArgs, publicEndpoint bool) error

func (*ReceiverProxy) MevSendBundleLocal

func (prx *ReceiverProxy) MevSendBundleLocal(ctx context.Context, mevSendBundle rpctypes.MevSendBundleArgs) error

func (*ReceiverProxy) MevSendBundlePublic

func (prx *ReceiverProxy) MevSendBundlePublic(ctx context.Context, mevSendBundle rpctypes.MevSendBundleArgs) error

func (*ReceiverProxy) PublicJSONRPCHandler

func (prx *ReceiverProxy) PublicJSONRPCHandler(maxRequestBodySizeBytes int64) (*rpcserver.JSONRPCHandler, error)

func (*ReceiverProxy) RegisterSecrets

func (prx *ReceiverProxy) RegisterSecrets(ctx context.Context) error

func (*ReceiverProxy) RequestNewPeers

func (prx *ReceiverProxy) RequestNewPeers() error

RequestNewPeers updates currently available peers from the builder config hub

func (*ReceiverProxy) Stop

func (prx *ReceiverProxy) Stop()

func (*ReceiverProxy) TLSConfig

func (prx *ReceiverProxy) TLSConfig() *tls.Config

func (*ReceiverProxy) ValidateSigner

func (prx *ReceiverProxy) ValidateSigner(ctx context.Context, req *ParsedRequest, publicEndpoint bool) error

type ReceiverProxyConfig

type ReceiverProxyConfig struct {
	ReceiverProxyConstantConfig
	CertValidDuration time.Duration
	CertHosts         []string

	BuilderConfigHubEndpoint string
	ArchiveEndpoint          string
	ArchiveConnections       int
	LocalBuilderEndpoint     string

	// EthRPC should support eth_blockNumber API
	EthRPC string

	MaxRequestBodySizeBytes int64

	ConnectionsPerPeer int
	MaxLocalRPS        int
}

type ReceiverProxyConstantConfig

type ReceiverProxyConstantConfig struct {
	Log *slog.Logger
	// Name is optional field and it used to distringuish multiple proxies when running in the same process in tests
	Name                   string
	FlashbotsSignerAddress common.Address
}

type ReceiverProxyServers

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

func StartReceiverServers

func StartReceiverServers(proxy *ReceiverProxy, publicListenAddress, localListenAddress, certListenAddress string) (*ReceiverProxyServers, error)

func (*ReceiverProxyServers) Stop

func (s *ReceiverProxyServers) Stop()

type SenderProxy

type SenderProxy struct {
	SenderProxyConstantConfig
	ConfigHub *BuilderConfigHub
	Handler   http.Handler

	PeerUpdateForce chan struct{}
	// contains filtered or unexported fields
}

func NewSenderProxy

func NewSenderProxy(config SenderProxyConfig) (*SenderProxy, error)

func (*SenderProxy) BidSubsidiseBlock

func (prx *SenderProxy) BidSubsidiseBlock(ctx context.Context, bidSubsidiseBlock rpctypes.BidSubsisideBlockArgs) error

func (*SenderProxy) EthCancelBundle

func (prx *SenderProxy) EthCancelBundle(ctx context.Context, ethCancelBundle rpctypes.EthCancelBundleArgs) error

func (*SenderProxy) EthSendBundle

func (prx *SenderProxy) EthSendBundle(ctx context.Context, ethSendBundle rpctypes.EthSendBundleArgs) error

func (*SenderProxy) EthSendRawTransaction

func (prx *SenderProxy) EthSendRawTransaction(ctx context.Context, ethSendRawTransaction rpctypes.EthSendRawTransactionArgs) error

func (*SenderProxy) HandleParsedRequest

func (prx *SenderProxy) HandleParsedRequest(ctx context.Context, parsedRequest ParsedRequest) error

func (*SenderProxy) MevSendBundle

func (prx *SenderProxy) MevSendBundle(ctx context.Context, mevSendBundle rpctypes.MevSendBundleArgs) error

func (*SenderProxy) Stop

func (prx *SenderProxy) Stop()

type SenderProxyConfig

type SenderProxyConfig struct {
	SenderProxyConstantConfig
	BuilderConfigHubEndpoint string
	MaxRequestBodySizeBytes  int64
	ConnectionsPerPeer       int
}

type SenderProxyConstantConfig

type SenderProxyConstantConfig struct {
	Log             *slog.Logger
	OrderflowSigner *signature.Signer
}

type SenderProxyServers

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

func StartSenderServers

func StartSenderServers(proxy *SenderProxy, listenAddress string) (*SenderProxyServers, error)

func (*SenderProxyServers) Stop

func (s *SenderProxyServers) Stop()

type ShareQueue

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

func (*ShareQueue) Run

func (sq *ShareQueue) Run()

Jump to

Keyboard shortcuts

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