Skip to content

Client JSON-RPC Support (old) #982

@holgerd77

Description

@holgerd77
Member

Description

Implementation of the JSON-RPC interface as described in https://github.com/ethereum/wiki/wiki/JSON-RPC.

This encompasses a server implementation and the implementation of the various API calls.

Possible Implementation

It probably best to start with an early-on implementation of 2-3 exemplary API calls and then refine this for some time to work out a good internal structure to build upon and extend with the further calls.

There are various Javascript libraries out there touching the topic, not sure if any can be of help here or be integrated/used, this should be examined more closely.

UI

The RPC server should be constantly running and be available via some configured address and port.

Implement all JSON-RPC Endpoints

Update (2018-07-10): This has been adressed in ethereumjs/ethereumjs-client#30 by @yurenju, providing a very solid structure for implementation and testing. It is now possible to implement the single RPC endpoints (limited by the functionality already implemented in the core client code).

Checklist of endpoints to support, and which are supported in master or pull requests (taken from Py-EVM:

  • Support all the web_* methods
    • web3_clientVersion
    • web3_sha3

  • support all the net_* methods

  • support all the eth_* write methods
    • make list of methods

  • support all the eth_* read-only methods
    • eth_protocolVersion
    • eth_syncing
    • eth_coinbase
    • eth_mining
    • eth_hashrate
    • eth_gasPrice
    • eth_accounts
    • eth_blockNumber
    • eth_getBalance
    • eth_getStorageAt
    • eth_getTransactionCount
    • eth_getBlockTransactionCountByHash
    • eth_getBlockTransactionCountByNumber
    • eth_getUncleCountByBlockHash
    • eth_getUncleCountByBlockNumber block int
    • eth_getUncleCountByBlockNumber block string
    • eth_getCode
    • eth_call
    • eth_estimateGas
    • eth_getBlockByHash
    • eth_getBlockByNumber block int
    • eth_getBlockByNumber block string
    • eth_getTransactionByHash
    • eth_getTransactionByBlockHashAndIndex
    • eth_getTransactionByBlockNumberAndIndex
    • eth_getTransactionReceipt
    • eth_getUncleByBlockHashAndIndex
    • eth_getUncleByBlockNumberAndIndex block int
    • eth_getUncleByBlockNumberAndIndex block string
    • eth_getCompilers
    • eth_getLogs
    • eth_getWork

Note: On a first round I've just copied over all calls, this might be limited by functionality which eventually shall not be implemented in the client (mining related stuff e.g.).

Reference Implementations / Links

Activity

changed the title [-]JSON RPC interface support[/-] [+]JSON-RPC Server / interface support[/+] on May 29, 2018
changed the title [-]JSON-RPC Server / interface support[/-] [+]JSON-RPC Support[/+] on May 29, 2018
kikoncuo

kikoncuo commented on Jun 6, 2018

@kikoncuo

How can we approach this?

I'm lost, here is my general impression:
Create an express web server to accept the defined petitions
Execute the transactions with ethereumjs-vm
Use ethereumjs-accounts to manage accounts
Read .ldb files to get info about blocks

yurenju

yurenju commented on Jun 11, 2018

@yurenju
Contributor

some clue from ganache-core
https://github.com/trufflesuite/ganache-core/blob/develop/lib/server.js

it should be a good start to use node.js built-in web server since JSON-RPC only has a single endpoint. express is pretty powerful with route path config and static file host, but JSON-RPC doesn't need these features.

maybe we should go with built-in HTTP server?

yurenju

yurenju commented on Jun 12, 2018

@yurenju
Contributor

before go deep into this issue I want to have a rough WIP commit to see if we are on the same page, here we go:

yurenju/ethereumjs-client@6d917a5

This is WIP commit only to verify the idea. This commit refers py-evm implementation to have a this.modules to lookup what module we should handle an RPC request. With this commit you can use --rpc to enable RPC server:

$ node lib/index.js --rpc

and use curl to try this API:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1b4", true],"id":1}' http://127.0.0.1:8545

then you should get not implement yet on the console.

@holgerd77 any thought? Is it too rough? Let me how should I contribute on this issue :D

holgerd77

holgerd77 commented on Jun 12, 2018

@holgerd77
MemberAuthor

@yurenju cool that you are taking on this! From a first look I would say that this is going into the right direction. I am in Croatia on holidays at the moment, so can't look into this deeper, back on the weekend and will have a closer look next week.

If you want you can already submit this as a PR and we can continue from there or you can await a deeper review, as you like.

yurenju

yurenju commented on Jun 12, 2018

@yurenju
Contributor

Cool, if this is the right direction I would like to finish one API call like eth_getBlockByNumber with test and send a PR, thank you!

btw I also went Croatia last year, pretty cool country especially Rovinj & Dubrovnik. enjoy your vacation and no rush to reply here!!

yurenju

yurenju commented on Jun 13, 2018

@yurenju
Contributor
added a commit that references this issue on Jun 28, 2018
d42166e

11 remaining items

holgerd77

holgerd77 commented on Aug 17, 2018

@holgerd77
MemberAuthor

@benjamincburns Thanks for letting us know, we will definitely have a closer look here.

aunyks

aunyks commented on Nov 8, 2018

@aunyks
Contributor

I've opened a PR for web3_* at ethereumjs/ethereumjs-client#65.

aunyks

aunyks commented on Dec 5, 2018

@aunyks
Contributor

net_* are complete.

tomonari-t

tomonari-t commented on Jun 7, 2020

@tomonari-t
Contributor

I guess web_* and eth_getBlockByHash are complete

changed the title [-]JSON-RPC Support[/-] [+]Client JSON-RPC Support[/+] on Dec 4, 2020
holgerd77

holgerd77 commented on Feb 15, 2021

@holgerd77
MemberAuthor

@ryanio I've read in some internal chats - I think from someone from the geth team - that RPC methods would be valuable for debugging and comparing results when clients are joining the Yolo testnet. So if you are not sure what to work on next adding (some) RPC methods is always a good candidate I guess. Maybe you want to have a closer look what might be the more useful ones to have, not sure, haven't given this any thought yet (others can suggest as well of course).

ryanio

ryanio commented on Feb 16, 2021

@ryanio
Contributor

@holgerd77 sounds good, I really like the setup of the RPC modules code with the methods on the classes, it makes it natural to use in TypeScript. I'm seeing that it's currently callback based though, I can start with a PR updating it to async/promises then start adding some useful methods.

I started a tracking table in #1114 to visualize some more namespaces I found.

holgerd77

holgerd77 commented on Feb 16, 2021

@holgerd77
MemberAuthor

Ok, great! 😄

Will then close here in favor of #1114

changed the title [-]Client JSON-RPC Support[/-] [+]Client JSON-RPC Support (old)[/+] on Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ryanio@yurenju@fgimenez@benjamincburns@holgerd77

        Issue actions

          Client JSON-RPC Support (old) · Issue #982 · ethereumjs/ethereumjs-monorepo