Skip to content
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

Implemented eth namespace apis (almost returning dummy or fixed values) #1123

Merged
merged 1 commit into from
Feb 2, 2022

Conversation

aeharvlee
Copy link
Contributor

@aeharvlee aeharvlee commented Jan 23, 2022

Proposed changes

This PR Implemented eth namespace apis.

  • Added publicGovernanceAPI which is used by eth_etherbase, eth_coinbase. Those apis return the address of operating node.
  • Other apis returns dummy or fixed values.
Api Ethereum Source Code
eth_etherbase Etherbase
eth_coinbase Coinbase
eth_hashrate Hashrate
eth_mining Mining
eth_getWork Mining
eth_submitWork SubmitWork
eth_submitHashrate SubmitHashrate
eth_getHashrate GetHashrate
eth_getUncleByBlockNumberAndIndex GetUncleByBlockNumberAndIndex
eth_getUncleByBlockHashAndIndex GetUncleByBlockHashAndIndex
eth_getUncleCountByBlockNumber GetUncleCountByBlockNumber
eth_getUncleCountByBlockHash GetUncleCountByBlockHash

Related Confluence: How Ethereum APIs are supported in Klaytn

How to test this PR

First, please clone my origin repo.

1. Run added tests in this PR.

  • Run go test -run "TestEthereumAPI_*" -v ./... -count=1

2. Build ken and test with it.

1. Build ken with source codes related with this PR.

  • Run make ken

2. Run ken

  • In my case, I tested with CN 1 - PN 1 - EN 1 in my local.
  • Please note that you should enable eth namepsace to RPC_API and WS_API in kend.conf

Test Logs

Click to expand
➜  corecell curl http://localhost:8551 \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_etherbase","params":[],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x9d776ff5745fd5b0df455f3259008ff3cd0eba95"}
➜  corecell curl http://localhost:8551 \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_coinbase","params":[],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x9d776ff5745fd5b0df455f3259008ff3cd0eba95"}
➜  corecell curl http://localhost:8551 \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_hashrate","params":[],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x0"}
➜  corecell curl http://localhost:8551 \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_mining","params":[],"id":1}'
{"jsonrpc":"2.0","id":1,"result":false}
➜  corecell curl http://localhost:8551 \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getWork","params":[],"id":1}'
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"no mining work available yet"}}
➜  corecell curl localhost:8551 -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"eth_submitWork", "params":["0x0000000000000001", "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"],"id":73}'
{"jsonrpc":"2.0","id":73,"result":false}
➜  corecell curl http://localhost:8551 \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getHashrate","params":[],"id":1}'
{"jsonrpc":"2.0","id":1,"result":0}
➜  corecell curl http://localhost:8551 \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getUncleCountByBlockNumber","params":["0x1"],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x0"}
➜  corecell curl http://localhost:8551 \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getUncleCountByBlockHash","params":["0xa4e7dcaedd5e5acb830180c2f05c5e95fb66908021623719c284dbf4c4262b40"],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x0"}

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Two kinds of apis in this commit
* Apis returning fixed or dummy value.
* Apis returning node addresses.
@aeharvlee aeharvlee self-assigned this Jan 23, 2022
@aeharvlee aeharvlee added this to the v1.8.0 milestone Jan 23, 2022
@aeharvlee aeharvlee added this to In progress in Interface via automation Jan 23, 2022
Copy link
Contributor

@hqjang-pepper hqjang-pepper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Works same with Confluence doc spec.

Interface automation moved this from In progress to Review in progress Jan 28, 2022
@aeharvlee aeharvlee merged commit 544a8bb into klaytn:dev Feb 2, 2022
Interface automation moved this from Review in progress to Done Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants