Skip to content

Experiment: flatten plain state for MemoryStateProvider #20612

@mediocregopher

Description

@mediocregopher

Describe the feature

When using MemoryStateProvider we pass it an array of ExecutedBlocks, which it then iterates over to serve requests:

for block in self.in_memory.iter() {
if let Some(account) = block.execution_output.account(address) {
return Ok(account);
}
}

for block in self.in_memory.iter() {
if let Some(value) = block.execution_output.storage(&address, storage_key.into()) {
return Ok(Some(value));
}
}

for block in self.in_memory.iter() {
if let Some(contract) = block.execution_output.bytecode(code_hash) {
return Ok(Some(contract));
}
}

We should see if we can flatten the BundleState of the ExecutedBlocks into a single state, which can be applied as an overlay instead. This can be done asynchronously in a similar manner to the trie input:

fn spawn_deferred_trie_task(

Note that we can only use this flattened state if its anchor block shares the anchor of the block being validated. If not then we must either compute a new flattened state or fallback to the current behavior.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-engineRelated to the engine implementationC-enhancementNew feature or requestC-perfA change motivated by improving speed, memory usage or disk footprint

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions