Skip to content

Commit

Permalink
[4844] EngineNewPayload - Add Blob Count validation (hyperledger#5973)
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
  • Loading branch information
Gabriel-Trintinalia authored and NickSneo committed Nov 12, 2023
1 parent 03110b7 commit ab7633f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,13 @@ protected ValidationResult<RpcErrorType> 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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ab7633f

Please sign in to comment.