New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON-RPC server #178

Closed
pipermerriam opened this Issue Dec 1, 2017 · 6 comments

Comments

Projects
None yet
2 participants
@pipermerriam
Member

pipermerriam commented Dec 1, 2017

Looking for the list of supported RPC endpoints?

See the full checklist here: #835

Original Issue

We need to implement the basic API for JSON-RPC server. A simplistic start can be found here: https://github.com/ethereum/py-evm/tree/master/evm/rpc

Lets flesh this out further to something more complete. For now lets keep it as something that must be run as python evm/rpc/server.py ....

I suggest sticking to the read-only apis for now.


Compiled to-do list:

(Checked off at the time of merge)

  • 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
  • serve over socket
  • make score available on block object, so that a returned block dict can be formatted without a chain reference ?

To save for another PR:

  • server over HTTP
@carver

This comment has been minimized.

Show comment
Hide comment
@carver

carver Dec 1, 2017

Contributor

Reasonable approach: only serve json-rpc over sockets, plus an HTTP proxy like: https://github.com/chfast/json-rpc-proxy/blob/master/jsonrpcproxy.py

Contributor

carver commented Dec 1, 2017

Reasonable approach: only serve json-rpc over sockets, plus an HTTP proxy like: https://github.com/chfast/json-rpc-proxy/blob/master/jsonrpcproxy.py

@pipermerriam

This comment has been minimized.

Show comment
Hide comment
@pipermerriam

pipermerriam Dec 1, 2017

Member

Yeah, I'd only implement one of the IPC/HTTP API with preference towards socket based on the thing you linked and the conversation from all-core-devs.

Member

pipermerriam commented Dec 1, 2017

Yeah, I'd only implement one of the IPC/HTTP API with preference towards socket based on the thing you linked and the conversation from all-core-devs.

@pipermerriam

This comment has been minimized.

Show comment
Hide comment
@pipermerriam

pipermerriam Dec 1, 2017

Member

More notes to self. This was said somewhere in our conversations. cc @chfast Pulling the Manager layer out of web3 might make sense here so that it can be use din the proxy library. Reasoning is that it would also allow for use of the middleware API in the proxy which seems like a really nice feature, allowing many degrees of freedom in what the proxy can actually do.

Member

pipermerriam commented Dec 1, 2017

More notes to self. This was said somewhere in our conversations. cc @chfast Pulling the Manager layer out of web3 might make sense here so that it can be use din the proxy library. Reasoning is that it would also allow for use of the middleware API in the proxy which seems like a really nice feature, allowing many degrees of freedom in what the proxy can actually do.

@carver

This comment has been minimized.

Show comment
Hide comment
@carver

carver Dec 1, 2017

Contributor

Pulling the Manager layer out of web3 might make sense here so that it can be use din the proxy library.

At the very least, pulling IPCProvider out of web3.py would be straightforward, but I agree that it's worth exploring what it would take to extract all of Manager (and with it, a middleware lib).

I'm starting to look at how to test an RPC server, and here's my plan so far:

  1. Generate a short test chain with MainnetTesterChain, with known values for various items, like block hashes, transaction hashes, etc.
  2. Store the chain.db and known values in /tests (as well as a script for generating them)
  3. In RPC tests, load the chain.db and request values from it using standard JSON-RPC calls
  4. Assert that the retrieved values match the known values from step 2
Contributor

carver commented Dec 1, 2017

Pulling the Manager layer out of web3 might make sense here so that it can be use din the proxy library.

At the very least, pulling IPCProvider out of web3.py would be straightforward, but I agree that it's worth exploring what it would take to extract all of Manager (and with it, a middleware lib).

I'm starting to look at how to test an RPC server, and here's my plan so far:

  1. Generate a short test chain with MainnetTesterChain, with known values for various items, like block hashes, transaction hashes, etc.
  2. Store the chain.db and known values in /tests (as well as a script for generating them)
  3. In RPC tests, load the chain.db and request values from it using standard JSON-RPC calls
  4. Assert that the retrieved values match the known values from step 2

@carver carver referenced this issue Dec 2, 2017

Merged

Basic transport-agnostic RPC server #183

14 of 38 tasks complete
@pipermerriam

This comment has been minimized.

Show comment
Hide comment
@pipermerriam

pipermerriam Dec 6, 2017

Member

Future TODO: make gas price strategy for eth_gasPrice pluggable and implement the Eth Gas Station strategy: ethereum/web3.py#496

Member

pipermerriam commented Dec 6, 2017

Future TODO: make gas price strategy for eth_gasPrice pluggable and implement the Eth Gas Station strategy: ethereum/web3.py#496

@pipermerriam pipermerriam added this to the MVP-public-alpha milestone Dec 13, 2017

@pipermerriam

This comment has been minimized.

Show comment
Hide comment
@pipermerriam

pipermerriam Dec 16, 2017

Member

Quick information drop about eth_estimateGas.

This may be as simple as returning computation.gas_meter.start_gas - computation.gas_meter.gas_remaining. However, if memory serves, I think it's more complicated that that.

The way that I recall go-ethereum doing this is to execute the transaction with some very large upper bound of gas like 50,000,000.

  • if it errors out: return an error over RPC
  • if it passes, proceed into a binary search, re-running the transaction at each gas value until you find the spot where it succeeds/fails and use the success value.

I'll re-iterate that the binary search approach may not be necessary based on how we do gas consumption tracking. Let's see.

Member

pipermerriam commented Dec 16, 2017

Quick information drop about eth_estimateGas.

This may be as simple as returning computation.gas_meter.start_gas - computation.gas_meter.gas_remaining. However, if memory serves, I think it's more complicated that that.

The way that I recall go-ethereum doing this is to execute the transaction with some very large upper bound of gas like 50,000,000.

  • if it errors out: return an error over RPC
  • if it passes, proceed into a binary search, re-running the transaction at each gas value until you find the spot where it succeeds/fails and use the success value.

I'll re-iterate that the binary search approach may not be necessary based on how we do gas consumption tracking. Let's see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment