server

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

OFAC banned addresses

Request represents an incoming client request

Whitelist for smart contract functions that never need protection.

Index

Constants

This section is empty.

Variables

View Source
var DebugDontSendTx = os.Getenv("DEBUG_DONT_SEND_RAWTX") != ""
View Source
var Now = time.Now // used to mock time in tests
View Source
var ProtectTxApiHost = "https://protect.flashbots.net"
View Source
var RedisExpiryBlockedTxHash = 24 * time.Hour // 1 day
View Source
var RedisExpiryNonceFixForAccount = 24 * time.Hour // 1 day
View Source
var RedisExpirySenderMaxNonce = 2 * time.Hour
View Source
var RedisExpirySenderOfTxHash = 24 * time.Hour // 1 day
View Source
var RedisExpiryTxHashForSenderAndNonce = 24 * time.Hour // 1 day
View Source
var RedisExpiryTxSentToRelay = 24 * time.Hour // 1 day
View Source
var RedisExpiryWhitehatBundleTransactions = 24 * time.Hour // 1 day
View Source
var RedisPrefix = "rpc-endpoint:"
View Source
var RedisPrefixBlockedTxHash = RedisPrefix + "blocked-tx-hash:"

Enable lookup of bundle txs by bundleId

View Source
var RedisPrefixNonceFixForAccount = RedisPrefix + "txsender-with-nonce-fix:"

nonce-fix of an account (with number of times sent)

View Source
var RedisPrefixSenderMaxNonce = RedisPrefix + "txsender-pending-max-nonce:"

Remember nonce of pending user tx

View Source
var RedisPrefixSenderOfTxHash = RedisPrefix + "txsender-of-txhash:"

Enable lookup of txFrom by txHash

View Source
var RedisPrefixTxHashForSenderAndNonce = RedisPrefix + "txsender-and-nonce-to-txhash:"

Enable lookup of txHash by txFrom+nonce (only if sent to relay)

View Source
var RedisPrefixTxSentToRelay = RedisPrefix + "tx-sent-to-relay:"

Enable lookup of timeSentToRelay by txHash

View Source
var RedisPrefixWhitehatBundleTransactions = RedisPrefix + "tx-for-whitehat-bundle:"

Enable lookup of bundle txs by bundleId

Functions

func AddressPtrToStr added in v1.4.4

func AddressPtrToStr(a *common.Address) string

func BigIntPtrToStr added in v1.4.4

func BigIntPtrToStr(i *big.Int) string

func GetIP

func GetIP(r *http.Request) string

func GetIPHash added in v1.5.0

func GetIPHash(r *http.Request) string

func GetSenderFromRawTx

func GetSenderFromRawTx(tx *ethtypes.Transaction) (string, error)

func GetSenderFromTx

func GetSenderFromTx(tx *ethtypes.Transaction) (string, error)

func GetTx

func GetTx(rawTxHex string) (*ethtypes.Transaction, error)

func GetTxStatus added in v1.3.0

func GetTxStatus(txHash string) (*types.PrivateTxApiResponse, error)

func IsBlacklisted

func IsBlacklisted(ip string) bool

func IsMetamask

func IsMetamask(r *http.Request) bool

CHROME_ID: nkbihfbeogaeaoehlefnkodbefgpgknn

func IsMetamaskMoz

func IsMetamaskMoz(r *http.Request) bool

FIREFOX_ID: webextension@metamask.io

func Max added in v1.4.2

func Max(a uint64, b uint64) uint64

func Min added in v1.4.2

func Min(a uint64, b uint64) uint64

func NewRequestRecord added in v1.5.0

func NewRequestRecord(db database.Store) *requestRecord

func ParseJsonRPCResponse added in v1.4.4

func ParseJsonRPCResponse(resp *http.Response) (*types.JsonRpcResponse, error)

func RedisKeyBlockedTxHash added in v1.5.1

func RedisKeyBlockedTxHash(txHash string) string

func RedisKeyNonceFixForAccount added in v1.4.2

func RedisKeyNonceFixForAccount(txFrom string) string

func RedisKeySenderMaxNonce added in v1.4.2

func RedisKeySenderMaxNonce(txFrom string) string

func RedisKeySenderOfTxHash added in v1.4.2

func RedisKeySenderOfTxHash(txHash string) string

func RedisKeyTxHashForSenderAndNonce added in v1.4.2

func RedisKeyTxHashForSenderAndNonce(txFrom string, nonce uint64) string

func RedisKeyTxSentToRelay added in v1.4.2

func RedisKeyTxSentToRelay(txHash string) string

func RedisKeyWhitehatBundleTransactions added in v1.4.3

func RedisKeyWhitehatBundleTransactions(bundleId string) string

Types

type RPCProxyClient added in v1.4.4

type RPCProxyClient interface {
	ProxyRequest(body []byte) (*http.Response, error)
}

func NewRPCProxyClient added in v1.4.4

func NewRPCProxyClient(proxyURL string) 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) 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 (s *RedisState) GetTxHashForSenderAndNonce(txFrom string, nonce uint64) (txHash string, found bool, err error)

func (*RedisState) GetTxSentToRelay added in v1.4.2

func (s *RedisState) GetTxSentToRelay(txHash string) (timeSent time.Time, found bool, err error)

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(version, listenAddress, proxyUrl, relayUrl string, relaySigningKey *ecdsa.PrivateKey, redisUrl string, db database.Store) (*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, ip, origin string, isWhitehatBundleCollection bool, whitehatBundleId string, ethSendRawTxEntry *database.EthSendRawTxEntry, preferences *types.PrivateTxPreferences) *RpcRequest

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(respw *http.ResponseWriter, req *http.Request, proxyUrl string, relaySigningKey *ecdsa.PrivateKey, db database.Store) *RpcRequestHandler

Jump to

Keyboard shortcuts

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