Documentation ¶
Overview ¶
OFAC banned addresses
Request represents an incoming client request ¶
Whitelist for smart contract functions that never need protection.
Index ¶
- Variables
- func AddressPtrToStr(a *common.Address) string
- func AuctionPreferenceErrorToJSONRPCResponse(jsonReq *types.JsonRpcRequest, err error) *types.JsonRpcResponse
- func BigIntPtrToStr(i *big.Int) string
- func GetEnv(key string, defaultValue string) string
- func GetIP(r *http.Request) string
- func GetIPHash(r *http.Request) string
- func GetSenderAddressFromTx(tx *ethtypes.Transaction) (common.Address, error)
- func GetSenderFromRawTx(tx *ethtypes.Transaction) (string, error)
- func GetSenderFromTx(tx *ethtypes.Transaction) (string, error)
- func GetTx(rawTxHex string) (*ethtypes.Transaction, error)
- func GetTxStatus(txHash string) (*types.PrivateTxApiResponse, error)
- func IsMetamask(r *http.Request) bool
- func IsMetamaskMoz(r *http.Request) bool
- func Max(a uint64, b uint64) uint64
- func Min(a uint64, b uint64) uint64
- func NewRequestRecord(db database.Store) *requestRecord
- func RedisKeyBlockedTxHash(txHash string) string
- func RedisKeyNonceFixForAccount(txFrom string) string
- func RedisKeySenderMaxNonce(txFrom string) string
- func RedisKeySenderOfTxHash(txHash string) string
- func RedisKeyTxHashForSenderAndNonce(txFrom string, nonce uint64) string
- func RedisKeyTxSentToRelay(txHash string) string
- func RedisKeyWhitehatBundleTransactions(bundleId string) string
- type BuilderNameProvider
- type Configuration
- type Fingerprint
- type RPCProxyClient
- type RedisState
- func (s *RedisState) AddTxToWhitehatBundle(bundleId string, signedTx string) error
- func (s *RedisState) DelNonceFixForAccount(txFrom string) error
- func (s *RedisState) DelSenderMaxNonce(txFrom string) error
- func (s *RedisState) DelWhitehatBundleTx(bundleId string) error
- func (s *RedisState) GetBlockedTxHash(txHash string) (returnValue string, found bool, err error)
- func (s *RedisState) GetNonceFixForAccount(txFrom string) (numTimesSent uint64, found bool, err error)
- func (s *RedisState) GetSenderMaxNonce(txFrom string) (senderMaxNonce uint64, found bool, err error)
- func (s *RedisState) GetSenderOfTxHash(txHash string) (txSender string, found bool, err error)
- func (s *RedisState) GetTxHashForSenderAndNonce(txFrom string, nonce uint64) (txHash string, found bool, err error)
- func (s *RedisState) GetTxSentToRelay(txHash string) (timeSent time.Time, found bool, err error)
- func (s *RedisState) GetWhitehatBundleTx(bundleId string) ([]string, error)
- func (s *RedisState) SetBlockedTxHash(txHash string, returnValue string) error
- func (s *RedisState) SetNonceFixForAccount(txFrom string, numTimesSent uint64) error
- func (s *RedisState) SetSenderMaxNonce(txFrom string, nonce uint64) error
- func (s *RedisState) SetSenderOfTxHash(txHash string, txFrom string) error
- func (s *RedisState) SetTxHashForSenderAndNonce(txFrom string, nonce uint64, txHash string) error
- func (s *RedisState) SetTxSentToRelay(txHash string) error
- type RpcEndPointServer
- type RpcRequest
- type RpcRequestHandler
- type URLParameters
Constants ¶
This section is empty.
Variables ¶
var ( DefaultAuctionHint = []string{"hash", "special_logs"} ErrEmptyHintQuery = errors.New("Hint query must be non-empty if set.") ErrEmptyTargetBuilderQuery = errors.New("Target builder query must be non-empty if set.") ErrIncorrectAuctionHints = errors.New("Incorrect auction hint, must be one of: contract_address, function_selector, logs, calldata, default_logs.") ErrIncorrectOriginId = errors.New("Incorrect origin id, must be less then 255 char.") ErrIncorrectRefundQuery = errors.New("Incorrect refund query, must be 0xaddress:percentage.") ErrIncorrectRefundAddressQuery = errors.New("Incorrect refund address.") ErrIncorrectRefundPercentageQuery = errors.New("Incorrect refund percentage.") ErrIncorrectRefundTotalPercentageQuery = errors.New("Incorrect refund total percentage, must be bellow 100%.") )
var DebugDontSendTx = os.Getenv("DEBUG_DONT_SEND_RAWTX") != ""
var Now = time.Now // used to mock time in tests
var ProtectTxApiHost = GetEnv("TX_API_HOST", "https://protect.flashbots.net")
var RedisExpiryBlockedTxHash = 24 * time.Hour // 1 day
var RedisExpiryNonceFixForAccount = 24 * time.Hour // 1 day
var RedisExpirySenderMaxNonce = 2 * time.Hour
var RedisExpirySenderOfTxHash = 24 * time.Hour // 1 day
var RedisExpiryTxHashForSenderAndNonce = 24 * time.Hour // 1 day
var RedisExpiryTxSentToRelay = 24 * time.Hour // 1 day
var RedisExpiryWhitehatBundleTransactions = 24 * time.Hour // 1 day
var RedisPrefix = "rpc-endpoint:"
var RedisPrefixBlockedTxHash = RedisPrefix + "blocked-tx-hash:"
Enable lookup of bundle txs by bundleId
var RedisPrefixNonceFixForAccount = RedisPrefix + "txsender-with-nonce-fix:"
nonce-fix of an account (with number of times sent)
var RedisPrefixSenderMaxNonce = RedisPrefix + "txsender-pending-max-nonce:"
Remember nonce of pending user tx
var RedisPrefixSenderOfTxHash = RedisPrefix + "txsender-of-txhash:"
Enable lookup of txFrom by txHash
var RedisPrefixTxHashForSenderAndNonce = RedisPrefix + "txsender-and-nonce-to-txhash:"
Enable lookup of txHash by txFrom+nonce (only if sent to relay)
var RedisPrefixTxSentToRelay = RedisPrefix + "tx-sent-to-relay:"
Enable lookup of timeSentToRelay by txHash
var RedisPrefixWhitehatBundleTransactions = RedisPrefix + "tx-for-whitehat-bundle:"
Enable lookup of bundle txs by bundleId
Functions ¶
func AddressPtrToStr ¶ added in v1.4.4
func AuctionPreferenceErrorToJSONRPCResponse ¶ added in v1.6.0
func AuctionPreferenceErrorToJSONRPCResponse(jsonReq *types.JsonRpcRequest, err error) *types.JsonRpcResponse
func BigIntPtrToStr ¶ added in v1.4.4
func GetEnv ¶ added in v1.6.0
GetEnv returns the value of the environment variable named by key, or defaultValue if the environment variable doesn't exist
func GetSenderAddressFromTx ¶ added in v1.6.0
func GetSenderAddressFromTx(tx *ethtypes.Transaction) (common.Address, error)
func GetSenderFromRawTx ¶
func GetSenderFromRawTx(tx *ethtypes.Transaction) (string, error)
func GetSenderFromTx ¶
func GetSenderFromTx(tx *ethtypes.Transaction) (string, error)
func GetTxStatus ¶ added in v1.3.0
func GetTxStatus(txHash string) (*types.PrivateTxApiResponse, error)
func NewRequestRecord ¶ added in v1.5.0
func RedisKeyBlockedTxHash ¶ added in v1.5.1
func RedisKeyNonceFixForAccount ¶ added in v1.4.2
func RedisKeySenderMaxNonce ¶ added in v1.4.2
func RedisKeySenderOfTxHash ¶ added in v1.4.2
func RedisKeyTxHashForSenderAndNonce ¶ added in v1.4.2
func RedisKeyTxSentToRelay ¶ added in v1.4.2
func RedisKeyWhitehatBundleTransactions ¶ added in v1.4.3
Types ¶
type BuilderNameProvider ¶ added in v1.6.0
type BuilderNameProvider interface {
BuilderNames() []string
}
type Configuration ¶ added in v1.6.0
type Configuration struct { DB database.Store DrainAddress string DrainSeconds int ListenAddress string Logger log.Logger ProxyTimeoutSeconds int ProxyUrl string RedisUrl string RelaySigningKey *ecdsa.PrivateKey RelayUrl string Version string BuilderInfoSource string FetchInfoInterval int TTLCacheSeconds int64 }
type Fingerprint ¶ added in v1.7.0
type Fingerprint uint64
func FingerprintFromRequest ¶ added in v1.7.0
FingerprintFromRequest returns a fingerprint for the request based on the X-Forwarded-For header and a salted timestamp. The fingerprint is used to identify unique users sessions over a short period of time, and thus can be used as a key for rate limiting. The seed param is additional entropy to make the fingerprint resistant to rainbow table lookups. Without the seed a malicious rpc operator could reverse a client IP address to a fingerprint by exhausting all possible IP addresses and comparing the resulting fingerprints.
We considered adding the User-Agent header to the fingerprint, but decided against it because it would make the fingerprint gameable. Instead, we will salt the fingerprint with the current timestamp rounded to the latest hour. This will make sure fingerprints rotate every hour so we cannot reasonably track user behavior over time.
func (Fingerprint) ToIPv6 ¶ added in v1.7.0
func (f Fingerprint) ToIPv6() net.IP
type RPCProxyClient ¶ added in v1.4.4
func NewRPCProxyClient ¶ added in v1.4.4
func NewRPCProxyClient(logger log.Logger, proxyURL string, timeoutSeconds int, fingerprint Fingerprint) RPCProxyClient
type RedisState ¶ added in v1.4.2
type RedisState struct {
RedisClient *redis.Client
}
var RState *RedisState
Metamask fix helper
func NewRedisState ¶ added in v1.4.2
func NewRedisState(redisUrl string) (*RedisState, error)
func (*RedisState) AddTxToWhitehatBundle ¶ added in v1.4.3
func (s *RedisState) AddTxToWhitehatBundle(bundleId string, signedTx string) error
Enable lookup of tx bundles by bundle ID
func (*RedisState) DelNonceFixForAccount ¶ added in v1.4.2
func (s *RedisState) DelNonceFixForAccount(txFrom string) error
func (*RedisState) DelSenderMaxNonce ¶ added in v1.8.1
func (s *RedisState) DelSenderMaxNonce(txFrom string) error
func (*RedisState) DelWhitehatBundleTx ¶ added in v1.4.3
func (s *RedisState) DelWhitehatBundleTx(bundleId string) error
func (*RedisState) GetBlockedTxHash ¶ added in v1.5.1
func (s *RedisState) GetBlockedTxHash(txHash string) (returnValue string, found bool, err error)
func (*RedisState) GetNonceFixForAccount ¶ added in v1.4.2
func (s *RedisState) GetNonceFixForAccount(txFrom string) (numTimesSent uint64, found bool, err error)
func (*RedisState) GetSenderMaxNonce ¶ added in v1.4.2
func (s *RedisState) GetSenderMaxNonce(txFrom string) (senderMaxNonce uint64, found bool, err error)
func (*RedisState) GetSenderOfTxHash ¶ added in v1.4.2
func (s *RedisState) GetSenderOfTxHash(txHash string) (txSender string, found bool, err error)
func (*RedisState) GetTxHashForSenderAndNonce ¶ added in v1.4.2
func (*RedisState) GetTxSentToRelay ¶ added in v1.4.2
func (*RedisState) GetWhitehatBundleTx ¶ added in v1.4.3
func (s *RedisState) GetWhitehatBundleTx(bundleId string) ([]string, error)
func (*RedisState) SetBlockedTxHash ¶ added in v1.5.1
func (s *RedisState) SetBlockedTxHash(txHash string, returnValue string) error
Block transactions, with a specific return value (eg. "nonce too low")
func (*RedisState) SetNonceFixForAccount ¶ added in v1.4.2
func (s *RedisState) SetNonceFixForAccount(txFrom string, numTimesSent uint64) error
nonce-fix per account
func (*RedisState) SetSenderMaxNonce ¶ added in v1.4.2
func (s *RedisState) SetSenderMaxNonce(txFrom string, nonce uint64) error
func (*RedisState) SetSenderOfTxHash ¶ added in v1.4.2
func (s *RedisState) SetSenderOfTxHash(txHash string, txFrom string) error
Enable lookup of txFrom by txHash
func (*RedisState) SetTxHashForSenderAndNonce ¶ added in v1.4.2
func (s *RedisState) SetTxHashForSenderAndNonce(txFrom string, nonce uint64, txHash string) error
Enable lookup of txHash by txFrom+nonce
func (*RedisState) SetTxSentToRelay ¶ added in v1.4.2
func (s *RedisState) SetTxSentToRelay(txHash string) error
Enable lookup of timeSentToRelay by txHash
type RpcEndPointServer ¶
type RpcEndPointServer struct {
// contains filtered or unexported fields
}
func NewRpcEndPointServer ¶
func NewRpcEndPointServer(cfg Configuration) (*RpcEndPointServer, error)
func (*RpcEndPointServer) HandleBundleRequest ¶ added in v1.4.3
func (s *RpcEndPointServer) HandleBundleRequest(respw http.ResponseWriter, req *http.Request)
func (*RpcEndPointServer) HandleHttpRequest ¶
func (s *RpcEndPointServer) HandleHttpRequest(respw http.ResponseWriter, req *http.Request)
func (*RpcEndPointServer) Start ¶
func (s *RpcEndPointServer) Start()
type RpcRequest ¶
type RpcRequest struct {
// contains filtered or unexported fields
}
func NewRpcRequest ¶
func NewRpcRequest( logger log.Logger, client RPCProxyClient, jsonReq *types.JsonRpcRequest, relaySigningKey *ecdsa.PrivateKey, relayUrl, origin, referer string, isWhitehatBundleCollection bool, whitehatBundleId string, ethSendRawTxEntry *database.EthSendRawTxEntry, urlParams URLParameters, chainID []byte, rpcCache *application.RpcCache, ) *RpcRequest
func (*RpcRequest) CheckFlashbotsSignature ¶ added in v1.8.0
func (r *RpcRequest) CheckFlashbotsSignature(signature string, body []byte) error
CheckFlashbotsSignature parses and validates the Flashbots signature if present, returning an error if the signature is invalid. If the signature is present and valid the signing address is stored in the request.
func (*RpcRequest) GetAddressNonceRange ¶ added in v1.4.2
func (r *RpcRequest) GetAddressNonceRange(address string) (minNonce, maxNonce uint64, err error)
func (*RpcRequest) ProcessRequest ¶ added in v1.4.3
func (r *RpcRequest) ProcessRequest() *types.JsonRpcResponse
func (*RpcRequest) WhitehatBalanceCheckerRewrite ¶ added in v1.4.3
func (r *RpcRequest) WhitehatBalanceCheckerRewrite()
type RpcRequestHandler ¶ added in v1.4.3
type RpcRequestHandler struct {
// contains filtered or unexported fields
}
RPC request handler for a single/ batch JSON-RPC request
func NewRpcRequestHandler ¶ added in v1.4.3
func NewRpcRequestHandler( logger log.Logger, respw *http.ResponseWriter, req *http.Request, proxyUrl string, proxyTimeoutSeconds int, relaySigningKey *ecdsa.PrivateKey, relayUrl string, db database.Store, builderNames []string, chainID []byte, rpcCache *application.RpcCache, ) *RpcRequestHandler
type URLParameters ¶ added in v1.6.0
type URLParameters struct {
// contains filtered or unexported fields
}
func ExtractParametersFromUrl ¶ added in v1.6.0
func ExtractParametersFromUrl(url *url.URL, allBuilders []string) (params URLParameters, err error)
ExtractParametersFromUrl extracts the auction preference from the url query Allowed query params:
- hint: mev share hints, can be set multiple times, default: hash, special_logs
- originId: origin id, default: ""
- builder: target builder, can be set multiple times, default: empty (only send to flashbots builders)
- refund: refund in the form of 0xaddress:percentage, default: empty (will be set by default when backrun is produced) example: 0x123:80 - will refund 80% of the backrun profit to 0x123