-
Notifications
You must be signed in to change notification settings - Fork 726
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] cleanup some changes made in the TangerineWhistle PR #814
Merged
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
868c4b3
[VM] cleanup some changes made in the TangerineWhistle PR
jochem-brouwer 02300d6
[VM] move StateManager calls from opFns into the EEI
jochem-brouwer 5aead89
[VM] fix account exists if account was previously deleted in cache
jochem-brouwer 9d27c44
[VM] fix TangerineWhistle test case (track deleted items in cache)
jochem-brouwer 661bb4b
[VM] remove Account cast in StateManager
jochem-brouwer 0c20c94
[VM] cleanup some changes made in the TangerineWhistle PR
jochem-brouwer 381b24f
[VM] move StateManager calls from opFns into the EEI
jochem-brouwer f5d20d2
[VM] fix account exists if account was previously deleted in cache
jochem-brouwer 3bbe706
[VM] fix TangerineWhistle test case (track deleted items in cache)
jochem-brouwer 681418a
[VM] remove Account cast in StateManager
jochem-brouwer 49f21ff
[VM] add EEI tests to check account state
jochem-brouwer fd3afe3
Merge branch 'cleanup-tangerine-whistle' of github.com:ethereumjs/eth…
jochem-brouwer 05d28ab
Merge branch 'master' into cleanup-tangerine-whistle
holgerd77 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,30 +51,39 @@ export default class Cache { | |
} | ||
} | ||
|
||
/** | ||
* Returns true if the key was deleted and thus existed in the cache earlier | ||
* @param key - trie key to lookup | ||
*/ | ||
keyIsDeleted(key: Buffer): boolean { | ||
const keyStr = key.toString('hex') | ||
const it = this._cache.find(keyStr) | ||
if (it.node) { | ||
return it.value.deleted | ||
} | ||
return false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added test for this |
||
} | ||
|
||
/** | ||
* Looks up address in underlying trie. | ||
* @param address - Address of account | ||
* @param create - Create emtpy account if non-existent | ||
*/ | ||
async _lookupAccount(address: Buffer, create: boolean = true): Promise<Account | undefined> { | ||
async _lookupAccount(address: Buffer): Promise<Account> { | ||
const raw = await this._trie.get(address) | ||
if (raw || create) { | ||
const account = new Account(raw) | ||
return account | ||
} | ||
const account = new Account(raw) | ||
return account | ||
} | ||
|
||
/** | ||
* Looks up address in cache, if not found, looks it up | ||
* in the underlying trie. | ||
* @param key - Address of account | ||
* @param create - Create emtpy account if non-existent | ||
*/ | ||
async getOrLoad(key: Buffer, create: boolean = true): Promise<Account | undefined> { | ||
evertonfraga marked this conversation as resolved.
Show resolved
Hide resolved
|
||
async getOrLoad(key: Buffer): Promise<Account> { | ||
let account = this.lookup(key) | ||
|
||
if (!account) { | ||
account = await this._lookupAccount(key, create) | ||
account = await this._lookupAccount(key) | ||
if (account) { | ||
this._update(key, account as Account, false, false) | ||
} | ||
|
@@ -114,7 +123,7 @@ export default class Cache { | |
it.next() | ||
} else if (it.value && it.value.deleted) { | ||
it.value.modified = false | ||
it.value.deleted = false | ||
it.value.deleted = true | ||
it.value.val = new Account().serialize() | ||
await this._trie.del(Buffer.from(it.key, 'hex')) | ||
next = it.hasNext | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is currently not covered by tests:
https://codecov.io/gh/ethereumjs/ethereumjs-vm/compare/2009f18c81f2fe253e846333ace57eb77625dd60...681418a97f5e27b56da0f5ca63a6fd4acb244c2b/src/packages/vm/lib/evm/eei.ts?before=packages/vm/lib/evm/eei.ts#L591
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.
Added a test for this (
StateManager
accountExists is actually being tested; theaccountExists
of EEI is actually a proxy function but we should still test that)