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

Fcu verify payload attributes #3837

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Additions and Improvements
- \[EXPERIMENTAL\] Add checkpoint sync `--sync-mode="X_CHECKPOINT"` [#3849](https://github.com/hyperledger/besu/pull/3849)
- Added verification of payload attributes in ForkchoiceUpdated [#3837](https://github.com/hyperledger/besu/pull/3837)

### Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,8 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
forkChoice.getFinalizedBlockHash(),
forkChoice.getSafeBlockHash());

if (optionalPayloadAttributes.isPresent()) {
debugLambda(
LOG,
new StringBuilder("timestamp: ")
.append(optionalPayloadAttributes.get().getTimestamp())
.append(", prevRandao: ")
.append(optionalPayloadAttributes.get().getPrevRandao().toHexString())
.append(", suggestedFeeRecipient: ")
.append(optionalPayloadAttributes.get().getSuggestedFeeRecipient().toHexString())
.toString());
} else {
debugLambda(LOG, "Payload attributes are null");
}
optionalPayloadAttributes.ifPresentOrElse(
this::logPayload, () -> LOG.debug("Payload attributes are null"));

if (!isValidForkchoiceState(
forkChoice.getSafeBlockHash(), forkChoice.getFinalizedBlockHash(), newHead.get())) {
Expand Down Expand Up @@ -173,6 +162,15 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
Optional.empty()));
}

private void logPayload(final EnginePayloadAttributesParameter payloadAttributes) {
debugLambda(
LOG,
"timestamp: {}, prevRandao: {}, suggestedFeeRecipient: {}",
payloadAttributes::getTimestamp,
() -> payloadAttributes.getPrevRandao().toHexString(),
() -> payloadAttributes.getPrevRandao().toHexString());
daniellehrner marked this conversation as resolved.
Show resolved Hide resolved
}

private boolean isValidForkchoiceState(
final Hash safeBlockHash, final Hash finalizedBlockHash, final BlockHeader newBlock) {
Optional<BlockHeader> maybeFinalizedBlock = Optional.empty();
Expand Down