A simple server which can be used as an RPC endpoint in popular Ethereum wallets.

RPC Endpoint

This repository contains code for a simple server which can be used as an RPC endpoint in popular Ethereum wallets.

The endpoint is https://rpc.flashbots.net/

It does two basic things:

  • First, it receives json-rpc requests, proxies those to a node, and responds with the result of the proxied request.
  • Second, it sends transactions to a "transaction manager," which manages the submission of that transaction to Flashbots. Currently that transaction manager is the Flashbots Protect API by default.

The server is made up of a few components:

  • server.go: the main server code where json rpc requests are validated and handled
  • relayer.go: handles the evaluation and relaying of transactions
  • types.go: defines a few json rpc types
  • util.go: contains utility functions

Transaction frontrunning protection evaluation rules

Not all transactions need frontrunning protection, and in fact some transactions cannot be sent to Flashbots at all. To reflect this we evaluate transactions in two ways:

  • Does the transaction use more than 42,000 gas? If it doesn't then the Flashbots Relay will reject it, and we're not aware of use cases that use such low gas that need frontrunning protection. Thus, we send low gas transactions to the mempool.
  • Does the transaction call one of a few whitelisted functions, such as an ERC20 approval, that don't need frontrunning protection? If so then we send it to the mempool.

We're open to new ways of evaluating what needs frontrunning protection and welcome PRs to this end.

Using the RPC endpoint as an end user

Please refer to the quick-start guide

Usage

To run the server, run the following command:

go run main.go --listen 127.0.0.1:9000 --proxy PROXY_URL

Example call:

curl localhost:9000 -f -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false],"id":1}'

Maintainers

This project is currently maintained by:

Comments
  • Extend sanctions checking

    Extend sanctions checking

    The current RPC endpoint doesn't go far enough in sanctioning bad people and bad addresses as this only covers one region of the world (USA). The world is much larger and we should account for possible sanctions in every corner of the globe and not just one country. This of course would be the most fair way of handling this so that one country doesn't receive undue preference.

    I've made a start by adding the only current UK sanctioned address, seen here: https://docs.fcdo.gov.uk/docs/UK-Sanctions-List.html

    I am willing to also add the same sanctions checking for other regions such as Russia, China, and North Korea (non-inclusive, just for example) if anyone is able to point me in the direction of their sanctions lists.

  • Whitehat txcache

    Whitehat txcache

    Todo:

    • [x] Rename bundle-id to something better
    • [ ] Test & merge #50
    • [x] Add maximum number of 15 tx per key (using ltrim)
    • [x] Intercept eth_getBalance and return 1 ETH
    • [x] Add a method for users to retrieve the cached keys (simple REST API?)
    • [x] Add e2e tests
    • [x] Test on staging
  • https://rpc.flashbots.net/fast  txn fail after 25 blocks,  then mined 90 minutes later

    https://rpc.flashbots.net/fast txn fail after 25 blocks, then mined 90 minutes later

    https://rpc.flashbots.net/fast txn fail after 25 blocks, then mined 90 minutes later. ( No any changes made at my side after the 25 blocks , no matter gas or endpoint)

    Miner is Ethermine.

    As per https://protect.flashbots.net/

    • fastMode":true,"seenInMempool":false,"simError":"MaxFeePerGasTooLow"}

    maxBlockNumber xxxxxx Which is far less than the actual block number.

    It's not 1st time that Ethermine mined my failed txns after 25 blocks drop in fastmode , it happened twice in last 8 hours , is this a bug or something else?

    ( my Txns were always failed at flashbot normal mode , so all of my 50 + Txns were through fast mode up to now)

    Thanks

  • init parallel batch processing

    init parallel batch processing

    1. Handle parallel batch request
    2. Divide RPCRequest as RpcRequestHandler & RpcRequest
    3. Introudce waitgroup & go routine to handle the batch request in parallel
  • flashbots_getBundleStats fails with

    flashbots_getBundleStats fails with "data did not match any variant of untagged enum ResponseData"

    I'm not sure if this is the correct repo for this issue but it seemed the most fitting out of the exisiting flashbots repos, please redirect me to the right repo if this is not the place for it.

    As per the title, when sending bundles to https://relay-goerli.flashbots.net, calling flashbots_getBundleStats returns the below error:

    RelayError(
      ResponseSerdeJson {
        err: Error("data did not match any variant of untagged enum ResponseData", line: 1, column: 55),
        text: "{\"id\":6,\"result\":{\"isSimulated\":false},\"jsonrpc\":\"2.0\"}",
      }
    

    I tried using both bundles that aren't included and also bundles that end up being included both fail with the same above error.

    Although I’m not sure yet if related, it's worth noting I'm using ethers-flashbots to perform the request.

  • Include sanctions checking for regions outside U.S.

    Include sanctions checking for regions outside U.S.

    Hi Flashbots,

    I'd originally attempted to submit a PR https://github.com/flashbots/rpc-endpoint/pull/96 without first realising that the contribution guidelines stated that I must first submit an issue. Unfortunately my PR was closed without any rationale on why, nor any pathways to rectify this. While the wording was tongue-in-cheek (I acknowledge) the intent was transparent and I believe that you there is a strong case to be made for expanding the sanctions checking to nations other than the U.S.

    My problems with this process so far:

    • Your approach to sactions maintenance is completely undocumented.
      • effect: how was I meant to know that this PR isn't helpful? Do you only consider sanctions from the U.S. to be valid?
    • Your approach to rectifying this PR is unhelpful.
      • effect: what was the issue with this PR? Why was it closed?

    Despite the comments on the PR being spam-like, and brigade-like I would like to make the case to open this PR based on the following:

    • AFAIK, Flashbots is an international organisation with members around the world, as noted in #92.
    • This is an honest, in essence, attempt to level the playing field on the sanctions handling: I have not invented the sanction address and this is very much a real, legally binding sanction from the UK government. Nor am I attempting to conceal it's weight, it is equally as valid as that of OFAC. It just happens to not be the U.S. government.

    While I'd like to be wrong, it feels disappointing to see any project hide behind contribution guidelines for discouraging conversation and to ensure that my next attempt meets all contribution guidelines I am creating this issue before re-raising the PR.

  • 添加制裁名单

    添加制裁名单

    您好,我最近发现您正在添加美国审查员名单。 请添加我们的列表作为可选标志; 它禁止想要主宰我们星球的敌对人士。 这些都是坏人; 还好他们不能参与网络。

    我很乐意将其视为默认标志。

    这种改变对中国人和朝鲜人来说是绝对必要的。 制裁名单包括无缘无故对我们怀有敌意并想要战争的公司的地址。 它还包括乌克兰捐赠基金。

    问候

  • skip serializing result if not set

    skip serializing result if not set

    Without omitempty, result field is serialized even when not populated, causing jsonrpc_core crate to fail deserializing failure response:

    https://docs.rs/jsonrpc-core/latest/jsonrpc_core/types/response/struct.Failure.html (it denies deserialization if unexpected fields like result exist)

    This PR adds omitempty in order to align with the general expectations.

  • Major cleanup, Improved Metamask failed tx handling

    Major cleanup, Improved Metamask failed tx handling

    • Improved Metamask failed tx handling
      • Added support for DEBUG_DONT_SEND_RAWTX environment variable, which will fake sending rawTransactions (returns the tx hash like on success, but doesn't forward it to relay/mempool). This triggers the Metamask failed transaction flow immediately, without needing to wait for a tx to expire.
      • Block transactions with 1e9+ nonce with an error that leads Metamask to drop a transaction immediately
      • Only triggering nonce fix on the latest transaction of a specific sender address
    • Introduction of a state struct which ill be used to put state into Redis in the future
    • Code cleanup: remove artifacts of legacy infra, dead codepaths, some simplifications
    • Allow immediate resubmission of a tx to the relay once state is "FAILED" (don't need to wait for any additional amount of time)
    • Better handle errors from the relay
  • feat(server): redirect `GET /fast` to corresponding docs page

    feat(server): redirect `GET /fast` to corresponding docs page

    Problem

    Currently, both https://rpc.flashbots.net/ and https://rpc.flashbots.net/fast redirect to the same docs page although I think it's more expected to have a redirect to fast mode related page for /fast endpoint.

    If it's an expected behaviour, you can close the PR 😄

    Solution

    ➜  ~ curl -v -L localhost:9000 2>&1 | grep -i "^< location:"
    < Location: https://docs.flashbots.net/flashbots-protect/rpc/quick-start/
    
    ➜  ~ curl -v -L localhost:9000/fast 2>&1 | grep -i "^< location:"
    < Location: https://docs.flashbots.net/flashbots-protect/rpc/fast-mode/
    
  • [feat] Support list of requests

    [feat] Support list of requests

    The endpoint payload must currently be a single JSON-RPC request.

    Infura and others also support a list of requests. Would be nice to support this in the endpoint too.

  • Allow users to choose their own sanctions lists

    Allow users to choose their own sanctions lists

    Summary

    I propose that a new command line argument be added that allows users to set the sanctions list of their choosing. The default OFAC sanctions list would be removed.

    Proposed usage:

    go run cmd/server/main.go -redis REDIS_URL -signingKey ETH_PRIVATE_KEY -proxy PROXY_URL -blocklist BLOCKLIST_PATH_OR_URL
    

    Example 1:

    go run cmd/server/main.go -redis REDIS_URL -signingKey ETH_PRIVATE_KEY -proxy PROXY_URL -blocklist ~/sanctions.jsonc
    
    /* filename: sanctions.jsonc */
    [
        "0xdead",
        "0x1234",
        "0x0" // You get the point
    ]
    

    JSON-C was used as an example, but YAML, JSON, or just a newline-separated file could also be acceptable file formats. Do whatever is easiest to develop, as long as this feature is implemented.

    Example 2

    go run cmd/server/main.go -redis REDIS_URL -signingKey ETH_PRIVATE_KEY -proxy PROXY_URL -blocklist https://someusgovmtwebsite.gov/blocklist.txt
    

    URIs should be allowed as well as files.

  • Removes OFAC blacklist.

    Removes OFAC blacklist.

    We (the Ethereum ecosystem) are building censorship resistant software. We are not building software that censors people out of the gate. If we wanted that, we would just use the fiat banking system and accept that people all over the world are unbanked due to censorship of various governments.

    If we support the OFAC blacklist, why not the equivalent Chinese or Russian blacklist? The whole point of this endeavor (Ethereum, crypto-currency, etc.) is to get away from censorship and this code just embeds it. If MEV-Boost is going to be a core part of Ethereum's infrastructure, it should be written to be censorship resistant from the ground up.

    If individual relayers, proposers, or builders want to run with a blacklist then they are welcome to do that and they can choose to support the totalitarian regime of their choice. It should not be part of the codebase that you are seeking to get "blessed" by the broader Ethereum community though.

  • Keep transactions private if they are destined for a contract, even with no calldata

    Keep transactions private if they are destined for a contract, even with no calldata

    Some contracts, like 0x8fc73419de427f8a5285484a800a85509c6ea385, have a front-runnable function call with no call data. It might be better to check for "is contract" instead of "is calldata 0x".

Related tags
A small tool used to correspond to the IP address according to the name, id, and network alias of the docker container, which can be run as a DNS server

A small tool used to correspond to the IP address according to the name, id, and network alias of the docker container, which can be run as a DNS server

Apr 4, 2022
A high-performance concurrent scanner written by go, which can be used for survival detection, tcp port detection, and web service detection.
A high-performance concurrent scanner written by go, which can be used for survival detection, tcp port detection, and web service detection.

aScan A high-performance concurrent scanner written by go, which can be used for survival detection, tcp port detection, and web service detection. Fu

Aug 15, 2022
Tapestry is an underlying distributed object location and retrieval system (DOLR) which can be used to store and locate objects. This distributed system provides an interface for storing and retrieving key-value pairs.

Tapestry This project implements Tapestry, an underlying distributed object location and retrieval system (DOLR) which can be used to store and locate

Mar 16, 2022
Antenna RPC is an RPC protocol for distributed computing, it's based on QUIC and Colfer. its currently an WIP.

aRPC - Antenna Remote Procedure Call Antenna remote procedure call (aRPC) is an RPC protocol focused on distributed processing and HPC. aRPC is implem

Jun 16, 2021
rpc/v2 support for JSON-RPC 2.0 Specification.

rpc rpc/v2 support for JSON-RPC 2.0 Specification. gorilla/rpc is a foundation for RPC over HTTP services, providing access to the exported methods of

Jul 4, 2021
Go Substrate RPC Client (GSRPC)Go Substrate RPC Client (GSRPC)

Go Substrate RPC Client (GSRPC) Substrate RPC client in Go. It provides APIs and types around Polkadot and any Substrate-based chain RPC calls. This c

Nov 11, 2021
Simple endpoint to create chat for specific application.

About Chat System Simple endpoint to create chat for specific application. Note This endpoints depend on chat-system repoistory, so you ought to run c

Nov 20, 2021
This is a tool that will proxy simple HTTPS requests to an external HTTP endpoint
 This is a tool that will proxy simple HTTPS requests to an external HTTP endpoint

AcmeShield A secured HTTP proxy that forwards requests from a remote service(Postman). This is a tool that will proxy simple HTTPS requests to an exte

Mar 21, 2022
A Realtime API Gateway used with NATS to build REST, real time, and RPC APIs, where all your clients are synchronized seamlessly.
A Realtime API Gateway used with NATS to build REST, real time, and RPC APIs, where all your clients are synchronized seamlessly.

Realtime API Gateway Synchronize Your Clients Visit Resgate.io for guides, live demos, and resources. Resgate is a Go project implementing a realtime

Dec 31, 2022
Netpoll is a high-performance non-blocking I/O networking framework, which focused on RPC scenarios, developed by ByteDance.
Netpoll is a high-performance non-blocking I/O networking framework, which focused on RPC scenarios, developed by ByteDance.

Netpoll is a high-performance non-blocking I/O networking framework, which focused on RPC scenarios, developed by ByteDance. RPC is usually heavy on processing logic and therefore cannot handle I/O serially. But Go's standard library net designed blocking I/O API, so that the RPC framework can only follow the One Conn One Goroutine design.

Jan 2, 2023
Timeouts for popular Go packages

Go Timeouts An unresponsive service can be worse than a down one. It can tie up your entire system if not handled properly. All network requests shoul

Aug 23, 2022
Serve endpoint metadata for client side load balancing

Servok Servok is a service that provides endpoint metadata for client side load balancing. See CONTRIBUTING.md for instructions on how to contribute a

Dec 9, 2021
Gogrok is a self hosted, easy to use alternative to ngrok. It uses SSH as a base protocol, using channels and existing functionality to tunnel requests to an endpoint.

gogrok A simple, easy to use ngrok alternative (self hosted!) The server and client can also be easily embedded into your applications, see the 'serve

Dec 3, 2022
A wrapper for exposing a shared endpoint for Google Cloud Functions in go. API styled after Node.JS firebase-functions package.

firebase-fx A wrapper for Google Cloud Functions that simplifies the deployment of serverless applications. Meant to expose a similar API to the Fireb

Nov 7, 2022
This repo contains a sample app exposing a gRPC health endpoint to demo Kubernetes gRPC probes.

This repo contains a sample app exposing a health endpoint by implementing grpc_health_v1. Usecase is to demo the gRPC readiness and liveness probes introduced in Kubernetes 1.23.

Feb 9, 2022
Sep 23, 2022
Http-server - A HTTP server and can be accessed via TLS and non-TLS mode

Application server.go runs a HTTP/HTTPS server on the port 9090. It gives you 4

Feb 3, 2022