diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java index 60abf0aa039..c8263450e72 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java @@ -445,6 +445,13 @@ protected ValidationResult validateBlobs( "Payload BlobGasUsed does not match calculated BlobGasUsed"); } } + + if (protocolSpec.getGasCalculator().blobGasCost(transactionVersionedHashes.size()) + > protocolSpec.getGasLimitCalculator().currentBlobGasLimit()) { + return ValidationResult.invalid( + RpcErrorType.INVALID_PARAMS, + String.format("Invalid Blob Count: %d", transactionVersionedHashes.size())); + } return ValidationResult.valid(); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java index e60f74e16c7..8f319c27cf0 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java @@ -51,6 +51,7 @@ import org.hyperledger.besu.ethereum.core.encoding.EncodingContext; import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; +import org.hyperledger.besu.ethereum.mainnet.CancunTargetingGasLimitCalculator; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator; @@ -96,6 +97,9 @@ public void before() { ethPeers, engineCallListener); lenient().when(protocolSpec.getGasCalculator()).thenReturn(new CancunGasCalculator()); + lenient() + .when(protocolSpec.getGasLimitCalculator()) + .thenReturn(mock(CancunTargetingGasLimitCalculator.class)); } @Test