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
Tracked by #12578
klkvr opened this issue Nov 13, 2024 · 3 comments · May be fixed by #12648
Open
Tracked by #12578

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

klkvr opened this issue Nov 13, 2024 · 3 comments · May be fixed by #12648
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?

@klkvr
Copy link
Collaborator Author

klkvr commented Nov 18, 2024

hey @0xriazaka do you need any pointers for this?

This was referenced Nov 18, 2024
@0xriazaka
Copy link
Contributor

hey @0xriazaka do you need any pointers for this?

check #12648

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

Successfully merging a pull request may close this issue.

2 participants