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

StateManager documentation #393

Merged
merged 1 commit into from
Nov 21, 2018
Merged

StateManager documentation #393

merged 1 commit into from
Nov 21, 2018

Conversation

mattdean-digicatapult
Copy link
Contributor

Initial StateManager documentation as per #391.

In the process of writing this a couple of inconsistencies in the code were found. Firstly several methods, which should only be called when there are no outstanding checkpoints, were found and updated to error when this is not the case. Secondly the checkpoint function was made asynchronous to match other methods.

Initial `StateManager` documentation. In the process of writing this a couple of inconsistencies in the code were found. Firstly several methods, which should only be called when there are no outstanding checkpoints, were found and updated to error when this is not the case. Secondly the `checkpoint` function was made asynchronous to match other methods.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 90.465% when pulling eddd9db on state-manager-docs into db3db1c on master.

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.

Thanks for this, will do a proper review tomorrow!

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.

One thing which needs clarification, otherwise: great comprehensive and straight-forward documentation!

- `opts.origin` **[Buffer][44]** the address where the call originated from. The address should be a `Buffer` of 20bits. Defaults to `0`
- `opts.value` **[Buffer][44]** the value in ether that is being sent to `opt.address`. Defaults to `0`
- `cb` **[runCode~callback][45]** callback
- `cb` **[runTx~callback][41]** the callback
Copy link
Member

Choose a reason for hiding this comment

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

Had a look at the generated doc, looks good.


[68]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error

[69]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
Copy link
Member

Choose a reason for hiding this comment

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

Same hear, looks good, nice and clear descriptions.

self.stateManager.revert(function () {
cb(err)
})
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, good catch.

proto.generateCanonicalGenesis = function (cb) {
var self = this

if (self._checkpointCount !== 0) { return cb(new Error('Cannot create genesis state with uncommitted checkpoints')) }

this.hasGenesisState(function (err, genesis) {
if (!genesis && !err) {
self.generateGenesis(genesisStates[self._common.chainName()], cb)
Copy link
Member

Choose a reason for hiding this comment

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

Here there is a call from a method from the interface to a method from the default implementation, this is probably not intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand you right it's completely intended. The method generateCanonicalGenesis in the implementation can use whatever mechanism it likes to provide implementation. This is much like how putContractStorage uses _modifyContractStorage internally.

FYI, I did consider removing generateCanonicalGenesis from the interface completely, but it would require further changes as to how we initialize the state trie. Depending on feedback during the beta this is something we might change still.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, getting closer with my understanding. So if we extract/separate StateManager to an own repository, we would also extract the default StateManger, is that correct? First thought it would be rather intended to only extract the interface methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would extract both to a single repo yes. Presuming it would be Typescript, we would then define the interface along with a reference (default) implementation in the external repo with both types being exported. Now there is a question as to whether the reference implementation should include methods beyond the interface? My gut instinct is it should not and we should strip away the extra functionality. It just felt like too much to do as part of this refactor

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I would go very much along with you, also think there shouldn't be additional methods in the default implementation. Ok, but nevertheless, let's keep it for now, I might make an additional comment in the release notes or so.

Will now prepare release notes, probably do a release one day later (absolutely no problem, just for info), so likely tomorrow.

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!

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.

5 participants