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

Enable ResolvePayloadFuture to be generic to the PayloadJob trait #5452

Closed
loocapro opened this issue Nov 15, 2023 · 15 comments
Closed

Enable ResolvePayloadFuture to be generic to the PayloadJob trait #5452

loocapro opened this issue Nov 15, 2023 · 15 comments
Labels
A-block-building Related to block building C-enhancement New feature or request M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity

Comments

@loocapro
Copy link
Contributor

Describe the feature

I am using the reth Payload crate to modify the default behaviour of engine Api payload jobs. I am implementing the PayloadJobGenerator passing my own PayloadJob.

Currently the PayloadJob::resolve()returns a ResolvePayloadFuture which is tied to the BuiltPayload reth type currently consumed by the engine API.

I 'd love that the ResolvePayloadFuture could be generic so that I could return a BuiltPayload and some other parameter that I am calculating from my PayloadJobs.

@mattsse do you have any better way to achieve this?

I'd love to pick this up myself.

Additional context

No response

@loocapro loocapro added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Nov 15, 2023
@mattsse
Copy link
Collaborator

mattsse commented Nov 16, 2023

how are you using your type?

because, by default, the generator is controlled by the service:

pub struct PayloadBuilderService<Gen>
where
Gen: PayloadJobGenerator,
{

which is wired to the engine API

@loocapro
Copy link
Contributor Author

loocapro commented Nov 16, 2023

how are you using your type?

because, by default, the generator is controlled by the service:

pub struct PayloadBuilderService<Gen>
where
Gen: PayloadJobGenerator,
{

which is wired to the engine API

I am just implementing a custom generator, with a custom job, and spawning a custom payload service, but still using the reth PayloadService from the payload crate.

Then I interact with the reth payload service via the payload handle resolve function, which unfortunately can only return a BuiltPayload future.

@mattsse
Copy link
Collaborator

mattsse commented Nov 16, 2023

gotcha,
so currently this format is fixed, but I think we actually want this to be generic, because optimism would also benefit from this.

I need to think about this a bit more because it would introduce a few more changes wrt generics

@loocapro
Copy link
Contributor Author

Okk, please let me know. If it's not a huge change i d like to take it.

@loocapro
Copy link
Contributor Author

loocapro commented Nov 21, 2023

Hi @mattsse sorry to hassle you, have you got any news on this?

Currently I have solved it by duplicating the PayloadService code but I am a bit worried about future conflicts.

@mattsse
Copy link
Collaborator

mattsse commented Nov 21, 2023

this would require significant changes across the codebase and is more or less blocked by this #5501

perhaps we can at least introduce a new associated type to the trait for now and require that it is Into<BuiltPayload>

But I also think you should be able to work around this for your use case with some extra code bypassing the payload handle, which doesn't have generics

@loocapro
Copy link
Contributor Author

bypassing the payload handle, which doesn't have generics

Thanks a lot Matt. Could you please show me how would you by pass the payload handle?

@idatsy
Copy link
Contributor

idatsy commented Nov 26, 2023

Would this be resolved by just making the PayloadBuilderHandle::new pub so that extending spawn_payload_builder_service lets you roll your own builder logic consuming the to_service channel directly?

That or make PayloadBuilderHandle a pub trait where users can impl their own resolve, best_payload, payload_attributes, send_new_payload and new_payload?

@mattsse
Copy link
Collaborator

mattsse commented Nov 26, 2023

Would this be resolved by just making the PayloadBuilderHandle::new pub so that extending

that would def make this possible, yeah

let's do that first.

then I think we want the return type of the Future Also Into<Payload>, though we'd need to break that again eventually

@idatsy
Copy link
Contributor

idatsy commented Nov 26, 2023

Would this be resolved by just making the PayloadBuilderHandle::new pub so that extending

that would def make this possible, yeah

let's do that first.

then I think we want the return type of the Future Also Into<Payload>, though we'd need to break that again eventually

Awesome, I'll PR that for your right away, will drastically simplify my (and I assume others) payload building logic :)

@idatsy
Copy link
Contributor

idatsy commented Nov 26, 2023

Would this be resolved by just making the PayloadBuilderHandle::new pub so that extending

that would def make this possible, yeah

let's do that first.

then I think we want the return type of the Future Also Into<Payload>, though we'd need to break that again eventually

I left out the Into<Payload> change as I'm not sure exactly what you have in mind there: #5578

@loocapro
Copy link
Contributor Author

Thanks @idatsy.

This is not going to solve my issue as I am using the payload crate (generator + service + handle) and I like how it is structured. I don't even think that new function should be exposed to the outside as it could expose the internal implementation to the outside world and it would totally miss the purpose of encapsulation.

@mattsse I love the idea of restricting the ResolvePayloadFuture to Into<Payload>, will try to get a pr up soon.

Copy link
Contributor

This issue is stale because it has been open for 21 days with no activity.

@github-actions github-actions bot added the S-stale This issue/PR is stale and will close with no further activity label Dec 19, 2023
@onbjerg onbjerg added A-block-building Related to block building and removed S-needs-triage This issue needs to be labelled S-stale This issue/PR is stale and will close with no further activity labels Dec 19, 2023
Copy link
Contributor

This issue is stale because it has been open for 21 days with no activity.

@github-actions github-actions bot added the S-stale This issue/PR is stale and will close with no further activity label Jan 10, 2024
@mattsse mattsse added M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity and removed S-stale This issue/PR is stale and will close with no further activity labels Jan 10, 2024
@mattsse
Copy link
Collaborator

mattsse commented Jan 17, 2024

marking this as completed because this is now possible:

<Gen::Job as PayloadJob>::BuiltPayload: Into<Engine::BuiltPayload>,

/// Represents the built payload type that is returned to the CL.
type BuiltPayload: BuiltPayload + std::fmt::Debug;

@mattsse mattsse closed this as completed Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-block-building Related to block building C-enhancement New feature or request M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity
Projects
Archived in project
Development

No branches or pull requests

4 participants