Documentation ¶
Overview ¶
Package server OFAC banned addresses Package server Request represents an incoming client request
Package server 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, 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, b uint64) uint64
- func Min(a, 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 RPCEndPointServer
- type RPCProxyClient
- type RPCRequest
- type RPCRequestHandler
- type RedisState
- func (s *RedisState) AddTxToWhitehatBundle(bundleID, signedTx string) error
- func (s *RedisState) DelNonceFixForAccount(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, 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, txFrom string) error
- func (s *RedisState) SetTxHashForSenderAndNonce(txFrom string, nonce uint64, txHash string) error
- func (s *RedisState) SetTxSentToRelay(txHash string) error
- type URLParameters
Constants ¶
This section is empty.
Variables ¶
var ( RedisPrefixTxSentToRelay = RedisPrefix + "tx-sent-to-relay:" RedisExpiryTxSentToRelay = 24 * time.Hour // 1 day )
Enable lookup of timeSentToRelay by txHash
var ( RedisPrefixTxHashForSenderAndNonce = RedisPrefix + "txsender-and-nonce-to-txhash:" RedisExpiryTxHashForSenderAndNonce = 24 * time.Hour // 1 day )
Enable lookup of txHash by txFrom+nonce (only if sent to relay)
var ( RedisPrefixNonceFixForAccount = RedisPrefix + "txsender-with-nonce-fix:" RedisExpiryNonceFixForAccount = 24 * time.Hour // 1 day )
nonce-fix of an account (with number of times sent)
var ( RedisPrefixSenderOfTxHash = RedisPrefix + "txsender-of-txhash:" RedisExpirySenderOfTxHash = 24 * time.Hour // 1 day )
Enable lookup of txFrom by txHash
var ( RedisPrefixSenderMaxNonce = RedisPrefix + "txsender-pending-max-nonce:" RedisExpirySenderMaxNonce = 2 * time.Hour )
Remember nonce of pending user tx
var ( RedisPrefixWhitehatBundleTransactions = RedisPrefix + "tx-for-whitehat-bundle:" RedisExpiryWhitehatBundleTransactions = 24 * time.Hour // 1 day )
Enable lookup of bundle txs by bundleID
var ( RedisPrefixBlockedTxHash = RedisPrefix + "blocked-tx-hash:" RedisExpiryBlockedTxHash = 24 * time.Hour // 1 day )
Enable lookup of bundle txs by bundleID
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 RedisPrefix = "rpc-endpoint:"
Functions ¶
func AddressPtrToStr ¶
func AuctionPreferenceErrorToJSONRPCResponse ¶
func AuctionPreferenceErrorToJSONRPCResponse(jsonReq *types.JSONRPCRequest, err error) *types.JSONRPCResponse
func BigIntPtrToStr ¶
func GetEnv ¶
GetEnv returns the value of the environment variable named by key, or defaultValue if the environment variable doesn't exist
func GetSenderAddressFromTx ¶
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 ¶
func GetTxStatus(txHash string) (*types.PrivateTxAPIResponse, error)
func IsMetamask ¶
IsMetamask CHROME_ID: nkbihfbeogaeaoehlefnkodbefgpgknn
func IsMetamaskMoz ¶
IsMetamaskMoz FIREFOX_ID: webextension@metamask.io
func NewRequestRecord ¶
func RedisKeyBlockedTxHash ¶
func RedisKeySenderMaxNonce ¶
func RedisKeySenderOfTxHash ¶
func RedisKeyTxSentToRelay ¶
Types ¶
type BuilderNameProvider ¶
type BuilderNameProvider interface {
BuilderNames() []string
}
type Configuration ¶
type RPCEndPointServer ¶
type RPCEndPointServer struct {
// contains filtered or unexported fields
}
func NewRPCEndPointServer ¶
func NewRPCEndPointServer(cfg Configuration) (*RPCEndPointServer, error)
func (*RPCEndPointServer) HandleBundleRequest ¶
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 RPCProxyClient ¶
func NewRPCProxyClient ¶
func NewRPCProxyClient(logger *zap.Logger, proxyURL string, timeoutSeconds int) RPCProxyClient
type RPCRequest ¶
type RPCRequest struct {
// contains filtered or unexported fields
}
func NewRPCRequest ¶
func NewRPCRequest(logger *zap.Logger, client RPCProxyClient, jsonReq *types.JSONRPCRequest, relaySigningKey *ecdsa.PrivateKey, relayURL, origin, referer string, isWhitehatBundleCollection bool, proxyURL string, ethSendRawTxEntry *database.EthSendRawTxEntry, urlParams URLParameters, chainID []byte) *RPCRequest
func (*RPCRequest) GetAddressNonceRange ¶
func (r *RPCRequest) GetAddressNonceRange(address string) (minNonce, maxNonce uint64, err error)
func (*RPCRequest) ProcessRequest ¶
func (r *RPCRequest) ProcessRequest() *types.JSONRPCResponse
func (*RPCRequest) WhitehatBalanceCheckerRewrite ¶
func (r *RPCRequest) WhitehatBalanceCheckerRewrite()
type RPCRequestHandler ¶
type RPCRequestHandler struct {
// contains filtered or unexported fields
}
RPCRequestHandler RPC request handler for a single/ batch JSON-RPC request
func NewRPCRequestHandler ¶
type RedisState ¶
type RedisState struct {
RedisClient *redis.Client
}
var RState *RedisState
RState Metamask fix helper
func NewRedisState ¶
func NewRedisState(redisURL string) (*RedisState, error)
func (*RedisState) AddTxToWhitehatBundle ¶
func (s *RedisState) AddTxToWhitehatBundle(bundleID, signedTx string) error
AddTxToWhitehatBundle Enable lookup of tx bundles by bundle ID
func (*RedisState) DelNonceFixForAccount ¶
func (s *RedisState) DelNonceFixForAccount(txFrom string) error
func (*RedisState) DelWhitehatBundleTx ¶
func (s *RedisState) DelWhitehatBundleTx(bundleID string) error
func (*RedisState) GetBlockedTxHash ¶
func (s *RedisState) GetBlockedTxHash(txHash string) (returnValue string, found bool, err error)
func (*RedisState) GetNonceFixForAccount ¶
func (s *RedisState) GetNonceFixForAccount(txFrom string) (numTimesSent uint64, found bool, err error)
func (*RedisState) GetSenderMaxNonce ¶
func (s *RedisState) GetSenderMaxNonce(txFrom string) (senderMaxNonce uint64, found bool, err error)
func (*RedisState) GetSenderOfTxHash ¶
func (s *RedisState) GetSenderOfTxHash(txHash string) (txSender string, found bool, err error)
func (*RedisState) GetTxHashForSenderAndNonce ¶
func (*RedisState) GetTxSentToRelay ¶
func (*RedisState) GetWhitehatBundleTx ¶
func (s *RedisState) GetWhitehatBundleTx(bundleID string) ([]string, error)
func (*RedisState) SetBlockedTxHash ¶
func (s *RedisState) SetBlockedTxHash(txHash, returnValue string) error
SetBlockedTxHash Block transactions, with a specific return value (eg. "nonce too low")
func (*RedisState) SetNonceFixForAccount ¶
func (s *RedisState) SetNonceFixForAccount(txFrom string, numTimesSent uint64) error
SetNonceFixForAccount nonce-fix per account
func (*RedisState) SetSenderMaxNonce ¶
func (s *RedisState) SetSenderMaxNonce(txFrom string, nonce uint64) error
func (*RedisState) SetSenderOfTxHash ¶
func (s *RedisState) SetSenderOfTxHash(txHash, txFrom string) error
SetSenderOfTxHash Enable lookup of txFrom by txHash
func (*RedisState) SetTxHashForSenderAndNonce ¶
func (s *RedisState) SetTxHashForSenderAndNonce(txFrom string, nonce uint64, txHash string) error
SetTxHashForSenderAndNonce Enable lookup of txHash by txFrom+nonce
func (*RedisState) SetTxSentToRelay ¶
func (s *RedisState) SetTxSentToRelay(txHash string) error
SetTxSentToRelay Enable lookup of timeSentToRelay by txHash
type URLParameters ¶
type URLParameters struct {
// contains filtered or unexported fields
}
func ExtractParametersFromURL ¶
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