Skip to content
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

Merged
merged 7 commits into from
Aug 22, 2017
Merged

Some smaller cleanups (mostly regarding calls) #186

merged 7 commits into from
Aug 22, 2017

Conversation

axic
Copy link
Member

@axic axic commented Aug 18, 2017

Depends on #188.

Copy link
Member

@holgerd77 holgerd77 left a 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)))
Copy link
Member

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)))
Copy link
Member

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))
Copy link
Member

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)
Copy link
Member

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)))
Copy link
Member

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)
})
}
})
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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]))
Copy link
Member

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()
Copy link
Member

Choose a reason for hiding this comment

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

Call with null here?

Copy link
Member Author

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.

@axic axic merged commit e40c6f1 into master Aug 22, 2017
@axic axic deleted the cleanup branch August 22, 2017 23:20
@axic axic removed the in progress label Aug 22, 2017
holgerd77 pushed a commit that referenced this pull request Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants