Code Monkey home page Code Monkey logo

trin's Introduction

trin

(a working name)

Trin is an Ethereum "portal": a json-rpc server with nearly instant sync, and low CPU & storage usage.

Trin does this by making these tradeoffs:

  • Trusts miners to include valid state transitions, to skip sync
  • Shards state across a (new) p2p network, to reduce local storage needs

This should sound similar to a light client. It is, but with a peer-to-peer philosophy rather than the LES client/server model, which has introduced challenges in an altruistic environment.

Ready for production?

LOL, not even a little bit. At the last readme update, this was simply a proxy to Infura for all inbound requests, and doesn't validate any answers against state roots.

Trin will proxy at least some requests to Infura for quite a while, but the plan is to incrementally reduce the reliance on Infura, as more trin functionality becomes available.

How to use

Create an Infura account, getting a project ID. Check out the trin repository, then:

cd trin
TRIN_INFURA_PROJECT_ID="YoUr-Id-HeRe" cargo run

Connect over IPC

In a python shell:

>>> from web3 import Web3
>>> w3 = Web3(Web3.IPCProvider("/tmp/trin-jsonrpc.ipc"))
>>> w3.clientVersion
'trin 0.0.1-alpha'
>>> w3.eth.blockNumber
11870768

Connect over HTTP

First launch trin using HTTP as the json-rpc transport protocol:

TRIN_INFURA_PROJECT_ID="YoUr-Id-HeRe" cargo run -- --web3-transport http

Then, in a python shell:

>>> from web3 import Web3
>>> w3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545"))
>>> w3.clientVersion
'trin 0.0.1-alpha'
>>> w3.eth.blockNumber
11870768

The client version responds immediately, from the trin client. The block number is retrieved more slowly, by proxying to Infura.

To interact with trin at the lowest possible level, try netcat:

nc -U /tmp/trin-jsonrpc.ipc
{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}
{"jsonrpc":"2.0","id":83,"result":"0xb52258"}{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":84}
{"jsonrpc":"2.0","id":84,"result":"0xb52259"}{"jsonrpc":"2.0","id":85,"params":[],"method":"web3_clientVersion"}
{"jsonrpc":"2.0","id":"85","result":"trin 0.0.1-alpha"}^C

CLI Options

trin 0.0.1
carver
Run an eth portal client

USAGE:
    trin [OPTIONS]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --pool-size <pool_size>              max size of threadpool [default: 2]
        --web3-http-port <web3_http_port>    port to accept json-rpc http connections [default: 8545]
        --web3-ipc-path <web3_ipc_path>      path to json-rpc endpoint over IPC [default: /tmp/trin-jsonrpc.ipc]
        --web3-transport <web3_transport>    select transport protocol to serve json-rpc endpoint [default: ipc]
                                             [possible values: http, ipc]

Gotchas

  • There is a limit on concurrent connections given by the threadpool. At last doc update, that number was 2, but will surely change. If you leave connections open, then new connections will block.
  • Error handling is pretty close to non-existent.
  • This project may never be updated. If this repo is looking stale, you might try asking the Trinity team to find out what spiritual successor exists, if any.

trin's People

Contributors

carver avatar njgheorghita avatar pawanjay176 avatar samwilsn avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.