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: add BuiltPayload associated type to EngineTypes #6028

Merged
merged 12 commits into from
Jan 15, 2024
Merged

Conversation

Rjected
Copy link
Member

@Rjected Rjected commented Jan 11, 2024

Adds a BuiltPayload associated type and trait to EngineTypes

closes #6026

@Rjected Rjected added C-enhancement New feature or request A-block-building Related to block building labels Jan 11, 2024
@Rjected Rjected marked this pull request as ready for review January 11, 2024 23:02
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.

nice, this is almost exactly what we want

Comment on lines +27 to +34
/// Converts the type into the response expected by `engine_getPayloadV1`
fn into_v1_payload(self) -> ExecutionPayloadV1;

/// Converts the type into the response expected by `engine_getPayloadV2`
fn into_v2_payload(self) -> ExecutionPayloadEnvelopeV2;

/// Converts the type into the response expected by `engine_getPayloadV2`
fn into_v3_payload(self) -> ExecutionPayloadEnvelopeV3;
Copy link
Collaborator

Choose a reason for hiding this comment

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

these are fine for now, but perhaps we want to reconsider this eventually and instead just require that the type is Serialize or can be converted into serde_Value

Copy link
Member Author

Choose a reason for hiding this comment

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

agree, it at least just needs to work well with get_payload in EngineApi. I like that the outputs are typed in EngineApi currently. But yeah, we may need to change this


/// Message type for the [PayloadBuilderService].
pub enum PayloadServiceCommand<T> {
pub enum PayloadServiceCommand<A, P> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we use EngineT: EngineTypes here?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah we can, just added

Gen::Job: PayloadJob<PayloadAttributes = Engine::PayloadBuilderAttributes>,
Gen::Job: PayloadJob<
PayloadAttributes = Engine::PayloadBuilderAttributes,
BuiltPayload = Engine::BuiltPayload,
Copy link
Collaborator

@mattsse mattsse Jan 11, 2024

Choose a reason for hiding this comment

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

I think we want:

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

this way the service can support any generator that creates jobs with a Payload that can be converted to the configured Engine::BuiltPayload.

I realize that this breaks the Arc wrapper, so I think we should remove the Arc from the Job trait resolve function signature.
cloning a payload isn't a big deal anyway and a job can take the payload on resolve

Copy link
Member Author

Choose a reason for hiding this comment

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

alright, I had to get rid of pretty much all of the Arc, might be possible to make it work again with best_payload, but the bounds are now Into<Engine::BuiltPayload>

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.

this is great!

last nits re clone calls

Comment on lines +18 to +19
/// Initializes the payload with the given initial block.
fn new(id: PayloadId, block: SealedBlock, fees: U256) -> Self;
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, I think this is fine now, but this effectively restricts how the built payload looks like.

I see that we're using this as the fallback for empty payloads, which is a default.

let's track this separately, so we can improve this a bit.
perhaps it should be the job's responsibility to create an empty payload

crates/rpc/rpc-engine-api/src/engine_api.rs Outdated Show resolved Hide resolved
crates/rpc/rpc-engine-api/src/engine_api.rs Outdated Show resolved Hide resolved
@Rjected Rjected added this pull request to the merge queue Jan 15, 2024
Merged via the queue into main with commit 685d1c5 Jan 15, 2024
27 checks passed
@Rjected Rjected deleted the dan/built-payload branch January 15, 2024 17:20
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce EngineTypes::BuiltPayload
2 participants