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(evm-ethereum): add BlockAccessListExecutor #10849

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

Rjected
Copy link
Member

@Rjected Rjected commented Sep 11, 2024

Introduces a new executor type that includes the CacheState in the returned BundleState during execution. This should make it easier to integrate the block executor into e.g. debug_executionWitness without changing the normal execution code paths.

@Rjected Rjected added C-enhancement New feature or request A-execution Related to the Execution and EVM labels Sep 11, 2024
@Rjected Rjected force-pushed the dan/add-block-access-list-executor branch from 6825a17 to 4e89479 Compare September 11, 2024 20:05
Comment on lines 430 to 431
for (address, account) in self.executor.state.cache.accounts {
if let Entry::Vacant(entry) = bundle_state.state.entry(address) {
Copy link
Member

@rkrasiuk rkrasiuk Sep 11, 2024

Choose a reason for hiding this comment

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

bundle state only stores changed slots. so if account or some slots were changed, accessed unchanged slots will not be written back to bundle state

Copy link
Member Author

Choose a reason for hiding this comment

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

ah right, added a match here with the occupied branch adding unchanged slots, lmk what you think

// NOTE: we need to merge keep the reverts for the bundle retention
self.executor.state.merge_transitions(BundleRetention::Reverts);

// now, ensure each account from the state is included in the bundle state
Copy link
Contributor

Choose a reason for hiding this comment

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

Below code basically need to be implemented again in crates/optimism/evm/src/execute.rs as well, not a big deal, but wonder if we can extract them somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, let me think about it, it might be possible to make this reusable across both

Copy link
Member Author

Choose a reason for hiding this comment

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

Couldn't figure out something nice, will just copy the implementation since it's one method and it's simple

@@ -384,6 +390,71 @@ where
}
}

/// An executor that retains all cache state from execution in its bundle state.
#[derive(Debug)]
pub struct BlockAccessListExecutor<EvmConfig, DB> {
Copy link
Contributor

@0x00101010 0x00101010 Sep 11, 2024

Choose a reason for hiding this comment

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

Currently we're reading from node components to get the block_executor_provider out, if we're gonna have another executor, are we ok with adding another method maybe called access_list_executor?

On the other side, here's the aforementioned version of code that changes fn execute(self, xxx) to fn execute(&mut self, xxx): https://github.com/paradigmxyz/reth/pull/10736/files#diff-eb5f2c91d277e8bdf71850182110f34c23bcb1d70a675f570572f18af090a1d1R33

It works, just need to change bunch of places to let mut executor which I'm not sure if we're ok with

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I think we will add another associated type and method to BlockExecutorProvider

Copy link
Member Author

Choose a reason for hiding this comment

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

#10868 tracking here

@Rjected
Copy link
Member Author

Rjected commented Sep 12, 2024

Would like review on this impl, before I copy it over to optimism as well

Copy link
Contributor

@0x00101010 0x00101010 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@rkrasiuk rkrasiuk left a comment

Choose a reason for hiding this comment

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

lgtm

@Rjected Rjected added this pull request to the merge queue Sep 13, 2024
Merged via the queue into main with commit 3012018 Sep 13, 2024
34 checks passed
@Rjected Rjected deleted the dan/add-block-access-list-executor branch September 13, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-execution Related to the Execution and EVM C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants