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

Public node: perf and fixes #5390

Merged
merged 2 commits into from
Apr 5, 2017
Merged

Public node: perf and fixes #5390

merged 2 commits into from
Apr 5, 2017

Conversation

maciejhirsz
Copy link
Contributor

  • Introduced a worker pool for webworkers, which speeds up re-generating of preview avatars (apparently each worker has to JIT the js on it's own, over and over again).
  • All keythereum related stuff is now done in workers as well, so the UI never hangs.
  • Regenerating the avatars on the new account modal now shows a spinner.
  • Restoring accounts from private keys, testing passwords and changing passwords now works as intended.

@maciejhirsz maciejhirsz added A0-pleasereview 🤓 Pull request needs code review. M7-ui labels Apr 3, 2017
@maciejhirsz maciejhirsz requested a review from jacogr April 3, 2017 16:53

const account = new Account(persist, { keyObject });
static fromPrivateKey (persist, key, password) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if you tested this 100%, if not there is a private key we use in tests on the Rust side inside tests (with a known account). If already done, ignore :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All the actual logic for this is in Keythereum, and the main issue here is that the tests take a while and can timeout in CI :|.


this._store.push(account);
this.lastAddress = account.address;
return Account.fromPrivateKey(this.persist, privateKey, password)
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nitpick, would prefer

return Account
  .fromPrivateKey(...)
  .then(...)

Just aligns with what we have in the rest of the codebase.

return false;
}

const account = this._store[index];
return account.isValidPassword(password)
Copy link
Contributor

@jacogr jacogr Apr 4, 2017

Choose a reason for hiding this comment

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

Same small alignment comment as above.

// Local accounts should never be used outside of the browser
export let keythereum = null;
export function createKeyObject (key, password) {
return workerPool.getWorker().action('createKeyObject', { key, password })
Copy link
Contributor

Choose a reason for hiding this comment

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

As per above, prefer

return ...getWorker()
  .action(...)
  .then(...)

(Next function has it that way, just align)

}
}
};

function bytesToHex (bytes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not 100% sure why this is "duplicated", i.e. not used from /api/util/format? (I looked at this the previous round as well, could see a slight difference, but non-duplication is obviously preferred)

register('parity_changePassword', ([address, oldPassword, newPassword]) => {
const account = accounts.get(address);

return account.decryptPrivateKey(oldPassword)
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nitpick as above.

@jacogr
Copy link
Contributor

jacogr commented Apr 4, 2017

Generally looks good, one testing comment (probably already taken care of), some small style grumbles, just one function duplication where we can re-use. No major grumbles.

Generally though, think we should try and invest in tests for the middleware at some time sooner rather than later, just ensuring that what we do is correct. (And that the future holds to that promise)

@jacogr jacogr added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Apr 4, 2017
expect(Object.keys(instance.state.accounts).length).to.equal(7);
it('resets the accounts', () => {
expect(instance.state.accounts).to.be.null;
// expect(Object.keys(instance.state.accounts).length).to.equal(7);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it still needed?

@maciejhirsz maciejhirsz added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Apr 4, 2017
Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Fixes looks good, as Jaco mentioned tests would be nice soonish in next PRs.

@tomusdrw tomusdrw added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Apr 5, 2017
@maciejhirsz maciejhirsz merged commit 237bac4 into master Apr 5, 2017
@maciejhirsz maciejhirsz deleted the mh-publicnode-perf branch April 5, 2017 08:43
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants