-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
as a minor point on naming, best to stick to one of "sstore", "secstore" and "secretstore" throughout the codebase. i like "secretstore". different IPC module, even if it's in the same process for now, is nice because it forces clear interfaces. |
@gavofyork thanks, will update PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, although I'm a bit concerned with the number of independent servers we're building into Parity:
- IPFS
- Secret Store
- Dapps
- UI
- RPC
Do we really need separate ports for all these?
If possible I would be in favour of integrating some stuff or at least abstracting server implementations to make future migrations easier.
Currently we use different version of hyper (sync/async) and we have a lot of duplicated code (and we're gonna have more) - spinning up server, parsing URLs, parsing headers, adding security headers etc.
"ethcore-util 1.6.0", | ||
"ethcrypto 0.1.0", | ||
"ethkey 0.2.0", | ||
"hyper 0.9.14 (registry+https://github.com/rust-lang/crates.io-index)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hyper is a bit heavy and slow, have you considered our async version or for instance tokio-minihttp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not actually :( By 'our async version' do you mean https://github.com/ethcore/hyper ? I'll take a look into it. tokio-minihttp sounds very good, as it has 'mini' in its name :) I'll check it out - thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed to use tokio-minihttp
with @tomusdrw but left it for another PR, as now it doesn't have a way to be closed programatically. so first fix tokio-minihttp
, then switch to it
Cargo.toml
Outdated
@@ -81,6 +82,7 @@ evm-debug = ["ethcore/evm-debug"] | |||
evm-debug-tests = ["ethcore/evm-debug-tests"] | |||
slow-blocks = ["ethcore/slow-blocks"] | |||
final = ["ethcore-util/final"] | |||
sstore = ["ethcore-secstore"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be best to enable it by default (or build it on the CI), otherwise it's hard to detect any possible breaking changes causing compilation errors in that crate, since people don't alter the features and builds are not including this as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it will be better to enable it later? When this functionality will be finished && polished. Now it has only basic features && it is not usable at all. I don't mind fixing any compilation issues by myself until it is ready for production, if you're worried about it.
|
||
impl<T> HttpHandler for KeyServerHttpHandler<T> where T: KeyServer + 'static { | ||
fn handle(&self, req: HttpRequest, mut res: HttpResponse) { | ||
if req.method != HttpMethod::Get { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to limit the requests depending on the planned usage:
- If we're not intending to use this server from browser context we can deny requests with
Origin
header. - If we do intend to use it from the browser we need to add CORS support, cause currently the website will be able to perform a request, but won't be able to read the response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also do not yet fully understand final shape of this functionality - who will be responsible for IPFS/Swarm integration. Is it key server, or some other component. If that's a key server, then most probably it will have its own UI. Or maybe it is user himself && it is his duty to save document to IPFS and then upload key here (that's a strange decision, but it can be so). I think @gavofyork could help us here. Or I can just add TODO about your comment here && update it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@svyatonik Probably we could have a trait "DocumentStore" with a single function "fn fetch(H256) -> BoxFuture<Option>`, and this could be trivially implemented for any swarm/ipfs/disk/memory store. This server should be concerned solely with the logic above that.
as an aside, couldn't this be a separate executable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rphmeier Yes - we can go that way, but I'm not sure that this would be a part of this particular server/service :) Maybe user/external app will access this keyserver just for storing/retrieving keys && will upload/download files to this DocumentStore
itself. Another option that this keyserver would be extended to something bigger && will have this functionality itself - then yes, I'll add something like DocumentStore
here, thanks :)
It will need access to the blockchain data, so it can't be totally separate application. But it is intended to be separate executable in future (after IPC will be enabled) - yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could actually use rust-web3
and existing IPC transport :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I like this idea :) So @gavofyork maybe create a completely separate executable for key-server and talk to Parity using RPC calls (it is enough for calling contract methods)? I think that's a great idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@svyatonik Yes, the eth_call
RPC is suitable for calling contracts. rust-web3
also has ethabi
integration for easy usage of contracts, abstracting over any direct eth_call
nastiness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left as is, until @gavofyork approves
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IPC transport layer was designed to be a very efficient RPC interface, supporting efficient underlying transport paradigms.
this would allow adding new, potentially non-ethereum, functionality without compromising the integrity of the existing codebase. whether the functionality is added as a separately spawned instance of parity
(as with sync and stratum) or a completely separate executable, isn't so important.
unless there's a particularly good reason to go with the eminently inefficient, inconcise, prehistoric and not-all-that-well designed JSONRPC, i would prefer to stick to using (and improving) our trait-based IPC module architecture.
i would lightly favour the same executable for now since it will make system deployment easier; that said, if you're desperate to have it in a different executable (rather than just a different crate/module) i'm not going to stand in the way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I don't feel myself confident enough to make such decisions. So let it be an IPC module (in future).
parity/sstore.rs
Outdated
|
||
/// Noop key server implementation | ||
pub struct KeyServer { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
braced empty struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
parity/sstore.rs
Outdated
impl KeyServer { | ||
/// Create new noop key server | ||
pub fn new(_conf: Configuration, _deps: Dependencies) -> Result<Self, String> { | ||
Ok(KeyServer {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok(KeyServer)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tried to make |
For this one I'd also suggest disabling it by default |
@svyatonik will leave the disabled-by-default for a separate PR... |
@gavofyork The feature is disabled by default from the beginning. |
As proposed by @gavofyork :
Unfortunately, you'll be unable to test it, as there's no currently way to fill database with some contents. But if you fill it, it will work like that:
PR outline: