Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
minor fix of zero value buffer check
Browse files Browse the repository at this point in the history
  • Loading branch information
Silur committed Jul 18, 2017
1 parent 70eada0 commit 83554fa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -598,7 +598,7 @@ exports.defineProperties = function (self, fields, data) {
function setter (v) {
v = exports.toBuffer(v)

if (v.toString('hex') === '00' && !field.allowZero) {
if (v.toString('hex').match(/^0+$/) !== null && !field.allowZero) {

This comment has been minimized.

Copy link
@yann300

yann300 Jul 18, 2017

Are you sure about this fix? cause that breaks remix (when using the parentHash property - we use the default value)
==> https://github.com/ethereumjs/ethereumjs-block/blob/master/header.js#L25

This comment has been minimized.

Copy link
@Silur

Silur Jul 18, 2017

Author Contributor

Hmm didn't see that during testing, wouldn't that have an allowZero or empty flag?
also see #85 I'll reopen it.

This comment has been minimized.

Copy link
@Silur

Silur Jul 18, 2017

Author Contributor

@wanderer what are your thoughts about handling util.zeroes with this fix, allowZero, empty, new flag or revert?

This comment has been minimized.

Copy link
@yann300

yann300 Jul 18, 2017

this change create a conflict with

self[field.name] = field.default

in case of parentHash, the default value is utils.zeros(32) and we fall line 602 and the assert line 609 fails.

This comment has been minimized.

Copy link
@wanderer

wanderer Jul 18, 2017

Member

@Silur i think we should just revert this change. I don't see the point of using regex here

This comment has been minimized.

Copy link
@yann300

yann300 Jul 18, 2017

sorry I didn't see your previous post.
setting previousHash => allowZero : true, empty: false would make sense I guess cause the default already is non empty and 00..

v = Buffer.allocUnsafe(0)
}

Expand Down

0 comments on commit 83554fa

Please sign in to comment.