Skip to content

feat(anvil): improve historic state access #8293

Open
@mattsse

Description

@mattsse
Member

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

Activity

Villegas2003

Villegas2003 commented on Jul 1, 2024

@Villegas2003

Hi @mattsse , Are you still in need of support for this issue? I'd be happy to help.

changed the title [-]Improve historic state access[/-] [+]feat(`anvil`): improve historic state access[/+] on Jul 16, 2024
zerosnacks

zerosnacks commented on Jul 16, 2024

@zerosnacks
Member

Hi @Villegas2003 that would be great, assigning this to you

added this to the v1.0.0 milestone on Jul 26, 2024
removed this from the v1.0.0 milestone on Oct 1, 2024
added this to the v1.2.0 milestone on Mar 25, 2025
linked a pull request that will close this issue on Apr 30, 2025
modified the milestones: v1.2.0, v1.3.0 on May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

      Development

      Participants

      @jenpaff@mattsse@grandizzy@yash-atreya@zerosnacks

      Issue actions

        feat(`anvil`): improve historic state access · Issue #8293 · foundry-rs/foundry