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

Fix travis build #14

Merged
merged 3 commits into from
Sep 28, 2017
Merged

Fix travis build #14

merged 3 commits into from
Sep 28, 2017

Conversation

holgerd77
Copy link
Member

This fixes the travis build by updating the Node versions tested and use non-deprecated (safe-buffer) initialization.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.7%) to 37.838% when pulling cf74009 on fix-travis-build into 88c821f on master.

index.js Outdated

var Account = module.exports = function (data) {
// Define Properties
var fields = [{
name: 'nonce',
default: new Buffer([])
default: Buffer.from([])
Copy link

Choose a reason for hiding this comment

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

Buffer.allocUnsafe(0) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks.

Sorry, I'm not really aware of the implications, can someone explain? Is this only for nonce?

Copy link
Member

Choose a reason for hiding this comment

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

Buffer.from([]) returns an empty buffer. Buffer.allocUnsafe(0) does the same but is faster.

Copy link

Choose a reason for hiding this comment

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

My intentions mostly was that alloc*(0) is more explicit than .from([])

Copy link
Member Author

Choose a reason for hiding this comment

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

So maybe we should avoid using the unsafe version all together in ethereumjs context, for not risking to leak a private key or stuff like this?@axic ?

Just tested both alloc versions on the console, there was not some noticeable lag on the output, feels like it doesn't really make a difference - at least for one-time operations.

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced this with alloc, actually feel better with this.

Copy link

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

alloc(0) will be the same since there is 0 bytes to clean after allocation.

Copy link
Member Author

Choose a reason for hiding this comment

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

@fanatid @axic Ok, to sum this up: I've learned a lot and we can leave alloc(0) since it doesn't make a difference both on the security and the speed side? :-)

Copy link
Member

Choose a reason for hiding this comment

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

I don't mind which is used, just make sure to update -util and -vm accordingly. -vm only uses alloc, -util uses allocUnsafe also in a combination of allocUnsafe+fill (which should really be just alloc).

@fanatid
Copy link

fanatid commented Sep 28, 2017

utACK

@axic
Copy link
Member

axic commented Sep 28, 2017

Looks good apart from @fanatid's comment.

@holgerd77
Copy link
Member Author

Done (for all 4 occurrences).

Are there any occasions where to consider the unsafe part of it?

@fanatid
Copy link

fanatid commented Sep 28, 2017

Are there any occasions where to consider the unsafe part of it?

Yes. unsafe is faster, but allow data to be leaked to another unsafe. https://nodejs.org/api/buffer.html#buffer_what_makes_buffer_allocunsafe_and_buffer_allocunsafeslow_unsafe

@coveralls
Copy link

Coverage Status

Coverage increased (+1.7%) to 37.838% when pulling 10f5bfb on fix-travis-build into 88c821f on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.7%) to 37.838% when pulling 84991a1 on fix-travis-build into 88c821f on master.

@holgerd77 holgerd77 merged commit 369b0c8 into master Sep 28, 2017
@fanatid fanatid deleted the fix-travis-build branch September 28, 2017 20:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants