-
Notifications
You must be signed in to change notification settings - Fork 773
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
Metro-Byzantium Working Branch #161
Conversation
jwasinger
commented
Jul 28, 2017
- This is the working branch for the implementation of Metropolis EIPs.
- If you'd like to help, check out ethereumjs/ethereumjs-lib on Gitter.
- Please be careful when pushing changes to this branch, especially if it reverts the work of others. If you aren't sure what to do next, ask in Gitter!
Todo-List/Current status:
|
lib/index.js
Outdated
for (var i = 1; i <= 4; i++) { | ||
this.trie.put(new Buffer('000000000000000000000000000000000000000' + i, 'hex'), new Account().serialize()) | ||
for (var i = 1; i <= 7; i++) { | ||
// temporarily skip 5 till EIP 198 added |
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.
I think there's no harm setting it. This code only ensures those accounts are touched and thus the first call to them won't incur an account creation fee.
package.json
Outdated
"ethereumjs-tx": "1.3.3", | ||
"level": "^1.4.0", | ||
"leveldown": "^1.4.6", | ||
"levelup": "^1.3.2", | ||
"memdown": "^1.1.0", | ||
"minimist": "^1.1.1", | ||
"standard": "^5.2.2", | ||
"tape": "^4.2.0" | ||
"tape": "4.6.3" |
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.
Why a fixed version?
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.
its mentioned in the commit: to downgrade tape to hide stack trace in test runner. tape versions higher 4.6.3 print a full js stack trace on failures, but its useless for our purposes (we'd want an EVM trace, not a test runner trace). Hiding it lets the test results fit in the travisCI log.
lib/opFns.js
Outdated
length = utils.bufferToInt(length) | ||
|
||
if (returnDataOffset + length > runState.lastReturned.length) { | ||
trap(ERROR.OUT_OF_GAS) |
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.
I think RETURNDATACOPY Out of range
is not the same as Out of Gas
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.
@gasolin I just took this from the EIP specification, there out-of-gas
is mentioned: https://github.com/ethereum/EIPs/pull/211/files
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.
"if `start + length` overflows or results in a value larger than `RETURNDATASIZE`, the current call stops in an out-of-gas condition"
it looks right. I referred pyethereum implementation and they seems showing the different exception https://github.com/ethereum/pyethereum/blob/develop/ethereum/fastvm.py#L415
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 EVM exceptions have the same behavior (state changes are reverted and remaining gas is consumed). The error message only determines what gets printed in the EVM trace log, though it would be good to standardize that.
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.
@cdetrio Makes a lot of sense
@jwasinger can you please rebase? |
73e234f
to
2d0521f
Compare
lib/index.js
Outdated
|
||
if (this.opts.activatePrecompiles) { | ||
for (var i = 1; i <= 4; i++) { | ||
this.trie.put(Buffer.from(new BN(i).toArray('be', 20)), new Account().serialize()) | ||
for (var i = 1; i <= 7; i++) { |
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.
Note, also isPrecompiled()
must be updated in ethereumjs-util.
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.
note that we're still using ethereumjs-util v4.5, not the latest v5.0
90ff061
to
86611c9
Compare
Should be using https://github.com/ethereumjs/rustbn.js (once ready) for the new ecc precompiles. |
var totalGas = results.gasUsed.addn(returnFee) | ||
var totalGas = results.gasUsed | ||
if (!results.runState.vmError) { | ||
var returnFee = results.return.length * fees.createDataGas.v |
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.
Should use a BN instance just in case.
b97664c
to
48ae163
Compare
package.json
Outdated
@@ -8,7 +8,7 @@ | |||
"async-eventemitter": "^0.2.2", | |||
"ethereum-common": "0.1.0", | |||
"ethereumjs-account": "^2.0.3", | |||
"ethereumjs-block": "^1.2.2", | |||
"ethereumjs-block": "git+https://github.com/holgerd77/ethereumjs-block.git#byzantium-changes", |
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.
Isn't this merged?
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.
No, that's work in progress, the PR you merged was just a prerequisite for this to be implemented. Finished EIP 100, will tomorrow have a look at EIP 649.
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.
d670471
to
d0096e5
Compare
3c09f3c
to
ea592fd
Compare
lib/opFns.js
Outdated
length = utils.bufferToInt(length) | ||
|
||
runState.stopped = true | ||
runState.returnValue = runState.lastReturned = memLoad(runState, offset, 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.
It is not necessary to set runState.lastReturned
here. The return data buffer is already set at https://github.com/jwasinger/ethereumjs-vm/blob/wip/metropolis/lib/opFns.js#L1022
lib/precompiled/05-modexp.js
Outdated
@@ -30,7 +30,7 @@ function getAdjustedExponentLength (E, eLen) { | |||
|
|||
// Taken from https://stackoverflow.com/a/1503019 | |||
function expmod (B, E, M) { |
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.
This function should use the reduction context in bn.js for proper speed.
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.
I'm not a genius on this, but what I extracted from the comments around the stack overflow solution, I think this actually is a reduction context (correct me if I'm wrong, I have no idea what a reduction context actually really is. :-))
I initially wanted to use the bn.js reduction context after reading your comments on the initial PR, but I didn't figure out how to apply this to this special problem. I actually implemented the stack overflow solution after running into long running tests ending with out-of-memory errors, with the stackoverflow solution this went back to be pretty snappy then.
You can rewrite this, but please make sure before, that you're not replacing one valid solution with another, this actually took me quite some time to implement.
5da7b23
to
be986bc
Compare
… ethereumjs/common
…ERT (fixes RevertOpcodeInCreateReturns)
74ede8a
to
5d7377f
Compare
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.
This needs a last update to package.json
with the updated master
branch dependencies, otherwise this can be merged.
@holgerd77 the commit ab90781 says there was no change in test failures. |