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

feat: blockchain provider tree state integration #9518

Merged
merged 9 commits into from
Jul 16, 2024

Conversation

fgimenez
Copy link
Member

@fgimenez fgimenez commented Jul 15, 2024

Towards #8747

Scaffolds InMemoryState trait and implements it for EngineApiTreeHandlerImpl. TreeState is updated to include pending and current_head data.

For now in BlockchainProvider there are only references to the field that will provide this state.

@fgimenez fgimenez force-pushed the fgimenez/blockchain-provider-tree-state-integration branch 2 times, most recently from 2d3b219 to 91ec045 Compare July 15, 2024 17:19
@fgimenez fgimenez marked this pull request as ready for review July 15, 2024 17:31
Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense, I have mostly doc nits!

crates/engine/tree/src/tree/mod.rs Outdated Show resolved Hide resolved
crates/engine/tree/src/tree/mod.rs Outdated Show resolved Hide resolved
crates/engine/tree/src/tree/mod.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, this is a very good start,
we're still missing some things but we can iterate on it.

I think from tree perspective it would be great if this state is managed separately as CanonicalState { Rwlocks } so that the tree updates only the canonical blocks in there

crates/engine/tree/src/tree/mod.rs Outdated Show resolved Hide resolved
Comment on lines +931 to +932
/// State composed of a block hash, and the receipts, state and transactions root
/// after executing it.
#[derive(Debug, PartialEq, Eq)]
pub struct State {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need the SealedBlock + the actual state so we can perform eth_call, trace etc. on this but this is a good start

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean, including a field with the SealedBlock? the rest of fields could be obtained from it or am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, what we need to access is:
block,receipts+state at this block

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will propose it in a followup

crates/engine/tree/src/tree/mod.rs Outdated Show resolved Hide resolved
crates/storage/provider/src/providers/mod.rs Outdated Show resolved Hide resolved
@fgimenez fgimenez force-pushed the fgimenez/blockchain-provider-tree-state-integration branch from 9a445d0 to 78edbaf Compare July 16, 2024 10:56
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for provider access we should put all of this a separate container type that can be easily shared:

struct InMemoryState {
  blocks: HashMap<Hash, Arc<State>>
  numbers: HashMap<u64, Hash>,
  pending: Option<State>,
}

we need to share access to this with rpc etc. I think we should consider maintaining this as a separate instance in the tree that only tracks the canonical chain. because otherwise we'd need locks around all of these:

 blocks_by_hash: HashMap<B256, ExecutedBlock>,
/// Executed blocks grouped by their respective block number.    blocks_by_number: BTreeMap<BlockNumber, Vec<ExecutedBlock>>,

but maybe that's fine? at least for now

Comment on lines +931 to +932
/// State composed of a block hash, and the receipts, state and transactions root
/// after executing it.
#[derive(Debug, PartialEq, Eq)]
pub struct State {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, what we need to access is:
block,receipts+state at this block

@fgimenez
Copy link
Member Author

we need to share access to this with rpc etc. I think we should consider maintaining this as a separate instance in the tree that only tracks the canonical chain. because otherwise we'd need locks around all of these:

makes sense, will add all this in a followup

@fgimenez fgimenez added this pull request to the merge queue Jul 16, 2024
Merged via the queue into main with commit f930297 Jul 16, 2024
32 checks passed
@fgimenez fgimenez deleted the fgimenez/blockchain-provider-tree-state-integration branch July 16, 2024 14:23
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

Successfully merging this pull request may close these issues.

3 participants