-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(levm): fix interaction with cache and db (#1531)
**Motivation** <!-- Why does this pull request exist? What are its goals? --> **Description** TLDR: We don't want to interact directly with the db without consulting before with the cache. This won't fix nor break tests because in every EFTest we send the cache empty, but it is a necessary fix for executing multiple transactions within a block. As a side effect we have to move contract creation and insertion to cache to `transact()`, so that we can revert if address is already occupied. <!-- A clear and concise general description of the changes this PR introduces --> Idea: - Move contract creation and insertion to cache to `transact()`, not to `new()`. - This is because we really want to check if the contract already exists both in the cache and in the db, and if when you want to create it you see that it already exists in one of those 2 there you revert. Currently we only check it in the db but the tests work because they test only one transaction each, so the cache always starts empty. - The idea is to stop using `db.get_account_info()` in the `VM::new()`, we want to query the cache first and then the DB. For this we have the `get_account()` method in VM, but in `VM::new()` it doesn't work because there is no vm created yet. The idea is to grab that behavior and take it to a `get_account(address, mut cache, db)` function that has the same behavior as now. The VM get_account method can be a handrail to call this, which does `get_account(address, self.cache, self.db)`. Additional Changes: - Remove unnecessary stuff in `VM::new()` - Remove receiver account every time a transaction reverts, independently of it's type. <!-- Link to issues: Resolves #111, Resolves #222 --> Closes #issue_number
- Loading branch information
Showing
1 changed file
with
42 additions
and
62 deletions.
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