-
Notifications
You must be signed in to change notification settings - Fork 283
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
starts engine_preparePayload
and engine_getPayload
API call implementation
#4371
Conversation
introduces Duty preparation uses Duty preparation in BlockProductionDuty to handle the call to the execution engine to prepare the block starts extending other required classes to be able to call the new method
engine_preparePayload
API call (#4346)
validator/coordinator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactory.java
Outdated
Show resolved
Hide resolved
public SafeFuture<Void> prepareDuty() { | ||
executionPayloadRequestId = | ||
UInt64.fromLongBits(SecureRandomProvider.publicSecureRandom().nextLong()); | ||
return validatorApiChannel.prepareExecutionPayload(slot, executionPayloadRequestId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this field initialization to the constructor and make it final
Does it make sense using random()
for generating requestId
here? Wouldn't a simple counter be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the idea was to avoid any potential concurrency issues (can they happen here?) and generate different id in case of duty prepared twice (late consensus block arrival). In the latter I assumed we need to refresh the requestId
(going to change it to payloadId
as per latest HackMD update).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I follow the logic now... prepareDuty()
is designed to be called more than once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest using AtomicInteger
here even if it's a static field to generate rather than random. There's no reason we need to be using a secure random at this point.
I do wonder if we should be using the same requestId when we resend prepareDuty though - otherwise we're leaving the previous "prepare" call hanging and it will never be cancelled or followed by "get". Might be a question for the API spec as much as anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved to AtomicLong
and made executionPayloadId
constant at every preparation
engine_preparePayload
API call implementation
BTW, should the |
oh, I see |
It's not necessarily a chain reorg that triggers calling prepare again but any head update. The most common case will be that we're proposing at slot X and the block at X-1 is received late. That's a normal head update to fill the empty slot but it still changes the parent root of the block we'll create so need to send a new prepare call. You should get another call to |
validator/client/src/main/java/tech/pegasys/teku/validator/client/PendingDuties.java
Outdated
Show resolved
Hide resolved
validator/coordinator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactory.java
Outdated
Show resolved
Hide resolved
...r/coordinator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java
Outdated
Show resolved
Hide resolved
engine_preparePayload
API call implementationengine_preparePayload
and engine_getPayload
API call implementation
@ajsutton a unit test is still failing i guess not related to current PR ( btw I was trying to focus on preparePayload only but I ended up starting getPayload as well (they are quite related) |
47b5a9d
to
be2a5b1
Compare
…reExecutionPayload (Consensys#4346)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
changelog:
slot
aspayloadId