GithubHelp home page GithubHelp logo

jacobdenver007 / ethereum-receipt-proof-maker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leonli000/ethereum-receipt-proof-maker-leon

0.0 0.0 0.0 799 KB

A maker of merkle-proofs for transaction receipts in ethereum using rust.

Rust 96.98% Shell 3.02%

ethereum-receipt-proof-maker's Introduction

๐ŸŒฟ Merkle-Proofs for Transactions Receipts in Ethereum

ย 

A Maker of Merkle-Proofs for Transaction Receipts in Ethereum using Rust.

ย 


ย 

๐Ÿ‘‰ Usage:

> To generate a proof for a given transaction hash:

โ rusty-receipt-proof-maker <your-tx-hash-here>


rusty-receipt-proof-maker 0x5d761b001c4d69bf14c94b8e8a604d97e008a8a7dfb74a6459823b2178ffc033 -v`
12:02:21 [ INFO] โœ” CLI Args parsed successfully!
12:02:21 [ INFO] โœ” Verbose mode: true
12:02:21 [ INFO] โœ” Transaction hash: 0x5d76โ€ฆc033
12:02:21 [ INFO] โœ” Validating CLI args...
12:02:21 [ INFO] โœ” Initializing state from CLI args...
12:02:21 [ INFO] โœ” Getting RPC endpoint from environment variables...
12:02:21 [ INFO] โœ” Endpoint retrieved: http://localhost:8545/
12:02:21 [ INFO] โœ” Connecting to node...
12:02:21 [ INFO] โœ” Connection successful! Latest block number: 8560379
12:02:21 [ INFO] โœ” Getting block from transaction hash: 0x5d76โ€ฆc033
12:02:21 [ INFO] โœ” Getting all receipts from block...
12:02:24 [ INFO] โœ” Getting transaction index of hash: 0x5d76โ€ฆc033
12:02:24 [ INFO] โœ” Building merkle-patricia trie from receipts...
12:02:24 [ INFO] โœ” Pulling branch from trie...
12:02:24 [ INFO] โœ” Hex encoding proof from nodes in branch...
12:02:24 [ INFO] โœ” Hex Proof:

f90264f8b1a0dc1a1b7bc9f38fc6710af9abdf1da874fa708573431381908b8b6a25bd1f2b55a0701833ef4ede796d9c96b1ae7c66830b0126f106ea0bfe99864e679e8b0dfeafa00db067f1c8ee75d8a563038903eb5129ee1d73beeea9380ca58d1920c15fe84ba0a55d0852ba77dbcc2824337150c123ccde62699b0c6eaddf735c1b2638bb85ba80808080a04937e058ea19511f92f803c23f4e9a4eceaaf2246c86da0f1b2241316be8a34d8080808080808080f901ae30b901aaf901a701837ab31ab9010000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000002000000080000000000000000200000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000020000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000004000000000000010200000000000000000000000000000000000000000000000000000000000f89df89b94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f863a08c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925a0000000000000000000000000539efb706852838c51905d3d31966c296e034000a0000000000000000000000000a2881a90bf33f03e7a3f803765cd2ed5c8928dfba0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff


By default, the tool's full tracing logs for each run are output to a file in ./logs/<utc-timestamp>.log

> For usage notes, run the tool thusly:

โ rusty-receipt-proof-maker --help


โ Rusty Receipt Proof Maker โ

    Copyright Provable 2019
    Questions: [email protected]

โ Info โ

This tool generates a merkle receipt proof of the receipt pertaining to the given transaction hash.

***

Usage:  rusty-receipt-proof-maker [-h | --help]
        rusty-receipt-proof-maker <txhash> [-t | --trace]
        rusty-receipt-proof-maker <txhash> [-v | --verbose]

Options:

    -h, --help          โ Show this message.

    -v, --verbose       โ Enable verbose mode for additional output.

    -t, --trace         โ Enable tracing for debugging/bug reporting.

    <txhash>            โ A transaction hash of an Ethereum transaction
                        โž” Format: A 32-byte long, prefixed hex string.

โ Rusty Receipt Proof Maker โ

    Copyright Provable 2019
    Questions: [email protected]

โ Info โ

This tool generates a merkle receipt proof of the receipt pertaining to the given transaction hash.

***

Usage:  rusty-receipt-proof-maker [-h | --help]
        rusty-receipt-proof-maker <txhash> [-t | --trace]
        rusty-receipt-proof-maker <txhash> [-v | --verbose]

Options:

    -h, --help          โ Show this message.

    -v, --verbose       โ Enable verbose mode for additional output.

    -t, --trace         โ Enable tracing for debugging/bug reporting.

    <txhash>            โ A transaction hash of an Ethereum transaction
                        โž” Format: A 32-byte long, prefixed hex string.


ย 


ย 

๐Ÿ”ฉ Setup:

The tool requires access to a full ethereum node on whichever network you wish to generate receipt proofs for.

You can configure an endpoint for that node by creating a .env file in the root of the repo thusly:


# At path: ./rusty-receipt-proof-maker/.env

ENDPOINT="<your-endpoint-here>"

This allows you to use for example an Infura endpoint without risking exposing your API key. Another optional endpoint if you are not running your own node is Slock.It.

If you do not provide an endpoint, the tool will default to https://localhost:8545, and fail to run at all if it can't connect to a node at that location:

rusty-receipt-proof-maker -v 0x5d761b001c4d69bf14c94b8e8a604d97e008a8a7dfb74a6459823b2178ffc033`

โœ” Getting RPC endpoint from environment variables...
โœ” Endpoint retrieved: http://localhost:8545/
โœ” Connecting to node...
โœ˜ HTTP Reqwest Error!
โœ˜ http://localhost:8545/ timed out
โœ˜ Please check your node & port settings and retry.

ย 


ย 

๐Ÿ’‚โ€โ™‚๏ธ Tests:

To run the tests:

โ cargo +nightly test

Note: Some expensive tests are ignored by default. To run all test, including those ignored, add the --ignored flag.

โ˜ข๏ธ CAUTION: Some tests rely on access to a full MAINNET node existing at http://localhost:8545. If one can't be reached at that endpoint, many of the tests will fail.

ย 


ย 

โœ’๏ธ Notes

โ The current memory database usage is pure in that we clone the db and return the new, updated copy back to state. Efficiency sacrificed for immutability. Depending on performance of final tool (whose bottleneck is guaranteed to be the fetching of the potentially many receipts for the transactions in a block from the RPC endpoint) this will be changed.


ย 

๐Ÿ“‹ To-Do

  • Allow configurable endpoint.
  • Have flag to suppress logging.
  • Have timeout error on reqwests.
  • Have method to convert hex string of even/odd length to offset/non- nibbles.
  • Need a node rlp-decoder!
  • Remove unused fxns
  • Benchmark it and maybe don't clone the db per above note?
  • Spinners for when it's doing the bits that take a while...?
  • Factor out log level stuff into own module (from cli arg parser!)

ethereum-receipt-proof-maker's People

Contributors

gskapka avatar leonli000 avatar techcircus 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.