foundry-rs / foundry-fork-db

Apache License 2.0
28 stars 9 forks source link

Make foundry-fork-db more flexible/extensible #6

Closed m1stoyanov closed 1 month ago

m1stoyanov commented 2 months ago

Currently, we cannot fetch/cache particular accounts, slots, and block hashes because the corresponding functions are private. Making them public will provide more flexibility.

Furthermore, having access to accounts, storage, and block_hashes HashMaps will allow for very fast simulations(we know how slow it can be getting a bunch of storage slots). So functions like:

pub fn insert_or_update_accounts(&self, data: Map<Address, AccountInfo>)
pub fn insert_or_update_storage(&self, data: Map<Address, StorageInfo>)
pub fn insert_or_update_block_hashes(&self, data: Map<U256, B256>)

will be of great benefit, i beleive.

mattsse commented 2 months ago

supportive

@Ethanol48 perhaps you want to take this?

Ethanol48 commented 2 months ago

Sure!

Ethanol48 commented 2 months ago

Currently, we cannot fetch/cache particular accounts, slots, and block hashes because the corresponding functions are private. Making them public will provide more flexibility.

Furthermore, having access to accounts, storage, and block_hashes HashMaps will allow for very fast simulations(we know how slow it can be getting a bunch of storage slots). So functions like:

pub fn insert_or_update_accounts(&self, data: Map<Address, AccountInfo>)
pub fn insert_or_update_storage(&self, data: Map<Address, StorageInfo>)
pub fn insert_or_update_block_hashes(&self, data: Map<U256, B256>)

will be of great benefit, i beleive.

Hi @m1stoyanov, can you tell me how do you use the library? I created some public functions inside the cache.rs in the struct BlockchainDb, that let's you do what you requested, but I'm not sure what you meant is that, do you want these functions inside the BackendHandler in backend.rs?

m1stoyanov commented 2 months ago

I use the library to simulate txs that touch many storage slots. I think the pub functions should be placed in SharedBackend to maintain the design integrity.

m1stoyanov commented 1 month ago

Great work, @Ethanol48 I am closing this