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: integrate HeaderValidator + make FileClient generic over block #12681

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

Conversation

klkvr
Copy link
Collaborator

@klkvr klkvr commented Nov 19, 2024

Integrates HeaderValidator from #12648 into ReverseHeadersDownloader. This required a small helper for casting traits (AsHeaderValidator)

Additionaly makes FileClient generic over block getting us closer to abstraction of CLI

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.

scope has grown to #12475, conflicts with #12521 @TropicalDog17

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.

lgtm, one q

@@ -46,7 +46,9 @@ impl<'a> PostExecutionInput<'a> {

/// Consensus is a protocol that chooses canonical chain.
#[auto_impl::auto_impl(&, Arc)]
pub trait Consensus<H = Header, B = BlockBody>: HeaderValidator<H> + Debug + Send + Sync {
pub trait Consensus<H = Header, B = BlockBody>:
AsHeaderValidator<H> + HeaderValidator<H> + Debug + Send + Sync
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, isn't this AsHeaderValidator<H> bound redundant if AsHeaderValidator is impl for all HeaderValidator

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

doesn't compile without it, unsure why exactly, probably has something to do with the fact that we are invoking this on Arc impl

error[E0599]: no method named `as_header_validator` found for struct `Arc<dyn reth_consensus::Consensus>` in the current scope
   --> crates/stages/stages/src/sets.rs:250:35
    |
250 |                 consensus.clone().as_header_validator(),
    |                                   ^^^^^^^^^^^^^^^^^^^ method not found in `Arc<dyn Consensus>`
    |
   ::: /Users/klkvr/github/reth/crates/consensus/consensus/src/lib.rs:150:8
    |
150 |     fn as_header_validator<'a>(self: Arc<Self>) -> Arc<dyn HeaderValidator<H> + 'a>
    |        -------------------
    |        |
    |        the method is available for `Arc<Arc<dyn reth_consensus::Consensus>>` here
    |        the method is available for `Arc<&Arc<dyn reth_consensus::Consensus>>` here
    |
help: consider wrapping the receiver expression with the appropriate type
    |
250 |                 Arc::new(consensus.clone()).as_header_validator(),
    |                 +++++++++                 +
help: consider wrapping the receiver expression with the appropriate type
    |
250 |                 Arc::new(&consensus.clone()).as_header_validator(),

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