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

refactor!: streamline OpBlockExecutionError error type to replace a hard-coded BlockExecutionError #13696

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

chungquantin
Copy link
Contributor

@chungquantin chungquantin commented Jan 7, 2025

Current issue

Adding a variant and removing the conversion brings complexities everywhere BlockExecutionError hard-coded in the associated type. Takes BlockExecutionStrategyFactory, BatchExecutor or BlockExecutorProvider. And the conversion between OpBlockExecutionError -> BlockExecutionError is still required in some parts of the code.

Requires opinions from the core devs before taking extra steps to finish this PR.

Link to the issue: #13644
cc: @emhane

@chungquantin chungquantin changed the title refactor: add Eth variant to OpBlockExecutionError refactor: add Eth variant to OpBlockExecutionError Jan 7, 2025
Copy link
Member

@emhane emhane left a comment

Choose a reason for hiding this comment

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

good under way! removing the hardcoded F: BlockExecutionStrategyFactory<Error = BlockExecutionError> should allow you to make progress to get it compiling. aware this pr may grow large.

crates/evm/src/execute.rs Outdated Show resolved Hide resolved
crates/optimism/evm/src/error.rs Outdated Show resolved Hide resolved
@@ -209,7 +209,7 @@ impl AppendableChain {
let block_hash = block.hash();
let block = block.unseal();

let state = executor.execute(&block)?;
let state = executor.execute(&block).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

we can't panic here. the return type of this method must change to
Result<(ExecutionOutcome, Option<TrieUpdates>), E::Error>.

Copy link
Contributor Author

@chungquantin chungquantin Jan 16, 2025

Choose a reason for hiding this comment

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

Thank for your suggestion. This is made on purpose for me to test my implementation. Currently I got blocked by the validate_block_post_execution that throws ConsensusError. I am thinking adding the type constraint From<ConsensusError> but it will lead to other issues.

Edit: Currently got it resolved but still have a lot of things to consider for the overall design. e.g. BlockErrorKind accepts BlockExecutionError. Hence, we would either streaming and converting the error type back to BlockExecutionError or redesign BlockErrorKind to accept generic Error type.

Copy link
Member

Choose a reason for hiding this comment

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

great design ideas, let's choose

(i) add trait bound: From, then impl the conversion From<ConsensusError> for OpBlockExecutionError which would put the consensus error inside the OpBlockExecutionError::Eth variant
(ii) redesign BlockErrorKind to accept generic Error type

Copy link
Member

Choose a reason for hiding this comment

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

This entire crate was actually removed, I think resolving merge conflicts with main will be the most productive thing to do here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @Rjected! Rebased.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great design ideas, let's choose

(i) add trait bound: From, then impl the conversion From<ConsensusError> for OpBlockExecutionError which would put the consensus error inside the OpBlockExecutionError::Eth variant (ii) redesign BlockErrorKind to accept generic Error type

Went further with the second option and seems like it is doable. Question for this approach would be which level of code that we want to convert back OpBlockExecutionError -> BlockExecutionError or we will streamline the OpBlockExecutionError the whole way to the Stage API level?

If the later is what we want, do you think it makes sense if Provider type can accept the Error type for block execution errors?

@chungquantin chungquantin requested a review from klkvr as a code owner January 16, 2025 16:19
@Rjected
Copy link
Member

Rjected commented Jan 16, 2025

This should be rebased to resolve all the merge conflicts, it might become simpler as the legacy tree etc have been removed

@Rjected
Copy link
Member

Rjected commented Jan 17, 2025

Sorry, will have to be rebased or merged again once #13839 is merged, since nightly clippy is broken right now

@chungquantin
Copy link
Contributor Author

Sorry, will have to be rebased or merged again once #13839 is merged, since nightly clippy is broken right now

That's ok, I don't see it as a breaking change.

@chungquantin chungquantin changed the title refactor: add Eth variant to OpBlockExecutionError refactor: streamline OpBlockExecutionError error type to replace a hard-coded BlockExecutionError Jan 17, 2025
@chungquantin chungquantin changed the title refactor: streamline OpBlockExecutionError error type to replace a hard-coded BlockExecutionError refactor!: streamline OpBlockExecutionError error type to replace a hard-coded BlockExecutionError Jan 17, 2025
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