-
Notifications
You must be signed in to change notification settings - Fork 206
perf(l1): batch account-state prefetch via rocksdb multi_get_cf #6712
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
472dbce
8ead6e9
8466a1f
e29a713
fdb876d
3f0e004
1235a29
bc36fee
492fa70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,19 @@ pub trait VmDatabase: Send + Sync + DynClone { | |
| fn get_chain_config(&self) -> Result<ChainConfig, EvmError>; | ||
| fn get_account_code(&self, code_hash: H256) -> Result<Code, EvmError>; | ||
| fn get_code_metadata(&self, code_hash: H256) -> Result<CodeMetadata, EvmError>; | ||
|
|
||
| /// Batch account-state lookup. Default impl loops `get_account_state`. | ||
| /// Backends that can amortize per-key cost (e.g. rocksdb `multi_get_cf` on | ||
| /// the flat key-value table) should override this. | ||
| fn get_account_states_batch( | ||
| &self, | ||
| addresses: &[Address], | ||
| ) -> Result<Vec<Option<AccountState>>, EvmError> { | ||
| addresses | ||
| .iter() | ||
| .map(|a| self.get_account_state(*a)) | ||
| .collect() | ||
| } | ||
|
Comment on lines
+19
to
+27
Collaborator
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. I'm not sure I like this trait growing even more.
Contributor
Author
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. Both levm::Database and VmDatabase need it because the batched read is in StoreVmDatabase but the cache it fills (CachingDatabase) is a layer up; DynVmDatabase bridges the two. Both have a default-loop impl so no other backend changes. The only way to drop the trait method is downcasting via as_any, which adds a trait method anyway plus a runtime check and fallback. Can do that if you'd rather, but this seemed lighter. |
||
| } | ||
|
|
||
| dyn_clone::clone_trait_object!(VmDatabase); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.