Skip to content

feat(anvil): improve historic state access #8293

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

Open
mattsse opened this issue Jun 28, 2024 · 2 comments · May be fixed by #10420
Open

feat(anvil): improve historic state access #8293

mattsse opened this issue Jun 28, 2024 · 2 comments · May be fixed by #10420
Labels
A-internals Area: internals A-reth-anvil Area: reth-anvil C-anvil Command: anvil T-feature Type: feature
Milestone

Comments

@mattsse
Copy link
Member

mattsse commented Jun 28, 2024

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

@mattsse mattsse added the T-feature Type: feature label Jun 28, 2024
@Villegas2003
Copy link

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

@tsnewnami tsnewnami mentioned this issue Jul 12, 2024
@zerosnacks zerosnacks added C-anvil Command: anvil A-internals Area: internals labels Jul 16, 2024
@zerosnacks zerosnacks changed the title Improve historic state access feat(anvil): improve historic state access Jul 16, 2024
@zerosnacks
Copy link
Member

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

@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
@grandizzy grandizzy removed this from the v1.0.0 milestone Oct 1, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Oct 1, 2024
@grandizzy grandizzy added the A-reth-anvil Area: reth-anvil label Nov 7, 2024
@jenpaff jenpaff added this to the v1.2.0 milestone Mar 25, 2025
@naijauser naijauser linked a pull request Apr 30, 2025 that will close this issue
3 tasks
@jenpaff jenpaff modified the milestones: v1.2.0, v1.3.0 May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-internals Area: internals A-reth-anvil Area: reth-anvil C-anvil Command: anvil T-feature Type: feature
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

6 participants