-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some smaller cleanups (mostly regarding calls) #186
Conversation
… codes are transmitted outside this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks ok, one change I don't understand completely (stateManager.getAccount
addition), so I'm not daring to judge here.
@@ -258,7 +258,7 @@ module.exports = { | |||
|
|||
memStore(runState, memOffset, runState.callData, dataOffset, dataLength) | |||
// sub the COPY fee | |||
subGas(runState, new BN(Number(fees.copyGas.v) * Math.ceil(dataLength / 32))) | |||
subGas(runState, new BN(fees.copyGas.v).imuln(Math.ceil(dataLength / 32))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
@@ -270,14 +270,14 @@ module.exports = { | |||
|
|||
memStore(runState, memOffset, runState.code, codeOffset, length) | |||
// sub the COPY fee | |||
subGas(runState, new BN(fees.copyGas.v * Math.ceil(length / 32))) | |||
subGas(runState, new BN(fees.copyGas.v).imuln(Math.ceil(length / 32))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
}, | ||
EXTCODESIZE: function (address, runState, cb) { | ||
var stateManager = runState.stateManager | ||
address = utils.setLengthLeft(address, 20) | ||
stateManager.getContractCode(address, function (err, code) { | ||
if (err) return cb(err) | ||
cb(err, utils.intToBuffer(code.length)) | ||
cb(null, utils.intToBuffer(code.length)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
@@ -386,7 +387,7 @@ module.exports = { | |||
stateManager.putContractStorage(address, key, value, function (err) { | |||
if (err) return cb(err) | |||
runState.contract = stateManager.cache.get(address) | |||
cb() | |||
cb(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both ok.
@@ -473,7 +474,7 @@ module.exports = { | |||
memLength = utils.bufferToInt(memLength) | |||
const numOfTopics = runState.opCode - 0xa0 | |||
const mem = memLoad(runState, memOffset, memLength) | |||
subGas(runState, new BN(numOfTopics * fees.logTopicGas.v + memLength * fees.logDataGas.v)) | |||
subGas(runState, new BN(fees.logTopicGas.v).imuln(numOfTopics).iadd(new BN(fees.logDataGas.v).imuln(memLength))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can optionally put some brackets around first multiplication like (new BN(fees.logTopicGas.v).imuln(numOfTopics))
for better readability/consistency, otherwise ok.
makeCall(runState, options, localOpts, done) | ||
}) | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, code looks correct, not completely understand the changing semantics here, so probably for someone else to review again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The account must exists even for precompiles.
@@ -670,8 +675,8 @@ module.exports = { | |||
} else { | |||
stateManager.getContractCode(toAddress, function (err, code, compiled) { | |||
if (err) return done(err) | |||
options.compiled = compiled || false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
@@ -921,7 +930,7 @@ function makeCall (runState, callOptions, localOpts, cb) { | |||
runState.contract.nonce = new BN(runState.contract.nonce).subn(1) | |||
} | |||
|
|||
cb(err, Buffer.from([results.vm.exception])) | |||
cb(null, Buffer.from([results.vm.exception])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All above ok.
// save result to the stack | ||
if (result) { | ||
// NOTE: Ensure that every stack item is padded to 256 bits. | ||
// This should be done at every opcode in the future. | ||
result = utils.setLengthLeft(result, 32) | ||
runState.stack.push(result) | ||
} | ||
cb(err) | ||
|
||
cb() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call with null
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, though that file has all the callbacks without null, need to tackle it at some point. Also some other methods (parseVmResults
) there have an issue passing both err
and results
. Haven't reviewed it yet.
Depends on #188.