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

Metro-Byzantium Working Branch #161

Merged
merged 62 commits into from
Sep 25, 2017
Merged

Conversation

jwasinger
Copy link
Contributor

  • 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!

@holgerd77
Copy link
Member

holgerd77 commented Aug 9, 2017

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

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

Choose a reason for hiding this comment

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

Why a fixed version?

Copy link
Contributor

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

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

Copy link
Member

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

Copy link
Contributor

@gasolin gasolin Aug 10, 2017

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

Copy link
Contributor

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.

Copy link
Member

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

@axic
Copy link
Member

axic commented Aug 10, 2017

@jwasinger can you please rebase?

@jwasinger jwasinger force-pushed the wip/metropolis branch 2 times, most recently from 73e234f to 2d0521f Compare August 12, 2017 08:26
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++) {
Copy link
Member

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.

Copy link
Contributor

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

@holgerd77 holgerd77 force-pushed the wip/metropolis branch 2 times, most recently from 90ff061 to 86611c9 Compare August 16, 2017 11:09
@axic
Copy link
Member

axic commented Aug 18, 2017

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

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.

@holgerd77 holgerd77 force-pushed the wip/metropolis branch 2 times, most recently from b97664c to 48ae163 Compare August 23, 2017 08:47
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",
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this merged?

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

@axic Also, before merging the Metro-Byzantium changes into ethereumjs-block, I would like to have this PR #189 to be merged, otherwise new installations target the current network will break (at lease when there is a npm ethereumjs-block release with the changes).

lib/opFns.js Outdated
length = utils.bufferToInt(length)

runState.stopped = true
runState.returnValue = runState.lastReturned = memLoad(runState, offset, length)
Copy link
Contributor Author

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

@holgerd77 holgerd77 changed the title Metropolis Working Branch Metro-Byzantium Working Branch Sep 18, 2017
@@ -30,7 +30,7 @@ function getAdjustedExponentLength (E, eLen) {

// Taken from https://stackoverflow.com/a/1503019
function expmod (B, E, M) {
Copy link
Member

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.

Copy link
Member

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.

@holgerd77 holgerd77 force-pushed the wip/metropolis branch 3 times, most recently from 5da7b23 to be986bc Compare September 21, 2017 12:32
holgerd77
holgerd77 previously approved these changes Sep 25, 2017
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.

This needs a last update to package.json with the updated master branch dependencies, otherwise this can be merged.

@cdetrio
Copy link
Contributor

cdetrio commented Sep 25, 2017

@holgerd77 the commit ab90781 says there was no change in test failures. runState.lastReturned is set here

@jwasinger jwasinger merged commit 45d73f0 into ethereumjs:master Sep 25, 2017
@holgerd77 holgerd77 mentioned this pull request Jun 25, 2020
15 tasks
holgerd77 added a commit that referenced this pull request Dec 1, 2020
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.

6 participants