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

rpc: new RPC implementation with pub/sub support #2035

Merged
merged 1 commit into from
Dec 14, 2015

Conversation

bas-vk
Copy link
Member

@bas-vk bas-vk commented Dec 3, 2015

This PR includes a new RPC implementation that is build on top of the new node architecture in the node. It adds support for pub/sub.

The new implementation lacks support for the admin and debug modules which the current interface provides since there is a debate how we can accommodate these in the new architecture.

Therefore a new flag --ipcexp flag is added. This will start the new RPC implementation. By default the old IPC interface is started.

closes #1935

@robotally
Copy link

Vote Count Reviewers
👍 2 @fjl @karalabe
👎 0

Updated: Mon Dec 14 16:28:16 UTC 2015

@codecov-io
Copy link

Current coverage is 44.21%

Merging #2035 into develop will decrease coverage by -2.80% as of 8939d7a

Powered by Codecov. Updated on successful CI builds.

@karalabe
Copy link
Member

karalabe commented Dec 4, 2015

A few things I've noticed while adding the admin stuff:

  • I wouldn't add a special type for rpc.Apis (aliasing []*rpc.Api). The second version is cleaner to understand and the only reason some of the core types have the plurals aliased is because they use custom RLP serialization rules. However I would avoid aliasing as it's just harder to understand looking at the code what it exactly is.
  • Instead of []*rpc.Api, I would use plain []rpc.Api to stay consistent with the []p2p.Protocol design. An rpc.Api either way contains very little data and is passed around only during construction, so it doesn't cost anything significant. It also helps when printing it as you can just display its contents and not have Go resolve it into a pointer.
  • Naming wise in the eth, whisper, etc package I don't think it's the best idea to name the file containing the API methods eth_rpc.go or whisper_rpc.go. If there's only a single file, then imho it's cleaner to simply name it rpc.go, or I would even consider api.go instead of RPC, as it actually contains the API that will or will not be exposed over RPC.

@karalabe
Copy link
Member

karalabe commented Dec 4, 2015

Also I think naming these API handlers as XyzService isn't the best idea, because we already have a Service concept in the node (e.g. Whisper, Ethereum, Swarm, etc). I would recommend naming the API method containers as <Name><Public/Private>Api. e.g: EthereumPublicApi, EthereumPrivateApi, BlockchainAdminPrivateApi. This way it would be much cleaner what they contain and what their access scope is meant to be opposed to simply BlockChainService which eou cannot really tie to API/RPC, neither say whether it will be public/private.

@karalabe
Copy link
Member

karalabe commented Dec 4, 2015

Just so that it's not lost, here's my PR against this PR bas-vk#1

@bas-vk
Copy link
Member Author

bas-vk commented Dec 7, 2015

@karalabe, made the rename changes as proposed.

@zelig
Copy link
Contributor

zelig commented Dec 10, 2015

I second Peter that Service is better avoided as a field name in rpc.Api
Also rpc.Api#Service is interface{}, but in fact all apis implement a Version method. If this is explicit and the api needs to implement Version() then we do not need Version field on the rpc.Api struct. Alternatively a Version rpc method should automatically insert based on the field Version of the rpc.Api.
However, did we not decide that only services (node.Service) will be versioned, their api just follows.
So we can eliminate both api internal Version methods as well as Version field in the rpc.Api struct and let the node start insert the version method.
What do you think?

@zelig
Copy link
Contributor

zelig commented Dec 10, 2015

As for the api naming. I agree that its best to just call it rpc.go within each package.
As for the types, I would not be so rigid as peter suggests, for instance in swarm there will be at least 2 different private api packages, which will be (i think correctly) named based on the funcitonality they provide: one for network test and one for swarm API with file-system access

@zelig
Copy link
Contributor

zelig commented Dec 10, 2015

Also, if we all get pedantic about naming of services, protocols then I gotta say, the web3.js selectors aka rpc.Api#Namespace should also be: ethereum, swarm and whisper, not eth, shh, bzz.
But I guess we might be stuck with those ...


web3 := utils.NewPublicWeb3Api(stack)
server.RegisterName("web3", web3)
net := utils.NewPublicNetApi(stack.Server(), ethereum.NetVersion())
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the only use of ethereum here. NetVersion should clearly not be there.

@zelig zelig mentioned this pull request Dec 11, 2015
@fjl
Copy link
Contributor

fjl commented Dec 13, 2015

Found during testing: JSON-RPC notifications sent by the client generate a response with id 0. Please fix.

@fjl
Copy link
Contributor

fjl commented Dec 13, 2015

When I was requesting to rename "Api" to "API", I probably should've said that this also applies to things like "PublicEthereumApi".
Please do the renaming for those types, too.

@fjl
Copy link
Contributor

fjl commented Dec 13, 2015

Can the core APIs be moved out of package core please?
We really want to avoid adding dependencies core->rpc and core->accounts.
The right place (for now) is package eth, because it is (still) the main entry point around Ethereum consensus.

I tried moving it to package eth and a bunch of work is required to make it work (can't access BlockChain.chainDb, etc.).
Maybe we can merge the PR without the move now and do it afterwards.

Another issue with the APIs in package core is that even though they are supposed to be "public",
they contain methods that do signing. Moving tx signing/submission (and signing in general) to a separate
API can also be done in a follow up PR.

}
}

responses[i] = codec.CreateResponse(req.id, reply[0].Interface())
Copy link
Contributor

Choose a reason for hiding this comment

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

Please find a way to share this code (inside the for loop) with exec.

"logIndex": rpc.NewHexNumber(r.Index),
"blockHash": r.BlockHash,
"transactionHash": r.TxHash,
"transactionIndex": rpc.NewHexNumber(r.TxIndex),
Copy link
Contributor

Choose a reason for hiding this comment

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

rpc.NewHexNumber(...) here should be replaced by fmt.Sprintf("%x", ...) to avoid the dependency on rpc.

@bas-vk bas-vk force-pushed the rcp-v2-rebase branch 2 times, most recently from d1e2312 to eae8146 Compare December 14, 2015 15:33
@fjl
Copy link
Contributor

fjl commented Dec 14, 2015

👍

@karalabe
Copy link
Member

I've skimmed through the PR before building my own admin/debug ports on top of it and it seemed solid. Apart from a few issues I've mentioned above and were already sorted out; and a few cleaning refactoring that will either way get done as we're progressing with the RPC updates, it seems ok for me. 👍

fjl added a commit that referenced this pull request Dec 14, 2015
rpc: new RPC implementation with pub/sub support
@fjl fjl merged commit fa187a3 into ethereum:develop Dec 14, 2015
@fjl fjl removed the review label Dec 14, 2015
@zelig zelig mentioned this pull request Dec 14, 2015
5 tasks
zelig referenced this pull request in ethersphere/swarm Dec 15, 2015
* integrate #2035 via latest develop. fixes #2041
* refactor apis
* fix tests for windows, add simple download test
* separate dns api and chequebook api
* http proxy api in separate subpackage
* remove legacy rpc code partially, adding only legacy to make v2 work
* TODO: add dns tests see #2048
* TODO: further refactor  due to #2040
zelig added a commit that referenced this pull request Dec 18, 2015
* integrate #2035 via latest develop. fixes #2041
* refactor apis
* fix tests for windows, add simple download test
* separate dns api and chequebook api
* http proxy api in separate subpackage
* remove legacy rpc code partially, adding only legacy to make v2 work
* TODO: add dns tests see #2048
* TODO: further refactor  due to #2040
nagydani pushed a commit that referenced this pull request Jan 30, 2016
* integrate #2035 via latest develop. fixes #2041
* refactor apis
* fix tests for windows, add simple download test
* separate dns api and chequebook api
* http proxy api in separate subpackage
* remove legacy rpc code partially, adding only legacy to make v2 work
* TODO: add dns tests see #2048
* TODO: further refactor  due to #2040
zelig added a commit that referenced this pull request Feb 1, 2016
* integrate #2035 via latest develop. fixes #2041
* refactor apis
* fix tests for windows, add simple download test
* separate dns api and chequebook api
* http proxy api in separate subpackage
* remove legacy rpc code partially, adding only legacy to make v2 work
* TODO: add dns tests see #2048
* TODO: further refactor  due to #2040
@obscuren obscuren modified the milestone: 1.4.0 Feb 6, 2016
zelig referenced this pull request in ethersphere/swarm May 8, 2016
* integrate #2035 via latest develop. fixes #2041
* refactor apis
* fix tests for windows, add simple download test
* separate dns api and chequebook api
* http proxy api in separate subpackage
* remove legacy rpc code partially, adding only legacy to make v2 work
* TODO: add dns tests see #2048
* TODO: further refactor  due to #2040
sduchesneau pushed a commit to streamingfast/go-ethereum that referenced this pull request Dec 19, 2023
all: pull snap sync PRs from upstream v1.13.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants