Skip to content
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

Pruning: EVM #1193

Open
Tracked by #1190
rakanalh opened this issue Sep 17, 2024 · 0 comments
Open
Tracked by #1190

Pruning: EVM #1193

rakanalh opened this issue Sep 17, 2024 · 0 comments

Comments

@rakanalh
Copy link
Contributor

rakanalh commented Sep 17, 2024

Description

Depends on #1191

EVM has 3 storage items that we need to cleanup:

  1. blocks: Implements StateVecAccessor which enables us to iter / retain blocks which would not be pruned.
  2. block_hashes: Implements StateMapAccessor which lets us remove entries for blocks which should be pruned.
  3. receipts: Implements StateVecAccessor. For the blocks we end up removing, each SealedBlockprovides access to the transactions which we'd want to remove. For reference:

let block = match block_number_or_hash {
BlockId::Hash(block_hash) => {
let block_number = match self
.block_hashes
.get(&block_hash.block_hash, &mut working_set.accessory_state())
{
Some(block_number) => block_number,
None => return Ok(None), // if hash is unknown, return None
};
// if hash is known, but we don't have the block, fail
self.blocks
.get(block_number as usize, &mut working_set.accessory_state())
.expect("Block must be set")
}
BlockId::Number(block_number) => {
match self.get_sealed_block_by_number(Some(block_number), working_set)? {
Some(block) => block,
None => return Ok(None), // if block doesn't exist return null
}
}
};
let receipts = &block
.transactions
.clone()
.map(|id| {
let tx = self
.transactions
.get(id as usize, &mut working_set.accessory_state())
.expect("Transaction must be set");
let receipt = self
.receipts
.get(id as usize, &mut working_set.accessory_state())
.expect("Receipt for known transaction must be set");
build_rpc_receipt(&block, tx, id, receipt)
})
.collect::<Vec<_>>();

This needs to be implemented in the pruner.

Concerns

Since blocks is a vector, we should consider race conditions between the pruner which is creating a new vector by filtering pruned blocks and the sequencer which is pushing new blocks into this list.

While pruning EVM, we should somehow lock access to EVM.

@rakanalh rakanalh mentioned this issue Sep 17, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant