Giter Club home page Giter Club logo

mev-commit's Introduction

This repo is archived. Please check mev-commit for all the latest work.

mev-commit

mev-commit is P2P software that creates a network of execution providers and bidders. Bidders can broadcast bids to providers and receive commitments from them. A high throughput POA EVM chain settles the bids at the end of a block slot.

mev-commit software components

mev-commit execution requirements

  • Software: mev-commit client and curl
  • OS: 64-bit Linux, Mac OS X 10.14+
  • CPU: 4+ cores @ 2.8+ GHz
  • Memory: 16GB+ RAM
  • Network: 1 GBit/sec broadband

Single Line Script For Quick Experimentation

The command:

  • Installs Foundry: For smart contract development and testing.
  • Downloads MEV-Commit Binary: The software included in this Repo, pre-built for your platform.
  • Automatic Funding and Initialization: Prepares node for participation in mev-commit network.
  • Runs the node with requisite configurations to connect to our running testnet.

Bidder Node

curl -o launchmevcommit https://raw.githubusercontent.com/primevprotocol/scripts/main/launchmevcommit && chmod +x launchmevcommit && ./launchmevcommit --node-type bidder

Provider Node

curl -o launchmevcommit https://raw.githubusercontent.com/primevprotocol/scripts/main/launchmevcommit && chmod +x launchmevcommit && ./launchmevcommit --node-type provider

Quick Build (For docker please skip this instruction)

buf generate
go build -o mev-commit ./cmd/main.go

When prompted, read the values of where the Smart-contracts where deployed on the settlement layer and update the configurations in the integrationtest/config/...yml files.

Quickstart

  • An ECDSA private key is required to create an ethereum address for the node as well as to use for the P2P network. Bidders can add an existing key or create a new key using the create-key command.
NAME:
   mev-commit create-key - Create a new ECDSA private key and save it to a file

USAGE:
   mev-commit create-key [command options] <output_file>

OPTIONS:
   --help, -h  show help
  • Once the key is available, create a yaml config file. Example config files are available in the config folder. The important options are defined below:
# Path to private key file.
priv_key_file: ~/.mev-commit/keys/nodekey

# Type of peer. Options are provider and bidder.
peer_type: provider

# Port used for P2P traffic. If not configured, 13522 is the default.
p2p_port: 13522

# Port used for HTTP traffic. If not configured, 13523 is the default.
http_port: 13523

# Port used for RPC traffic. If not configured, 13524 is the default.
rpc_port: 13524

# Secret for the node. This is used to authorize the nodes. The value doesnt matter as long as it is sufficiently unique. It is signed using the private key.
secret: hello

# Address of bidder registery
bidder_registry_contract: 0x62197Abd7672925c7606Bdf9931e42baCa6619AD

# Address of provider registery
provider_registry_contract: 0xeA73E67c2E34C4E02A2f3c5D416F59B76e7617fC

# Format used for the logs. Options are "text" or "json".
log_fmt: text

# Log level. Options are "debug", "info", "warn" or "error".
log_level: debug

# Bootnodes used for bootstrapping the network.
bootnodes:
  - /ip4/35.91.118.20/tcp/13522/p2p/16Uiu2HAmAG5z3E8p7o19tEcLdGvYrJYdD1NabRDc6jmizDva5BL3

# The default is set to false for development reasons. Change it to true if you wish to accept bids on your provider instance
expose_provider_api: false
  • Once the config file is ready, run mev-commit start with the config option.
NAME:
   mev-commit start - Start the mev-commit node

USAGE:
   mev-commit start [command options] [arguments...]

OPTIONS:
   --config value  path to config file [$MEV_COMMIT_CONFIG]
   --help, -h      show help
  • After the node is started, check the status of the peers connected to the node using the /topology endpoint on the HTTP port (optional).
{
   "self": {
      "Addresses": [
         "/ip4/127.0.0.1/tcp/13526",
         "/ip4/192.168.1.103/tcp/13526",
         "/ip4/192.168.100.5/tcp/18625"
      ],
      "Ethereum Address": "0x55B3B672DEB14178615F648911e76b7FE1B23e5D",
      "Peer Type": "provider",
      "Underlay": "16Uiu2HAmBykfyf9A5DnRguHNS1mvSaprzYEkjRf6uafLU4javG4L"
   },
   "connected_peers": {
      "providers": [
         "0xca61596ccef983eb7cae42340ec553dd89881403"
      ]
   }
}

Building Docker Image

To simplify the deployment process, you may utilize Docker to create an isolated environment to run mev-commit.

  • Build the Docker Image: Navigate to the project root directory (where your Dockerfile is located) and run:

    docker build -t mev-commit:latest .
    
  • Running with Docker Compose:

    If you want to just spin up the mev-commit p2p nodes, you may use:

    docker-compose up --build
    
  • Stopping the Service:

    docker-compose down
    

APIs for Bidders & Execution Providers

Link to Documentation on Bidder and Execution provider API

  • This includes:
    • the payload for the Bidder API
    • The required setup for execution providers to process bids into commitments in their personal infra.

Settlement Layer

This repository contains a settlement layer under the settlement/geth-poa folder. You can run the entire stack for multiple POA nodes locally from this folder. See here for instructions on running the Settlment Layer locally.

mev-commit's People

Contributors

aloknerurkar avatar ckartik avatar dependabot[bot] avatar iowar avatar kant777 avatar mikelle avatar mrekucci avatar shaspitz avatar techgangboss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mev-commit's Issues

gRPC gateway

Add gRPC gateway endpoints for the RPC APIs. This will allow the RPCs to be available on HTTP.

Add annotations and generate basic openapi spec for docs.

Update protocols to use new protobuf encoding

Currently, we have 2 protocols already. By the time this issue is started we might have another one. They are using msgpack encoding right now to exchange messages. Instead they should use protobuf implementation.

Tasks:

  1. Define the protobuf messages. These would be similar to the existing structs used.
  2. Generate pb files for the proto specs.
  3. Update the protocols to use the new types and use the protobuf encoder/decoder to read/write.
  4. Update any tests required in the protocols.

Add tracing support

  • Setup opentelemetry tracing support
  • Setup spans for relevant packages
  • Use datadog? or other open source tools to start observing the traces

Implement simple topology

Implement the topology implementation following the interfaces already defined.

Currently the implementation would be simple as the network is small.

Node init and CLI

Implement simple CLI to instantiate the node and run the p2p client.

Add model or property based e2e testing

Following integration of settlement layer devnet, an e2e testing framework should be introduced. There's a lot of flavors as to how this idea could be implemented. General idea is to apply high level actions to a system, and test the outcome of such actions against an expected system state. Few Different options:

  • System inputs w/ expected outputs can be encoded manually
  • Model based testing can be used to generate input/expected output traces that must satisfy a simplified model of the system (compatible with fuzz testing)
  • Property based testing can be used to generate i/o traces from properties/invariants defined for the system (compatible with fuzz testing)

Inspiration which I am familiar with:

Nit UX Improvement: Add Provider Address in API Response

It would be nice to check the commitmentSignature and do an ECRecover on the payload, and augment the output of the API to include the address associated with the provider.

e.g, currently if you POST a bid to the bidder api, you get back a payload:

{
      "txHash":"91a89B633194c0D86C539A1A5B14DCCacfD47094",
      "bidAmount":"2000",
      "blockNumber":"890200",
      "receivedBidDigest":"61634fad9081e1b23a00234a52a85386a91fc0fad3fb32d325891bdc4f8a52a9",
      "receivedBidSignature":"be99f499be5483665d569bd52fa8c4c9ed5c3bed2f94fb9949259bf640d8bd365b1d9a4b9ccb3ace86ffdcd1fdadc605b0f49b3adaf1c6a9ffea25585234664f1c",
      "commitmentDigest":"08a98d4c9d45f8431b46d99a23e6e8f82601ccf0773499d4e47bcd857cad92a6",
      "commitmentSignature":"cfc1e4e2ea9cc417027ed5846fa073c8e6031f70f91ffa9b92051b5b7738c0500d8fefb0fc189bce16004b3c0e1c4cfa41260968161adf8b55446ed5c40d1ac51b"
   }

We can augment the response to have "providerAddress": 0xProvider

{
      "providerAddress": 0xProvider
      "txHash":"91a89B633194c0D86C539A1A5B14DCCacfD47094",
      "bidAmount":"2000",
      ..."commitmentSignature":"cfc1e4e2ea9cc417027ed5846fa073c8e6031f70f91ffa9b92051b5b7738c0500d8fefb0fc189bce16004b3c0e1c4cfa41260968161adf8b55446ed5c40d1ac51b"
   }
} 

Add blocklisting and connection gating

  • Blocklisting can be handled at the libp2p level which makes it transparent for the protocol handlers. This can be done by protocols either returning some specific error which can include reason and time to blocklist. Also, we can have a top-level interface in the libp2p.Service to blocklist with reason and time.
  • Add libp2p.ConnectionGater option. This can use blocklist or other mechanisms to prevent unnecessary protocol traffic on the node.

Add protobuf encoding for msg handling

Add protobuf encoding, similar to pkg/p2p/msgpack.

For protobuf, we don't need to use generics as pb.Message interface already provides similar features.

ReadMsg(context.Context, pb.Message) error
WriteMsg(context.Context, pb.Message) error

Add unit tests for the implementation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.