Coder Social home page Coder Social logo

lightclients / patronum Goto Github PK

View Code? Open in Web Editor NEW
19.0 6.0 5.0 1.24 MB

Patronum: Ethereum RPC proxy that verifies RPC responses against given trusted block hashes

TypeScript 99.58% Shell 0.10% JavaScript 0.32%
blockchain ethereum lightclient rpc rpc-proxy

patronum's Introduction

Patronum

Ethereum RPC proxy that verifies RPC responses against given trusted block hashes. Currently, most of the DAPPs and Wallets interact with Ethereum over RPC. Patronum can be used as a building block to build light clients that retrofit into the existing Ethereum infrastructure. This library mainly takes advantage of the eth_getProof RPC to perform merkle inclusion proofs for RPC call verification.

Patronus

Start RPC Provider

import { VerifyingProvider, startServer } from 'patronum';

const provider = new VerifyingProvider(
  trustlessRPCURL,
  trustedBlockNumber,
  trustedBlockHash,
);
await startServer(provider, PORT);

Use VerifyingProvider

import { VerifyingProvider } from 'patronum';

const provider = new VerifyingProvider(
  trustlessRPCURL,
  trustedBlockNumber,
  trustedBlockHash,
);

console.log(await provider.getBalance(address, blockTag));

console.log(await provider.call(tx));

The RPC URL provided to VerifyingProvider should support eth_getProof and eth_createAccessList. Infura doesn't support eth_createAccessList.

patronum's People

Contributors

k4m4 avatar pkakelas avatar shresthagrawal avatar tzinas avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

patronum's Issues

Block verification/building is broken

After the latest hardfork, headerDataFromWeb3Response seems to build a wrong header structure.

All uses of header.hash() get compared wrongly as a result. All other security checks still seem to run fine though.

This is a somewhat high priority to fix given the nature. I have, in the mean time, disabled block hash verification.

Request: Support eth_getLogs

I am requesting to add support for eth_getLogs and potentially the other log related methods.

At minimum I would like a guide on how this should be implemented as a method in the VerifyingProvider class.

Thanks!

Make VerifiedProvider an EthersProvider

EthersJs has a big suite of libraries to interact with Ethereum. If we can extend the VerifiedProvider to implement the AbstractProvider interface provided by the EthersJs then we can use the VerifiedProvider with all the existing EthersJs toolchain.

Make default block parameter optional

Getting error "missing value for required argument 1" for methods eth_getTransactionCount, eth_getBalance, eth_getCode, eth_call and eth_estimateGas.

The default block parameter is usually skipped (and defaults to 'latest') even though it is not documented as optional.

Fix MaxListenersExceededWarning

(node:64331) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 hardforkChanged listeners added to [Common]. Use emitter.setMaxListeners() to increase limit

Allow for passing multiple RPC URLs

Currently, the Verifying provider is booted up with just one provider. This provider can be malicious in such a case the current system simply throws an error and fails.

Allow for passing a set of RPC URLs ordered by the most trusted one first. Gracefully try other provider URLs sequentially

Make Verifying Provider dynamic

Currently, the Verifying Provider accepts the latest Blockhash and Blocknumber as a constructor param. But as the blockchain has new blocks, the provider should be updated to the latest BlockHash and BlockNumber

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.