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

Extract Header-only methods of Consensus to a separate trait #12522

Open
klkvr opened this issue Nov 13, 2024 · 1 comment
Open

Extract Header-only methods of Consensus to a separate trait #12522

klkvr opened this issue Nov 13, 2024 · 1 comment
Assignees
Labels
A-sdk Related to reth's use as a library C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@klkvr
Copy link
Collaborator

klkvr commented Nov 13, 2024

Describe the feature

With #12451 Consensus is now generic over header and body

pub trait Consensus<H = Header, B = BlockBody>: Debug + Send + Sync {

However, in components which only know the header type we can't provide Consensus with Body generic, e.g

consensus: Arc<dyn Consensus<H::Header>>,

To address this, we'll need a separate trait which is alike Consensus but only operates on headers.

Steps:

  1. Inroduce trait trait HeaderValidator<H = Header> and move Consensus methods which only need header to it. Those include validate_header, validate_header_against_parent, validate_header_range, validate_header_with_total_difficulty
  2. Inroduce bound Consensus<H = Header, B = Body>: HeaderValidator<H>
  3. Fix trait impls and import HeaderValidator where needed

Additional context

No response

@klkvr klkvr added A-sdk Related to reth's use as a library C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started S-needs-triage This issue needs to be labelled labels Nov 13, 2024
@klkvr klkvr removed the S-needs-triage This issue needs to be labelled label Nov 13, 2024
@0xriazaka
Copy link
Contributor

Can i work on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sdk Related to reth's use as a library C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Status: Todo
Development

No branches or pull requests

2 participants