Skip to content

feat(anvil): improve historic state access #8293

Open
@mattsse

Description

@mattsse

Component

Anvil

Describe the feature you would like

for historic blocks we currently need to acquire a write lock

if let Some((state, block)) = self

in case we need to fetch the state from disk:

if let Some(state) = self.on_disk_states.get_mut(hash) {

this is very inefficient because it bottlenecks concurrent requests < current.height.

this can be improved in various ways,

  • easiest solution would be two step locking
  1. write lock and ensure state is initialized if missing:
    if let Some(state) = self.on_disk_states.get_mut(hash) {
    if let Some(cached) = self.disk_cache.read(*hash) {
    state.init_from_snapshot(cached);
  2. read lock to fetch it

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions