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

Updated isPrecomile according to Byzantium precompile-used address space #115

Merged
merged 1 commit into from
Feb 3, 2018

Conversation

holgerd77
Copy link
Member

Addresses #110

@holgerd77
Copy link
Member Author

@Silur Hi, thanks for the quick ES5 PR review, can you also do a short review of this (nothing exciting)? Would like to have this included before we do a release.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.17% when pulling 7685191 on byzantium-is-precompiled into 3550ee3 on master.

@@ -510,13 +510,13 @@ exports.generateAddress = function (from, nonce) {
}

/**
* Returns true if the supplied address belongs to a precompiled account
* Returns true if the supplied address belongs to a precompiled account (Byzantium)
* @param {Buffer|String} address
* @return {Boolean}
*/
exports.isPrecompiled = function (address) {
const a = exports.unpad(address)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add isValidAddress?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, normally your are right. I wouldn't want this here, since the IsPrecompiled method is removed anyhow (citing @axic) on next major release. Adding isValidAddress would change the behavior here and would cause extra/unnecessary problems for people already have this in use.

assert.equal(ethUtils.isPrecompiled('0000000000000000000000000000000000000006'), true)
assert.equal(ethUtils.isPrecompiled('0000000000000000000000000000000000000007'), true)
assert.equal(ethUtils.isPrecompiled('0000000000000000000000000000000000000008'), true)
assert.equal(ethUtils.isPrecompiled(Buffer.from('0000000000000000000000000000000000000001', 'hex')), true)
Copy link
Contributor

@fanatid fanatid Feb 2, 2018

Choose a reason for hiding this comment

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

for (let i = 1; i < 9; ++i) {
  assert.true(ethUtils.isPrecompiled(new BN(i).toString(10, 40)))
  assert.true(ethUtils.isPrecompiled(new BN(i).toBuffer('be', 20)))
}

Copy link
Member Author

Choose a reason for hiding this comment

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

This is definitely more elegant, thanks for the suggestion. Unfortunately it kills the browser tests somehow due to Buffer usage, just tested it, and I didn't want to go deeper in debugging here, think this would be not worth it in this case. Is it ok to leave it as is?

Also, can you approve, If you are ok with both explanations?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, this is ok let it as is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool, thanks.

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.

None yet

4 participants