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

Log blob count when importing a block via Engine API #6466

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
### Additions and Improvements
- Add `OperationTracer.tracePrepareTransaction`, where the sender account has not yet been altered[#6453](https://github.com/hyperledger/besu/pull/6453)
- Improve the high spec flag by limiting it to a few column families [#6354](https://github.com/hyperledger/besu/pull/6354)

- Log blob count when importing a block via Engine API [#6466](https://github.com/hyperledger/besu/pull/6466)

### Bug fixes
- Fix the way an advertised host configured with `--p2p-host` is treated when communicating with the originator of a PING packet [#6225](https://github.com/hyperledger/besu/pull/6225)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,12 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
return respondWithInvalid(reqId, blockParam, null, getInvalidBlockHashStatus(), errorMessage);
}

final var blobTransactions =
transactions.stream().filter(transaction -> transaction.getType().supportsBlob()).toList();

ValidationResult<RpcErrorType> blobValidationResult =
validateBlobs(
transactions,
blobTransactions,
newBlockHeader,
maybeParentHeader,
maybeVersionedHashes,
Expand Down Expand Up @@ -302,7 +305,8 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
final BlockProcessingResult executionResult = mergeCoordinator.rememberBlock(block);

if (executionResult.isSuccessful()) {
logImportedBlockInfo(block, (System.currentTimeMillis() - startTimeMs) / 1000.0);
logImportedBlockInfo(
block, blobTransactions.size(), (System.currentTimeMillis() - startTimeMs) / 1000.0);
return respondWith(reqId, blockParam, newBlockHeader.getHash(), VALID);
} else {
if (executionResult.causedBy().isPresent()) {
Expand Down Expand Up @@ -380,10 +384,6 @@ JsonRpcResponse respondWithInvalid(
invalidStatus, latestValidHash, Optional.of(validationError)));
}

protected boolean requireTerminalPoWBlockValidation() {
return false;
}

protected EngineStatus getInvalidBlockHashStatus() {
return INVALID;
}
Expand All @@ -396,15 +396,12 @@ protected ValidationResult<RpcErrorType> validateParameters(
}

protected ValidationResult<RpcErrorType> validateBlobs(
final List<Transaction> transactions,
final List<Transaction> blobTransactions,
final BlockHeader header,
final Optional<BlockHeader> maybeParentHeader,
final Optional<List<VersionedHash>> maybeVersionedHashes,
final ProtocolSpec protocolSpec) {

var blobTransactions =
transactions.stream().filter(transaction -> transaction.getType().supportsBlob()).toList();

final List<VersionedHash> transactionVersionedHashes = new ArrayList<>();
for (Transaction transaction : blobTransactions) {
var versionedHashes = transaction.getVersionedHashes();
Expand Down Expand Up @@ -489,7 +486,7 @@ private Optional<List<VersionedHash>> extractVersionedHashes(
.collect(Collectors.toList()));
}

private void logImportedBlockInfo(final Block block, final double timeInS) {
private void logImportedBlockInfo(final Block block, final int blobCount, final double timeInS) {
final StringBuilder message = new StringBuilder();
message.append("Imported #%,d / %d tx");
final List<Object> messageArgs =
Expand All @@ -503,9 +500,10 @@ private void logImportedBlockInfo(final Block block, final double timeInS) {
message.append(" / %d ds");
messageArgs.add(block.getBody().getDeposits().get().size());
}
message.append(" / base fee %s / %,d (%01.1f%%) gas / (%s) in %01.3fs. Peers: %d");
message.append(" / %d blobs / base fee %s / %,d (%01.1f%%) gas / (%s) in %01.3fs. Peers: %d");
messageArgs.addAll(
List.of(
blobCount,
block.getHeader().getBaseFee().map(Wei::toHumanReadableString).orElse("N/A"),
block.getHeader().getGasUsed(),
(block.getHeader().getGasUsed() * 100.0) / block.getHeader().getGasLimit(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ public String getName() {
return RpcMethod.ENGINE_NEW_PAYLOAD_V1.getMethodName();
}

@Override
protected boolean requireTerminalPoWBlockValidation() {
return true;
}

@Override
protected EngineStatus getInvalidBlockHashStatus() {
return INVALID_BLOCK_HASH;
Expand Down