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 cleanup for stateManager #266

Merged
merged 4 commits into from
Jul 19, 2018
Merged

Some cleanup for stateManager #266

merged 4 commits into from
Jul 19, 2018

Conversation

axic
Copy link
Member

@axic axic commented Feb 2, 2018

Depends on #264. Part of #33.

self.blockchain = blockchain
self.trie = trie
self.blockchain = opts.blockchain || fakeBlockchain
self.trie = opts.trie || new Trie()
self._storageTries = {} // the storage trie cache
self.cache = new Cache(trie)
Copy link
Member

Choose a reason for hiding this comment

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

Should cache also be made an option, so that people can easier switch that if desired?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I'd do it in a separate work. _storageTries is another cache too, so not sure how it works yet.

@@ -33,6 +33,10 @@ function StateManager (opts) {

var proto = StateManager.prototype

proto.clone = function () {
Copy link
Member Author

Choose a reason for hiding this comment

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

Should this be called copy since both VM and Trie uses copy?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. to improve consistency.

Copy link
Member Author

Choose a reason for hiding this comment

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

Though I think copy is wrong overall, should be clone, yet we can do that in a separate step.

self.blockchain = blockchain
self.trie = trie
self.blockchain = opts.blockchain || fakeBlockchain
self.trie = opts.trie || new Trie()
self._storageTries = {} // the storage trie cache
self.cache = new Cache(trie)
Copy link
Member Author

Choose a reason for hiding this comment

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

Should use self.trie here, wonder why lint didn't catch this.

@jwasinger
Copy link
Contributor

Looks good overall. I approve of this refactor.

@axic axic force-pushed the statemanager-cleanup branch 2 times, most recently from fe82d0b to d43976f Compare February 3, 2018 18:50
@coveralls
Copy link

coveralls commented Feb 13, 2018

Coverage Status

Coverage increased (+0.04%) to 85.748% when pulling ae89563 on statemanager-cleanup into 0e6d2ff on master.

@axic
Copy link
Member Author

axic commented Feb 13, 2018

Need to figure out why this is failing.

@holgerd77
Copy link
Member

Just rebased this.

@holgerd77
Copy link
Member

holgerd77 commented Apr 26, 2018

This is breaking at modexpRandomInput with:

# file: modexpRandomInput test: modexpRandomInput
ok 1472 the state roots should match
ok 1473 the state roots should match
/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/rustbn.js/lib/index.asm.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object

Error: Number can only safely store up to 53 bits
    at assert (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/bn.js/lib/bn.js:6:21)
    at BN.toNumber (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/bn.js/lib/bn.js:506:7)
    at getAdjustedExponentLength (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/dist/precompiled/05-modexp.js:30:43)
    at Object.module.exports [as code] (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/dist/precompiled/05-modexp.js:82:22)

Test can be run with:

node tests/tester.js -s --test='modexpRandomInput'

(just realized that I took the updated tests from #272, results on Travis might be different)

@holgerd77
Copy link
Member

Just rebased this.

@axic
Copy link
Member Author

axic commented Jul 17, 2018

@holgerd77 this works now! 😉

@axic axic changed the title [WIP] Some cleanup for stateManager Some cleanup for stateManager Jul 17, 2018
@axic
Copy link
Member Author

axic commented Jul 19, 2018

@holgerd77 mergemerge? :)

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.

Looks good.

@holgerd77 holgerd77 merged commit d92e7b5 into master Jul 19, 2018
@holgerd77 holgerd77 deleted the statemanager-cleanup branch July 19, 2018 22:54
@axic axic mentioned this pull request Jul 21, 2018
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.

None yet

5 participants