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

VM: stateManager -> add modifyAccountFields method #1369

Merged
merged 10 commits into from
Jul 27, 2021

Conversation

emersonmacro
Copy link
Contributor

Addresses #731.

This was my first time working with stateManager and I was learning as I went, so any feedback, suggestions, or critique are welcomed.

There was one part of the original issue that I wasn't able to figure out: The method should probably throw if account doesn't exist.. I attempted that but couldn't get it to work, and after some digging, it looks like if the account doesn't exist, a new one will be created, so an account always exists when getAccount is called. Is there something I'm not understanding?

@codecov
Copy link

codecov bot commented Jul 21, 2021

Codecov Report

Merging #1369 (97c7f35) into master (5ac0ff8) will increase coverage by 1.30%.
The diff coverage is 100.00%.

Impacted file tree graph

Flag Coverage Δ
block 86.06% <ø> (ø)
blockchain 83.49% <ø> (ø)
client 83.70% <ø> (ø)
common 93.02% <ø> (+0.31%) ⬆️
devp2p 83.32% <ø> (-0.25%) ⬇️
ethash 82.83% <ø> (ø)
tx 88.24% <ø> (-0.12%) ⬇️
vm 82.78% <100.00%> (+3.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@acolytec3
Copy link
Contributor

acolytec3 commented Jul 21, 2021

Per previous comments, getAccount creates a new account if it doesn't already exist in the stateManager as you noted so I think the question here is, should getAccount create a new account or not? The docs currently state Returns an empty account if the account does not exist so that seems pretty clear to me that it shouldn't throw unless we're going to change the design, which would be a breaking change here since it would change the behavior of the function. My opinion is that if it ain't broke, don't fix it. @ryanio @jochem-brouwer thoughts?

acolytec3
acolytec3 previously approved these changes Jul 21, 2021
Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

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

This looks great. I added one additional test to prove out the fact that modifying a non-existent account will first create an empty one and then update its values accordingly.

@jochem-brouwer
Copy link
Member

I don't know the reasoning behind throwing if the account does not exist. I'd say it makes much sense, and is consistent, to just take the empty account and then modify these fields.

jochem-brouwer
jochem-brouwer previously approved these changes Jul 21, 2021
Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

This looks good to me!

@ryanio
Copy link
Contributor

ryanio commented Jul 21, 2021

looks great. is there anywhere we can use this new method within our own internal VM then? or is it just a convenience helper for external use?

@emersonmacro
Copy link
Contributor Author

@ryanio Ah, yes I think there are some spots internally where this new method could be used. Should I include that as part of this PR or tackle separately?

@ryanio
Copy link
Contributor

ryanio commented Jul 21, 2021

I say let's include it as part of this PR, so that the changes are contained together nicely.

@emersonmacro
Copy link
Contributor Author

PR updated with some usage changes

Copy link
Contributor

@ryanio ryanio left a comment

Choose a reason for hiding this comment

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

looks really great!

@ryanio ryanio linked an issue Jul 27, 2021 that may be closed by this pull request
@ryanio ryanio merged commit 39c18b1 into master Jul 27, 2021
@ryanio ryanio deleted the vm-statemanager-modify-account-fields-method branch July 27, 2021 19:55
@ryanio ryanio mentioned this pull request Aug 2, 2021
ryanio added a commit that referenced this pull request Aug 3, 2021
…due to statemanager interface breaking change
@holgerd77 holgerd77 mentioned this pull request Feb 16, 2022
51 tasks
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.

stateManager: add modifyAccountFields method
4 participants