-
Notifications
You must be signed in to change notification settings - Fork 757
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 interface simplification #388
Conversation
Simplifies the stateManager interface used by the VM by removing dependencies on the following methods: * getAccountBalance * putAccountBalance * copy
03de1b0
to
c346a04
Compare
Rebased this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Matthew, since this is also passing all previously passed tests (actually: even let some additional tests on Constantinople pass), I think I can merge this now! 👍
if (err) { | ||
return cb(err) | ||
} | ||
cb(null, new BN(value)) | ||
cb(null, new BN(account.balance)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also double-checked that all occurences of getAccountBalance
have been caught.
} catch (e) { | ||
done(e.error) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty
is not needed here, so this can be simplified, ok.
function (account, cb) { | ||
account.balance = new BN(0) | ||
stateManager.putAccount(contractAddress, account, cb) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own understanding, is this switch from series
to waterfall
just to make things faster?
@@ -196,7 +199,7 @@ module.exports = function (opts, cb) { | |||
.add(new BN(fromAccount.balance)) | |||
fromAccount.balance = finalFromBalance | |||
|
|||
self.stateManager.putAccountBalance(utils.toBuffer(tx.from), finalFromBalance, next) | |||
self.stateManager.putAccount(utils.toBuffer(tx.from), fromAccount, next) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double-checked here as well that there are no occurrences of putAccountBalance()
left.
current | ||
}) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, think I've gotten the concept, this is also well additionally covered by tests.
This PR is based on discussions in #268 and simplifies the
stateManager
interface used by the VM by removing dependencies on the following methods:getAccountBalance
putAccountBalance
copy
As per the discussion in #268 the balance methods have been removed as they are superfluously supported by both
ethereumjs-account
and bystateManager
.The dependency on the
copy
was introduced by #367 but this method in it's current form would be very difficult to document for an external interface. I've therefore removed this usage replacing it with astorageReader
class which provides the necessary original value lookup caching.