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

Plug ovm codec into ImportOpCommand #12759

Closed

Conversation

lakshya-sky
Copy link
Contributor

Towards #12587

@lakshya-sky
Copy link
Contributor Author

this is incomplete and cuts too many corners. but the bigger issue is reth_providers::DatabaseProvider is tightly coupled with reth_primitives::BlockBody, which doesn't allow using reth_optimism_cli::ovm_file_codec::BlockBody.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

build_import_pipeline fails to compile with the error

error[E0271]: type mismatch resolving `<DatabaseProvider<<<N as NodeTypesWithDB>::DB as Database>::TXMut, N> as BlockWriter>::Body == BlockBody`
   --> crates/optimism/cli/src/commands/build_pipeline.rs:95:14
    |
95  |             .builder()
    |              ^^^^^^^ expected `BlockBody`, found a different `BlockBody`
    |
    = note: `BlockBody` and `BlockBody` have similar names, but are actually distinct types
note: `BlockBody` is defined in crate `reth_primitives`
   --> /home/dkathiriya/projects/reth/crates/primitives/src/block.rs:591:1
    |
591 | pub struct BlockBody {
    | ^^^^^^^^^^^^^^^^^^^^
note: `BlockBody` is defined in the current crate
   --> crates/optimism/cli/src/ovm_file_codec.rs:102:1
    |
102 | pub struct BlockBody {
    | ^^^^^^^^^^^^^^^^^^^^
    = note: required for `BodyStage<TaskDownloader<BlockBody>>` to implement `reth_stages::Stage<DatabaseProvider<<<N as NodeTypesWithDB>::DB as reth_db::Database>::TXMut, N>>`
    = note: required for `OnlineStages<ProviderFactory<N>, ..., ...>` to implement `StageSet<DatabaseProvider<<<N as NodeTypesWithDB>::DB as reth_db::Database>::TXMut, N>>`
    = note: 1 redundant requirement hidden
    = note: required for `DefaultStages<ProviderFactory<...>, ..., ..., ...>` to implement `StageSet<DatabaseProvider<<<N as NodeTypesWithDB>::DB as reth_db::Database>::TXMut, N>>`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume fixing this would require a large refactor of DatabaseProvider?

Copy link
Member

Choose a reason for hiding this comment

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

DatabaseProvider is generic over N: NodeTypes, so should be possible to use with custom N::Primitives, i.e. making a new type

pub struct OvmPrimitives {
    type BlockBody = ovm_file_codec::BlockBody;
    ..
}

and implementing the reth_primitives_traits::BlockBody trait for ovm_file_codec::BlockBody etc. then make a copy of the OpNode called OvmNode, replacing type Primitives = OpPrimitives with type Primitives = OvmPrimitives.

if you could impl these changes now, it's not sure if it will be able to take effect right away, since the complete integration of generic data primitives is pending #12454. however this pr will definitely be merged once it compiles.

Copy link
Contributor Author

@lakshya-sky lakshya-sky Nov 27, 2024

Choose a reason for hiding this comment

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

I was thinking maybe move ovm_file_codec::{Block, BlockBody, *} to reth_optimism_primitives and update OpPrimitives itself with the new primitives. That way we won't have to introduce OvmNode and OvmPrimitives?

Copy link
Member

Choose a reason for hiding this comment

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

OpNode is EVM since the bedrock hardfork, that's why we are importing the OVM part of the op mainnet chain by this command as opposed to the traditional way: syncing from peers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it

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.

Since BlockFileCodec was made generic over Block, I think it makes more sense to pass the Block in the ovm codec file to the original BlockFileCodec, does that make sense?

@lakshya-sky
Copy link
Contributor Author

Since BlockFileCodec was made generic over Block, I think it makes more sense to pass the Block in the ovm codec file to the original BlockFileCodec, does that make sense?

You're right and I did that on my first attempt. But ends up on the same error as this one.

@lakshya-sky
Copy link
Contributor Author

@emhane the scope of this pr is huge compared to what I thought. Despite adding OvmNode and OvmPrimitives it wouldn't compile. Each stage needs to be made generic over primitives then only OvmCodec could be used. I think I'll close this for now and comeback in future.

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.

2 participants