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

EIP 1283 SSTORE #367

Merged
merged 1 commit into from
Oct 11, 2018
Merged

EIP 1283 SSTORE #367

merged 1 commit into from
Oct 11, 2018

Conversation

vpulim
Copy link
Contributor

@vpulim vpulim commented Oct 8, 2018

Depends on ethereumjs/ethereumjs-common#27.

Closes #354

I wasn't sure about the best way to test this PR since there aren't any EIP-1283 tests yet in ethereum/tests, so I created my own tests in tests/constantinopleSstoreTest.js until official tests are available. These tests are currently not being run in circleci. Ideas?

@coveralls
Copy link

coveralls commented Oct 8, 2018

Coverage Status

Coverage decreased (-1.2%) to 91.677% when pulling 397d510 on eip-1283 into 08b5a93 on master.

@holgerd77
Copy link
Member

If I got this correct I think the latest PR merge on the tests repository ethereum/tests#511 should contain various tests (primarily testing other functionality) implicitly testing the new gas prices. This is just three days old, we'll have to do a new release with an updated submodule of our own proxy testing module (ethereumjs-testing).

@vpulim
Copy link
Contributor Author

vpulim commented Oct 8, 2018

@holgerd77 Ah ok, great. I didn't realize they were just released. I'll update this PR and remove my tests once ethereumjs-testing is updated.

@vpulim
Copy link
Contributor Author

vpulim commented Oct 10, 2018

I just verified that #368 fixes many failing Constantinople state tests using this PR. Still many other failing tests that are dependent on the other open Constantinople PRs.

@holgerd77
Copy link
Member

Ok, I just released a new version of the ethereumjs-common library v0.6.0, so this can be updated now.

@holgerd77
Copy link
Member

Update: I would update the ethereumjs-common dependency myself and then do a review and eventually merge if you don't intervene in the next hour or so, then we can build/rebase other stuff on top.

Side note: I thought of the labels PR state: WIP and PR state: needs review somewhat excluding each other, so the WIP semantics would be more of "someone is still actively working on it" explicitly leaving out the review as part of the work. With this notion I think it is more useful, then one can switch - once work is ready - from WIP to review label and it's more clear for others what to do. Since you assigned both labels simultaneously I assume that you have done this with the code-work-side of this PR ready and therewith open for a review.

@vpulim
Copy link
Contributor Author

vpulim commented Oct 11, 2018

@holgerd77 I'm updating ethereumjs-common to 0.6.0 now, but I'm trying to track down an error that I wasn't seeing before when I ran the Constantinople tests:

# GeneralStateTests
# file: addNonConst test: addNonConst
assert.js:49
  throw new AssertionError(obj);
  ^

AssertionError [ERR_ASSERTION]: The field stateRoot must have byte length of 32
    at module.exports.setter [as stateRoot] (/Users/vpulim/dev/ethereumjs-vm/node_modules/ethereumjs-account/node_modules/ethereumjs-util/index.js:644:9)
    at /Users/vpulim/dev/ethereumjs-vm/tests/util.js:384:27

Will report back once I confirm things are okay to proceed.

@vpulim
Copy link
Contributor Author

vpulim commented Oct 11, 2018

It looks like #369 is causing these errors. If that is expected behavior due to a dependency on other open PRs, then please proceed with the review/merge.

current: function (cb) { runState.stateManager.getContractStorage(address, key, cb) }
}, cb)
} else {
runState.stateManager.getContractStorage(address, key, cb)
Copy link
Member

Choose a reason for hiding this comment

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

Pre-constantinople logic seems to be cleanly separated, ok.

} else if (value.length !== 0 && found.length) {
subGas(runState, new BN(runState._common.param('gasPrices', 'sstoreReset')))
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Same here, clean separation of pre-constantinople SSTORE gas calculations.

// If current value equals new value (this is a no-op), 200 gas is deducted.
subGas(runState, new BN(runState._common.param('gasPrices', 'netSstoreNoopGas')))
return
}
Copy link
Member

Choose a reason for hiding this comment

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

First case of EIP, with return, ok.

Copy link
Member

Choose a reason for hiding this comment

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

Second look, as far as I see it these both versions 1) first subGas() call, then blank return and 2) return subGas() on other occasions doesn't make any difference I assume (?). Won't make this a review blocker, but unless there are reasons for it I am not seeing right now this might be updated to be more consistent if there is the occasion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! This should be return subGas... like in the rest of the code. This is stylistic and can be fixed later... not critical.

runState.gasRefund = runState.gasRefund.addn(runState._common.param('gasPrices', 'netSstoreResetRefund'))
}
}
return subGas(runState, new BN(runState._common.param('gasPrices', 'netSstoreDirtyGas')))
Copy link
Member

Choose a reason for hiding this comment

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

This is working down the various cases from the EIP and adding to the existing runState.gasRefund variable. I assume this is correct since tests are passing here on a broad basis.

If there are smaller caveats or edge cases we can do subsequent PRs to correct once we have a clearer picture on the test runs and tests have stabilized more.

@holgerd77 holgerd77 merged commit 7e15b49 into master Oct 11, 2018
@holgerd77 holgerd77 deleted the eip-1283 branch October 11, 2018 12:01
@holgerd77
Copy link
Member

Hi Vinay, have now merged, thanks a lot that you took on this so quickly! 😄

Hmm, the new test failure caused by #369 wasn't intended, but we can then probably address this separately in a new PR, if you want you can file a new issue for that. No need to wait here since #369 is already merged anyhow and we will not do an imminent release on the VM.

@holgerd77
Copy link
Member

Short test result summary (ethereumjs-testing v1.2.3, submodule 9777827):

Before:

1..4776
# tests 4776
# pass  3783
# fail  993

After:

1..4776
# tests 4776
# pass  4684
# fail  92

Really cool! 🏆 🏆
And some tropical drink for the win: 🍹 😄

@vpulim
Copy link
Contributor Author

vpulim commented Oct 11, 2018

Woo hoo! 🙌

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.

[Constantinople] EIP 1283 SSTORE net metering
4 participants