forked from paradigmxyz/reth
-
Notifications
You must be signed in to change notification settings - Fork 39
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
feat(db): SyncDatabase for cross-chain state access #44
Merged
Conversation
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
Brechtpd
reviewed
Oct 2, 2024
Comment on lines
-39
to
+42
<TransactionRequest as TransactionBuilder<Ethereum>>::set_blob_sidecar(&mut tx, sidecar); | ||
<TransactionRequest as TransactionBuilder<Ethereum>>::set_max_fee_per_blob_gas( | ||
<TransactionRequest as TransactionBuilder4844>::set_blob_sidecar(&mut tx, sidecar); | ||
<TransactionRequest as TransactionBuilder<Ethereum>>::set_max_fee_per_gas( |
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.
What does this change do?
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.
think it's from different ver of alloy, the old lines doesn't compile anymore
# Conflicts: # Cargo.lock # crates/ethereum/payload/src/lib.rs # crates/gwyneth/src/exex.rs # crates/storage/storage-api/src/state.rs
[gwyneth] Rebase EL image mods to current main `gwyneth` branch
rbuilder integration with gwyneth-reth
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
We modified Revm for cross-chain state access, namely, it reads any account/storage with
ChainAddress = (ChainId, Address)
and we need to support that when we start L2 nodes in ExEx Context.Current Database & Provider
Revm
Need state provider associated with the current block to execute transactions, so the entire Revm crate abstracts over
DB: revm::Database
to provide this access. The struct implementation is typically a wrapper holding an in-memory cache state with underlying real database passed from Reth.Reth
Reth uses a
ProviderFactory
that holds unique references to an in-memory (mostly MDBX) DB and aStaticFileProvider
: https://github.com/paradigmxyz/reth/tree/main/crates/static-file/static-fileThe lowest level abstraction of Database in Reth represents operations on reading/writing data, which is different from that of Revm. Between the physical database and Revm state provider, Reth implemented many APIs to access blockchain data and they are mostly in
StateProvider
trait.Cross-chain Database & Provider
We first modified Revm's Database trait to execute transactions against the targeted state root: taikoxyz/revm#17
For Reth, the cross-chain state provider should be implemented as a HashMap over some database trait, but the concrete type can be anything. Thus, performing type erasure with
dyn
trait object makes sense. We managed to preserve Reth's abstraction on its physical database and the building process of different genericBox< dyn StateProvider>
. The main DB being pass into the executor is the following:This implements
SyncDatabase
and a modified blanket traitSyncEvmStateProvider
which glue the old singleton database withEvmStateProvider
and the synchronous database together:We can start the sync DB compatible with the old code, and insert as many DB instances for multiple L2s in the ExEx context. Note that the
CacheDB
and state builder withWrapDatabaseRef
are also available out of the box:taiko-reth/crates/gwyneth/src/builder.rs
Line 80 in 1f7ea4e