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

[4844] Add excessDataGas and dataGasUsed validation to EngineNewPayloadV3 #5683

Conversation

Gabriel-Trintinalia
Copy link
Contributor

PR description

Add excessDataGas and dataGasUsed validation to EngineNewPayloadV3

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
@Gabriel-Trintinalia Gabriel-Trintinalia changed the title Add excessDataGas and dataGasUsed validation to EngineNewPayloadV3 [4844] Add excessDataGas and dataGasUsed validation to EngineNewPayloadV3 Jul 7, 2023
@Gabriel-Trintinalia Gabriel-Trintinalia marked this pull request as ready for review July 7, 2023 06:14
@Gabriel-Trintinalia Gabriel-Trintinalia marked this pull request as draft July 7, 2023 06:35
Copy link
Contributor

@siladu siladu left a comment

Choose a reason for hiding this comment

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

LGTM - copy of suggestions

Comment on lines 117 to 120
ValidationResult<NewPayloadValidationResult> forkValidationResult =
validateForkSupported(reqId, blockParam);
if (!forkValidationResult.isValid()) {
return new JsonRpcErrorResponse(reqId, UNSUPPORTED_FORK);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an improvement in readability IMO and good reuse of the ValidationResult. Not really for this PR, but wonder if we should move ValidationResult to a more generic package since it's already being used outside of the ethereum.mainnet

protected Optional<JsonRpcResponse> validateTransactions(
final EnginePayloadParameter blockParam,
final Object reqId,
protected ValidationResult<NewPayloadValidationResult> validateBlobs(
Copy link
Contributor

Choose a reason for hiding this comment

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

more accurate name 👍

final Optional<BlockHeader> maybeParentHeader,
final Optional<List<String>> maybeVersionedHashParam,
final ProtocolSpec protocolSpec) {
return ValidationResult.valid();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Since Cancun will be the new default, I think it is preferable to put the actual blob validation code in the Abstract class and override with valid() for V1 and V2.

That means when we no longer want to support V2, it's a simple delete of EngineNewPayloadV2 class without any refactoring.

For example, this was done for V1 with these two overrides https://github.com/hyperledger/besu/blob/main/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV1.java#L44-L52
(indeed, we could probably delete those V1 classes now that Shanghai is live)

validateTransactions(blockParam, reqId, transactions, maybeVersionedHashParam);
if (transactionValidationResult.isPresent()) {
return transactionValidationResult.get();
ValidationResult<NewPayloadValidationResult> transactionValidationResult =
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ValidationResult<NewPayloadValidationResult> transactionValidationResult =
ValidationResult<NewPayloadValidationResult> blobValidationResult =

}
} else {
if (payloadParameter.getDataGasUsed() != null
|| payloadParameter.getExcessDataGas() != null) {
return Optional.of(new JsonRpcErrorResponse(reqId, UNSUPPORTED_FORK));
return ValidationResult.invalid(NewPayloadValidationResult.INVALID_NEW_PAYLOAD_PARAMS);
Copy link
Contributor

Choose a reason for hiding this comment

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

There's been a semantic change from UNSUPPORTED_FORK to INVALID_NEW_PAYLOAD_PARAMS here? Just checking it's not copy/paste error.

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
@Gabriel-Trintinalia Gabriel-Trintinalia marked this pull request as ready for review July 10, 2023 08:52
@Gabriel-Trintinalia Gabriel-Trintinalia merged commit d3faf00 into hyperledger:4844-devnet-5b Jul 10, 2023
5 checks passed
jflo pushed a commit to jflo/besu that referenced this pull request Jul 20, 2023
…adV3 (hyperledger#5683)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
@Gabriel-Trintinalia Gabriel-Trintinalia deleted the add-excess-data-gas-validation branch September 20, 2023 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants