-
Notifications
You must be signed in to change notification settings - Fork 554
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
Persist reverted account and storage slot lookups in JournaledState
#1437
Persist reverted account and storage slot lookups in JournaledState
#1437
Conversation
Alternative implementation: #1438 |
I like this option better, and i think it would be good addition to revm. In general there were few footguns where people asumed behavior from this PR, and get surprised when account gets reverted/deleted. And this gives more flexibiliy and align with others EVMs where access list is a different struct. Will need to review this in detail, entry revert seems to be missing and I need to check what to do on create revert and sloads of reverted storage, a lot of edge cases there. |
Could you elaborate on the point regarding access lists? I don't think this will have any implications in regards to how the access lists are managed with journaled state? From my understanding the access list is populated in journaled state via the
Could you elaborate on what you are referring to with "entry revert" please? With
For reverted We certainly need to test edge cases thoroughly. How would you propose we go about this? |
I'm not sure on the specifics you are referring to around access list handling but If we wanted to add the ability to assess if an account was loaded due to an access list then we could extend the // The `bitflags!` macro generates `struct`s that manage a set of flags.
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct AccountStatus: u8 {
...
/// used to mark account as cold
const Cold = 0b0010000;
/// used to mark and access list account
const AccessList = 0b0100000;
}
} We could also introduce bitflags on the |
In other EVMs, the access list is a different HashMap and it is disconnected from the internal state, which another HashMap. I was just making zoomed out comment that this PR aligns more with that, and this is desirable.
I didn't see it, I meant about this: https://github.com/bluealloy/revm/pull/1437/files#diff-32ab64096b0ec0ba2da45b3ed2c625d583845fb31fce99db138683b0178fdd44R322
tldr: I like this change, but will need to check edge cases and how they behave in code. |
.last_mut() | ||
.unwrap() | ||
.push(JournalEntry::AccountLoaded { address }); | ||
} |
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.
Awesome change!
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.
Have made additional change to StorageSlot
structures, now it is localised only to internal Evm state so is_cold
is not leaked outside.
PR is good to go, but will need to check how this will propagate to inspectors |
It shouldn't be disruptive. @frisitano thank you for PR. |
Most welcome. Thank you for the review and support 🙏 |
This PR modifies the logic of how
JournaledState
manages reverts forAccountLoaded
andStorageChange
journal entries.When reverting, instead of removing
Account
andStorageSlot
entries fromState
we mark the entries as cold. As such if they are later loaded they will already be in journaled state mitigating the requirement to load them again from the database. When they are requested again they will be marked as warm.This is beneficial when finalizing the
JournaledState
object as it will include all accounts and storage slots which have been loaded during a transactions execution, regardless of whether they were reverted. This is a requirement for generating stateless witnesses. Currently thePrestateTracer
does not include accounts and storage slots which have been accessed and then subsequently reverted.We need stateless witnesses to use
revm
(andreth
) as an execution engine for the type 1 prover which is under development at Polgyon and by association the shared sequencer we are developing at Fractal.