Skip to content

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

License

Notifications You must be signed in to change notification settings

gskapka/ethereum-receipt-proof-maker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌿 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, first you'll need RPC access to an ETH node on the network your transaction exists on. Once you have that, set it as an environment variable and run the tool thusly::

❍ ENDPOINT=<ETH-mainnet-rpc-endpoint> rusty-receipt-proof-maker <your-tx-hash-here>


ENDPOINT=<redacted> 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: greg@oraclize.it

❍ 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 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!)

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published