Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Chain-selection from UI #4859

Merged
merged 22 commits into from
Mar 13, 2017
Merged

Chain-selection from UI #4859

merged 22 commits into from
Mar 13, 2017

Conversation

gavofyork
Copy link
Contributor

No description provided.

@gavofyork gavofyork added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. M4-core ⛓ Core client code / Rust. M6-rpcapi 📣 RPC API. M7-ui labels Mar 10, 2017
@gavofyork gavofyork added this to the 1.7 milestone Mar 10, 2017
@arkpar
Copy link
Collaborator

arkpar commented Mar 10, 2017

Looks good for now. However hypervisor approach will make it hard to implement changing settings such as chain, ports, etc. in parity-as-a library setting. We'd probably have to reimplement this so it does not require process shutdown eventually. This would require careful accounting for any shutdown leaks. AFAIK some of the services currently (IPC/RPC/stratum/whatever) don't cleanup 100% after themselves and may leave a thread hanging or some memory stuck in a pointer loop. This will require quite a bit of work and maybe automated tests that would check that there are no memory/thread/FD leaks.

@gavofyork gavofyork added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Mar 11, 2017
@gavofyork gavofyork changed the title First little bits for chain-selection. Chain-selection from UI Mar 11, 2017
@@ -94,5 +100,26 @@ describe('views/Settings/Parity', () => {
expect(instance.store.changeMode).to.have.been.calledWith('dark');
});
});
describe('chain selector', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Blank line before.

describe('@action', () => {
describe('setMode', () => {
it('sets the mode', () => {
store.setMode('offline');
expect(store.mode).to.equal('offline');
});
});
describe('setChain', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Blank line before.

@jacogr
Copy link
Contributor

jacogr commented Mar 12, 2017

2 tiny comments, otherwise code looks good.

[ci:skip]
[ci:skip]
}

/// Hypervisor should kill this client.
pub fn exit(&self) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is this called from? Why not just implement Drop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exit and restart are not yet called from anywhere, however, they seem like useful public api to have; i plan on implementing a UI endpoints for them to all the user to kill or restart parity easily.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how it belongs in Client, whose role is just to manage and provide blockchain data. Hypervisor stuff being at a higher level would make it a lot simpler to manage different kinds of clients, parity-as-a-library, non-hypervised instances, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will remove for the present PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i guess we might want to look into an alternative "hypervisor" IPC endpoint that could host such calls, however in the context of the present PR that would be too much extra baggage.

PostExecutionAction::Restart => PLEASE_RESTART_EXIT_CODE,
PostExecutionAction::Restart(spec_name_override) => {
if let Some(spec_name) = spec_name_override {
set_spec_name_override(spec_name);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about all other CLI options? Are they not preserved?

Copy link
Contributor Author

@gavofyork gavofyork Mar 12, 2017

Choose a reason for hiding this comment

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

yes, but that happens as part of the standard hypervisor process. this is specifically handling the instance where the user has altered the chain spec via the UI.

@@ -208,6 +208,22 @@ fn latest_exe_path() -> Option<PathBuf> {
.and_then(|mut f| { let mut exe = String::new(); f.read_to_string(&mut exe).ok().map(|_| updates_path(&exe)) })
}

fn set_spec_name_override(spec_name: String) {
if let Err(e) = File::create(updates_path("spec_name_overide"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is there a need for a file at all? Can't the hypervisor just pass CLI params to a new process?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not introduce --chain=auto as default setting and just update user_defaults like we do with pruning, tracing and fat_db?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is there a need for a file at all? Can't the hypervisor just pass CLI params to a new process?

two reasons:

  1. getting data out a child process back to the parent cleanly is non-trivial. i used a return-code thus far but it's no good for information-rich content. i guess we could use std-out but then it wouldn't work properly in all circumstances.

  2. this method works well for existing auto-update installations; using the hypervisor to relay information (even if it were easy) would mean everyone manually re-installing before this feature worked, since the hypervisor process is always the most recent manually installed executable.

Why not introduce --chain=auto as default setting and just update user_defaults like we do with pruning, tracing and fat_db?

(I actually implemented it this way originally.) user_defaults is per-chain, which obv. won't work for the setting of which chain to use. we could use another non-per-chain user-defaults, but then that's a lot of extra baggage for what is really just temporary signalling.

@arkpar arkpar added A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. and removed A0-pleasereview 🤓 Pull request needs code review. labels Mar 12, 2017
@gavofyork gavofyork added A0-pleasereview 🤓 Pull request needs code review. and removed A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. labels Mar 12, 2017
@arkpar arkpar added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Mar 13, 2017
@gavofyork gavofyork merged commit 3041c95 into master Mar 13, 2017
@gavofyork gavofyork deleted the ui-chain-select branch March 13, 2017 11:10
@ngotchac ngotchac mentioned this pull request Mar 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust. M6-rpcapi 📣 RPC API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants